Product: | Elvis |
Version: | all |
Booth: | 2002-07-25 |
Summary
To output individual messages or values, this data can be saved to a file in the global script. In the example, the data point named ‘Alarm’ stores the alarm status and the alarm value whenever the alarm status changes. Of course, there are many possibilities for variation of the program here. To print the data, see KB050011.
Details
In the following example, message texts are generated when an alarm data point changes to the state “alarm”, “no alarm” or “alarm acknowledged”. The texts are saved in a file. In the example, the file name is stored in the current value of the data point named sFile. However, the file name can also be entered permanently in the program. In order for everything to work, these points must be followed:
1. Insert this program into the global script (download script):
Sub OnDatapointChanged(ByVal DP As Object, ByVal prop As String)
If prop = “AlarmState” Then
Dim File Number As Integer
File Number = FreeFile
Open Database.Datapoint(“sFile”). ActualValue For Append As #Dateinummer
If DP. AlarmState = Asc(“N”) Then ‘no Alarm
Print #Dateinummer, “no alarm:” & DP.Name & “value: ” & DP. ActualValue
ElseIf DP. AlarmState = Asc(“A”) Then ‘Alarm
Print #Dateinummer, “Alarm: ” & DP.Name & ” Value: ” & DP. ActualValue
ElseIf DP. AlarmState = Asc(“Q”) Then ‘Quit Alarm
Print #Dateinummer, “Alarm acknowledged: ” & DP.Name & ” Value: ” & DP. ActualValue
End If
If File Number Then Close #Dateinummer
End If
End Sub
Note: All programs in the global script are executed by the Elvis server. In the global script, the OnDatapointChanged subroutine can only be defined once. In other words, do all the actions required there within the subroutine or create and call them as a separate subroutine.
2. Create the data point for the file name: Name = “sFile”; Type = “Text”; DP group = <put> somehow; Location = “c:\program files\elvis\prtq\alarm.txt”
Here I have specified a special subdirectory, the role of which is explained under KB050011 .
3. Of course, there must be at least one alarm data point.