
#metadef
#idString Keysight Technologies,U1241C,
#name Keysight U1241C
#handle K1241

;untested
#metadef
#idString Keysight Technologies,U1242C,
#name Keysight U1242C
#handle K1242

#meta
#idString Keysight Technologies,U1241C,
#name Keysight U1241C
#handle K1241
#port com
#driver KeysightDMM
#baudrate 9600
#author WS

#notes Added configuration for measurement ranges
Restrictions: 
- 2nd Function measurement (frequency, Volt, Current, Temp) not implemented.
- Readback of autorange on/off not possible.
- A current reports same mode as uA/mA current mode back.
- Zlow measurement reports Voltage measurement back, fixed range 1000V. 

; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6)
#value DC_Voltage V d5 VOLT,DIOD,NCV
#value Harmonic_Ratio VOLT:HRAT
#value AC_Voltage V d4 VOLT:AC
#value DC_Current A si CURR,CURRA
#value AC_Current A si CURR:AC
#value Resistance ohm si RES
#value Continuity ohm si CONT
#value Capacity F si CAP
#value Temperature °C d1 TEMP:K,TEMP:J,TEMP
#value Frequency Hz si FREQ,FREQ:AC
#value CurrentLoop % CPER:0-20mA, CPER:4-20mA  

; 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," ");

#interfaceType DMM
#interface readValue 0

;Mode-------------------------------------------------------------------------------------------
#cmdSetup info Active_Mode
:read: CONF?
:readmath: getElement("DC_Voltage;AC_Voltage;Resistance;DC_Current;AC_Current;Diode;Continuity;Frequency;Frequency;Capacity;CurrentLoop;CurrentLoop;Temperature;Temperature;Temperature;Harmonic_Ratio;NCV",listIndex(getElement(unQuote(value),0," "),"VOLT VOLT:AC RES CURR CURR:AC DIOD CONT FREQ FREQ:AC CAP CPER:4-20mA CPER:0-20mA TEMP:K TEMP:J TEMP VOLT:HRAT NCV"," "),";")
:updatemodechange:

#cmdSetup info Battery
:read: SYST:BATT?
: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 _ _

; ------------------------------------- DC_Voltage -----------------------------------------------------------
#cmdSetup button Auto_Range DC_Voltage
:write: CONF:VOLT:DC
:updatedelayed: 1
:update: Actual_Range DC_Voltage

#cmdSetup info Actual_Range DC_Voltage
:read: CONF?
:readmath: getElement("1V;10V;100V;1000V",listIndex(getElement(unQuote(value),1," "),"+1.00000000E+00,+1.00000000E-04;+1.00000000E+01,+1.00000000E-03;+1.00000000E+02,+1.00000000E-02;+1.00000000E+03,+1.00000000E-01",";"),";")

#cmdSetup button Range_1V DC_Voltage
:write: CONF:VOLT:DC 1
:updatedelayed: 1
:update: Actual_Range DC_Voltage

#cmdSetup button Range_10V DC_Voltage
:write: CONF:VOLT:DC 10
:updatedelayed: 1
:update: Actual_Range DC_Voltage

#cmdSetup button Range_100V DC_Voltage
:write: CONF:VOLT:DC 100
:updatedelayed: 1
:update: Actual_Range DC_Voltage

#cmdSetup button Range_1000V DC_Voltage
:write: CONF:VOLT:DC 1000
:updatedelayed: 1
:update: Actual_Range DC_Voltage

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

#cmdSetup info Actual_Range AC_Voltage
:read: CONF?
:readmath: getElement("1V;10V;100V;1000V",listIndex(getElement(unQuote(value),1," "),"+1.00000000E+00,+1.00000000E-04;+1.00000000E+01,+1.00000000E-03;+1.00000000E+02,+1.00000000E-02;+1.00000000E+03,+1.00000000E-01",";"),";")

#cmdSetup button Range_1V AC_Voltage
:write: CONF:VOLT:AC 1
:updatedelayed: 1
:update: Actual_Range DC_Voltage

#cmdSetup button Range_10V AC_Voltage
:write: CONF:VOLT:AC 10
:updatedelayed: 1
:update: Actual_Range AC_Voltage

#cmdSetup button Range_100V AC_Voltage
:write: CONF:VOLT:AC 100
:updatedelayed: 1
:update: Actual_Range AC_Voltage

#cmdSetup button Range_1000V AC_Voltage
:write: CONF:VOLT:AC 1000
:updatedelayed: 1
:update: Actual_Range AC_Voltage

; ------------------------------------- Resistance -----------------------------------------------------------
#cmdSetup button Auto_Range Resistance
:write: CONF:RES
:updatedelayed: 1
:update: Actual_Range Resistance

#cmdSetup info Actual_Range Resistance
:read: CONF?
:readmath: getElement("1kOhm;10kOhm;100kOhm;1MOhm;10MOhm;100MOhm",listIndex(getElement(unQuote(value),1," "),"+1.00000000E+03,+1.00000000E-01;+1.00000000E+04,+1.00000000E+00;+1.00000000E+05,+1.00000000E+01;+1.00000000E+06,+1.00000000E+02;+1.00000000E+07,+1.00000000E+03;+1.00000000E+08,+1.00000000E+04",";"),";")

#cmdSetup button Range_1kOhm Resistance
:write: CONF:RES 1000
:updatedelayed: 1
:update: Actual_Range Resistance

#cmdSetup button Range_10kOhm Resistance
:write: CONF:RES 10k
:updatedelayed: 1
:update: Actual_Range Resistance

#cmdSetup button Range_100kOhm Resistance
:write: CONF:RES 100k
:updatedelayed: 1
:update: Actual_Range Resistance

#cmdSetup button Range_1MOhm Resistance
:write: CONF:RES 1000k
:updatedelayed: 1
:update: Actual_Range Resistance

#cmdSetup button Range_10MOhm Resistance
:write: CONF:RES 10M
:updatedelayed: 1
:update: Actual_Range Resistance

#cmdSetup button Range_100MOhm Resistance
:write: CONF:RES 100M
:updatedelayed: 1
:update: Actual_Range Resistance

; ------------------------------------- Continuity -----------------------------------------------------------
#cmdSetup button Auto_Range Continuity
:write: CONF:CONT
:updatedelayed: 1
:update: Actual_Range Continuity

#cmdSetup info Actual_Range Continuity
:read: CONF?
:readmath: getElement("1kOhm;10kOhm;100kOhm;1MOhm;10MOhm;100MOhm",listIndex(getElement(unQuote(value),1," "),"+1.00000000E+03,+1.00000000E-01;+1.00000000E+04,+1.00000000E+00;+1.00000000E+05,+1.00000000E+01;+1.00000000E+06,+1.00000000E+02;+1.00000000E+07,+1.00000000E+03;+1.00000000E+08,+1.00000000E+04",";"),";")

#cmdSetup button Range_1kOhm Continuity
:write: CONF:CONT 1000
:updatedelayed: 1
:update: Actual_Range Continuity

#cmdSetup button Range_10kOhm Continuity
:write: CONF:CONT 10k
:updatedelayed: 1
:update: Actual_Range Continuity

#cmdSetup button Range_100kOhm Continuity
:write: CONF:CONT 100k
:updatedelayed: 1
:update: Actual_Range Continuity

#cmdSetup button Range_1MOhm Continuity
:write: CONF:CONT 1000k
:updatedelayed: 1
:update: Actual_Range Continuity

#cmdSetup button Range_10MOhm Continuity
:write: CONF:CONT 10M
:updatedelayed: 1
:update: Actual_Range Continuity

#cmdSetup button Range_100MOhm Continuity
:write: CONF:CONT 100M
:updatedelayed: 1
:update: Actual_Range Continuity

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

#cmdSetup info Actual_Range Capacity
:read: CONF?
:readmath: getElement("1000nF;10uF;100uF;1000uF;10mF",listIndex(getElement(unQuote(value),1," "),"+1.00000000E-06,+1.00000000E-10;+1.00000000E-05,+1.00000000E-09;+1.00000000E-04,+1.00000000E-08;+1.00000000E-03,+1.00000000E-07;+1.00000000E-02,+1.00000000E-06",";"),";")

#cmdSetup button Range_1uF 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

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

#cmdSetup info Actual_Range DC_Current
:read: CONF?
:readmath: getElement("1000uA;10mA;100mA;1000mA;10A",listIndex(getElement(unQuote(value),1," "),"+1.00000000E-03,+1.00000000E-07;+1.00000000E-02,+1.00000000E-06;+1.00000000E-01,+1.00000000E-05;+1.00000000E+00,+1.00000000E-04;+1.00000000E+01,+1.00000000E-03",";"),";")

#cmdSetup button Range_1000uA DC_Current
:write: CONF:CURR:DC 1000u
:updatedelayed: 1
:update: Actual_Range DC_Current

#cmdSetup button Range_10mA DC_Current
:write: CONF:CURR:DC 10m
:updatedelayed: 1
:update: Actual_Range DC_Current

#cmdSetup button Range_100mA DC_Current
:write: CONF:CURR:DC 100m
:updatedelayed: 1
:update: Actual_Range DC_Current

#cmdSetup button Range_1000mA DC_Current
:write: CONF:CURR:DC 1000m
:updatedelayed: 1
:update: Actual_Range DC_Current

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

#cmdSetup info Actual_Range AC_Current
:read: CONF?
:readmath: getElement("1000uA;10mA;100mA;1000mA;10A",listIndex(getElement(unQuote(value),1," "),"+1.00000000E-03,+1.00000000E-07;+1.00000000E-02,+1.00000000E-06;+1.00000000E-01,+1.00000000E-05;+1.00000000E+00,+1.00000000E-04;+1.00000000E+01,+1.00000000E-03",";"),";")

#cmdSetup button Range_1000uA AC_Current
:write: CONF:CURR:AC 1000u
:updatedelayed: 1
:update: Actual_Range AC_Current

#cmdSetup button Range_10mA AC_Current
:write: CONF:CURR:AC 10m
:updatedelayed: 1
:update: Actual_Range AC_Current

#cmdSetup button Range_100mA AC_Current
:write: CONF:CURR:AC 100m
:updatedelayed: 1
:update: Actual_Range AC_Current

#cmdSetup button Range_1000mA AC_Current
:write: CONF:CURR:AC 1000m
:updatedelayed: 1
:update: Actual_Range AC_Current

; ------------------------------------------------------------------------------------------------

#cmdSetup selector Mode_settings 
:read: CONF?
:readmath: getElement(unQuote(value),0," ")
:updatemodechange:
VOLT DC_Voltage.
VOLT:AC AC_Voltage.
CURR DC_Current.
CURR:AC AC_Current.
DIOD Diode.
CAP Capacity.
FREQ Frequency.
FREQ:AC Frequency.
RES Resistance.
CONT Continuity.
PER Period.
CPER:4-20mA CurrentLoop.
CPER:0-20mA CurrentLoop.
TEMP:K Temperature.
TEMP:J Temperature.
TEMP Temperature.
VOLT:HRAT Harmonic_Ratio.
NCV NCV.