Пример #1
0
        /// <summary>
        /// Subscribe to motors on Scribbler base
        /// </summary>
        private void SubscribeToScribblerBase()
        {
            // Create a notification port
            brick.ScribblerOperations _notificationPort = new brick.ScribblerOperations();

            //create a custom subscription request
            brick.MySubscribeRequestType request = new brick.MySubscribeRequestType();

            request.Sensors = new List <string>();
            request.Sensors.Add("MOTORS");

            //Subscribe to the ScribblerBase and wait for a response
            Activate(
                Arbiter.Choice(_scribblerPort.SelectiveSubscribe(request, _notificationPort),
                               delegate(SubscribeResponseType Rsp)
            {
                //update our state with subscription status
                _subscribed = true;

                LogInfo("Backup Monitor subscription success");

                //Subscription was successful, start listening for sensor change notifications
                Activate(
                    Arbiter.Receive <brick.Replace>(true, _notificationPort, MotorNotificationHandler)
                    );
            },
                               delegate(soap.Fault F)
            {
                LogError("Backup Monitor subscription failed");
            }
                               )
                );
        }
Пример #2
0
        /// <summary>
        /// Subscribe to appropriate sensors on Scribbler base
        /// </summary>
        private void SubscribeToScribblerBase()
        {
            // Create a notification port
            brick.ScribblerOperations _notificationPort = new brick.ScribblerOperations();

            //create a custom subscription request
            brick.MySubscribeRequestType request = new brick.MySubscribeRequestType();

            //select only the sensor and port we want
            //NOTE: this name must match the scribbler sensor name.
            request.Sensors = new List <string>();

            foreach (bumper.ContactSensor entry in _state.Sensors)
            {
                request.Sensors.Add(entry.Name);
            }

            //Subscribe to the ScribblerBase and wait for a response
            Activate(
                Arbiter.Choice(_scribblerPort.SelectiveSubscribe(request, _notificationPort),
                               delegate(SubscribeResponseType Rsp)
            {
                //update our state with subscription status
                _subscribed = true;

                LogInfo("Bumper subscription success");

                //Subscription was successful, start listening for sensor change notifications
                Activate(
                    Arbiter.Receive <brick.Replace>(true, _notificationPort, SensorNotificationHandler)
                    );
            },
                               delegate(soap.Fault F)
            {
                LogError("Bumper subscription failed");
            }
                               )
                );
        }
Пример #3
0
        /// <summary>
        /// Subscribe to appropriate sensors on Scribbler base
        /// </summary>
        private void SubscribeToScribblerBase()
        {
            // Create a notification port
            brick.ScribblerOperations _notificationPort = new brick.ScribblerOperations();

            //create a custom subscription request
            brick.MySubscribeRequestType request = new brick.MySubscribeRequestType();

            //select only the sensor and port we want
            //NOTE: this name must match the scribbler sensor name.
            request.Sensors = new List<string>();

            request.Sensors.Add("LightLeft");
            request.Sensors.Add("LightCenter");
            request.Sensors.Add("LightRight");

            //Subscribe to the ScribblerBase and wait for a response
            Activate(
                Arbiter.Choice(_scribblerPort.SelectiveSubscribe(request, _notificationPort),
                    delegate(SubscribeResponseType Rsp)
                    {
                        //update our state with subscription status
                        _subscribed = true;

                        LogInfo("Scribbler Light Sensor subscription success");

                        //Subscription was successful, start listening for sensor change notifications
                        Activate(
                            Arbiter.Receive<brick.Replace>(true, _notificationPort, SensorNotificationHandler)
                        );
                    },
                    delegate(soap.Fault F)
                    {
                        LogError("Scribbler Light Sensor subscription failed");
                    }
                )
            );
        }
Пример #4
0
        /// <summary>
        /// Subscribe to motors on Scribbler base
        /// </summary>
        private void SubscribeToScribblerBase()
        {
            // Create a notification port
            brick.ScribblerOperations _notificationPort = new brick.ScribblerOperations();

            //create a custom subscription request
            brick.MySubscribeRequestType request = new brick.MySubscribeRequestType();

            request.Sensors = new List<string>();
            request.Sensors.Add("MOTORS");
            
            //Subscribe to the ScribblerBase and wait for a response
            Activate(
                Arbiter.Choice(_scribblerPort.SelectiveSubscribe(request, _notificationPort),
                    delegate(SubscribeResponseType Rsp)
                    {
                        //update our state with subscription status
                        _subscribed = true;

                        LogInfo("Backup Monitor subscription success");

                        //Subscription was successful, start listening for sensor change notifications
                        Activate(
                            Arbiter.Receive<brick.Replace>(true, _notificationPort, MotorNotificationHandler)
                        );
                    },
                    delegate(soap.Fault F)
                    {
                        LogError("Backup Monitor subscription failed");
                    }
                )
            );
        }