Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MetaMeteringNode.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
4using Waher.Content;
10
12{
16 public abstract class MetaMeteringNode : MeteringNode
17 {
18 private string name = string.Empty; // NAME
19 private string className = string.Empty; // CLASS
20 private string serialNumber = string.Empty; // SN
21 private string meterNumber = string.Empty; // MNR
22 private string meterLocation = string.Empty; // MLOC
23 private string manufacturerDomain = string.Empty; // MAN
24 private string model = string.Empty; // MODEL
25 private string productUrl = string.Empty; // PURL
26
27 private string country = string.Empty; // COUNTRY
28 private string region = string.Empty; // REGION
29 private string city = string.Empty; // CITY
30 private string area = string.Empty; // AREA
31 private string street = string.Empty; // STREET
32 private string streetNr = string.Empty; // STREETNR
33 private string building = string.Empty; // BLD
34 private string apartment = string.Empty; // APT
35 private string room = string.Empty; // ROOM
36
37 private double? latitude = null; // LAT
38 private double? longitude = null; // LON
39 private double? altitude = null; // ALT
40 private double? version = null; // V
41
46 : base()
47 {
48 }
49
53 [Page(16, "Identity", 0)]
54 [Header(28, "Name:", 10)]
55 [ToolTip(29, "An additional name can be provided here.")]
56 [DefaultValueStringEmpty]
57 public string Name
58 {
59 get => this.name;
60 set => this.name = value;
61 }
62
66 [Page(16, "Identity", 0)]
67 [Header(31, "Class:", 20)]
68 [ToolTip(32, "Class of node.")]
69 [DefaultValueStringEmpty]
70 public string Class
71 {
72 get => this.className;
73 set => this.className = value;
74 }
75
79 [Page(16, "Identity", 0)]
80 [Header(34, "Serial number:", 30)]
81 [ToolTip(35, "Serial number of device.")]
82 [DefaultValueStringEmpty]
83 public string SerialNumber
84 {
85 get => this.serialNumber;
86 set => this.serialNumber = value;
87 }
88
92 [Page(16, "Identity", 0)]
93 [Header(37, "Meter number:", 40)]
94 [ToolTip(38, "Additional identity of meter.")]
95 [DefaultValueStringEmpty]
96 public string MeterNumber
97 {
98 get => this.meterNumber;
99 set => this.meterNumber = value;
100 }
101
105 [Page(16, "Identity", 0)]
106 [Header(40, "Meter location:", 50)]
107 [ToolTip(41, "Identity of the location of the meter.")]
108 [DefaultValueStringEmpty]
109 public string MeterLocation
110 {
111 get => this.meterLocation;
112 set => this.meterLocation = value;
113 }
114
118 [Page(16, "Identity", 0)]
119 [Header(43, "Manufacturer domain:", 60)]
120 [ToolTip(44, "A domain controlled by the manufacturer.")]
121 [DefaultValueStringEmpty]
122 public string ManufacturerDomain
123 {
124 get => this.manufacturerDomain;
125 set => this.manufacturerDomain = value;
126 }
127
131 [Page(16, "Identity", 0)]
132 [Header(46, "Model:", 70)]
133 [ToolTip(47, "Model name of the device.")]
134 [DefaultValueStringEmpty]
135 public string Model
136 {
137 get => this.model;
138 set => this.model = value;
139 }
140
144 [Page(16, "Identity", 0)]
145 [Header(78, "Version:", 80)]
146 [ToolTip(79, "Version number of model of device.")]
147 [DefaultValueNull]
148 public double? Version
149 {
150 get => this.version;
151 set => this.version = value;
152 }
153
157 [Page(16, "Identity", 0)]
158 [Header(49, "Product URL:", 90)]
159 [ToolTip(50, "A URL with more information about the product.")]
160 [DefaultValueStringEmpty]
161 public string ProductUrl
162 {
163 get => this.productUrl;
164 set => this.productUrl = value;
165 }
166
170 [Page(51, "Location", 10)]
171 [Header(52, "Country:", 10)]
172 [ToolTip(53, "Country of device.")]
173 [DefaultValueStringEmpty]
174 public string Country
175 {
176 get => this.country;
177 set => this.country = value;
178 }
179
183 [Page(51, "Location", 10)]
184 [Header(55, "Region:", 20)]
185 [ToolTip(56, "Region of device.")]
186 [DefaultValueStringEmpty]
187 public string Region
188 {
189 get => this.region;
190 set => this.region = value;
191 }
192
196 [Page(51, "Location", 10)]
197 [Header(58, "City:", 30)]
198 [ToolTip(59, "City of device.")]
199 [DefaultValueStringEmpty]
200 public string City
201 {
202 get => this.city;
203 set => this.city = value;
204 }
205
209 [Page(51, "Location", 10)]
210 [Header(61, "Area:", 40)]
211 [ToolTip(62, "Area of device.")]
212 [DefaultValueStringEmpty]
213 public string Area
214 {
215 get => this.area;
216 set => this.area = value;
217 }
218
222 [Page(51, "Location", 10)]
223 [Header(64, "Street:", 50)]
224 [ToolTip(65, "Street device resides on.")]
225 [DefaultValueStringEmpty]
226 public string Street
227 {
228 get => this.street;
229 set => this.street = value;
230 }
231
235 [Page(51, "Location", 10)]
236 [Header(67, "Street number:", 60)]
237 [ToolTip(68, "Street number where device resides.")]
238 [DefaultValueStringEmpty]
239 public string StreetNr
240 {
241 get => this.streetNr;
242 set => this.streetNr = value;
243 }
244
248 public string StreetAndNr
249 {
250 get
251 {
252 if (string.IsNullOrEmpty(this.streetNr))
253 return this.street;
254 else if (string.IsNullOrEmpty(this.street))
255 return this.streetNr;
256 else
257 return this.street + " " + this.streetNr;
258 }
259 }
260
264 [Page(51, "Location", 10)]
265 [Header(69, "Building:", 70)]
266 [ToolTip(70, "Building device resides in.")]
267 [DefaultValueStringEmpty]
268 public string Building
269 {
270 get => this.building;
271 set => this.building = value;
272 }
273
277 [Page(51, "Location", 10)]
278 [Header(72, "Apartment:", 80)]
279 [ToolTip(73, "Apartment device resides in.")]
280 [DefaultValueStringEmpty]
281 public string Apartment
282 {
283 get => this.apartment;
284 set => this.apartment = value;
285 }
286
290 [Page(51, "Location", 10)]
291 [Header(75, "Room:", 90)]
292 [ToolTip(76, "Room device resides in.")]
293 [DefaultValueStringEmpty]
294 public string Room
295 {
296 get => this.room;
297 set => this.room = value;
298 }
299
303 [Page(81, "Position", 20)]
304 [Header(82, "Latitude:", 10)]
305 [ToolTip(83, "Latitude of device.")]
306 [DefaultValueNull]
307 [Range(-90, 90)]
308 public double? Latitude
309 {
310 get => this.latitude;
311 set => this.latitude = value;
312 }
313
317 [Page(81, "Position", 20)]
318 [Header(84, "Longitude:", 20)]
319 [ToolTip(85, "Longitude of device.")]
320 [DefaultValueNull]
321 [Range(-180, 180)]
322 public double? Longitude
323 {
324 get => this.longitude;
325 set => this.longitude = value;
326 }
327
331 [Page(81, "Position", 20)]
332 [Header(86, "Altitude:", 30)]
333 [ToolTip(87, "Altitude of device.")]
334 [DefaultValueNull]
335 public double? Altitude
336 {
337 get => this.altitude;
338 set => this.altitude = value;
339 }
340
347 public override async Task<IEnumerable<Parameter>> GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
348 {
349 LinkedList<Parameter> Result = await base.GetDisplayableParametersAsync(Language, Caller) as LinkedList<Parameter>;
350
351 if (!string.IsNullOrEmpty(this.name))
352 Result.AddLast(new StringParameter("Name", await Language.GetStringAsync(typeof(MeteringTopology), 30, "Name"), this.name));
353
354 if (!string.IsNullOrEmpty(this.className))
355 Result.AddLast(new StringParameter("Class", await Language.GetStringAsync(typeof(MeteringTopology), 33, "Class"), this.className));
356
357 if (!string.IsNullOrEmpty(this.serialNumber))
358 Result.AddLast(new StringParameter("SerialNumber", await Language.GetStringAsync(typeof(MeteringTopology), 36, "S/N"), this.serialNumber));
359
360 if (!string.IsNullOrEmpty(this.meterNumber))
361 Result.AddLast(new StringParameter("MeterNumber", await Language.GetStringAsync(typeof(MeteringTopology), 39, "Meter Nr."), this.meterNumber));
362
363 if (!string.IsNullOrEmpty(this.meterLocation))
364 Result.AddLast(new StringParameter("MeterLocation", await Language.GetStringAsync(typeof(MeteringTopology), 42, "Meter Loc."), this.meterLocation));
365
366 if (!string.IsNullOrEmpty(this.manufacturerDomain))
367 Result.AddLast(new StringParameter("Manufacturer", await Language.GetStringAsync(typeof(MeteringTopology), 45, "Manufacturer"), this.manufacturerDomain));
368
369 if (!string.IsNullOrEmpty(this.model))
370 Result.AddLast(new StringParameter("Model", await Language.GetStringAsync(typeof(MeteringTopology), 48, "Model"), this.model));
371
372 if (this.version.HasValue)
373 Result.AddLast(new StringParameter("Version", await Language.GetStringAsync(typeof(MeteringTopology), 80, "Version"), this.version.ToString()));
374
375 if (!string.IsNullOrEmpty(this.country))
376 Result.AddLast(new StringParameter("Country", await Language.GetStringAsync(typeof(MeteringTopology), 54, "Country"), this.country));
377
378 if (!string.IsNullOrEmpty(this.region))
379 Result.AddLast(new StringParameter("Region", await Language.GetStringAsync(typeof(MeteringTopology), 57, "Region"), this.region));
380
381 if (!string.IsNullOrEmpty(this.city))
382 Result.AddLast(new StringParameter("City", await Language.GetStringAsync(typeof(MeteringTopology), 60, "City"), this.city));
383
384 if (!string.IsNullOrEmpty(this.area))
385 Result.AddLast(new StringParameter("Area", await Language.GetStringAsync(typeof(MeteringTopology), 63, "Area"), this.area));
386
387 string s = this.StreetAndNr;
388 if (!string.IsNullOrEmpty(s))
389 Result.AddLast(new StringParameter("Street", await Language.GetStringAsync(typeof(MeteringTopology), 66, "Street"), s));
390
391 if (!string.IsNullOrEmpty(this.building))
392 Result.AddLast(new StringParameter("Building", await Language.GetStringAsync(typeof(MeteringTopology), 71, "Building"), this.building));
393
394 if (!string.IsNullOrEmpty(this.apartment))
395 Result.AddLast(new StringParameter("Apartment", await Language.GetStringAsync(typeof(MeteringTopology), 74, "Apartment"), this.apartment));
396
397 if (!string.IsNullOrEmpty(this.room))
398 Result.AddLast(new StringParameter("Room", await Language.GetStringAsync(typeof(MeteringTopology), 77, "Room"), this.room));
399
400 if (this.latitude.HasValue)
401 Result.AddLast(new StringParameter("Latitude", await Language.GetStringAsync(typeof(MeteringTopology), 88, "Latitude"), this.latitude.ToString()));
402
403 if (this.longitude.HasValue)
404 Result.AddLast(new StringParameter("Longitude", await Language.GetStringAsync(typeof(MeteringTopology), 89, "Longitude"), this.longitude.ToString()));
405
406 if (this.altitude.HasValue)
407 Result.AddLast(new StringParameter("Altitude", await Language.GetStringAsync(typeof(MeteringTopology), 90, "Altitude"), this.altitude.ToString()));
408
409 return Result;
410 }
411
416 public override async Task<KeyValuePair<string, object>[]> GetMetaData()
417 {
418 List<KeyValuePair<string, object>> Result = new List<KeyValuePair<string, object>>(await base.GetMetaData());
419
420 if (!string.IsNullOrEmpty(this.name))
421 Result.Add(new KeyValuePair<string, object>("NAME", this.name));
422
423 if (!string.IsNullOrEmpty(this.className))
424 Result.Add(new KeyValuePair<string, object>("CLASS", this.className));
425
426 if (!string.IsNullOrEmpty(this.serialNumber))
427 Result.Add(new KeyValuePair<string, object>("SN", this.serialNumber));
428
429 if (!string.IsNullOrEmpty(this.meterNumber))
430 Result.Add(new KeyValuePair<string, object>("MNR", this.meterNumber));
431
432 if (!string.IsNullOrEmpty(this.meterLocation))
433 Result.Add(new KeyValuePair<string, object>("MLOC", this.meterLocation));
434
435 if (!string.IsNullOrEmpty(this.manufacturerDomain))
436 Result.Add(new KeyValuePair<string, object>("MAN", this.manufacturerDomain));
437
438 if (!string.IsNullOrEmpty(this.model))
439 Result.Add(new KeyValuePair<string, object>("MODEL", this.model));
440
441 if (this.version.HasValue)
442 Result.Add(new KeyValuePair<string, object>("V", this.version.Value));
443
444 if (!string.IsNullOrEmpty(this.productUrl))
445 Result.Add(new KeyValuePair<string, object>("PURL", this.productUrl));
446
447 if (!string.IsNullOrEmpty(this.country))
448 Result.Add(new KeyValuePair<string, object>("COUNTRY", this.country));
449
450 if (!string.IsNullOrEmpty(this.region))
451 Result.Add(new KeyValuePair<string, object>("REGION", this.region));
452
453 if (!string.IsNullOrEmpty(this.city))
454 Result.Add(new KeyValuePair<string, object>("CITY", this.city));
455
456 if (!string.IsNullOrEmpty(this.area))
457 Result.Add(new KeyValuePair<string, object>("AREA", this.area));
458
459 if (!string.IsNullOrEmpty(this.street))
460 Result.Add(new KeyValuePair<string, object>("STREET", this.street));
461
462 if (!string.IsNullOrEmpty(this.streetNr))
463 Result.Add(new KeyValuePair<string, object>("STREETNR", this.streetNr));
464
465 if (!string.IsNullOrEmpty(this.building))
466 Result.Add(new KeyValuePair<string, object>("BLD", this.building));
467
468 if (!string.IsNullOrEmpty(this.apartment))
469 Result.Add(new KeyValuePair<string, object>("APT", this.apartment));
470
471 if (!string.IsNullOrEmpty(this.room))
472 Result.Add(new KeyValuePair<string, object>("ROOM", this.room));
473
474 if (this.latitude.HasValue)
475 Result.Add(new KeyValuePair<string, object>("LAT", this.latitude.Value));
476
477 if (this.longitude.HasValue)
478 Result.Add(new KeyValuePair<string, object>("LON", this.longitude.Value));
479
480 if (this.altitude.HasValue)
481 Result.Add(new KeyValuePair<string, object>("ALT", this.altitude.Value));
482
483 return Result.ToArray();
484 }
485
491 public virtual void AddIdentityReadout(List<Field> Fields, DateTime Now)
492 {
493 string Module = typeof(MeteringTopology).Namespace;
494
495 if (!string.IsNullOrEmpty(this.name))
496 Fields.Add(new StringField(this, Now, "Name", this.name, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 30));
497
498 if (!string.IsNullOrEmpty(this.className))
499 Fields.Add(new StringField(this, Now, "Class", this.className, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 33));
500
501 if (!string.IsNullOrEmpty(this.serialNumber))
502 Fields.Add(new StringField(this, Now, "Serial Number", this.serialNumber, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 91));
503
504 if (!string.IsNullOrEmpty(this.meterNumber))
505 Fields.Add(new StringField(this, Now, "Meter Number", this.meterNumber, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 92));
506
507 if (!string.IsNullOrEmpty(this.meterLocation))
508 Fields.Add(new StringField(this, Now, "Meter Location", this.meterLocation, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 93));
509
510 if (!string.IsNullOrEmpty(this.manufacturerDomain))
511 Fields.Add(new StringField(this, Now, "Manufacturer", this.manufacturerDomain, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 45));
512
513 if (!string.IsNullOrEmpty(this.model))
514 Fields.Add(new StringField(this, Now, "Model", this.model, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 48));
515
516 if (this.version.HasValue)
517 Fields.Add(new QuantityField(this, Now, "Version", this.version.Value, CommonTypes.GetNrDecimals(this.version.Value), string.Empty, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 80));
518
519 if (!string.IsNullOrEmpty(this.country))
520 Fields.Add(new StringField(this, Now, "Country", this.country, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 54));
521
522 if (!string.IsNullOrEmpty(this.region))
523 Fields.Add(new StringField(this, Now, "Region", this.region, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 57));
524
525 if (!string.IsNullOrEmpty(this.city))
526 Fields.Add(new StringField(this, Now, "City", this.city, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 60));
527
528 if (!string.IsNullOrEmpty(this.area))
529 Fields.Add(new StringField(this, Now, "Area", this.area, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 63));
530
531 string s = this.StreetAndNr;
532 if (!string.IsNullOrEmpty(s))
533 Fields.Add(new StringField(this, Now, "Street", s, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 66));
534
535 if (!string.IsNullOrEmpty(this.building))
536 Fields.Add(new StringField(this, Now, "Building", this.building, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 71));
537
538 if (!string.IsNullOrEmpty(this.apartment))
539 Fields.Add(new StringField(this, Now, "Apartment", this.apartment, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 74));
540
541 if (!string.IsNullOrEmpty(this.room))
542 Fields.Add(new StringField(this, Now, "Room", this.room, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 77));
543
544 if (this.latitude.HasValue)
545 Fields.Add(new QuantityField(this, Now, "Latitude", this.latitude.Value, CommonTypes.GetNrDecimals(this.latitude.Value), string.Empty, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 88));
546
547 if (this.longitude.HasValue)
548 Fields.Add(new QuantityField(this, Now, "Longitude", this.longitude.Value, CommonTypes.GetNrDecimals(this.longitude.Value), string.Empty, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 89));
549
550 if (this.altitude.HasValue)
551 Fields.Add(new QuantityField(this, Now, "Altitude", this.altitude.Value, CommonTypes.GetNrDecimals(this.altitude.Value), string.Empty, FieldType.Identity, FieldQoS.AutomaticReadout, Module, 90));
552 }
553
554 }
555}
Helps with parsing of commong data types.
Definition: CommonTypes.cs:13
static byte GetNrDecimals(double x)
Calculates the number of decimals of a floating-point number.
Definition: CommonTypes.cs:903
Contains information about a language.
Definition: Language.cs:17
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Definition: Language.cs:209
Base class for metering nodes with interoperable meta-information.
MetaMeteringNode()
Base class for metering nodes with interoperable meta-information.
string ManufacturerDomain
Manufacturer (domain)
virtual void AddIdentityReadout(List< Field > Fields, DateTime Now)
Adds defined identity fields to a sensor data readout.
override async Task< KeyValuePair< string, object >[]> GetMetaData()
Gets meta-data about the node.
string Name
If the node is provisioned is not. Property is editable.
string StreetAndNr
Combination of both Street and StreetNr.
string Class
A class name or the node.
override async Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
Base class for all metering nodes.
Definition: MeteringNode.cs:28
Defines the Metering Topology data source. This data source contains a tree structure of persistent r...
Tokens available in request.
Definition: RequestOrigin.cs:9
Represents a physical quantity value.
Represents a string value.
Definition: StringField.cs:10
FieldQoS
Field Quality of Service flags
Definition: FieldQoS.cs:10
FieldType
Field Type flags
Definition: FieldType.cs:10