
#author DiplIngenieur
#idString OWON,XDM3051,
#name Owon XDM3051
#handle XDM3051
#port 5025 COM


;Does not handle dual readings right now.


; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6)
#value VoltageDC V si DC_Voltage
#value CurrentDC A si DC_Current
#value VoltageAC V si AC_Voltage
#value CurrentAC A si AC_Current
#value Resistance ohm si 2W_Resistance,4W_Resistance,Continuity
#value Capacitance F si Capacitance
#value Temperature °C si Temperature
#value Frequency Hz si Frequency
#value Period s si Period

; 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?

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

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

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

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

; String to ask about actual meter mode, 
; This is a single line command
#askMode SENS:FUNC?
; Remove spaces from returned result: "VOLT AC" and "CURR AC" to "VOLTAC" and "CURRAC"
#askModeMathFormat unQuote(replace(replace(value,"VOLT AC","VOLTAC"),"CURR AC","CURRAC"))



; 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
#mayModifyMode conf
;#mayModifyMode meas
;#mayModifyMode abor
;#mayModifyMode trig 

; Prepare the meter to response to #askValues
;#prepareSample

; Initial commands to meter when establishing connection
#initCmd SYST:REM; TEMP:RTD:UNIT C

; Final command to meter before breaking connection
#finalCmd *cls; SYST:LOC

#interfaceType DMM
#interface readValue 0

; 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

#cmdModeLayout 3 4

#cmdMode DC_Voltage VOLT
CONF:VOLT:DC

#cmdMode AC_Voltage VOLTAC
CONF:VOLT:AC

#cmdMode 2W_Resistance RES
CONF:RES

#cmdMode DC_Current CURR
CONF:CURR:DC

#cmdMode AC_Current CURRAC
CONF:CURR:AC

#cmdMode 4W_Resistance FRES
CONF:FRES

#cmdMode Diode DIOD
CONF:DIOD

#cmdMode Continuity CONT
CONF:CONT

#cmdMode Temperature TEMP
CONF:TEMP:RTD

#cmdMode Capacitance CAP
CONF:CAP

#cmdMode Frequency FREQ
CONF:FREQ

#cmdMode Period PER
CONF:PER

; 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.

;Mode-------------------------------------------------------------------------------------------
#cmdSetup info Active_Mode
:read: FUNC?
:readmath: getElement("Diode;DC Voltage;AC Voltage;DC Current;AC Current;Temperture;Capacitance;2W Resistance;4W Resistance;Frequency;Period;Continuity",listIndex(unQuote(replace(replace(value,"VOLT AC","VOLTAC"),"CURR AC","CURRAC")),"DIOD,VOLT,VOLTAC,CURR,CURRAC,TEMP,CAP,RES,FRES,FREQ,PER,CONT",","),";")
:updatemodechange:

;DC_Current-------------------------------------------------------------------------------------
#cmdSetup radio Range DC_Current
:write: CURR:DC:RANGE:AUTO
:read: CURR:DC:RANGE:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range DC_Current
:write: CURR:DC:RANGE
:read: CURR:DC:RANGE?
:readformat: f
200uA 2.000000E-04
2mA 2.000000E-03
20mA 2.000000E-02
200mA 2.000000E-01
2A 2.000000E+00
10A 1.000000E+01
:updatemodechange:

#cmdSetup radio Rate DC_Current
:read: [100];RATE?
:write: RATE
:string:
Slow S
Medium M
Fast F

#cmdSetup radio Filter DC_Current
:write: CURR:DC:FILTER:STAT
:read: CURR:DC:FILTER:STAT?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup radio Null DC_Current
:write: CURR:DC:NULL
:read: CURR:DC:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value DC_Current
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Amps -10 +10
:updatemodechange:

;DC_Voltage-------------------------------------------------------------------------------------
#cmdSetup radio Range DC_Voltage
:read: VOLT:DC:RANGE:AUTO?
:write: VOLT:DC:RANGE:AUTO
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range DC_Voltage
:write: VOLT:DC:RANGE
:read: VOLT:DC:RANGE?
200mV +2.000000E-01
2V 2.000000E+00
20V 2.000000E+01
200V 2.000000E+02
1000V 1.000000E+03
:updatemodechange:

