Exemplo n.º 1
0
 /// <summary>
 /// Represents a enum value.
 /// </summary>
 /// <param name="Thing">Reference to the thing to which the field belongs.</param>
 /// <param name="Timestamp">Timestamp of field value.</param>
 /// <param name="Name">Field Name.</param>
 /// <param name="ValueString">String-representation of enumeration value.</param>
 /// <param name="EnumerationType">Enumeration type.</param>
 /// <param name="Type">Field Type flags.</param>
 /// <param name="QoS">Quality of Service flags.</param>
 /// <param name="Writable">If the field is writable, i.e. corresponds to a control parameter.</param>
 /// <param name="Module">Language Module for localization purposes.</param>
 /// <param name="StringIdSteps">String ID steps.</param>
 public EnumField(ThingReference Thing, DateTime Timestamp, string Name, string ValueString, string EnumerationType, FieldType Type, FieldQoS QoS, bool Writable, string Module, params LocalizationStep[] StringIdSteps)
     : base(Thing, Timestamp, Name, Type, QoS, Writable, Module, StringIdSteps)
 {
     this.value       = null;        // TODO: See if enumeration type is recognized, and find the corresponding enum value.
     this.valueString = ValueString;
     this.type        = EnumerationType;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the value of the control parameter.
        /// </summary>
        /// <param name="Node">Node reference, if available.</param>
        /// <param name="StringValue">String representation of value to set.</param>
        /// <returns>If the parameter could be set (true), or if the value could not be parsed or its value was invalid (false).</returns>
        public override bool SetStringValue(ThingReference Node, string StringValue)
        {
            Enum Value;

            try
            {
                Value = (Enum)Enum.Parse(this.enumType, StringValue);
            }
            catch (Exception)
            {
                return(false);
            }

            try
            {
                this.setHandler(Node, Value);
            }
            catch (Exception ex)
            {
                Log.Critical(ex);
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
 /// <summary>
 /// If there are subscriptions registered for a given node.
 /// </summary>
 /// <param name="Reference">Node reference.</param>
 /// <returns>If there are subscriptions for the current node.</returns>
 public bool HasSubscriptions(ThingReference Reference)
 {
     lock (this.subscriptionsByThing)
     {
         return(this.subscriptionsByThing.ContainsKey(Reference));
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Represents a physical quantity value.
 /// </summary>
 /// <param name="Thing">Reference to the thing to which the field belongs.</param>
 /// <param name="Timestamp">Timestamp of field value.</param>
 /// <param name="Name">Field Name.</param>
 /// <param name="Value">Field Value.</param>
 /// <param name="NrDecimals">Number of decimals.</param>
 /// <param name="Unit">Unit</param>
 /// <param name="Type">Field Type flags.</param>
 /// <param name="QoS">Quality of Service flags.</param>
 public QuantityField(ThingReference Thing, DateTime Timestamp, string Name, double Value, byte NrDecimals, string Unit, FieldType Type, FieldQoS QoS)
     : base(Thing, Timestamp, Name, Type, QoS)
 {
     this.value      = Value;
     this.nrDecimals = NrDecimals;
     this.unit       = Unit;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Represents a enum value.
 /// </summary>
 /// <param name="Thing">Reference to the thing to which the field belongs.</param>
 /// <param name="Timestamp">Timestamp of field value.</param>
 /// <param name="Name">Field Name.</param>
 /// <param name="Value">Field Value.</param>
 /// <param name="Type">Field Type flags.</param>
 /// <param name="QoS">Quality of Service flags.</param>
 public EnumField(ThingReference Thing, DateTime Timestamp, string Name, Enum Value, FieldType Type, FieldQoS QoS)
     : base(Thing, Timestamp, Name, Type, QoS)
 {
     this.value       = Value;
     this.valueString = Value.ToString();
     this.type        = Value.GetType().FullName;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Represents a enum value.
 /// </summary>
 /// <param name="Thing">Reference to the thing to which the field belongs.</param>
 /// <param name="Timestamp">Timestamp of field value.</param>
 /// <param name="Name">Field Name.</param>
 /// <param name="Value">Field Value.</param>
 /// <param name="Type">Field Type flags.</param>
 /// <param name="QoS">Quality of Service flags.</param>
 /// <param name="Module">Language Module for localization purposes.</param>
 /// <param name="StringIdSteps">String ID steps.</param>
 public EnumField(ThingReference Thing, DateTime Timestamp, string Name, Enum Value, FieldType Type, FieldQoS QoS, string Module, params LocalizationStep[] StringIdSteps)
     : base(Thing, Timestamp, Name, Type, QoS, Module, StringIdSteps)
 {
     this.value       = Value;
     this.valueString = Value.ToString();
     this.type        = Value.GetType().FullName;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Contains information about a thing in a search result.
 /// </summary>
 /// <param name="Jid">JID of thing.</param>
 /// <param name="OwnerJid">JID of owner.</param>
 /// <param name="Node">Node reference. Can be equal to <see cref="ThingReference.Empty"/> if not behind a concentrator.</param>
 /// <param name="Tags">Meta-data tags.</param>
 public SearchResultThing(string Jid, string OwnerJid, ThingReference Node, params MetaDataTag[] Tags)
 {
     this.jid      = Jid;
     this.ownerJid = OwnerJid;
     this.node     = Node;
     this.tags     = Tags;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Represents a enum value.
 /// </summary>
 /// <param name="Thing">Reference to the thing to which the field belongs.</param>
 /// <param name="Timestamp">Timestamp of field value.</param>
 /// <param name="Name">Field Name.</param>
 /// <param name="ValueString">String-representation of enumeration value.</param>
 /// <param name="EnumerationType">Enumeration type.</param>
 /// <param name="Type">Field Type flags.</param>
 /// <param name="QoS">Quality of Service flags.</param>
 public EnumField(ThingReference Thing, DateTime Timestamp, string Name, string ValueString, string EnumerationType, FieldType Type, FieldQoS QoS)
     : base(Thing, Timestamp, Name, Type, QoS)
 {
     this.value       = null;        // TODO: See if enumeration type is recognized, and find the corresponding enum value.
     this.valueString = ValueString;
     this.type        = EnumerationType;
 }
Exemplo n.º 9
0
        public override void StartReadout(ThingReference ThingReference, ISensorReadout Request, string Prefix, bool Last)
        {
            List <Field> Fields = new List <Field>();

            this.AppendFields(ThingReference, Fields, Request, this.value, Prefix);
            Request.ReportFields(Last, Fields.ToArray());
        }
Exemplo n.º 10
0
        private void RemovedHandler(object Sender, IqEventArgs e)
        {
            XmlElement     E         = e.Query;
            string         NodeId    = XML.Attribute(E, "id");
            string         SourceId  = XML.Attribute(E, "src");
            string         Partition = XML.Attribute(E, "pt");
            ThingReference Node;

            if (string.IsNullOrEmpty(NodeId) && string.IsNullOrEmpty(SourceId) && string.IsNullOrEmpty(Partition))
            {
                Node = ThingReference.Empty;
            }
            else
            {
                Node = new ThingReference(NodeId, SourceId, Partition);
            }

            NodeEventArgs    e2 = new NodeEventArgs(e, Node);
            NodeEventHandler h  = this.Removed;

            if (h != null)
            {
                try
                {
                    h(this, e2);
                }
                catch (Exception ex)
                {
                    Log.Critical(ex);
                }
            }

            e.IqResult(string.Empty);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Represents a enum value.
 /// </summary>
 /// <param name="Thing">Reference to the thing to which the field belongs.</param>
 /// <param name="Timestamp">Timestamp of field value.</param>
 /// <param name="Name">Field Name.</param>
 /// <param name="Value">Field Value.</param>
 /// <param name="Type">Field Type flags.</param>
 /// <param name="QoS">Quality of Service flags.</param>
 /// <param name="Writable">If the field is writable, i.e. corresponds to a control parameter.</param>
 /// <param name="Module">Language Module for localization purposes.</param>
 /// <param name="StringIds">String IDs.</param>
 public EnumField(ThingReference Thing, DateTime Timestamp, string Name, Enum Value, FieldType Type, FieldQoS QoS, bool Writable,
                  string Module, params int[] StringIds)
     : base(Thing, Timestamp, Name, Type, QoS, Writable, Module, StringIds)
 {
     this.value       = Value;
     this.valueString = Value.ToString();
     this.type        = Value.GetType().FullName;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Represents a physical quantity value.
 /// </summary>
 /// <param name="Thing">Reference to the thing to which the field belongs.</param>
 /// <param name="Timestamp">Timestamp of field value.</param>
 /// <param name="Name">Field Name.</param>
 /// <param name="Value">Field Value.</param>
 /// <param name="NrDecimals">Number of decimals.</param>
 /// <param name="Unit">Unit</param>
 /// <param name="Type">Field Type flags.</param>
 /// <param name="QoS">Quality of Service flags.</param>
 /// <param name="Module">Language Module for localization purposes.</param>
 /// <param name="StringIdSteps">String ID steps.</param>
 public QuantityField(ThingReference Thing, DateTime Timestamp, string Name, double Value, byte NrDecimals, string Unit,
                      FieldType Type, FieldQoS QoS, string Module, params LocalizationStep[] StringIdSteps)
     : base(Thing, Timestamp, Name, Type, QoS, Module, StringIdSteps)
 {
     this.value      = Value;
     this.nrDecimals = NrDecimals;
     this.unit       = Unit;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Represents a physical quantity value.
 /// </summary>
 /// <param name="Thing">Reference to the thing to which the field belongs.</param>
 /// <param name="Timestamp">Timestamp of field value.</param>
 /// <param name="Name">Field Name.</param>
 /// <param name="Value">Field Value.</param>
 /// <param name="NrDecimals">Number of decimals.</param>
 /// <param name="Unit">Unit</param>
 /// <param name="Type">Field Type flags.</param>
 /// <param name="QoS">Quality of Service flags.</param>
 /// <param name="Writable">If the field is writable, i.e. corresponds to a control parameter.</param>
 /// <param name="Module">Language Module for localization purposes.</param>
 /// <param name="StringIds">String IDs.</param>
 public QuantityField(ThingReference Thing, DateTime Timestamp, string Name, double Value, byte NrDecimals, string Unit,
                      FieldType Type, FieldQoS QoS, bool Writable, string Module, params int[] StringIds)
     : base(Thing, Timestamp, Name, Type, QoS, Writable, Module, StringIds)
 {
     this.value      = Value;
     this.nrDecimals = NrDecimals;
     this.unit       = Unit;
 }
Exemplo n.º 14
0
        public async Task Test_07_FindFilterSort()
        {
            IEnumerable <ThingReference> ThingReferences = await Database.Find <ThingReference>(new FilterFieldLikeRegEx("NodeId", "Node(2|3)"), "-NodeId");

            foreach (ThingReference ThingReference in ThingReferences)
            {
                Console.Out.WriteLine(ThingReference.ToString());
            }
        }
Exemplo n.º 15
0
        public async Task Test_06_FindFilter()
        {
            IEnumerable <ThingReference> ThingReferences = await Database.Find <ThingReference>(new FilterFieldEqualTo("NodeId", "Node2"));

            foreach (ThingReference ThingReference in ThingReferences)
            {
                Console.Out.WriteLine(ThingReference.ToString());
            }
        }
Exemplo n.º 16
0
        public async Task Test_05_Find()
        {
            IEnumerable <ThingReference> ThingReferences = await Database.Find <ThingReference>();

            foreach (ThingReference ThingReference in ThingReferences)
            {
                Console.Out.WriteLine(ThingReference.ToString());
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Sets properties and attributes of class in accordance with XML definition.
        /// </summary>
        /// <param name="Definition">XML definition</param>
        public override Task FromXml(XmlElement Definition)
        {
            this.source    = XML.Attribute(Definition, "source");
            this.partition = XML.Attribute(Definition, "partition");
            this.node      = XML.Attribute(Definition, "node");

            this.thingRef = new ThingReference(this.node, this.source, this.partition);

            return(base.FromXml(Definition));
        }
Exemplo n.º 18
0
        /// <summary>
        /// Sets the value of the control parameter.
        /// </summary>
        /// <param name="Node">Node reference, if available.</param>
        /// <param name="StringValue">String representation of value to set.</param>
        /// <returns>If the parameter could be set (true), or if the value could not be parsed or its value was invalid (false).</returns>
        public override bool SetStringValue(ThingReference Node, string StringValue)
        {
            if (!CommonTypes.TryParse(StringValue, out bool Value))
            {
                return(false);
            }

            this.Set(Node, Value);

            return(true);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Sets the value of the control parameter.
        /// </summary>
        /// <param name="Node">Node reference, if available.</param>
        /// <param name="StringValue">String representation of value to set.</param>
        /// <returns>If the parameter could be set (true), or if the value could not be parsed or its value was invalid (false).</returns>
        public override bool SetStringValue(ThingReference Node, string StringValue)
        {
            if (!long.TryParse(StringValue, out long Value) || (this.min.HasValue && Value < this.min.Value) || (this.max.HasValue && Value > this.max.Value))
            {
                return(false);
            }

            this.Set(Node, Value);

            return(true);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Base class for all sensor data fields.
 /// </summary>
 /// <param name="Thing">Reference to the thing to which the field belongs.</param>
 /// <param name="Timestamp">Timestamp of field value.</param>
 /// <param name="Name">Field Name.</param>
 /// <param name="Type">Field Type flags.</param>
 /// <param name="QoS">Quality of Service flags.</param>
 public Field(ThingReference Thing, DateTime Timestamp, string Name, FieldType Type, FieldQoS QoS)
 {
     this.thing         = Thing;
     this.timestamp     = Timestamp;
     this.name          = Name;
     this.type          = Type;
     this.qos           = QoS;
     this.writable      = false;
     this.module        = string.Empty;
     this.stringIdSteps = null;
 }
Exemplo n.º 21
0
        /// <summary>
        /// Sets the value of the control parameter.
        /// </summary>
        /// <param name="Node">Node reference, if available.</param>
        /// <param name="StringValue">String representation of value to set.</param>
        /// <returns>If the parameter could be set (true), or if the value could not be parsed or its value was invalid (false).</returns>
        public override bool SetStringValue(ThingReference Node, string StringValue)
        {
            if (!TimeSpan.TryParse(StringValue, out TimeSpan Value))
            {
                return(false);
            }

            this.Set(Node, Value);

            return(true);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Represents a enum value.
        /// </summary>
        /// <param name="Thing">Reference to the thing to which the field belongs.</param>
        /// <param name="Timestamp">Timestamp of field value.</param>
        /// <param name="Name">Field Name.</param>
        /// <param name="ValueString">String-representation of enumeration value.</param>
        /// <param name="EnumerationType">Enumeration type.</param>
        /// <param name="Type">Field Type flags.</param>
        /// <param name="QoS">Quality of Service flags.</param>
        /// <param name="Module">Language Module for localization purposes.</param>
        /// <param name="StringIdSteps">String ID steps.</param>
        public EnumField(ThingReference Thing, DateTime Timestamp, string Name, string ValueString, string EnumerationType, FieldType Type, FieldQoS QoS, string Module, params LocalizationStep[] StringIdSteps)
            : base(Thing, Timestamp, Name, Type, QoS, Module, StringIdSteps)
        {
            this.valueString = ValueString;
            this.type        = EnumerationType;

            if (!Types.TryParseEnum(this.type, this.valueString, out this.value))
            {
                this.value = null;
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Represents a enum value.
        /// </summary>
        /// <param name="Thing">Reference to the thing to which the field belongs.</param>
        /// <param name="Timestamp">Timestamp of field value.</param>
        /// <param name="Name">Field Name.</param>
        /// <param name="ValueString">String-representation of enumeration value.</param>
        /// <param name="EnumerationType">Enumeration type.</param>
        /// <param name="Type">Field Type flags.</param>
        /// <param name="QoS">Quality of Service flags.</param>
        public EnumField(ThingReference Thing, DateTime Timestamp, string Name, string ValueString, string EnumerationType, FieldType Type, FieldQoS QoS)
            : base(Thing, Timestamp, Name, Type, QoS)
        {
            this.valueString = ValueString;
            this.type        = EnumerationType;

            if (!Types.TryParseEnum(this.type, this.valueString, out this.value))
            {
                this.value = null;
            }
        }
Exemplo n.º 24
0
 /// <summary>
 /// Base class for all sensor data fields.
 /// </summary>
 /// <param name="Thing">Reference to the thing to which the field belongs.</param>
 /// <param name="Timestamp">Timestamp of field value.</param>
 /// <param name="Name">Field Name.</param>
 /// <param name="Type">Field Type flags.</param>
 /// <param name="QoS">Quality of Service flags.</param>
 /// <param name="Module">Language Module for localization purposes.</param>
 /// <param name="StringIdSteps">String ID steps.</param>
 public Field(ThingReference Thing, DateTime Timestamp, string Name, FieldType Type, FieldQoS QoS, string Module, params LocalizationStep[] StringIdSteps)
 {
     this.thing         = Thing;
     this.timestamp     = Timestamp;
     this.name          = Name;
     this.type          = Type;
     this.qos           = QoS;
     this.writable      = false;
     this.module        = Module;
     this.stringIdSteps = StringIdSteps;
 }
Exemplo n.º 25
0
 /// <summary>
 /// Gets the value of the control parameter.
 /// </summary>
 /// <returns>Current value, or null if not available.</returns>
 public bool?Get(ThingReference Node)
 {
     try
     {
         return(this.getHandler(Node));
     }
     catch (Exception ex)
     {
         Log.Critical(ex);
         return(null);
     }
 }
Exemplo n.º 26
0
 /// <summary>
 /// Base class for all sensor data fields.
 /// </summary>
 /// <param name="Thing">Reference to the thing to which the field belongs.</param>
 /// <param name="Timestamp">Timestamp of field value.</param>
 /// <param name="Name">Field Name.</param>
 /// <param name="Type">Field Type flags.</param>
 /// <param name="QoS">Quality of Service flags.</param>
 /// <param name="Writable">If the field is writable, i.e. corresponds to a control parameter.</param>
 /// <param name="Module">Language Module for localization purposes.</param>
 /// <param name="StringIds">String ID steps.</param>
 public Field(ThingReference Thing, DateTime Timestamp, string Name, FieldType Type, FieldQoS QoS, bool Writable, string Module,
              params int[] StringIds)
 {
     this.thing         = Thing;
     this.timestamp     = Timestamp;
     this.name          = Name;
     this.type          = Type;
     this.qos           = QoS;
     this.writable      = Writable;
     this.module        = Module;
     this.stringIdSteps = Convert(StringIds);
 }
Exemplo n.º 27
0
        public void Test_06_FindFilterSort()
        {
            Task <IEnumerable <ThingReference> > Task = Database.Find <ThingReference>(new FilterFieldLikeRegEx("NodeId", "Node(2|3)"), "-NodeId");

            Assert.IsTrue(Task.Wait(5000));
            IEnumerable <ThingReference> ThingReferences = Task.Result;

            foreach (ThingReference ThingReference in ThingReferences)
            {
                Console.Out.WriteLine(ThingReference.ToString());
            }
        }
Exemplo n.º 28
0
        public void Test_05_FindFilter()
        {
            Task <IEnumerable <ThingReference> > Task = Database.Find <ThingReference>(new FilterFieldEqualTo("NodeId", "Node2"));

            Assert.IsTrue(Task.Wait(5000));
            IEnumerable <ThingReference> ThingReferences = Task.Result;

            foreach (ThingReference ThingReference in ThingReferences)
            {
                Console.Out.WriteLine(ThingReference.ToString());
            }
        }
Exemplo n.º 29
0
        public void Test_04_Find()
        {
            Task <IEnumerable <ThingReference> > Task = Database.Find <ThingReference>();

            Assert.IsTrue(Task.Wait(5000));
            IEnumerable <ThingReference> ThingReferences = Task.Result;

            foreach (ThingReference ThingReference in ThingReferences)
            {
                Console.Out.WriteLine(ThingReference.ToString());
            }
        }
Exemplo n.º 30
0
 /// <summary>
 /// Sets the value of the control parameter.
 /// </summary>
 /// <param name="Node">Node reference, if available.</param>
 /// <param name="Value">Value to set.</param>
 /// <returns>If the parameter could be set (true), or if the value was invalid (false).</returns>
 public bool Set(ThingReference Node, bool Value)
 {
     try
     {
         this.setHandler(Node, Value);
         return(true);
     }
     catch (Exception ex)
     {
         Log.Critical(ex);
         return(false);
     }
 }