
#idString HKJ,SS-Relay,
#name HKJ SS-Relay
#handle SSR
#port comnobaud

#help SS_Relay
#helpurl https://lygte-info.dk/project/SSRelay%20UK.html


#value Outputs _ DIGITAL(O1,O2,O3,O4,O5,O6,O7,O8)

#askValues relays?

#outputOff relays 0


#interfaceType Relay Relay:2 Relay:3 Relay:4
#interface setRelays relays (value)
#interface getRelays relays?
#interface setRelay relay(value?"on":"off") (channel)
#interface getRelay relay? (channel)
#interface setFrequency PWMFREQ (value)
#interface getFrequency PWMFREQ?
:readFormat: u
#interface setPWM PWM (channel) (value)
#interface getPWM PWM?
:readmath: replace(getElement(value,channel-1),"%","");

; Strings to configure device in different modes
; First parameter must match a #value (4 parameter) and second parameter must match what #askMode returns
; First parameter is also used in shortcut menu
;#cmdMode 

; Setup menu functions
; The parameters on the first line is: type name page 
; Settings on the following lines are:
; read: SCPI to read value from device, is used to synchronize when opening setup page or setting equal named fields. Not always used
; readformat: Parse read value.
; write: Send the value to device, this field is used in combination with data fields in the details to send updates to device.
; tip: Add this tip to all components for this input field.


#cmdSetup indicatornum Out
:read: relay? 1
:updatealloff:
Off 99 red
On 1 Red

#cmdSetup indicatornum Out
:read: relay? 2
:updatealloff:
Off 99 red
On 1 Red

#cmdSetup indicatornum Out
:read: relay? 3
:updatealloff:
Off 99 red
On 1 Red

#cmdSetup indicatornum Out
:read: relay? 4
:updatealloff:
Off 99 Red
On 1 Red


#cmdSetup buttons On
:write: relayOn
:update: Out1 Out2 Out3 Out4 Out PWM_Output_1 PWM_Output_2 PWM_Output_3
On1 1_1
On2 2_1
On3 3_1
On4 4_1

#cmdSetup buttons Off
:write: relayOff
:update: Out1 Out2 Out3 Out4 Out PWM_Output_1 PWM_Output_2 PWM_Output_3
Off1 1_0
Off2 2_0
Off3 3_0
Off4 4_0

#cmdSetup number PWM_Frequency
:read: PWMFREQ?
:write: PWMFREQ
:readFormat: u
Hz 1 100k

#cmdSetup number PWM_Output_1
:read: PWM?
:readmath: replace(getElement(value,0),"%","");
:write: PWM 1 
:update: Out1
% 0 100

#cmdSetup number PWM_Output_2
:read: PWM?
:readmath: replace(getElement(value,1),"%","");
:write: PWM 2
:update: Out2
% 0 100

#cmdSetup number PWM_Output_3
:read: PWM?
:readmath: replace(getElement(value,2),"%","");
:write: PWM 3 
:update: Out3
% 0 100

#cmdSetup Updater update
:update:Out1 Out2 Out3 Out4 Out
0.5
