Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variable Error in Scheduled Task
#1
I have a scheduled task that has been running for a long time that is now generating errors.  NOt sure when they started appearing, but I did upgrade last week and thats when I first noticed it when looking at the logs.

Below is the tasks (simplified) and it generates an error on the last line in the subtract statement

Devices::FieldRead

    P1=PowerPLC.$UnknownMsg
    P2=LVar:PLCErrorNow
    P3=False

Devices::FieldRead
    P1=Var1.PLCErrorPrevious
    P2=LVar:PLCErrorPrevious
    P3=False

LocalVars::Subtract
    P1=LVar:PLCErrorNow
    P2=%(LVar:PLCErrorPrevious)

Devices::FieldWrite
    P1=Var1.PLCErrorPrevious
    P2=$(PowerPLC.$UnknownMsg)
    P3=False

Output from test window


----------------------------------------------------------


TRC: Start Action
Global Vars=
----------------------------------------------------------
TRC: Start Action

Global Vars=

CMD: 001.  (1ms) - Devices::FieldRead
    P1=PowerPLC.$UnknownMsg
    P2=LVar:PLCErrorNow
    P3=False


CMD: 002.  (1245ms) - Devices::FieldRead
    P1=Var1.PLCErrorPrevious
    P2=LVar:PLCErrorPrevious
    P3=False

VAR: Set variable 'LVar:PLCErrorPrevious'
       =6834

CMD: 003.  (9ms) - LocalVars::Subtract
    P1=LVar:PLCErrorNow
    P2=6834

TRC: End Action [Result=Failure]

Error information

Variable LVar:PLCErrorNow was not found

I cant find anything wrong with this that would cause the error (WIll probably find it about 5 minutes after posting though).

Any one with an eagle eye spot the error.....
Mykel Koblenz
Illawarra Smart Home
Reply
#2
The most likely scenario is that the first read is failing. Since the last parameter is false, that tells it not to generate an error, but you aren't checking the return value. So it would just silently fail and the output variable would never get created.

So you should probably put it in an If/Else and log something in the Else that the PLC error state couldn't be read.
Dean Roddey
Explorans limites defectum
Reply
#3
I found the issue - you were right. THe variable was not being created because of the failure to read the field.

I am pretty sure that I tested all this when I wrote it - yet the field has changed from $UnknownMsg to $UnknownMsgs.

Is there any chance you changed the field names somewhere along the way?
Mykel Koblenz
Illawarra Smart Home
Reply
#4
Yeh, it was changed at some point. I think it was sort of by accident, though it is more correct to be plural. By the time I realized it it had been quite a while so I didn't want to change it back and possibly make things worse.

Sorry about that.
Dean Roddey
Explorans limites defectum
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Question on Socket Error kblagron 4 150 04-07-2019, 09:19 PM
Last Post: kblagron
  Sonos Update Error (Again) karenlee 39 3,278 12-04-2018, 10:15 PM
Last Post: Dean Roddey
  Question on Formatting of Variable Text kblagron 2 900 09-07-2018, 08:52 PM
Last Post: kblagron
Question Boolean image is in error state ghurty 4 1,055 05-24-2018, 09:04 PM
Last Post: ghurty
  How would I manually collect digits to enter into a variable ghurty 1 544 05-24-2018, 08:51 PM
Last Post: Dean Roddey
  usb-uirt error indygreg 1 547 05-12-2018, 06:57 PM
Last Post: Dean Roddey
  Embedded Variable in Text zra 2 822 05-07-2018, 09:59 AM
Last Post: zra
  Variable Limits Syntax Shaky 6 1,418 03-03-2018, 09:47 PM
Last Post: Dean Roddey
  "CQCData" Locked Error jokermac 7 3,135 01-14-2018, 11:35 AM
Last Post: Dean Roddey
  Scheduled Events? jkmonroe 9 2,013 01-06-2018, 09:08 AM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)