예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        /// <summary>
        /// Waits for incomming data
        /// </summary>
        /// <param name="portID">Class that represents the logical connection</param>
        /// <param name="rXMsg">Buffer for received data</param>
        /// <param name="timeout">Desired time to wait</param>
        /// <returns>Success if data was received, otherwise appropriate error code</returns>
        public TSessionError DataInd
            (object portID, out ISesDBuffer rXMsg, int timeout)
        {
            rXMsg = null;
            if (!CAPI_Interface.IsRegistered)
            {
                return(TSessionError.Session_NotRegistered);
            }
            if (portID == null)
            {
                return(TSessionError.NotConnected);
            }
            ;
            C_PLCIState port   = (C_PLCIState)portID;
            bool        isData = port.RxDataGet(out rXMsg, timeout);

            if (isData)
            {
                return(TSessionError.Success);
            }
            else
            {
                if (!port.IsConnected)
                {
                    return(TSessionError.NotConnected);
                }
                else
                {
                    return(TSessionError.DataInd_NoDat);
                }
            }
        }
예제 #3
0
        public TSessionError DataReq(object portID, ISesDBuffer tXmsg)
        {
            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);
            }
            if (port.TxDataSet(tXmsg))
            {
                port.SM_PLCI(CAPI_Wrapper.comsub.DATA_B3_REQ);
            }
            else
            {
                return(TSessionError.NotConnected);
            }
            return(TSessionError.Success);
        }
예제 #4
0
        /// <summary>
        /// Waits for incoming connection
        /// </summary>
        /// <param name="portID">Class that represents the logical connection</param>
        /// <param name="timeout">Desired time to wait</param>
        /// <param name="B1_conf">B1 protocol configuration</param>
        /// <param name="B2_conf">B2 protocol configuration</param>
        /// <param name="B3_conf">B3 protocol configuration</param>
        /// <param name="userDBufferPool">Buffer pool for data</param>
        /// <returns>Success if parties are connected, otherwise appropriate error code</returns>
        public TSessionError ConnectInd
            (out object portID, int timeout, IB1_Proto B1_conf, IB2_Proto B2_conf, IB3_Proto B3_conf, SesDBufferPool userDBufferPool)
        {
            portID = null;
            if (!CAPI_Interface.IsRegistered)
            {
                return(TSessionError.Session_NotRegistered);
            }
            //MPNI to jest zle - trzeba szukaæ czy ind nie pojawi³o siê wczeœniej
            C_PLCIState port = Connections.NewPLCIPort();

            portID = port;
            if (port == null)
            {
                return(TSessionError.ConnectReq_Failure);
            }
            port.B1_config       = B1_conf;
            port.B2_config       = B2_conf;
            port.B3_config       = B3_conf;
            port.userDBufferPool = userDBufferPool;
            port.SM_PLCI(CAPI_Wrapper.comsub.INTERNAL_WaitFConnInd);
            if (port.IsConnectedWait(timeout))
            {
                return(TSessionError.Success);
            }
            else
            {
                //port.Release();
                Connections.ClosePLCIPort(ref port);
                return(TSessionError.ConnectReq_Failure);
            }
        }
예제 #5
0
        public TSessionError ClearData(object portID)
        {
            ISesDBuffer rXMsg;

            if (!CAPI_Interface.IsRegistered)
            {
                return(TSessionError.Session_NotRegistered);
            }
            if (portID == null)
            {
                return(TSessionError.NotConnected);
            }
            ;
            C_PLCIState port = (C_PLCIState)portID;

            while (port.RxDataGet(out rXMsg, 10))
            {
                rXMsg = null;
            }
            return(TSessionError.Success);
        }
예제 #6
0
        /// <summary>
        /// Requests for connection
        /// </summary>
        /// <param name="portID">Class that represents the logical connection</param>
        /// <param name="telNum">Called party number</param>
        /// <param name="B1_conf">B1 protocol configuration</param>
        /// <param name="B2_conf">B2 protocol configuration</param>
        /// <param name="B3_conf">B3 protocol configuration</param>
        /// <param name="userDBufferPool">Buffer pool for data</param>
        /// <param name="timeout">timeout</param>
        /// <returns>Success if parties are connected, otherwise appropriate error code</returns>
        public TSessionError ConnectReq
        (
            out object portID,
            string telNum,
            IB1_Proto B1_conf,
            IB2_Proto B2_conf,
            IB3_Proto B3_conf,
            SesDBufferPool userDBufferPool,
            int timeout
        )
        {
            portID = null;
            if (!CAPI_Interface.IsRegistered)
            {
                return(TSessionError.Session_NotRegistered);
            }
            C_PLCIState port = Connections.NewPLCIPort();

            portID = port;
            if (port == null)
            {
                return(TSessionError.ConnectReq_Failure);
            }
            port.portTelNumber   = telNum;
            port.B1_config       = B1_conf;
            port.B2_config       = B2_conf;
            port.B3_config       = B3_conf;
            port.userDBufferPool = userDBufferPool;
            port.SM_PLCI(CAPI_Wrapper.comsub.CONNECT_REQ);
            if (port.IsConnectedWait(timeout))
            {
                return(TSessionError.Success);
            }
            else
            {
                //  port.Release();
                Connections.ClosePLCIPort(ref port);
            }
            return(TSessionError.ConnectReq_Failure);
        }
예제 #7
0
        /// <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);
            }
        }