#cmdSetup radio Rate DC_Voltage
:read: [100];RATE?
:write: RATE
:string:
Slow S
Medium M
Fast F

#cmdSetup radio Filter DC_Voltage
:write: VOLT:DC:FILTER:STAT
:read: VOLT:DC:FILTER:STAT?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup radio Impedance DC_Voltage
:write: VOLT:DC:IMP:AUTO
:read: VOLT:DC:IMP:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
10M OFF
10Gand10M ON
:updatemodechange:

#cmdSetup radio Null DC_Voltage
:write: VOLT:DC:NULL
:read: VOLT:DC:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value DC_Voltage
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Volts -1000 +1000
:updatemodechange:

;Diode------------------------------------------------------------------------------------------
#cmdSetup radio Beeper Diode
:write: SYST:BEEP:STAT
:read: SYST:BEEP:STAT?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

;Frequency--------------------------------------------------------------------------------------
#cmdSetup radio Range Frequency
:write: FREQ:VOLT:RANGE:AUTO
:read: FREQ:VOLT:RANGE:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range Frequency
:write: FREQ:VOLT:RANGE
:read: FREQ:VOLT:RANGE?
200mV 2.000000E-01
2V 2.000000E+00
20V 2.000000E+01
200V 2.000000E+02
750V 7.500000E+02
:updatemodechange:

#cmdSetup radio Null Frequency
:write: FREQ:NULL
:read: FREQ:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value Frequency
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Hz 0 1000000
:updatemodechange:

;Period-----------------------------------------------------------------------------------------
#cmdSetup radio Range Period
:write: PER:VOLT:RANGE:AUTO
:read: PER:VOLT:RANGE:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range Period
:write: PER:VOLT:RANGE
:read: PER:VOLT:RANGE?
200mV 2.000000E-01
2V 2.000000E+00
20V 2.000000E+01
200V 2.000000E+02
750V 7.500000E+02
:updatemodechange:

#cmdSetup radio Null Period
:write: PER:NULL:STAT
:read: PER:NULL:STAT?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value Period
:read: CALC:NULL?
:write: CALC:NULL
:buttontext: Set
Sec 0.000001 0.05
:updatemodechange:



;Temperature------------------------------------------------------------------------------------

#cmdSetup combobox SENSORTYPE Temperature
:write: TEMP:RTD:TYP
:read: TEMP:RTD:TYP?
THR_BITS90 BITS90
THR_EITS90 EITS90
THR_JITS90 JITS90
THR_KITS90 KITS90
THR_NITS90 NITS90
THR_RITS90 RITS90
THR_SITS90 SITS90
THR_TITS90 TITS90
THR_W5_26 W5_26
THR_W3_25 W3_25
RTD_PT100 PT100
RTD_PT10 PT10
RTD_Cu100 Cu100
RTD_Cu50 Cu50
:updatemodechange:

;Don't allow changing unti because it is unclear how to change the unit on a value
;#cmdSetup combobox TEMPUNIT Temperature
;:write: TEMP:RTD:UNIT
;:read: TEMP:RTD:UNIT?
;:string:
;Celsius C
;Fahrenheiht F
;Kelvin K
;:updatemodechange:


#cmdSetup radio Null Temperature
:write: TEMP:RTD:NULL
:read: TEMP:RTD:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value Temperature
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
°C -270 +1820
:updatemodechange:



;2W_Resistance----------------------------------------------------------------------------------
#cmdSetup radio Range 2W_Resistance
:read: RES:RANGE:AUTO?
:write: RES:RANGE:AUTO
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range 2W_Resistance
:write: RES:RANGE
:read: RES:RANGE?
200Ω 2.000000E+02
2kΩ 2.000000E+03
20kΩ 2.000000E+04
200kΩ 2.000000E+05
2MΩ 2.000000E+06
10MΩ 1.000000E+07
100MΩ 1.000000E+08
:updatemodechange:

#cmdSetup radio Rate 2W_Resistance
:read: [100];RATE?
:write: RATE:VOLT:DC
:string:
Slow S
Medium M
Fast F

