示例#1
0
        public LinkedBlockingCollection <BabelMessage> GetQueue(int id)
        {
            LinkedBlockingCollection <BabelMessage> q = null;

            IncomingQueues.TryGetValue(id, out q);
            return(q);
        }
示例#2
0
        // Construct a new Exchange.
        public MessageExchange(string shellOrTitleId, string name, string masterSN)
        {
            Shell s = Shell.GetShell(shellOrTitleId);

            if (s == null)
            {
                s = Shell.GetShell(Shell.ConsoleShellId);
            }
            if (s != null)
            {
                Interrupter = s.Interrupter;
                ShellId     = s.ShellId;
            }
            Id             = name;
            IsClosing      = false;
            ParameterTable = new DeviceParameterTable();
            ParameterTabelInit(masterSN);
            Manager = new NetIfManager(ShellId, masterSN, Interrupter);
            Manager.AddDriver(new MediatorNetIf(Manager, this));

            OutgoingQueue     = new LinkedBlockingCollection <MessageBinder>();
            IncomingQueue     = new LinkedBlockingCollection <BabelMessage>();
            IncomingListeners = new List <MessageBinder>();
            WaitingForReply   = new List <MessageBinder>();

            DispatcherThread = new MessageDispatcherThread(this);
            DispatcherThread.Start();
            ReceiverThread = new MessageReceiverThread(this);
            ReceiverThread.Start();

            Manager.Start();
        }
示例#3
0
        public BabelMessage GetMessageFromQueue(int id)
        {
            LinkedBlockingCollection <BabelMessage> q = GetQueue(id);

            if (q != null)
            {
                return(q.Take());
            }
            return(null);
        }
示例#4
0
        public int GetQueueLength(int id)
        {
            LinkedBlockingCollection <BabelMessage> q = GetQueue(id);

            if (q != null)
            {
                return(q.Size());
            }
            return(0);
        }
示例#5
0
        public void AddToQueue(int id, BabelMessage m)
        {
            LinkedBlockingCollection <BabelMessage> q = GetQueue(id);

            if (q == null)
            {
                q = new LinkedBlockingCollection <BabelMessage>();
                IncomingQueues.TryAdd(id, q);
            }
            q.Add(m);
        }
示例#6
0
 protected LinkDevice()
 {
     Interrupt       = new InterruptSource();
     IsClosing       = false;
     IsReading       = false;
     IsWriting       = false;
     IsInterrupted   = false;
     EnableListeners = true;
     ReadsCount      = 0;
     WritesCount     = 0;
     DeviceLock      = new Object();
     SuspendGate     = new Gate(true);
     WriteQueue      = new LinkedBlockingCollection <byte[]>();
     ReadQueue       = new BlockingCollection <byte[]>();
     ReadThread      = null;
     WriteThread     = null;
     ListenerThread  = null;
 }
示例#7
0
 public RecorderChart(RecorderControl recorder)
 {
     Recorder         = recorder;
     ChartPlotter     = null;
     IsClosing        = false;
     IsYZoom          = false;
     NumPointsPerPlot = POINTS_PER_PLOT;
     CurrentRelativeChartCacheIndex = 0;
     CurrentChartImageFileName      = null;
     ChartCache                  = new DataCache(recorder.ShellId, false, true, true, 0);
     BottomAxis                  = new RecorderTimeLineAxis(this);
     LeftAngularAxis             = new RecorderLeftAngularAxis(this);
     LeftSignalAxis              = new RecorderLeftSignalAxis(this);
     AxisPointTaskQueue          = new LinkedBlockingCollection <RecorderAxisPoint>();
     PointSchedulerTask          = new Thread(new ThreadStart(AxisPointScheduler));
     PointSchedulerTask.Name     = "AxisPointSchedulerThread:" + recorder.ShellId;
     PointSchedulerTask.Priority = ThreadPriority.Normal;
     PointSchedulerTask.Start();
 }