;-----------------------------------------------------------------------------
; R&S HMO12X2/RTC1002 2 channel scope meter
;
; Revision 1.0  19 Feb 2022     Inital release
;
;          1.1  30 Jul 2022     Add hardcopy menu item
;                               Add device status dialog
;                               Add waveform download (Analog, Logic, Bus)
;                               Add pattern gnerator upload/download
;                               Add pattern generator control
;                               Update function generator GUI
;                               Update measurement GUI
;                               Add DVM and counter to measurement
;                               Add cursor measurement
;                               Add trigger configuration
;                               Add virtual screen/message control
;                               Add file upload/download/directory change
;
;-----------------------------------------------------------------------------

#author PL (based on HMO1022, WA)


;------------------------------------------------------------
; Devices
;------------------------------------------------------------

#metadef
#idString Rohde&Schwarz,RTC1002,
#name     R&S RTC1002
#handle   RTC1002
#port     com 5025 LXI GPIB
#baudrate 115200

#metadef
#idString Rohde&Schwarz,HMO1202,
#name     R&S HMO1202
#handle   HMO1202
#port     com 5025 LXI GPIB
#baudrate 115200

#metadef
#idString Rohde&Schwarz,HMO1212,
#name     R&S HMO1212
#handle   HMO1212
#port     com 5025 LXI GPIB
#baudrate 115200

#metadef
#idString Rohde&Schwarz,HMO1222,
#name     R&S HMO1222
#handle   HMO1222
#port     com 5025 LXI GPIB
#baudrate 115200

#metadef
#idString Rohde&Schwarz,HMO1232,
#name     R&S HMO1232
#handle   HMO1232
#port     com 5025 LXI GPIB
#baudrate 115200

#meta
#idString Rohde&Schwarz,XXXXXX,
#name     R&S XXXXXX
#handle   XXXXXX
#port     com 5025 LXI GPIB
#baudrate 115200

#driver   SCPIx


;------------------------------------------------------------------------------------
; Emulation Layer
;------------------------------------------------------------------------------------

; Internal: show measurement configurations (slow)
#scpiCmd MEAS:SHOW none
:setvar: measshow=inputValue
#scpiCmd MEAS:SHOW? none?
:readmath: varExists("measshow")?(measshow):(0)

; Internal: show utilites
#scpiCmd UTIL:SHOW none
:setvar: utilshow=inputValue
#scpiCmd UTIL:SHOW? none?
:readmath: varExists("utilshow")?(utilshow):(0)

; Internal: show bus
#scpiCmd BUS:SHOW none
:setvar: busshow=inputValue
#scpiCmd BUS:SHOW? none?
:readmath: varExists("busshow")?(busshow):(0)

; Internal: show bus 1 type
#scpiCmd HORIZ:SHOW none
:setvar: horizshow=inputValue
#scpiCmd HORIZ:SHOW? none?
:readmath: varExists("horizshow")?(horizshow):(0)




;------------------------------------------------------------
; Low-Level Interface
;------------------------------------------------------------

; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6)
#value Mean V SI MEAN
#value RMS V SI RMS
#value Vpp V SI PEAK
#value Vp+ V SI UPE
#value Vp- V SI LPE
#value f Hz d4 FREQ
#value T s SI PER
#value VAmp V SI AMPL
#value Crest 1 SI CRES
#value Vtop V SI HIGH
#value Vbase V SI LOW
#value +Ovr % SI POV
#value -Ovr % SI NOV
#value PW+ s SI PPW
#value PW- s SI NPW
#value Dty+ % SI PDCY
#value Dty- % SI NDCY
#value tr s SI RTIM
#value tf s SI FTIM
#value StdDev V SI STDD
#value Dly s SI DEL
#value Phs Deg SI PHAS
#value Bst s SI BWID
#value CntP+ 1 SI PPC
#value CntP- 1 SI NPC
#value CntS+ 1 SI REC
#value CntS- 1 SI FEC
#value f(Tr) Hz SI TFR
#value T(Tr) s SI TPER

; Optional Channels
#value Meas2 - SI Meas_2
#value Meas3 - SI Meas_3
#value Meas4 - SI Meas_4
#value Meas5 - SI Meas_5
#value Meas6 - SI Meas_6
#value DVM1 V SI DVM_1
#value DVM2 V SI DVM_2
#value DVM3 V SI DVM_3
#value DVM4 V SI DVM_4
#value TCO Hz SI TCO
#value Cursor - SI Cursor

; 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 :MEAS1:RES?;[mode:Meas_2]MEAS2:RES?;[mode:Meas_3]MEAS3:RES?;[mode:Meas_4]MEAS4:RES?;[mode:Meas_5]MEAS5:RES?;[mode:Meas_6]MEAS6:RES?;[mode:DVM_1]DVM1:RES?;[mode:DVM_2]DVM2:RES?;[mode:DVM_3]DVM3:RES?;[mode:DVM_4]DVM4:RES?;[mode:TCO]TCO:RES?;[mode:Cursor]CURS:RES?
#askValuesReadFormat FFFFFFFFFFFF

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

; Prepare the meter to response to #askValues
#prepareSample

#outputOff GEN:OUTP 0


;------------------------------------------------------------------------------------
; Interface
;------------------------------------------------------------------------------------

#interfaceType OSC OSC:2

; Channels CH1-CH2

; Channel State (on/off)
; value: 0, 1
#interface setCHState CHAN(channel):STAT (value)
#interface getCHState CHAN(channel):STAT?

; Channel Coupling
; value: "{DCLimit|ACLimit|GND}"
#interface setCHCoupling CHAN(channel):COUP (value)
#interface getCHCoupling CHAN(channel):COUP?
:string:

; Channel Polarity
; value: {NORMal|INVerted}
#interface setCHPolarity CHAN(channel):POL (value)
#interface getCHPolarity CHAN(channel):POL?
:string:

; Channel Bandwidth
; {FULL|B20}
#interface setCHBW CHAN(channel):BAND (value)
#interface getCHBW CHAN(channel):BAND?
:string:

; Channel Scale
#interface setCHScale CHAN(channel):SCALE (value)
#interface getCHScale CHAN(channel):SCALE?

; Channel Offset
#interface setCHOffset CHAN(channel):POS (value)
#interface getCHOffset CHAN(channel):POS?


; Global Settings

; Horizontal Scale
#interface setHorizontalScale TIM:SCALE (value)
#interface getHorizontalScale TIM:SCALE?

; Acquisition Mode
; value: "{REFresh|SMOoth|AVERage|ENVelope|FILTer|REFresh}"
#interface setAcquireMode ACQ:TYPE (value)
#interface getAcquireMode ACQ:TYPE?
:string:


; Measurement 1-6 (channel independent)

; Enable or disable Measurement 1-6
; value: 0|1
;---------------------------------------------------------------------------------------------
#interface setMeasState1   MEAS1:ENAB (value)
#interface setMeasState2   MEAS2:ENAB (value)
#interface setMeasState3   MEAS3:ENAB (value)
#interface setMeasState4   MEAS4:ENAB (value)
#interface setMeasState5   MEAS5:ENAB (value)
#interface setMeasState6   MEAS6:ENAB (value)

#interface getMeasState1   MEAS1:ENAB?
#interface getMeasState2   MEAS2:ENAB?
#interface getMeasState3   MEAS3:ENAB?
#interface getMeasState4   MEAS4:ENAB?
#interface getMeasState5   MEAS5:ENAB?
#interface getMeasState6   MEAS6:ENAB?

; Select Measurement 1-6 source (two sources for "DELay" or "PHASe")
; value: "{CH1-2|D0-7|EXT|QMA|MA1-5|RE1-4|TRIGger}[,{CH1-2|D0-7|EXT|QMA|MA1-5|RE1-4|TRIGger}]"
;---------------------------------------------------------------------------------------------
#interface setMeasSource1  MEAS1:SOUR (value)
#interface setMeasSource2  MEAS2:SOUR (value)
#interface setMeasSource3  MEAS3:SOUR (value)
#interface setMeasSource4  MEAS4:SOUR (value)
#interface setMeasSource5  MEAS5:SOUR (value)
#interface setMeasSource6  MEAS6:SOUR (value)

#interface getMeasSource1  MEAS1:SOUR?
:string:
#interface getMeasSource2  MEAS2:SOUR?
:string:
#interface getMeasSource3  MEAS3:SOUR?
:string:
#interface getMeasSource4  MEAS4:SOUR?
:string:
#interface getMeasSource5  MEAS5:SOUR?
:string:
#interface getMeasSource6  MEAS6:SOUR?
:string:

; Select Measurement 1-6 measurement type
; value: "{FREQuency|PERiod|PEAK|UPEakvalue|LPEakvalue|PPCount|NPCount|RECount|FECount|HIGH|LOW|
;         AMPLitude|CRESt|MEAN|RMS|RTIMe|FTIMe|PDCYcle|NDCYcle|PPWidth|NPWidth|CYCMean|CYCRms|
;         STDDev|TFRequency|TPERiode|DELay|PHASe|BWIDth|POVershoot|NOVershoot}"
;---------------------------------------------------------------------------------------------
#interface setMeasType1    MEAS1:MAIN (value)
#interface setMeasType2    MEAS2:MAIN (value)
#interface setMeasType3    MEAS3:MAIN (value)
#interface setMeasType4    MEAS4:MAIN (value)
#interface setMeasType5    MEAS5:MAIN (value)
#interface setMeasType6    MEAS6:MAIN (value)

#interface getMeasType1    MEAS1:MAIN?
:string:
#interface getMeasType2    MEAS2:MAIN?
:string:
#interface getMeasType3    MEAS3:MAIN?
:string:
#interface getMeasType4    MEAS4:MAIN?
:string:
#interface getMeasType5    MEAS5:MAIN?
:string:
#interface getMeasType6    MEAS6:MAIN?
:string:

; Select Slope polarity for "DELay" or "PHASe"
; value: "{POS|NEG},{NEG|POS}"
;---------------------------------------------------------------------------------------------
#interface setMeasSlope1   MEAS1:DEL:SLOP (value)
#interface setMeasSlope2   MEAS2:DEL:SLOP (value)
#interface setMeasSlope3   MEAS3:DEL:SLOP (value)
#interface setMeasSlope4   MEAS4:DEL:SLOP (value)
#interface setMeasSlope5   MEAS5:DEL:SLOP (value)
#interface setMeasSlope6   MEAS6:DEL:SLOP (value)

#interface getMeasSlope1   MEAS1:DEL:SLOP?
:string:
#interface getMeasSlope2   MEAS2:DEL:SLOP?
:string:
#interface getMeasSlope3   MEAS3:DEL:SLOP?
:string:
#interface getMeasSlope4   MEAS4:DEL:SLOP?
:string:
#interface getMeasSlope5   MEAS5:DEL:SLOP?
:string:
#interface getMeasSlope6   MEAS6:DEL:SLOP?
:string:

; Read measurement result
; value: float
;---------------------------------------------------------------------------------------------
#interface getMeasValue1   MEAS1:RES?
#interface getMeasValue2   MEAS2:RES?
#interface getMeasValue3   MEAS3:RES?
#interface getMeasValue4   MEAS4:RES?
#interface getMeasValue5   MEAS5:RES?
#interface getMeasValue6   MEAS6:RES?

#interface readMeasValue  0
#interface readMeasValue1 0
#interface readMeasValue2 1 ; also 2-6
#interface readMeasValue3 2 ; also 3-6
#interface readMeasValue4 3 ; also 4-6
#interface readMeasValue5 5 ; also 5-6
#interface readMeasValue6 6


;------------------------------------------------------------------------------------
; Mode Commands
;------------------------------------------------------------------------------------

#cmdModeLayout 2 8


; 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 Meas_1_Sync _ _

#cmdModeCheck DVM_1 m2 0
[localMode]
[localMode]

#cmdModeCheck Meas_2 m2 0
[localMode]
[localMode]

#cmdModeCheck DVM_2 m2 0
[localMode]
[localMode]

#cmdModeCheck Meas_3 m2 0
[localMode]
[localMode]

#cmdModeCheck DVM_3 m2 0
[localMode]
[localMode]

#cmdModeCheck Meas_4 m2 0
[localMode]
[localMode]

#cmdModeCheck DVM_4 m2 0
[localMode]
[localMode]

#cmdModeCheck Meas_5 m2 0
[localMode]
[localMode]

#cmdModeCheck TCO m2 0
[localMode]
[localMode]

#cmdModeCheck Meas_6 m2 0
[localMode]
[localMode]

#cmdModeCheck Cursor m2 0
[localMode]
[localMode]

#cmdMode Run Run
RUN

#cmdMode Stop Stop
STOP

#cmdMode Single Single
SING

#cmdMode Auto_Set Auto_Set
AUT


;------------------------------------------------------------------------------------
; CH1
;------------------------------------------------------------------------------------

#cmdSetup selector SelectCH1 CH_1
:read:    CHAN1:STAT?
:string:
0 CH_1_OFF. CH_1_Control.
1 CH_1_ON.  CH_1_Control.

#cmdSetup Info CH_1 CH_1_OFF
_ _
#cmdSetup Info CH_1 CH_1_OFF
_________________________________________
_

#cmdSetup separator - CH_1_OFF
:color: (235,235,00)
3 100 Solid


#cmdSetup Info CH_1 CH_1_ON

#cmdSetup separator - CH_1_ON
:color: (235,235,00)
3 100 Solid

#cmdSetup number Position CH_1_ON
:read:    CHAN1:POS?
:write:   CHAN1:POS
;:textwidth: 8
div -1.5E+01 1.5E+01

;#cmdSetup slider Position CH_1_ON
;:read:    CHAN1:POS?
;:write:   CHAN1:POS
;div -15 15

#cmdSetup number Scale CH_1_ON
:read:    CHAN1:SCAL?
:write:   CHAN1:SCAL
V/div 1.00E-03 1.00E+01

#cmdSetup comboboxhot Coupling CH_1_ON
:read:    CHAN1:COUP?
:write:   CHAN1:COUP
:string:
AC ACL
DC DCL
GND GND

#cmdSetup comboboxhot Bandwidth CH_1_ON
:read:    CHAN1:BAND?
:write:   CHAN1:BAND
:string:
Full   FULL
20_MHz B20

#cmdSetup comboboxhot Invert CH_1_ON
:read:  CHAN1:POL?
:write: CHAN1:POL
:string:
Off NORM
On INV


#cmdSetup separator - CH_1_ON
1 100 Empty

#cmdSetup info Config CH_1_ON

#cmdSetup separator - CH_1_ON
1 100 Solid

#cmdSetup number Skew CH_1_ON
:read:    CHAN1:SKEW?
:write:   CHAN1:SKEW
V -120n 120n

#cmdSetup number Threshold CH_1_ON
:read:    CHAN1:THR?
:write:   CHAN1:THR
V -100 100

#cmdSetup comboboxhot Hysteresis CH_1_ON
:read:    CHAN1:THR:HYST?
:write:   CHAN1:THR:HYST #
Small SMAL
Medium MED
Large LARG

#cmdSetup separator - CH_1_ON
1 100 Solid

#cmdSetup buttonsOn Channel CH_1_Control
:read:    CHAN1:STAT?
:write:   CHAN1:STAT
:color:   (255,255,0)
:update:  CH_1.SelectCH1
:updatealloff:
Off 0
On 1


;------------------------------------------------------------------------------------
; CH2
;------------------------------------------------------------------------------------

#cmdSetup selector SelectCH2 CH_2
:read:    CHAN2:STAT?
:string:
0 CH_2_OFF. CH_2_Control.
1 CH_2_ON.  CH_2_Control.


#cmdSetup Info CH_2 CH_2_OFF
_ _
#cmdSetup Info CH_2 CH_2_OFF
_________________________________________
_

#cmdSetup separator - CH_2_OFF
:color: (0,235,235)
3 100 Solid


#cmdSetup Info CH_2 CH_2_ON

#cmdSetup separator - CH_2_ON
:color: (0,235,235)
3 100 Solid

#cmdSetup number Position CH_2_ON
:read:    CHAN2:POS?
:write:   CHAN2:POS
;:textwidth: 13
div -1.5E+01 1.5E+01

#cmdSetup number Scale CH_2_ON
:read:    CHAN2:SCAL?
:write:   CHAN2:SCAL
V/div 1.00E-03 1.00E+01

#cmdSetup comboboxhot Coupling CH_2_ON
:read:    CHAN2:COUP?
:write:   CHAN2:COUP
:string:
AC ACL
DC DCL
GND GND

#cmdSetup comboboxhot Bandwidth CH_2_ON
:read:    CHAN2:BAND?
:write:   CHAN2:BAND
:string:
Full   FULL
20_MHz B20

#cmdSetup comboboxhot Invert CH_2_ON
:read:  CHAN2:POL?
:write: CHAN2:POL
:string:
Off NORM
On INV


#cmdSetup separator - CH_2_ON
1 100 Empty

#cmdSetup info Config CH_2_ON

#cmdSetup separator - CH_2_ON
1 100 Solid

#cmdSetup number Skew CH_2_ON
:read:    CHAN2:SKEW?
:write:   CHAN2:SKEW
V -120n 120n

#cmdSetup number Threshold CH_2_ON
:read:    CHAN2:THR?
:write:   CHAN2:THR
V -100 100

#cmdSetup comboboxhot Hysteresis CH_2_ON
:read:    CHAN2:THR:HYST?
:write:   CHAN2:THR:HYST #
Small SMAL
Medium MED
Large LARG

#cmdSetup separator - CH_2_ON
1 100 Solid

#cmdSetup buttonsOn Channel CH_2_Control
:read:    CHAN2:STAT?
:write:   CHAN2:STAT
:color:   (0,255,255)
:update:  CH_2.SelectCH2
:updatealloff:
Off 0
On 1


;------------------------------------------------------------------------------------
; EXT
;------------------------------------------------------------------------------------

#cmdSetup selector SelectEXT EXT
:read:    EXT:STAT?
:string:
0 EXT_OFF. EXT_Control.
1 EXT_ON.  EXT_Control.


#cmdSetup Info EXT EXT_OFF
_ _
#cmdSetup Info EXT EXT_OFF
_________________________________________
_

#cmdSetup separator - EXT_OFF
:color: (0,235,0)
3 100 Solid


#cmdSetup Info EXT EXT_ON

#cmdSetup separator - EXT_ON
:color: (0,235,0)
3 100 Solid

#cmdSetup number Position EXT_ON
:read:    EXT:POS?
:write:   EXT:POS
:textwidth: 8
div -1.5E+01 1.5E+01

#cmdSetup comboboxhot Scale EXT_ON
:read:    EXT:SIZE?
:write:   EXT:SIZE #
Small  SMAL
Medium MED
Large  LARG

#cmdSetup comboboxhot Coupling EXT_ON
:read:    EXT:COUP?
:write:   EXT:COUP
:string:
AC AC
DC DC


#cmdSetup separator - EXT_ON
1 100 Empty

#cmdSetup info Config EXT_ON

#cmdSetup separator - EXT_ON
1 100 Solid

#cmdSetup number Skew EXT_ON
:read:    EXT:DESKEW?
:write:   EXT:DESKEW
V -42n 42n

#cmdSetup number Threshold EXT_ON
:read:    EXT:THR?
:write:   EXT:THR
V -5.5 5.5

#cmdSetup separator - EXT_ON
1 100 Solid

; NOTE: Timeout when B1 and B2 are enabled
#cmdSetup buttonsOn Channel EXT_Control
:read:    EXT:STAT?
:write:   EXT:STAT
:color:   (0,255,0)
:update:  EXT.SelectEXT
:updatealloff:
Off 0
On 1


;------------------------------------------------------------------------------------
; POD
;------------------------------------------------------------------------------------

#cmdSetup selector SelectPOD POD
:read:    POD:STAT?
:string:
0 POD_OFF. POD_Control.
1 POD_ON.


#cmdSetup Info POD POD_OFF
_ _
#cmdSetup Info POD POD_OFF
_________________________________________
_

#cmdSetup separator - POD_OFF
:color: (235,0,235)
3 100 Solid


#cmdSetup Info POD POD_ON

#cmdSetup separator - POD_ON
:color: (235,0,235)
3 100 Solid

#cmdSetup multi Position_D0 POD_ON
:read:    LOG0:STAT?;LOG0:POS?
:write:   LOG0:STAT #;LOG0:POS #
Checkbox  _ 0 1
Number _ div -1.5E+01 1.5E+01

#cmdSetup multi Position_D1 POD_ON
:read:    LOG1:STAT?;LOG1:POS?
:write:   LOG1:STAT #;LOG1:POS #
Checkbox  _ 0 1
Number _ div -1.5E+01 1.5E+01

#cmdSetup multi Position_D2 POD_ON
:read:    LOG2:STAT?;LOG2:POS?
:write:   LOG2:STAT #;LOG2:POS #
Checkbox  _ 0 1
Number _ div -1.5E+01 1.5E+01

#cmdSetup multi Position_D3 POD_ON
:read:    LOG3:STAT?;LOG3:POS?
:write:   LOG3:STAT #;LOG3:POS #
Checkbox  _ 0 1
Number _ div -1.5E+01 1.5E+01

#cmdSetup multi Position_D4 POD_ON
:read:    LOG4:STAT?;LOG4:POS?
:write:   LOG4:STAT #;LOG4:POS #
Checkbox  _ 0 1
Number _ div -1.5E+01 1.5E+01

#cmdSetup multi Position_D5 POD_ON
:read:    LOG5:STAT?;LOG5:POS?
:write:   LOG5:STAT #;LOG5:POS #
Checkbox  _ 0 1
Number _ div -1.5E+01 1.5E+01

#cmdSetup multi Position_D6 POD_ON
:read:    LOG6:STAT?;LOG6:POS?
:write:   LOG6:STAT #;LOG6:POS #
Checkbox  _ 0 1
Number _ div -1.5E+01 1.5E+01

#cmdSetup multi Position_D7 POD_ON
:read:    LOG7:STAT?;LOG7:POS?
:write:   LOG7:STAT #;LOG7:POS #
Checkbox  _ 0 1
Number _ div -1.5E+01 1.5E+01

#cmdSetup comboboxhot Scale POD_ON
:read:    LOG0:SIZE?
:write:   LOG0:SIZE #;LOG1:SIZE #;LOG2:SIZE #;LOG3:SIZE #;LOG4:SIZE #;LOG5:SIZE #;LOG6:SIZE #;LOG7:SIZE #
:update:  POD.Position_D0 POD.Position_D1 POD.Position_D2 POD.Position_D3 POD.Position_D4 POD.Position_D5 POD.Position_D6 POD.Position_D7
Small     SMAL
Medium    MED
Large     LARG


#cmdSetup separator - POD_ON
1 100 Empty

#cmdSetup info Config POD_ON

#cmdSetup separator - POD_ON
1 100 Solid

#cmdSetup comboboxhot Threshold POD_ON
:read:    POD:THR?
:write:   POD:THR #
:update:  POD_ON.SelectThreshold
TTL    TTL
ECL    ECL
CMOS   CMOS
User_1 USER
User_2 USER2

#cmdSetup selector SelectThreshold POD_ON
:read:    POD:THR?
TTL    POD_ON_PRESET. POD_ON_TAIL. POD_Control.
ECL    POD_ON_PRESET. POD_ON_TAIL. POD_Control.
CMOS   POD_ON_PRESET. POD_ON_TAIL. POD_Control.
USER   POD_ON_USER1.  POD_ON_TAIL. POD_Control.
USER2  POD_ON_USER2.  POD_ON_TAIL. POD_Control.

#cmdSetup number User_1 POD_ON_PRESET
:enable:  (0)
:textwidth: 7
V -2 8

#cmdSetup number User_1 POD_ON_USER1
:read:    POD:THR:UDL1?
:write:   POD:THR:UDL1
:textwidth: 7
V -2 8

#cmdSetup number User_2 POD_ON_USER2
:read:    POD:THR:UDL2?
:write:   POD:THR:UDL2
:textwidth: 7
V -2 8

#cmdSetup separator - POD_ON_TAIL
1 100 Solid

#cmdSetup buttonsOn Channel POD_Control
:read:     POD:STAT?
:write:    POD:STAT
:update:   POD.SelectPOD
:color:    (255,0,255)
:updatealloff:
Off 0
On 1


;------------------------------------------------------------------------------------
; BUS
;------------------------------------------------------------------------------------

#cmdSetup radio BUS BUS
:read:    BUS:SHOW?
:write:   BUS:SHOW #
:update:  SelectBus
:string:
B1 0
B2 1

#cmdSetup separator - BUS
:color: white
3 100 Solid

#cmdSetup selector SelectBus BUS
:read:    BUS:SHOW?
0  BUS_B1_SEL.
1  BUS_B2_SEL.


; ----- Bus 1 -----------------------------------------------------------------------

#cmdSetup number Position BUS_B1_SEL
:read:    BUS1:POS?
:write:   BUS1:POS #
div -1.5E+01 1.5E+01

#cmdSetup comboboxhot Scale BUS_B1_SEL
:read:    BUS1:DSIZ?
:write:   BUS1:DSIZ #
Small  SMAL
Medium MED
Large  LARG

#cmdSetup selector SelectBusB1 BUS_B1_SEL
:read:    BUS1:STAT?
0         BUS_B1_Control.
1         BUS_B1.


#cmdSetup comboboxhot Signals BUS_B1
:read:    BUS1:DSIG?
:write:   BUS1:DSIG #
Off 0
On  1

#cmdSetup comboboxhot Format BUS_B1
:read:    BUS1:FORM?
:write:   BUS1:FORM #
Binary      BIN
Hexadecimal HEX
Decimal     DEC
Octal       OCT
ASCII       ASC

#cmdSetup separator - BUS_B1
3 100 Empty

#cmdSetup comboboxhot Config BUS_B1
:read:    BUS1:TYPE?
:write:   BUS1:TYPE #
:update:  BUS_B1.SelectBus1Type
Parallel_Clocked CPAR
Parallel         PAR
I2C              I2C
SPI_(3_Wire)     SPI
SSPI_(2_Wire)    SSPI
UART             UART
CAN              CAN
LIN              LIN

#cmdSetup separator - BUS_B1
1 100 Solid

#cmdSetup selector SelectBus1Type BUS_B1
:read:    BUS1:TYPE?
:string:
CPAR BUS_B1_CPAR. BUS_B1_Control.
PAR  BUS_B1_PAR.  BUS_B1_Control.
I2C  BUS_B1_I2C.  BUS_B1_Control.
SPI  BUS_B1_SPI.  BUS_B1_Control.
SSPI BUS_B1_SSPI. BUS_B1_Control.
UART BUS_B1_UART. BUS_B1_Control.
CAN  BUS_B1_CAN.  BUS_B1_Control.
LIN  BUS_B1_LIN.  BUS_B1_Control.


; PAR
#cmdSetup comboboxhot DATA BUS_B1_PAR
:read:    BUS1:PAR:WIDT?
:write:   BUS1:PAR:WIDT #
1_Bit 1
2_Bit 2
3_Bit 3
4_Bit 4
5_Bit 5
6_Bit 6
7_Bit 7
8_Bit 8

#cmdSetup comboboxhot D0 BUS_B1_PAR
:read:    BUS1:PAR:DATA0:SOUR?
:write:   BUS1:PAR:DATA0:SOUR #
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D1 BUS_B1_PAR
:read:    BUS1:PAR:DATA1:SOUR?
:write:   BUS1:PAR:DATA1:SOUR #
:enable:  inList(BUS_B1_PAR.DATA, "2,3,4,5,6,7,8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D2 BUS_B1_PAR
:read:    BUS1:PAR:DATA2:SOUR?
:write:   BUS1:PAR:DATA2:SOUR #
:enable:  inList(BUS_B1_PAR.DATA, "3,4,5,6,7,8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D3 BUS_B1_PAR
:read:    BUS1:PAR:DATA3:SOUR?
:write:   BUS1:PAR:DATA3:SOUR #
:enable:  inList(BUS_B1_PAR.DATA, "4,5,6,7,8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D4 BUS_B1_PAR
:read:    BUS1:PAR:DATA4:SOUR?
:write:   BUS1:PAR:DATA4:SOUR #
:enable:  inList(BUS_B1_PAR.DATA, "5,6,7,8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D5 BUS_B1_PAR
:read:    BUS1:PAR:DATA5:SOUR?
:write:   BUS1:PAR:DATA5:SOUR #
:enable:  inList(BUS_B1_PAR.DATA, "6,7,8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D6 BUS_B1_PAR
:read:    BUS1:PAR:DATA6:SOUR?
:write:   BUS1:PAR:DATA6:SOUR #
:enable:  inList(BUS_B1_PAR.DATA, "7,8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D7 BUS_B1_PAR
:read:    BUS1:PAR:DATA7:SOUR?
:write:   BUS1:PAR:DATA7:SOUR #
:enable:  inList(BUS_B1_PAR.DATA, "8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7


; CPAR
#cmdSetup comboboxhot CLK BUS_B1_CPAR
:read:    BUS1:CPAR:CLOC:SOUR?
:write:   BUS1:CPAR:CLOC:SOUR #
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Slope BUS_B1_CPAR
:read:    BUS1:CPAR:CLOC:SLOP?
:write:   BUS1:CPAR:CLOC:SLOP #
Rise      POS
Fall      NEG
Either    EITH

#cmdSetup comboboxhot CS BUS_B1_CPAR
:read:    BUS1:CPAR:CS:SOUR?
:write:   BUS1:CPAR:CS:SOUR #
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Active BUS_B1_CPAR
:read:    BUS1:CPAR:CS:POL?
:write:   BUS1:CPAR:CS:POL #
High      POS
Low       NEG

#cmdSetup comboboxhot DATA BUS_B1_CPAR
:read:    BUS1:CPAR:WIDT?
:write:   BUS1:CPAR:WIDT #
1_Bit 1
2_Bit 2
3_Bit 3
4_Bit 4
5_Bit 5
6_Bit 6

#cmdSetup comboboxhot D0 BUS_B1_CPAR
:read:    BUS1:CPAR:DATA0:SOUR?
:write:   BUS1:CPAR:DATA0:SOUR #
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D1 BUS_B1_CPAR
:read:    BUS1:CPAR:DATA1:SOUR?
:write:   BUS1:CPAR:DATA1:SOUR #
:enable:  inList(BUS_B1_CPAR.DATA, "2,3,4,5,6", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D2 BUS_B1_CPAR
:read:    BUS1:CPAR:DATA2:SOUR?
:write:   BUS1:CPAR:DATA2:SOUR #
:enable:  inList(BUS_B1_CPAR.DATA, "3,4,5,6", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D3 BUS_B1_CPAR
:read:    BUS1:CPAR:DATA3:SOUR?
:write:   BUS1:CPAR:DATA3:SOUR #
:enable:  inList(BUS_B1_CPAR.DATA, "4,5,6", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D4 BUS_B1_CPAR
:read:    BUS1:CPAR:DATA4:SOUR?
:write:   BUS1:CPAR:DATA4:SOUR #
:enable:  inList(BUS_B1_CPAR.DATA, "5,6", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D5 BUS_B1_CPAR
:read:    BUS1:CPAR:DATA5:SOUR?
:write:   BUS1:CPAR:DATA5:SOUR #
:enable:  inList(BUS_B1_CPAR.DATA, "6", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7


;I2C
#cmdSetup comboboxhot SCL BUS_B1_I2C
:read:    BUS1:I2C:CLOC:SOUR?
:write:   BUS1:I2C:CLOC:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot SDA BUS_B1_I2C
:read:    BUS1:I2C:DATA:SOUR?
:write:   BUS1:I2C:DATA:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Mode BUS_B1_I2C
:read:    BUS1:I2C:AMOD?
:write:   BUS1:I2C:AMOD #
Address_and_RW ARWR
Address_only   AONL


; SPI
#cmdSetup comboboxhot Width BUS_B1_SPI
:read:    BUS1:SPI:SSIZ?
:write:   BUS1:SPI:SSIZ #
4_Bit  4
5_Bit  5
6_Bit  6
7_Bit  7
8_Bit  8
9_Bit  9
10_Bit 10
11_Bit 11
12_Bit 12
13_Bit 13
14_Bit 14
15_Bit 15
16_Bit 16
17_Bit 17
18_Bit 18
19_Bit 19
20_Bit 20
21_Bit 21
22_Bit 22
23_Bit 23
24_Bit 24
25_Bit 25
26_Bit 26
27_Bit 27
28_Bit 28
29_Bit 29
30_Bit 30
31_Bit 31
32_Bit 32

#cmdSetup comboboxhot Order BUS_B1_SPI
:read:    BUS1:SPI:BORD?
:write:   BUS1:SPI:BORD #
MSB_first MSBF
LSB_first LSBF

#cmdSetup comboboxhot CLK BUS_B1_SPI
:read:    BUS1:SPI:CLOC:SOUR?
:write:   BUS1:SPI:CLOC:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Slope BUS_B1_SPI
:read:    BUS1:SPI:CLOC:POL?
:write:   BUS1:SPI:CLOC:POL #
Rising    POS
Falling   NEG

#cmdSetup comboboxhot CS BUS_B1_SPI
:read:    BUS1:SPI:CS:SOUR?
:write:   BUS1:SPI:CS:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7
EXT EXT

#cmdSetup comboboxhot Active BUS_B1_SPI
:read:    BUS1:SPI:CS:POL?
:write:   BUS1:SPI:CS:POL #
High      POS
Low       NEG

#cmdSetup comboboxhot DATA BUS_B1_SPI
:read:    BUS1:SPI:DATA:SOUR?
:write:   BUS1:SPI:DATA:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Active BUS_B1_SPI
:read:    BUS1:SPI:DATA:POL?
:write:   BUS1:SPI:DATA:POL #
High      POS
Low       NEG


; SSPI
#cmdSetup comboboxhot Width BUS_B1_SSPI
:read:    BUS1:SSPI:SSIZ?
:write:   BUS1:SSPI:SSIZ #
4_Bit  4
5_Bit  5
6_Bit  6
7_Bit  7
8_Bit  8
9_Bit  9
10_Bit 10
11_Bit 11
12_Bit 12
13_Bit 13
14_Bit 14
15_Bit 15
16_Bit 16
17_Bit 17
18_Bit 18
19_Bit 19
20_Bit 20
21_Bit 21
22_Bit 22
23_Bit 23
24_Bit 24
25_Bit 25
26_Bit 26
27_Bit 27
28_Bit 28
29_Bit 29
30_Bit 30
31_Bit 31
32_Bit 32

#cmdSetup comboboxhot Order BUS_B1_SSPI
:read:    BUS1:SSPI:BORD?
:write:   BUS1:SSPI:BORD #
MSB_first MSBF
LSB_first LSBF

#cmdSetup number Time BUS_B1_SSPI
:read:    BUS1:SSPI:BIT?
:write:   BUS1:SSPI:BIT #
s 3.20E-08  6.7E-02

#cmdSetup comboboxhot CLK BUS_B1_SSPI
:read:    BUS1:SSPI:CLOC:SOUR?
:write:   BUS1:SSPI:CLOC:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Slope BUS_B1_SSPI
:read:    BUS1:SSPI:CLOC:POL?
:write:   BUS1:SSPI:CLOC:POL #
Rising    POS
Falling   NEG

#cmdSetup comboboxhot DATA BUS_B1_SSPI
:read:    BUS1:SSPI:DATA:SOUR?
:write:   BUS1:SSPI:DATA:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Active BUS_B1_SSPI
:read:    BUS1:SSPI:DATA:POL?
:write:   BUS1:SSPI:DATA:POL #
High      POS
Low       NEG


; UART
#cmdSetup comboboxhot Width BUS_B1_UART
:read:    BUS1:UART:SSIZ?
:write:   BUS1:UART:SSIZ #
5_Bit  5
6_Bit  6
7_Bit  7
8_Bit  8
9_Bit  9

#cmdSetup comboboxhot Parity BUS_B1_UART
:read:    BUS1:UART:PAR?
:write:   BUS1:UART:PAR #
None NONE
Odd  ODD
Even EVEN

#cmdSetup comboboxhot Stop BUS_B1_UART
:read:    BUS1:UART:SBIT?
:write:   BUS1:UART:SBIT #
1   B1
1.5 B1_5
2   B2

#cmdSetup comboboxhot DATA BUS_B1_UART
:read:    BUS1:UART:DATA:SOUR?
:write:   BUS1:UART:DATA:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Active BUS_B1_UART
:read:    BUS1:UART:DATA:POL?
:write:   BUS1:UART:DATA:POL #
High      POS
Low       NEG


;CAN
#cmdSetup Info Not_available BUS_B1_CAN


;LIN
#cmdSetup Info Not_available BUS_B1_LIN


;Control
#cmdSetup separator - BUS_B1_Control
1 100 Solid

#cmdSetup buttonsOn Bus_1 BUS_B1_Control
:read:     BUS1:STAT?
:write:    BUS1:STAT #
:update:   BUS_B1.SelectBusB1
:color:    white
Off 0
On  1


; ----- Bus 2 -----------------------------------------------------------------------

#cmdSetup number Position BUS_B2_SEL
:read:    BUS2:POS?
:write:   BUS2:POS #
div -1.5E+01 1.5E+01

#cmdSetup comboboxhot Scale BUS_B2_SEL
:read:    BUS2:DSIZ?
:write:   BUS2:DSIZ #
Small  SMAL
Medium MED
Large  LARG

#cmdSetup selector SelectBusB2 BUS_B2_SEL
:read:    BUS2:STAT?
0         BUS_B2_Control.
1         BUS_B2.


#cmdSetup comboboxhot Signals BUS_B2
:read:    BUS2:DSIG?
:write:   BUS2:DSIG #
Off 0
On  1

#cmdSetup comboboxhot Format BUS_B2
:read:    BUS2:FORM?
:write:   BUS2:FORM #
Binary      BIN
Hexadecimal HEX
Decimal     DEC
Octal       OCT
ASCII       ASC

#cmdSetup separator - BUS_B2
3 100 Empty

#cmdSetup comboboxhot Config BUS_B2
:read:    BUS2:TYPE?
:write:   BUS2:TYPE #
:update:  BUS_B2.SelectBus2Type
Parallel_Clocked CPAR
Parallel         PAR
I2C              I2C
SPI_(3_Wire)     SPI
SSPI_(2_Wire)    SSPI
UART             UART
CAN              CAN
LIN              LIN

#cmdSetup separator - BUS_B2
1 100 Solid

#cmdSetup selector SelectBus2Type BUS_B2
:read:    BUS2:TYPE?
:string:
CPAR BUS_B2_CPAR. BUS_B2_Control.
PAR  BUS_B2_PAR.  BUS_B2_Control.
I2C  BUS_B2_I2C.  BUS_B2_Control.
SPI  BUS_B2_SPI.  BUS_B2_Control.
SSPI BUS_B2_SSPI. BUS_B2_Control.
UART BUS_B2_UART. BUS_B2_Control.
CAN  BUS_B2_CAN.  BUS_B2_Control.
LIN  BUS_B2_LIN.  BUS_B2_Control.


; PAR
#cmdSetup comboboxhot DATA BUS_B2_PAR
:read:    BUS2:PAR:WIDT?
:write:   BUS2:PAR:WIDT #
1_Bit 1
2_Bit 2
3_Bit 3
4_Bit 4
5_Bit 5
6_Bit 6
7_Bit 7
8_Bit 8

#cmdSetup comboboxhot D0 BUS_B2_PAR
:read:    BUS2:PAR:DATA0:SOUR?
:write:   BUS2:PAR:DATA0:SOUR #
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D1 BUS_B2_PAR
:read:    BUS2:PAR:DATA1:SOUR?
:write:   BUS2:PAR:DATA1:SOUR #
:enable:  inList(BUS_B2_PAR.DATA, "2,3,4,5,6,7,8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D2 BUS_B2_PAR
:read:    BUS2:PAR:DATA2:SOUR?
:write:   BUS2:PAR:DATA2:SOUR #
:enable:  inList(BUS_B2_PAR.DATA, "3,4,5,6,7,8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D3 BUS_B2_PAR
:read:    BUS2:PAR:DATA3:SOUR?
:write:   BUS2:PAR:DATA3:SOUR #
:enable:  inList(BUS_B2_PAR.DATA, "4,5,6,7,8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D4 BUS_B2_PAR
:read:    BUS2:PAR:DATA4:SOUR?
:write:   BUS2:PAR:DATA4:SOUR #
:enable:  inList(BUS_B2_PAR.DATA, "5,6,7,8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D5 BUS_B2_PAR
:read:    BUS2:PAR:DATA5:SOUR?
:write:   BUS2:PAR:DATA5:SOUR #
:enable:  inList(BUS_B2_PAR.DATA, "6,7,8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D6 BUS_B2_PAR
:read:    BUS2:PAR:DATA6:SOUR?
:write:   BUS2:PAR:DATA6:SOUR #
:enable:  inList(BUS_B2_PAR.DATA, "7,8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D7 BUS_B2_PAR
:read:    BUS2:PAR:DATA7:SOUR?
:write:   BUS2:PAR:DATA7:SOUR #
:enable:  inList(BUS_B2_PAR.DATA, "8", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7


; CPAR
#cmdSetup comboboxhot CLK BUS_B2_CPAR
:read:    BUS2:CPAR:CLOC:SOUR?
:write:   BUS2:CPAR:CLOC:SOUR #
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Slope BUS_B2_CPAR
:read:    BUS2:CPAR:CLOC:SLOP?
:write:   BUS2:CPAR:CLOC:SLOP #
Rise      POS
Fall      NEG
Either    EITH

#cmdSetup comboboxhot CS BUS_B2_CPAR
:read:    BUS2:CPAR:CS:SOUR?
:write:   BUS2:CPAR:CS:SOUR #
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Active BUS_B2_CPAR
:read:    BUS2:CPAR:CS:POL?
:write:   BUS2:CPAR:CS:POL #
High      POS
Low       NEG

#cmdSetup comboboxhot DATA BUS_B2_CPAR
:read:    BUS2:CPAR:WIDT?
:write:   BUS2:CPAR:WIDT #
1_Bit 1
2_Bit 2
3_Bit 3
4_Bit 4
5_Bit 5
6_Bit 6

#cmdSetup comboboxhot D0 BUS_B2_CPAR
:read:    BUS2:CPAR:DATA0:SOUR?
:write:   BUS2:CPAR:DATA0:SOUR #
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D1 BUS_B2_CPAR
:read:    BUS2:CPAR:DATA1:SOUR?
:write:   BUS2:CPAR:DATA1:SOUR #
:enable:  inList(BUS_B2_CPAR.DATA, "2,3,4,5,6", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D2 BUS_B2_CPAR
:read:    BUS2:CPAR:DATA2:SOUR?
:write:   BUS2:CPAR:DATA2:SOUR #
:enable:  inList(BUS_B2_CPAR.DATA, "3,4,5,6", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D3 BUS_B2_CPAR
:read:    BUS2:CPAR:DATA3:SOUR?
:write:   BUS2:CPAR:DATA3:SOUR #
:enable:  inList(BUS_B2_CPAR.DATA, "4,5,6", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D4 BUS_B2_CPAR
:read:    BUS2:CPAR:DATA4:SOUR?
:write:   BUS2:CPAR:DATA4:SOUR #
:enable:  inList(BUS_B2_CPAR.DATA, "5,6", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot D5 BUS_B2_CPAR
:read:    BUS2:CPAR:DATA5:SOUR?
:write:   BUS2:CPAR:DATA5:SOUR #
:enable:  inList(BUS_B2_CPAR.DATA, "6", ",")
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7


;I2C
#cmdSetup comboboxhot SCL BUS_B2_I2C
:read:    BUS2:I2C:CLOC:SOUR?
:write:   BUS2:I2C:CLOC:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot SDA BUS_B2_I2C
:read:    BUS2:I2C:DATA:SOUR?
:write:   BUS2:I2C:DATA:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Mode BUS_B2_I2C
:read:    BUS2:I2C:AMOD?
:write:   BUS2:I2C:AMOD #
Address_and_RW ARWR
Address_only   AONL


; SPI
#cmdSetup comboboxhot Width BUS_B2_SPI
:read:    BUS2:SPI:SSIZ?
:write:   BUS2:SPI:SSIZ #
4_Bit  4
5_Bit  5
6_Bit  6
7_Bit  7
8_Bit  8
9_Bit  9
10_Bit 10
11_Bit 11
12_Bit 12
13_Bit 13
14_Bit 14
15_Bit 15
16_Bit 16
17_Bit 17
18_Bit 18
19_Bit 19
20_Bit 20
21_Bit 21
22_Bit 22
23_Bit 23
24_Bit 24
25_Bit 25
26_Bit 26
27_Bit 27
28_Bit 28
29_Bit 29
30_Bit 30
31_Bit 31
32_Bit 32

#cmdSetup comboboxhot Order BUS_B2_SPI
:read:    BUS2:SPI:BORD?
:write:   BUS2:SPI:BORD #
MSB_first MSBF
LSB_first LSBF

#cmdSetup comboboxhot CLK BUS_B2_SPI
:read:    BUS2:SPI:CLOC:SOUR?
:write:   BUS2:SPI:CLOC:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Slope BUS_B2_SPI
:read:    BUS2:SPI:CLOC:POL?
:write:   BUS2:SPI:CLOC:POL #
Rising    POS
Falling   NEG

#cmdSetup comboboxhot CS BUS_B2_SPI
:read:    BUS2:SPI:CS:SOUR?
:write:   BUS2:SPI:CS:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7
EXT EXT

#cmdSetup comboboxhot Active BUS_B2_SPI
:read:    BUS2:SPI:CS:POL?
:write:   BUS2:SPI:CS:POL #
High      POS
Low       NEG

#cmdSetup comboboxhot DATA BUS_B2_SPI
:read:    BUS2:SPI:DATA:SOUR?
:write:   BUS2:SPI:DATA:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Active BUS_B2_SPI
:read:    BUS2:SPI:DATA:POL?
:write:   BUS2:SPI:DATA:POL #
High      POS
Low       NEG


; SSPI
#cmdSetup comboboxhot Width BUS_B2_SSPI
:read:    BUS2:SSPI:SSIZ?
:write:   BUS2:SSPI:SSIZ #
4_Bit  4
5_Bit  5
6_Bit  6
7_Bit  7
8_Bit  8
9_Bit  9
10_Bit 10
11_Bit 11
12_Bit 12
13_Bit 13
14_Bit 14
15_Bit 15
16_Bit 16
17_Bit 17
18_Bit 18
19_Bit 19
20_Bit 20
21_Bit 21
22_Bit 22
23_Bit 23
24_Bit 24
25_Bit 25
26_Bit 26
27_Bit 27
28_Bit 28
29_Bit 29
30_Bit 30
31_Bit 31
32_Bit 32

#cmdSetup comboboxhot Order BUS_B2_SSPI
:read:    BUS2:SSPI:BORD?
:write:   BUS2:SSPI:BORD #
MSB_first MSBF
LSB_first LSBF

#cmdSetup number Time BUS_B2_SSPI
:read:    BUS2:SSPI:BIT?
:write:   BUS2:SSPI:BIT #
s 3.20E-08  6.7E-02

#cmdSetup comboboxhot CLK BUS_B2_SSPI
:read:    BUS2:SSPI:CLOC:SOUR?
:write:   BUS2:SSPI:CLOC:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Slope BUS_B2_SSPI
:read:    BUS2:SSPI:CLOC:POL?
:write:   BUS2:SSPI:CLOC:POL #
Rising    POS
Falling   NEG

#cmdSetup comboboxhot DATA BUS_B2_SSPI
:read:    BUS2:SSPI:DATA:SOUR?
:write:   BUS2:SSPI:DATA:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Active BUS_B2_SSPI
:read:    BUS2:SSPI:DATA:POL?
:write:   BUS2:SSPI:DATA:POL #
High      POS
Low       NEG


; UART
#cmdSetup comboboxhot Width BUS_B2_UART
:read:    BUS2:UART:SSIZ?
:write:   BUS2:UART:SSIZ #
5_Bit  5
6_Bit  6
7_Bit  7
8_Bit  8
9_Bit  9

#cmdSetup comboboxhot Parity BUS_B2_UART
:read:    BUS2:UART:PAR?
:write:   BUS2:UART:PAR #
None NONE
Odd  ODD
Even EVEN

#cmdSetup comboboxhot Stop BUS_B2_UART
:read:    BUS2:UART:SBIT?
:write:   BUS2:UART:SBIT #
1   B1
1.5 B1_5
2   B2

#cmdSetup comboboxhot DATA BUS_B2_UART
:read:    BUS2:UART:DATA:SOUR?
:write:   BUS2:UART:DATA:SOUR #
CH1 CH1
CH2 CH2
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7

#cmdSetup comboboxhot Active BUS_B2_UART
:read:    BUS2:UART:DATA:POL?
:write:   BUS2:UART:DATA:POL #
High      POS
Low       NEG


;CAN
#cmdSetup Info Not_available BUS_B2_CAN


;LIN
#cmdSetup Info Not_available BUS_B2_LIN


;Control
#cmdSetup separator - BUS_B2_Control
1 100 Solid

#cmdSetup buttonsOn Bus_2 BUS_B2_Control
:read:     BUS2:STAT?
:write:    BUS2:STAT #
:update:   BUS_B2.SelectBusB2
:color:    white
Off 0
On  1


;------------------------------------------------------------------------------------
; Horizontal
;------------------------------------------------------------------------------------

#cmdSetup radio Horizontal Hori
:read:    HORIZ:SHOW?
:write:   HORIZ:SHOW #
:update:  SelectUtil
:string:
Trigger   1
Time      0


#cmdSetup separator - Hori
:color: black
3 100 Solid

#cmdSetup selector SelectUtil Hori
:read:    HORIZ:SHOW?
0 Time.
1 Trigger.


;------------------------------------------------------------------------------------
; Time
;------------------------------------------------------------------------------------

#cmdSetup number Position Time
:read:    TIM:POS?
:write:   TIM:POS
:textwidth: 7
:update:  Time.ACQ_Time
s -500 500

#cmdSetup number Scale Time
:read:    TIM:SCAL?
:write:   TIM:SCAL
:update:  Time.ACQ_Time
s/div 1n 100

#cmdSetup number ACQ_Time Time
:read:    TIM:ACQT?
:write:   TIM:ACQT
:update:  Time.Scale
s 12n 1200

#cmdSetup slider Reference Time
:read:    TIM:REF?
:write:   TIM:REF
% 0 100

;#cmdSetup buttons Marker Time
;:write:   #
;<         TST:PREV
;Set       TST:SET
;Clear     TST:CLE
;>         TST:NEXT
;Clear_All TST:ACLE


#cmdSetup separator - Time
1 100 Empty

#cmdSetup info Acquire Time

#cmdSetup separator - Time
1 100 Solid

#cmdSetup comboboxhot Arithmetics Time
:read:    CHAN:ARIT?
:write:   CHAN:ARIT #
Refresh   OFF
Smooth    SMO
Envelope  ENV
Average   AVER
Filter    FILT

#cmdSetup comboboxhot Average_Count Time
:read:    ACQ:AVER:COUN?
:write:   ACQ:AVER:COUN #
:enable:  Time.Arithmetics == "AVER"
2    2
4    4
8    8
16   16
32   32
64   64
128  128
256  256
512  512
1024 1024

#cmdSetup number Filter_Cutoff Time
:read:    ACQ:FILT:FREQ?
:write:   ACQ:FILT:FREQ
:enable:  Time.Arithmetics == "FILT"
Hz 0 300M

#cmdSetup comboboxhot Type Time
:read:    CHAN:TYPE?
:write:   CHAN:TYPE #
Sample          SAMP
Peak_Detect     PDET
High_Resolution HRES

#cmdSetup comboboxhot Interplolate Time
:read:    ACQ:INT?
:write:   ACQ:INT #
Linear      LIN
Sin(x)/x    SINX
Sample/Hold SMHD

#cmdSetup comboboxhot Record_Mode Time
:read:    ACQ:WRAT?
:write:   ACQ:WRAT #
Automatic          AUTO
Max._Waveform_Rate MWAV
Max._Sample_Rate   MSAM


;------------------------------------------------------------------------------------
; Trigger
;------------------------------------------------------------------------------------

#cmdSetup comboboxhot Trigger Trigger
:read:    TRIG:A:TYPE?
:write:   TRIG:A:TYPE #
:update:  Time.SelectTrigger
Edge  EDGE
Width WIDT
Logic LOG
Video TV
Bus   BUS

#cmdSetup selector SelectTrigger Trigger
:read:    TRIG:A:TYPE?
EDGE Trigger_Edge.  Trigger_Control.
WIDT Trigger_Width. Trigger_Control.
LOG  Trigger_Logic. Trigger_Control.
TV   Trigger_Video. Trigger_Control.
BUS  Trigger_Bus.


;-- Edge ----------------------------------------------------------------------------
#cmdSetup comboboxhot Source Trigger_Edge
:read:    TRIG:A:SOUR?
:write:   TRIG:A:SOUR #
CH1       CH1
CH2       CH2
EXT       EXT
D0        D0
D1        D1
D2        D2
D3        D3
D4        D4
D5        D5
D6        D6
D7        D7
AC_LINE   LINE
None      NONE

#cmdSetup separator - Trigger_Edge
1 100 Empty

#cmdSetup info Edge Trigger_Edge

#cmdSetup separator - Trigger_Edge
1 100 Solid

#cmdSetup comboboxhot Slope Trigger_Edge
:read:    TRIG:A:EDGE:SLOPE?
:write:   TRIG:A:EDGE:SLOPE #
Rising    POS
Falling   NEG
Either    EITH

#cmdSetup comboboxhot Coupling Trigger_Edge
:read:    TRIG:A:EDGE:COUP?
:write:   TRIG:A:EDGE:COUP #
Auto_Level ALEV
AC         AC
DC         DC
HF         HF

#cmdSetup comboboxhot Lowpass Trigger_Edge
:read:    TRIG:A:EDGE:FILT:LPAS?
:write:   TRIG:A:EDGE:FILT:LPAS #
Off 0
On  1

#cmdSetup comboboxhot Noise_Reject Trigger_Edge
:read:    TRIG:A:EDGE:FILT:NREJ?
:write:   TRIG:A:EDGE:FILT:NREJ #
Off 0
On  1


;-- Width  --------------------------------------------------------------------------
#cmdSetup comboboxhot Source Trigger_Width
:read:    TRIG:A:SOUR?
:write:   TRIG:A:SOUR #
CH1       CH1
CH2       CH2
D0        D0
D1        D1
D2        D2
D3        D3
D4        D4
D5        D5
D6        D6
D7        D7
None      NONE

#cmdSetup separator - Trigger_Width
1 100 Empty

#cmdSetup info Width Trigger_Width

#cmdSetup separator - Trigger_Width
1 100 Solid

#cmdSetup comboboxhot Polarity Trigger_Width
:read:    TRIG:A:WIDT:POL?
:write:   TRIG:A:WIDT:POL #
Positive  POS
Negative  NEG

#cmdSetup comboboxhot Compare Trigger_Width
:read:    TRIG:A:WIDT:RANG?
:write:   TRIG:A:WIDT:RANG #
ti_>_t    LONG
ti_<_t    SHOR
ti_=_t    WITH
ti_!=_t   OUTS

#cmdSetup number Time_t Trigger_Width
:read:    TRIG:A:WIDT:WIDT?
:write:   TRIG:A:WIDT:WIDT #
s 8n 34

#cmdSetup number Variation Trigger_Width
:read:    TRIG:A:WIDT:DELT?
:write:   TRIG:A:WIDT:DELT #
:enable:  Trigger_Width.Compare == "WITH" || Trigger_Width.Compare == "OUTS"
s 4n 34


;-- Logic  --------------------------------------------------------------------------

#cmdSetup separator - Trigger_Logic
1 100 Empty

#cmdSetup info Logic Trigger_Logic

#cmdSetup separator - Trigger_Logic
1 100 Solid

#cmdSetup comboboxhot Function Trigger_Logic
:read:    TRIG:A:PATT:FUNC?
:write:   TRIG:A:PATT:FUNC #
AND       AND
OR        OR

#cmdSetup comboboxhot Condition Trigger_Logic
:read:    TRIG:A:PATT:COND?
:write:   TRIG:A:PATT:COND "#"
:readmath: unQuote(value)
:string:
True      TRUE
False     FALSE

#cmdSetup comboboxhot Duration Trigger_Logic
:read:    TRIG:A:PATT:MODE?
:write:   TRIG:A:PATT:MODE #
Off       OFF
Width     WIDT
Timeout   TIM

#cmdSetup comboboxhot Compare Trigger_Logic
:read:    TRIG:A:PATT:WIDT:RANGE?
:write:   TRIG:A:PATT:WIDT:RANGE #
:enable:  Trigger_Logic.Duration != "OFF"
ti_>_t    LONG
ti_<_t    SHOR
ti_=_t    WITH
ti_!=_t   OUTS

#cmdSetup number Time_t Trigger_Logic
:read:    TRIG:A:PATT:WIDT:WIDT?
:write:   TRIG:A:PATT:WIDT:WIDT #
:enable:  Trigger_Logic.Duration != "OFF"
s 8n 34

#cmdSetup number Variation Trigger_Logic
:read:    TRIG:A:PATT:WIDT:DELT?
:write:   TRIG:A:PATT:WIDT:DELT #
:enable:  (Trigger_Logic.Duration == "WIDT") && (Trigger_Logic.Compare == "WITH" || Trigger_Logic.Compare == "OUTS")
s 4n 34


;-- Video  --------------------------------------------------------------------------

#cmdSetup comboboxhot Source Trigger_Video
:read:    TRIG:A:SOUR?
:write:   TRIG:A:SOUR #
CH1       CH1
CH2       CH2
None      NONE

#cmdSetup separator - Trigger_Video
1 100 Empty

#cmdSetup info Video Trigger_Video

#cmdSetup separator - Trigger_Video
1 100 Solid

#cmdSetup comboboxhot Standard Trigger_Video
:read:    TRIG:A:TV:STAN?
:write:   TRIG:A:TV:STAN #
PAL        PAL
NTSC       NTSC
SECAM      SEC
PAL-M      PALM
SDTV-576i  I576
HDTV-720p  P720
HDTV-1080p P1080
HDTV-1080i I1080

#cmdSetup comboboxhot Signal Trigger_Video
:read:    TRIG:A:TV:POL?
:write:   TRIG:A:TV:POL #
Positive  POS
Negative  NEG

#cmdSetup comboboxhot Mode Trigger_Video
:read:    TRIG:A:TV:FIEL?
:write:   TRIG:A:TV:FIEL #
All_Frames  ALL
Odd_Frame   ODD
Even_Frame  EVEN
All_Lines   ALIN
Line        LINE

#cmdSetup numberInt Line Trigger_Video
:read:    TRIG:A:TV:LINE?
:write:   TRIG:A:TV:LINE #
:enable:  Trigger_Video.Mode=="LINE"
_ 1 1080


;-- Bus -----------------------------------------------------------------------------

#cmdSetup comboboxhot Source Trigger_Bus
:read:    TRIG:A:SOUR?
:write:   TRIG:A:SOUR #
:update:  Trigger_Bus.SelectTriggerBus
B1        BUS1
B2        BUS2
None      NONE

#cmdSetup separator - Trigger_Bus
1 100 Empty

#cmdSetup selector SelectTriggerBus Trigger_Bus
:read:    TRIG:A:SOUR?
NONE      Trigger_NOP.
BUS1      Trigger_Bus_Type1.
BUS2      Trigger_Bus_Type2.

#cmdSetup selector SelectTriggerBusType Trigger_Bus_Type1
:read:    BUS1:TYPE?
I2C       Trigger_I2C.  Trigger_Control.
SPI       Trigger_SPI.  Trigger_Control.
SSPI      Trigger_SPI.  Trigger_Control.
UART      Trigger_UART. Trigger_Control.
CAN       Trigger_NOP.  Trigger_Control.
LIN       Trigger_NOP.  Trigger_Control.
PAR       Trigger_NOP.  Trigger_Control.
CPAR      Trigger_NOP.  Trigger_Control.

#cmdSetup selector SelectTriggerBusType Trigger_Bus_Type2
:read:    BUS2:TYPE?
I2C       Trigger_I2C.  Trigger_Control.
SPI       Trigger_SPI.  Trigger_Control.
SSPI      Trigger_SPI.  Trigger_Control.
UART      Trigger_UART. Trigger_Control.
CAN       Trigger_NOP.  Trigger_Control.
LIN       Trigger_NOP.  Trigger_Control.
PAR       Trigger_NOP.  Trigger_Control.
CPAR      Trigger_NOP.  Trigger_Control.

#cmdSetup info No_Trigger Trigger_NOP


;-- I2C -----------------------------------------------------------------------------

#cmdSetup info I2C Trigger_I2C

#cmdSetup separator - Trigger_I2C
1 100 Solid

#cmdSetup comboboxhot Trigger Trigger_I2C
:read:    TRIG:A:I2C:MODE?
:write:   TRIG:A:I2C:MODE #
Start           STAR
Restart         REST
Stop            STOP
Not_Acknowledge MACK
Read/Write      PATT

#cmdSetup comboboxhot Master Trigger_I2C
:read:    TRIG:A:I2C:ACC?
:write:   TRIG:A:I2C:ACC #
:enable:  Trigger_I2C.Trigger == "PATT"
Read      READ
Write     WRIT

#cmdSetup comboboxhot Address_Length Trigger_I2C
:read:    TRIG:A:I2C:AMOD?
:write:   TRIG:A:I2C:AMOD #
:enable:  Trigger_I2C.Trigger == "PATT"
7_Bit     NORM
10_Bit    EXT

#cmdSetup text Address Trigger_I2C
:read:    TRIG:A:I2C:ADDR?
:write:   TRIG:A:I2C:ADDR "#"
:enable:  Trigger_I2C.Trigger == "PATT"
:tip:     0/1/X - 7 or 10 bits

#cmdSetup numberInt Offset Trigger_I2C
:read:    TRIG:A:I2C:POFF?
:write:   TRIG:A:I2C:POFF #
:enable:  Trigger_I2C.Trigger == "PATT"
B 0 4095

#cmdSetup numberInt Length Trigger_I2C
:read:    TRIG:A:I2C:PLEN?
:write:   TRIG:A:I2C:PLEN #
:enable:  Trigger_I2C.Trigger == "PATT"
B 1 3

#cmdSetup text Data Trigger_I2C
:read:    TRIG:A:I2C:PATT?
:write:   TRIG:A:I2C:PATT "#"
:enable:  Trigger_I2C.Trigger == "PATT"
:tip:     0/1/X - 7 or 10 bits


;-- SPI -----------------------------------------------------------------------------

#cmdSetup info SPI Trigger_SPI

#cmdSetup separator - Trigger_SPI
1 100 Solid

#cmdSetup comboboxhot Trigger Trigger_SPI
:read:    TRIG:A:SPI:MODE?
:write:   TRIG:A:SPI:MODE #
Frame_Start     BST
Frame_End       BEND
Bit             NTHB
Pattern         PATT

#cmdSetup numberInt Offset Trigger_SPI
:read:    TRIG:A:SPI:POFF?
:write:   TRIG:A:SPI:POFF #
:enable:  Trigger_SPI.Trigger == "PATT" || Trigger_SPI.Trigger == "NTHB"
bits 0 4095

#cmdSetup numberInt Length Trigger_SPI
:read:    TRIG:A:SPI:PLEN?
:write:   TRIG:A:SPI:PLEN #
:update:  Trigger_SPI.Pattern
:enable:  Trigger_SPI.Trigger == "PATT"
bits 1 32

#cmdSetup text Pattern Trigger_SPI
:read:    TRIG:A:SPI:PATT?
:write:   TRIG:A:SPI:PATT "#"
:enable:  Trigger_SPI.Trigger == "PATT"
:tip:     0/1/X


;-- UART ----------------------------------------------------------------------------

#cmdSetup info UART Trigger_UART

#cmdSetup separator - Trigger_UART
1 100 Solid

#cmdSetup comboboxhot Trigger Trigger_UART
:read:    TRIG:A:UART:MODE?
:write:   TRIG:A:UART:MODE #
Start_Bit    SBIT
Frame_Start  BST
Symbol_N     NTHS
Any_Symbol   SYMB
Parity_Error PRER
Frame_Error  FERR
Break        BRE
Pattern      PATT

#cmdSetup numberInt Offset Trigger_UART
:read:    TRIG:A:UART:POFF?
:write:   TRIG:A:UART:POFF #
:enable:  Trigger_UART.Trigger == "PATT" || Trigger_UART.Trigger == "NTHS"
Sym 0 4095

#cmdSetup numberInt Length Trigger_UART
:read:    TRIG:A:UART:PLEN?
:write:   TRIG:A:UART:PLEN #
:update:  Trigger_UART.Pattern
:enable:  Trigger_UART.Trigger == "PATT"
Sym 1 3

#cmdSetup text Pattern Trigger_UART
:read:    TRIG:A:UART:PATT?
:write:   TRIG:A:UART:PATT "#"
:enable:  Trigger_UART.Trigger == "PATT"
:tip:     0/1/X


;-- Control -------------------------------------------------------------------------

#cmdSetup separator - Trigger_Control
1 100 Empty

#cmdSetup info Control Trigger_Control

#cmdSetup separator - Trigger_Control
1 100 Solid

#cmdSetup number Level_CH1 Trigger_Control
:read:    TRIG:A:LEV0?
:write:   TRIG:A:LEV0 #
V -99 99

#cmdSetup number Level_CH2 Trigger_Control
:read:    TRIG:A:LEV1?
:write:   TRIG:A:LEV1 #
V -99 99

#cmdSetup number Level_EXT Trigger_Control
:read:    TRIG:A:LEV2?
:write:   TRIG:A:LEV2 #
V -99 99

#cmdSetup comboboxhot Trigger Trigger_Control
:read:    TRIG:A:MODE?
:write:   TRIG:A:MODE #
Auto   AUTO
Normal NORM

#cmdSetup comboboxhot Hold_off Trigger_Control
:read:    TRIG:A:HOLD:MODE?
:write:   TRIG:A:HOLD:MODE #
Off    OFF
Time   TIME

#cmdSetup number Time Trigger_Control
:read:    TRIG:A:HOLD:TIME?
:write:   TRIG:A:HOLD:TIME #
:enable:  Trigger_Control.Hold_off == "TIME"
s 50n 10


;------------------------------------------------------------------------------------
; Utilities
;------------------------------------------------------------------------------------

#cmdSetup radio Utility Util
:read:    UTIL:SHOW?
:write:   UTIL:SHOW #
:update:  SelectUtil
:string:
Function 0
Pattern  1
Misc     2

#cmdSetup separator - Util
:color: black
3 100 Solid

#cmdSetup selector SelectUtil Util
:read:    UTIL:SHOW?
0 Gen.
1 Pat.
2 Misc.


;------------------------------------------------------------------------------------
; Generator
;------------------------------------------------------------------------------------

#cmdSetup separator - Gen
:color: white
2 100 Empty

#cmdSetup comboboxhot Function Gen
:read:    GEN:FUNC?
:write:   GEN:FUNC #
:update:  Gen.SelectGen
DC        DC
Sinus     SIN
Square    SQU
Pulse     PULS
Triangle  TRI
Ramp      RAMP

#cmdSetup separator - Gen
:color: white
2 100 Empty

#cmdSetup selector SelectGen Gen
:read:    GEN:FUNC?
DC                                  Gen_Offset.            Gen_Control.
SIN   Gen_Frequency. Gen_Amplitude. Gen_Offset.            Gen_Control.
SQU   Gen_Frequency. Gen_Amplitude. Gen_Offset.            Gen_Control.
PULS  Gen_Frequency. Gen_Amplitude. Gen_Offset. Gen_Pulse. Gen_Control.
TRI   Gen_Frequency. Gen_Amplitude. Gen_Offset.            Gen_Control.
RAMP  Gen_Frequency. Gen_Amplitude. Gen_Offset. Gen_Ramp.  Gen_Control.


#cmdSetup number Frequency Gen_Frequency
:read:  GEN:FREQ?
:write: GEN:FREQ
Hz 0.1 50k

#cmdSetup number Amplitude Gen_Amplitude
:read:  GEN:VOLT?
:write: GEN:VOLT
V 0.06 6

#cmdSetup number Offset Gen_Offset
:read:  GEN:VOLT:OFFS?
:write: GEN:VOLT:OFFS
V -3 3

#cmdSetup number Duty_Cycle Gen_Pulse
:read:  GEN:FUNC:PULS:DCYC?
:write: GEN:FUNC:PULS:DCYC
% 10 90

#cmdSetup comboboxhot Ramp Gen_Ramp
:read:  GEN:FUNC:RAMP:POL?
:write: GEN:FUNC:RAMP:POL
:string:
Positive_Slope POS
Negative_Slope NEG

#cmdSetup separator - Gen_Control
2 100 Empty

#cmdSetup separator - Gen_Control
1 100 Solid

#cmdSetup buttonsOn Output Gen_Control
:read:     GEN:OUTP?
:write:    GEN:OUTP
:color:    white
:updatealloff:
Off 0
On 1


;------------------------------------------------------------------------------------
; Pattern Generator
;------------------------------------------------------------------------------------

#cmdSetup separator - Pat
:color: white
2 100 Empty

#cmdSetup comboboxhot Function Pat
:read:    PGEN:FUNC?
:write:   PGEN:FUNC #
:update:  Pat.SelectPat
Manual    MAN
Counter   COUN
Square    SQU
Arbitrary ARB
SPI       SPI
I2C       I2C
UART      UART

#cmdSetup separator - Pat
:color: white
2 100 Empty

#cmdSetup selector SelectPat Pat
:read:    PGEN:FUNC?
SQU       Pat_Square.  Pat_Trigger. Pat_Control.
COUN      Pat_Counter. Pat_Trigger. Pat_Control.
ARB       Pat_ARB.     Pat_Trigger. Pat_Control.
MAN       Pat_Manual.  Pat_Trigger. Pat_Control.
SPI       Pat_SPI.     Pat_Trigger. Pat_Control.
I2C       Pat_I2C.     Pat_Trigger. Pat_Control.
UART      Pat_UART.    Pat_Trigger. Pat_Control.


#cmdSetup number Frequency Pat_Square
:read:    PGEN:PATT:COUN:FREQ?
:readmath: (value/100)
:write:   PGEN:PATT:COUN:FREQ (value*100)
:update:  Pat_Square.Period
Hz 0.1 50M

#cmdSetup number Period Pat_Square
:read:    PGEN:PATT:COUN:FREQ?
:readmath: 1.0/(value/100)
:write:   PGEN:PATT:COUN:FREQ ((1.0/value)*100)
:update:  Pat_Square.Frequency
s 0.00000002 100

#cmdSetup number Duty_Cycle Pat_Square
:read:    PGEN:PATT:SQU:DCYC?
:write:   PGEN:PATT:SQU:DCYC #
% 0 100

#cmdSetup comboboxhot Polarity Pat_Square
:read:    PGEN:PATT:SQU:POL?
:write:   PGEN:PATT:SQU:POL #
Normal    NORM
Inverted  INV


#cmdSetup number Frequency Pat_Counter
:read:    PGEN:PATT:COUN:FREQ?
:write:   PGEN:PATT:COUN:FREQ #
:update:  Pat_Counter.Period
Hz 0.1 50M

#cmdSetup number Period Pat_Counter
:read:    PGEN:PATT:COUN:FREQ?
:readmath: (1.0/value)
:write:   PGEN:PATT:COUN:FREQ (1.0/value)
:update:  Pat_Counter.Frequency
s 0.00000002 100

#cmdSetup comboboxhot Direction Pat_Counter
:read:    PGEN:PATT:COUN:DIR?
:write:   PGEN:PATT:COUN:DIR #
Up        UPW
Down      DOWN


#cmdSetup checkbox Port Pat_Manual
:read:    PGEN:MAN:STAT0?
:write:   PGEN:MAN:STAT0 #
P0 0 1

#cmdSetup checkbox Port Pat_Manual
:read:    PGEN:MAN:STAT1?
:write:   PGEN:MAN:STAT1 #
P1 0 1

#cmdSetup checkbox Port Pat_Manual
:read:    PGEN:MAN:STAT2?
:write:   PGEN:MAN:STAT2 #
P2 0 1

#cmdSetup checkbox Port Pat_Manual
:read:    PGEN:MAN:STAT3?
:write:   PGEN:MAN:STAT3 #
P3 0 1


#cmdSetup number Frequency Pat_ARB
:read:    PGEN:PATT:FREQ?
:write:   PGEN:PATT:FREQ #
:update:  Pat.Period
Hz 0.1 50M

#cmdSetup number Period Pat_ARB
:read:    PGEN:PATT:PER?
:write:   PGEN:PATT:PER #
:update:  Pat.Frequency
s 0.00000002 100

#cmdSetup number Bit_Time Pat_ARB
:read:    PGEN:PATT:STIM?
:write:   PGEN:PATT:STIM #
s 0.00000002 100

#cmdSetup separator - Pat_ARB
1 100 Empty

#cmdSetup comboboxhot Burst Pat_ARB
:read:    PGEN:PATT:BURS:STAT?
:write:   PGEN:PATT:BURS:STAT #
:update:  Pat_ARB.SelectPatBurst
Off 0
On  1

#cmdSetup selector SelectPatBurst Pat_ARB
:read:    PGEN:PATT:BURS:STAT?
0         Pat_ARB_NoBurst.
1         Pat_ARB_Burst.

#cmdSetup separator - Pat_ARB_NoBurst
1 100 Empty

#cmdSetup number Idle_Time Pat_ARB_Burst
:read:    PGEN:PATT:ITIM?
:write:   PGEN:PATT:ITIM #
s 0.00000002 100

#cmdSetup number Cycles Pat_ARB_Burst
:read:    PGEN:PATT:BURS:NCYC?
:write:   PGEN:PATT:BURS:NCYC #
_ 0 10000


#cmdSetup number Frequency Pat_SPI
:read:    PGEN:PATT:COUN:FREQ?
:readmath: (value/4)
:write:   PGEN:PATT:COUN:FREQ (value*4)
bit/s 0.1 50M

#cmdSetup number Frequency Pat_I2C
:read:    PGEN:PATT:COUN:FREQ?
:readmath: (value/3)
:write:   PGEN:PATT:COUN:FREQ (value*3)
bit/s 0.1 50M

#cmdSetup number Frequency Pat_UART
:read:    PGEN:PATT:COUN:FREQ?
:write:   PGEN:PATT:COUN:FREQ #
bit/s 0.1 50M

#cmdSetup separator - Pat_Trigger
1 100 Empty



#cmdSetup comboboxhot Trigger Pat_Trigger
:read:    PGEN:PATT:TRIG:MODE?
:write:   PGEN:PATT:TRIG:MODE #
:update:  Pat_Trigger.SelectPat
Continuous CONT
Extern     EXT
Manual     SING

#cmdSetup selector SelectPat Pat_Trigger
:read:    PGEN:PATT:TRIG:MODE?
CONT      Pat_Trigger_Continuous.
SING      Pat_Trigger_Manual.
EXT       Pat_Trigger_Extern.

#cmdSetup separator - Pat_Trigger_Continuous
1 100 Empty

#cmdSetup button Trigger Pat_Trigger_Manual
:write:   PGEN:PATT:TRIG:SING

#cmdSetup comboboxhot Slope Pat_Trigger_Extern
:read:    PGEN:PATT:TRIG:EXT:SLOP?
:write:   PGEN:PATT:TRIG:EXT:SLOP #
Rising    POS
Falling   NEG
Both      EITH


#cmdSetup separator - Pat_Control
1 100 Solid

#cmdSetup buttonsOn Output Pat_Control
:read:    PGEN:PATT:STAT?
:write:   PGEN:PATT:STAT
:color:   white
:updatealloff:
Off 0
On 1


;------------------------------------------------------------------------------------
; Misc
;------------------------------------------------------------------------------------

#cmdSetup separator - Misc
2 100 Empty


; Virtual Screen
#cmdSetup info Screen Misc

#cmdSetup separator - Misc
1 100 Solid

#cmdSetup checkbox Scroll Misc
:read:    DISP:VSCR:ENAB?
:write:   DISP:VSCR:ENAB #
:update:  Misc.Positon
Enable 0 1

#cmdSetup slider Positon Misc
:read:    DISP:VSCR:POS?
:write:   DISP:VSCR:POS #
:enable:  Misc.Scroll.Enable
div -10 2

#cmdSetup number Positon Misc
:read:    DISP:VSCR:POS?
:write:   DISP:VSCR:POS #
:enable:  Misc.Scroll.Enable
div -10 2


; Message
#cmdSetup separator - Misc
2 100 Empty

#cmdSetup info Message Misc

#cmdSetup separator - Misc
1 100 Solid

#cmdSetup separator - Misc
:color: white
2 100 Empty

#cmdSetup text Text Misc
:write:   DISP:DIAL:MESS "#"

#cmdSetup button Clear Misc
:write:   DISP:DIAL:CLOSE


; Status
#cmdSetup separator - Misc
2 100 Empty

#cmdSetup info Status Misc

#cmdSetup separator - Misc
1 100 Solid

#cmdSetup info Temperature Misc
:readmath: double(value)
:read: SYST:TEMP:VAL?
C


;------------------------------------------------------------------------------------
; Measurment
;------------------------------------------------------------------------------------

#cmdSetup info Measure Meas

#cmdSetup separator - Meas
3 100 Solid

#cmdSetup separator - Meas
3 100 Empty

#cmdSetup comboboxhot Settings Meas
:read:    MEAS:SHOW?
:write:   MEAS:SHOW #
:update:  SelectMeas
:string:
Cursor_-_Cursor_Measurement  0
Meas_1_-_Auto_Measurement_1  1
Meas_2_-_Auto_Measurement_2  2
Meas_3_-_Auto_Measurement_3  3
Meas_4_-_Auto_Measurement_4  4
Meas_5_-_Auto_Measurement_5  5
Meas_6_-_Auto_Measurement_6  6
DVM_1_-_Digital_Voltmeter_1  7
DVM_2_-_Digital_Voltmeter_2  8
DVM_3_-_Digital_Voltmeter_3  9
DVM_4_-_Digital_Voltmeter_4____________________________ 10

#cmdSetup separator - Meas
:color: black
1 100 Solid

#cmdSetup selector SelectMeas Meas
:read:    MEAS:SHOW?
0  Meas_Cursor.    Meas_Control.
1  Meas_1.         Meas_Control.
2  Meas_2.         Meas_Control.
3  Meas_3.         Meas_Control.
4  Meas_4.         Meas_Control.
5  Meas_5.         Meas_Control.
6  Meas_6.         Meas_Control.
7  Meas_DVM1.      Meas_Control.
8  Meas_DVM2.      Meas_Control.
9  Meas_DVM3.      Meas_Control.
10 Meas_DVM4.      Meas_Control.


; ----- Meas_1 -----------------------------------------------------------------------

#cmdSetup comboboxhot Type Meas_1
:read:    MEAS1:MAIN?
:write:   MEAS1:MAIN #
:update:  Meas_1.Source
:string:
Mean_(DC)               MEAN
Standard_Deviation_(AC) STDD
RMS_(AC+DC)             RMS
Amplitude               AMPL
Peak_Peak               PEAK
Peak_+                  UPE
Peak_-                  LPE
Crest_Factor            CRES
Top_Level               HIGH
Base_Level              LOW
Pos_Overshoot           POV
Neg_Overshoot           NOV
Frequency               FREQ
Period                  PER
Rise_Time               RTIM
Fall_Time               FTIM
Pulse_Width_+           PPW
Pulse_Width_-           NPW
Duty_Cycle_+            PDCY
Duty_Cycle_-            NDCY
Delay                   DEL
Phase                   PHAS
Burst_Width             BWID
Pos_Pulses              PPC
Neg_Pulses              NPC
Pos_Slopes              REC
Neg_Slopes              FEC
Trigger_Frequency       TFR
Trigger_Period          TPER

#cmdSetup multi Source Meas_1
:read:    MEAS1:SOUR?
:write:   MEAS1:SOUR #,#
:string:
combobox CH1 CH1 CH2 CH2 EXT EXT D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 RE1 RE1 RE2 RE2 RE3 RE3 RE4 RE4 MA1 MA1 MA2 MA2 MA3 MA3 MA4 MA4 MA5 MA5
combobox - - CH1 CH1 CH2 CH2 EXT EXT D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 RE1 RE1 RE2 RE2 RE3 RE3 RE4 RE4 MA1 MA1 MA2 MA2 MA3 MA3 MA4 MA4 MA5 MA5

#cmdSetup multi Slope Meas_1
:read:    MEAS1:DEL:SLOP?
:write:   MEAS1:DEL:SLOP #,#
:enable:  Meas_1.Type=="DEL"
:string:
combobox Rise POS Fall NEG
combobox Rise POS Fall NEG




; ----- Meas_2 -----------------------------------------------------------------------

#cmdSetup comboboxhot Type Meas_2
:read:    MEAS2:MAIN?
:write:   MEAS2:MAIN #
:update:  Meas_2.Source
:string:
Mean_(DC)               MEAN
Standard_Deviation_(AC) STDD
RMS_(AC+DC)             RMS
Amplitude               AMPL
Peak_Peak               PEAK
Peak_+                  UPE
Peak_-                  LPE
Crest_Factor            CRES
Top_Level               HIGH
Base_Level              LOW
Pos_Overshoot           POV
Neg_Overshoot           NOV
Frequency               FREQ
Period                  PER
Rise_Time               RTIM
Fall_Time               FTIM
Pulse_Width_+           PPW
Pulse_Width_-           NPW
Duty_Cycle_+            PDCY
Duty_Cycle_-            NDCY
Delay                   DEL
Phase                   PHAS
Burst_Width             BWID
Pos_Pulses              PPC
Neg_Pulses              NPC
Pos_Slopes              REC
Neg_Slopes              FEC
Trigger_Frequency       TFR
Trigger_Period          TPER

#cmdSetup multi Source Meas_2
:read:    MEAS2:SOUR?
:write:   MEAS2:SOUR #,#
:string:
combobox CH1 CH1 CH2 CH2 EXT EXT D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 RE1 RE1 RE2 RE2 RE3 RE3 RE4 RE4 MA1 MA1 MA2 MA2 MA3 MA3 MA4 MA4 MA5 MA5
combobox - - CH1 CH1 CH2 CH2 EXT EXT D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 RE1 RE1 RE2 RE2 RE3 RE3 RE4 RE4 MA1 MA1 MA2 MA2 MA3 MA3 MA4 MA4 MA5 MA5

#cmdSetup multi Slope Meas_2
:read:    MEAS2:DEL:SLOP?
:write:   MEAS2:DEL:SLOP #,#
:enable:  Meas_2.Type=="DEL"
:string:
combobox Rise POS Fall NEG
combobox Rise POS Fall NEG


; ----- Meas_3 -----------------------------------------------------------------------

#cmdSetup comboboxhot Type Meas_3
:read:    MEAS3:MAIN?
:write:   MEAS3:MAIN #
:update:  Meas_3.Source
:string:
Mean_(DC)               MEAN
Standard_Deviation_(AC) STDD
RMS_(AC+DC)             RMS
Amplitude               AMPL
Peak_Peak               PEAK
Peak_+                  UPE
Peak_-                  LPE
Crest_Factor            CRES
Top_Level               HIGH
Base_Level              LOW
Pos_Overshoot           POV
Neg_Overshoot           NOV
Frequency               FREQ
Period                  PER
Rise_Time               RTIM
Fall_Time               FTIM
Pulse_Width_+           PPW
Pulse_Width_-           NPW
Duty_Cycle_+            PDCY
Duty_Cycle_-            NDCY
Delay                   DEL
Phase                   PHAS
Burst_Width             BWID
Pos_Pulses              PPC
Neg_Pulses              NPC
Pos_Slopes              REC
Neg_Slopes              FEC
Trigger_Frequency       TFR
Trigger_Period          TPER

#cmdSetup multi Source Meas_3
:read:    MEAS3:SOUR?
:write:   MEAS3:SOUR #,#
:string:
combobox CH1 CH1 CH2 CH2 EXT EXT D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 RE1 RE1 RE2 RE2 RE3 RE3 RE4 RE4 MA1 MA1 MA2 MA2 MA3 MA3 MA4 MA4 MA5 MA5
combobox - - CH1 CH1 CH2 CH2 EXT EXT D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 RE1 RE1 RE2 RE2 RE3 RE3 RE4 RE4 MA1 MA1 MA2 MA2 MA3 MA3 MA4 MA4 MA5 MA5

#cmdSetup multi Slope Meas_3
:read:    MEAS3:DEL:SLOP?
:write:   MEAS3:DEL:SLOP #,#
:enable:  Meas_3.Type=="DEL"
:string:
combobox Rise POS Fall NEG
combobox Rise POS Fall NEG


; ----- Meas_4 -----------------------------------------------------------------------

#cmdSetup comboboxhot Type Meas_4
:write:   MEAS4:MAIN #
:update:  Meas_4.Source
:string:
Mean_(DC)               MEAN
Standard_Deviation_(AC) STDD
RMS_(AC+DC)             RMS
Amplitude               AMPL
Peak_Peak               PEAK
Peak_+                  UPE
Peak_-                  LPE
Crest_Factor            CRES
Top_Level               HIGH
Base_Level              LOW
Pos_Overshoot           POV
Neg_Overshoot           NOV
Frequency               FREQ
Period                  PER
Rise_Time               RTIM
Fall_Time               FTIM
Pulse_Width_+           PPW
Pulse_Width_-           NPW
Duty_Cycle_+            PDCY
Duty_Cycle_-            NDCY
Delay                   DEL
Phase                   PHAS
Burst_Width             BWID
Pos_Pulses              PPC
Neg_Pulses              NPC
Pos_Slopes              REC
Neg_Slopes              FEC
Trigger_Frequency       TFR
Trigger_Period          TPER

#cmdSetup multi Source Meas_4
:read:    MEAS4:SOUR?
:write:   MEAS4:SOUR #,#
:string:
combobox CH1 CH1 CH2 CH2 EXT EXT D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 RE1 RE1 RE2 RE2 RE3 RE3 RE4 RE4 MA1 MA1 MA2 MA2 MA3 MA3 MA4 MA4 MA5 MA5
combobox - - CH1 CH1 CH2 CH2 EXT EXT D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 RE1 RE1 RE2 RE2 RE3 RE3 RE4 RE4 MA1 MA1 MA2 MA2 MA3 MA3 MA4 MA4 MA5 MA5

#cmdSetup multi Slope Meas_4
:read:    MEAS4:DEL:SLOP?
:write:   MEAS4:DEL:SLOP #,#
:enable:  Meas_4.Type=="DEL"
:string:
combobox Rise POS Fall NEG
combobox Rise POS Fall NEG


; ----- Meas_5 -----------------------------------------------------------------------

#cmdSetup comboboxhot Type Meas_5
:read:  :MEAS5:MAIN?
:write: :MEAS5:MAIN #
:update: Meas_5.Source
:string:
Mean_(DC)               MEAN
Standard_Deviation_(AC) STDD
RMS_(AC+DC)             RMS
Amplitude               AMPL
Peak_Peak               PEAK
Peak_+                  UPE
Peak_-                  LPE
Crest_Factor            CRES
Top_Level               HIGH
Base_Level              LOW
Pos_Overshoot           POV
Neg_Overshoot           NOV
Frequency               FREQ
Period                  PER
Rise_Time               RTIM
Fall_Time               FTIM
Pulse_Width_+           PPW
Pulse_Width_-           NPW
Duty_Cycle_+            PDCY
Duty_Cycle_-            NDCY
Delay                   DEL
Phase                   PHAS
Burst_Width             BWID
Pos_Pulses              PPC
Neg_Pulses              NPC
Pos_Slopes              REC
Neg_Slopes              FEC
Trigger_Frequency       TFR
Trigger_Period          TPER

#cmdSetup multi Source Meas_5
:read:   MEAS5:SOUR?
:write:  MEAS5:SOUR #,#
:string:
combobox CH1 CH1 CH2 CH2 EXT EXT D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 RE1 RE1 RE2 RE2 RE3 RE3 RE4 RE4 MA1 MA1 MA2 MA2 MA3 MA3 MA4 MA4 MA5 MA5
combobox - - CH1 CH1 CH2 CH2 EXT EXT D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 RE1 RE1 RE2 RE2 RE3 RE3 RE4 RE4 MA1 MA1 MA2 MA2 MA3 MA3 MA4 MA4 MA5 MA5

#cmdSetup multi Slope Meas_5
:read:    MEAS5:DEL:SLOP?
:write:   MEAS5:DEL:SLOP #,#
:enable:  Meas_5.Type=="DEL"
:string:
combobox Rise POS Fall NEG
combobox Rise POS Fall NEG


; ----- Meas_6 -----------------------------------------------------------------------

#cmdSetup comboboxhot Type Meas_6
:read:  :MEAS6:MAIN?
:write: :MEAS6:MAIN #
:update: Meas_6.Source
:string:
Mean_(DC)               MEAN
Standard_Deviation_(AC) STDD
RMS_(AC+DC)             RMS
Amplitude               AMPL
Peak_Peak               PEAK
Peak_+                  UPE
Peak_-                  LPE
Crest_Factor            CRES
Top_Level               HIGH
Base_Level              LOW
Pos_Overshoot           POV
Neg_Overshoot           NOV
Frequency               FREQ
Period                  PER
Rise_Time               RTIM
Fall_Time               FTIM
Pulse_Width_+           PPW
Pulse_Width_-           NPW
Duty_Cycle_+            PDCY
Duty_Cycle_-            NDCY
Delay                   DEL
Phase                   PHAS
Burst_Width             BWID
Pos_Pulses              PPC
Neg_Pulses              NPC
Pos_Slopes              REC
Neg_Slopes              FEC
Trigger_Frequency       TFR
Trigger_Period          TPER

#cmdSetup multi Source Meas_6
:read:    MEAS6:SOUR?
:write:   MEAS6:SOUR #,#
:string:
combobox CH1 CH1 CH2 CH2 EXT EXT D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 RE1 RE1 RE2 RE2 RE3 RE3 RE4 RE4 MA1 MA1 MA2 MA2 MA3 MA3 MA4 MA4 MA5 MA5
combobox - - CH1 CH1 CH2 CH2 EXT EXT D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 RE1 RE1 RE2 RE2 RE3 RE3 RE4 RE4 MA1 MA1 MA2 MA2 MA3 MA3 MA4 MA4 MA5 MA5

#cmdSetup multi Slope Meas_6
:read:    MEAS6:DEL:SLOP?
:write:   MEAS6:DEL:SLOP #,#
:enable:  Meas_6.Type=="DEL"
:string:
combobox Rise POS Fall NEG
combobox Rise POS Fall NEG


; ----- DVM 1 -----------------------------------------------------------------------

#cmdSetup comboboxhot Type Meas_DVM1
:read:    DVM1:TYPE?
:write:   DVM1:TYPE #
:string:
Off    OFF
DC     DC
AC+DC  ACDC
AC_RMS ACRM

#cmdSetup comboboxhot Source Meas_DVM1
:read:    DVM1:SOUR?
:write:   DVM1:SOUR #
:string:
CH1 CH1
CH2 CH2

#cmdSetup numberInt Weight Meas_DVM1
:read:    DVM1:STAT:WEIG?
:write:   DVM1:STAT:WEIG #
_ 1 1000


; ----- DVM 2 -----------------------------------------------------------------------

#cmdSetup comboboxhot Type Meas_DVM2
:read:    DVM2:TYPE?
:write:   DVM2:TYPE #
:string:
Off    OFF
DC     DC
AC+DC  ACDC
AC_RMS ACRM

#cmdSetup comboboxhot Source Meas_DVM2
:read:    DVM2:SOUR?
:write:   DVM2:SOUR #
:string:
CH1 CH1
CH2 CH2

#cmdSetup numberInt Weight Meas_DVM2
:read:    DVM2:STAT:WEIG?
:write:   DVM2:STAT:WEIG #
_ 1 1000


; ----- DVM 3 -----------------------------------------------------------------------

#cmdSetup separator - Meas_DVM3
:color: white
2 100 Empty

#cmdSetup comboboxhot Type Meas_DVM3
:read:    DVM3:TYPE?
:write:   DVM3:TYPE #
:string:
Off    OFF
DC     DC
AC+DC  ACDC
AC_RMS ACRM

#cmdSetup comboboxhot Source Meas_DVM3
:read:    DVM3:SOUR?
:write:   DVM3:SOUR #
:string:
CH1 CH1
CH2 CH2

#cmdSetup numberInt Weight Meas_DVM3
:read:    DVM3:STAT:WEIG?
:write:   DVM3:STAT:WEIG #
_ 1 1000


; ----- DVM 4 -----------------------------------------------------------------------

#cmdSetup comboboxhot Type Meas_DVM4
:read:    DVM4:TYPE?
:write:   DVM4:TYPE #
:string:
Off    OFF
DC     DC
AC+DC  ACDC
AC_RMS ACRM

#cmdSetup comboboxhot Source Meas_DVM4
:read:    DVM4:SOUR?
:write:   DVM4:SOUR #
:string:
CH1 CH1
CH2 CH2

#cmdSetup numberInt Weight Meas_DVM4
:read:    DVM4:STAT:WEIG?
:write:   DVM4:STAT:WEIG #
_ 1 1000


; ----- Cursor -----------------------------------------------------------------------

#cmdSetup comboboxhot Type Meas_Cursor
:read:    CURS:FUNC?
:write:   CURS:FUNC #
:string:
Mean_(DC)               MEAN
Standard_Deviation_(AC) STDD
RMS_(AC+DC)             RMS
Peak_Peak               PEAK
Peak+                   UPE
Peak-                   LPE
V-Marker                PAIR
Voltage                 HOR
Horizontal_Ratio        HRAT
Vertical_Ratio          VRAT
Time                    VERT
Frequency               FRE
Period                  PER
Rise_Time               RTIM
Fall_Time               FTIM
Duty_Cycle_+            PDCY
Duty_Cycle_-            NDCY
Pos_Pulses              PPC
Neg_Pulses              NPC
Pos_Slopes              REC
Neg_Slopes              FEC

#cmdSetup comboboxhot Source Meas_Cursor
:read:    CURS:SOUR?
:write:   CURS:SOUR #
:string:
CH1 CH1
CH2 CH2
EXT EXT
D0  D0
D1  D1
D2  D2
D3  D3
D4  D4
D5  D5
D6  D6
D7  D7
QMA QMA
MA1 MA1
MA2 MA2
MA3 MA3
MA4 MA4
MA5 MA5
RE1 RE1
RE2 RE2
RE3 RE3
RE4 RE4
XY  XY

#cmdSetup button Set_to_Trace Meas_Cursor
:write: SWAV


; ----- Control- -----------------------------------------------------------------------

#cmdSetup separator - Meas_Control
4 100 Empty

#cmdSetup info Display Meas_Control

#cmdSetup separator - Meas_Control
1 100 Solid

#cmdSetup buttonsOn Meas_1 Meas_Control
:read:    MEAS1:ENAB?
:write:   MEAS1:ENAB #
Off 0
On 1

#cmdSetup buttonsOn Meas_2 Meas_Control
:read:    MEAS2:ENAB?
:write:   MEAS2:ENAB #
Off 0
On  1

#cmdSetup buttonsOn Meas_3 Meas_Control
:read:    MEAS3:ENAB?
:write:   MEAS3:ENAB #
Off 0
On  1

#cmdSetup buttonsOn Meas_4 Meas_Control
:read:    MEAS4:ENAB?
:write:   MEAS4:ENAB #
Off 0
On  1

#cmdSetup buttonsOn Meas_5 Meas_Control
:read:    MEAS5:ENAB?
:write:   MEAS5:ENAB #
Off 0
On  1

#cmdSetup buttonsOn Meas_6 Meas_Control
:read:    MEAS6:ENAB?
:write:   MEAS6:ENAB #
Off 0
On  1

#cmdSetup buttonsOn DVM_1-4 Meas_Control
:read:    DVM:ENAB?
:write:   DVM:ENAB #
;:color:   white
Off 0
On 1

#cmdSetup buttonsOn TCO Meas_Control
:read:    TCO:ENAB?
:write:   TCO:ENAB #
Off 0
On 1

#cmdSetup buttonsOn Cursor Meas_Control
:read:    CURS:STAT?
:write:   CURS:STAT #
Off 0
On 1


;------------------------------------------------------------------------------------
; Global Control
;------------------------------------------------------------------------------------

; NOTE: the underscores define a constant dialog width
#cmdSetup radio Mode________
:read:  DEV:MODE?
:write: DEV:MODE
:string:
YT YT
Quick QME
FFT FFT
XY XY
Mask MASK
Comp COMP

; NOTE: Should be logically in the Setup dialog, but readability is better when in the Mode Dialog
;#cmdSetup button Auto_Set
;:write: AUT

; NOTE: This commands are OK, but overload the dialog
;#cmdSetup buttons Control
;:write: #
;Single   SING
;Run      RUN
;Stop     STOP
;Auto_Set AUTO


;------------------------------------------------------------------------------------
; Other Commands
;------------------------------------------------------------------------------------

#otherList
menuItem[0]="Hardcopy....xxx";
menuItem[1]="Device Status....xxx";
menuItem[2]="Save Waveforms....xxx";
menuItem[3]="Save Pattern....xxx"
menuItem[4]="Load Pattern....xxx"
menuItem[5]="Save Settings....xxx";
menuItem[6]="Load Settings....xxx";
menuItem[7]="Save File....xxx";
menuItem[8]="Load File....xxx";
menuItem[9]="Delete File....xxx";
menuItem[10]="Change Directory....xxx";

#otherFunc
if (name == "Hardcopy....xxx")

  deviceWrite(handle, "HCOP:FORM PNG");

  var now   = date();
  var image = deviceReadBytes(handle, "HCOPY:DATA?");
  var timestamp;

  timestamp = substring(now,0,4)+"-" + substring(now,4,6) + "-" + substring(now,6,8);
  timestamp = timestamp + " " + substring(now,8,10)+":" + substring(now,10,12)+":" + substring(now,12,14);

  addImage(image, handle +" "+timestamp);

elseif (name == "Device Status....xxx")

  var data;

  data = unQuote(deviceRead(handle,"SYST:ERR:ALL?"));
  data = replace  (data, "\",","\"\r\n");

  if (indexOf(data, "No error") != -1)
    popupShowInfo("Error Queue: \r\n"+data, 1);
  else
    popupShowInfo("Error Queue: \r\n"+data, 3);
  endif

elseif (name == "Save File....xxx")

  var bStatus    = 0;
  var filename   = "";
  var file_name  = "" ;
  var file_count = int(deviceRead(handle, "MMEM:CAT:LENG?"));
  var file_list  = deviceRead(handle, "MMEM:CAT?");
  var file_binary;
  var dir_current = unQuote(deviceRead(handle, "MMEM:CDIR?"));
  var dir_size;
  var disk_size;
  var list[0];
  var j;

  file_list = replace(file_list, "\"", "");

  for j=0 to file_count-1 do
    list[j]=getElement(file_list, 2+j*3, ",");
  endfor
  dir_size  = int(getElement(file_list, 0, ","));
  disk_size = int(getElement(file_list, 1, ","));

  popupInit   ("Save File");
  popupLabel  ("");
  popupLabel  ("  Download a file from the current directory on the remote device and save it.  ");
  popupLabel  ("Usage: "+string(int(dir_size/1024))+" KB of "+string(int(disk_size/1024))+" KB ("+int(dir_size/disk_size+1)+"%)");
  popupLabel  ("");
  popupLabel  (dir_current+"/");
  popupCombo  ("From", "file_name", list);
  popupFile   ("To", "filename", "", "", 0);
  popupButtons("OK", "bStatus", "Cancel");
  popupShow   ();

  if (bStatus && filename != "")
    file_binary = deviceReadBytes(handle, "MMEM:DATA? \""+file_name+"\"");
    fileWriteBytes(filename, file_binary);
    popupShowInfo("Saved file "+file_name+" to file\r\n"+filename, 1);
  endif

elseif (name == "Load File....xxx")

  var bStatus    = 1;
  var filename   = "";
  var file_name  = "" ;
  var file_count = int(deviceRead(handle, "MMEM:CAT:LENG?"));
  var file_list  = deviceRead(handle, "MMEM:CAT?");
  var file_binary;
  var dir_current = unQuote(deviceRead(handle, "MMEM:CDIR?"));
  var dir_size;
  var disk_size;
  var list[0];
  var j;
  var valid_filename=0;

  file_list = replace(file_list, "\"", "");

  for j=0 to file_count-1 do
    list[j]=getElement(file_list, 2+j*3, ",");
  endfor
  dir_size  = int(getElement(file_list, 0, ","));
  disk_size = int(getElement(file_list, 1, ","));

  while (bStatus && valid_filename==0) do
    bStatus = 0;
    popupInit   ("Load File");
    popupLabel  ("");
    popupLabel  ("  Download file to the current directory on the remote device.  ");
    popupLabel  ("Usage: "+string(int(dir_size/1024))+" KB of "+string(int(disk_size/1024))+" KB ("+int(dir_size/disk_size+1)+"%)");
    popupLabel  ("");
    popupFile   ("From", "filename", "", "", 1);
    popupLabel  (dir_current+"/");
    popupText   ("To ", "file_name")
    popupButtons("OK", "bStatus", "Cancel");
    popupShow   ();

    if (bStatus)
      valid_filename = countMatch(file_name,"[a-zA-Z0-9_]+[.][a-zA-Z0-9]+")==1;

      if (valid_filename==0)
         popupShowInfo("Invalid filename\r\n "+file_name, 3);
      elseif (int(deviceRead(handle, "MMEM:EXIS? \""+file_name+"\"")))
         valid_filename=0;
         popupShowInfo("File already exists:\r\n "+file_name, 3);
      endif
    endif
  endwhile

  if (bStatus && filename != "")
    file_binary = fileReadBytes(filename);
    displayVar("Download "+file_name+" ("+string(size(file_binary))+" bytes) ...");
    var command = "MMEM:DATA \""+file_name+"\", ";
    deviceWriteBytes(handle, command, file_binary, "\n");
    displayVar("Download of file "+file_name+" completed.");
  endif

elseif (name == "Delete File....xxx")

  var bStatus    = 1;
  
  while (bStatus) do
    var file_name   = "" ;
    var file_count  = int(deviceRead(handle, "MMEM:CAT:LENG?"));
    var file_list   = deviceRead(handle, "MMEM:CAT?");
    var dir_current = unQuote(deviceRead(handle, "MMEM:CDIR?"));
    var dir_size;
    var disk_size;
    var list[0];
    var j;
    
    ; TC BUG: array is not resized (getting smaller) when redeclared => fill
    for j = 0 to size(list)-1 do
      list[j]="";
    endfor
    
    file_list = replace(file_list, "\"", "");
    
    for j=0 to file_count-1 do
      list[j]=getElement(file_list, 2+j*3, ",");
    endfor
    dir_size  = int(getElement(file_list, 0, ","));
    disk_size = int(getElement(file_list, 1, ","));
    
    popupInit   ("Delete File");
    popupLabel  ("");
    popupLabel  ("  Delete files from the current directory on the remote device.  ");
    popupLabel  ("Usage: "+string(int(dir_size/1024))+" KB of "+string(int(disk_size/1024))+" KB ("+int(dir_size/disk_size+1)+"%)");
    popupLabel  ("");
    popupLabel  (dir_current+"/");
    popupCombo  ("File", "file_name", list);
    popupButtons("Delete", "bStatus", "Close");
    popupShow   ();
    
    if (bStatus && file_name != "")
      if(popupShowQuestion("Delete file on remote device?\r\n"+file_name)) 
        deviceWrite(handle, "MMEM:DEL \""+file_name+"\"");
        popupShowInfo("Deleted file on remote device\r\n"+file_name, 1);
      endif
    endif
  endwhile

elseif (name == "Change Directory....xxx")

  var bStatus = 1;
  var j;

  while (bStatus) do
    var list[0];
    var start       = 0;
    var file_name   = "..";
    var file_count  = int(deviceRead(handle, "MMEM:DCAT:LENG?"));
    var file_list   = deviceRead(handle, "MMEM:DCAT?");
    var dir_current = unQuote(deviceRead(handle, "MMEM:CDIR?"));
    file_list       = replace(file_list, "\"", "");

    ; TC BUG: array is not resized (getting smaller) when redeclared => fill
    for j = 0 to size(list)-1 do
      list[j]="";
    endfor

    if (getElement(file_list, 0, ",")==".")
      start = 1;
    endif

    for j=0 to file_count-start-1 do
       list[j]=getElement(file_list, (j+start)*3, ",");
    endfor

    var drives = deviceRead(handle, "MMEM:DRIV?");
	drives = replace(drives, "\"", "");
    list[file_count-start]   = "/INT";
	if (inList("/USB_FRONT", drives))
	  list[file_count-start+1] = "/USB_FRONT";
	endif

    popupInit   ("Change Directory");
    popupLabel  ("");
    popupLabel  ("  Change to a new directory on the remote device.  ");
    popupLabel  ("");
    popupLabel  (dir_current+"/");
    popupCombo  ("Directory", "file_name", list);
    popupButtons("Change", "bStatus", "Close");
    popupShow   ();

    if (bStatus && file_name != "")
      deviceWrite(handle, "MMEM:CDIR \""+file_name+"\"");
    endif
  endwhile

elseif (name == "Save Settings....xxx")

  var bStatus  = 0;
  var filename = "";
  var data;

  popupInit   ("Save Settings");
  popupLabel  ("");
  popupLabel  ("  Download device settings from the device and write them to a file.  ");
  popupLabel  ("");
  popupFile   ("File", "filename", "", "set", 0);
  popupButtons("OK", "bStatus", "Cancel");
  popupShow   ();

  if (bStatus && filename != "")
    data = deviceReadBytes(handle, "SYST:SET?");
    fileWriteBytes(filename, data);
    popupShowInfo("Saved device setting to file\r\n"+filename, 1);
  endif

elseif (name == "Load Settings....xxx")

  var bStatus  = 0;
  var filename = "";
  var data;

  popupInit   ("Load Settings");
  popupLabel  ("");
  popupLabel  ("  Load device settings from file and download them to the device.  ");
  popupLabel  ("");
  popupFile   ("File", "filename", "", "set", 1);
  popupButtons("OK", "bStatus", "Cancel");
  popupShow   ();

  if (bStatus && filename != "")
     data = fileReadBytes(filename);
     deviceWriteBytes(handle, "SYST:SET ", data, "\n");

     popupShowInfo("Loaded device setting from file\r\n"+filename, 1);
  endif

elseif (name == "Save Pattern....xxx")

  var bStatus  = 0;
  var filename = "";
  var samples;
  var data;
  var i;
  var value;

  popupInit   ("Save Pattern");
  popupLabel  ("");
  popupLabel  ("  Download Pattern Generator data from the device and write them to a file.  ");
  popupLabel  ("");
  popupFile   ("File", "filename", "", "csv", 0);
  popupButtons("OK", "bStatus", "Cancel");
  popupShow   ();

  if (bStatus && filename != "")
     samples = deviceRead(handle, "PGEN:PATTern:ARBitrary:DATA:LENGth?");
     data = deviceRead(handle, "PGEN:PATT:ARB:DATA?");

     fileDelete(filename);
     fileAppendText(filename, "#P3;P2;P1;P0\n");
     for i=0 to samples-1 do
       value = getElement(data, i, ",");
       fileAppendText(filename, (value>>3)&1, ";", (value>>2)&1, ";", (value>>1)&1, ";", (value>>0)&1, "\n");
     endfor
     fileAppendClose();

     popupShowInfo("Saved pattern generator data to file\r\n"+filename+"\r\n("+string(samples)+" data points)", 1);
  endif

elseif (name == "Load Pattern....xxx")

  var bStatus  = 0;
  var filename = "";
  var samples  = 0;
  var data;
  var command;
  var i;
  var p0;
  var p1;
  var p2;
  var p3;

  popupInit   ("Load Pattern");
  popupLabel  ("");
  popupLabel  ("  Load Pattern Generator data from a file and download them to the device.  ");
  popupLabel  ("");
  popupFile   ("File", "filename", "", "csv", 1);
  popupButtons("OK", "bStatus", "Cancel");
  popupShow   ();

  if (bStatus && filename != "")

    data = fileReadText(filename);
    data = replace  (data, "\r\n","\n");
    data = replaceRX(data, "[ \t]","");
    data = replaceRX(data, "[\n]+\n","\n");
    data = replaceRX(data, "#[^\n]*\n","");
    data = replace  (data, ";",",");
    data = replace  (data, ",\n","\n");
    samples = countMatch(data,"\n");
    data = replace  (data, "\n",",");

    command = "";
    for i=0 to samples-1 do
      p3 = int(getElement(data, i*4+0, ","));
      p2 = int(getElement(data, i*4+1, ","));
      p1 = int(getElement(data, i*4+2, ","));
      p0 = int(getElement(data, i*4+3, ","));
      command = command+string(((p3 & 1)<<3) | ((p2 & 1)<<2) | ((p1 & 1)<<1) | ((p0 & 1)<<0));
      if (i != samples-1)
        command = command+",";
      endif
    endfor

    deviceWrite(handle, "PGEN:PATT:ARB:DATA "+command);

    popupShowInfo("Loaded pattern generator data from file\r\n"+filename+"\r\n("+string(samples)+" data points)", 1);
  endif

elseif (name == "Save Waveforms....xxx")

  var indexname = "";
  var basename;
  var filename;
  var data;
  var header;
  var start;
  var end;
  var samples;
  var samples_per_sample;
  var yincrement;
  var yorigin;
  var value;
  var i;
  var bindex;

  ; Dialog
  var bStatus = 0;
  var bBUS[3];
  var bCH[3];
  var bEXT = 0;
  var bPOD = 0;
  var bCSV = 0;

  var ch1  = int(deviceRead(handle, "CHAN1:STAT?"));
  var ch2  = int(deviceRead(handle, "CHAN2:STAT?"));
  var pod  = int(deviceRead(handle, "POD:STAT?"));
  var b1   = int(deviceRead(handle, "BUS1:STAT?"));
  var b2   = int(deviceRead(handle, "BUS2:STAT?"));
  var ext;
  if (b1 && b2)
    ext = 0;
  else
    ext = int(deviceRead(handle, "EXT:STAT?"));
  endif

  bCH[1]  = 0;
  bCH[2]  = 0;
  bBUS[1] = 0;
  bBUS[2] = 0;

  popupInit    ("Save Waveforms");
  popupLabel   ("");
  popupLabel   ("  Download waveform data and write to a file per channel.  ");
  popupLabel   ("  An index file with acquistion parameters is generated.  ");
  popupLabel   ("");
  popupFile    ("File", "indexname", "", "idx",0);
  popupCheckbox("CSV","bCSV", "Save data in CSV format");
  popupLabel   ("");
  popupLabel   ("Channels:");
  if (ch1)
    bCH[1] = 1;
    popupCheckbox("CH1","bCH[1]");
  endif
  if (ch2)
    bCH[2] = 1;
    popupCheckbox("CH2","bCH[2]");
  endif
  if (ext)
    bEXT = 1;
    popupCheckbox("EXT","bEXT");
  endif
  if (pod)
    bPOD = 1;
    popupCheckbox("D0-7","bPOD");
  endif
  if (b1)
    bBUS[1] = 1;
    popupCheckbox("B1","bBUS[1]");
  endif
  if (b2)
    bBUS[2] = 1;
    popupCheckbox("B2","bBUS[2]");
  endif
  popupButtons("OK", "bStatus", "Cancel");
  popupShow   ();

  if (bStatus && indexname != "")

    basename = substring(indexname, 0, strlen(indexname)-4);
    fileDelete(indexname);
    fileAppendText(indexname, "#Channel;Start;End;Samples;Samples_per_sample\n");

    ; Download
    deviceWrite(handle,"FORMAT:DATA UINT,8;");

    for bindex = 1 to 2 do

      filename = basename + "_ch"+string(bindex);
	  fileDelete(filename+ ".csv");
	  fileDelete(filename+ ".dat");
	  if (bCSV)
	    filename = filename + ".csv";
	  else
	    filename = filename + ".dat";
      endif
      
      if (bCH[bindex])
        displayVar("CH"+bindex+": Save to "+filename+"...");

        var chan_cmd = "CHAN"+string(bindex);

        yincrement = double(deviceRead(handle, chan_cmd+":DATA:YINC?"));
        yorigin    = double(deviceRead(handle, chan_cmd+":DATA:YOR?" ));
        header     =        deviceRead(handle, chan_cmd+":DATA:HEAD?");
        start      = double(getElement(header, 0, ","));
        end        = double(getElement(header, 1, ","));
        samples    = int   (getElement(header, 2, ","));
        samples_per_sample = int(getElement(header, 3, ","));

        fileAppendText(indexname, "ch", bindex, ";",start,";",end,";",samples,";",samples_per_sample,"\n");
        fileAppendClose(indexname);

        data = deviceReadBytes(handle, chan_cmd+":DATA?");

        if (bCSV)
          var data_time = start;
          var step      = (end-start)/(samples-samples_per_sample);

          fileAppendText(filename, "#Time;Value\n");
          for i=0 to samples-1 do
            value = int(subbytes(data, i, i+1));
            fileAppendText(filename, data_time, ";", double(value)*yincrement+yorigin, "\n");
            data_time = data_time + step;
          endfor
          fileAppendClose(filename);
        else
          fileWriteBytes(filename, data);
        endif
      endif
    endfor

    filename = basename + "_ext";
	fileDelete(filename+ ".csv");
	fileDelete(filename+ ".dat");
	if (bCSV)
	  filename = filename + ".csv";
	else
	  filename = filename + ".dat";
    endif
	
    if (bEXT)
      displayVar("EXT: Save to "+filename+"...");

      header     = deviceRead(handle, "EXT:DATA:HEAD?");
      start      = double(getElement(header, 0, ","));
      end        = double(getElement(header, 1, ","));
      samples    = int   (getElement(header, 2, ","));
      samples_per_sample = int(getElement(header, 3, ","));
      fileAppendText(indexname, "ext;",start,";",end,";",samples,";",samples_per_sample,"\n");
      fileAppendClose();

      data = deviceReadBytes(handle, "EXT:DATA?");

      if (bCSV)
        var data_time = start;
        var step      = (end-start)/(samples-samples_per_sample);

        fileAppendText(filename, "#Time;EXT\n");
        for i=0 to samples-1 do
          value = int(subbytes(data, i, i+1));
          fileAppendText(filename, data_time, ";", value, "\n");
          data_time = data_time + step;
        endfor
        fileAppendClose();
      else
        fileWriteBytes(filename, data);
      endif
    endif

    filename = basename + "_pod"
	fileDelete(filename+ ".csv");
	fileDelete(filename+ ".dat");
	if (bCSV)
	  filename = filename + ".csv";
	else
	  filename = filename + ".dat";
    endif
	
    if (bPOD)
      displayVar("D0-7: Save to "+filename+"...");

      header     = deviceRead(handle, "POD:DATA:HEAD?");
      start      = double(getElement(header, 0, ","));
      end        = double(getElement(header, 1, ","));
      samples    = int   (getElement(header, 2, ","));
      samples_per_sample = int(getElement(header, 3, ","));
      fileAppendText(indexname, "pod;",start,";",end,";",samples,";",samples_per_sample,"\n");
      fileAppendClose(filename);

      data = deviceReadBytes(handle, "POD:DATA?");

      if (bCSV)
        var data_time = start;
        var step      = (end-start)/(samples-samples_per_sample);

        fileAppendText(filename, "#Time;D7;D6;D5;D4;D3,D2,D1;D0\n");
        for i=0 to samples-1 do
          value = int(subbytes(data, i, i+1));
          fileAppendText(filename, data_time,";", (value>>7)&1,";", (value>>6)&1,";", (value>>5)&1,";", (value>>4)&1,";", (value>>3)&1,";", (value>>2)&1,";", (value>>1)&1,";", (value>>0)&1, "\n");
          data_time = data_time + step;
        endfor
        fileAppendClose(filename);
      else
        fileWriteBytes(filename, data);
      endif
    endif

    for bindex = 1 to 2 do

        filename = basename + "_b"+string(bindex)+".csv";
        fileDelete(filename);

        if (bBUS[bindex])

          var i;
          var j;
          var bus_cmd = "BUS"+string(bindex);

          displayVar("B"+string(bindex)+": Save to "+filename+"...");

          var bus_format = deviceRead(handle, bus_cmd+":FORM?");
          var bus_type   = deviceRead(handle, bus_cmd+":TYPE?");

          fileAppendText(indexname, "b"+string(bindex)+"; ",bus_type, ";", bus_format, "\n");
          fileAppendClose(indexname);

          if (bus_type == "SPI" || bus_type == "SSPI")

             var frames = deviceRead(handle, bus_cmd+":SPI:FCO?");

             for i=1 to frames do
               var frame_cmd    = bus_cmd+":SPI:FRAM"+string(i);
               var frame_status =        deviceRead(handle, frame_cmd+":STAT?");
               var frame_start  = double(deviceRead(handle, frame_cmd+":STAR?"));
               var frame_stop   = double(deviceRead(handle, frame_cmd+":STOP?"));

               if (frame_status != "VOID")
                 var frame_data  =     deviceRead(handle, frame_cmd+":DATA?");
                 var frame_words = int(deviceRead(handle, frame_cmd+":WCO?"));

                 displayVar("B"+string(bindex)+": Save to "+filename+"..."+" - "+string(frame_words));

                 for j=1 to frame_words do
                   var word_cmd   = frame_cmd+":WORD"+string(j);
                   var word_status;
                   var word_start = double(deviceRead(handle, word_cmd+":STAR?"));
                   var word_stop  = double(deviceRead(handle, word_cmd+":STOP?"));
                   var word       = int(getElement(frame_data, j-1, ","));

                   if (j==1 && frame_status == "INCF")
                      word_status = frame_status;
                   elseif (j==frame_words && frame_status == "INCL")
                      word_status = frame_status;
                   else
                      word_status = "OK";
                   endif
                   fileAppendText(filename, word_start, ";", word_stop, ";", word, ";", word_status, "\n");
                 endfor
               else
                 displayVar("Frame "+string(i)+": "+frame_status);
               endif
             endfor
             fileAppendClose(filename);

          elseif (bus_type == "UART")

             var frames = deviceRead(handle, "BUS"+string(bindex)+":UART:FCO?");

             for i=1 to frames do
               var frame_cmd   = "BUS"+string(bindex)+":UART:FRAM"+string(i);
               var frame_words = deviceRead(handle, frame_cmd+":WCO?");

               for j=0 to frame_words-1 do
                 var word_cmd    = frame_cmd+":WORD"+string(j);
                 var word_status =        deviceRead(handle, word_cmd+":STAT?");
                 var word_start  = double(deviceRead(handle, word_cmd+":STAR?"));
                 var word_stop   = double(deviceRead(handle, word_cmd+":STOP?"));

                 if (word_status != "VOID" && word_status != "INS")
                   var word = int(deviceRead(handle, word_cmd+":VAL?"));
                   fileAppendText(filename, word_start, ";", word_stop, ";", word, ";", word_status, "\n");
                 else
                   fileAppendText(filename, word_start, ";", word_stop, ";", 0, ";", word_status, "\n");
                 endif
               endfor
             endfor
             fileAppendClose(filename);

          elseif (bus_type == "I2C")

            var frames  = deviceRead(handle, bus_cmd+":I2C:FCO?");

            for i=1 to frames do
               var frame_cmd    = bus_cmd+":I2C:FRAM"+string(i);
               var frame_status =        deviceRead(handle, frame_cmd+":STAT?");
               var frame_start  = double(deviceRead(handle, frame_cmd+":STAR?"));
               var frame_stop   = double(deviceRead(handle, frame_cmd+":STOP?"));

               if (frame_status != "VOID" && frame_status != "INS" && frame_status != "INC")
                 var frame_address       = int(deviceRead(handle, frame_cmd+":ADDR?"));
                 var frame_address_start = double(deviceRead(handle, frame_cmd+":AST?"));
                 var frame_address_stop  = double(deviceRead(handle, frame_cmd+":ADBS?"));
                 var frame_address_ack   = deviceRead(handle, frame_cmd+":AACC?");
                 var frame_data          = deviceRead(handle, frame_cmd+":DATA?");
                 var frame_words         = int(deviceRead(handle, frame_cmd+":BCO?"));

                 fileAppendText(filename, frame_address_start, ";", frame_address_stop, ";", frame_address, ";", frame_address_ack, ";", frame_status, "\n");

                 for j=0 to frame_words-1 do
                   var word_cmd   = frame_cmd+":BYTE"+string(j);
                   var word_ack   =        deviceRead(handle, word_cmd+":ACC?");
                   var word_start = double(deviceRead(handle, word_cmd+":STAR?"));
                   var word_stop  = double(deviceRead(handle, word_cmd+":ACKS?"));
                   var word       = getElement(frame_data, j, ",");

                   fileAppendText(filename, word_start, ";", word_stop, ";", word, ";", word_ack, "\n");
                 endfor
               endif
            endfor
            fileAppendClose(filename);

          elseif (bus_type == "PAR" || bus_type == "CPAR")

            var frames = deviceRead(handle, bus_cmd+":PAR:FCO?");

            for i=1 to frames do
               var frame_cmd    = bus_cmd+":PAR:FRAM"+string(i);
               var frame_status =        deviceRead(handle, frame_cmd+":STAT?");
               var frame_start  = double(deviceRead(handle, frame_cmd+":STAR?"));
               var frame_stop   = double(deviceRead(handle, frame_cmd+":STOP?"));

               if (frame_status != "VOID" && frame_status != "INS" && frame_status != "ERR")
                 var frame_data  = deviceRead(handle, frame_cmd+":DATA?");
                 var frame_words = 1;
                 if (bus_type=="CPAR" && frame_status != "FRST")
                    frame_words  = countMatch(frame_data,",")+1;
                 endif

                 var word_delta  = (frame_stop-frame_start)/frame_words;
                 var word_start  = frame_start;
                 var word_stop   = word_start + word_delta;

                 for j=0 to frame_words-1 do
                   var word = getElement(frame_data, j, ",");
                   fileAppendText(filename, word_start, ";", word_stop, ";", word, "\n");
                   word_start = word_stop;
                   word_stop  = word_stop + word_delta;
                 endfor
               endif
            endfor
            fileAppendClose(filename);

          endif
        endif
    endfor

    displayVar("Download complete");

  endif

endif


;------------------------------------------------------------------------------------
; Help
;------------------------------------------------------------------------------------

#notes
Press F1 in Mode or Setup window for device information.

The device provides up to 12 configurable measurement channels, which can be used for logging.
The waveform data of the analog channels, the digital channels or the bus decoders can be downloaded.
The Pattern Generator data can be up or downloaded.
The most important device functions can be configured remotely.

Revision 1.0  19 Feb 2022
- Inital release

Revision 1.1  30 Jul 2022
- Add hardcopy menu item
- Add device status dialog
- Add waveform download (Analog, Logic, Bus)
- Add pattern gnerator upload/download
- Add pattern generator control
- Update function generator GUI
- Update measurement GUI
- Add DVM and counter to measurement
- Add cursor measurement
- Add trigger configuration
- Add virtual screen/message control
- Add file upload/download/directory change


#helpurl https://www.rohde-schwarz.com/webhelp/RTC_HTML_UserManual_en/Content/welcome.htm
;#helpurl https://scdn.rohde-schwarz.com/ur/pws/dl_downloads/pdm/cl_manuals/user_manual/1335_7352_01/RTC_UserManual_en_06.pdf


;------------------------------------------------------------------------------------
; Debug
;------------------------------------------------------------------------------------

