Ejemplo n.º 1
0
        public IEnumerator <ITask> OnFilteredSubscribe(FilteredSubscribe subscribe)
        {
            FilteredSubscribeRequest request = subscribe.Body;

            submgr.InsertSubscriptionMessage message = new submgr.InsertSubscriptionMessage(request);
            if (request.Filter != Filter.None && request.Filter != Filter.All)
            {
                List <submgr.QueryType> queries = new List <submgr.QueryType>();
                for (int i = 1; i < (int)Filter.All; i <<= 1)
                {
                    Filter filter = (Filter)i;
                    if ((request.Filter & filter) == filter)
                    {
                        queries.Add(new submgr.QueryType(filter.ToString()));
                    }
                }
                message.QueryList = queries.ToArray();
            }
            submgr.InsertSubscription insert = new submgr.InsertSubscription(message);

            yield return(Arbiter.Choice(
                             insert.ResponsePort,
                             subscribe.ResponsePort.Post,
                             subscribe.ResponsePort.Post
                             ));
        }
Ejemplo n.º 2
0
        public virtual IEnumerator <ITask> SubscribeHandler(Subscribe subscribe)
        {
            SubscribeRequest request = subscribe.Body;

            Console.WriteLine("SubscribeHandler() received Subscription request from Subscriber=" + subscribe.Body.Subscriber + "   for: " + request.MessageTypes);

            submgr.InsertSubscription insert = new submgr.InsertSubscription(request);
            insert.Body.FilterType = submgr.FilterType.Default;

            string valid = request.ValidOnly ? "True" : null;

            List <submgr.QueryType> query = new List <submgr.QueryType>();

            if (request.MessageTypes == ChrMessageType.All ||
                request.MessageTypes == ChrMessageType.None)
            {
                if (request.ValidOnly)
                {
                    query.Add(new submgr.QueryType(null, valid));
                }
            }
            else
            {
                // Subscriber supplied a bitmask requesting certain UM6 messages:
                if ((request.MessageTypes & ChrMessageType.GYRO_PROC) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_GYRO_PROC, valid));
                }
                if ((request.MessageTypes & ChrMessageType.ACCEL_PROC) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_ACCEL_PROC, valid));
                }
                if ((request.MessageTypes & ChrMessageType.MAG_PROC) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_MAG_PROC, valid));
                }
                if ((request.MessageTypes & ChrMessageType.EULER) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_EULER, valid));
                }
                if ((request.MessageTypes & ChrMessageType.QUAT) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_QUAT, valid));
                }
                // add more types here to the query
            }

            if (query.Count > 0)
            {
                insert.Body.QueryList = query.ToArray();
            }
            _subMgrPort.Post(insert);

            yield return(Arbiter.Choice(
                             insert.ResponsePort,
                             subscribe.ResponsePort.Post,
                             subscribe.ResponsePort.Post
                             ));
        }
        /// <summary>
        /// Forwards a subscription to a partner
        /// </summary>
        /// <param name="partner">The partner.</param>
        /// <param name="request">The request.</param>
        /// <param name="responsePort">The response port.</param>
        private void ForwardSubscription(
            IPort partner,
            SubscribeRequestType request,
            PortSet <SubscribeResponseType, Fault> responsePort)
        {
            var lookup = new DsspDefaultLookup();

            partner.PostUnknownType(lookup);
            this.Activate(
                lookup.ResponsePort.Choice(
                    svcinfo =>
            {
                var submgrInfo = svcinfo.PartnerList.Find(p => p.Contract == submgr.Contract.Identifier);
                var subMgrOps  = ServiceForwarder <submgr.SubscriptionManagerPort>(submgrInfo.Service);
                var insert     = new submgr.InsertSubscription(request)
                {
                    ResponsePort = responsePort
                };
                subMgrOps.Post(insert);
            },
                    responsePort.Post));
        }
Ejemplo n.º 4
0
        public IEnumerator <ITask> SelectiveSubscribeHandler(SelectiveSubscribe subRequest)
        {
            submgr.InsertSubscription selectiveSubscription = new submgr.InsertSubscription(
                new submgr.InsertSubscriptionMessage(
                    subRequest.Body.Subscriber,
                    subRequest.Body.Expiration,
                    0));

            selectiveSubscription.Body.NotificationCount = subRequest.Body.NotificationCount;

            List <submgr.QueryType> subscribeFilter = new List <submgr.QueryType>();

            //items in this loop are OR'ed together in the subscription
            foreach (string s in subRequest.Body.Sensors)
            {
                LogInfo("Adding subscription for: " + s.ToUpper());

                //you can achieve an AND behavior by adding a list of strings in the new QueryType
                subscribeFilter.Add(new submgr.QueryType(s.ToUpper()));
            }

            selectiveSubscription.Body.QueryList = subscribeFilter.ToArray();
            subMgrPort.Post(selectiveSubscription);

            yield return(Arbiter.Choice(selectiveSubscription.ResponsePort,
                                        delegate(dssp.SubscribeResponseType response)
            {
                subRequest.ResponsePort.Post(response);
            },
                                        delegate(Fault fault)
            {
                subRequest.ResponsePort.Post(fault);
            }));

            yield break;
        }
