Skip to content
Menu
Menu

Knowledge Base

KB050005 | FILE OUTPUT WHEN A DATA POINT VALUE CHANGES

KB050005 | FILE OUTPUT WHEN A DATA POINT VALUE CHANGES

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.

Support Area

KB050005 | FILE OUTPUT WHEN A DATA POINT VALUE CHANGES

Knowledge Base

Here you will find answers, solutions to problems and examples of our products.
KB050005 | FILE OUTPUT WHEN A DATA POINT VALUE CHANGES

Case Studies

Successful in use: practical examples of our products and individual developments.
KB050005 | FILE OUTPUT WHEN A DATA POINT VALUE CHANGES

Support

Describe your concern using our support form.
KB050005 | FILE OUTPUT WHEN A DATA POINT VALUE CHANGES

License registration

Register your Elvis license!

IT GmbH · An der Kaufleite 12 · D-90562 Kalchreuth

© Copyright 2024. IT GmbH | Webdesign by Appear Online