
#metadef
#idString TENMA,72-13210,
#name Tenma 72-13210
#handle Tenma13210
#replaceText MaxPower 300


#metadef
#idString TENMA,72-13200,
#name Tenma 72-13200
#handle Tenma13200
#replaceText MaxPower 150

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

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

#meta

#idString TENMA,72,
#name Tenma 72-13210
#handle Tenma13210
#port com 18190u
#driver SCPIx
#baudrate 115200



#notes Use serial connection to setup network parameters.
UPD network is unreliable, this means there is no guarantee that commands or answer are received. On a low traffic local network the probability is good it will work.

The advanced modes on the load must be started from the command line.


; Fix *idn? by adding commas and swapping serial number and version
#scpiCmd *idn? *IDN?
:readmath: var v=split(value,"[ ]");v[0]+","+v[1]+","+replace(replace(v[3],"SN:",""),"\n","")+","+replace(v[2],"V:","");
#forceUpperCase 1

; 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 Voltage V D4
#value Current A D4
#value Power W D4

; 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
#askValues :meas:volt?;:meas:curr?;:meas:pow?

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

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

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


; String to ask about actual meter mode, it is mostly used for DMM's
; This is a single line command
;#askMode 


; 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:lock 1

; Final command to meter before breaking connection, used to restore local control
#finalCmd :inp 0;:syst:lock 0

; Used to turn output off for power supplies, generators and electronic loads
#outputOff :inp 0



; This type will specify the handle name for the first device with this type
; This makes it possible to easy get generic handle names for a setup, that will work with a script
#interfaceType Load
; These function will adjust settings
#interface setVoltage :VOLT (value)V
#interface setCurrent :CURR (value)A
#interface setPower :POW (value)W
#interface setResistance :RES (value)OHM
#interface setRemoteSense :SYST:COMP (value)
#interface setOn :INP (value)
; These function will return the value applied with the set function
#interface getVoltage :VOLT?
:readformat: u
#interface getCurrent :CURR?
:readformat: u
#interface getPower :POW?
:readformat: u
#interface getResistance :RES?
:readformat: u
#interface getRemoteSense :SYST:COMP?
:readmath: listIndex(value,"OFF ON");
#interface getOn :INP?
:readmath: listIndex(value,"OFF ON");
; These functions will read the actual values
; These can either contain a number that will reference to a data column or they can contain a command to read the value
#interface readVoltage 0
#interface readCurrent 1
#interface readPower 2

#cmdSetup indicator Status Main
:read: :inp?
:updatealloff:
Off 0 red
On value=="ON" Red

#cmdSetup indicatornum Status Main
:read: :stat?
:readmath: getElement(value,4)
Local_sense 0 Blue
Remote_Sense 1 Yellow

#cmdSetup info Mode Main
:read: :func?
_

;#cmdSetup radio Mode Main
;:read: :func?
;:write: :func
;:string:
;CC CC
;CV CV
;CW CW
;CR CR


#cmdSetup radio Current Main
:read: :curr?
:readformat: u
:write: :curr #A
:update: Mode
:tip: Load current for current mode
100mA 0.1
300mA 0.3
1A 1.0
3A 3.0
10A 10.0
30A 30.0


#cmdSetup number Voltage Main
:read: :volt?
:readformat: u
:write: :volt #V
:update: Mode
:buttontext: Mode
:tip: Load voltage for voltage mode
Volt 0.1 120


#cmdSetup number Current Main
:read: :curr?
:readformat: u
:write: :curr #A
:update: Mode
:buttontext: Mode
:tip: Load current for current mode
Amps 0 30

#cmdSetup number Power Main
:read: :pow?
:readformat: u
:write: :pow #W
:update: Mode
:buttontext: Mode
:tip: Load power for power mode
Watt 0 MaxPower

#cmdSetup number Resistance Main
:read: :res?
:readformat: u
:write: :res #OHM
:update: Mode
:buttontext: Mode
:tip: Load resistance for resistance mode
Ohm 0.05 7500


#cmdSetup checkbox Remote_sense Main
:read: :syst:comp?
:readmath: listIndex(value,"OFF ON");
:write: :syst:comp
:update: Status
on 0 1


#cmdSetup text IP_Address Network
:read: :syst:ipad?
:write: :syst:ipad
15

#cmdSetup text Subnet_mask Network
:read: :syst:smask?
:write: :syst:smask
15

#cmdSetup text Gateway Network
:read: :syst:gate?
:write: :syst:gate
15

#cmdSetup checkbox Use_DHCP Network
:read: :syst:dhcp?
:write: :syst:dhcp
:update: Gateway Subnet_mask IP_Address
:updatedelayed: 2
On 0 1

#cmdSetup numberInt Port Network
:read: :syst:port?
:write: :syst:port
:tip: Default is 18190 and TC is defined for this (18191 cannot be used).
_ 1 65535

#cmdSetup buttons Factory_reset Network
:write: :syst:factreset
:tip: This will loose the connection and require a reconnect
Reset _

#cmdsetup buttons Status
:write: :inp
off 0
on 1


