[WT-support] ESM and introduction to scripting

Tõnno Vähk Tonno.Vahk at gildbankers.com
Sun Aug 9 20:34:40 CEST 2009


:) did anyone get this? I am afraid 99% of the users will not be able to comprehend this and will just rely on whatever is provided by the program. Thus I hope you agree that the default version (even if only one) should be suitable for most and bug-free.

1. Can you please provide the logic of current ESM. I did not find it anywhere. In RUN mode is it:
-when callsign field empty then F1
-when callsign field filled then INSERT and every next press of ENTER is PLUS

Is that it?

2. I was too sleepy last night to figure out why AUTOSEND and ESM did not function together and I got second INSERT. Of course the ESM did not take the AUTOSEND INSERT into account. Can you make it understand when AUTOSEND has been activated and have next ENTER yield TU message? Without this I can forget about ESM at all as it is not usable at all as AUTOSEND is elementary.

3. It would be really great to have two options for ESM (as I understand N1MM provides this):

a. Logic as described above. It does not matter where the cursor is but the next ESM message after Exchange is always TU.
b. Logic according to cursor. When on Callsign field and it is not empty then INSERT and when on Exchange field then always PLUS.

The latter is what P3F suggested I understand and at the first thought it sounded sensible but after thinking about it I prefer the first (current) solution for most occasions. Why?

Say we have CQWW CW. I always use $SPACEBAR to send cursor to exchange field after INSERT is activated. Now there are 2 reasons cursor can get back to Callsign field: 1. Accidentally 2. Intentionally when I go back to correct callsign. In both cases I don't want to repeat the exchange but I want to send PLUS! Thus making it obligatory to make sure I will be on the Exchange field is not efficient.

When I want to send Exchange again (out of normal rhythm) then I would rather use INSERT (or whatever designated key I have for that) than press first SPACEBAR to return to the callsing field and then press Enter. Not efficient! 

Thus in this case I never benefit from P3F solution.

But in SSB contests it is sometimes different as Exchange cannot be sent by ESM at all (WPX) and then there are two ways: to have the ESM message linked to cursor position OR enable user to change the logic (sequence) by cutting off Exchange. Meaning when callsign field empty then Enter sends CQ, when filled then always TU (wherever the cursor is).


To conclude:

My suggestion is that leave the current logic, fix the AUTOSEND bug and enable user to cut off Exchange step from ESM (or let it to be replaced by CR$ or $SPACEBAR (the best option))

That would be minimum program in my mind. Of course enabling user to do little more like specifying keys used for ESM and also defining ESM message as simply $CR would be really great. Introducing the ESM2 with cursor defined messages would be next thing to wish then.

Look forward to read your answers.

73
Tonno
ES5TV

p.s. I noticed a very interesting idea. To introduce a new variable: $CURSORTOEXCHANGEFIELD (shorter version welcome:). Putting that into INSERT instead of $SPACEBAR would eliminate the cursor toggling back and force when Exchange is being sent more than once. You WANT THE CURSOR TO STICK TO EXCHANGE FIELD AND NOT COME BACK. The same applies to S&P where I have defined calling message as $MYCALL $SPACEBAR. Then you are ready to write Exchange after calling without further key strokes. Now if you don't get the guy with first call then cursor starts toggling. Using the proposed variable instead of $SPACEBAR would solve the problem and make the cursor stick to correct field. Doable??? 


-----Original Message-----
From: support-bounces at win-test.com [mailto:support-bounces at win-test.com] On Behalf Of Laurent HAAS - F6FVY
Sent: Sunday, August 09, 2009 11:42 AM
To: win-test support
Subject: [WT-support] ESM and introduction to scripting

Hi !

We read with much attention all comments regarding the ESM 
implementation in Win-Test v4, and we must confess we were ready to read 
them. Actually, they even came much later than we thought ;-)

Because ESM is such a personal feeling to everyone of us, we decided to 
make an additional effort to leave to the user the full freedom to 
customize it. In other words, you will be able to modify _YOURSELF_ the 
way the ESM mode is handled by Win-Test and tailor it to fit EXACTLY 
your needs.

Having said that, we are not going to touch the default behavior of ESM 
as it is built in WT. As it stands, it is a simple implementation that 
serves as both as a reference and as a starting point for someone who 
wants more advanced behavior.

The customization is achieved using a scripting language. The scripting 
language gives, in our opinion, the unique possibility to achieve 
dynamic tasks in WT. And it also offers the possibility to share your 
work with other WT users who don't have time or skill to build it.

