/// <summary> /// Reads the status from the server. /// </summary> public OPCEVENTSERVERSTATUS?GetStatus() { string methodName = "IOPCEventServer.GetStatus"; try { IOPCEventServer server = BeginComCall <IOPCEventServer>(methodName, true); IntPtr ppServerStatus; server.GetStatus(out ppServerStatus); OPCEVENTSERVERSTATUS pStatus = (OPCEVENTSERVERSTATUS)Marshal.PtrToStructure(ppServerStatus, typeof(OPCEVENTSERVERSTATUS)); Marshal.DestroyStructure(ppServerStatus, typeof(OPCEVENTSERVERSTATUS)); Marshal.FreeCoTaskMem(ppServerStatus); return(pStatus); } catch (Exception e) { ComCallError(methodName, e); return(null); } finally { EndComCall(methodName); } }
internal static Opc.Ae.ServerStatus GetServerStatus(ref IntPtr pInput, bool deallocate) { Opc.Ae.ServerStatus status = null; if (pInput != IntPtr.Zero) { OPCEVENTSERVERSTATUS opceventserverstatus = (OPCEVENTSERVERSTATUS)Marshal.PtrToStructure(pInput, typeof(OPCEVENTSERVERSTATUS)); status = new Opc.Ae.ServerStatus { VendorInfo = opceventserverstatus.szVendorInfo, ProductVersion = string.Format("{0}.{1}.{2}", opceventserverstatus.wMajorVersion, opceventserverstatus.wMinorVersion, opceventserverstatus.wBuildNumber), ServerState = (ServerState)opceventserverstatus.dwServerState, StatusInfo = null, StartTime = OpcCom.Interop.GetFILETIME(Convert(opceventserverstatus.ftStartTime)), CurrentTime = OpcCom.Interop.GetFILETIME(Convert(opceventserverstatus.ftCurrentTime)), LastUpdateTime = OpcCom.Interop.GetFILETIME(Convert(opceventserverstatus.ftLastUpdateTime)) }; if (deallocate) { Marshal.DestroyStructure(pInput, typeof(OPCEVENTSERVERSTATUS)); Marshal.FreeCoTaskMem(pInput); pInput = IntPtr.Zero; } } return(status); }
internal static Opc.Ae.ServerStatus GetServerStatus(ref IntPtr pInput, bool deallocate) { Opc.Ae.ServerStatus serverStatus = null; if (pInput != IntPtr.Zero) { OPCEVENTSERVERSTATUS oPCEVENTSERVERSTATUS = (OPCEVENTSERVERSTATUS)Marshal.PtrToStructure(pInput, typeof(OPCEVENTSERVERSTATUS)); serverStatus = new Opc.Ae.ServerStatus(); serverStatus.VendorInfo = oPCEVENTSERVERSTATUS.szVendorInfo; serverStatus.ProductVersion = $"{oPCEVENTSERVERSTATUS.wMajorVersion}.{oPCEVENTSERVERSTATUS.wMinorVersion}.{oPCEVENTSERVERSTATUS.wBuildNumber}"; serverStatus.ServerState = (ServerState)oPCEVENTSERVERSTATUS.dwServerState; serverStatus.StatusInfo = null; serverStatus.StartTime = OpcCom.Interop.GetFILETIME(Convert(oPCEVENTSERVERSTATUS.ftStartTime)); serverStatus.CurrentTime = OpcCom.Interop.GetFILETIME(Convert(oPCEVENTSERVERSTATUS.ftCurrentTime)); serverStatus.LastUpdateTime = OpcCom.Interop.GetFILETIME(Convert(oPCEVENTSERVERSTATUS.ftLastUpdateTime)); if (deallocate) { Marshal.DestroyStructure(pInput, typeof(OPCEVENTSERVERSTATUS)); Marshal.FreeCoTaskMem(pInput); pInput = IntPtr.Zero; } } return(serverStatus); }