#cmdSetup radio Null 2W_Resistance
:write: RES:NULL
:read: RES:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value 2W_Resistance
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Ω -60000000 +60000000
:updatemodechange:

;4W_Resistance----------------------------------------------------------------------------------
#cmdSetup radio Range 4W_Resistance
:read: FRES:RANGE:AUTO?
:write: FRES:RANGE:AUTO
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range 4W_Resistance
:write: FRES:RANGE
:read: FRES:RANGE?
200Ω 2.000000E+02
2kΩ 2.000000E+03
20kΩ 2.000000E+04
200kΩ 2.00000E+05
2MΩ 2.000000E+06
10MΩ 1.000000E+07
100MΩ 1.000000E+08
:updatemodechange:

#cmdSetup radio Rate 4W_Resistance
:read: [100];RATE?
:write: RATE:VOLT:DC
:string:
Slow S
Medium M
Fast F

#cmdSetup radio Null 4W_Resistance
:write: FRES:NULL
:read: FRES:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value 4W_Resistance
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Ω -60000000 +60000000
:updatemodechange:

;AC_Current-------------------------------------------------------------------------------------
#cmdSetup radio Range AC_Current
:write: CURR:AC:RANGE:AUTO
:read: CURR:AC:RANGE:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range AC_Current
:write: CURR:AC:RANGE
:read: CURR:AC:RANGE?
20mA 2.000000E-02
200mA 2.000000E-01
2A 2.000000E+00
10A 1.000000E+01
:updatemodechange:

#cmdSetup radio Rate AC_Current
:read: [100];RATE?
:write: RATE
:string:
Slow S
Medium M
Fast F

#cmdSetup radio Null AC_Current
:write: CURR:AC:NULL
:read: CURR:AC:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value AC_Current
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Amps -10 +10
:updatemodechange:

;AC_Voltage-------------------------------------------------------------------------------------
#cmdSetup radio Range AC_Voltage
:write: VOLT:AC:RANGE:AUTO
:read: VOLT:AC:RANGE:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range AC_Voltage
:write: VOLT:AC:RANGE
:read: VOLT:AC:RANGE?
200mV 2.000000E-01
2V 2.000000E+00
20V 2.000000E+01
200V 2.000000E+02
750V 7.500000E+02
:updatemodechange:

#cmdSetup radio Rate AC_Voltage
:read: [100];RATE?
:write: RATE
:string:
Slow S
Medium M
Fast F

#cmdSetup radio Null AC_Voltage
:write: VOLT:AC:NULL
:read: VOLT:AC:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value AC_Voltage
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Volts -750 +750
:updatemodechange:

;Capacitance------------------------------------------------------------------------------------
#cmdSetup radio Range Capacitance
:write: Cap:RANGE:AUTO
:read: Cap:RANGE:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range Capacitance
:write: Cap:RANGE
:read: Cap:RANGE?
2nF 2.000000E-09
20nF 2.000000E-08
200nF 2.000000E-07
2uF 2.000000E-06
200uF 2.000000E-04
10mf 1.000000E-02
:updatemodechange:

#cmdSetup radio Null Capacitance
:write: Cap:NULL
:read: Cap:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value Capacitance
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
mF -10 +10
:updatemodechange:

;Continuity------------------------------------------------------------------------------------------
#cmdSetup radio Beeper Continuity
:write: SYST:BEEP:STAT
:read: SYST:BEEP:STAT?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Threshold Continuity
:read: CONT:THRE?
:write: CONT:THRE
:buttontext: Set
Ohms 1 1100
:updatemodechange:


;Mod sel-------------------------------------------------------------------------------------------
#cmdSetup selector Mode_settings
:read: FUNC?
:readmath: unQuote(replace(replace(value,"VOLT AC","VOLTAC"),"CURR AC","CURRAC"))

:updatemodechange:
VOLT DC_Voltage.
VOLTAC AC_Voltage.
CURR DC_Current.
CURRAC AC_Current.
DIOD Diode.
FREQ Frequency.
TEMP Temperature.
RES 2W_Resistance.
FRES 4W_Resistance.
CAP Capacitance.
CONT Continuity.
PER Period.
