Ejemplo n.º 1
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("IRLeft");
            //request.Sensors.Add("IRRight");
            request.Sensors.Add("Stall");

            //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("ScribblerStall subscription success");

                //Subscription was successful, start listening for sensor change notifications
                Activate(
                    Arbiter.Receive <brick.Replace>(true, _notificationPort, SensorNotificationHandler)
                    );
            },
                               delegate(soap.Fault F)
            {
                LogError("ScribblerStall subscription failed");
            }
                               )
                );
        }
Ejemplo n.º 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>();

            //request.Sensors.Add("IRLeft");
            //request.Sensors.Add("IRRight");
            request.Sensors.Add("Stall");

            //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("ScribblerStall subscription success");

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