예제 #1
0
        public TrackingManager(ICommandTransport commandTransport, bool testMode)
        {
            // check that the command transport is legit
            if (commandTransport == null)
            {
                throw new ArgumentNullException("commandTransport");
            }

            this.testMode = testMode;

            // create the command queue
            deltaSteeringQueue = new TimeWindowQueue <double>(3);

            // store the command transport
            this.commandTransport = commandTransport;

            // set up a null tracking command initially
            currentCommand = new NullTrackingCommand();
            // mark the current completion result as "working"
            currentResult = CompletionResult.Working;

            if (!testMode)
            {
                AsyncFlowControl?flowControl = null;
                if (!ExecutionContext.IsFlowSuppressed())
                {
                    flowControl = ExecutionContext.SuppressFlow();
                }

                // set up the thread
                trackingThread = new Thread(TrackingProc);
                // set it as a background thread
                trackingThread.IsBackground = true;
                // set it as higher priority
                trackingThread.Priority = ThreadPriority.AboveNormal;
                // give it a useful name
                trackingThread.Name = "Tracking Thread";
                // start her up
                trackingThread.Start();

                if (flowControl != null)
                {
                    flowControl.Value.Undo();
                }
            }
        }
        public TrackingManager(ICommandTransport commandTransport, bool testMode)
        {
            // check that the command transport is legit
            if (commandTransport == null) {
                throw new ArgumentNullException("commandTransport");
            }

            this.testMode = testMode;

            // create the command queue
            deltaSteeringQueue = new TimeWindowQueue<double>(3);

            // store the command transport
            this.commandTransport = commandTransport;

            // set up a null tracking command initially
            currentCommand = new NullTrackingCommand();
            // mark the current completion result as "working"
            currentResult = CompletionResult.Working;

            if (!testMode) {
                AsyncFlowControl? flowControl = null;
                if (!ExecutionContext.IsFlowSuppressed()) {
                    flowControl = ExecutionContext.SuppressFlow();
                }

                // set up the thread
                trackingThread = new Thread(TrackingProc);
                // set it as a background thread
                trackingThread.IsBackground = true;
                // set it as higher priority
                trackingThread.Priority = ThreadPriority.AboveNormal;
                // give it a useful name
                trackingThread.Name = "Tracking Thread";
                // start her up
                trackingThread.Start();

                if (flowControl != null) {
                    flowControl.Value.Undo();
                }
            }
        }
        public GraphItemAdapter(string name, Color color, double windowSize, DataItemAdapter dataItemAdapter)
        {
            // store values
            this.dataItemAdapter = dataItemAdapter;
            this.name = name;

            // get the source units
            this.sourceUnits = UnitConverter.GetUnit(dataItemAdapter.DataItemUnits);

            // create the queues
            plotQueue = new TimeWindowQueue(windowSize);
            recvQueue = new TimeWindowQueue(windowSize);

            // create the plot object
            plot = new LinePlot(plotQueue.ValueList, plotQueue.TimestampList);
            plot.Color = color;
            plot.Label = name;

            // subscribe to relevant events
            Services.RunControlService.RenderCycle += RunControlService_RenderCycle;
            dataItemAdapter.DataValueReceived += dataItemAdapter_DataValueReceived;
        }