protected override TamperingDetectorAlarmSnapshot Parse(TopicExpressionType topic, Message message)
        {
            if (message.source == null || message.source.simpleItem == null)
            {
                throw new InvalidOperationException();
            }

            string topicText             = topic.Any[0].InnerText;
            TamperingDetectorAlarms type = topics[topicText];

            bool state = false;

            var data = message.data;

            if (data.simpleItem != null)
            {
                foreach (var si in data.simpleItem)
                {
                    if (si.name == "State")
                    {
                        si.value.TryParseInvariant(out state);
                    }
                }
            }

            var snapshot = new TamperingDetectorAlarmSnapshot
            {
                Type  = type,
                State = state
            };

            return(snapshot);
        }
Exemplo n.º 2
0
    public static string ParseTopic(TopicExpressionType topic)
    {
        string topicString = "";

        topic.Any.ForEach(node => {
            topicString += "value: " + node.Value;
        });
        return(topicString);
    }
        protected override RegionMotionAlarmSnapshot Parse(TopicExpressionType topic, Message message)
        {
            if (message.source == null || message.source.simpleItem == null)
            {
                throw new InvalidOperationException();
            }
            string rule = null;

            foreach (var s in message.source.simpleItem)
            {
                if (s.name == "Rule")
                {
                    rule = s.value;
                }
            }
            if (string.IsNullOrEmpty(rule))
            {
                throw new InvalidOperationException();
            }

            if (message.key == null || message.key.simpleItem == null || message.key.simpleItem.Length != 1)
            {
                throw new InvalidOperationException();
            }
            var key = message.key.simpleItem[0];

            if (key == null || key.name != "ObjectId")
            {
                throw new InvalidOperationException();
            }
            string objectId = key.value;

            bool state = false;

            var data = message.data;

            if (data.simpleItem != null)
            {
                foreach (var si in data.simpleItem)
                {
                    if (si.name == "State")
                    {
                        si.value.TryParseInvariant(out state);
                    }
                }
            }

            var snapshot = new RegionMotionAlarmSnapshot
            {
                State    = state,
                Rule     = rule,
                ObjectId = objectId
            };

            return(snapshot);
        }
Exemplo n.º 4
0
 protected override bool VerifyTopic(TopicExpressionType topic)
 {
     if (@"http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete".Equals(topic.Dialect))
     {
         var innerTopic = topic.Any;
         //TODO : resolve namespace prefixes!
         if (innerTopic != null && innerTopic.Length == 1 && "tns1:RuleEngine/LineDetector/tnsx:Object".Equals(innerTopic[0].InnerText))
         {
             return(true);
         }
     }
     return(false);
 }
        private void Parse(TopicExpressionType topic, XmlElement msg)
        {
            var message = msg.Deserialize <Message>();

            var propertyOperation = message.propertyOperation;

            if (message.source != null && message.source.simpleItem != null)
            {
                foreach (var simpleItem in message.source.simpleItem)
                {
                    if (simpleItem.name == "VideoSourceToken" && videoSourceToken != null && simpleItem.value != videoSourceToken)
                    {
                        return;
                    }
                    if (simpleItem.name == "VideoSourceConfigurationToken" && videoSourceConfToken != null && simpleItem.value != videoSourceConfToken)
                    {
                        return;
                    }
                    if (simpleItem.name == "VideoAnalyticsConfigurationToken" && videoAnalyticsConfToken != null && simpleItem.value != videoAnalyticsConfToken)
                    {
                        return;
                    }
                }
            }

            if (message.data == null)
            {
                return;
            }

            var snapshot = Parse(topic, message);

            snapshot.Time = message.utcTime;


            if (this.initialized != null && propertyOperation == PropertyOperation.initialized)
            {
                this.initialized(snapshot);
            }
            if (this.changed != null && propertyOperation == PropertyOperation.changed)
            {
                this.changed(snapshot);
            }
            if (this.deleted != null && propertyOperation == PropertyOperation.deleted)
            {
                this.deleted(snapshot);
            }
        }
 protected override bool VerifyTopic(TopicExpressionType topic)
 {
     if (@"http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete".Equals(topic.Dialect))
     {
         var innerTopic = topic.Any;
         //TODO : resolve namespace prefixes!
         if (innerTopic != null && innerTopic.Length == 1)
         {
             var topicText = innerTopic[0].InnerText;
             if (topics.Any((p) => p.Key == topicText))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        TopicExpressionType GetTopicExression()
        {
            var parts = (from Selector ctrl in valuesTopicExpr.Items
                         where ctrl.SelectedItem != string.Empty
                         select(string) ctrl.SelectedItem).ToArray();

            string dialect = @"http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet";

            if (parts.Length == 1 && !parts.First().EndsWith("//."))
            {
                dialect = @"http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete";
            }

            var expr = string.Join("|", parts);

            var topicExpr = new TopicExpressionType()
            {
                Dialect = dialect,
                Any     = new XmlNode[] { new XmlDocument().CreateTextNode(expr) }
            };

            return(topicExpr);
        }
Exemplo n.º 8
0
        protected override MotionAlarmSnapshot Parse(TopicExpressionType topic, Message message)
        {
            bool state = false;

            var data = message.data;

            if (data.simpleItem != null)
            {
                foreach (var si in data.simpleItem)
                {
                    if (si.name == "State")
                    {
                        si.value.TryParseInvariant(out state);
                    }
                }
            }

            var snapshot = new MotionAlarmSnapshot
            {
                State = state
            };

            return(snapshot);
        }
 protected abstract TSnapshot Parse(TopicExpressionType topic, Message message);
 protected abstract bool VerifyTopic(TopicExpressionType topic);
        protected override VAObjectSnapshot Parse(TopicExpressionType topic, Message message)
        {
            if (message.key == null || message.key.simpleItem == null || message.key.simpleItem.Length != 1)
            {
                throw new InvalidOperationException();
            }
            var key = message.key.simpleItem[0];

            if (key == null || key.name != "ObjectId")
            {
                throw new InvalidOperationException();
            }
            string objectId = key.value;

            System.Windows.Rect  rect     = System.Windows.Rect.Empty;
            System.Windows.Point currPos  = new System.Windows.Point();
            System.Windows.Point startPos = new System.Windows.Point();

            var data = message.data;

            if (data.simpleItem != null)
            {
                foreach (var si in data.simpleItem)
                {
                    if (si.name == "BoundingBox")
                    {
                        si.value.TryParseInvariant(out rect);
                    }
                    else if (si.name == "CurrentPosition")
                    {
                        si.value.TryParseInvariant(out currPos);
                    }
                    else if (si.name == "StartPosition")
                    {
                        si.value.TryParseInvariant(out startPos);
                    }
                }
            }
            if (data.elementItem != null)
            {
                foreach (var ei in data.elementItem)
                {
                    //TODO remove
                    if (ei.name == "BoundingBox")
                    {
                        var rectangle = ei.any.Deserialize <Rectangle>();
                        rect = new Rect(new Point(rectangle.left, rectangle.bottom), new Point(rectangle.right, rectangle.top));
                    }
                }
            }


            var snapshot = new VAObjectSnapshot
            {
                Id              = objectId,
                BoundingBox     = rect,
                CurrentPosition = currPos,
                StartPosition   = startPos,
            };

            return(snapshot);
        }