/// <summary>
 /// Enumeration valued field.
 /// </summary>
 /// <param name="Node">Node</param>
 /// <param name="FieldName">Name of field</param>
 /// <param name="StringId">Corresponding String ID</param>
 /// <param name="LocalizationSeed">Localization seed, i.e. the default string for creating
 /// a localized field name.</param>
 /// <param name="Timepoint">Timepoint of field value.</param>
 /// <param name="Value">Value</param>
 /// <param name="Type">Type of value.</param>
 public FieldEnum(string NodeId, string FieldName, int StringId, string LocalizationSeed,
                  DateTime Timepoint, Enum Value, ReadoutType Type)
     : base(NodeId, FieldName, StringId, LocalizationSeed, Timepoint, Type)
 {
     this.value    = Value.ToString();
     this.dataType = Value.GetType().FullName;
 }
 /// <summary>
 /// Enumeration valued field.
 /// </summary>
 /// <param name="Node">Node</param>
 /// <param name="FieldName">Name of field</param>
 /// <param name="StringIds">Corresponding String IDs</param>
 /// <param name="Timepoint">Timepoint of field value.</param>
 /// <param name="Value">Value</param>
 /// <param name="Type">Type of value.</param>
 public FieldEnum(string NodeId, string FieldName, FieldLanguageStep[] StringIds, DateTime Timepoint,
                  Enum Value, ReadoutType Type)
     : base(NodeId, FieldName, StringIds, Timepoint, Type)
 {
     this.value    = Value.ToString();
     this.dataType = Value.GetType().FullName;
 }
Пример #3
0
		/// <summary>
		/// Enumeration valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringIds">Corresponding String IDs</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="Value">Value</param>
		/// <param name="Type">Type of value.</param>
		public FieldEnum(string NodeId, string FieldName, FieldLanguageStep[] StringIds, DateTime Timepoint,
			Enum Value, ReadoutType Type)
			: base(NodeId, FieldName, StringIds, Timepoint, Type)
		{
			this.value = Value.ToString();
			this.dataType = Value.GetType ().FullName;
		}
Пример #4
0
        public override List <Field> ParseContent(object Content, ReadoutType Types, DateTime From, DateTime To)
        {
            List <Field> Result = new List <Field>();
            string       s      = Content as string;
            Duration     D;

            if (!string.IsNullOrEmpty(s) && XmlUtilities.TryParseDuration(s, out D))
            {
                try
                {
                    TimeSpan TS = D.ToTimeSpan();

                    Result.Add(new FieldTimeSpan(this, this.FieldName, 0, null, DateTime.Now, TS, ReadoutType.MomentaryValues, FieldStatus.AutomaticReadout, string.Empty));
                }
                catch (Exception ex)
                {
                    this.LogError(ex.Message);
                }
            }
            else if (s != null)
            {
                this.LogError(String(39, "Unable to parse duration value: %0%", s));
            }
            else
            {
                this.LogError(String(40, "Unable to parse duration value."));
            }

            return(Result);
        }
 /// <summary>
 /// Enumeration valued field.
 /// </summary>
 /// <param name="Node">Node</param>
 /// <param name="FieldName">Name of field</param>
 /// <param name="StringIds">Corresponding String IDs</param>
 /// <param name="Timepoint">Timepoint of field value.</param>
 /// <param name="EnumType">Enum Type</param>
 /// <param name="EnumValue">Enum Value</param>
 /// <param name="Type">Type of value.</param>
 /// <param name="Status">Field status. Default value is <see cref="FieldStatus.AutomaticReadout"/>.</param>
 /// <param name="LanguageModule">Language Module to use for localization purposes. This parameter is optional. If
 /// not specified, or if empty or null, the language module of the metering library will be used.</param>
 public FieldEnum(string NodeId, string FieldName, FieldLanguageStep[] StringIds, DateTime Timepoint,
                  string ValueType, string Value, ReadoutType Type, FieldStatus Status, string LanguageModule)
     : base(NodeId, FieldName, StringIds, Timepoint, Type, Status, LanguageModule)
 {
     this.value    = Value;
     this.dataType = ValueType;
 }
Пример #6
0
        public override List <Field> ParseContent(object Content, ReadoutType Types, DateTime From, DateTime To)
        {
            List <Field> Result = new List <Field>();
            string       s      = Content as string;
            DateTime     TP;

            if (!string.IsNullOrEmpty(s) && (XmlUtilities.TryParseDateTimeXml(s, out TP) || (TP = Web.ParseDateTimeRfc822(s)) != DateTime.MinValue))
            {
                try
                {
                    Result.Add(new FieldDateTime(this, this.FieldName, 0, null, DateTime.Now, TP, ReadoutType.MomentaryValues, FieldStatus.AutomaticReadout, string.Empty));
                }
                catch (Exception ex)
                {
                    this.LogError(ex.Message);
                }
            }
            else if (s != null)
            {
                this.LogError(String(41, "Unable to parse date & time value: %0%", s));
            }
            else
            {
                this.LogError(String(42, "Unable to parse date & time value."));
            }

            return(Result);
        }
 /// <summary>
 /// Represents a request for sensor data.
 /// </summary>
 /// <param name="Types">Readout types to read.</param>
 /// <param name="From">From what timestamp readout is desired.</param>
 /// <param name="To">To what timestamp readout is desired.</param>
 /// <param name="Nodes">Nodes to read.</param>
 public ReadoutRequest(ReadoutType Types, DateTime From, DateTime To, NodeReference[] Nodes)
 {
     this.types = Types;
     this.from  = From;
     this.to    = To;
     this.nodes = Nodes;
 }
 /// <summary>
 /// Enumeration valued field.
 /// </summary>
 /// <param name="Node">Node</param>
 /// <param name="FieldName">Name of field</param>
 /// <param name="StringId">Corresponding String ID</param>
 /// <param name="Timepoint">Timepoint of field value.</param>
 /// <param name="Value">Value</param>
 /// <param name="Type">Type of value.</param>
 /// <param name="Status">Field status. Default value is <see cref="FieldStatus.AutomaticReadout"/>.</param>
 /// <param name="LanguageModule">Language Module to use for localization purposes. This parameter is optional. If
 /// not specified, or if empty or null, the language module of the metering library will be used.</param>
 public FieldEnum(string NodeId, string FieldName, int StringId, DateTime Timepoint,
                  Enum Value, ReadoutType Type, FieldStatus Status, string LanguageModule)
     : base(NodeId, FieldName, StringId, Timepoint, Type, LanguageModule)
 {
     this.value    = Value.ToString();
     this.dataType = Value.GetType().FullName;
 }
