; TestController must be restarted before any changes in this file will be used.

; Manual is here: https://lygte-info.dk/project/TestControllerConfigDevice%20UK.html
; ===================================================================
; The device identification and connection parametes
#idString ET5410
#name East Tester ET5410
#handle ET5410
#port comfixedbaud
#baudrate 115200
#driver SCPIx
#author jmurray@jmaudio.com.au

; *IDN? returns: <model>,<SN>,<software>,<NL>
;  <ET5410 01234567890 V1.12.1234.123 V1.12.1234.123>
; Fix *idn? by adding commas and swapping serial number and version
#scpiCmd *idn? *IDN?
:readmath: var v=split(value," ");v[0]+","+v[2]+","+v[1]+","+v[3];
#eol \n |.\n

; ===================================================================
; Data type definitions
; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6) 
; Format: #value ColumnName Unit Format {Selector}
; Selector is only used when column layout varies with mode, this often require the use of #cmdMode
#value Current A D3
#value Voltage V D3
#value Power W D2
#value Resistance Ohm D3
#value Capacity Ah D3

; ===================================================================
; Basic communication
; How to poll for data, this is used for table and #values?
; a #askMode, #cmdMode and #prepareSample is used before this is string is used.
; Number of returned values must match number of columns defined with #value
; This is a single line command
; MEAS:ALL? returns  values current, voltage, power, resistance
;#askValues MEAS:CURR?;MEAS:VOLT?;MEAS:POWE?;MEAS:RESI?;BATT:CAPA?
#askValues MEAS:ALL?;BATT:CAPA?
 
#askValuesMathFormat trim(replace(replace(value,"R",""),"  "," "))

; Format of answer: f=float, u=remove trailing letters, x=skip, *=Zero upper case values if this value is 0
#askValuesReadFormat fffff

; Accept this delay when reading values (seconds)
;#readingDelay 5

; Mode change have a longer delay on reading values (seconds)
;#modeChangeDelay 10

#interfaceType Load
;#interface readValue 0

; Switch meter to this mode during start, leave empty to avoid any switching
#initialMode

; String to ask about actual meter mode, it is mostly used for DMM's
; This is a single line command
#askMode CH:MODE?
;#askModeMathFormat getElement(value,0); 

; When one of these commands are used through the command interface a new configuration will be done before using #askMode
; Only one word for each #mayModifyMode
; Specify command without initial colon and in the shortest possible form
;#mayModifyMode 

; Prepare the meter to response to #askValues
;#prepareSample arm:sour imm;:arm:count 1;:trig:sour imm;:trig:count 1;:trig:samp:count 1;init

; Initial commands to meter when establishing connection, used to disable local control
#initCmd SYST:PC

; Final command to meter before breaking connection, used to restore local control
#finalCmd CH:SW OFF;SYST:LOCA

; Used to turn output off for power supplies, generators and electronic loads
#outputOff CH:SW OFF

; =======MODE========================================================
#cmdModeLayout 2 6

#cmdMode 01.CC CC
CH:MODE CC
[500]

#cmdMode 02.CV CV
CH:MODE CV
[500]

#cmdMode 03.CP CP
CH:MODE CP
[500]

#cmdMode 04.CR CR
CH:MODE CR
[500]

#cmdMode 05.CC+CV CCCV
CH:MODE CCCV
[500]

#cmdMode 06.CR+CV CRCV
CH:MODE CRCV
[500]

#cmdMode 07.Tran TRAN
CH:MODE TRAN
[500]
LOAD:CRANge HIGH
[500]
CURR:IMAX 42
[500]

#cmdMode 08.List LIST
CH:MODE LIST
[500]
LOAD:CRANge HIGH
[500]
CURR:IMAX 42
[500]

#cmdMode 09.Scan SCAN
CH:MODE SCAN
[500]
LOAD:CRANge HIGH
[500]
CURR:IMAX 42
[500]

#cmdMode 10.Short SHOR
CH:MODE SHOR
[500]

