Esempio n. 1
0
        void PackMode(Socket sock)
        {
            int dummy_iterations = 0;

            object[] args;
            byte[]   buff;

            TransactionEnded = false;
            DataWritten      = 0;
            while (sock.Connected && (!TransactionEnded))
            {
#if false
                if (sock.Available == 0)
                {
                    if (dummy_iterations == 500)
                    {
                        args    = new object[1];
                        args[0] = "dummy";
                        Invoke(updateStatus, args);
                        LogUtility.LogUtility.LogFile("dummy");
                        break;
                    }
                    dummy_iterations++;
                    Thread.Sleep(100);
                    continue;
                }
                dummy_iterations = 0;
#endif
                buff = new byte[sock.Available];
                try
                {
                    LogUtility.LogUtility.LogFile("Available " + Convert.ToString(sock.Available), ModuleLogLevel);
                    int received = sock.Receive(buff);
                    BytesReceived += (uint)received;
                    if (received > 0)
                    {
                        LogUtility.LogUtility.LogFile("Received " + Convert.ToString(received), ModuleLogLevel);
                        receiverPackLib.OnDataByteMode(buff, 0);
                    }
                }
                catch (SocketException se)
                {
                    args    = new object[1];
                    args[0] = se.Message;
                    Invoke(updateStatus, args);
                    break;
                }
            }
        }
Esempio n. 2
0
        protected override void OnProprietarySegmentMsgReceived()
        {
            LogUtility.LogUtility.LogFile(Convert.ToString(m_Id) + " Entering OnProprietarySegmentMsgReceived", LogUtility.LogLevels.LEVEL_LOG_MEDIUM);
            try
            {
                LogUtility.LogUtility.LogFile(Convert.ToString(m_Id) + " Received message type " + Convert.ToString(m_rxStateMachine.GetKind()), ModuleLogLevel);
                if (m_rxStateMachine.GetMsgBody() == null)
                {
                    LogUtility.LogUtility.LogFile(Convert.ToString(m_Id) + " msg body is null", ModuleLogLevel);
                    return;
                }
                m_ReceivedMsgs++;
                switch (m_rxStateMachine.GetKind())
                {
                case (byte)PackEnvelopeKinds.PACK_ENVELOPE_DOWNSTREAM_DATA_KIND:
                    //receiverPackLib.OnDataByteMode(rxStateMachine.GetMsgBody(), 0);
                    //rxStateMachine.ClearMsgBody();
                    LogUtility.LogUtility.LogFile("SHOULD NOT OCCUR!!!!!!!!!!!!", LogUtility.LogLevels.LEVEL_LOG_HIGH);
                    break;

                case (byte)PackEnvelopeKinds.PACK_ENVELOPE_DOWNSTREAM_MSG_KIND:
                    EnterProprietaryLibCriticalArea();
                    try
                    {
                        m_receiverPackLib.OnDataByteMode(m_rxStateMachine.GetMsgBody(), 0);
                        LeaveProprietaryLibCriticalArea();
                    }
                    catch (Exception exc)
                    {
                        LogUtility.LogUtility.LogFile(Convert.ToString(m_Id) + " EXCEPTION " + exc.Message + " " + exc.StackTrace, LogUtility.LogLevels.LEVEL_LOG_HIGH);
                        LeaveProprietaryLibCriticalArea();
                    }
                    m_rxStateMachine.ClearMsgBody();
                    break;
                }
            }
            catch (Exception exc)
            {
                LogUtility.LogUtility.LogFile(Convert.ToString(m_Id) + " EXCEPTION " + exc.Message + " " + exc.StackTrace, LogUtility.LogLevels.LEVEL_LOG_HIGH);
                throw new Exception("Exception in OnProprietarySegmentMsgReceived", exc);
            }
            LogUtility.LogUtility.LogFile(Convert.ToString(m_Id) + " Leaving OnProprietarySegmentMsgReceived", LogUtility.LogLevels.LEVEL_LOG_MEDIUM);
        }