
#metadef
#idString Keysight Technologies,U1231A,
#name Keysight U1231A
#handle K1231

#metadef
#idString Keysight Technologies,U1232A,
#name Keysight U1232A
#handle K1232

#metadef
#idString Keysight Technologies,U1233A,
#name Keysight U1233A
#handle K1233

#port com
#driver KeysightDMM
#baudrate 9600
#author WA

#notes Added configuration for measurement ranges and battery info.
Restrictions: 
- Ranges can't be selected in Zlow measurement.
- Zlow measurement reports Voltage measurement back, fixed range 1000V. 
- Readback of autorange on/off not possible.

; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6)
#value DC_Voltage V d5 VDC,MVDC,DIOD
#value AC_Voltage V d4 VAC,MVAC
#value DC_Current A si ADC,MADC
#value DC_Current_uA A si UADC
#value AC_Current A si AAC,MAAC
#value AC_Current_uA A si UAAC
#value Resistance/Continuity ohm si RES
#value Capacity F si CAP
#value Temperature °C d1 TEMP
#value Frequency Hz si FREQAC

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

; String to ask about actual meter mode, 
; This is a single line command
#askMode CONF?
#askModeMathFormat getElement(unQuote(value),0,",")+getElement(unQuote(value),2,",");

#interfaceType DMM
#interface readValue 0

;Mode-------------------------------------------------------------------------------------------
#cmdSetup info Active_Mode
:read: CONF?
:readmath: getElement("DC_Voltage;AC_Voltage;Resistance/Continuity;DC_Current;DC_Current_uA;AC_Current;AC_Current_uA;Diode;Frequency;Capacity;Temperature",listIndex(getElement(unQuote(value),0,",")+getElement(unQuote(value),2,","),"VDC VAC RES ADC UADC AAC UAAC DIOD FREQAC CAP TEMP"," "),";")
:updatemodechange:

; Strings to configure device in different modes, using these forces a mode check/change
; When used to select mode first parameter must match a #value (4 parameter) and second parameter must match what #askMode returns
; It can also be used for just checking the mode, then the #value (4 parameter) must match what #askMode returns
; First parameter is also used in shortcut menu
#cmdMode Check_mode _ _

; ------------------------------------- Volt DC -----------------------------------------------------------
#cmdSetup button Auto_Range DC_Voltage
:write: CONF:VOLT:DC
:visible: Rotary_Switch=="DC_Volt"
:updatedelayed: 0.5
:update: Actual_Range DC_Voltage

#cmdSetup info Actual_Range DC_Voltage
:read: CONF?
:readmath: getElement("600mV;6V;60V;600V",listIndex(getElement(unQuote(value),1,","),"0;1;2;3",";"),";")
:update:

#cmdSetup button Range_600mV DC_Voltage
:write: CONF:VOLT:DC 0.6
:updatedelayed: 0.5
:update: Actual_Range DC_Voltage

#cmdSetup button Range_6V DC_Voltage
:write: CONF:VOLT:DC 6
:updatedelayed: 0.5
:update: Actual_Range DC_Voltage

#cmdSetup button Range_60V DC_Voltage
:write: CONF:VOLT:DC 60
:updatedelayed: 0.5
:update: Actual_Range DC_Voltage

#cmdSetup button Range_600V DC_Voltage
:write: CONF:VOLT:DC 600
:updatedelayed: 0.5
:update: Actual_Range DC_Voltage

; ------------------------------------- Volt AC -----------------------------------------------------------
#cmdSetup button Auto_Range AC_Voltage
:write: CONF:VOLT:AC
:updatedelayed: 0.5
:update: Actual_Range AC_Voltage

#cmdSetup info Actual_Range AC_Voltage
:read: CONF?
:readmath: getElement("600mV;6V;60V;600V",listIndex(getElement(unQuote(value),1,","),"0;1;2;3",";"),";")
:update:

#cmdSetup button Range_600mV AC_Voltage
:write: CONF:VOLT:AC 0.6
:updatedelayed: 0.5
:update: Actual_Range AC_Voltage

#cmdSetup button Range_6V AC_Voltage
:write: CONF:VOLT:AC 6
:updatedelayed: 0.5
:update: Actual_Range AC_Voltage

#cmdSetup button Range_60V AC_Voltage
:write: CONF:VOLT:AC 60
:updatedelayed: 0.5
:update: Actual_Range AC_Voltage

#cmdSetup button Range_600V AC_Voltage
:write: CONF:VOLT:AC 600
:updatedelayed: 0.5
:update: Actual_Range AC_Voltage

; ------------------------------------- Current DC -----------------------------------------------------------
#cmdSetup button Auto_Range DC_Current
:write: CONF:CURR:DC
:updatedelayed: 0.5
:update: Actual_Range DC_Current

#cmdSetup info Actual_Range DC_Current
:read: CONF?
:readmath: getElement("6A;10A",listIndex(getElement(unQuote(value),1,","),"0;1",";"),";")
:update:

#cmdSetup button Range_6A DC_Current
:write: CONF:CURR:DC 6
:updatedelayed: 0.5
:update: Actual_Range DC_Current

#cmdSetup button Range_10A DC_Current
:write: CONF:CURR:DC 10
:updatedelayed: 0.5
:update: Actual_Range DC_Current

; ------------------------------------- Current DC uA-----------------------------------------------------------
#cmdSetup button Auto_Range DC_Current_uA
:write: CONF:CURR:DC
:updatedelayed: 0.5
:update: Actual_Range DC_Current_uA

#cmdSetup info Actual_Range DC_Current_uA
:read: CONF?
:readmath: getElement("60uA;600uA",listIndex(getElement(unQuote(value),1,","),"0;1",";"),";")
:update:

#cmdSetup button Range_60uA DC_Current_uA
:write: CONF:CURR:DC 60u
:updatedelayed: 0.5
:update: Actual_Range DC_Current_uA

#cmdSetup button Range_600uA DC_Current_uA
:write: CONF:CURR:DC 600u
:updatedelayed: 0.5
:update: Actual_Range DC_Current_uA

; ------------------------------------- Current AC -----------------------------------------------------------
#cmdSetup button Auto_Range AC_Current
:write: CONF:CURR:AC
:updatedelayed: 0.5
:update: Actual_Range AC_Current

#cmdSetup info Actual_Range AC_Current
:read: CONF?
:readmath: getElement("6A;10A",listIndex(getElement(unQuote(value),1,","),"0;1",";"),";")
:update:

#cmdSetup button Range_6A AC_Current
:write: CONF:CURR:AC 6
:updatedelayed: 0.5
:update: Actual_Range AC_Current

#cmdSetup button Range_10A AC_Current
:write: CONF:CURR:AC 10
:updatedelayed: 0.5
:update: Actual_Range AC_Current

; ------------------------------------- Current AC uA-----------------------------------------------------------
#cmdSetup button Auto_Range AC_Current_uA
:write: CONF:CURR:AC
:updatedelayed: 0.5
:update: Actual_Range AC_Current_uA

#cmdSetup info Actual_Range AC_Current_uA
:read: CONF?
:readmath: getElement("60uA;600uA",listIndex(getElement(unQuote(value),1,","),"0;1",";"),";")
:update:

#cmdSetup button Range_60uA AC_Current_uA
:write: CONF:CURR:AC 60u
:updatedelayed: 0.5
:update: Actual_Range AC_Current_uA

#cmdSetup button Range_600uA AC_Current_uA
:write: CONF:CURR:AC 600u
:updatedelayed: 0.5
:update: Actual_Range AC_Current_uA

; ------------------------------------- Resistance/Continuity -----------------------------------------------------------
#cmdSetup button Auto_Range Resistance/Continuity
:write: CONF:RES
:updatedelayed: 0.5
:update: Actual_Range Resistance/Continuity

#cmdSetup info Actual_Range Resistance/Continuity
:read: CONF?
:readmath: getElement("600Ohm;6kOhm;60kOhm;600kOhm;6MOhm;60MOhm",listIndex(getElement(unQuote(value),1,","),"0;1;2;3;4;5",";"),";")
:update:

#cmdSetup button Range_600Ohm Resistance/Continuity
:write: CONF:RES 600
:updatedelayed: 0.5
:update: Actual_Range Resistance/Continuity

#cmdSetup button Range_6kOhm Resistance/Continuity
:write: CONF:RES 6k
:updatedelayed: 0.5
:update: Actual_Range Resistance/Continuity

#cmdSetup button Range_60kOhm Resistance/Continuity
:write: CONF:RES 60k
:updatedelayed: 0.5
:update: Actual_Range Resistance/Continuity

#cmdSetup button Range_600kOhm Resistance/Continuity
:write: CONF:RES 600k
:updatedelayed: 0.5
:update: Actual_Range Resistance/Continuity

#cmdSetup button Range_6MOhm Resistance/Continuity
:write: CONF:RES 6M
:updatedelayed: 0.5
:update: Actual_Range Resistance/Continuity

#cmdSetup button Range_60MOhm Resistance/Continuity
:write: CONF:RES 60M
:updatedelayed: 0.5
:update: Actual_Range Resistance/Continuity

; ------------------------------------- Capacity -----------------------------------------------------------
#cmdSetup button Auto_Range Capacity
:write: CONF:CAP
:updatedelayed: 0.5
:update: Actual_Range Capacity

#cmdSetup info Actual_Range Capacity
:read: CONF?
:readmath: getElement("1000nF;10uF;100uF;1000uF;10mF",listIndex(getElement(unQuote(value),1,","),"0;1;2;3;4",";"),";")
:update:

#cmdSetup button Range_1000nF Capacity
:write: CONF:CAP 1000n
:updatedelayed: 0.5
:update: Actual_Range Capacity

#cmdSetup button Range_10uF Capacity
:write: CONF:CAP 10u
:updatedelayed: 0.5
:update: Actual_Range Capacity

#cmdSetup button Range_100uF Capacity
:write: CONF:CAP 100u
:updatedelayed: 0.5
:update: Actual_Range Capacity

#cmdSetup button Range_1000uF Capacity
:write: CONF:CAP 1000u
:updatedelayed: 0.5
:update: Actual_Range Capacity

#cmdSetup button Range_10mF Capacity
:write: CONF:CAP 10m
:updatedelayed: 0.5
:update: Actual_Range Capacity

; ------------------------------------------------------------------------------------------------------------
;#cmdSetup info Rotary_Switch
;:read: STAT?
;:readmath: getElement("Zlow;AC Volt / Frequency;DC Volt;Resistance / Continuity;Diode;Capacity / Temperature;Current / Frequency;Current uA / Frequency;",listIndex(substring(value,16,17),"0;1;2;3;4;5;6;7",";"),";")
;:updatemodechange:

#cmdSetup info Battery
:read: SYST:BATT?
:updatemodechange:
; ------------------------------------------------------------------------------------------------------------

#cmdSetup selector Mode_settings 
:read: CONF?
:readmath: getElement(unQuote(value),0,",")+getElement(unQuote(value),2,",")
:updatemodechange:
VDC DC_Voltage.
VAC AC_Voltage.
ADC DC_Current.
UADC DC_Current_uA.
AAC AC_Current.
UAAC AC_Current_uA.
DIOD Diode.
CAP Capacity.
FREQAC Frequency.
RES Resistance/Continuity.
TEMP Temperature.