The ESM is the first area in Win-Test where the scripting language Lua 
is used. The ESM function itself is a Lua script, embedded in Win-Test 
(not modifiable). But, it has been designed to be totally overriden by a 
user-written script if wanted. It means you can write and use you own 
script to replace some ESM actions, or even to totally override the 
embedded script.

How to do this ? The minimum requirement is to know some basics of 
programming. No pain, no gain... The Lua syntax is *very* easy, almost 
simplistic for easy tasks. You can read this reference manual 
(http://www.lua.org/manual/5.1/ see Chapter 2) to be convinced. If 
you're comfortable with ANY programming language, you will learn Lua in 
minutes, at least for basic scripting involved in Win-Test. We also 
provide several WT API/functions to allow actions. Check the list below :

wtApp:AlertBox(Text)
Opens a standard Windows alert box with text.

wtApp:SendFKey(Key)
Key is one of "F1".."F12" + "Insert" + "Plus" + "Esc"

wtContest:IsExchangeRequired()
Return a boolean. True if the current contest requires an exchange 
(associated with RST)

wtContest:GetContestId()
Return the current contestID

wtKeyer:Play(Message)
Message is a plain string to be played, a saved message ($F1 etc.) or a 
variable ($xxx)

wtKeyer:Stop()
Stop the current message

wtQso:IsCallsignEmpty()
Return a boolean : True if the callsign field of the active Qso is empty

wtQso:IsCallsignIncomplete()
Return a boolean : True if the callsign field of the active Qso contains 
a "?"

wtQso:IsExchangeEmpty()
Return a boolean : True if the exchange field of the active Qso is empty

wtQso:IsExchangeSent()
Return a boolean : True if the exchangeSent flag of the active Qso is set

wtQso:SetExchangeSent()
Set the exchangeSent flag of the active Qso (see 
wtQso::IsExchangeSent()) - Similar to the use of $SETEXCHSENT

wtQso:ResetExchangeSent()
Reset the exchangeSent flag of the active Qso (see 
wtQso::IsExchangeSent()) - Similar to the use of $RSTEXCHSENT

wtQso:ClearStatus()
Clear the status flags of the active Qso

wtQso:IsCallsignRepeated()
Return a boolean. True if the callsign hasn't changed since the last Enter

wtQso:IsOperatingModeRun()
Return a boolean. True if the operating mode of the active Qso is RUN 
(and False if S&P)

wtQso:IsModePhone()
Return a boolean. True if the mode of the active Qso is Phone (SSB and 
FM), and False otherwise

wtQso:IsQsoApproved()
Return a boolean. True if all requested fields of the active Qso are 
filled (contest dependent)

wtQso:IsDupe()
Return a boolean. True if the current callsign is a dupe

wtQso:IsCurrentFieldCallsign()
Return a boolean : True if the current field is the callsign field

wtQso:IsCurrentFieldExchange()
Return a boolean : True if the current field is an exchange field

wtQso:IsCurrentFieldOther()
Return a boolean : True if the current field is not the callsign field 
or an exchange field

wtQso:IsCurrentFieldEmpty()
Return a boolean : True if the current field is empty (except RST for 
the exchange field)

Notes:

1/ WT maintains two different Qso status : One for each radio. They are 
automatically cleared when the QSO is entered, if the operating mode 
(RUN / S&P) is switched or if the wtQso:ClearStatus() is executed.
2/ Lua global variables are persistent between scripts calls. If you 
don't want this behavior, use local variables instead (keyword local).

Until we provide a more comfortable IDE (we are working on it) to help 
script writing and debugging, you will have very basic output 
information (read syntax error messages etc.) in a standard Windows alert.

Write your script with a plain text editor, and save it as "esm.wts" 
(mandatory name) in the {AppData}/All Users/Win-Test/scripts/ directory. 
The value returned by YOUR script will then indicate to Win-Test what to 
do after it is executed : If the return value is 0 (or if there is no 
return value), WT will run its own embedded script after yours. If the 
the return value is 1, WT will continue the Enter key process, without 
calling its embedded script. And if the return value is -1, WT will stop 
the Enter key process, without calling its embedded script.

Basic Examples :

1/

-- esm.wts
wtApp:AlertBox("Enter key ! ESM rulez...");
return 0; -- This line can be omitted
-- end

No return value (or 0) => WT will execute this script (the alert box 
will be displayed), and the embedded script will be called after it.

2/

-- esm.wts
wtApp:AlertBox("Enter key ! The key is processed by WT");
return 1;
-- end

The return value is 1 => After executing the script (the alert box will 
be displayed), WT will continue its own process and act exactly as if 
someone hit Enter. Read : It silently enters the QSO if it is OK. The 
embedded ESM script is ignored.

3/

-- esm.wts
wtApp:AlertBox("Enter key ! The key processing is stopped");
return -1;
-- end

The return value is -1 => After executing the script (the alert box will 
be displayed), the embedded ESM script is ignored and WT will also 
ignore the Enter key process (no QSO is entered).

For convenience, you can find below the current ESM embedded script. 
Note that the real returned values are somewhat different from the ones 
described above, because of the nature of this script (embedded), but it 
is a good source of inspiration for your own masterpiece. As Lua is an 
interpreted language, the good news is that you can edit your script 
while WT is running. No need to exit WT, enter modifications, and start 
WT again. Just edit esm.wts while WT is running, save it, and try it 
immediately !

Finally, note that we currently restrict for now the usage of scripting 
to the ESM. We have other projects in mind, but we must setup a more 
convenient IDE before going any further. Please don't ask for other 
functions/API or script interface for now !

73

Larry - F6FVY

--------------------------------------------------------------------

-- v1.1 Dupes taken into account in the S&P mode
-- v1.0 Initial version

-- Send functions

function sendCq()
   wtQso:ResetExchangeSent();
   wtApp:SendFKey("F1");  -- Always use the function key
end;

function sendExchangeRun()
   if (wtQso:IsModePhone()) then
     wtApp:SendFKey("F2");
   else
     wtKeyer:Play("$INSERT");
   end;
   wtQso:SetExchangeSent();
end;

function sendExchangeAgain()
   if (wtQso:IsModePhone()) then
     wtApp:SendFKey("F2");
   else
     wtKeyer:Play("$F5 $F7"); -- $LOGGED ?
   end;
end;

function sendTu()
   if (wtQso:IsModePhone()) then
     wtApp:SendFKey("PLUS");
   else
     wtKeyer:Play("$PLUS");
   end;
   wtQso:ClearStatus();
end;

function sendQuestionMark()
   wtQso:ResetExchangeSent();
   if (wtQso:IsModePhone()) then
     wtApp:SendFKey("F7"); -- Again ?
   else
     wtKeyer:Play("$F7");
   end;
end;

function sendMyCall()
   if (wtQso:IsModePhone()) then
     wtApp:SendFKey("F4"); -- My call
   else
     wtKeyer:Play("$F4");
   end;
end;

function sendExchangeSAndP()
   if (wtQso:IsModePhone()) then
     wtApp:SendFKey("F2");
   else
     wtKeyer:Play("$F2");
   end;
   wtQso:SetExchangeSent();
end;

-- ESM core code

-- Return 0 (or return nothing) if we want the CR
-- to be processed also by WT (ie log QSO) and -1 if not.

if (wtQso:IsOperatingModeRun()) then -- Run
   if (wtContest:IsExchangeRequired()) then -- Usual contests
     if (wtQso:IsExchangeEmpty() or not wtQso:IsQsoApproved()) then
       if (wtQso:IsCallsignEmpty()) then
         sendCq();
       else
         if (wtQso:IsCallsignRepeated()) then
           sendExchangeAgain();
         else
           sendExchangeRun();
         end;
       end;
     else
       if (wtQso:IsExchangeSent()) then
         sendTu()
       else
         sendExchangeRun();
       end;
     end;
   else -- DXPed etc.
     if (not wtQso:IsQsoApproved()) then
       if (wtQso:IsCallsignEmpty()) then
         sendCq();
       else
         if (wtQso:IsCallsignRepeated()) then
           sendExchangeAgain();
         else
           sendExchangeRun();
         end;
       end;
     else
       if (wtQso:IsExchangeSent()) then
         sendTu();
       else
         sendExchangeRun();
       end;
     end;
   end;
else -- S&P : The automatic exchange fill (if enabled) is disabled by WT
   if ( (wtQso:IsExchangeEmpty() and wtContest:IsExchangeRequired())
         or not wtQso:IsQsoApproved() ) then
     if (wtQso:IsCallsignEmpty()) then
       sendQuestionMark();
     else
       if (not wtQso:IsDupe()) then -- Call only if not dupe
         sendMyCall();
       end;
     end;
   else
     if (wtQso:IsExchangeSent()) then
       wtQso:ClearStatus();
       return 1 -- Log it silently _Caution_ : embedded script returns 0
     else
       if (not wtQso:IsDupe()) then -- Sent exchange only if not dupe
         sendExchangeSAndP();
       end;
     end;
   end;
end;

return -1; -- This script overrides the Win-Test CR process

_______________________________________________
Support mailing list
Support at win-test.com
http://www.f5mzn.org/cgi-bin/mailman/listinfo/support


More information about the Support mailing list