; This definition is basically 4 separate definitions (AC/DC/DCLOAD/USB) selected by the #metadef's

;DL24 has moved to ATorchPX100Devices using a more complete protocol
#metadef
#idString ATorch,ATorch DL24-old,
#name ATorch DL24-old
#handle ATDL24
#sections DCLOAD_DEVICE

#metadef
#idString ATorch,ATorch AT3010,
#name ATorch AT3010 
#handle AT3010
#sections AC_DEVICE

#metadef
#idString ATorch,ATorch USB,
#name ATorch USB
#checksum none
#handle ATUSB
#sections USB_DEVICE

#metadef
#idString ATorch,ATorch JL44,
#name ATorch JL44
#handle JL44
#checksum none
#sections AC_DEVICE

#metadef
#idString ATorch,ATorch JL24,
#name ATorch JL24
#handle JL24
#checksum none
#sections AC_DEVICE




#meta
;--------------------------------------------------------------------------
; https://github.com/NiceLabs/atorch-console/blob/master/docs/protocol-design.md
; https://auto-scripting.com/2020/05/03/atorch-dl24-hack-1/
; All datafields are decoded and for USB a watt is added at the end.
; Time is converted into seconds, backlight is stored separately with its own read command
; All the different commands can be added with the tx command.

#idString ATorch,ATorch,
#name ATorch 
#handle ATorch
#port comfixedbaud
#baudrate 9600

#driver ATorch
#readingDelay 5

#checksum none

;--------------------------------------------------------------------------
#metaSection AC_DEVICE
#subDriver AC
#value Voltage V D1
#value Current A D3
#value Power W D1
#value Energy Wh D2
#value Frequency Hz D1
#value Power_Factor - D3

#askValues values?

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

#interfacetype Power
#interface readPower 2
#interface readVoltage 0
#interface readCurrent 1
#interface readEnergy 3
#interface readFrequency 4
#interface readPowerFactor 5


#cmdSetup buttons Reset
:write: tx
Wh 1
Ah 2
Time 3
All 5

#cmdSetup numberInt Backlight
:read: backlightTimer?
:write: tx 0x21 
sec 0 255


;--------------------------------------------------------------------------
#metaSection DCLOAD_DEVICE
#subDriver DCLOAD
#value Voltage V D1
#value Current A D3
#value Power W D1
#value Capacity Ah D3
#value Energy Wh D3

#askValues values?

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

#notes This is a simple interface for the ATorch loads, many of them supports a better interface.


#interfacetype Load
#interface readVoltage 0
#interface readCurrent 1
#interface readPower 2
#interface readEnergy 3


#cmdSetup buttons Reset
:write: tx
Wh 1
Ah 2
Time 3
All 5

#cmdSetup numberInt Backlight
:read: backlightTimer?
:write: tx 0x21 
sec 0 255

#cmdSetup buttons Setup
:write: tx
Setup 0x31
- 0x34
+ 0x33


#cmdSetup button On/off
:write: tx 0x32

;--------------------------------------------------------------------------
#metaSection DC_DEVICE
#subDriver DC
#value Voltage V D1
#value Current A D3
#value Power W D1
#value Energy Wh D2

#askValues values?

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


#interfacetype Power
#interface readVoltage 0
#interface readCurrent 1
#interface readPower 2
#interface readEnergy 3


#cmdSetup buttons Reset
:write: tx
Wh 1
Ah 2
Time 3
All 5

#cmdSetup numberInt Backlight
:read: backlightTimer?
:write: tx 0x21 
sec 0 255

;--------------------------------------------------------------------------
#metaSection USB_DEVICE
#subDriver USB
#value Voltage V D2
#value Current A D2
#value Capacity Ah D3
#value Energy Wh D2
#value D_Minus V D2
#value D_Plus V D2
#value Power W D3

#askValues values?
#checksum none

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

#interfacetype USBTest
#interface readVoltage 0
#interface readCurrent 1
#interface readCapacity 2
#interface readEnergy 3
#interface readPower 6


#cmdSetup buttons Reset
:write: tx
Wh 1
Ah 2
Time 3
All 5

#cmdSetup numberInt Backlight
:read: backlightTimer?
:write: tx 0x21 
sec 0 255




;--------------------------------------------------------------------------
#metaSection


