示例#1
0
        object SendBufferProcess(object o)
        {
            while (true)
            {
                try
                {
                    string data = TxQueue.Dequeue();
#if DEBUG
                    CrestronConsole.Print("Revolabs Tx: {0}", data);
#endif
                    if (programStopping)
                    {
                        return(null);
                    }
                    else
                    {
                        this.ComPort.Send(data);
                    }

                    Thread.Sleep(50);
                }
                catch (Exception e)
                {
                    if (e.Message != "ThreadAbortException")
                    {
                        ErrorLog.Exception(string.Format("{0} - Exception in tx buffer thread", GetType().Name), e);
                    }
                }
            }
        }
示例#2
0
        object SendBufferProcess(object o)
        {
            while (!TxQueue.IsEmpty)
            {
                try
                {
                    Byte[] packet = TxQueue.Dequeue();
#if DEBUG
                    //CrestronConsole.Print("Samsung Tx: ");
                    //Tools.PrintBytes(packet, packet.Length);
#endif
                    if (programStopping)
                    {
                        TxQueue.Clear();
                        return(null);
                    }
                    else
                    {
                        this.ComPort.Send(packet, packet.Length);
                        CrestronEnvironment.AllowOtherAppsToRun();
                        Thread.Sleep(10);
                    }
                }
                catch (Exception e)
                {
                    if (e.Message != "ThreadAbortException")
                    {
                        ErrorLog.Exception(string.Format("{0} - Exception in tx buffer thread", GetType().Name), e);
                    }
                }
            }

            return(null);
        }
示例#3
0
        /// <summary>
        /// Handles the reception and transmission of messages
        /// </summary>
        protected virtual void CommManager()
        {
            while (!isStopping)
            {
                lock (CommQueue)
                {
                    if (CommQueue.Count > 0)
                    {
                        if (CommQueue.Peek().TargetID == ID)
                        {
                            OnMessageRxEvent(CommQueue.Dequeue());
                        }
                    }
                }

                if (TxQueue.Count > 0)
                {
                    CommQueue.Enqueue(TxQueue.Dequeue());
                }

                Thread.Sleep(100);
            }
        }