#cmdMode 11.Battery BATT
CH:MODE BATT
[500]
LOAD:CRANge HIGH
[500]
CURR:IMAX 42
[500]

#cmdMode 12.LED LED
CH:MODE LED
[500]
LOAD:CRANge HIGH
[500]
CURR:IMAX 42
[500]

; =======SETUP=======================================================
; -------SYSTEM SET--------------------------------------------------
#cmdSetup info Mode_
:read: CH:MODE?
:tip: Setting channel mode
:updatemodechange:

#cmdSetup comboboxhot Trigger_
:read: LOAD:TRIGger?;
:write: LOAD:TRIGger #;[300];
:tip: Set the trigger mode of the trigger source
Manual   MAN
External(*) EXT
Trigger  TRG
:updatemodechange:

#cmdSetup radio Range_I_
:read: LOAD:CRANge?;
:write: LOAD:CRANge #;[300];CURR:IMAX (value=="HIGH"?42:3.1);[300];
:update: Set_I_;Set_I_V_;Limit_;Level-A_I_;Level-B_I_;Value_I_;Value_I_;Limit_I_;Battery_I_;LED_Io_;
:tip: Set the range of current
:string:
Low_(3.100A)  LOW
High_(42.00A) HIGH
:updatemodechange:

#cmdSetup radio Range_V_
:read: LOAD:VRANge?;
:write: LOAD:VRANge #;[300];VOLT:VMAX (value=="HIGH"?155:21.0);[300];
:update: Set_V_;Set_I_V_;Set_R_V_;Limit_;Level-A_V_;Level-B_V_;Value_V_;Value_V_;TH_VTH_;TH_V_min_;Limit_V_;Battery_V_;Battery_R_;LED_Vo_;
:tip: Set the voltage range
:string:
Low_(21.00V)   LOW
High_(155.00V) HIGH
:updatemodechange:

;#cmdSetup multi Limit_
;:read: CURR:IMAX?;VOLT:VMAX?;POWE:PMAX?;
;:readmath: trim(replace(value,"R",""))
;:write: CURR:IMAX #;[300];VOLT:VMAX #;[300];POWE:PMAX #;[300];
;:tip: Set protection value
;Number I A 0 42
;Number V V 0.1 155
;Number P W 0 420
;:updatemodechange:

;#cmdSetup info Note_
;:tip: Note
;*_-_functions only from the device

; -------CC----------------------------------------------------------
#cmdSetup number Set_I_
:read: CURR:CC?;
:readmath: trim(replace(value,"R",""))
:write: CURR:CC #;[300];
:tip: Set CC mode current value
Amps 0 40
:updatemodechange:

; -------CV----------------------------------------------------------
#cmdSetup number Set_V_
:read: VOLT:CV?;
:readmath: trim(replace(value,"R",""))
:write: VOLT:CV #;[300];
:tip: Set the voltage value of CV mode
Volt 0 150
:updatemodechange:

; -------CP----------------------------------------------------------
#cmdSetup number Set_P_
:read: POWE:CP?;
:readmath: trim(replace(value,"R",""))
:write: POWE:CP #;[300];
:tip: Set CP mode power value
Watt 0 400
:updatemodechange:

; -------CR----------------------------------------------------------
#cmdSetup number Set_R_
:read: RESI:CR?;
:readmath: trim(replace(value,"R",""))
:write: RESI:CR #;[300];
:tip: Set the resistance value of CR mode
Ohm 0 4500
:updatemodechange:

; -------CC-CV-CR-CP-------------------------------------------------
#cmdSetup numberInt Off_Time_
:read: TIME:OFFDelay?;
:readmath: trim(replace(value,"R",""))
:write: TIME:OFFDelay #;[300];
:tip: Set the delay shutdown time to query the current delay shutdown time value
Seconds 0 60000
:updatemodechange:

; -------CCCV--------------------------------------------------------
#cmdSetup multi Set_I_V_
:read: CURR:CCCV?;VOLT:CCCV?;
:readmath: trim(replace(value,"R",""))
:write: CURR:CCCV #;[300];VOLT:CCCV #;[300];
:tip: Set CC+CV mode value
Number I A 0 40
Number V V 0 150
:updatemodechange:

; -------CRCV--------------------------------------------------------
#cmdSetup multi Set_R_V_
:read: RESI:CRCV?;VOLT:CRCV?;
:readmath: trim(replace(value,"R",""))
:write: RESI:CRCV #;[300];VOLT:CRCV #;[300];
:tip: Set CR+CV mode value
Number R Ohm 0 4500
Number V V 0 150
:updatemodechange:

; -------CC-CV-CR-CP-CCCV-CRCV-SHOR----------------------------------
#cmdSetup multi Limit_
:read: CURR:IMAX?;VOLT:VMAX?;POWE:PMAX?;
:readmath: trim(replace(value,"R",""))
:write: CURR:IMAX #;[300];VOLT:VMAX #;[300];POWE:PMAX #;[300];
:tip: Set protection value
Number I A 0 42
Number V V 0.1 155
Number P W 0 420
:updatemodechange:

; -------TRAN--------------------------------------------------------
#cmdSetup comboboxhot Tran_State_
:read: TRAN:STATe?;
:write: TRAN:STATe #;[300]
:update: Level-A_I_,Level-B_I_,Level-A_V_,Level-B_V_;
:tip: Set the dynamic state of dynamic test
:string:
CC CC
CV CV
:updatemodechange:

#cmdSetup comboboxhot Tran_Mode_
:read: TRAN:MODE?;
:write: TRAN:MODE #;[300];
:update: Level-A_I_,Level-B_I_,Level-A_V_,Level-B_V_;
:tip: Set dynamic test dynamic mode
Continuous COUT
Trigger TRIG
Pulse PULS
:updatemodechange:

#cmdSetup multi Level-A_I_
:read: CURR:TA?;TIME:WA?;
;:readmath: getElement(replace(value,"R",""),0)+" "+getElement(replace(value,"R",""),1)/1000
:readmath: replace(getElement(value,0),"R","")+" "+(replace(getElement(value,1),"R","")/1000.0)
:write: CURR:TA #;[300];TIME:WA #;[300];
:update: Level-A_V_
:enable: Tran_State_=="CC"
:tip: Set the dynamic test A value
Number I A 0 40
Number T s 0 60
:updatemodechange:

#cmdSetup multi Level-B_I_
:read: CURR:TB?;TIME:WB?;
;:readmath: getElement(replace(value,"R",""),0)+" "+getElement(replace(value,"R",""),1)/1000
:readmath: replace(getElement(value,0),"R","")+" "+(replace(getElement(value,1),"R","")/1000.0)
:write: CURR:TB #;[300];TIME:WB #;[300];
:update: Level-B_V_
:enable: Tran_State_=="CC"
:tip: Set the dynamic test B value
Number I A 0 40
Number T s 0 60
:updatemodechange:

#cmdSetup multi Level-A_V_
:read: VOLT:TA?;TIME:WA?;
;:readmath: getElement(replace(value,"R",""),0)+" "+getElement(replace(value,"R",""),1)/1000
:readmath: replace(getElement(value,0),"R","")+" "+(replace(getElement(value,1),"R","")/1000.0)
:write: VOLT:TA #;[300];TIME:WA #;[300];
:update: Level-A_I_
:enable: Tran_State_=="CV"
:tip: Set the dynamic test A value
Number V V 0.1 150
Number T s 0 60
:updatemodechange:

#cmdSetup multi Level-B_V_
:read: VOLT:TB?;TIME:WB?;
;:readmath: getElement(replace(value,"R",""),0)+" "+getElement(replace(value,"R",""),1)/1000
:readmath: replace(getElement(value,0),"R","")+" "+(replace(getElement(value,1),"R","")/1000.0)
:write: VOLT:TB #;[300];TIME:WB #;[300];
:update: Level-B_I_
:enable: Tran_State_=="CV"
:tip: Set the dynamic test B value
Number V V 0.1 150
Number T s 0 60
:updatemodechange:

