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