9 Replies Latest reply on Mar 17, 2010 7:03 PM by njacobs

    Output Tag Timestamp in c#

    wpurrer

      How do i specify the output Tag Timestamp in c# ?

        • Re: Output Tag Timestamp in c#
          Asle Frantzen

          From the manual:

           

          Output Tag Timestamp

           

          By default, the timestamp for an output tag equals to the scheduled execution time (i.e., the
          time when the calculation is supposed to be evaluated, not when the calculation is actually
          carried out). Users can choose any timestamp for the output tag by simply specifying the
          desired timestamp when setting its value (e.g., OUTPUTTAG.Value(Now) =
          INPUTTAG.Value).

           

           

            • Re: Output Tag Timestamp in c#
              wpurrer

              I know, i read this .... but i repeat the question how it is in csharp.

               

               

               

              => in csharp  the .value is a type of object...

                • Re: Output Tag Timestamp in c#
                  michaelh

                  Have you tried a PITimeServer.PITime, System.DateTime, Double (like Exetime) , String (in PI Time format ) ?

                   

                  They should all work fine, and that's why it's just an Object  ( in vb.net as well, btw. )

                   

                  I don't see your problem applying vb.net information for objects to a C# environment ?

                   

                   

                    • Re: Output Tag Timestamp in c#
                      wpurrer

                      Sorry maybe i forgot to mention the error message

                       

                      Error    1    Non-invocable member 'OSIsoft.PI.ACE.PIACEPoint.Value' cannot be used like a method.    C:\Program Files (x86)\PIPC\ACE\ClassLibraries\Zeitstempeln\Class1.cs    21    25    Zeitstempeln

                       

                      The code looks like

                      using System;
                      using System.Collections.Generic;
                      using System.Linq;
                      using System.Text;
                      using OSIsoft.PI.ACE;

                      namespace PIACE.Zeitstempeln
                      {
                          public class CZeitstempeln: PIACENetClassModule
                          {
                              PIACEPoint Input_Wert;
                              PIACEPoint Input_Zeit;
                              PIACEPoint Output_Wert;

                              public override void ACECalculations()
                              {
                                  DateTime zeit = new DateTime(1970, 01, 01).AddSeconds((int)Input_Zeit.Value);

                                  Output_Wert.Value(zeit) = Input_Wert;
                              }

                              protected override void InitializePIACEPoints()
                              {
                                  Input_Wert = GetPIACEPoint("Input_Wert");
                                  Input_Zeit = GetPIACEPoint("Input_Zeit");
                                  Output_Wert = GetPIACEPoint("Output_Wert");
                              }

                              protected override void ModuleDependentTermination()
                              {

                              }
                          }
                      }

                        • Re: Output Tag Timestamp in c#
                          Asle Frantzen

                          I think you might be right!

                           

                          Looking at the metadata definition of PIACEPoint, "Value" is defined as a propery - when using this in C#.

                           

                          If I look at the Object Explorer when I have a VB.NET ACE project open, it seems that "Value" is defined once with no parameters, and once with a parameter of type 'object'.

                           

                           

                           

                          How bout trying the PIACEPoint.set_Value(object time, object Value) ?

                            • Re: Output Tag Timestamp in c#
                              wpurrer

                              Thank you!

                               

                               

                               

                               Output_Wert.set_Value(zeit, Input_Wert.Value);

                               

                              Works!

                                • Re: Output Tag Timestamp in c#
                                  Asle Frantzen

                                  No problem!

                                   

                                  But while this seems to solve YOUR problems right now, I would be interested in knowing why this seems to be implemented so that Value has two definitions as a function when using VB.NET - and only one definition as a propery when using C#.

                                   

                                  I'm reading from the same dll-file.

                                   

                                   

                                   

                                   

                                  • Re: Output Tag Timestamp in c#

                                    A quick look at the Object Browser tells us that in C#, there is only 1 version of the Value property exposed, with no parameter. In VB.NET, there is a Value and a Value(time) exposed. It looks like in C# you'll have to use get_Value(time) and set_Value(time, value) methods instead...

                                     

                                    100301_2D00_ACEinVBvsCSharp.jpg

                                     

                                    Very good catch! I'll investigate this further add a note to the "Writing PI ACE Calculations in C#" white paper.

                                     

                                    Thanks!

                                      • Re: Output Tag Timestamp in c#
                                        njacobs

                                        The difference is that VB supports optional arguments, but C# (at least in versions prior to Visual Studio 2010) does not. The PIACEPoint value property has the timestamp as an optional parameter:

                                         

                                        Public Property Get Value(Optional varTime)

                                         

                                        C# in VS 2010 apparently supports optional and named arguments; however it isn't clear how this works with respect to PIACEPoint.value. I expect that for now, you'll need a VB.net stub that provides explicit overrides to the underlying COM interface.