/// <summary> /// Disconnects both parties and clears the connection /// </summary> /// <param name="portID">Class that represents the logical connection</param> /// <param name="timeout">Desired time to wait</param> /// <returns>Success if parties are disconnected, otherwise appropriate error code</returns> public TSessionError DisconnectReq(ref object portID, int timeout) { if (!CAPI_Interface.IsRegistered) { return(TSessionError.Session_NotRegistered); } if (portID == null) { return(TSessionError.NotConnected); } ; C_PLCIState port = (C_PLCIState)portID; if (!port.IsConnected) { return(TSessionError.NotConnected); } port.SM_PLCI(CAPI_Wrapper.comsub.DISCONNECT_B3_REQ); if (port.IsDisconnectedWait(timeout)) { Connections.ClosePLCIPort(ref port); //port.Release(); return(TSessionError.Success); } else { return(TSessionError.DisconnectInd_StillConnected); } }
/// <summary> /// Cleans up port after connection was closed /// </summary> /// <param name="portID">Class that represents the logical connection</param> /// <param name="timeout">Desired time to wait</param> /// <returns>Success if port was cleared, otherwise appropriate error code</returns> public TSessionError DisconnectInd(object portID, int timeout) { if (!CAPI_Interface.IsRegistered) { return(TSessionError.Session_NotRegistered); } if (portID == null) { return(TSessionError.NotConnected); } ; C_PLCIState port = (C_PLCIState)portID; if (port.IsDisconnectedWait(timeout)) { Connections.ClosePLCIPort(ref port); // port.Release(); return(TSessionError.Success); } else { return(TSessionError.DisconnectInd_StillConnected); } }