Create a tags report and send it by mail
The purpose of this document is to give an example of how to create a report and send it by mail. The report will contain current tags values and will be generated in text and html formats.
Tags name creation
Create the 3 analog tags below, whatever the eWON IO Server they belong to:
- –VesselPressure
- –VesselTemperature
- –VesselLevel
- Create a fourth tag called HourInfo as an analog EWON tag.
Files creation
We will now create the files which will be used for the report. To insert the current value of the Tag into the report we will use the TagSSI syntax. The SSI stands for Server Side Include; this method is used for creating web sites in which the server updates parts of the HTML page. For further explications please refer to the eWON Web Reference Guide (RG-003-0-EN). All he have to know for our example here is that we have to use following syntax to include the value of a tag inside of the report: <%#TagSSI,TagName%> When eWON then sends out the report by eMail or FTP, eWON will parse the file and replace the <%#TagSSI,TagName%> with the current value of the Tag called "Tagname".
Text file
Create a text file called VesselData.txt with the following content and place this file under the /usr folder of the eWON (using FTP) :
Values of the vessel sensors at <%#TagSSI,HourInfo%> Vessel Temperature : <%#TagSSI,VesselTemperature%> °C Vessel Pressure : <%#TagSSI,VesselPressure%> bar Vessel Level : <%#TagSSI,VesselLevel%> L
HTML file
Create a HTML file called VesselData.html, with the following content and place this file under the /usr folder of the eWON (using FTP):
<html doctype="html"> <head> <meta charset="UTF-8" /> </head> <body> <p><strong>Values of the vessel sensors at <%#TagSSI,HourInfo%></strong></p> <p>Vessel Temperature : <%#TagSSI,VesselTemperature%> °C</p> <p>Vessel Pressure : <%#TagSSI,VesselPressure%> bar</p> <p>Vessel Level : <%#TagSSI,VesselLevel%> L</p> </body> </html>
Script
In the Init section:
REM Activation of Timer 1 executed each 60 seconds TSET 1,60 REM Trigger of the GetTime section ONTIMER 1, "Goto GetTime" END
In the User section:
GetTime: A$ = TIME$ REM Get the day of the week a% = DOW A$ REM Get the hour value b% = VAL(A$(12 TO 13)) REM Get the minute value c% = VAL(A$(15 TO 16)) REM Check if action must be done REM Check Day of the week IF ((a% > 0) AND (a% < 6)) THEN REM Check hour of the day IF ((b% >= 8) AND (b% <= 17)) THEN REM Check minute of the hour IF (c% = 0) THEN HourInfo = b% Goto SendVesselData ENDIF ENDIF ENDIF END SendVesselData: REM Send mail with text file in attachment Sendmail "test@test.com", "", "Vessel Sensors Values", "&[$dtUF $fnVesselData.txt]" REM Send mail with html file in attachment Sendmail "test@test.com", "", "Vessel Sensors Values", "&[$dtUF $fnVesselData.html]" END