; Based on ET5410 device file by jmurray. AlexD added Channel 2 & moved mode control to Setup Popup.
; 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 ET5420
#name East Tester ET5420
#handle ET5420
#port comfixedbaud
#baudrate 115200
#driver SCPIx
#author AlexD, jmurray@jmaudio.com.au

; *IDN? returns: <model>,<SN>,<software>,<NL>
;  <ET5420,V1.02.2127.002,09422126024,ET5420V1.01.21>
; 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 CH1_Current A D3
#value CH1_Voltage V D3
#value CH1_Power W D2
#value CH1_Resistance Ohm D3
#value CH1_Capacity Ah D3
#value CH2_Current A D3
#value CH2_Voltage V D3
#value CH2_Power W D2
#value CH2_Resistance Ohm D3
#value CH2_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 MEAS1:ALL?;BATT1:CAPA?;MEAS2:ALL?;BATT2:CAPA?

; Remove extraneous 'R' & spaces from returned result:
#askValuesMathFormat trim(replace(replace(replace(value,"R",""),"  "," "),"  "," "))

; Format of answer: f=float, u=remove trailing letters, x=skip, *=Zero upper case values if this value is 0
; ** Needs to be one character for each number to be returned **. If fewer, #values will be missing from table.
#askValuesReadFormat ffffffffff

; 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 CH1:MODE?;CH2: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 CH1:SW OFF;[300];CH2:SW OFF;[300];SYST:LOCA

; Used to turn output off for power supplies, generators and electronic loads
#outputOff CH1:SW OFF;[300];CH2:SW OFF


; =======SETUP CHANNEL 1=============================================
; -------SYSTEM SET--------------------------------------------------

#cmdSetup buttons Input_1 CHANNEL_1
:write: CH1:SW
:string:
ON ON
OFF OFF

#cmdSetup comboboxhot Mode CHANNEL_1
:write: CH1:MODE #;[300];
:read: CH1:MODE?;[300];
Constant_Current_(01._CC) CC
Constant_Voltage_(02._CV) CV
Constant_Power_(03._CP) CP
Constant_Resistance_(04._CR) CR
Constant_Current_to_Constant_Voltage_(05._CC+CV) CCCV
Constant_Resistance_to_Constant_Voltage_(06._CR+CV) CRCV
Transient_Test_(07._Tran) TRAN
List_Test_(08._List) LIST
Scan_Test_(09._Scan) SCAN
Short_Test_(10._Short) SHOR
Battery_Test_(11._Batt) BATT
LED_Test_(12._LED) LED
:update: CH1_Controls

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

#cmdSetup radio Range_I_ CHANNEL_1
: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
:update: CH1_Controls

#cmdSetup radio Range_V_ CHANNEL_1
: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
:update: CH1_Controls

;#cmdSetup multi Limit_ CHANNEL_1
;: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
:update: CH1_Controls

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

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

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

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

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

; -------CC-CV-CR-CP-------------------------------------------------
#cmdSetup numberInt Off_Time_ CHANNEL_1
: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
:update: CH1_Controls

; -------CCCV--------------------------------------------------------
#cmdSetup multi Set_I_V_ CHANNEL_1
: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
:update: CH1_Controls

; -------CRCV--------------------------------------------------------
#cmdSetup multi Set_R_V_ CHANNEL_1
: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
:update: CH1_Controls

; -------CC-CV-CR-CP-CCCV-CRCV-SHOR----------------------------------
#cmdSetup multi Limit_ CHANNEL_1
: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
:update: CH1_Controls

; -------TRAN--------------------------------------------------------
#cmdSetup comboboxhot Tran_State_ CHANNEL_1
: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
:update: CH1_Controls

#cmdSetup comboboxhot Tran_Mode_ CHANNEL_1
: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
:update: CH1_Controls

#cmdSetup multi Level-A_I_ CHANNEL_1
: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: CHANNEL_1.Tran_State_=="CC"
:tip: Set the dynamic test A value
Number I A 0 40
Number T s 0 60
:update: CH1_Controls

#cmdSetup multi Level-B_I_ CHANNEL_1
: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: CHANNEL_1.Tran_State_=="CC"
:tip: Set the dynamic test B value
Number I A 0 40
Number T s 0 60
:update: CH1_Controls

#cmdSetup multi Level-A_V_ CHANNEL_1
: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: CHANNEL_1.Tran_State_=="CV"
:tip: Set the dynamic test A value
Number V V 0.1 150
Number T s 0 60
:update: CH1_Controls

#cmdSetup multi Level-B_V_ CHANNEL_1
: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: CHANNEL_1.Tran_State_=="CV"
:tip: Set the dynamic test B value
Number V V 0.1 150
Number T s 0 60
:update: CH1_Controls

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

#cmdSetup multi Value_I_ CHANNEL_1
:read: CURR:STARt?;CURR:END?;CURR:STEP?;
:readmath: trim(replace(value,"R",""))
:write: CURR:STARt #;[300];CURR:END #;[300];CURR:STEP #;[300];
:enable: CHANNEL_1.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
:update: CH1_Controls