Пример #9
0
		/// <summary>
		/// Represents a request for sensor data.
		/// </summary>
		/// <param name="Types">Readout types to read.</param>
		/// <param name="From">From what timestamp readout is desired.</param>
		/// <param name="To">To what timestamp readout is desired.</param>
		/// <param name="Nodes">Nodes to read.</param>
		public ReadoutRequest (ReadoutType Types, DateTime From, DateTime To, NodeReference[] Nodes)
		{
			this.types = Types;
			this.from = From;
			this.to = To;
			this.nodes = Nodes;
		}
        public override List <Field> ParseContent(object Content, ReadoutType Types, DateTime From, DateTime To)
        {
            List <Field>      Result = new List <Field>();
            string            s      = Content as string;
            PhysicalMagnitude M;

            if (!string.IsNullOrEmpty(s) && PhysicalMagnitude.TryParse(s, out M))
            {
                try
                {
                    Result.Add(new FieldNumeric(this, this.FieldName, 0, null, DateTime.Now, M.Value, M.NrDecimals, M.Unit, ReadoutType.MomentaryValues, FieldStatus.AutomaticReadout, string.Empty));
                }
                catch (Exception ex)
                {
                    this.LogError(ex.Message);
                }
            }
            else if (s != null)
            {
                this.LogError(String(45, "Unable to parse physical magnitude value: %0%", s));
            }
            else
            {
                this.LogError(String(46, "Unable to parse physical magnitude value."));
            }

            return(Result);
        }
Пример #11
0
        public override List <Field> ProcessReadoutRequest(ReadoutType Types, DateTime From, DateTime To)
        {
            String           Path   = this.resource;
            EditableTreeNode Node   = this.Parent;
            CoapServer       Server = null;
            CoapFolder       Folder;

            while (Node != null)
            {
                if ((Folder = Node as CoapFolder) != null)
                {
                    Path = Folder.Folder + "/" + Path;
                }
                else if ((Server = Node as CoapServer) != null)
                {
                    break;
                }

                Node = Node.Parent;
            }

            if (Server == null)
            {
                throw new Exception("No CoAP Server node found.");
            }

            CoapEndpoint Endpoint = Server.Endpoint;
            CoapResponse Response = Endpoint.GET(true, Server.Host, Server.Port, Path, this.query, 20000);

            return(this.ParseContent(Response.Response, Types, From, To));
        }
 /// <summary>
 /// Enumeration valued field.
 /// </summary>
 /// <param name="Node">Node</param>
 /// <param name="FieldName">Name of field</param>
 /// <param name="StringIds">Corresponding String IDs</param>
 /// <param name="LocalizationSeed">Localization seed, i.e. the default string for creating
 /// a localized field name.</param>
 /// <param name="Timepoint">Timepoint of field value.</param>
 /// <param name="EnumType">Enum Type</param>
 /// <param name="EnumValue">Enum Value</param>
 /// <param name="Type">Type of value.</param>
 /// <param name="Status">Field status. Default value is <see cref="FieldStatus.AutomaticReadout"/>.</param>
 /// <param name="LanguageModule">Language Module to use for localization purposes. This parameter is optional. If
 /// not specified, or if empty or null, the language module of the metering library will be used.</param>
 public FieldEnum(string NodeId, string FieldName, int[] StringIds, string LocalizationSeed,
                  DateTime Timepoint, string EnumType, string EnumValue, ReadoutType Type, FieldStatus Status, string LanguageModule)
     : base(NodeId, FieldName, StringIds, LocalizationSeed, Timepoint, Type, Status, LanguageModule)
 {
     this.value    = EnumValue;
     this.dataType = EnumType;
 }
        public override List <Field> ParseContent(object Content, ReadoutType Types, DateTime From, DateTime To)
        {
            List <Field> Result = new List <Field>();
            string       s      = Content as string;
            double       d;
            int          NrDec;

            if (!string.IsNullOrEmpty(s) && XmlUtilities.TryParseDouble(s, out d, out NrDec))
            {
                try
                {
                    Result.Add(new FieldNumeric(this, this.FieldName, 0, null, DateTime.Now, d, NrDec, string.Empty, ReadoutType.MomentaryValues, FieldStatus.AutomaticReadout, string.Empty));
                }
                catch (Exception ex)
                {
                    this.LogError(ex.Message);
                }
            }
            else if (s != null)
            {
                this.LogError(String(43, "Unable to parse numeric value: %0%", s));
            }
            else
            {
                this.LogError(String(44, "Unable to parse numeric value."));
            }

            return(Result);
        }
