internal static OpcDaItemValue[] Create(IList<OpcDaItem> items, object[] ppvValues, OpcDaQuality[] ppwQualities,
     DateTimeOffset[] ppftTimeStamps, HRESULT[] ppErrors)
 {
     try
     {
         var result = new OpcDaItemValue[items.Count];
         for (var i = 0; i < ppvValues.Length; i++)
         {
             var tagValue = new OpcDaItemValue
             {
                 Value = ppvValues[i],
                 Quality = ppwQualities[i],
                 Timestamp = ppftTimeStamps[i],
                 Error = ppErrors[i],
                 Item = items[i]
             };
             result[i] = tagValue;
         }
         return result;
     }
     catch (Exception ex)
     {
         Log.Error("Cannot create OpcDaItemValue object.", ex);
         return new OpcDaItemValue[0];
     }
 }
Exemplo n.º 2
0
        public object[] ReadMaxAge(int[] serverHandles, IList<TimeSpan> maxAge, out OpcDaQuality[] qualities,
            out DateTimeOffset[] timestamps, out HRESULT[] errors)
        {
            int[] intMaxAge = ArrayHelpers.CreateMaxAgeArray(maxAge, maxAge.Count);
            object[] ppvValues = {};
            short[] ppwQualities = {};
            FILETIME[] ppftTimeStamps = {};
            HRESULT[] _errors = {};
            DoComCall(ComObject, "IOpcSyncIO2::ReadMaxAge", () =>
                    ComObject.ReadMaxAge(serverHandles.Length, serverHandles, intMaxAge, out ppvValues, out ppwQualities,
                        out ppftTimeStamps, out _errors), serverHandles.Length,
                serverHandles, intMaxAge);
            timestamps = new DateTimeOffset[ppftTimeStamps.Length];
            qualities = new OpcDaQuality[ppwQualities.Length];

            for (int i = 0; i < timestamps.Length; i++)
            {
                timestamps[i] = FileTimeConverter.FromFileTime(ppftTimeStamps[i]);
                qualities[i] = new OpcDaQuality(ppwQualities[i]);
            }
            errors = _errors;
            return ppvValues;
        }
Exemplo n.º 3
0
        public object[] ReadMaxAge(int[] serverHandles, IList <TimeSpan> maxAge, out OpcDaQuality[] qualities,
                                   out DateTimeOffset[] timestamps, out HRESULT[] errors)
        {
            int[]      intMaxAge      = ArrayHelpers.CreateMaxAgeArray(maxAge, maxAge.Count);
            object[]   ppvValues      = {};
            short[]    ppwQualities   = {};
            FILETIME[] ppftTimeStamps = {};
            HRESULT[]  _errors        = {};
            DoComCall(ComObject, "IOpcSyncIO2::ReadMaxAge", () =>
                      ComObject.ReadMaxAge(serverHandles.Length, serverHandles, intMaxAge, out ppvValues, out ppwQualities,
                                           out ppftTimeStamps, out _errors), serverHandles.Length,
                      serverHandles, intMaxAge);
            timestamps = new DateTimeOffset[ppftTimeStamps.Length];
            qualities  = new OpcDaQuality[ppwQualities.Length];

            for (int i = 0; i < timestamps.Length; i++)
            {
                timestamps[i] = FileTimeConverter.FromFileTime(ppftTimeStamps[i]);
                qualities[i]  = new OpcDaQuality(ppwQualities[i]);
            }
            errors = _errors;
            return(ppvValues);
        }