Automatically log Tags when setup as historical tags

We have in our Ewons a generic script for sending alarm rep-mail (everyday @9), an automatically loop of all our tags set as alarms…

b% = Getsys Prg, "NBTAGS"
b% = b% - 1	REM index goes from 0 to NBTAGS-1
For i%=0 To b% 
 ONALARM -i%, "GOSUB SmsAlarm" 

Next i%

this works well…

The only not generic about the script is about logging every (historical) tag every minute…

HistTriggerRap:
 LOGIO "LOG_LIT_B01"
 LOGIO "LOG_LIT_B05"
 LOGIO "LOG_LIT_B06"
 ...

END

is there a way to find out if the tag is a historical one so I could work like in the alarm script part through all of the tags (with the for -loop again), and if so, “LOGIO Index%” at that time… instead, for every project list manually all of the historical data in the function…

br,
Peter

Hi Peter,

Historical logging info for a tag can be checked either through the tag setup section of the flexy or the var_lst.csv file hosted on the device.

In the var_lst, you’ll want to check the Log_Enabled column and make sure it’s set to 1 so that it’s a tag that allows historical logging. You’ll also want to make sure that the deadband, (LogDB) is set to -1 and that the Time Interval (LogTimer) is set to 0 if you want to do this only through scripting.

Hi Tim,

thx for the quick reply! the settings were already in place, so far so good… :slight_smile:
i was thinking in code something like this.

ONDATE 1,"* * * * *",“GOTO HistTriggerRap”

HistTriggerRap:

b% = Getsys Prg, “NBTAGS”
b% = b% - 1 REM index goes from 0 to NBTAGS-1
For i%=0 To b%
SETSYS TAG,“LOAD”,-i%
$bLog= GETSYS TAG,“logEnabled”
if ($bLog) then
LOGIO -i%
ENDIF
Next i%
END

But I get an error "Invalid assignment (22) 47: $blog= getsys Tag,“logEnabled”

any tips of what I’m doing wrong?

BR,
Peter

Hey Peter,

Try something like this:

HistTriggerRap:

b% = Getsys Prg, “NBTAGS”
b% = b% - 1 REM index goes from 0 to NBTAGS-1
For i%=0 To b%
SETSYS TAG,“LOAD”,-i%
A$ = GETSYS TAG,“logEnabled”
If VAL A$ = 1 Then
print “logging”
LOGIO -i%
ENDIF
Next i%
END

Hi Tim,

the solution you provided worked out perfectly! :ok_hand:

adjusted the code a bit, so the code is more readable :slight_smile:

HistTriggerRap:

b% = Getsys Prg, “NBTAGS”
For i%=b%-1 To 0 STEP -1
SETSYS TAG,“LOAD”,-i%
bLog$= GETSYS TAG,“logEnabled”
If VAL bLog$ = 1 Then
LOGIO -i%
ENDIF
Next i%
END

1 Like

Hi Peter,

Glad we could get the code working!

-Tim