コード例 #1
0
ファイル: CAPI_Session.cs プロジェクト: mpostol/PO.Common
        /// <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);
            }
        }
コード例 #2
0
ファイル: CAPI_NCCIState.cs プロジェクト: mpostol/PO.Common
 /// <summary>
 /// Clears the port and sets the starting conditions
 /// </summary>
 internal virtual void Release()
 {
     myDBufferPool = null;
     buff_RxMess.Clear();
     buff_RxMess.Open();
     buff_TxMess.TxDataClear();
     NCCI = 0;
     Disconnect_B3_Pending = false;
     accept         = true;
     NCCIPCurrState = NCCI_States.N0;
     IsConnectedCon.NotifyAll();
     B3_config = null;
 }
コード例 #3
0
ファイル: CAPI_Session.cs プロジェクト: mpostol/PO.Common
        /// <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);
        }
コード例 #4
0
ファイル: CAPI_Interface.cs プロジェクト: mpostol/PO.Common
        /// <summary>
        /// Sets all the parameters and sends CONNECT_RESP message to CAPI message queue
        /// </summary>
        /// <param name="CAPImsg">Message to send</param>
        /// <param name="controller">Number of controller</param>
        /// <param name="PLCI">Physical Link Connection Identifier</param>
        /// <param name="accept">Set true to accept connection, otherwise set false</param>
        /// <param name="B1">B1 protocol configuration</param>
        /// <param name="B2">B2 protocol configuration</param>
        /// <param name="B3">B3 protocol configuration</param>
        /// <param name="info">Result code</param>
        /// <returns>True if success, otherwise false</returns>
        public static bool Send_msg_connect_resp(ref CAPI_Message CAPImsg, byte controller, byte PLCI, bool accept, IB1_Proto B1, IB2_Proto B2, IB3_Proto B3, out uint info)
        {
            CAPImsg.reset_offset();
            CAPImsg.appID      = (short)app_ID;
            CAPImsg.sub_com    = comsub.CONNECT_RESP;
            CAPImsg.controller = controller;
            CAPImsg.plci       = PLCI;
            CAPImsg.ncci       = 0;
            if (accept)
            {
                CAPImsg.WriteInt16(0);
            }
            else
            {
                CAPImsg.WriteInt16(2);
            }
            ushort len_pos = CAPImsg.offset;

            CAPImsg.offset++;
            CAPImsg.WriteInt16((short)B1.B1);
            CAPImsg.WriteInt16((short)B2.B2);
            CAPImsg.WriteInt16((short)B3.B3);
            CAPImsg.WriteByte(0);                             //b1 conf default
            CAPImsg.WriteByte(0);                             //b2 conf default
            CAPImsg.WriteByte(0);                             //b3 conf defautl
            ushort act_pos = CAPImsg.offset;

            CAPImsg.offset = len_pos;
            CAPImsg.WriteByte((byte)(act_pos - len_pos));
            CAPImsg.offset = act_pos;
            CAPImsg.WriteByte(0);
            CAPImsg.WriteByte(0);
            CAPImsg.WriteByte(0);
            CAPImsg.WriteByte(0);
            CAPImsg.length = 28;
            TInterfaceError ret = CAPI_PUT_MESSAGE(app_ID, CAPImsg.uMessagePtr);

            info = (uint)ret;
            return(ret == TInterfaceError.SUCCESS);
        }
コード例 #5
0
ファイル: CAPI_Interface.cs プロジェクト: mpostol/PO.Common
        /// <summary>
        /// Sets all the parameters and sends CONNECT_REQ message to CAPI message queue
        /// </summary>
        /// <param name="CAPImsg">Message to send</param>
        /// <param name="tel">Called party number</param>
        /// <param name="controller">Number of controller</param>
        /// <param name="CIP">Compatibilty Information Profile</param>
        /// <param name="B1">B1 protocol configuration</param>
        /// <param name="B2">B2 protocol configuration</param>
        /// <param name="B3">B3 protocol configuration</param>
        /// <param name="connect_ident">Any number to distinguish from connections</param>
        /// <param name="info">Result code</param>
        /// <returns>True if success, otherwise false</returns>
        public static bool Send_msg_connect_req(ref CAPI_Message CAPImsg, string tel, byte controller, CIP_Value CIP, IB1_Proto B1, IB2_Proto B2, IB3_Proto B3, short connect_ident, out uint info)
        {
            CAPImsg.reset_offset();
            CAPImsg.appID      = (short)app_ID;
            CAPImsg.sub_com    = comsub.CONNECT_REQ;
            CAPImsg.controller = controller;
            CAPImsg.number     = connect_ident;
            CAPImsg.plci       = 0;
            CAPImsg.ncci       = 0;
            CAPImsg.WriteInt16((short)CIP);
            CAPImsg.WriteTelNum(tel);
            CAPImsg.WriteByte(0);                             //calling part no
            CAPImsg.WriteByte(0);                             //called party subadd
            CAPImsg.WriteByte(0);                             //calling party subadd
            CAPImsg.Start_block();
            CAPImsg.WriteInt16((short)B1.B1);
            CAPImsg.WriteInt16((short)B2.B2);
            CAPImsg.WriteInt16((short)B3.B3);
            B1.Set_param(CAPImsg);
            B2.Set_param(CAPImsg);
            B3.Set_param(CAPImsg);
            CAPImsg.End_block();
            //BC
            CAPImsg.WriteByte(0);
            //LLC
            CAPImsg.WriteByte(0);
            //HLC
            CAPImsg.WriteByte(0);
            CAPImsg.Start_block();
            CAPImsg.Start_block();                                                      //B channel info
            CAPImsg.WriteInt16(0);
            CAPImsg.End_block();
            CAPImsg.WriteInt16(0);
            CAPImsg.WriteByte(0);
            CAPImsg.End_block();
            CAPImsg.length = (short)((CAPImsg.offset));
            TInterfaceError ret = CAPI_PUT_MESSAGE(app_ID, CAPImsg.uMessagePtr);

            info = (uint)ret;
            return(ret == TInterfaceError.SUCCESS);
        }