Ejemplo n.º 5
0
        public virtual IEnumerator<ITask> SubscribeHandler(Subscribe subscribe)
        {
            SubscribeRequest request = subscribe.Body;

            submgr.InsertSubscription insert = new submgr.InsertSubscription(request);
            insert.Body.FilterType = submgr.FilterType.Default;

            string valid = request.ValidOnly ? "True" : null;

            List<submgr.QueryType> query = new List<submgr.QueryType>();

            if (request.MessageTypes == GpsMessageType.All ||
                request.MessageTypes == GpsMessageType.None)
            {
                if (request.ValidOnly)
                {
                    query.Add(new submgr.QueryType(null, valid));
                }
            }
            else
            {
                if ((request.MessageTypes & GpsMessageType.GPGGA) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_GpGga, valid));
                }
                if ((request.MessageTypes & GpsMessageType.GPGLL) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_GpGll, valid));
                }
                if ((request.MessageTypes & GpsMessageType.GPGSA) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_GpGsa, valid));
                }
                if ((request.MessageTypes & GpsMessageType.GPGSV) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_GpGsv, valid));
                }
                if ((request.MessageTypes & GpsMessageType.GPRMC) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_GpRmc, valid));
                }
                if ((request.MessageTypes & GpsMessageType.GPVTG) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_GpVtg, valid));
                }
            }

            if (query.Count > 0)
            {
                insert.Body.QueryList = query.ToArray();
            }
            _subMgrPort.Post(insert);

            yield return Arbiter.Choice(
                insert.ResponsePort,
                subscribe.ResponsePort.Post,
                subscribe.ResponsePort.Post
            );
        }
        public virtual IEnumerator<ITask> SubscribeHandler(Subscribe subscribe)
        {
            SubscribeRequest request = subscribe.Body;

            Console.WriteLine("SubscribeHandler() received Subscription request from Subscriber=" + subscribe.Body.Subscriber + "   for: " + request.MessageTypes);

            submgr.InsertSubscription insert = new submgr.InsertSubscription(request);
            insert.Body.FilterType = submgr.FilterType.Default;

            string valid = request.ValidOnly ? "True" : null;

            List<submgr.QueryType> query = new List<submgr.QueryType>();

            if (request.MessageTypes == ChrMessageType.All ||
                request.MessageTypes == ChrMessageType.None)
            {
                if (request.ValidOnly)
                {
                    query.Add(new submgr.QueryType(null, valid));
                }
            }
            else
            {
                // Subscriber supplied a bitmask requesting certain UM6 messages:
                if ((request.MessageTypes & ChrMessageType.GYRO_PROC) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_GYRO_PROC, valid));
                }
                if ((request.MessageTypes & ChrMessageType.ACCEL_PROC) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_ACCEL_PROC, valid));
                }
                if ((request.MessageTypes & ChrMessageType.MAG_PROC) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_MAG_PROC, valid));
                }
                if ((request.MessageTypes & ChrMessageType.EULER) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_EULER, valid));
                }
                if ((request.MessageTypes & ChrMessageType.QUAT) != 0)
                {
                    query.Add(new submgr.QueryType(Tag_QUAT, valid));
                }
                // add more types here to the query
            }

            if (query.Count > 0)
            {
                insert.Body.QueryList = query.ToArray();
            }
            _subMgrPort.Post(insert);

            yield return Arbiter.Choice(
                insert.ResponsePort,
                subscribe.ResponsePort.Post,
                subscribe.ResponsePort.Post
            );
        }
Ejemplo n.º 7
0
        public IEnumerator<ITask> SelectiveSubscribeHandler(SelectiveSubscribe subRequest)
        {
            submgr.InsertSubscription selectiveSubscription = new submgr.InsertSubscription(
                new submgr.InsertSubscriptionMessage(
                    subRequest.Body.Subscriber,
                    subRequest.Body.Expiration,
                    0));

            selectiveSubscription.Body.NotificationCount = subRequest.Body.NotificationCount;

            List<submgr.QueryType> subscribeFilter = new List<submgr.QueryType>();

            //items in this loop are OR'ed together in the subscription
            foreach (string s in subRequest.Body.Sensors)
            {
                LogInfo("Adding subscription for: " + s.ToUpper());

                //you can achieve an AND behavior by adding a list of strings in the new QueryType
                subscribeFilter.Add(new submgr.QueryType(s.ToUpper()));
            }

            selectiveSubscription.Body.QueryList = subscribeFilter.ToArray();
            subMgrPort.Post(selectiveSubscription);

            yield return Arbiter.Choice(selectiveSubscription.ResponsePort,
                delegate(dssp.SubscribeResponseType response)
                {
                    subRequest.ResponsePort.Post(response);
                },
                delegate(Fault fault)
                {
                    subRequest.ResponsePort.Post(fault);
                });
            yield break;
        }
        /// <summary>
        /// Create a custom selective subscribe which filters on the 
        /// service uri of the subscriber.
        /// </summary>
        /// <param name="subscribe"></param>
        /// <returns></returns>
        private PortSet<SubscribeResponseType, Fault> SelectiveSubscribe(AttachAndSubscribe subscribe)
        {
            submgr.InsertSubscription insert = new submgr.InsertSubscription(subscribe.Body);
            insert.Body.FilterType = submgr.FilterType.Default;

            //List<submgr.QueryType> query = new List<submgr.QueryType>();
            //query.Add(new submgr.QueryType(subscribe.Body.Registration.ServiceUri));
            //insert.Body.QueryList = query.ToArray();

            _subMgrPort.Post(insert);
            return insert.ResponsePort;
        }