0

Calcs and Events - Latch value

I have a complex event trigger that I am having difficulty programming. I have a trigger that when the length has been reset (Previous length > current length - which we'll call A) and then the length is greater than 200 (where now the Previous length will not be > than current length). Is there a way to latch the first constraint to True when it becomes true (A)  in order to use an and A with the second constraint?

 

so something like 

A = if(PreviousValue('Length') or A, True, False) (But we can't use A where it is defined)

B = A and (Length > 200)

5 replies

null
    • smason
    • 2 days ago
    • Reported - view

    Hi ,

    I'm having difficulty understanding what you're trying to accomplish. Could you provide some more detail or context?

    • erice
    • 2 days ago
    • Reported - view

    Thanks Steve

    I'll try to be more specific. I have an event I would like to capture that requires:

    1) The length to be reset - PreviousValue('Length') > Length

    2) The Length needs to be greater than 200

    3) Then when (1) and (2) are true I want to be able to create an event if another tag goes out of a calculated range.

     

    (1) and (2) may not all be true at the same time, so I need the ability to hold a variable True when (1) happens, then (2) and (3) will always be True at the same time (if (3) happens at all). So my problem is being able to hold a value True even after PreviousValue('Length') > Length is no longer True.

     

    I hope that helps make it a little more clear.

      • smason
      • yesterday
      • Reported - view

      Thanks for the clarification. I think I understand now, but I don't know if we have a way to handle this. Does the resetting of the Length happen at a set interval or set time of day?

      If you had a Boolean tag that was set to True whenever the PreviousValue>CurrentValue, then used CountInStateNonZero when it exceeded 200, could you look back over a set amount of time to see if the Count = 1?

      Scratching my head on this one. 🤔

      • erice
      • 9 hrs ago
      • Reported - view

       Thanks. I figured I may have to create another tag for this purpose. I was hoping to avoid that. To answer your question though - no the length reset can happen anytime during the day. 

      • smason
      • 8 hrs ago
      • Reported - view

      Ok. You'll have to have a flag for the initial reset when the PreviousValue > CurrentValue. I can't think of a way to refer back to an "old" True state. Steps 1 and 2 from your previous message would have to be True at the same time. The tricky part might be determining when to reset Step 1 back to False. I thought if there was a predictable schedule of when this occurs, you could just do it based on a periodic calculation.

Content aside

print this pagePrint this page
  • 8 hrs agoLast active
  • 5Replies
  • 15Views
  • 2 Following