;--------SCAN--------------------------------------------------------
#cmdSetup comboboxhot Scan_Type_
:read: SCAN:TYPE?;
:write: SCAN:TYPE #;[300]
:tip: Set scan type of scan test
:string:
CC CC
CV CV
CP CP
:updatemodechange:

#cmdSetup multi Value_I_
:read: CURR:STARt?;CURR:END?;CURR:STEP?;
:readmath: trim(replace(value,"R",""))
:write: CURR:STARt #;[300];CURR:END #;[300];CURR:STEP #;[300];
:enable: Scan_Type_=="CC"
:tip: Set the scan test current values
Number Start A 0 40
Number End A 0 40
Number Step A 0 40
:updatemodechange:

#cmdSetup multi Value_V_
:read: VOLT:STARt?;VOLT:END?;VOLT:STEP?;
:readmath: trim(replace(value,"R",""))
:write: VOLT:STARt #;[300];VOLT:END #;[300];VOLT:STEP #;[300];
:enable: Scan_Type_=="CV"
:tip: Set voltage values of scanning test
Number Start V 0.1 150
Number End V 0.1 150
Number Step V 0.1 150
:updatemodechange:

#cmdSetup multi Value_P_
:read: POWE:STARt?;POWE:END?;POWE:STEP?;
:readmath: trim(replace(value,"R",""))
:write: POWE:STARt #;[300];POWE:END #;[300];POWE:STEP #;[300];
:enable: Scan_Type_=="CP"
:tip: Set the power value of scanning test
Number Start W 0 400
Number End W 0 400
Number Step W 0 400
:updatemodechange:

#cmdSetup numberInt Step_Delay_
:read: TIME:STEP?;
:readmath: trim(replace(value,"R",""))
:write: TIME:STEP #;[300];
:tip: Set the scan test step delay value
Seconds 0 9999
:updatemodechange:

#cmdSetup comboboxhot TH_Type_
:read: SCAN:THTYpe?;
:write: SCAN:THTYpe #;[300]
:tip: Set the threshold type of the scan test
:string:
VTH VTH
DROP(*) DROP
VMIN VMIN
:updatemodechange:

#cmdSetup number TH_VTH_
:read: VOLT:VTH?;
:readmath: trim(replace(value,"R",""))
:write: VOLT:VTH #;[300];
:enable: TH_Type_=="VTH"
:tip: Set the threshold of scan test voltage transition
Volts 0.1 150
:updatemodechange:

#cmdSetup number TH_V_min_
:read: VOLT:VMIN?;
:readmath: trim(replace(value,"R",""))
:write: VOLT:VMIN #;[300];
:enable: TH_Type_=="VMIN"
:tip: Set the minimum voltage threshold for scanning test
Volts 0.1 150
:updatemodechange:

#cmdSetup comboboxhot Compare_Type_
:read: SCAN:COMPare?;
:write: SCAN:COMPare #;[300]
:tip: Sets the comparison type of the scan test to query the comparison type of the scan test
:string:
Off(*) VMIN
Current INCURR
Voltage INVOLT
Power INPOW
:updatemodechange:

#cmdSetup multi Limit_I_
:read: CURR:LOW?;CURR:HIGH?;
:readmath: trim(replace(value,"R",""))
:write: CURR:LOW #;[300];CURR:HIGH #;[300];
:enable: Compare_Type_=="INCURR"
:tip: Set the scan test current limit
Number Low A 0 42
Number High A 0 42
:updatemodechange:

