Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Geo SCADA Knowledge Base
Access vast amounts of technical know-how and pro tips from our community of Geo SCADA experts.
Link copied. Please paste this link to share this article on your social media post.
Originally published on Geo SCADA Knowledge Base by Anonymous user | June 09, 2021 11:58 PM
PROGRAM HistoricDemoVAR (* The order of these variables is important, ensure that the time and qualities variables are defined BEFORE the actual value as when the program exits, they are written to in the order they are defined here. They can be used in any order in the code however. *) (* These two have to be %Q / write-only variables *) AnalogTime AT %Q(.Analog.PresetTimestamp) : DATE_AND_TIME; AnalogQuality AT %Q(.Analog.PresetQuality) : INT; (* This can be of any declaration type *) Analog AT %M(.Analog.CurrentValue) : INT;END_VAR(* Use RETAIN keyword so different value written each execution *)VAR RETAIN Count : INT;END_VAR (* Calculate a new time (e.g. 14 days prior to current) *) AnalogTime := SUB_DT_TIME(NOW(),MAKE_TIME(14,0,0,0,0)); (* Set quality: 0 is Bad, 192 is Good *) AnalogQuality := 192; (* Change Count's value for the next time this program is run *) Count := Count + 1; IF (Count > 100) THEN Count := 0; END_IF; (* Set value to a changing integer *) Analog := Count;END_PROGRAM
Link copied. Please paste this link to share this article on your social media post.
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.