Compare commits
22 Commits
c4f16fb36d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 756cc4bd20 | |||
|
|
a12c083b3f | ||
| 496c5688bc | |||
|
|
5a0c46cb67 | ||
|
|
b1ba23212d | ||
|
|
f6da9a6fc5 | ||
|
|
94da1a36e4 | ||
| 9a7b5a93ed | |||
|
|
be7c929600 | ||
|
|
de76803f7e | ||
|
|
bef39bc533 | ||
|
|
6aa6a226ea | ||
|
|
4e2cdb389e | ||
|
|
625e0dd7e8 | ||
|
|
edf9b09af1 | ||
|
|
b4803e5e9b | ||
|
|
b3f1fad74e | ||
|
|
57f6ec9cde | ||
|
|
0feff2e0fe | ||
|
|
0f855a8d2f | ||
|
|
d05d521408 | ||
|
|
6f63415698 |
102
LICENSE
102
LICENSE
@@ -1,15 +1,97 @@
|
||||
MIT License
|
||||
OPENBARE LICENTIE VAN DE EUROPESE UNIE v. 1.2.
|
||||
EUPL © Europese Unie 2007, 2016
|
||||
Deze openbare licentie van de Europese Unie („EUPL”) is van toepassing op het werk (zoals hieronder gedefinieerd) dat onder de voorwaarden van deze licentie wordt verstrekt. Elk gebruik van het werk dat niet door deze licentie is toegestaan, is verboden (voor zover dit gebruik valt onder een recht van de houder van het auteursrecht op het werk). Het werk wordt verstrekt onder de voorwaarden van deze licentie wanneer de licentiegever (zoals hieronder gedefinieerd), direct volgend op de kennisgeving inzake het auteursrecht op het werk, de volgende kennisgeving opneemt:
|
||||
In licentie gegeven krachtens de EUPL
|
||||
of op een andere wijze zijn bereidheid te kennen heeft gegeven krachtens de EUPL in licentie te geven.
|
||||
|
||||
Copyright (c) 2025 Rene De Ren
|
||||
1.Definities
|
||||
In deze licentie wordt verstaan onder:
|
||||
— „de licentie”:de onderhavige licentie;
|
||||
— „het oorspronkelijke werk”:het werk dat of de software die door de licentiegever krachtens deze licentie wordt verspreid of medegedeeld, en dat/die beschikbaar is als broncode en, in voorkomend geval, ook als uitvoerbare code;
|
||||
— „bewerkingen”:de werken of software die de licentiehouder kan creëren op grond van het oorspronkelijke werk of wijzigingen ervan. In deze licentie wordt niet gedefinieerd welke mate van wijziging of afhankelijkheid van het oorspronkelijke werk vereist is om een werk als een bewerking te kunnen aanmerken; dat wordt bepaald conform het auteursrecht dat van toepassing is in de in artikel 15 bedoelde staat;
|
||||
— „het werk”:het oorspronkelijke werk of de bewerkingen ervan;
|
||||
— „de broncode”:de voor mensen leesbare vorm van het werk, die het gemakkelijkste door mensen kan worden bestudeerd en gewijzigd;
|
||||
— „de uitvoerbare code”:elke code die over het algemeen is gecompileerd en is bedoeld om door een computer als een programma te worden uitgevoerd;
|
||||
— „de licentiegever”:de natuurlijke of rechtspersoon die het werk krachtens de licentie verspreidt of mededeelt;
|
||||
— „bewerker(s)”:elke natuurlijke of rechtspersoon die het werk krachtens de licentie wijzigt of op een andere wijze bijdraagt tot de totstandkoming van een bewerking;
|
||||
— „de licentiehouder” of „u”:elke natuurlijke of rechtspersoon die het werk onder de voorwaarden van de licentie gebruikt; — „verspreiding” of „mededeling”:het verkopen, geven, uitlenen, verhuren, verspreiden, mededelen, doorgeven, of op een andere wijze online of offline beschikbaar stellen van kopieën van het werk of het verlenen van toegang tot de essentiële functies ervan ten behoeve van andere natuurlijke of rechtspersonen.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to use,
|
||||
copy, modify, merge, publish, and distribute the Software for **personal, scientific, or educational purposes**, subject to the following conditions:
|
||||
2.Draagwijdte van de uit hoofde van de licentie verleende rechten
|
||||
De licentiegever verleent u hierbij een wereldwijde, royaltyvrije, niet-exclusieve, voor een sublicentie in aanmerking komende licentie, om voor de duur van het aan het oorspronkelijke werk verbonden auteursrecht, het volgende te doen:
|
||||
— het werk in alle omstandigheden en voor ongeacht welk doel te gebruiken;
|
||||
— het werk te verveelvoudigen;
|
||||
— het werk te wijzigen en op grond van het werk bewerkingen te ontwikkelen;
|
||||
— het werk aan het publiek mede te delen, waaronder het recht om het werk of kopieën ervan aan het publiek ter beschikking te stellen of te vertonen, en het werk, in voorkomend geval, in het openbaar uit te voeren;
|
||||
— het werk of kopieën ervan te verspreiden;
|
||||
— het werk of kopieën ervan uit te lenen en te verhuren;
|
||||
— de rechten op het werk of op kopieën ervan in sublicentie te geven.
|
||||
Deze rechten kunnen worden uitgeoefend met gebruikmaking van alle thans bekende of nog uit te vinden media, dragers en formaten, voor zover het toepasselijke recht dit toestaat. In de landen waar immateriële rechten van toepassing zijn, doet de licentiegever afstand van zijn recht op uitoefening van zijn immateriële rechten in de mate die door het toepasselijke recht wordt toegestaan teneinde een doeltreffende uitoefening van de bovenvermelde in licentie gegeven economische rechten mogelijk te maken. De licentiegever verleent de licentiehouder een royaltyvrij, niet-exclusief gebruiksrecht op alle octrooien van de licentiegever, voor zover dit noodzakelijk is om de uit hoofde van deze licentie verleende rechten op het werk te gebruiken.
|
||||
|
||||
**Commercial use of the Software or any derivative work is explicitly prohibited without prior written consent from the authors.**
|
||||
This includes but is not limited to resale, inclusion in paid products or services, and monetized distribution.
|
||||
Any commercial usage must be governed by a shared license or explicit contractual agreement with the authors.
|
||||
3.Mededeling van de broncode
|
||||
De licentiegever kan het werk verstrekken in zijn broncode of als uitvoerbare code. Indien het werk als uitvoerbare code wordt verstrekt, verstrekt de licentiegever bij elke door hem verspreide kopie van het werk tevens een machinaal leesbare kopie van de broncode van het werk of geeft hij in een mededeling, volgende op de bij het werk gevoegde auteursrechtelijke kennisgeving, de plaats aan waar de broncode gemakkelijk en vrij toegankelijk is, zolang de licentiegever het werk blijft verspreiden of mededelen.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
4.Beperkingen van het auteursrecht
|
||||
Geen enkele bepaling in deze licentie heeft ten doel de licentiehouder het recht te ontnemen een beroep te doen op een uitzondering op of een beperking van de exclusieve rechten van de rechthebbenden op het werk, of op de uitputting van die rechten of andere toepasselijke beperkingen daarvan.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED...
|
||||
5.Verplichtingen van de licentiehouder
|
||||
De verlening van de bovenvermelde rechten is onderworpen aan een aantal aan de licentiehouder opgelegde beperkingen en verplichtingen. Het gaat om de onderstaande verplichtingen.
|
||||
|
||||
Attributierecht: de licentiehouder moet alle auteurs-, octrooi- of merkenrechtelijke kennisgevingen onverlet laten alsook alle kennisgevingen die naar de licentie en de afwijzing van garanties verwijzen. De licentiehouder moet een afschrift van deze kennisgevingen en een afschrift van de licentie bij elke kopie van het werk voegen die hij verspreidt of mededeelt. De licentiehouder moet in elke bewerking duidelijk aangeven dat het werk is gewijzigd, en eveneens de datum van wijziging vermelden.
|
||||
|
||||
Copyleftclausule: wanneer de licentiehouder kopieën van het oorspronkelijke werk of bewerkingen verspreidt of mededeelt, geschiedt die verspreiding of mededeling onder de voorwaarden van deze licentie of van een latere versie van deze licentie, tenzij het oorspronkelijke werk uitdrukkelijk alleen onder deze versie van de licentie wordt verspreid — bijvoorbeeld door de mededeling „alleen EUPL v. 1.2”. De licentiehouder (die licentiegever wordt) kan met betrekking tot het werk of de bewerkingen geen aanvullende bepalingen of voorwaarden opleggen of stellen die de voorwaarden van de licentie wijzigen of beperken.
|
||||
|
||||
Verenigbaarheidsclausule: wanneer de licentiehouder bewerkingen of kopieën ervan verspreidt of mededeelt die zijn gebaseerd op het werk en op een ander werk dat uit hoofde van een verenigbare licentie in licentie is gegeven, kan die verspreiding of mededeling geschieden onder de voorwaarden van deze verenigbare licentie. Voor de toepassing van deze clausule wordt onder „verenigbare licentie” verstaan, de licenties die in het aanhangsel bij deze licentie zijn opgesomd. Indien de verplichtingen van de licentiehouder uit hoofde van de verenigbare licentie in strijd zijn met diens verplichtingen uit hoofde van deze licentie, hebben de verplichtingen van de verenigbare licentie voorrang.
|
||||
|
||||
Verstrekking van de broncode: bij de verspreiding of mededeling van kopieën van het werk verstrekt de licentiehouder een machinaal leesbare kopie van de broncode of geeft hij aan waar deze broncode gemakkelijk en vrij toegankelijk is, zolang de licentiehouder het werk blijft verspreiden of mededelen.
|
||||
|
||||
Juridische bescherming: deze licentie verleent geen toestemming om handelsnamen, handelsmerken, dienstmerken of namen van de licentiegever te gebruiken, behalve wanneer dit op grond van een redelijk en normaal gebruik noodzakelijk is om de oorsprong van het werk te beschrijven en de inhoud van de auteursrechtelijke kennisgeving te herhalen.
|
||||
|
||||
6.Auteursketen
|
||||
De oorspronkelijke licentiegever garandeert dat hij houder is van het hierbij verleende auteursrecht op het oorspronkelijke werk dan wel dat dit hem in licentie is gegeven en dat hij de bevoegdheid heeft de licentie te verlenen. Elke bewerker garandeert dat hij houder is van het auteursrecht op de door hem aan het werk aangebrachte wijzigingen dan wel dat dit hem in licentie is gegeven en dat hij de bevoegdheid heeft de licentie te verlenen. Telkens wanneer u de licentie aanvaardt, verlenen de oorspronkelijke licentiegever en de opeenvolgende bewerkers u een licentie op hun bijdragen aan het werk onder de voorwaarden van deze licentie.
|
||||
|
||||
7.Uitsluiting van garantie
|
||||
Het werk is een werk in ontwikkeling, dat voortdurend door vele bewerkers wordt verbeterd. Het is een onvoltooid werk, dat bijgevolg nog tekortkomingen of programmeerfouten („bugs”) kan vertonen, die onlosmakelijk verbonden zijn met dit soort ontwikkeling. Om die reden wordt het werk op grond van de licentie verstrekt „zoals het is” en zonder enige garantie met betrekking tot het werk te geven, met inbegrip van, maar niet beperkt tot garanties met betrekking tot de verhandelbaarheid, de geschiktheid voor een specifiek doel, de afwezigheid van tekortkomingen of fouten, de nauwkeurigheid, de eerbiediging van andere intellectuele-eigendomsrechten dan het in artikel 6 van deze licentie bedoelde auteursrecht. Deze uitsluiting van garantie is een essentieel onderdeel van de licentie en een voorwaarde voor de verlening van rechten op het werk.
|
||||
|
||||
8.Uitsluiting van aansprakelijkheid
|
||||
Behoudens in het geval van een opzettelijke fout of directe schade aan natuurlijke personen, is de licentiegever in geen enkel geval aansprakelijk voor ongeacht welke directe of indirecte, materiële of immateriële schade die voortvloeit uit de licentie of het gebruik van het werk, met inbegrip van, maar niet beperkt tot schade als gevolg van het verlies van goodwill, verloren werkuren, een computerdefect of computerfout, het verlies van gegevens, of enige andere commerciële schade, zelfs indien de licentiegever werd gewezen op de mogelijkheid van dergelijke schade. De licentiegever is echter aansprakelijk op grond van de wetgeving inzake productaansprakelijkheid, voor zover deze wetgeving op het werk van toepassing is.
|
||||
|
||||
9.Aanvullende overeenkomsten
|
||||
Bij de verspreiding van het werk kunt u ervoor kiezen een aanvullende overeenkomst te sluiten, waarin de verplichtingen of diensten overeenkomstig deze licentie worden omschreven. Indien deze verplichtingen worden aanvaard, kunt u echter alleen in eigen naam en onder eigen verantwoordelijkheid handelen, en dus niet in naam van de oorspronkelijke licentiegever of een bewerker, en kunt u voorts alleen handelen indien u ermee instemt alle bewerkers schadeloos te stellen, te verdedigen of te vrijwaren met betrekking tot de aansprakelijkheid van of vorderingen tegen deze bewerkers op grond van het feit dat u een garantie of aanvullende aansprakelijkheid hebt aanvaard.
|
||||
|
||||
10.Aanvaarding van de licentie
|
||||
De bepalingen van deze licentie kunnen worden aanvaard door te klikken op het pictogram „Ik ga akkoord”, dat zich bevindt onderaan het venster waarin de tekst van deze licentie is weergegeven, of door overeenkomstig de toepasselijke wetsbepalingen op een soortgelijke wijze met de licentie in te stemmen. Door op dat pictogram te klikken geeft u aan dat u deze licentie en alle voorwaarden ervan ondubbelzinnig en onherroepelijk aanvaardt. Evenzo aanvaardt u onherroepelijk deze licentie en alle voorwaarden ervan door uitoefening van de rechten die u in artikel 2 van deze licentie zijn verleend, zoals het gebruik van het werk, het creëren door u van een bewerking of de verspreiding of mededeling door u van het werk of kopieën ervan.
|
||||
|
||||
11.Voorlichting van het publiek
|
||||
Indien u het werk verspreidt of mededeelt door middel van elektronische communicatiemiddelen (bijvoorbeeld door voor te stellen het werk op afstand te downloaden), moet het distributiekanaal of het medium (bijvoorbeeld een website) het publiek ten minste de gegevens verschaffen die door het toepasselijke recht zijn voorgeschreven met betrekking tot de licentiegever, de licentie en de wijze waarop deze kan worden geraadpleegd, gesloten, opgeslagen en gereproduceerd door de licentiehouder.
|
||||
|
||||
12.Einde van de licentie
|
||||
De licentie en de uit hoofde daarvan verleende rechten eindigen automatisch bij elke inbreuk door de licentiehouder op de voorwaarden van de licentie. Dit einde beëindigt niet de licenties van personen die het werk van de licentiehouder krachtens de licentie hebben ontvangen, mits deze personen zich volledig aan de licentie houden.
|
||||
|
||||
13.Overige
|
||||
Onverminderd artikel 9 vormt de licentie de gehele overeenkomst tussen de partijen met betrekking tot het werk. Indien een bepaling van de licentie volgens het toepasselijke recht ongeldig is of niet uitvoerbaar is, doet dit geen afbreuk aan de geldigheid of uitvoerbaarheid van de licentie in haar geheel. Deze bepaling dient zodanig te worden uitgelegd of gewijzigd dat zij geldig en uitvoerbaar wordt. De Europese Commissie kan, voor zover dit noodzakelijk en redelijk is, versies in andere talen of nieuwe versies van deze licentie of geactualiseerde versies van dit aanhangsel publiceren, zonder de draagwijdte van de uit hoofde van de licentie verleende rechten te beperken. Nieuwe versies van de licentie zullen worden gepubliceerd met een uniek versienummer. Alle door de Europese Commissie goedgekeurde taalversies van deze licentie hebben dezelfde waarde. De partijen kunnen zich beroepen op de taalversie van hun keuze.
|
||||
|
||||
14.Bevoegd gerecht
|
||||
Onverminderd specifieke overeenkomsten tussen de partijen,
|
||||
— vallen alle geschillen tussen de instellingen, organen en instanties van de Europese Unie, als licentiegeefster, en een licentiehouder in verband met de uitlegging van deze licentie onder de bevoegdheid van het Hof van Justitie van de Europese Unie, conform artikel 272 van het Verdrag betreffende de werking van de Europese Unie,
|
||||
— vallen alle geschillen tussen andere partijen in verband met de uitlegging van deze licentie onder de uitsluitende bevoegdheid van het bevoegde gerecht van de plaats waar de licentiegever is gevestigd of zijn voornaamste activiteit uitoefent.
|
||||
|
||||
15.Toepasselijk recht
|
||||
Onverminderd specifieke overeenkomsten tussen de partijen,
|
||||
— wordt deze licentie beheerst door het recht van de lidstaat van de Europese Unie waar de licentiegever zijn statutaire zetel, verblijfplaats of hoofdkantoor heeft,
|
||||
— wordt deze licentie beheerst door het Belgische recht indien de licentiegever geen statutaire zetel, verblijfplaats of hoofdkantoor heeft in een lidstaat van de Europese Unie.
|
||||
|
||||
|
||||
Aanhangsel
|
||||
„Verenigbare licenties” in de zin van artikel 5 EUPL zijn:
|
||||
— GNU General Public License (GPL) v. 2, v. 3
|
||||
— GNU Affero General Public License (AGPL) v. 3
|
||||
— Open Software License (OSL) v. 2.1, v. 3.0
|
||||
— Eclipse Public License (EPL) v. 1.0
|
||||
— CeCILL v. 2.0, v. 2.1
|
||||
— Mozilla Public Licence (MPL) v. 2
|
||||
— GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
|
||||
— Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) voor andere werken dan software
|
||||
— European Union Public Licence (EUPL) v. 1.1, v. 1.2
|
||||
— Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) of Strong Reciprocity (LiLiQ-R+).
|
||||
De Europese Commissie kan dit aanhangsel actualiseren in geval van latere versies van de bovengenoemde licenties zonder dat er een nieuwe EUPL-versie wordt ontwikkeld, zolang die versies de uit hoofde van artikel 2 van deze licentie verleende rechten verlenen en ze de betrokken broncode beschermen tegen exclusieve toe-eigening.
|
||||
Voor alle andere wijzigingen van of aanvullingen op dit aanhangsel is de ontwikkeling van een nieuwe EUPL-versie vereist.
|
||||
357
dependencies/measurement/measurementConfig.json
vendored
357
dependencies/measurement/measurementConfig.json
vendored
@@ -1,357 +0,0 @@
|
||||
{
|
||||
"general": {
|
||||
"name": {
|
||||
"default": "Measurement Configuration",
|
||||
"rules": {
|
||||
"type": "string",
|
||||
"description": "A human-readable name or label for this measurement configuration."
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"default": null,
|
||||
"rules": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "A unique identifier for this configuration. If not provided, defaults to null."
|
||||
}
|
||||
},
|
||||
"unit": {
|
||||
"default": "unitless",
|
||||
"rules": {
|
||||
"type": "string",
|
||||
"description": "The unit of measurement for this configuration (e.g., 'meters', 'seconds', 'unitless')."
|
||||
}
|
||||
},
|
||||
"logging": {
|
||||
"logLevel": {
|
||||
"default": "info",
|
||||
"rules": {
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"value": "debug",
|
||||
"description": "Log messages are printed for debugging purposes."
|
||||
},
|
||||
{
|
||||
"value": "info",
|
||||
"description": "Informational messages are printed."
|
||||
},
|
||||
{
|
||||
"value": "warn",
|
||||
"description": "Warning messages are printed."
|
||||
},
|
||||
{
|
||||
"value": "error",
|
||||
"description": "Error messages are printed."
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"enabled": {
|
||||
"default": true,
|
||||
"rules": {
|
||||
"type": "boolean",
|
||||
"description": "Indicates whether logging is active. If true, log messages will be generated."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"functionality": {
|
||||
"softwareType": {
|
||||
"default": "measurement",
|
||||
"rules": {
|
||||
"type": "string",
|
||||
"description": "Specified software type for this configuration."
|
||||
}
|
||||
},
|
||||
"role": {
|
||||
"default": "Sensor",
|
||||
"rules": {
|
||||
"type": "string",
|
||||
"description": "Indicates the role this configuration plays (e.g., sensor, controller, etc.)."
|
||||
}
|
||||
}
|
||||
},
|
||||
"asset": {
|
||||
"uuid": {
|
||||
"default": null,
|
||||
"rules": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Asset tag number which is a universally unique identifier for this asset. May be null if not assigned."
|
||||
}
|
||||
},
|
||||
"tagCode":{
|
||||
"default": null,
|
||||
"rules": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Asset tag code which is a unique identifier for this asset. May be null if not assigned."
|
||||
}
|
||||
},
|
||||
"geoLocation": {
|
||||
"default": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"rules": {
|
||||
"type": "object",
|
||||
"description": "An object representing the asset's physical coordinates or location.",
|
||||
"schema": {
|
||||
"x": {
|
||||
"default": 0,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"description": "X coordinate of the asset's location."
|
||||
}
|
||||
},
|
||||
"y": {
|
||||
"default": 0,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"description": "Y coordinate of the asset's location."
|
||||
}
|
||||
},
|
||||
"z": {
|
||||
"default": 0,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"description": "Z coordinate of the asset's location."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"supplier": {
|
||||
"default": "Unknown",
|
||||
"rules": {
|
||||
"type": "string",
|
||||
"description": "The supplier or manufacturer of the asset."
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"default": "sensor",
|
||||
"rules": {
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"value": "sensor",
|
||||
"description": "A device that detects or measures a physical property and responds to it (e.g. temperature sensor)."
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"subType": {
|
||||
"default": "pressure",
|
||||
"rules": {
|
||||
"type": "string",
|
||||
"description": "A more specific classification within 'type'. For example, 'pressure' for a pressure sensor."
|
||||
}
|
||||
},
|
||||
"model": {
|
||||
"default": "Unknown",
|
||||
"rules": {
|
||||
"type": "string",
|
||||
"description": "A user-defined or manufacturer-defined model identifier for the asset."
|
||||
}
|
||||
},
|
||||
"accuracy": {
|
||||
"default": null,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"nullable": true,
|
||||
"description": "The accuracy of the sensor, typically represented as a percentage or absolute value."
|
||||
}
|
||||
},
|
||||
"repeatability": {
|
||||
"default": null,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"nullable": true,
|
||||
"description": "The repeatability of the sensor, typically represented as a percentage or absolute value."
|
||||
}
|
||||
}
|
||||
},
|
||||
"scaling": {
|
||||
"enabled": {
|
||||
"default": false,
|
||||
"rules": {
|
||||
"type": "boolean",
|
||||
"description": "Indicates whether input scaling is active. If true, input values will be scaled according to the parameters below."
|
||||
}
|
||||
},
|
||||
"inputMin": {
|
||||
"default": 0,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"description": "The minimum expected input value before scaling."
|
||||
}
|
||||
},
|
||||
"inputMax": {
|
||||
"default": 1,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"description": "The maximum expected input value before scaling."
|
||||
}
|
||||
},
|
||||
"absMin": {
|
||||
"default": 50,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"description": "The absolute minimum value that can be read or displayed after scaling."
|
||||
}
|
||||
},
|
||||
"absMax": {
|
||||
"default": 100,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"description": "The absolute maximum value that can be read or displayed after scaling."
|
||||
}
|
||||
},
|
||||
"offset": {
|
||||
"default": 0,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"description": "A constant offset to apply to the scaled output (e.g., to calibrate zero-points)."
|
||||
}
|
||||
}
|
||||
},
|
||||
"smoothing": {
|
||||
"smoothWindow": {
|
||||
"default": 10,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"min": 1,
|
||||
"description": "Determines the size of the data window (number of samples) used for smoothing operations."
|
||||
}
|
||||
},
|
||||
"smoothMethod": {
|
||||
"default": "mean",
|
||||
"rules": {
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"value": "none",
|
||||
"description": "No smoothing is applied; raw data is passed through."
|
||||
},
|
||||
{
|
||||
"value": "mean",
|
||||
"description": "Calculates the simple arithmetic mean (average) of the data points in a window."
|
||||
},
|
||||
{
|
||||
"value": "min",
|
||||
"description": "Selects the smallest (minimum) value among the data points in a window."
|
||||
},
|
||||
{
|
||||
"value": "max",
|
||||
"description": "Selects the largest (maximum) value among the data points in a window."
|
||||
},
|
||||
{
|
||||
"value": "sd",
|
||||
"description": "Computes the standard deviation to measure the variation or spread of the data."
|
||||
},
|
||||
{
|
||||
"value": "lowPass",
|
||||
"description": "Filters out high-frequency components, allowing only lower frequencies to pass."
|
||||
},
|
||||
{
|
||||
"value": "highPass",
|
||||
"description": "Filters out low-frequency components, allowing only higher frequencies to pass."
|
||||
},
|
||||
{
|
||||
"value": "weightedMovingAverage",
|
||||
"description": "Applies varying weights to each data point in a window before averaging."
|
||||
},
|
||||
{
|
||||
"value": "bandPass",
|
||||
"description": "Filters the signal to allow only frequencies within a specific range to pass."
|
||||
},
|
||||
{
|
||||
"value": "median",
|
||||
"description": "Selects the median (middle) value in a window, minimizing the effect of outliers."
|
||||
},
|
||||
{
|
||||
"value": "kalman",
|
||||
"description": "Applies a Kalman filter to combine noisy measurements over time for more accurate estimates."
|
||||
},
|
||||
{
|
||||
"value": "savitzkyGolay",
|
||||
"description": "Uses a polynomial smoothing filter on a moving window, which can also provide derivative estimates."
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"simulation": {
|
||||
"enabled": {
|
||||
"default": false,
|
||||
"rules": {
|
||||
"type": "boolean",
|
||||
"description": "If true, the system operates in simulation mode, generating simulated values instead of using real inputs."
|
||||
}
|
||||
},
|
||||
"safeCalibrationTime": {
|
||||
"default": 100,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"min": 100,
|
||||
"description": "Time to wait before finalizing calibration in simulation mode (in milliseconds or appropriate unit)."
|
||||
}
|
||||
}
|
||||
},
|
||||
"interpolation": {
|
||||
"percentMin": {
|
||||
"default": 0,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"min": 0,
|
||||
"description": "Minimum percentage for interpolation or data scaling operations."
|
||||
}
|
||||
},
|
||||
"percentMax": {
|
||||
"default": 100,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"max": 100,
|
||||
"description": "Maximum percentage for interpolation or data scaling operations."
|
||||
}
|
||||
}
|
||||
},
|
||||
"outlierDetection": {
|
||||
"enabled": {
|
||||
"default": false,
|
||||
"rules": {
|
||||
"type": "boolean",
|
||||
"description": "Indicates whether outlier detection is enabled. If true, outliers will be identified and handled according to the method specified."
|
||||
}
|
||||
},
|
||||
"method": {
|
||||
"default": "zScore",
|
||||
"rules": {
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"value": "zScore",
|
||||
"description": "Uses the Z-score method to identify outliers based on standard deviations from the mean."
|
||||
},
|
||||
{
|
||||
"value": "iqr",
|
||||
"description": "Uses the Interquartile Range (IQR) method to identify outliers based on the spread of the middle 50% of the data."
|
||||
},
|
||||
{
|
||||
"value": "modifiedZScore",
|
||||
"description": "Uses a modified Z-score method that is more robust to small sample sizes."
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"threshold": {
|
||||
"default": 3,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"description": "The threshold value used by the selected outlier detection method. For example, a Z-score threshold of 3.0."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
311
measurement.html
311
measurement.html
@@ -1,17 +1,24 @@
|
||||
<!--
|
||||
| S88-niveau | Primair (blokkleur) | Tekstkleur |
|
||||
| ---------------------- | ------------------- | ---------- |
|
||||
| **Area** | `#0f52a5` | wit |
|
||||
| **Process Cell** | `#0c99d9` | wit |
|
||||
| **Unit** | `#50a8d9` | zwart |
|
||||
| **Equipment (Module)** | `#86bbdd` | zwart |
|
||||
| **Control Module** | `#a9daee` | zwart |
|
||||
|
||||
-->
|
||||
<script src="/measurement/menu.js"></script> <!-- Load the menu script for dynamic dropdowns -->
|
||||
<script src="/measurement/configData.js"></script> <!-- Load the config script for node information -->
|
||||
|
||||
<script src="measurement/resources/menuUtils.js"></script>
|
||||
<script>
|
||||
RED.nodes.registerType("measurement", {
|
||||
|
||||
category: "digital twin",
|
||||
color: "#e4a363",
|
||||
|
||||
category: "EVOLV",
|
||||
color: "#a9daee", // color for the node based on the S88 schema
|
||||
defaults: {
|
||||
|
||||
// Define default properties
|
||||
name: { value: "", required: true },
|
||||
enableLog: { value: false },
|
||||
logLevel: { value: "error" },
|
||||
name: { value: "sensor" }, // use asset category as name
|
||||
|
||||
// Define specific properties
|
||||
scaling: { value: false },
|
||||
@@ -21,120 +28,122 @@
|
||||
o_min: { value: 0, required: true },
|
||||
o_max: { value: 1, required: true },
|
||||
simulator: { value: false },
|
||||
unit: { value: "unit", required: true },
|
||||
smooth_method: { value: "" },
|
||||
count: { value: "10", required: true },
|
||||
|
||||
//define asset properties
|
||||
uuid: { value: "" },
|
||||
supplier: { value: "" },
|
||||
subType: { value: "" },
|
||||
category: { value: "" },
|
||||
assetType: { value: "" },
|
||||
model: { value: "" },
|
||||
unit: { value: "" },
|
||||
|
||||
//logger properties
|
||||
enableLog: { value: false },
|
||||
logLevel: { value: "error" },
|
||||
|
||||
//physicalAspect
|
||||
positionVsParent: { value: "" },
|
||||
positionIcon: { value: "" },
|
||||
hasDistance: { value: false },
|
||||
distance: { value: 0 },
|
||||
distanceUnit: { value: "m" },
|
||||
distanceDescription: { value: "" }
|
||||
|
||||
},
|
||||
|
||||
inputs: 1,
|
||||
outputs: 4,
|
||||
inputLabels: ["Measurement Input"],
|
||||
outputLabels: ["process", "dbase", "upstreamParent", "downstreamParent"],
|
||||
icon: "font-awesome/fa-tachometer",
|
||||
outputs: 3,
|
||||
inputLabels: ["Input"],
|
||||
outputLabels: ["process", "dbase", "parent"],
|
||||
icon: "font-awesome/fa-sliders",
|
||||
|
||||
label: function () {
|
||||
return this.name || "Measurement";
|
||||
return this.positionIcon + " " + this.assetType || "Measurement";
|
||||
},
|
||||
|
||||
|
||||
oneditprepare: function() {
|
||||
|
||||
const node = this;
|
||||
|
||||
// Use the namespaced version instead of global
|
||||
const menuUtils = window.EVOLV.nodes.measurement.utils.menuUtils;
|
||||
const helpers = window.EVOLV.nodes.measurement.utils.helpers;
|
||||
//this needs to live somewhere and for now we add it to every node file for simplicity
|
||||
const projecSettingstURL = "http://localhost:1880/generalFunctions/settings/projectSettings.json";
|
||||
|
||||
// Define UI html elements
|
||||
const elements = {
|
||||
// Basic fields
|
||||
name: document.getElementById("node-input-name"),
|
||||
// specific fields
|
||||
scalingCheckbox: document.getElementById("node-input-scaling"),
|
||||
rowInputMin: document.getElementById("row-input-i_min"),
|
||||
rowInputMax: document.getElementById("row-input-i_max"),
|
||||
smoothMethod: document.getElementById("node-input-smooth_method"),
|
||||
count: document.getElementById("node-input-count"),
|
||||
iOffset: document.getElementById("node-input-i_offset"),
|
||||
oMin: document.getElementById("node-input-o_min"),
|
||||
oMax: document.getElementById("node-input-o_max"),
|
||||
// Logging fields
|
||||
logCheckbox: document.getElementById("node-input-enableLog"),
|
||||
logLevelSelect: document.getElementById("node-input-logLevel"),
|
||||
rowLogLevel: document.getElementById("row-logLevel"),
|
||||
// Asset fields
|
||||
supplier: document.getElementById("node-input-supplier"),
|
||||
subType: document.getElementById("node-input-subType"),
|
||||
model: document.getElementById("node-input-model"),
|
||||
unit: document.getElementById("node-input-unit"),
|
||||
const waitForMenuData = () => {
|
||||
if (window.EVOLV?.nodes?.measurement?.initEditor) {
|
||||
window.EVOLV.nodes.measurement.initEditor(this);
|
||||
} else {
|
||||
setTimeout(waitForMenuData, 50);
|
||||
}
|
||||
};
|
||||
// Wait for the menu data to be ready before initializing the editor
|
||||
waitForMenuData();
|
||||
|
||||
// THIS IS NODE SPECIFIC --------------- Initialize the dropdowns and other specific UI elements -------------- this should be derived from the config in the future (make config based menu)
|
||||
// Populate smoothing methods dropdown
|
||||
const smoothMethodSelect = document.getElementById('node-input-smooth_method');
|
||||
const options = window.EVOLV?.nodes?.measurement?.config?.smoothing?.smoothMethod?.rules?.values || [];
|
||||
|
||||
// Clear existing options
|
||||
smoothMethodSelect.innerHTML = '';
|
||||
|
||||
try{
|
||||
// Add empty option
|
||||
const emptyOption = document.createElement('option');
|
||||
emptyOption.value = '';
|
||||
emptyOption.textContent = 'Select method...';
|
||||
smoothMethodSelect.appendChild(emptyOption);
|
||||
|
||||
// Fetch project settings
|
||||
menuUtils.fetchProjectData(projecSettingstURL)
|
||||
.then((projectSettings) => {
|
||||
// Add smoothing method options
|
||||
options.forEach(option => {
|
||||
const optionElement = document.createElement('option');
|
||||
optionElement.value = option.value;
|
||||
optionElement.textContent = option.value;
|
||||
optionElement.title = option.description; // Add tooltip with full description
|
||||
smoothMethodSelect.appendChild(optionElement);
|
||||
});
|
||||
|
||||
//assign to node vars
|
||||
node.configUrls = projectSettings.configUrls;
|
||||
|
||||
const { cloudConfigURL, localConfigURL } = menuUtils.getSpecificConfigUrl("measurement",node.configUrls.cloud.taggcodeAPI);
|
||||
node.configUrls.cloud.config = cloudConfigURL; // first call
|
||||
node.configUrls.local.config = localConfigURL; // backup call
|
||||
|
||||
node.locationId = projectSettings.locationId;
|
||||
node.uuid = projectSettings.uuid;
|
||||
|
||||
// Gets the ID of the active workspace (Flow)
|
||||
const activeFlowId = RED.workspaces.active(); //fetches active flow id
|
||||
node.processId = 1;//activeFlowId;
|
||||
|
||||
|
||||
// UI elements specific for node
|
||||
menuUtils.initMeasurementToggles(elements);
|
||||
menuUtils.populateSmoothingMethods(node.configUrls, elements, node);
|
||||
// UI elements across all nodes
|
||||
menuUtils.fetchAndPopulateDropdowns(node.configUrls, elements, node); // function for all assets
|
||||
menuUtils.initBasicToggles(elements);
|
||||
|
||||
})
|
||||
}catch(e){
|
||||
console.log("Error fetching project settings", e);
|
||||
// Set current value if it exists
|
||||
if (this.smooth_method) {
|
||||
smoothMethodSelect.value = this.smooth_method;
|
||||
}
|
||||
|
||||
if(node.d){
|
||||
//this means node is disabled
|
||||
console.log("Current status of node is disabled");
|
||||
// --- Scale rows toggle ---
|
||||
const chk = document.getElementById('node-input-scaling');
|
||||
const rowMin = document.getElementById('row-input-i_min');
|
||||
const rowMax = document.getElementById('row-input-i_max');
|
||||
|
||||
function toggleScalingRows() {
|
||||
const show = chk.checked;
|
||||
rowMin.style.display = show ? 'block' : 'none';
|
||||
rowMax.style.display = show ? 'block' : 'none';
|
||||
}
|
||||
|
||||
// wire and initialize
|
||||
chk.addEventListener('change', toggleScalingRows);
|
||||
toggleScalingRows();
|
||||
|
||||
|
||||
//------------------- END OF CUSTOM config UI ELEMENTS ------------------- //
|
||||
},
|
||||
|
||||
oneditsave: function () {
|
||||
const node = this;
|
||||
|
||||
console.log(`------------ Saving changes to node ------------`);
|
||||
console.log(`${node.uuid}`);
|
||||
// Validate asset properties using the asset menu
|
||||
if (window.EVOLV?.nodes?.measurement?.assetMenu?.saveEditor) {
|
||||
success = window.EVOLV.nodes.measurement.assetMenu.saveEditor(this);
|
||||
}
|
||||
|
||||
// Validate logger properties using the logger menu
|
||||
if (window.EVOLV?.nodes?.measurement?.loggerMenu?.saveEditor) {
|
||||
success = window.EVOLV.nodes.measurement.loggerMenu.saveEditor(node);
|
||||
}
|
||||
|
||||
// save position field
|
||||
if (window.EVOLV?.nodes?.measurement?.positionMenu?.saveEditor) {
|
||||
window.EVOLV.nodes.measurement.positionMenu.saveEditor(this);
|
||||
}
|
||||
|
||||
// Save basic properties
|
||||
["name", "supplier", "subType", "model", "unit", "smooth_method"].forEach(
|
||||
["smooth_method"].forEach(
|
||||
(field) => (node[field] = document.getElementById(`node-input-${field}`).value || "")
|
||||
);
|
||||
|
||||
// Save numeric and boolean properties
|
||||
["scaling", "enableLog", "simulator"].forEach(
|
||||
["scaling", "simulator"].forEach(
|
||||
(field) => (node[field] = document.getElementById(`node-input-${field}`).checked)
|
||||
);
|
||||
|
||||
@@ -142,41 +151,11 @@
|
||||
(field) => (node[field] = parseFloat(document.getElementById(`node-input-${field}`).value) || 0)
|
||||
);
|
||||
|
||||
node.logLevel = document.getElementById("node-input-logLevel").value || "info";
|
||||
|
||||
// Validation checks
|
||||
if (node.scaling && (isNaN(node.i_min) || isNaN(node.i_max))) {
|
||||
RED.notify("Scaling enabled, but input range is incomplete!", "error");
|
||||
}
|
||||
|
||||
if (!node.unit) {
|
||||
RED.notify("Unit selection is required.", "error");
|
||||
}
|
||||
|
||||
if (node.subType && !node.unit) {
|
||||
RED.notify("Unit must be set when specifying a subtype.", "error");
|
||||
}
|
||||
|
||||
console.log("stored node modelData", node.modelMetadata);
|
||||
console.log("------------ Changes saved to measurement node preparing to save to API ------------");
|
||||
|
||||
try{
|
||||
// Fetch project settings
|
||||
menuUtils.apiCall(node,node.configUrls)
|
||||
.then((response) => {
|
||||
|
||||
//save response to node information
|
||||
node.assetTagCode = response.asset_tag_number;
|
||||
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("Error during API call", error);
|
||||
});
|
||||
|
||||
}catch(e){
|
||||
console.log("Error saving assetID and tagnumber", e);
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@@ -185,47 +164,28 @@
|
||||
|
||||
<script type="text/html" data-template-name="measurement">
|
||||
|
||||
<!-- Node Name -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||
<input
|
||||
type="text"
|
||||
id="node-input-name"
|
||||
placeholder="Measurement Name"
|
||||
style="width:70%;"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Scaling Checkbox -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-scaling"
|
||||
><i class="fa fa-compress"></i> Scaling</label
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="node-input-scaling"
|
||||
style="width:20px; vertical-align:baseline;"
|
||||
/>
|
||||
><i class="fa fa-compress"></i> Scaling</label>
|
||||
<input type="checkbox" id="node-input-scaling" style="width:20px; vertical-align:baseline;"/>
|
||||
<span>Enable input scaling?</span>
|
||||
</div>
|
||||
|
||||
<!-- Source Min/Max (only if scaling is true) -->
|
||||
<div class="form-row" id="row-input-i_min">
|
||||
<label for="node-input-i_min"
|
||||
><i class="fa fa-arrow-down"></i> Source Min</label>
|
||||
<label for="node-input-i_min"><i class="fa fa-arrow-down"></i> Source Min</label>
|
||||
<input type="number" id="node-input-i_min" placeholder="0" />
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="row-input-i_max">
|
||||
<label for="node-input-i_max"
|
||||
><i class="fa fa-arrow-up"></i> Source Max</label>
|
||||
<label for="node-input-i_max"><i class="fa fa-arrow-up"></i> Source Max</label>
|
||||
<input type="number" id="node-input-i_max" placeholder="3000" />
|
||||
</div>
|
||||
|
||||
<!-- Offset -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-i_offset"
|
||||
><i class="fa fa-adjust"></i> Input Offset</label>
|
||||
<label for="node-input-i_offset"><i class="fa fa-adjust"></i> Input Offset</label>
|
||||
<input type="number" id="node-input-i_offset" placeholder="0" />
|
||||
</div>
|
||||
|
||||
@@ -241,87 +201,34 @@
|
||||
|
||||
<!-- Simulator Checkbox -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-simulator"
|
||||
><i class="fa fa-cog"></i> Simulator</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="node-input-simulator"
|
||||
style="width:20px; vertical-align:baseline;"
|
||||
/>
|
||||
<label for="node-input-simulator"><i class="fa fa-cog"></i> Simulator</label>
|
||||
<input type="checkbox" id="node-input-simulator" style="width:20px; vertical-align:baseline;"/>
|
||||
<span>Activate internal simulation?</span>
|
||||
</div>
|
||||
|
||||
<!-- Smoothing Method -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-smooth_method"
|
||||
><i class="fa fa-line-chart"></i> Smoothing</label>
|
||||
<label for="node-input-smooth_method"><i class="fa fa-line-chart"></i> Smoothing</label>
|
||||
<select id="node-input-smooth_method" style="width:60%;">
|
||||
<!-- Filled dynamically from measurementConfig.json or fallback -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Smoothing Window -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-count">Window</label>
|
||||
<input
|
||||
type="number"
|
||||
id="node-input-count"
|
||||
placeholder="10"
|
||||
style="width:60px;"
|
||||
/>
|
||||
<input type="number" id="node-input-count" placeholder="10" style="width:60px;"/>
|
||||
<div class="form-tips">Number of samples for smoothing</div>
|
||||
</div>
|
||||
|
||||
<!-- Optional Extended Fields: supplier, type, subType, model -->
|
||||
<hr />
|
||||
<div class="form-row">
|
||||
<label for="node-input-supplier"
|
||||
><i class="fa fa-industry"></i> Supplier</label>
|
||||
<select id="node-input-supplier" style="width:60%;">
|
||||
<option value="">(optional)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-subType"
|
||||
><i class="fa fa-puzzle-piece"></i> SubType</label>
|
||||
<select id="node-input-subType" style="width:60%;">
|
||||
<option value="">(optional)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-model"><i class="fa fa-wrench"></i> Model</label>
|
||||
<select id="node-input-model" style="width:60%;">
|
||||
<option value="">(optional)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-unit"><i class="fa fa-balance-scale"></i> Unit</label>
|
||||
<select id="node-input-unit" style="width:60%;"></select>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
<!-- Optional Extended Fields: supplier, cat, type, model, unit -->
|
||||
<!-- Asset fields will be injected here -->
|
||||
<div id="asset-fields-placeholder"></div>
|
||||
|
||||
<!-- loglevel checkbox -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-enableLog"
|
||||
><i class="fa fa-cog"></i> Enable Log</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="node-input-enableLog"
|
||||
style="width:20px; vertical-align:baseline;"
|
||||
/>
|
||||
<span>Enable logging</span>
|
||||
</div>
|
||||
<div id="logger-fields-placeholder"></div>
|
||||
|
||||
<div class="form-row" id="row-logLevel">
|
||||
<label for="node-input-logLevel"><i class="fa fa-cog"></i> Log Level</label>
|
||||
<select id="node-input-logLevel" style="width:60%;">
|
||||
<option value="info">Info</option>
|
||||
<option value="debug">Debug</option>
|
||||
<option value="warn">Warn</option>
|
||||
<option value="error">Error</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Position fields will be injected here -->
|
||||
<div id="position-fields-placeholder"></div>
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
177
measurement.js
177
measurement.js
@@ -1,159 +1,40 @@
|
||||
console.log('Loading measurement.js module...');
|
||||
// load helper modules from the generalFunctions folder
|
||||
const { outputUtils } = require('generalFunctions');
|
||||
//internal node-red node dependencies this is the class that will handle the measurement
|
||||
const Measurement = require("./dependencies/measurement/measurement");
|
||||
const { menuUtils } = require('generalFunctions');
|
||||
console.log('All dependencies loaded successfully');
|
||||
console.log(menuUtils);
|
||||
const nameOfNode = 'measurement'; // this is the name of the node, it should match the file name and the node type in Node-RED
|
||||
const nodeClass = require('./src/nodeClass.js'); // this is the specific node class
|
||||
const { MenuManager, configManager } = require('generalFunctions');
|
||||
|
||||
module.exports = function (RED) {
|
||||
function measurement(config) {
|
||||
//create node
|
||||
// This is the main entry point for the Node-RED node, it will register the node and setup the endpoints
|
||||
module.exports = function(RED) {
|
||||
// Register the node type
|
||||
RED.nodes.registerType(nameOfNode, function(config) {
|
||||
// Initialize the Node-RED node first
|
||||
RED.nodes.createNode(this, config);
|
||||
//call this => node so whenver you want to call a node function type node and the function behind it
|
||||
var node = this;
|
||||
|
||||
try{
|
||||
//load user defined config in the node-red UI
|
||||
const mConfig={
|
||||
general: {
|
||||
name: config.name,
|
||||
id: node.id,
|
||||
unit: config.unit,
|
||||
logging:{
|
||||
logLevel: config.logLevel,
|
||||
enabled: config.enableLog,
|
||||
},
|
||||
},
|
||||
asset: {
|
||||
tagCode: config.assetTagCode,
|
||||
supplier: config.supplier,
|
||||
subType: config.subType,
|
||||
model: config.model,
|
||||
},
|
||||
scaling:{
|
||||
enabled: config.scaling,
|
||||
inputMin: config.i_min,
|
||||
inputMax: config.i_max,
|
||||
absMin: config.o_min,
|
||||
absMax: config.o_max,
|
||||
offset: config.i_offset
|
||||
},
|
||||
smoothing: {
|
||||
smoothWindow: config.count,
|
||||
smoothMethod: config.smooth_method,
|
||||
},
|
||||
simulation: {
|
||||
enabled: config.simulator,
|
||||
},
|
||||
}
|
||||
|
||||
//make new measurement on creation to work with.
|
||||
const m = new Measurement(mConfig);
|
||||
|
||||
// put m on node memory as source
|
||||
node.source = m;
|
||||
|
||||
//load output utils
|
||||
const output = new outputUtils();
|
||||
|
||||
function updateNodeStatus(val) {
|
||||
//display status
|
||||
node.status({ fill: "green", shape: "dot", text: val + " " + mConfig.general.unit });
|
||||
}
|
||||
|
||||
//Update status only on event change
|
||||
m.emitter.on('mAbs', (val) => {
|
||||
updateNodeStatus(val);
|
||||
// Then create your custom class and attach it
|
||||
this.nodeClass = new nodeClass(config, RED, this, nameOfNode);
|
||||
});
|
||||
|
||||
//never ending functions
|
||||
function tick(){
|
||||
|
||||
//kick class ticks for time move
|
||||
m.tick();
|
||||
|
||||
//get output
|
||||
const classOutput = m.getOutput();
|
||||
const dbOutput = output.formatMsg(classOutput, m.config, "influxdb");
|
||||
const pOutput = output.formatMsg(classOutput, m.config, "process");
|
||||
|
||||
//only send output on values that changed
|
||||
let msgs = [];
|
||||
msgs[0] = pOutput;
|
||||
msgs[1] = dbOutput;
|
||||
|
||||
node.send(msgs);
|
||||
// Setup admin UIs
|
||||
const menuMgr = new MenuManager(); //this will handle the menu endpoints so we can load them dynamically
|
||||
const cfgMgr = new configManager(); // this will handle the config endpoints so we can load them dynamically
|
||||
|
||||
// Register the different menu's for the measurement node (in the future we could automate this further by refering to the config)
|
||||
RED.httpAdmin.get(`/${nameOfNode}/menu.js`, (req, res) => {
|
||||
try {
|
||||
const script = menuMgr.createEndpoint(nameOfNode, ['asset','logger','position']);
|
||||
res.type('application/javascript').send(script);
|
||||
} catch (err) {
|
||||
res.status(500).send(`// Error generating menu: ${err.message}`);
|
||||
}
|
||||
|
||||
// register child on first output this timeout is needed because of node - red stuff
|
||||
setTimeout(
|
||||
() => {
|
||||
|
||||
/*---execute code on first start----*/
|
||||
let msgs = [];
|
||||
|
||||
msgs[2] = { topic : "registerChild" , payload: node.id, positionVsParent: "upstream" };
|
||||
msgs[3] = { topic : "registerChild" , payload: node.id, positionVsParent: "downstream" };
|
||||
|
||||
//send msg
|
||||
this.send(msgs);
|
||||
},
|
||||
100
|
||||
);
|
||||
|
||||
//declare refresh interval internal node
|
||||
setTimeout(
|
||||
() => {
|
||||
/*---execute code on first start----*/
|
||||
this.intervalId = setInterval(function(){ tick() },1000)
|
||||
},
|
||||
1000
|
||||
);
|
||||
|
||||
//-------------------------------------------------------------------->>what to do on input
|
||||
node.on("input", function (msg,send,done) {
|
||||
|
||||
if(msg.topic == "simulator" ){
|
||||
m.toggleSimulation();
|
||||
}
|
||||
|
||||
if(msg.topic == "outlierDetection" ){
|
||||
m.toggleOutlierDetection();
|
||||
}
|
||||
|
||||
if(msg.topic == "calibrate" ){
|
||||
m.calibrate();
|
||||
}
|
||||
|
||||
if(msg.topic == "measurement" && typeof msg.payload == "number"){
|
||||
//feed input into the measurement node and calculate output
|
||||
m.inputValue = parseFloat(msg.payload);
|
||||
}
|
||||
|
||||
done();
|
||||
|
||||
});
|
||||
|
||||
// tidy up any async code here - shutdown connections and so on.
|
||||
node.on('close', function(done) {
|
||||
if (node.intervalId) clearTimeout(node.intervalId);
|
||||
if (node.tickInterval) clearInterval(node.tickInterval);
|
||||
if (done) done();
|
||||
// Endpoint to get the configuration data for the specific node
|
||||
RED.httpAdmin.get(`/${nameOfNode}/configData.js`, (req, res) => {
|
||||
try {
|
||||
const script = cfgMgr.createEndpoint(nameOfNode);
|
||||
// Send the configuration data as JSON response
|
||||
res.type('application/javascript').send(script);
|
||||
} catch (err) {
|
||||
res.status(500).send(`// Error generating configData: ${err.message}`);
|
||||
}
|
||||
});
|
||||
|
||||
}catch(e){
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
RED.nodes.registerType("measurement", measurement);
|
||||
|
||||
// Create a new instance of MenuUtils for use in the html browser
|
||||
let menuUtil = new menuUtils();
|
||||
// Create the endpoint with one line!
|
||||
menuUtil.createMenuUtilsEndpoint(RED, 'measurement', menuUtils);
|
||||
|
||||
};
|
||||
@@ -17,8 +17,7 @@
|
||||
"author": "Rene De Ren",
|
||||
"license": "SEE LICENSE",
|
||||
"dependencies": {
|
||||
"generalFunctions": "git+https://gitea.centraal.wbd-rd.nl/RnD/generalFunctions.git",
|
||||
"convert": "git+https://gitea.centraal.wbd-rd.nl/RnD/convert.git"
|
||||
"generalFunctions": "git+https://gitea.centraal.wbd-rd.nl/RnD/generalFunctions.git"
|
||||
},
|
||||
"node-red": {
|
||||
"nodes": {
|
||||
|
||||
182
src/nodeClass.js
Normal file
182
src/nodeClass.js
Normal file
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* measurement.class.js
|
||||
*
|
||||
* Encapsulates all node logic in a reusable class. In future updates we can split this into multiple generic classes and use the config to specifiy which ones to use.
|
||||
* This allows us to keep the Node-RED node clean and focused on wiring up the UI and event handlers.
|
||||
*/
|
||||
const { outputUtils, configManager } = require('generalFunctions');
|
||||
const Specific = require("./specificClass");
|
||||
|
||||
|
||||
class nodeClass {
|
||||
/**
|
||||
* Create a MeasurementNode.
|
||||
* @param {object} uiConfig - Node-RED node configuration.
|
||||
* @param {object} RED - Node-RED runtime API.
|
||||
* @param {object} nodeInstance - The Node-RED node instance.
|
||||
* @param {string} nameOfNode - The name of the node, used for
|
||||
*/
|
||||
constructor(uiConfig, RED, nodeInstance, nameOfNode) {
|
||||
|
||||
// Preserve RED reference for HTTP endpoints if needed
|
||||
this.node = nodeInstance;
|
||||
this.RED = RED;
|
||||
this.name = nameOfNode;
|
||||
|
||||
// Load default & UI config
|
||||
this._loadConfig(uiConfig,this.node);
|
||||
|
||||
// Instantiate core Measurement class
|
||||
this._setupSpecificClass();
|
||||
|
||||
// Wire up event and lifecycle handlers
|
||||
this._bindEvents();
|
||||
this._registerChild();
|
||||
this._startTickLoop();
|
||||
this._attachInputHandler();
|
||||
this._attachCloseHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load and merge default config with user-defined settings.
|
||||
* @param {object} uiConfig - Raw config from Node-RED UI.
|
||||
*/
|
||||
_loadConfig(uiConfig,node) {
|
||||
const cfgMgr = new configManager();
|
||||
this.defaultConfig = cfgMgr.getConfig(this.name);
|
||||
|
||||
// Merge UI config over defaults
|
||||
this.config = {
|
||||
general: {
|
||||
name: this.name,
|
||||
id: node.id, // node.id is for the child registration process
|
||||
unit: uiConfig.unit, // add converter options later to convert to default units (need like a model that defines this which units we are going to use and then conver to those standards)
|
||||
logging: {
|
||||
enabled: uiConfig.enableLog,
|
||||
logLevel: uiConfig.logLevel
|
||||
}
|
||||
},
|
||||
asset: {
|
||||
uuid: uiConfig.assetUuid, //need to add this later to the asset model
|
||||
tagCode: uiConfig.assetTagCode, //need to add this later to the asset model
|
||||
supplier: uiConfig.supplier,
|
||||
category: uiConfig.category, //add later to define as the software type
|
||||
type: uiConfig.assetType,
|
||||
model: uiConfig.model,
|
||||
unit: uiConfig.unit
|
||||
},
|
||||
scaling: {
|
||||
enabled: uiConfig.scaling,
|
||||
inputMin: uiConfig.i_min,
|
||||
inputMax: uiConfig.i_max,
|
||||
absMin: uiConfig.o_min,
|
||||
absMax: uiConfig.o_max,
|
||||
offset: uiConfig.i_offset
|
||||
},
|
||||
smoothing: {
|
||||
smoothWindow: uiConfig.count,
|
||||
smoothMethod: uiConfig.smooth_method
|
||||
},
|
||||
simulation: {
|
||||
enabled: uiConfig.simulator
|
||||
},
|
||||
functionality: {
|
||||
positionVsParent: uiConfig.positionVsParent,// Default to 'atEquipment' if not specified
|
||||
distance: uiConfig.hasDistance ? uiConfig.distance : undefined
|
||||
}
|
||||
};
|
||||
|
||||
console.log(`position vs child for ${this.name} is ${this.config.functionality.positionVsParent} the distance is ${this.config.functionality.distance}`);
|
||||
|
||||
// Utility for formatting outputs
|
||||
this._output = new outputUtils();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate the core logic and store as source.
|
||||
*/
|
||||
_setupSpecificClass() {
|
||||
this.source = new Specific(this.config);
|
||||
this.node.source = this.source; // Store the source in the node instance for easy access
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind Measurement events to Node-RED status updates. Using internal emitter. --> REMOVE LATER WE NEED ONLY COMPLETE CHILDS AND THEN CHECK FOR UPDATES
|
||||
*/
|
||||
_bindEvents() {
|
||||
|
||||
this.source.emitter.on('mAbs', (val) => {
|
||||
this.node.status({ fill: 'green', shape: 'dot', text: `${val} ${this.config.general.unit}` });
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register this node as a child upstream and downstream.
|
||||
* Delayed to avoid Node-RED startup race conditions.
|
||||
*/
|
||||
_registerChild() {
|
||||
setTimeout(() => {
|
||||
this.node.send([
|
||||
null,
|
||||
null,
|
||||
{ topic: 'registerChild', payload: this.node.id , positionVsParent: this.config?.functionality?.positionVsParent || 'atEquipment' , distance: this.config?.functionality?.distance || null},
|
||||
]);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the periodic tick loop to drive the Measurement class.
|
||||
*/
|
||||
_startTickLoop() {
|
||||
setTimeout(() => {
|
||||
this._tickInterval = setInterval(() => this._tick(), 1000);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a single tick: update measurement, format and send outputs.
|
||||
*/
|
||||
_tick() {
|
||||
this.source.tick();
|
||||
|
||||
const raw = this.source.getOutput();
|
||||
const processMsg = this._output.formatMsg(raw, this.config, 'process');
|
||||
const influxMsg = this._output.formatMsg(raw, this.config, 'influxdb');
|
||||
|
||||
// Send only updated outputs on ports 0 & 1
|
||||
this.node.send([processMsg, influxMsg]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach the node's input handler, routing control messages to the class.
|
||||
*/
|
||||
_attachInputHandler() {
|
||||
this.node.on('input', (msg, send, done) => {
|
||||
switch (msg.topic) {
|
||||
case 'simulator': this.source.toggleSimulation(); break;
|
||||
case 'outlierDetection': this.source.toggleOutlierDetection(); break;
|
||||
case 'calibrate': this.source.calibrate(); break;
|
||||
case 'measurement':
|
||||
if (typeof msg.payload === 'number') {
|
||||
this.source.inputValue = parseFloat(msg.payload);
|
||||
}
|
||||
break;
|
||||
}
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up timers and intervals when Node-RED stops the node.
|
||||
*/
|
||||
_attachCloseHandler() {
|
||||
this.node.on('close', (done) => {
|
||||
clearInterval(this._tickInterval);
|
||||
//clearInterval(this._statusInterval);
|
||||
done();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = nodeClass;
|
||||
@@ -1,57 +1,27 @@
|
||||
/**
|
||||
* @file Measurement.js
|
||||
*
|
||||
* Permission is hereby granted to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to use it for personal
|
||||
* or non-commercial purposes, with the following restrictions:
|
||||
*
|
||||
* 1. **No Copying or Redistribution**: The Software or any of its parts may not
|
||||
* be copied, merged, distributed, sublicensed, or sold without explicit
|
||||
* prior written permission from the author.
|
||||
*
|
||||
* 2. **Commercial Use**: Any use of the Software for commercial purposes requires
|
||||
* a valid license, obtainable only with the explicit consent of the author.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Ownership of this code remains solely with the original author. Unauthorized
|
||||
* use of this Software is strictly prohibited.
|
||||
*
|
||||
* Author:
|
||||
* - Rene De Ren
|
||||
* Email:
|
||||
* - rene@thegoldenbasket.nl
|
||||
*
|
||||
* Future Improvements:
|
||||
* - Time-based stability checks
|
||||
* - Warmup handling
|
||||
* - Dynamic outlier detection thresholds
|
||||
* - Dynamic smoothing window and methods
|
||||
* - Alarm and threshold handling
|
||||
* - Maintenance mode
|
||||
* - Historical data and trend analysis
|
||||
*/
|
||||
|
||||
const EventEmitter = require('events');
|
||||
const {logger,configUtils} = require('generalFunctions');
|
||||
const defaultConfig = require('./measurementConfig.json');
|
||||
const {logger,configUtils,configManager,MeasurementContainer} = require('generalFunctions');
|
||||
|
||||
class Measurement {
|
||||
constructor(config={}) {
|
||||
|
||||
this.emitter = new EventEmitter(); // Own EventEmitter
|
||||
this.configUtils = new configUtils(defaultConfig);
|
||||
this.configManager = new configManager();
|
||||
this.defaultConfig = this.configManager.getConfig('measurement');
|
||||
this.configUtils = new configUtils(this.defaultConfig);
|
||||
this.config = this.configUtils.initConfig(config);
|
||||
|
||||
// Init after config is set
|
||||
this.logger = new logger(this.config.general.logging.enabled,this.config.general.logging.logLevel, this.config.general.name);
|
||||
|
||||
// General properties
|
||||
this.measurements = new MeasurementContainer({
|
||||
autoConvert: true,
|
||||
windowSize: this.config.smoothing.smoothWindow
|
||||
});
|
||||
|
||||
this.measurements.setChildId(this.config.general.id);
|
||||
this.measurements.setChildName(this.config.general.name);
|
||||
|
||||
// Smoothing
|
||||
this.storedValues = [];
|
||||
|
||||
@@ -487,8 +457,18 @@ class Measurement {
|
||||
|
||||
updateOutputAbs(val) {
|
||||
|
||||
// Constrain first, then check for changes
|
||||
let constrainedVal = val;
|
||||
|
||||
if (val < this.config.scaling.absMin || val > this.config.scaling.absMax) {
|
||||
this.logger.warn(`Output value=${val} is outside of ABS range. Constraining.`);
|
||||
constrainedVal = this.constrain(val, this.config.scaling.absMin, this.config.scaling.absMax);
|
||||
}
|
||||
|
||||
const roundedVal = Math.round(constrainedVal * 100) / 100;
|
||||
|
||||
//only update on change
|
||||
if(val != this.outputAbs){
|
||||
if (roundedVal != this.outputAbs) {
|
||||
|
||||
// Constrain value within process range
|
||||
if (val < this.config.scaling.absMin || val > this.config.scaling.absMax) {
|
||||
@@ -499,8 +479,10 @@ class Measurement {
|
||||
this.outputAbs = Math.round(val * 100) / 100;
|
||||
this.outputPercent = this.updateOutputPercent(val);
|
||||
|
||||
this.logger.debug(`[DEBUG] Emitting mAbs=${this.outputAbs}, Current listeners:`, this.emitter.eventNames());
|
||||
this.emitter.emit('mAbs', this.outputAbs);
|
||||
this.emitter.emit('mAbs', this.outputAbs);// DEPRECATED: Use measurements container instead
|
||||
|
||||
this.logger.debug(`Updating type: ${this.config.asset.type}, variant: ${"measured"}, postition : ${this.config.functionality.positionVsParent} container with new value: ${this.outputAbs}`);
|
||||
this.measurements.type(this.config.asset.type).variant("measured").position(this.config.functionality.positionVsParent).distance(this.config.functionality.distance).value(this.outputAbs, Date.now(),this.config.asset.unit );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -559,12 +541,24 @@ const configuration = {
|
||||
absMax: 4000,
|
||||
offset: 1000
|
||||
},
|
||||
asset: {
|
||||
type: "pressure",
|
||||
unit: "bar",
|
||||
category: "measurement",
|
||||
model: "PT1",
|
||||
uuid: "123e4567-e89b-12d3-a456-426614174000",
|
||||
tagCode: "PT1-001",
|
||||
supplier: "DeltaTech"
|
||||
},
|
||||
smoothing: {
|
||||
smoothWindow: 10,
|
||||
smoothMethod: 'mean',
|
||||
},
|
||||
simulation: {
|
||||
enabled: true,
|
||||
},
|
||||
functionality: {
|
||||
positionVsParent: "upstream"
|
||||
}
|
||||
};
|
||||
|
||||
@@ -575,8 +569,9 @@ m.logger.info(`Measurement created with config : ${JSON.stringify(m.config)}`);
|
||||
|
||||
m.logger.setLogLevel("debug");
|
||||
|
||||
m.emitter.on('mAbs', (val) => {
|
||||
m.logger.info(`Received : ${val}`);
|
||||
//look for flow updates
|
||||
m.measurements.emitter.on('pressure.measured.upstream', (newVal) => {
|
||||
m.logger.info(`Received : ${newVal.value} ${newVal.unit}`);
|
||||
const repeatability = m.evaluateRepeatability();
|
||||
if (repeatability !== null) {
|
||||
m.logger.info(`Current repeatability (standard deviation): ${repeatability}`);
|
||||
Reference in New Issue
Block a user