Пример #14
0
		/// <summary>
		/// Numeric valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringIds">Corresponding String IDs</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="Value">Value</param>
		/// <param name="NrDecimals">Number of decimals to use.</param>
		/// <param name="Unit">Unit corresponding to the value.</param>
		/// <param name="Type">Type of value.</param>
		public FieldNumeric(string NodeId, string FieldName, int[] StringIds, DateTime Timepoint,
			double Value, int NrDecimals, string Unit, ReadoutType Type)
			: base(NodeId, FieldName, StringIds, Timepoint, Type)
		{
			this.unit = Unit;
			this.value = Value;
			this.nrDecimals = NrDecimals;
		}
Пример #15
0
		/// <summary>
		/// Numeric valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringId">Corresponding String ID</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="Value">Value</param>
		/// <param name="Type">Type of value.</param>
		public FieldNumeric(string NodeId, string FieldName, int StringId, DateTime Timepoint,
			long Value, ReadoutType Type)
			: base(NodeId, FieldName, StringId, Timepoint, Type)
		{
			this.unit = string.Empty;
			this.value = Value;
			this.nrDecimals = 0;
		}
Пример #16
0
        public override List <Field> ParseContent(object Content, ReadoutType Types, DateTime From, DateTime To)
        {
            List <Field> Result = new List <Field>();
            DateTime     TP     = DateTime.Now;

            this.ReportFields(Content, Result, this.Resource, TP, this, true);

            return(Result);
        }
Пример #17
0
		/// <summary>
		/// Base class of all field values.
		/// </summary>
		/// <param name="NodeId">Node ID</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringIds">Corresponding String IDs</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="Type">Type of value.</param>
		public Field (string NodeId, string FieldName, FieldLanguageStep[] StringIds, DateTime Timepoint, ReadoutType Type)
		{
			this.nodeId = NodeId;
			this.fieldName = FieldName;
			this.timepoint = Timepoint;
			this.type = Type;
			this.languageModule = null;
			this.stringIds = StringIds;
			this.status = FieldStatus.AutomaticReadout;
		}
Пример #18
0
		/// <summary>
		/// Represents a request for sensor data.
		/// </summary>
		/// <param name="Types">Readout types to read.</param>
		/// <param name="From">From what timestamp readout is desired.</param>
		/// <param name="To">To what timestamp readout is desired.</param>
		/// <param name="Nodes">Nodes to read.</param>
		/// <param name="Fields">Fields</param>
		public ReadoutRequest (ReadoutType Types, DateTime From, DateTime To, NodeReference[] Nodes, IEnumerable<string> Fields)
		{
			this.types = Types;
			this.from = From;
			this.to = To;
			this.nodes = Nodes;

			this.fields = new SortedDictionary<string, bool> ();

			foreach (string Field in Fields)
				this.fields [Field] = true;
		}
        /// <summary>
        /// Represents a request for sensor data.
        /// </summary>
        /// <param name="Types">Readout types to read.</param>
        /// <param name="From">From what timestamp readout is desired.</param>
        /// <param name="To">To what timestamp readout is desired.</param>
        /// <param name="Nodes">Nodes to read.</param>
        /// <param name="Fields">Fields</param>
        public ReadoutRequest(ReadoutType Types, DateTime From, DateTime To, NodeReference[] Nodes, IEnumerable <string> Fields)
        {
            this.types = Types;
            this.from  = From;
            this.to    = To;
            this.nodes = Nodes;

            this.fields = new SortedDictionary <string, bool> ();

            foreach (string Field in Fields)
            {
                this.fields [Field] = true;
            }
        }
        public override List <Field> ParseContent(object Content, ReadoutType Types, DateTime From, DateTime To)
        {
            List <Field> Result = null;
            XmlDocument  Doc    = Content as XmlDocument;

            if (Doc != null)
            {
                if (Doc.DocumentElement.LocalName == "fields")
                {
                    Result = FieldResult.GetFieldsFromXmppXep0323Xml(Doc.DocumentElement, this);
                }
                else if (Doc.DocumentElement.LocalName == "failure")
                {
                    XmlElement ErrorElement;
                    DateTime   Timestamp;

                    foreach (XmlNode N in Doc.DocumentElement.ChildNodes)
                    {
                        ErrorElement = N as XmlElement;
                        if (ErrorElement == null || ErrorElement.LocalName != "error")
                        {
                            continue;
                        }

                        Timestamp = XmlUtilities.GetAttribute(ErrorElement, "timestamp", DateTime.MinValue);
                        if (Timestamp == DateTime.MinValue)
                        {
                            continue;
                        }

                        this.LogError(ErrorElement.InnerText);
                    }
                }
                else
                {
                    this.LogError(String(52, "Content not valid XMPP XEP-0323 XML."));
                }
            }
            else
            {
                this.LogError(String(49, "XML expected."));
            }

            if (Result == null)
            {
                Result = new List <Field>();
            }

            return(Result);
        }
Пример #21
0
        public override List <Field> ParseContent(object Content, ReadoutType Types, DateTime From, DateTime To)
        {
            List <Field> Result = new List <Field>();
            string       s      = Content as string;

            if (!string.IsNullOrEmpty(s))
            {
                Result.Add(new FieldString(this, this.FieldName, 0, null, DateTime.Now, s, ReadoutType.MomentaryValues, FieldStatus.AutomaticReadout, string.Empty));
            }
            else
            {
                this.LogError(String(47, "Unable to parse string value."));
            }

            return(Result);
        }
Пример #22
0
        public override List <Field> ParseContent(object Content, ReadoutType Types, DateTime From, DateTime To)
        {
            List <Field> Result = new List <Field>();
            XmlDocument  Doc    = Content as XmlDocument;

            if (Doc != null && Doc.DocumentElement != null)
            {
                this.ReportFields(Doc.DocumentElement, Result, Doc.DocumentElement.LocalName, DateTime.Now, this, true);
            }
            else
            {
                this.LogError(String(49, "XML expected."));
            }

            return(Result);
        }
Пример #23
0
        /// <summary>
        /// Exports a field.
        /// </summary>
        /// <param name="Field">Field.</param>
        public virtual void Field(Field Field)
        {
            ReadoutType Type = Field.Type;

            if ((Type & ReadoutType.HistoricalValuesYear) != 0)
            {
                this.Export(Field, ref this.historyYears, Field.FieldName, this.lastTimestamp);
            }
            else if ((Type & ReadoutType.HistoricalValuesQuarter) != 0)
            {
                this.Export(Field, ref this.historyQuarters, Field.FieldName, this.lastTimestamp);
            }
            else if ((Type & ReadoutType.HistoricalValuesMonth) != 0)
            {
                this.Export(Field, ref this.historyMonths, Field.FieldName, this.lastTimestamp);
            }
            else if ((Type & ReadoutType.HistoricalValuesWeek) != 0)
            {
                this.Export(Field, ref this.historyWeeks, Field.FieldName, this.lastTimestamp);
            }
            else if ((Type & ReadoutType.HistoricalValuesDay) != 0)
            {
                this.Export(Field, ref this.historyDays, Field.FieldName, this.lastTimestamp);
            }
            else if ((Type & ReadoutType.HistoricalValuesHour) != 0)
            {
                this.Export(Field, ref this.historyHours, Field.FieldName, this.lastTimestamp);
            }
            else if ((Type & ReadoutType.HistoricalValuesMinute) != 0)
            {
                this.Export(Field, ref this.historyMinutes, Field.FieldName, this.lastTimestamp);
            }
            else if ((Type & ReadoutType.HistoricalValuesSecond) != 0)
            {
                this.Export(Field, ref this.historySeconds, Field.FieldName, this.lastTimestamp);
            }
            else if ((Type & ReadoutType.HistoricalValuesOther) != 0)
            {
                this.Export(Field, ref this.historyOthers, Field.FieldName, this.lastTimestamp);
            }
            else
            {
                this.Export(Field, ref this.otherValues, this.lastTimestamp, Field.FieldName);
            }
        }
Пример #24
0
        public override List <Field> ParseContent(object Content, ReadoutType Types, DateTime From, DateTime To)
        {
            List <Field> Result = new List <Field>();
            XmlDocument  Doc    = Content as XmlDocument;

            if (Doc != null)
            {
                FieldResult[] FieldResults = FieldResult.FromXml(Doc, false, false);
                foreach (FieldResult Fields in FieldResults)
                {
                    Result.AddRange(Fields.Fields);
                }
            }
            else
            {
                this.LogError(String(49, "XML expected."));
            }

            return(Result);
        }
Пример #25
0
        public override List <Field> ParseContent(object Content, ReadoutType Types, DateTime From, DateTime To)
        {
            List <Field> Result = new List <Field>();
            string       s      = Content as string;
            bool         b;

            if (!string.IsNullOrEmpty(s) && XmlUtilities.TryParseBoolean(s, out b))
            {
                Result.Add(new FieldBoolean(this, this.FieldName, 0, null, DateTime.Now, b, ReadoutType.MomentaryValues, FieldStatus.AutomaticReadout, string.Empty));
            }
            else if (s != null)
            {
                this.LogError(String(37, "Unable to parse boolean value: %0%", s));
            }
            else
            {
                this.LogError(String(38, "Unable to parse boolean value."));
            }

            return(Result);
        }
        /// <summary>
        /// Represents a request for sensor data.
        /// </summary>
        /// <param name="Req">Readout request element.</param>
        public ReadoutRequest(XmlElement Req)
        {
            this.from         = XmlUtilities.GetAttribute(Req, "from", DateTime.MinValue);
            this.to           = XmlUtilities.GetAttribute(Req, "to", DateTime.MaxValue);
            this.serviceToken = XmlUtilities.GetAttribute(Req, "serviceToken", string.Empty);
            this.deviceToken  = XmlUtilities.GetAttribute(Req, "deviceToken", string.Empty);
            this.userToken    = XmlUtilities.GetAttribute(Req, "userToken", string.Empty);
            this.types        = ParseReadoutType(Req);

            List <NodeReference> Nodes;
            List <string>        FieldNames;

            ParseNodesAndFieldNames(Req, out Nodes, out FieldNames);

            if (Nodes != null)
            {
                this.nodes = Nodes.ToArray();
            }

            if (FieldNames != null)
            {
                this.SetFields(FieldNames.ToArray());
            }
        }
Пример #27
0
		/// <summary>
		/// DateTime valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringId">Corresponding String ID</param>
		/// <param name="LocalizationSeed">Localization seed, i.e. the default string for creating
		/// a localized field name.</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="Value">Value</param>
		/// <param name="Type">Type of value.</param>
		public FieldDateTime(string NodeId, string FieldName, int StringId, string LocalizationSeed,
			DateTime Timepoint, DateTime Value, ReadoutType Type)
			: base(NodeId, FieldName, StringId, LocalizationSeed, Timepoint, Type)
		{
			this.value = Value;
		}
Пример #28
0
		/// <summary>
		/// Enumeration valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringId">Corresponding String ID</param>
		/// <param name="LocalizationSeed">Localization seed, i.e. the default string for creating
		/// a localized field name.</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="Value">Value</param>
		/// <param name="Type">Type of value.</param>
		public FieldEnum(string NodeId, string FieldName, int StringId, string LocalizationSeed, 
			DateTime Timepoint, Enum Value, ReadoutType Type)
			: base(NodeId, FieldName, StringId, LocalizationSeed, Timepoint, Type)
		{
			this.value = Value.ToString();
			this.dataType = Value.GetType ().FullName;
		}
