KB-57412: Demo application – Hourly programming to turn the device on/off from a day of the week.

Overview:

This demo application demonstrates the necessary procedures to create an hourly programming considering the day of the week from the current date, and then executing commands to change/write values in the tags referring to the device.

Operation:

Inside the Viewer there is a User Event whose function is to check the day of the week (Thursday, Friday, etc) from the date in the PC where the application is being executed. For this, use a Demo tag and set up the event to happen Always when property/expression changes its value:

 

 

In the event’s script, the application uses an IF command to check the value returned by Weekday method, inserting then the values referring to the hourly programming (initial and final times) so that the tag’s value is altered:

Dim data, initialtime, finaltime, final, final2
‘Check if it is Sunday
IF Weekday(Item(“DateTime”).Value) = 1 Then
data = DateValue(now)
initialtime = “12:00:00”
finaltime = “12:01:00”
final = data&” “& initialtime
Application.GetObject(“Data.TurnDeviceOn”).StartTime = final
final2 = data&” “&horafinal
Application.GetObject(“Data.TurnDeviceOff”).StartTime = final2
End If

Finally, the Timer tag’s OnPreset event contains the command scripts to change the tag’s value regarding the device. Example:

Sub TurnDeviceOn_OnPreset()
Parent.Item(“Device”).Value = TRUE
End Sub

NOTE: the demo application attached to this article was developed with Elipse E3 v4.0 build 225.

Attachments:

Sample.zip

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *