Example #1
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));
        }
Example #2
0
        /// <summary>
        /// Sets properties and attributes of class in accordance with XML definition.
        /// </summary>
        /// <param name="Definition">XML definition</param>
        public override async Task FromXml(XmlElement Definition)
        {
            this.actor            = new StringAttribute(XML.Attribute(Definition, "actor"));
            this.to               = new StringAttribute(XML.Attribute(Definition, "to"));
            this.responseVariable = XML.Attribute(Definition, "responseVariable");
            this.responseType     = (SensorDataResponseType)XML.Attribute(Definition, "responseType", SensorDataResponseType.Object);
            this.fieldTypes       = 0;

            await base.FromXml(Definition);

            List <ThingReference> Nodes  = null;
            List <string>         Fields = null;

            foreach (ISimulationNode Node in this.Children)
            {
                if (Node is NodeReference NodeRef)
                {
                    if (Nodes is null)
                    {
                        Nodes = new List <ThingReference>();
                    }

                    Nodes.Add(NodeRef.ThingReference);
                }
                else if (Node is FieldReference FieldRef)
                {
                    if (Fields is null)
                    {
                        Fields = new List <string>();
                    }

                    Fields.Add(FieldRef.Name);
                }
                else if (Node is FieldType FieldType)
                {
                    this.fieldTypes |= FieldType.Type;
                }
            }

            this.nodeReferences = Nodes?.ToArray();
            this.fields         = Fields?.ToArray();
        }