示例#1
0
        protected override void Start()
        {
            #region request handler setup
            Activate(
                Arbiter.Interleave(
                    new TeardownReceiverGroup(
                        Arbiter.Receive <DsspDefaultDrop>(false, _mainPort, DropHandler)
                        ),
                    new ExclusiveReceiverGroup(
                        Arbiter.Receive <LaserRangeFinderResetUpdate>(true, _mainPort, LaserRangeFinderResetUpdateHandler),
                        Arbiter.Receive <LaserRangeFinderUpdate>(true, _mainPort, LaserRangeFinderUpdateHandler),
                        Arbiter.Receive <BumpersUpdate>(true, _mainPort, BumpersUpdateHandler),
                        Arbiter.Receive <BumperUpdate>(true, _mainPort, BumperUpdateHandler),
                        Arbiter.Receive <DriveUpdate>(true, _mainPort, DriveUpdateHandler),
                        Arbiter.Receive <WatchDogUpdate>(true, _mainPort, WatchDogUpdateHandler)
                        ),
                    new ConcurrentReceiverGroup(
                        Arbiter.Receive <Get>(true, _mainPort, GetHandler),
                        Arbiter.Receive <dssp.DsspDefaultLookup>(true, _mainPort, DefaultLookupHandler)
                        )
                    )
                );
            #endregion

            #region notification handler setup
            Activate(
                Arbiter.Interleave(
                    new TeardownReceiverGroup(),
                    new ExclusiveReceiverGroup(),
                    new ConcurrentReceiverGroup(
                        Arbiter.Receive <sicklrf.Reset>(true, _laserNotify, LaserResetNotification),
                        Arbiter.Receive <drive.Update>(true, _driveNotify, DriveUpdateNotification),
                        Arbiter.Receive <bumper.Replace>(true, _bumperNotify, BumperReplaceNotification),
                        Arbiter.Receive <bumper.Update>(true, _bumperNotify, BumperUpdateNotification)
                        )
                    )
                );

            // We cannot replicate the activation of laser notifications because the
            // handler uses Test() to skip old laser notifications.
            Activate(
                Arbiter.ReceiveWithIterator <sicklrf.Replace>(false, _laserNotify, LaserReplaceNotification)
                );
            #endregion

            // Start watchdog timer
            _mainPort.Post(new WatchDogUpdate(new WatchDogUpdateRequest(DateTime.Now)));

            // Create Subscriptions
            _bumperPort.Subscribe(_bumperNotify);
            _drivePort.Subscribe(_driveNotify);
            _laserPort.Subscribe(_laserNotify);

            DirectoryInsert();
        }
        protected override void Start()
        {
            base.Start();

            WinFormsServicePort.Post(new RunForm(StartForm));

            #region CODECLIP 01-5
            _drivePort.Subscribe(_driveNotify);
            Activate(Arbiter.Receive <drive.Update>(true, _driveNotify, NotifyDriveUpdate));
            #endregion
        }
示例#3
0
        protected override void Start()
        {
            base.Start();

            WinFormsServicePort.Post(new RunForm(StartForm));

            // Start listening for colors
            //SubscribeToColorSensor();

            _drivePort.Subscribe(_driveNotify);
            Activate(Arbiter.Receive <drive.Update>(true, _driveNotify, NotifyDriveUpdate));
        }
示例#4
0
        protected virtual void Initialize()
        {
            // Initialize the port and subscribe to the service
            motorsOn  = false;
            drivePort = DssEnvironment.ServiceForwarder <drive.DriveOperations>(new Uri(ServiceInfo.Service));
            drive.DriveOperations driveNotificationPort = new drive.DriveOperations();
            drivePort.Subscribe(driveNotificationPort);

            // Set up notifications
            Arbiter.Activate(DssEnvironment.TaskQueue,
                             Arbiter.Receive <drive.Update>(true, driveNotificationPort, NotifyDriveUpdate));
        }
示例#5
0
        protected virtual void Initialize()
        {
            // Initialize the port and subscribe to the service to know when the motors are enabled
            motorsOn  = false;
            drivePort = DssEnvironment.ServiceForwarder <drive.DriveOperations>(new Uri(ServiceInfo.Service));
            drive.DriveOperations driveNotificationPort = new drive.DriveOperations();
            RSUtils.ReceiveSync(taskQueue, drivePort.Subscribe(driveNotificationPort), Params.DefaultRecieveTimeout);

            // Set up notifications
            Arbiter.Activate(DssEnvironment.TaskQueue,
                             Arbiter.Receive <drive.Update>(true, driveNotificationPort, NotifyDriveUpdate));
        }
示例#6
0
        void ConnectToScribbler(DateTime dt)
        {
            Uri driveUri = null;

            // Look for any active generic drive contract service running
            Arbiter.Activate(DssEnvironment.TaskQueue,
                             Arbiter.Choice(DssEnvironment.DirectoryQuery(drive.Contract.Identifier),
                                            delegate(ServiceInfoType success)
            {
                driveUri = new Uri(success.Service);
                Console.WriteLine("================\n" + driveUri);

                // Initialize the port and subscribe to the service
                motorsOn  = false;
                drivePort = DssEnvironment.ServiceForwarder <drive.DriveOperations>(driveUri);
                drive.DriveOperations driveNotificationPort = new drive.DriveOperations();
                drivePort.Subscribe(driveNotificationPort);

                // Set up notifications
                Arbiter.Activate(DssEnvironment.TaskQueue,
                                 Arbiter.Receive <drive.Update>(true, driveNotificationPort, NotifyDriveUpdate)
                                 );

                autolock.Set();
            },
                                            delegate(W3C.Soap.Fault failure)
            {
                // Request failed. Sleep for 1 sec and look for 30 times.
                if (++attemptCount >= 30)
                {
                    DssEnvironment.LogError("Unable to find Drive Service, aborting - Press <Enter>");
                    Console.ReadLine();
                    DssEnvironment.Shutdown();
                }
                else
                {
                    // Post a timer message that expires in 30 seconds
                    TimeSpan timeout = new TimeSpan(0, 0, 30);
                    DssEnvironment.TaskQueue.EnqueueTimer(timeout, _timerPort);
                }
            }
                                            ));
        }
        /// <summary>
        /// Service start
        /// </summary>
        protected override void Start()
        {
            // Initialize the state
            if (_state == null)
            {
                _state = new WaitForDriveCompletionState();
            }
            _state.LastStatus = drive.DriveStage.InitialRequest;

            // Subscribe to the drive for notification messages
            _drivePort.Subscribe(_driveNotify);

            // Add the necessary receivers
            // NOTE: These are INDEPENDENT receivers.
            // This is OK because they do not affect the state of the service.
            Activate(Arbiter.ReceiveWithIterator <drive.DriveDistance>(true, _driveNotify, DriveDistanceUpdateHandler));
            Activate(Arbiter.ReceiveWithIterator <drive.RotateDegrees>(true, _driveNotify, RotateDegreesUpdateHandler));

            base.Start();
        }
        /// <summary>
        /// Service start
        /// </summary>
        protected override void Start()
        {
            // Set this to true to see how it works with just SetDrivePower and
            // timers to control the motions
            useTimers = false;

            // Subscribe to the drive for notification messages
            _drivePort.Subscribe(_driveNotify);

            // Add the necessary receivers
            // NOTE: These are INDEPENDENT receivers.
            // This is OK because they do not affect the state of the service.
            Activate(Arbiter.ReceiveWithIterator <drive.DriveDistance>(true, _driveNotify, DriveDistanceUpdateHandler));
            Activate(Arbiter.ReceiveWithIterator <drive.RotateDegrees>(true, _driveNotify, RotateDegreesUpdateHandler));

            base.Start();

            // Execute the geometric pattern
            SpawnIterator(Behavior);
        }
示例#9
0
        protected virtual void Initialize()
        {
            // Initialize the port and subscribe to the service to know when the motors are enabled
            motorsOn = false;
            drivePort = DssEnvironment.ServiceForwarder<drive.DriveOperations>(new Uri(ServiceInfo.Service));
            drive.DriveOperations driveNotificationPort = new drive.DriveOperations();
            RSUtils.ReceiveSync(taskQueue, drivePort.Subscribe(driveNotificationPort), Params.DefaultRecieveTimeout);

            // Set up notifications
            Arbiter.Activate(DssEnvironment.TaskQueue,
                Arbiter.Receive<drive.Update>(true, driveNotificationPort, NotifyDriveUpdate));
        }