4 Replies Latest reply on Nov 17, 2011 4:54 PM by michaelh

    Can you change time stamp written when Calc Fails?

    ccheno

      I have some monthly environment calc's that the HSE folks wanted time stamped at the beginning of the month the calc if for (ie: Total data from 1-Oct-11 thru 1-Nov-11 and output the result with a time stamp of: 1-Oct-11 00:00:00).

       

      What I'd like to be able to do, is if/when the calc fails, to write "Calc Failed" at 1-Oct-11 00:00:00 rather than at run time 1-Nov-11 00:00:00 (default behavior).

       

      I've figured out the syntax for first-of-previous-month that I use when writing "good" calc output:  OutputTotal.value(PrevMonDay1). So I have a variable to pass. Just don't know how.

       

      Can this be done? If yes, could you please provide example code of how to do it.

       

      Thanks, Cory

        • Re: Can you change time stamp written when Calc Fails?
          michaelh

          You have to avoid a Failing Calculation

           

          If needed, your code can write a System State at a desired timestamp. If it's not a String tag,

           

               MyPIACEPoint.Value(MyTime) = "Error"  ' or "Calc Failed" if you prefer

           

          should work as desired.

           

          - If it's a String tag, it won't turn into a System DigitalState

           

          - System Management Tool shows you the list of all available System states

            • Re: Can you change time stamp written when Calc Fails?
              ccheno

              Thanks Michael for the reply. I should have noted that I'm new to .NET programming. So where/how would I code that.

               

              My is basically an IF THEN ELSE. IF 1st of the month, then calc & output result, ELSE no output. HOw do I trap for calculation failure to code MyPIACEPoint.Value(MyTime) = "Calc Failed".

                • Re: Can you change time stamp written when Calc Fails?
                  ccheno

                  I figured out how to do this. Added FINALLY to my TRY CATCH. It seems to work. If anyone has a better solution, please let me know.

                   
                  TRY
                  
                       'calc code
                  
                  CATCH 
                  
                      'error message
                  
                  FINALLY 
                  
                      OutputTag.Value(TimeStamp) = "Calc Failed"
                  
                  END TRY
                  

                   

                    • Re: Can you change time stamp written when Calc Fails?
                      michaelh

                      Cory Chenoweth

                      If anyone has a better solution, please let me know.

                       

                      I'd rather

                       
                      Dim Timestamp as Double = FirstOfPrevMonth.UTCSeconds
                      Try
                        Dim result As Double = calculation( )
                        Outputtag.Value(Timestamp) = result
                      Catch
                         error message
                        Outputtag.Value(Timestamp) = "Calc Failed"
                      End Try
                      

                      If you have problems calculating the correct timestamp or if

                       
                      Outputtag.Value(Timestamp) = "Calc Failed"
                      

                      should fail, well then you're lost anyway ;)


                       

                      Sorry for my bad formatting in response 1. fixed now.
                      You know how to do a No Output in PIACE, don't you ?

                       

                      If not, this might well be the reason why you're struggling with Calc Failed at all.
                      Not writing anything to Outputtag.Value is not the solution ...
                      Rather set Outputag.SendDataToPI = False

                       

                       

                       

                       

                      P.S. Initializing the PITime variable   FirstOfPrevMonth correctly, is an exercise for the reader