Пример #1
0
        public OperationalService(ICommandTransport transport, bool forwardPackets, bool listenPackets)
        {
            if (transport == null)
            {
                throw new ArgumentNullException("transport");
            }

            if (forwardPackets || listenPackets)
            {
                InitializePacketForwarding(listenPackets, forwardPackets);
            }

            // don't really need to initialize anything
            if (Settings.TestMode)
            {
                helper = new TestHelper();
                CommBuilder.BindObject(OperationalTestComponentFacade.ServiceName, helper);
            }
            else
            {
                CommBuilder.BindObject(OperationalFacade.ServiceName, this);
            }

            // set up the car mode channel
            carModeChannel = CommBuilder.GetChannel(CarModeChannelName);

            // register to receive run mode events
            transport.CarModeChanged += new EventHandler <CarModeChangedEventArgs>(transport_CarModeChanged);

            // mark that we haven't started yet
            started = false;
        }
Пример #2
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();
                }
            }
        }