Execute actions at specific times
The following BASIC code show an short example on how the eWON can execute actions / tasks on a defined time frame.
For this example, each hour + 0 minute and each hour + 30 minutes, a mail will be sent with the value of a temperature tag.
This email must be sent only during working days (monday to friday) and during office hours ( 08h00 → 17h30 ).
REM Activation of Timer 1 executed each 60 seconds TSET 1,60 REM Trigger of the GetTime section ONTIMER 1, "Goto GetTime" END
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) OR (c% = 30)) THEN Goto TimeAction ENDIF ENDIF ENDIF END
TimeAction: REM Convert analog value into a string B$ = STR$ VesselTemp@ B$ = “The vessel temperature value is: “ + B$ + “°C” Sendmail "ewon@actl.be", "", "Vessel Temperature", B$ END