Пример #29
0
		/// <summary>
		/// Represents a request for sensor data.
		/// </summary>
		/// <param name="Types">Readout types to read.</param>
		public ReadoutRequest (ReadoutType Types)
		{
			this.types = Types;
		}
Пример #30
0
		/// <summary>
		/// Enumeration valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringId">Corresponding String ID</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="Value">Value</param>
		/// <param name="Type">Type of value.</param>
		/// <param name="Status">Field status. Default value is <see cref="FieldStatus.AutomaticReadout"/>.</param>
		/// <param name="LanguageModule">Language Module to use for localization purposes. This parameter is optional. If
		/// not specified, or if empty or null, the language module of the metering library will be used.</param>
		public FieldEnum(string NodeId, string FieldName, int StringId, DateTime Timepoint,
			Enum Value, ReadoutType Type, FieldStatus Status, string LanguageModule)
			: base(NodeId, FieldName, StringId, Timepoint, Type, LanguageModule)
		{
			this.value = Value.ToString();
			this.dataType = Value.GetType ().FullName;
		}
Пример #31
0
		/// <summary>
		/// Enumeration valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringIds">Corresponding String IDs</param>
		/// <param name="LocalizationSeed">Localization seed, i.e. the default string for creating
		/// a localized field name.</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="EnumType">Enum Type</param>
		/// <param name="EnumValue">Enum Value</param>
		/// <param name="Type">Type of value.</param>
		/// <param name="Status">Field status. Default value is <see cref="FieldStatus.AutomaticReadout"/>.</param>
		/// <param name="LanguageModule">Language Module to use for localization purposes. This parameter is optional. If
		/// not specified, or if empty or null, the language module of the metering library will be used.</param>
		public FieldEnum(string NodeId, string FieldName, int[] StringIds, string LocalizationSeed,
			DateTime Timepoint, string EnumType, string EnumValue, ReadoutType Type, FieldStatus Status, string LanguageModule)
			: base(NodeId, FieldName, StringIds, LocalizationSeed, Timepoint, Type, Status, LanguageModule)
		{
			this.value = EnumValue;
			this.dataType = EnumType;
		}
		/// <summary>
		/// Exports a numerical field.
		/// </summary>
		/// <param name="FieldName">Field name.</param>
		/// <param name="Value">Value.</param>
		/// <param name="NrDecimals">Number of decimals.</param>
		/// <param name="Unit">Unit.</param>
		/// <param name="Type">Type.</param>
		public void ExportField (string FieldName, double Value, int NrDecimals, string Unit, ReadoutType Type)
		{
			Export.ExportField (this.xml, FieldName, Value, NrDecimals, Unit, Type);
		}
Пример #33
0
		/// <summary>
		/// Exports a TimeSpan field.
		/// </summary>
		/// <param name="Xml">XML Output</param>
		/// <param name="FieldName">Field name.</param>
		/// <param name="Value">Value.</param>
		/// <param name="Type">Type.</param>
		public static void ExportField (XmlWriter Xml, string FieldName, TimeSpan Value, ReadoutType Type)
		{
			ExportField (Xml, new FieldTimeSpan (string.Empty, FieldName, (FieldLanguageStep[])null, DateTime.MinValue, Value, Type, FieldStatus.AutomaticReadout));
		}
Пример #34
0
		private static void Export (ISensorDataExport Output, IEnumerable<Record> History, ReadoutType Type, ReadoutRequest Request)
		{
			if ((Request.Types & Type) != 0)
			{
				foreach (Record Rec in History)
				{
					if (!Request.ReportTimestamp (Rec.Timestamp))
						continue;

					Output.StartTimestamp (Rec.Timestamp);

					if (Request.ReportField ("Temperature"))
						Output.ExportField ("Temperature", Rec.TemperatureC, 1, "C", Type);

					if (Request.ReportField ("Light"))
						Output.ExportField ("Light", Rec.LightPercent, 1, "%", Type);

					if (Request.ReportField ("Motion"))
						Output.ExportField ("Motion", Rec.Motion, Type);

					Output.EndTimestamp ();
				}
			}
		}
		/// <summary>
		/// Exports a TimeSpan field.
		/// </summary>
		/// <param name="FieldName">Field name.</param>
		/// <param name="Value">Value.</param>
		/// <param name="Type">Type.</param>
		public void ExportField (string FieldName, TimeSpan Value, ReadoutType Type)
		{
			Export.ExportField (this.turtle, FieldName, Value, Type);
		}
Пример #36
0
 /// <summary>
 /// Exports an enumeration field.
 /// </summary>
 /// <param name="FieldName">Field name.</param>
 /// <param name="Value">Value.</param>
 /// <param name="Type">Type.</param>
 public void ExportField(string FieldName, Enum Value, ReadoutType Type)
 {
     this.Field(new FieldEnum(this.lastNodeId, FieldName, 0, this.lastTimestamp, Value, Type));
 }
Пример #37
0
 /// <summary>
 /// Exports a numerical field.
 /// </summary>
 /// <param name="FieldName">Field name.</param>
 /// <param name="Value">Value.</param>
 /// <param name="NrDecimals">Number of decimals.</param>
 /// <param name="Unit">Unit.</param>
 /// <param name="Type">Type.</param>
 public void ExportField(string FieldName, double Value, int NrDecimals, string Unit, ReadoutType Type)
 {
     this.Field(new FieldNumeric(this.lastNodeId, FieldName, 0, this.lastTimestamp, Value, NrDecimals, Unit, Type));
 }
