Exemplo n.º 1
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.º 2
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.º 3
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.name     = XML.Attribute(Definition, "name");
            this.type     = (Waher.Things.SensorData.FieldType)XML.Attribute(Definition, "type", Waher.Things.SensorData.FieldType.Momentary);
            this.qos      = (FieldQoS)XML.Attribute(Definition, "qos", FieldQoS.AutomaticReadout);
            this.writable = XML.Attribute(Definition, "writable", false);

            return(base.FromXml(Definition));
        }
Exemplo n.º 4
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.º 5
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.º 6
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.º 7
0
        /// <summary>
        /// Represents one item in a sensor data readout.
        /// </summary>
        /// <param name="Field">Sensor data field.</param>
        public FieldItem(Field Field)
            : base(Colors.Black, Colors.White)
        {
            this.field         = Field;
            this.quantityField = Field as QuantityField;

            FieldQoS QoS = Field.QoS;

            if (QoS.HasFlag(FieldQoS.InvoiceConfirmed) || QoS.HasFlag(FieldQoS.Invoiced))
            {
                this.BackgroundColor = Colors.Gold;
            }
            else if (QoS.HasFlag(FieldQoS.EndOfSeries))
            {
                this.BackgroundColor = Colors.LightBlue;
            }
            else if (QoS.HasFlag(FieldQoS.Signed))
            {
                this.BackgroundColor = Colors.LightGreen;
            }
            else if (QoS.HasFlag(FieldQoS.Error))
            {
                this.BackgroundColor = Colors.LightPink;
            }
            else if (QoS.HasFlag(FieldQoS.PowerFailure) || QoS.HasFlag(FieldQoS.TimeOffset) || QoS.HasFlag(FieldQoS.Warning))
            {
                this.BackgroundColor = Colors.LightYellow;
            }
            else if (QoS.HasFlag(FieldQoS.Missing) || QoS.HasFlag(FieldQoS.InProgress))
            {
                this.BackgroundColor = Colors.LightGray;
            }
            else if (QoS.HasFlag(FieldQoS.AutomaticEstimate) || QoS.HasFlag(FieldQoS.ManualEstimate))
            {
                this.BackgroundColor = Colors.WhiteSmoke;
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Represents a boolean value that can be either true or false.
 /// </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="StringIds">String IDs.</param>
 public BooleanField(ThingReference Thing, DateTime Timestamp, string Name, bool Value, FieldType Type, FieldQoS QoS, string Module,
                     params int[] StringIds)
     : base(Thing, Timestamp, Name, Type, QoS, Module, StringIds)
 {
     this.value = Value;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Represents a boolean value that can be either true or false.
 /// </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="StringIdSteps">String ID steps.</param>
 public BooleanField(ThingReference Thing, DateTime Timestamp, string Name, bool Value, FieldType Type, FieldQoS QoS, bool Writable, string Module, params LocalizationStep[] StringIdSteps)
     : base(Thing, Timestamp, Name, Type, QoS, Writable, Module, StringIdSteps)
 {
     this.value = Value;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Represents a boolean value that can be either true or false.
 /// </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 BooleanField(ThingReference Thing, DateTime Timestamp, string Name, bool Value, FieldType Type, FieldQoS QoS)
     : base(Thing, Timestamp, Name, Type, QoS)
 {
     this.value = Value;
 }
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="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.º 12
0
 /// <summary>
 /// Represents a duration value. Duration values adhere to the type specified by xsd:duration.
 ///
 /// Difference between xsd:time and xsd:duration is that:
 ///		xsd:duration represents the relative span between twostamps in time.
 ///		xsd:time represents an absolute time or clock in the 24-hour clock.
 /// </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 DurationField(ThingReference Thing, DateTime Timestamp, string Name, Duration Value, FieldType Type, FieldQoS QoS, bool Writable,
                      string Module, params int[] StringIds)
     : base(Thing, Timestamp, Name, Type, QoS, Writable, Module, StringIds)
 {
     this.value = Value;
 }
Exemplo n.º 13
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="StringIds">String IDs.</param>
 public EnumField(ThingReference Thing, DateTime Timestamp, string Name, Enum Value, FieldType Type, FieldQoS QoS, string Module,
                  params int[] StringIds)
     : base(Thing, Timestamp, Name, Type, QoS, Module, StringIds)
 {
     this.value       = Value;
     this.valueString = Value.ToString();
     this.type        = Value.GetType().FullName;
 }
Exemplo n.º 14
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.º 15
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.º 16
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>
 public EnumField(ThingReference Thing, DateTime Timestamp, string Name, Enum Value, FieldType Type, FieldQoS QoS, bool Writable)
     : base(Thing, Timestamp, Name, Type, QoS, Writable)
 {
     this.value       = Value;
     this.valueString = Value.ToString();
     this.type        = Value.GetType().FullName;
 }
Exemplo n.º 17
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.º 18
0
 /// <summary>
 /// Represents a 64-bit integer 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 Int64Field(ThingReference Thing, DateTime Timestamp, string Name, long Value, FieldType Type, FieldQoS QoS)
     : base(Thing, Timestamp, Name, Type, QoS)
 {
     this.value = Value;
 }
Exemplo n.º 19
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="StringIdSteps">String ID steps.</param>
 public EnumField(ThingReference Thing, DateTime Timestamp, string Name, Enum Value, FieldType Type, FieldQoS QoS, bool Writable, string Module, params LocalizationStep[] StringIdSteps)
     : base(Thing, Timestamp, Name, Type, QoS, Writable, Module, StringIdSteps)
 {
     this.value       = Value;
     this.valueString = Value.ToString();
     this.type        = Value.GetType().FullName;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Represents a time value. Time values adhere to the type specified by xsd:time.
 ///
 /// Difference between xsd:time and xsd:duration is that:
 ///		xsd:duration represents the relative span between twostamps in time.
 ///		xsd:time represents an absolute time or clock in the 24-hour clock.
 /// </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>
 public TimeField(ThingReference Thing, DateTime Timestamp, string Name, TimeSpan Value, FieldType Type, FieldQoS QoS, bool Writable)
     : base(Thing, Timestamp, Name, Type, QoS, Writable)
 {
     this.value = Value;
 }
Exemplo n.º 21
0
 /// <summary>
 /// Represents a duration value. Duration values adhere to the type specified by xsd:duration.
 ///
 /// Difference between xsd:time and xsd:duration is that:
 ///		xsd:duration represents the relative span between twostamps in time.
 ///		xsd:time represents an absolute time or clock in the 24-hour clock.
 /// </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 DurationField(ThingReference Thing, DateTime Timestamp, string Name, Duration Value, FieldType Type, FieldQoS QoS)
     : base(Thing, Timestamp, Name, Type, QoS)
 {
     this.value = Value;
 }
        /// <summary>
        /// Outputs a field to XML using the field format specified in the IEEE XMPP IoT extensions.
        /// </summary>
        /// <param name="Xml">XML output.</param>
        /// <param name="Field">Field to output.</param>
        public static void OutputField(XmlWriter Xml, Field Field)
        {
            FieldType FieldTypes;
            FieldQoS  FieldQoS;
            EnumField EnumField;
            string    FieldDataTypeName;
            bool      First;

            FieldDataTypeName = Field.FieldDataTypeName;

            Xml.WriteStartElement(FieldDataTypeName);
            Xml.WriteAttributeString("n", Field.Name);

            if (Field.Writable)
            {
                Xml.WriteAttributeString("ctr", "true");
            }

            if (!string.IsNullOrEmpty(Field.Module))
            {
                Xml.WriteAttributeString("lns", Field.Module);
            }

            if (Field.StringIdSteps != null && Field.StringIdSteps.Length > 0)
            {
                StringBuilder Value = new StringBuilder();

                First = true;
                foreach (LocalizationStep Step in Field.StringIdSteps)
                {
                    if (First)
                    {
                        First = false;
                    }
                    else
                    {
                        Value.Append(',');
                    }

                    Value.Append(Step.StringId.ToString());

                    if (!string.IsNullOrEmpty(Step.Module) || !string.IsNullOrEmpty(Step.Seed))
                    {
                        Value.Append('|');
                        Value.Append(XML.Encode(Step.Module));

                        if (!string.IsNullOrEmpty(Step.Seed))
                        {
                            Value.Append('|');
                            Value.Append(XML.Encode(Step.Seed));
                        }
                    }
                }

                Xml.WriteAttributeString("loc", Value.ToString());
            }

            FieldTypes = Field.Type;

            if ((FieldTypes & FieldType.All) == FieldType.All)
            {
                Xml.WriteAttributeString("all", "true");
            }
            else
            {
                if (FieldTypes.HasFlag(FieldType.Momentary))
                {
                    Xml.WriteAttributeString("m", "true");
                }

                if (FieldTypes.HasFlag(FieldType.Identity))
                {
                    Xml.WriteAttributeString("i", "true");
                }

                if (FieldTypes.HasFlag(FieldType.Status))
                {
                    Xml.WriteAttributeString("s", "true");
                }

                if (FieldTypes.HasFlag(FieldType.Computed))
                {
                    Xml.WriteAttributeString("c", "true");
                }

                if (FieldTypes.HasFlag(FieldType.Peak))
                {
                    Xml.WriteAttributeString("p", "true");
                }

                if (FieldTypes.HasFlag(FieldType.Historical))
                {
                    Xml.WriteAttributeString("h", "true");
                }
            }

            FieldQoS = Field.QoS;

            if (FieldQoS.HasFlag(FieldQoS.Missing))
            {
                Xml.WriteAttributeString("ms", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.InProgress))
            {
                Xml.WriteAttributeString("pr", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.AutomaticEstimate))
            {
                Xml.WriteAttributeString("ae", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.ManualEstimate))
            {
                Xml.WriteAttributeString("me", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.ManualReadout))
            {
                Xml.WriteAttributeString("mr", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.AutomaticReadout))
            {
                Xml.WriteAttributeString("ar", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.TimeOffset))
            {
                Xml.WriteAttributeString("of", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.Warning))
            {
                Xml.WriteAttributeString("w", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.Error))
            {
                Xml.WriteAttributeString("er", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.Signed))
            {
                Xml.WriteAttributeString("so", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.Invoiced))
            {
                Xml.WriteAttributeString("iv", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.EndOfSeries))
            {
                Xml.WriteAttributeString("eos", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.PowerFailure))
            {
                Xml.WriteAttributeString("pf", "true");
            }

            if (FieldQoS.HasFlag(FieldQoS.InvoiceConfirmed))
            {
                Xml.WriteAttributeString("ic", "true");
            }

            if (Field is QuantityField QuantityField)
            {
                Xml.WriteAttributeString("v", CommonTypes.Encode(QuantityField.Value, QuantityField.NrDecimals));
                Xml.WriteAttributeString("u", QuantityField.Unit);
            }
            else if ((EnumField = Field as EnumField) != null)
            {
                Xml.WriteAttributeString("v", Field.ValueString);
                Xml.WriteAttributeString("t", EnumField.EnumerationType);
            }
            else
            {
                Xml.WriteAttributeString("v", Field.ValueString);
            }

            Xml.WriteEndElement();
        }
Exemplo n.º 23
0
 /// <summary>
 /// Represents a duration value. Duration values adhere to the type specified by xsd:duration.
 ///
 /// Difference between xsd:time and xsd:duration is that:
 ///		xsd:duration represents the relative span between twostamps in time.
 ///		xsd:time represents an absolute time or clock in the 24-hour clock.
 /// </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 DurationField(ThingReference Thing, DateTime Timestamp, string Name, Duration Value, FieldType Type, FieldQoS QoS, string Module, params LocalizationStep[] StringIdSteps)
     : base(Thing, Timestamp, Name, Type, QoS, Module, StringIdSteps)
 {
     this.value = Value;
 }
Exemplo n.º 24
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="StringIds">String IDs.</param>
 public EnumField(ThingReference Thing, DateTime Timestamp, string Name, string ValueString, string EnumerationType, FieldType Type, FieldQoS QoS, bool Writable,
                  string Module, params int[] StringIds)
     : base(Thing, Timestamp, Name, Type, QoS, Writable, Module, StringIds)
 {
     this.value       = null;        // TODO: See if enumeration type is recognized, and find the corresponding enum value.
     this.valueString = ValueString;
     this.type        = EnumerationType;
 }