3 Replies Latest reply on Sep 13, 2013 3:20 PM by michaelh

    Need help in ACE Code

    sricharan.m

      Dear Experts,

       

      I’m framing ACE code for the below logic.

       

      2630.codde.PNG

       

      I will explain in more detail..We have tag say sinusoid, it has data for past 24 hours. it also has a high limit say 50..if the value of sinusoid crosses high limit then we will check for the next value when it is within the limit.

       

      So far I’m here

       
              Dim PIVALS As PISDK.PIValues
              Dim PIVAL As PISDK.PIValue
              PIVALS = sinusoid.Values("*-24h", "*")
              For Each PIVAL In PIVALS
                  If PIVAL.Value > 50 Then
      
                  End If
              Next
      

      So 1st loop is complete now 2nd part where I need to check when it comes back to within limit so need to run a loop again but not able to code it. 

       

      In the case below, need to capture timestamp of index 2 (crosses high limit) and index 4 (within limit) so that time difference could be calculated and we could find the total time and number of deviation.

       

      5756.table.PNG

       

      Looking forward for your valuable inputs.

        • Re: Need help in ACE Code
          michaelh

          Instead of a direct solution :

           

          Why do you need to do it only daily after the fact ?

           

          It's easy to run this event driven:

           

          - Use a static ( global ) variable (LimitTime) : time when limit was hit. Use it also to know this was marked already.
          -    If (value > limit && LimitTime == 0)  set LimitTime = now; 
               If (value < limit && LimitTime != 0 )  { calculate LimitTimeSpan; set LimitTime = 0; }

           

          Perhaps I just did not get the problem, but sometimes it helps to step back a bit from the previous approach.

           

          BTW: Does the TimeGT method help you to calculate LimitTimeSpan ?  
                     ( It does all the interpolation between events for you ) 

                     And you can easily experiment with that function using PE and pi\adm\pipetest.exe

           

           

           

          P.S. Sorry for my c syntax even in pseudo code:   && means AND ,   != means NOT EQUAL,  a semicolon means NEWLINE   ;)