Hi HKJ,
I am working on a device definition at present and have observed some curious behaviour.
I have created a setup dialogue box - all the parameters are part of a "#cmdSetup set" control, so updated all at once. This works fine.
Because all the parameters are read from the same defined #scpiCmd, it only issues the defined :read: command once and caches the results. This is great because it's not unnecessarily sending the same command over serial each time.
I have added Run/Pause/Stop buttons to the bottom, and they work fine as well.
I added :enable: tags to the buttons because Pause should only be available when running, Stop only available during Pause, etc.
I am also using a "#cmdSetup info" to display the current "Run/Pause/Stop/etc" state.
Because a "#cmdSetup info" control does not create a variable with its name, I have made its defined #scpiCmd save the result to a variable.
My :enable: tags for the buttons read like this:
:enable: inList(deviceRead(handle,"readOperationState?"), "STOP PAUSE")
This works, however for some reason the use of the deviceRead function in the :enable: tag means that when I update the parameters in the "#cmdSetup set", it issues the defined :read: #scpiCmd for each parameter, resulting in the same command/response occuring 11 times over serial, instead of once and caching the response. This appears to visibly slow down the debug output as the last few command/response instances occur.
It still works, but it just seems a bit clunky and would prefer to keep it fast and clean so I can share the finished definition and minimise the chances of any timing issues between instruments.
Is this an oddity in the way the deviceRead function works, or am I missing something?
It seems as though an easier solution would be if the "#cmdSetup info" controls created a variable with their name, but I presume there was a reason for them not to.
Thanks again for all the work you've put into this software. While I am still learning as I go and struggle with the syntax at times, I am definitely finding my way and am very grateful for it!
Relevant lines from the definition are below:
#scpiCmd OPER:SET txrxn 13 "@0153" (value)
#scpiCmd OPER:STAT? txrxn? 22 "@0151" / 7h2
:readmath: matchBitsList(value,"00000000","STOP","00000001","RUN","00000011","READY","00000101","WAIT","00010001","HOLD","00100000","END","10000000","PAUSE")
:setvar: Operation_State=value
#scpiCmd readOperationState? none?
:readmath: getVar("Operation_State")
#scpiCmd READ:FIX? txrxn? 37 "@0125" / 5h4 9h4 13h4 17h4 21h4 25h2 27h1 28h1 29h1 30h1 31h1
:readmath: binConv(int(getElement(value,0)),0,2,1)/10.0+" "+binConv(int(getElement(value,1)),0,2,1)/10.0+" "+binConv(int(getElement(value,2)),0,2,1)/10.0+" "+binConv(int(getElement(value,3)),0,2,1)/10.0+" "+getElement(value,4)+" "+getElement(value,5)+" "+getElement(value,6)+" "+getElement(value,7)+" "+getElement(value,8)+" "+getElement(value,9)+" "+getElement(value,10)
#scpiCmd SET:FIX? txrxn? 12 "@0115" (value) / 5h2
:setvar: response=value
#cmdSetup number Temperature
:read: READ:FIX?
:readformat: fxxxxxxxxxx
:write: (bytesAsHex(hex(value*10)))
°C -20 110
#cmdSetup number Humidity
:read: READ:FIX?
:readformat: xfxxxxxxxxx
:write: (bytesAsHex(hex(value*10)))
%RH 0 99.9
#cmdSetup number Temperature_Slope
:read: READ:FIX?
:readformat: xxfxxxxxxxx
:write: (bytesAsHex(hex(value*10)))
°C/min 0 99.9
#cmdSetup number Humidity_Slope
:read: READ:FIX?
:readformat: xxxfxxxxxxx
:write: (bytesAsHex(hex(value*10)))
%RH/min 0 99.9
#cmdSetup number Run_Hours
:read: READ:FIX?
:readformat: xxxxfxxxxxx
:write: (bytesAsHex(hex(round(value),4)))
hrs 0 9999
#cmdSetup number Run_Minutes
:read: READ:FIX?
:readformat: xxxxxfxxxxx
:write: (bytesAsHex(hex(round(value),2)))
mins 0 59
#cmdSetup combobox Time_Mode
:read: READ:FIX?
:readformat: xxxxxxfxxxx
:write: (bytesAsHex(hex(round(value),1)))
Continuous 0
Timer 1
#cmdSetup combobox Wait
:read: READ:FIX?
:readformat: xxxxxxxfxxx
:write: (bytesAsHex(hex(round(value),1)))
Off 0
On 1
#cmdSetup number Time_Signal_1
:read: READ:FIX?
:readformat: xxxxxxxxfxx
:write: (bytesAsHex(hex(round(value),1)))
_ 0 9
#cmdSetup number Time_Signal_2
:read: READ:FIX?
:readformat: xxxxxxxxxfx
:write: (bytesAsHex(hex(round(value),1)))
_ 0 9
#cmdSetup number Time_Signal_3
:read: READ:FIX?
:readformat: xxxxxxxxxxf
:write: (bytesAsHex(hex(round(value),1)))
_ 0 9
#cmdSetup set Fixed_Settings
:write: SET:FIX?
:update: Fix_Settings
Temperature Humidity Temperature_Slope Humidity_Slope Run_Hours Run_Minutes Time_Mode Wait Time_Signal_1 Time_Signal_2 Time_Signal_3
\x20
#cmdSetup info Operation_State
:read: OPER:STAT?
#cmdSetup button Run
:write: OPER:SET "011"
:update: Operation_State
:enable: inList(deviceRead(handle,"readOperationState?"), "STOP PAUSE")
#cmdSetup button Pause
:write: OPER:SET "051"
:update: Operation_State
:enable: deviceRead(handle,"readOperationState?")=="RUN"
#cmdSetup button Stop
:write: OPER:SET "021"
:update: Operation_State
:enable: inList(deviceRead(handle,"readOperationState?"), "PAUSE BREAK END")