Exemplo n.º 1
0
        public bool Read(OPCDataSource p_Src, int[] p_ArrHSrv, out OPCItemState[] p_ArrStat)
        {
            p_ArrStat = null;
            int    l_Count = p_ArrHSrv.Length;
            IntPtr l_PtrStat;
            IntPtr l_PtrErr;

            int l_HResult = m_IfSync.Read(p_Src, l_Count, p_ArrHSrv, out l_PtrStat, out l_PtrErr);

            if (HResults.Failed(l_HResult))
            {
                Marshal.ThrowExceptionForHR(l_HResult);
            }

            int l_RunErr  = (int)l_PtrErr;
            int l_RunStat = (int)l_PtrStat;

            if ((l_RunErr == 0) || (l_RunStat == 0))
            {
                Marshal.ThrowExceptionForHR(HResults.E_ABORT);
            }

            p_ArrStat = new OPCItemState[l_Count];

            for (int i = 0; i < l_Count; ++i)
            {
                p_ArrStat[i] = new OPCItemState();

                p_ArrStat[i].Error = Marshal.ReadInt32((IntPtr)l_RunErr);
                l_RunErr          += 4;

                p_ArrStat[i].HandleClient = Marshal.ReadInt32((IntPtr)l_RunStat);

                if (HResults.Succeeded(p_ArrStat[i].Error))
                {
                    short l_VT = Marshal.ReadInt16((IntPtr)(l_RunStat + 16));
                    if (l_VT == (short)VarEnum.VT_ERROR)
                    {
                        p_ArrStat[i].Error = Marshal.ReadInt32((IntPtr)(l_RunStat + 24));
                    }

                    p_ArrStat[i].Timestamp = Marshal.ReadInt64((IntPtr)(l_RunStat + 4));
                    p_ArrStat[i].Quality   = Marshal.ReadInt16((IntPtr)(l_RunStat + 12));
                    p_ArrStat[i].DataValue = Marshal.GetObjectForNativeVariant((IntPtr)(l_RunStat + 16));
                    DummyVariant.VariantClear((IntPtr)(l_RunStat + 16));
                }
                else
                {
                    p_ArrStat[i].DataValue = null;
                }

                l_RunStat += 32;
            }

            Marshal.FreeCoTaskMem(l_PtrStat);
            Marshal.FreeCoTaskMem(l_PtrErr);

            return(l_HResult == HResults.S_OK);
        }
Exemplo n.º 2
0
        public OpcValueImpl(
            OPCServer aServer, 
            string aName = "", 
            OPCDataSource aSource = OPCDataSource.OPCCache, 
            int aUpdateRate = 100)
        {
            if (aServer == null) {
                throw new ArgumentNullException("aServer");
            }

            Source = aSource;
            server = aServer;
            Name = aName;
            UpdateRate = aUpdateRate;
        }
Exemplo n.º 3
0
        public OpcValueImpl(
            OPCServer aServer,
            string aName          = "",
            OPCDataSource aSource = OPCDataSource.OPCCache,
            int aUpdateRate       = 100)
        {
            if (aServer == null)
            {
                throw new ArgumentNullException("aServer");
            }

            Source     = aSource;
            server     = aServer;
            Name       = aName;
            UpdateRate = aUpdateRate;
        }
Exemplo n.º 4
0
 public void Refresh2(OPCDataSource p_SourceMode, int p_TransactionID, out int p_CancelID)
 {
     m_IfAsync.Refresh2(p_SourceMode, p_TransactionID, out p_CancelID);
 }