Пример #38
0
 /// <summary>
 /// Exports a TimeSpan field.
 /// </summary>
 /// <param name="FieldName">Field name.</param>
 /// <param name="Value">Value.</param>
 /// <param name="Type">Type.</param>
 /// <param name="Status">Status.</param>
 public void ExportField(string FieldName, TimeSpan Value, ReadoutType Type, FieldStatus Status)
 {
     this.Field(new FieldTimeSpan(this.lastNodeId, FieldName, 0, this.lastTimestamp, Value, Type, Status));
 }
		/// <summary>
		/// Exports a numerical field.
		/// </summary>
		/// <param name="FieldName">Field name.</param>
		/// <param name="Value">Value.</param>
		/// <param name="NrDecimals">Number of decimals.</param>
		/// <param name="Unit">Unit.</param>
		/// <param name="Type">Type.</param>
		/// <param name="Status">Status.</param>
		public void ExportField (string FieldName, double Value, int NrDecimals, string Unit, ReadoutType Type, FieldStatus Status)
		{
			Export.ExportField (this.turtle, FieldName, Value, NrDecimals, Unit, Type, Status);
		}
Пример #40
0
 /// <summary>
 /// TimeSpan valued fields.
 /// </summary>
 /// <param name="Node">Node</param>
 /// <param name="FieldName">Name of field</param>
 /// <param name="StringId">Corresponding String ID</param>
 /// <param name="LocalizationSeed">Localization seed, i.e. the default string for creating
 /// a localized field name.</param>
 /// <param name="Timepoint">Timepoint of field value.</param>
 /// <param name="Value">Value</param>
 /// <param name="Type">Type of value.</param>
 public FieldTimeSpan(string NodeId, string FieldName, int StringId, string LocalizationSeed,
                      DateTime Timepoint, TimeSpan Value, ReadoutType Type)
     : base(NodeId, FieldName, StringId, LocalizationSeed, Timepoint, Type)
 {
     this.value = Value;
 }
		/// <summary>
		/// Exports a TimeSpan field.
		/// </summary>
		/// <param name="FieldName">Field name.</param>
		/// <param name="Value">Value.</param>
		/// <param name="Type">Type.</param>
		/// <param name="Status">Status.</param>
		public void ExportField (string FieldName, TimeSpan Value, ReadoutType Type, FieldStatus Status)
		{
			Export.ExportField (this.xml, FieldName, Value, Type, Status);
		}
Пример #42
0
		/// <summary>
		/// DateTime valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringIds">Corresponding String IDs</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="Value">Value</param>
		/// <param name="Type">Type of value.</param>
		public FieldDateTime(string NodeId, string FieldName, FieldLanguageStep[] StringIds, DateTime Timepoint,
			DateTime Value, ReadoutType Type)
			: base(NodeId, FieldName, StringIds, Timepoint, Type)
		{
			this.value = Value;
		}
		/// <summary>
		/// Exports an enumeration field.
		/// </summary>
		/// <param name="FieldName">Field name.</param>
		/// <param name="Value">Value.</param>
		/// <param name="Type">Type.</param>
		public void ExportField (string FieldName, Enum Value, ReadoutType Type)
		{
			Export.ExportField (this.xml, FieldName, Value, Type);
		}
 /// <summary>
 /// Enumeration valued field.
 /// </summary>
 /// <param name="Node">Node</param>
 /// <param name="FieldName">Name of field</param>
 /// <param name="StringId">Corresponding String ID</param>
 /// <param name="Timepoint">Timepoint of field value.</param>
 /// <param name="EnumType">Enum Type</param>
 /// <param name="EnumValue">Enum Value</param>
 /// <param name="Type">Type of value.</param>
 /// <param name="Status">Field status. Default value is <see cref="FieldStatus.AutomaticReadout"/>.</param>
 public FieldEnum(string NodeId, string FieldName, int StringId, DateTime Timepoint, string EnumType, string EnumValue, ReadoutType Type, FieldStatus Status)
     : base(NodeId, FieldName, StringId, Timepoint, Type, Status)
 {
     this.value    = EnumValue;
     this.dataType = EnumType;
 }
Пример #45
0
		/// <summary>
		/// Enumeration valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringId">Corresponding String ID</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="EnumType">Enum Type</param>
		/// <param name="EnumValue">Enum Value</param>
		/// <param name="Type">Type of value.</param>
		/// <param name="Status">Field status. Default value is <see cref="FieldStatus.AutomaticReadout"/>.</param>
		public FieldEnum(string NodeId, string FieldName, int StringId, DateTime Timepoint, string EnumType, string EnumValue, ReadoutType Type, FieldStatus Status)
			: base(NodeId, FieldName, StringId, Timepoint, Type, Status)
		{
			this.value = EnumValue;
			this.dataType = EnumType;
		}
Пример #46
0
		/// <summary>
		/// DateTime valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringIds">Corresponding String IDs</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="Value">Value</param>
		/// <param name="Type">Type of value.</param>
		/// <param name="Status">Field status. Default value is <see cref="FieldStatus.AutomaticReadout"/>.</param>
		/// <param name="LanguageModule">Language Module to use for localization purposes. This parameter is optional. If
		/// not specified, or if empty or null, the language module of the metering library will be used.</param>
		public FieldDateTime(string NodeId, string FieldName, int[] StringIds, DateTime Timepoint,
			DateTime Value, ReadoutType Type, FieldStatus Status, string LanguageModule)
			: base(NodeId, FieldName, StringIds, Timepoint, Type, Status, LanguageModule)
		{
			this.value = Value;
		}
