5 Replies Latest reply on Nov 6, 2012 8:20 PM by Babar

    Writing to Windows Event Viewer from ACE Calculations


      I am trying to write to windows event viewer from my ACE calculations. It works fine when I set the scheduling to Clock but does not work when set to natural.


      I am wondering if thee is a known issue with natural scheduling.


      Thank you,



        • Re: Writing to Windows Event Viewer from ACE Calculations

          Hi Babar,


          Natural and Clock scheduling setting should only affect how the calculation is triggered, that tasks that is performed in the Calculation method of the ACE module should be the same. as long as the calculation is triggered properly.


          Are there any other output from the ACE calculation other then to windows event log? We can probably use it to verify if the calculation is executed and isolate the problem to output to windows event log. If there isn't any other output, you can probably try to insert some log statements into the calculation (which will be written to the PI Message Log on the PI ACE scheduler machine). That should again give you more information to work with. Method that will do that is LogPIACEMessage().


          These will help us try to find out what is going on in the scheduler and give us more information to work on the issue.

            • Re: Writing to Windows Event Viewer from ACE Calculations
              Asle Frantzen

              For more information on logging capabilities in ACE, see Gregor's blog post: vcampus.osisoft.com/.../logging-capabilities-in-pi-ace.aspx

              • Re: Writing to Windows Event Viewer from ACE Calculations



                There are 2 output tags tags and they get updated regularly. The calculations write to event log when set to clock. As soon as I switch the mode to natural, there is no entry in the event log. Initially I was trying to write performance counter values, calculation exetime, name in one string. Currently, I am just trying to write to a simple string for testing purpose.

                  • Re: Writing to Windows Event Viewer from ACE Calculations

                    Hello Babar,


                    Can you please try if the following works for you:


                    1. Create a PI tag of type string with name "ACE_Debug_String"


                    2. Create a new ACE calculation using PI ACE Wizard with


                    Inputs: SINUSOID and CDT158


                    Output: ACE_Debug_String


                    3. After ACE Wizard has created the Visual Studio project, please add a reference to OSIsoft.PITimeServer. Modify the list of Imports so it looks as follows:

                    Imports OSIsoft.PI.ACE
                    Imports OSIsoft.PI.ACE.PIACEBIFunctions
                    Imports OSIsoft.PI.ACE.MessageLevel
                    Imports PITimeServer
                    Imports System.Diagnostics

                    4. Implement the following ACE code:

                        Public Overrides Sub ACECalculations()
                                ' Declaration
                                Dim sDebug As String
                                Dim exTime As New PITime
                                Dim eLog As New EventLog("MyACE", ".", "With Regards from ACE")
                                ' Generate some result string
                                exTime.UTCSeconds = ExeTime
                                sDebug = exTime.LocalDate.ToString() & ": "
                                If sinusoid.IsTrigger Then
                                    sDebug = sDebug & "SINUSOID: " & sinusoid.Value.ToString()
                                ElseIf cdt158.IsTrigger Then
                                    sDebug = sDebug & "CDT158: " & cdt158.Value.ToString()
                                    sDebug = sDebug & "We should never get here if the calculation is set up with natural schedule."
                                End If
                                ' Writing to the PI Message Log
                                LogPIACEMessage(mlUserMessage, sDebug, Me.Name)
                                ' Writing to the Windows Event Log
                                ' Writing to the Debug PI tag
                                ACE_Debug_String.Value = sDebug
                            Catch ex As Exception
                                LogPIACEMessage(mlErrors, ex.Message, Me.Name)
                            End Try
                        End Sub

                    5. Test the Module using PI ACE Wizard


                    6. Register the Module using PI ACE Wizard


                    7. Open a command prompt to continuously monitor the PI Message Log:


                    execute cd /d %pihome% to change to the PIHOME folder


                    execute cd adm to change to the adm subfolder


                    execute pigetmsg -f


                    8. Enable user messages using PI ACE Manager:


                    - launch PI ACE Manager (if it is not already running)


                    - locate the new ACE Library and click the [+] to make below structure visible. Click the [+] in front of the new Module. Click the [+] in front of Contexts and right click the Context. From the Menu select "Message Log Level ...", check the Checkbox in front of "User Messages" and confirm the choice by clicking [Ok].


                    Within 2 minutes you should see messages like the following one in the command prompt running pigetmsg:


                    I 06-Nov-12 12:53:42 PIACEClassLibraryHost
                     >> NEMESIS\vcEventLog\vcEventLogClass\NEMESIS: 11/6/2012 12:53:25 PM: CDT158: 212.5148


                    9. Check for Event Log entries with Windows Event Viewer. Please note that the name of the custom log is "MyACE".


                    10. Use ProcessBook, DataLink or PI-SMT to check for values of PI tag "ACE_Debug_String"


                    Please let us know how it goes.