Tags in error notification email

Hello eWON Support,

I would like to get an email notification if any of my tags stop reading. How would I go about determining whether my tag quality is good or if communication has dropped to a PLC using the BASIC IDE in the Flexy?

Thanks in advance!

Hi Rick,

You can check the quality of a tag using BASIC and then if the quality of the tag is below 32 then it means it’s in a ‘bad state.’

Here’s a script that I wrote that checks each tag for its quality value every hour then sends 1 email out that includes all the tags that are currently in error. This script will need to be pasted into the INIT section of your basic IDE, and you’ll have to edit the Tofield$ or CC field to fit your needs.

Init section:
    C% = GETSYS PRG, "NBTAGS" // load tag amount
    tags$ = ""
    counter% = 0
    TSET 1,3600 // timer for every hour to check tags, configurable
    ONTIMER 1, "goto CheckTagErrors"

    // Configure your email settings
    tofield$ = "test1@gmail.com,test2@yahoo.com" // Example, Enter in your to field emails here 
    cc$ = "" // cc field empty
END

CheckTagErrors:
    FOR C% = 0 TO (C%-1)
        SETSYS Tag, "load", -C%
        t$ = GETSYS Tag, "TagQuality"
        name$ = GETSYS Tag, "Name"
        v% = FCNV t$, 30, 0, "%d"
        If (v% < 32) THEN
            tags$ = tags$ + " " + name$
            counter% = counter% + 1
        ENDIF
    NEXT C% 
    IF (counter% <> 0) THEN
         subject$ = str$(counter%) + " tag(s) are in error at " + time$
         body$ = "The tags in error are: " + tags$
         SENDMAIL tofield$,cc$,subject$,body$ 
         print "Sending tag error notification email"
         tags$ = ""
         counter% = 0
   ENDIF
END
1 Like