Пример #47
0
		/// <summary>
		/// Enumeration valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringIds">Corresponding String IDs</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="EnumType">Enum Type</param>
		/// <param name="EnumValue">Enum Value</param>
		/// <param name="Type">Type of value.</param>
		/// <param name="Status">Field status. Default value is <see cref="FieldStatus.AutomaticReadout"/>.</param>
		/// <param name="LanguageModule">Language Module to use for localization purposes. This parameter is optional. If
		/// not specified, or if empty or null, the language module of the metering library will be used.</param>
		public FieldEnum(string NodeId, string FieldName, FieldLanguageStep[] StringIds, DateTime Timepoint,
			string ValueType, string Value, ReadoutType Type, FieldStatus Status, string LanguageModule)
			: base(NodeId, FieldName, StringIds, Timepoint, Type, Status, LanguageModule)
		{
			this.value = Value;
			this.dataType = ValueType;
		}
Пример #48
0
		/// <summary>
		/// DateTime valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringId">Corresponding String ID</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="Value">Value</param>
		/// <param name="Type">Type of value.</param>
		/// <param name="Status">Field status. Default value is <see cref="FieldStatus.AutomaticReadout"/>.</param>
		public FieldDateTime(string NodeId, string FieldName, int StringId, DateTime Timepoint,
			DateTime Value, ReadoutType Type, FieldStatus Status)
			: base(NodeId, FieldName, StringId, Timepoint, Type, Status)
		{
			this.value = Value;
		}
Пример #49
0
		/// <summary>
		/// Exports an enumeration field.
		/// </summary>
		/// <param name="Xml">XML Output</param>
		/// <param name="FieldName">Field name.</param>
		/// <param name="Value">Value.</param>
		/// <param name="Type">Type.</param>
		/// <param name="Status">Status.</param>
		public static void ExportField (XmlWriter Xml, string FieldName, Enum Value, ReadoutType Type, FieldStatus Status)
		{
			ExportField (Xml, new FieldEnum (string.Empty, FieldName, (FieldLanguageStep[])null, DateTime.MinValue, Value, Type, Status));
		}
Пример #50
0
		/// <summary>
		/// Exports an enumeration field.
		/// </summary>
		/// <param name="Json">JSON Output</param>
		/// <param name="FieldName">Field name.</param>
		/// <param name="Value">Value.</param>
		/// <param name="Type">Type.</param>
		public static void ExportField (JsonWriter Json, string FieldName, Enum Value, ReadoutType Type)
		{
			ExportField (Json, new FieldEnum (string.Empty, FieldName, (FieldLanguageStep[])null, DateTime.MinValue, Value, Type, FieldStatus.AutomaticReadout));
		}
Пример #51
0
		/// <summary>
		/// Represents a request for sensor data.
		/// </summary>
		/// <param name="Request">HTTP Request</param>
		public ReadoutRequest (HttpServerRequest Request)
		{
			string NodeId = string.Empty;
			string CacheType = string.Empty;
			string SourceId = string.Empty;
			bool b;

			foreach (KeyValuePair<string,string> Parameter in Request.Query)
			{
				switch (Parameter.Key.ToLower ())
				{
					case "nodeid":
						NodeId = Parameter.Value;
						break;

					case "cachetype":
						CacheType = Parameter.Value;
						break;

					case "sourceid":
						SourceId = Parameter.Value;
						break;

					case "all":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types = ReadoutType.All;
						else
							this.types = (ReadoutType)0;
						break;

					case "historical":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.HistoricalValues;
						else
							this.types &= ~ReadoutType.HistoricalValues;

						break;

					case "from":
						if (!XmlUtilities.TryParseDateTimeXml (Parameter.Value, out this.from))
							this.from = DateTime.MinValue;
						break;

					case "to":
						if (!XmlUtilities.TryParseDateTimeXml (Parameter.Value, out this.to))
							this.from = DateTime.MaxValue;
						break;

					case "when":
						throw new HttpException (HttpStatusCode.ClientError_BadRequest);	// Not supported through HTTP interface.
						
					case "servicetoken":
						this.serviceToken = Parameter.Value;
						break;

					case "devicetoken":
						this.deviceToken = Parameter.Value;
						break;

					case "usertoken":
						this.userToken = Parameter.Value;
						break;

					case "momentary":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.MomentaryValues;
						else
							this.types &= ~ReadoutType.MomentaryValues;
						break;

					case "peak":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.PeakValues;
						else
							this.types &= ~ReadoutType.PeakValues;
						break;

					case "status":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.StatusValues;
						else
							this.types &= ~ReadoutType.StatusValues;
						break;

					case "computed":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.Computed;
						else
							this.types &= ~ReadoutType.Computed;
						break;

					case "identity":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.Identity;
						else
							this.types &= ~ReadoutType.Identity;
						break;

					case "historicalsecond":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.HistoricalValuesSecond;
						else
							this.types &= ~ReadoutType.HistoricalValuesSecond;
						break;

					case "historicalminute":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.HistoricalValuesMinute;
						else
							this.types &= ~ReadoutType.HistoricalValuesMinute;
						break;

					case "historicalhour":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.HistoricalValuesHour;
						else
							this.types &= ~ReadoutType.HistoricalValuesHour;
						break;

					case "historicalday":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.HistoricalValuesDay;
						else
							this.types &= ~ReadoutType.HistoricalValuesDay;
						break;

					case "historicalweek":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.HistoricalValuesWeek;
						else
							this.types &= ~ReadoutType.HistoricalValuesWeek;
						break;

					case "historicalmonth":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.HistoricalValuesMonth;
						else
							this.types &= ~ReadoutType.HistoricalValuesMonth;
						break;

					case "historicalquarter":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.HistoricalValuesQuarter;
						else
							this.types &= ~ReadoutType.HistoricalValuesQuarter;
						break;

					case "historicalyear":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.HistoricalValuesYear;
						else
							this.types &= ~ReadoutType.HistoricalValuesYear;
						break;

					case "historicalother":
						if (XmlUtilities.TryParseBoolean (Parameter.Value, out b) && b)
							this.types |= ReadoutType.HistoricalValuesOther;
						else
							this.types &= ~ReadoutType.HistoricalValuesOther;
						break;

					default:
						if (this.fields == null)
							this.fields = new SortedDictionary<string, bool> ();

						this.fields [Parameter.Key] = true;
						break;
				}
			}

			if ((int)this.types == 0)
				this.types = ReadoutType.All;	// If no types specified, all types are implicitly implied.

			if (!string.IsNullOrEmpty (NodeId))
				this.nodes = new NodeReference[]{ new NodeReference (NodeId, CacheType, SourceId) };
		}