#cmdSetup multi Value_V_ CHANNEL_1
:read: VOLT:STARt?;VOLT:END?;VOLT:STEP?;
:readmath: trim(replace(value,"R",""))
:write: VOLT:STARt #;[300];VOLT:END #;[300];VOLT:STEP #;[300];
:enable: CHANNEL_1.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
:update: CH1_Controls

#cmdSetup multi Value_P_ CHANNEL_1
:read: POWE:STARt?;POWE:END?;POWE:STEP?;
:readmath: trim(replace(value,"R",""))
:write: POWE:STARt #;[300];POWE:END #;[300];POWE:STEP #;[300];
:enable: CHANNEL_1.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
:update: CH1_Controls

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

#cmdSetup comboboxhot TH_Type_ CHANNEL_1
:read: SCAN:THTYpe?;
:write: SCAN:THTYpe #;[300]
:tip: Set the threshold type of the scan test
:string:
VTH VTH
DROP(*) DROP
VMIN VMIN
:updatemodechange:
:update: CH1_Controls
#cmdSetup number TH_VTH_ CHANNEL_1
:read: VOLT:VTH?;
:readmath: trim(replace(value,"R",""))
:write: VOLT:VTH #;[300];
:enable: CHANNEL_1.TH_Type_=="VTH"
:tip: Set the threshold of scan test voltage transition
Volts 0.1 150
:update: CH1_Controls

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

#cmdSetup comboboxhot Compare_Type_ CHANNEL_1
: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
:update: CH1_Controls

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

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

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

;----------LIST------------------------------------------------------
#cmdSetup info Not_created CHANNEL_1

;----------BATT------------------------------------------------------
#cmdSetup comboboxhot Discharge_Mode_ CHANNEL_1
: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
:update: CH1_Controls

#cmdSetup multi Battery_I_ CHANNEL_1
:read: CURR:BCC1?;CURR:BCC2?;CURR:BCC3?
:readmath: trim(replace(value,"R",""))
:write: CURR:BCC1 #;[300];CURR:BCC2 #;[300];CURR:BCC3 #;[300]
:enable:  CHANNEL_1.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
:update: CH1_Controls

#cmdSetup multi Battery_V_ CHANNEL_1
:read: VOLT:BCC1?;VOLT:BCC2?;VOLT:BCC3?
:readmath: trim(replace(value,"R",""))
:write: VOLT:BCC1 #;[300];VOLT:BCC2 #;[300];VOLT:BCC3 #;[300]
:enable:  CHANNEL_1.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
:update: CH1_Controls

#cmdSetup multi Battery_R_ CHANNEL_1
:read: RESI:BCR?;VOLT:BCR?
:readmath: trim(replace(value,"R",""))
:write: RESI:BCR #;[300];VOLT:BCR #;[300]
:enable:  CHANNEL_1.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
:update: CH1_Controls

;----------LED-------------------------------------------------------
#cmdSetup number LED_Vo_ CHANNEL_1
: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
:update: CH1_Controls

#cmdSetup multi LED_Io_ CHANNEL_1
: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
:update: CH1_Controls

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

;========SETUP CHANNEL 2=============================================
; -------SYSTEM SET--------------------------------------------------
#cmdSetup buttons Input_2 CHANNEL_2
:write: CH2:SW
:string:
ON ON
OFF OFF

#cmdSetup comboboxhot Mode CHANNEL_2
:write: CH2:MODE #;[300];
:read: CH2:MODE?;[300];
Constant_Current_(01._CC) CC
Constant_Voltage_(02._CV) CV
Constant_Power_(03._CP) CP
Constant_Resistance_(04._CR) CR
Constant_Current_to_Constant_Voltage_(05._CC+CV) CCCV
Constant_Resistance_to_Constant_Voltage_(06._CR+CV) CRCV
Transient_Test_(07._Tran) TRAN
List_Test_(08._List) LIST
Scan_Test_(09._Scan) SCAN
Short_Test_(10._Short) SHOR
Battery_Test_(11._Batt) BATT
LED_Test_(12._LED) LED
:update: CH2_Controls

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

#cmdSetup radio Range_I_ CHANNEL_2
:read: LOAD2:CRANge?;
:write: LOAD2:CRANge #;[300];CURR2: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
:update: CH2_Controls

#cmdSetup radio Range_V_ CHANNEL_2
:read: LOAD2:VRANge?;
:write: LOAD2:VRANge #;[300];VOLT2: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
:update: CH2_Controls

;#cmdSetup multi Limit_ CHANNEL_2
;:read: CURR2:IMAX?;VOLT2:VMAX?;POWE2:PMAX?;
;:readmath: trim(replace(value,"R",""))
;:write: CURR2:IMAX #;[300];VOLT2:VMAX #;[300];POWE2:PMAX #;[300];
;:tip: Set protection value
;Number I A 0 42
;Number V V 0.1 155
;Number P W 0 420
;:update: CH2_Controls

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

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

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

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

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

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

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

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

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

