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

; Manual is here: https://lygte-info.dk/project/TestControllerConfigDevice%20UK.html

#metadef
#idString HEWLETT-PACKARD,E3632A,
#name HP E3632A
#handle HPE3632A
#replaceText MaxCurrent 7
#replaceText MaxVoltage 30
#replaceText MaxProtectionVoltage 32
#replaceText MaxProtectionCurrent 7.5

; UNTESTED
#metadef
#idString HEWLETT-PACKARD,E3633A,
#name HP E3633A
#handle HPE3633A
#replaceText MaxCurrent 20
#replaceText MaxVoltage 20
#replaceText MaxProtectionVoltage 22
#replaceText MaxProtectionCurrent 20.5

#replace #cmdSetup radio Voltage_Range Main
:string:
:write: VOLT:RANG
:read: VOLT:RANG?
:updatedelayed: 0.2
:update: Voltage Main;Current Main
8V P8V
20V P20V

; UNTESTED
#metadef
#idString HEWLETT-PACKARD,E3634A,
#name HP E3634A
#handle HPE3634A
#replaceText MaxCurrent 7
#replaceText MaxVoltage 50
#replaceText MaxProtectionVoltage 52
#replaceText MaxProtectionCurrent 7.5

#replace #cmdSetup radio Voltage_Range Main
:string:
:write: VOLT:RANG
:read: VOLT:RANG?
:updatedelayed: 0.2
:update: Voltage Main;Current Main
25V P25V
50V P50V

#meta
#idString HEWLETT-PACKARD,E3632A,
#name HP E3632A
#handle HPE3632A

#author WS

#driver SCPI
#port comfixedbaud
#baudrate 9600N82H

#interfaceType PS

#notes This device use RS232 handshake with DTR, TestController only supports this on Windows

; 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
;  >>>>>>>>>>>>>>>>>>>>>>>
; Per HJK: When using columns to show on/off value, try declaring the datatype "digital(on)" instead of "D0"
;  >>>>>>>>>>>>>>>>>>>>>>>

; 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.
; This is a single line command
#askValues MEAS:VOLT?;MEAS:CURR?

; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6)
#value Voltage V D3 
#value Current A D3 

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

; Initial commands to meter when establishing connection
#initCmd *RST;SYST:REM;

; Final command to meter before breaking connection
#finalCmd OUTP 0;CURR:PROT:CLE;VOLT:PROT:CLE;SYST:LOC

; Used when output off button is pressed
#outputOff OUTP 0

#interface setVoltage VOLT:LEVEL:IMM (value)
#interface setCurrent CURR:LEVEL:IMM (value)
#interface setOn OUTP (value)
#interface getVoltage VOLT:LEVEL:IMM?
#interface getCurrent CURR:LEVEL:IMM?
#interface getOn OUTP?
#interface readVoltage 0
#interface readCurrent 1

; Strings to configure device in different modes
; First parameter must match a #value (4 parameter) and second parameter must match what #askMode returns
; First parameter is also used in shortcut menu
;#cmdMode 

; Setup menu functions
; The parameters on the first line is: type name page 
; Settings on the following lines are:
; read: SCPI to read value from device, is used to synchronize when opening setup page or setting equal named fields. Not always used
; readformat: Parse read value.
; write: Send the value to device, this field is used in combination with data fields in the details to send updates to device.
; tip: Add this tip to all components for this input field.

#cmdSetup buttonsOn Output
:write: OUTP
:read: OUTP?
:updatedelayed: 0.1
Off 0
On 1

#cmdSetup radio Voltage_Range Main
:string:
:write: VOLT:RANG
:read: VOLT:RANG?
:updatedelayed: 0.2
:update: Voltage Main;Current Main
15V P15V
30V P30V

#cmdSetup number Voltage Main
:write: VOLT:LEV:IMM
:read: VOLT:LEV:IMM?
:updatedelayed: 0.2
V 0 MaxVoltage

#cmdSetup number Current Main
:write: CURR:LEV:IMM
:read: CURR:LEV:IMM?
:updatedelayed: 0.2
A 0 MaxCurrent

#cmdSetup number OVP_Level Limits
:write: VOLT:PROT:LEV
:read: VOLT:PROT:LEV?
:updatedelayed: 0.2
V 0 MaxProtectionVoltage

#cmdSetup buttonsOn OVP Limits
:write: VOLT:PROT:STAT
:read: VOLT:PROT:STAT?
:updatedelayed: 0.2
Off 0
On 1

#cmdSetup indicator OVP_Tripped Limits
:read: VOLT:PROT:TRIP?
Ok 0 green
Tripped getElement(value,0)=="1" Red

#cmdSetup button OVP_Clear Limits
:write: VOLT:PROT:CLE
:updatedelayed: 0.2
:update: indicator OVP_Tripped;buttonsOn Output

#cmdSetup number OCP_Level Limits
:write: CURR:PROT:LEV
:read: CURR:PROT:LEV?
:updatedelayed: 0.2
A 0.000 MaxProtectionCurrent

#cmdSetup buttonsOn OCP Limits
:write: CURR:PROT:STAT
:read: CURR:PROT:STAT?
:updatedelayed: 0.2
Off 0
On 1

#cmdSetup indicator OCP_Tripped Limits
:read: CURR:PROT:TRIP?
Ok 0 green
Tripped getElement(value,0)=="1" Red

#cmdSetup button OCP_Clear Limits
:write: CURR:PROT:CLE
:updatedelayed: 0.2
:update: indicator OCP_Tripped;buttonsOn Output

#cmdSetup button Save_1 Store
:write: *SAV 1
 
#cmdSetup button Save_2 Store
:write: *SAV 2

#cmdSetup button Save_3 Store
:write: *SAV 3

#cmdSetup button Restore_1 Store
:write: *RCL 1
:updatedelayed: 0.2
:update: Voltage Main;Current Main;Voltage_Range Main;buttonsOn Output;OVP_Level Limits;OVP Limits;OVP_Tripped Limits;OCP_Level Limits;OCP Limits;OCP_Tripped Limits

#cmdSetup button Restore_2 Store
:write: *RCL 2
:updatedelayed: 0.2
:update: Voltage Main;Current Main;Voltage_Range Main;buttonsOn Output;OVP_Level Limits;OVP Limits;OVP_Tripped Limits;OCP_Level Limits;OCP Limits;OCP_Tripped Limits

#cmdSetup button Restore_3 Store
:write: *RCL 3
:updatedelayed: 0.2
:update: Voltage Main;Current Main;Voltage_Range Main;buttonsOn Output;OVP_Level Limits;OVP Limits;OVP_Tripped Limits;OCP_Level Limits;OCP Limits;OCP_Tripped Limits
