Hi all, I hope I am in the right thread. I try to explain you what I'd like to do. Sorry for my bad english.
I have 2 Timers and they start and stop (through an event) when a state of a device change. For example it start when a device is on (1-2-3-....) and stop then few seconds when the device is off. Attached the two events.
Through a script I'd like to:
- do an algebric operation (in this case "-") of the two timers
- set the above result into a virtual device
- reset the two timers
What I tried to do with a script is the follow:
Public Sub Main(param As Object)
Dim valore_su As String
Dim valore_giu As String
Dim risultato As String
valore_su = hs.TimerValue("Timer_Tapp_cucina_SU")
valore_giu = hs.TimerValue("Timer_Tapp_cucina_GIU")
risultato = valore_su - valore_giu
hs.SetDeviceValueByRef(515, risultato, TRUE)
hs.TimerReset("Timer_Tapp_cucina_SU")
hs.TimerReset("Timer_Tapp_cucina_GIU")
End Sub
It doesn't work. I also have a lot of doubts like "String" (maybe Double or TimeSpan, even if I tried anyway) and if I have to insert some "hs.WaitSec()".....
Please can anyone help me?
Thanks
Regards
I have 2 Timers and they start and stop (through an event) when a state of a device change. For example it start when a device is on (1-2-3-....) and stop then few seconds when the device is off. Attached the two events.
Through a script I'd like to:
- do an algebric operation (in this case "-") of the two timers
- set the above result into a virtual device
- reset the two timers
What I tried to do with a script is the follow:
Public Sub Main(param As Object)
Dim valore_su As String
Dim valore_giu As String
Dim risultato As String
valore_su = hs.TimerValue("Timer_Tapp_cucina_SU")
valore_giu = hs.TimerValue("Timer_Tapp_cucina_GIU")
risultato = valore_su - valore_giu
hs.SetDeviceValueByRef(515, risultato, TRUE)
hs.TimerReset("Timer_Tapp_cucina_SU")
hs.TimerReset("Timer_Tapp_cucina_GIU")
End Sub
It doesn't work. I also have a lot of doubts like "String" (maybe Double or TimeSpan, even if I tried anyway) and if I have to insert some "hs.WaitSec()".....
Please can anyone help me?
Thanks
Regards
Comment