; -------TRAN--------------------------------------------------------
#cmdSetup comboboxhot Tran_State_ CHANNEL_2
:read: TRAN2:STATe?;
:write: TRAN2: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
:update: CH2_Controls

#cmdSetup comboboxhot Tran_Mode_ CHANNEL_2
:read: TRAN2:MODE?;
:write: TRAN2: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
:update: CH2_Controls

#cmdSetup multi Level-A_I_ CHANNEL_2
:read: CURR2:TA?;TIME2: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: CURR2:TA #;[300];TIME2:WA #;[300];
:update: Level-A_V_
:enable: CHANNEL_2.Tran_State_=="CC"
:tip: Set the dynamic test A value
Number I A 0 40
Number T s 0 60
:update: CH2_Controls

#cmdSetup multi Level-B_I_ CHANNEL_2
:read: CURR2:TB?;TIME2: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: CURR2:TB #;[300];TIME2:WB #;[300];
:update: Level-B_V_
:enable: CHANNEL_2.Tran_State_=="CC"
:tip: Set the dynamic test B value
Number I A 0 40
Number T s 0 60
:update: CH2_Controls

#cmdSetup multi Level-A_V_ CHANNEL_2
:read: VOLT2:TA?;TIME2: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: VOLT2:TA #;[300];TIME2:WA #;[300];
:update: Level-A_I_
:enable: CHANNEL_2.Tran_State_=="CV"
:tip: Set the dynamic test A value
Number V V 0.1 150
Number T s 0 60
:update: CH2_Controls

#cmdSetup multi Level-B_V_ CHANNEL_2
:read: VOLT2:TB?;TIME2: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: VOLT2:TB #;[300];TIME2:WB #;[300];
:update: Level-B_I_
:enable: CHANNEL_2.Tran_State_=="CV"
:tip: Set the dynamic test B value
Number V V 0.1 150
Number T s 0 60
:update: CH2_Controls

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

#cmdSetup multi Value_I_ CHANNEL_2
:read: CURR2:STARt?;CURR2:END?;CURR2:STEP?;
:readmath: trim(replace(value,"R",""))
:write: CURR2:STARt #;[300];CURR2:END #;[300];CURR2:STEP #;[300];
:enable: CHANNEL_2.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
:update: CH2_Controls

#cmdSetup multi Value_V_ CHANNEL_2
:read: VOLT2:STARt?;VOLT2:END?;VOLT2:STEP?;
:readmath: trim(replace(value,"R",""))
:write: VOLT2:STARt #;[300];VOLT2:END #;[300];VOLT2:STEP #;[300];
:enable: CHANNEL_2.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
:update: CH2_Controls

#cmdSetup multi Value_P_ CHANNEL_2
:read: POWE2:STARt?;POWE2:END?;POWE2:STEP?;
:readmath: trim(replace(value,"R",""))
:write: POWE2:STARt #;[300];POWE2:END #;[300];POWE2:STEP #;[300];
:enable: CHANNEL_2.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
:update: CH2_Controls

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

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

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

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

#cmdSetup comboboxhot Compare_Type_ CHANNEL_2
:read: SCAN2:COMPare?;
:write: SCAN2: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
:update: CH2_Controls

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

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

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

;----------LIST------------------------------------------------------
#cmdSetup info Not_created CHANNEL_2

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

#cmdSetup multi Battery_I_ CHANNEL_2
:read: CURR2:BCC1?;CURR2:BCC2?;CURR2:BCC3?
:readmath: trim(replace(value,"R",""))
:write: CURR2:BCC1 #;[300];CURR2:BCC2 #;[300];CURR2:BCC3 #;[300]
:enable:  CHANNEL_2.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
:update: CH2_Controls

#cmdSetup multi Battery_V_ CHANNEL_2
:read: VOLT2:BCC1?;VOLT2:BCC2?;VOLT2:BCC3?
:readmath: trim(replace(value,"R",""))
:write: VOLT2:BCC1 #;[300];VOLT2:BCC2 #;[300];VOLT2:BCC3 #;[300]
:enable:  CHANNEL_2.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
:update: CH2_Controls

#cmdSetup multi Battery_R_ CHANNEL_2
:read: RESI2:BCR?;VOLT2:BCR?
:readmath: trim(replace(value,"R",""))
:write: RESI2:BCR #;[300];VOLT2:BCR #;[300]
:enable:  CHANNEL_2.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
:update: CH2_Controls

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

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

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

#cmdSetup Updater update
:update: Input_Status
0.5

#cmdSetup indicator Input_Status
:read: CH1:SW?
___Channel_1 getElement(value,0)=="ON" red
___Channel_1 getElement(value,0)=="OFF" gray

#cmdSetup indicator Input_Status
:read: CH2:SW?
___Channel_2 getElement(value,0)=="ON" red
___Channel_2 getElement(value,0)=="OFF" gray