Пример #52
0
		/// <summary>
		/// Exports a numerical field.
		/// </summary>
		/// <param name="Json">JSON Output</param>
		/// <param name="FieldName">Field name.</param>
		/// <param name="Value">Value.</param>
		/// <param name="NrDecimals">Number of decimals.</param>
		/// <param name="Unit">Unit.</param>
		/// <param name="Type">Type.</param>
		public static void ExportField (JsonWriter Json, string FieldName, double Value, int NrDecimals, string Unit, ReadoutType Type)
		{
			ExportField (Json, new FieldNumeric (string.Empty, FieldName, (FieldLanguageStep[])null, DateTime.MinValue, Value, NrDecimals, Unit, Type, FieldStatus.AutomaticReadout));
		}
Пример #53
0
		/// <summary>
		/// Represents a request for sensor data.
		/// </summary>
		/// <param name="Types">Readout types to read.</param>
		/// <param name="From">From what timestamp readout is desired.</param>
		/// <param name="To">To what timestamp readout is desired.</param>
		public ReadoutRequest (ReadoutType Types, DateTime From, DateTime To)
		{
			this.types = Types;
			this.from = From;
			this.to = To;
		}
Пример #54
0
		/// <summary>
		/// Exports a TimeSpan field.
		/// </summary>
		/// <param name="Json">JSON Output</param>
		/// <param name="FieldName">Field name.</param>
		/// <param name="Value">Value.</param>
		/// <param name="Type">Type.</param>
		/// <param name="Status">Status.</param>
		public static void ExportField (JsonWriter Json, string FieldName, TimeSpan Value, ReadoutType Type, FieldStatus Status)
		{
			ExportField (Json, new FieldTimeSpan (string.Empty, FieldName, (FieldLanguageStep[])null, DateTime.MinValue, Value, Type, Status));
		}
Пример #55
0
 /// <summary>
 /// Exports a TimeSpan field.
 /// </summary>
 /// <param name="FieldName">Field name.</param>
 /// <param name="Value">Value.</param>
 /// <param name="Type">Type.</param>
 /// <param name="Status">Status.</param>
 public void ExportField(string FieldName, TimeSpan Value, ReadoutType Type, FieldStatus Status)
 {
     Export.ExportField(this.json, FieldName, Value, Type, Status);
 }
Пример #56
0
 /// <summary>
 /// Exports a numerical field.
 /// </summary>
 /// <param name="FieldName">Field name.</param>
 /// <param name="Value">Value.</param>
 /// <param name="NrDecimals">Number of decimals.</param>
 /// <param name="Unit">Unit.</param>
 /// <param name="Type">Type.</param>
 public void ExportField(string FieldName, double Value, int NrDecimals, string Unit, ReadoutType Type)
 {
     Export.ExportField(this.json, FieldName, Value, NrDecimals, Unit, Type);
 }
Пример #57
0
 public abstract List <Field> ParseContent(object Content, ReadoutType Types, DateTime From, DateTime To);
Пример #58
0
 /// <summary>
 /// Exports an enumeration field.
 /// </summary>
 /// <param name="FieldName">Field name.</param>
 /// <param name="Value">Value.</param>
 /// <param name="Type">Type.</param>
 public void ExportField(string FieldName, Enum Value, ReadoutType Type)
 {
     Export.ExportField(this.json, FieldName, Value, Type);
 }
Пример #59
0
        private static void Export(ISensorDataExport Output, IEnumerable <Record> History, ReadoutType Type, ReadoutRequest Request)
        {
            if ((Request.Types & Type) != 0)
            {
                foreach (Record Rec in History)
                {
                    if (!Request.ReportTimestamp(Rec.Timestamp))
                    {
                        continue;
                    }

                    Output.StartTimestamp(Rec.Timestamp);

                    if (Request.ReportField("Temperature"))
                    {
                        Output.ExportField("Temperature", Rec.TemperatureC, 1, "C", Type);
                    }

                    if (Request.ReportField("Light"))
                    {
                        Output.ExportField("Light", Rec.LightPercent, 1, "%", Type);
                    }

                    if (Request.ReportField("Motion"))
                    {
                        Output.ExportField("Motion", Rec.Motion, Type);
                    }

                    Output.EndTimestamp();
                }
            }
        }
		/// <summary>
		/// Exports an enumeration field.
		/// </summary>
		/// <param name="FieldName">Field name.</param>
		/// <param name="Value">Value.</param>
		/// <param name="Type">Type.</param>
		/// <param name="Status">Status.</param>
		public void ExportField (string FieldName, Enum Value, ReadoutType Type, FieldStatus Status)
		{
			Export.ExportField (this.turtle, FieldName, Value, Type, Status);
		}