#cmdSetup multi Limit_V_
:read: VOLT:LOW?;VOLT:HIGH?;
:readmath: trim(replace(value,"R",""))
:write: VOLT:LOW #;[300];VOLT:HIGH #;[300];
:enable: Compare_Type_=="INVOLT"
:tip: Set the scan test voltage limit
Number Low V 0.1 150
Number High V 0.1 150
:updatemodechange:

#cmdSetup multi Limit_P_
:read: POWE:LOW?;POWE:HIGH?;
:readmath: trim(replace(value,"R",""))
:write: POWE:LOW #;[300];POWE:HIGH #;[300];
:enable: Compare_Type_=="INPOW"
:tip: Set the scan test power limit
Number Low W 0 400
Number High W 0 400
:updatemodechange:

;----------LIST------------------------------------------------------
#cmdSetup info No_created

;----------BATT------------------------------------------------------
#cmdSetup comboboxhot Discharge_Mode_
:read: BATT:MODE?
:write: BATT:MODE #;[300];CH:MODE BATT;[300]
:tip: Set the discharge mode of the battery test
:string:
CC CC
CR CR
:updatemodechange:

#cmdSetup multi Battery_I_
:read: CURR:BCC1?;CURR:BCC2?;CURR:BCC3?
:readmath: trim(replace(value,"R",""))
:write: CURR:BCC1 #;[300];CURR:BCC2 #;[300];CURR:BCC3 #;[300]
:enable:  Discharge_Mode_=="CC"
:tip: Set the constant current current value
Number 1 I 0 40
Number 2 I 0 40
Number 3 I 0 40
:updatemodechange:

#cmdSetup multi Battery_V_
:read: VOLT:BCC1?;VOLT:BCC2?;VOLT:BCC3?
:readmath: trim(replace(value,"R",""))
:write: VOLT:BCC1 #;[300];VOLT:BCC2 #;[300];VOLT:BCC3 #;[300]
:enable:  Discharge_Mode_=="CC"
:tip: Set the constant current cut-off voltage value
Number 1 V 0 150
Number 2 V 0 150
Number 3 V 0 150
:updatemodechange:

#cmdSetup multi Battery_R_
:read: RESI:BCR?;VOLT:BCR?
:readmath: trim(replace(value,"R",""))
:write: RESI:BCR #;[300];VOLT:BCR #;[300]
:enable:  Discharge_Mode_=="CR"
:tip: Set the constant resistance cut-off voltage value of battery test mode
Number R Ohm 0 4000
Number V V 0 150
:updatemodechange:

;----------LED-------------------------------------------------------
#cmdSetup number LED_Vo_
:read: VOLT:LED?;
:readmath: trim(replace(value,"R",""))
:write: VOLT:LED #;[300];
:tip: Set the voltage value of LED test mode Vo
Volt 0 150
:updatemodechange:

#cmdSetup multi LED_Io_
:read: CURR:LED?;LED:COEFf?;
:readmath: trim(replace(value,"R",""))
:write: CURR:LED #;[300];LED:COEFf #;[300];
:tip: Set LED test mode Io current value & coefficient value
Number I A 0 40
Number Coeff _ 0.001 1.000
:updatemodechange:

;--------------------------------------------------------------------
#cmdSetup selector Sel_1
:read: CH:MODE?
CC Set_I_,Off_Time_,Limit_
CV Set_V_,Off_Time_,Limit_
CP Set_P_,Off_Time_,Limit_
CR Set_R_,Off_Time_,Limit_
CCCV Set_I_V_,Limit_
CRCV Set_R_V_,Limit_
TRAN Tran_State_,Tran_Mode_,Level-A_I_,Level-B_I_,Level-A_V_,Level-B_V_
LIST No_created
SCAN Scan_Type_,Value_I_,Value_V_,Value_P_,Step_Delay_,TH_Type_,TH_VTH_,TH_V_min_,Compare_Type_,Limit_I_,Limit_V_,Limit_P_
SHOR Limit_
BATT Discharge_Mode_,Battery_I_,Battery_V_,Battery_R_
LED LED_Vo_,LED_Io_
:updatemodechange:


