;Vitrek PA900 series Power Analyzers
;	May also work with very similare PA910 and PA920 analyzers
;   Tested over Ethernet with Test Controller V2.04.  Earlier versions might not work.
; 2/28/23  Rev B   GBY   Created power analyzer abbreviation for interface
; 4/7/22   Rev A   GBY   Originate

;Per Vitrek manual Communications Interface doc:
; Socket Interface 
;	TCP Port 10733
;   *IDN? returns VITREK,PA900/H500/EN/MU,25605,1.2.10
;   Must use capital letters on the *IDN query and probably all commands
;   ascii text interface
;   The end of a command set is determined by the presence of a command terminator which may be
;		 the line-feed, carriage return, form feed or NULL (0 value) ASCII characters. 
;   Multiple commands together between end of command are separated by the semi-colon ASCII character (;).
;   Over LAN minimum reliable sampling interval is 15 mSec.

#idString VITREK,PA900/H500/EN/MU,
#name Vitrek PA900
#handle PA900
#port 10733
#author gby
#notes Vitrek PA900 series instruments are multi-channel power analyzers.  This driver uses the Ethernet communications option with socket connection.  A modified form of this device file might work with serial, USB or GPIB communications and may work with Vitrek PA910, PA920 series analyzers.
; Alternate port types: comnobaud or com, com lets the user define baudrate on the "Load devices" page


; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6) 
; Format: #value ColumnName Unit Format {Selector}
; Selector is only used when column layout varies with mode, this often require the use of #cmdMode
; Below must match READ? channels defined by the #intCmd or a subsequent custom programming of READ? list.

#value VPA1_A Amp SI
#value VPA1_V Volt SI
#value VPA1_W Watt SI
#value VPA1_F Freq SI
#value VPA2_A Amp SI
#value VPA2_V Volt SI
#value VPA2_W Watt SI
#value VPA2_F Freq SI

; How to poll for data, this is used for table and #values?
; a #askMode, #cmdMode and #prepareSample is used before this is string is used.
; Number of returned values must match number of columns defined with #value
; This is a single line command
;  #initCmd uses READ? to set the default values to be logged.
;  #askValues just does REREAD? to fetch the last set of value fetched by READ?
#askValues REREAD?

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

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

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


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


; When one of these commands are used through the command interface a new configuration will be done before using #askMode
; Only one word for each #mayModifyMode
; Specify command without initial colon and in the shortest possible form
;#mayModifyMode 


; Prepare the meter to response to #askValues
;#prepareSample arm:sour imm;:arm:count 1;:trig:sour imm;:trig:count 1;:trig:samp:count 1;init

; Initial commands to meter when establishing connection, used to disable local control
; askValues uses REREAD? which returns set of values defined by the last READ? command
; At connection set the READ? values up front.
; Below sets up for Virtual Power Analyzer (VPA) 1 ,2 A, V, W, Freq
#initCmd  READ?,A:A1,V:A1,W:A1,FREQ:A1,A:A2,V:A2,W:A2,FREQ:A2

; Final command to meter before breaking connection, used to restore local control
;#finalCmd 

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

;************   Programming Interface **********

#interfaceType PA