This is an old revision of the document!
Storing Event and Report values to a file in TransSECS Devices
Whenever an Event is received the script associated with that event is called.
When an event is received, the value of the incoming variable (incoming value) is a JSON representation of the event, including all reports and values. For example, the script shown may print something like:
<JavaScript> Report Received { “COMPLETED”: [ { “RPTID0”: [ {“CLOCK”:“2024032014462593”, “type”:20 },{“GasFlow”:“1.883”, “type”:44 },{“LOTID”:“”, “type”:20 } ], “rptid”:100} ], “ceid”:7502, “timestamp”:“2024-03-20 14:46:25.955”} </JavaScript>
Similarly, when a Report is received a script is called on the report. This will be called if the report is part of any event or requested manually.
The value here is slightly different. The value itself is the report Id, for example, 100. The data associated with the report is retrieved by calling
var map = incomingValue.getProperty("MAP");
You can get string representation of the map with
var mapString = map.toString();
If you print that string you might get something like:
<JavaScript> {CLOCK=2024032015172190, GasFlow=1.955, LOTID=, CEID=7502, EventName=COMPLETED} </JavaScript>
We can save either the Event JSON or the map to a file, appending a line as each new value is received. If we want to save the event, then our string is:
var stringToSave = incomingValue.getStringValue();
and the script