-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsmart-meter-mbus-dlms.js
2 lines (2 loc) · 127 KB
/
smart-meter-mbus-dlms.js
1
2
(()=>{"use strict";var e={91:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var c=Object.getOwnPropertyDescriptor(t,n);c&&!("get"in c?!t.__esModule:c.writable||c.configurable)||(c={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,c)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),c=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return c(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ApplicationDataDecrypter=void 0;const o=i(n(113)),a=n(312);t.ApplicationDataDecrypter=class{static Decrypt(e){const t=Buffer.from(a.DecryptionSettings.key,"hex"),n=Buffer.concat([e.systemTitle,e.frameCounter]),r=Buffer.concat([n,Buffer.from("00000002","hex")]),c=o.createDecipheriv("aes-128-ctr",t,r),i=c.update(e.encryptedPayload),s=c.final();e.decryptedPayload=Buffer.concat([i,s])}}},535:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ApplicationProtocolDataUnit=void 0;const r=n(82),c=n(97);class i{constructor(){this.cypheringService=0,this.systemTitleLength=0,this._systemTitle=i.emptyBuffer,this._systemTitleManufacturerId="",this._systemTitleText="",this._serialNumber=0,this._lengthFieldLength=0,this._lengthTotal=0,this._lengthEncryptedPayload=0,this._lengthField=0,this._securityControl=0,this._securitySuiteId=0,this._securityAuthentication=!1,this._securityEncryption=!1,this._securityKeySet=r.KeySet.broadcast,this._securityCompression=!1,this._frameCounter=i.emptyBuffer,this._frameCounterNumber=0,this.encryptedPayload=i.emptyBuffer,this.decryptedPayload=i.emptyBuffer,this.apduRaw=i.emptyBuffer}setSystemTitle(e){if(this._systemTitle=e,this._systemTitleManufacturerId=e.subarray(0,3).toString(),this._serialNumber=c.Tools.getNumberFromBuffer(e,5,8),"KFM"==this._systemTitleManufacturerId){const t=e[3].toString(16).padStart(2,"0"),n=e[4].toString(16).padStart(2,"0"),r=c.Tools.getNumberFromBuffer(e,5,8).toString().padStart(7,"0");this._systemTitleText=t[0]+this._systemTitleManufacturerId+t[1]+n+r}else{let t=0;for(;t<5&&e[3+t]>=48&&e[3+t]<=122;)t++;let n="",r="";if(t>0&&(n=e.subarray(3,3+t).toString()),3+t<8){const n=(256**(5-t)).toString().length;r=c.Tools.getNumberFromByteArray([...e.subarray(3+t,8)]).toString().padStart(n,"0")}this._systemTitleText=this._systemTitleManufacturerId+n+r}}get systemTitle(){return this._systemTitle}get systemTitleManufacturerId(){return this._systemTitleManufacturerId}get systemTitleText(){return this._systemTitleText}setLength(e,t=0,n){return null==n&&(n=e.length),e[t]<128?(this._lengthField=e[t],this._lengthFieldLength=1):130==e[t]?(this._lengthField=c.Tools.getNumberFromBuffer(e,t+1,n),this._lengthFieldLength=3):129==e[t]?(this._lengthField=e.readUint8(t+1),this._lengthFieldLength=2):console.error(`Invalid APDU length. First length field: ${e[t]}. Should be <= 0x7F (127) or 0x81 or 0x82`),this._lengthEncryptedPayload=this._lengthField-5,this._lengthTotal=this._lengthField+this._lengthFieldLength+10,this._lengthFieldLength}get lengthFieldLength(){return this._lengthFieldLength}get lengthTotal(){return this._lengthTotal}get lengthEncryptedPayload(){return this._lengthEncryptedPayload}get lengthField(){return this._lengthField}set securityControl(e){this._securityControl=e,this._securitySuiteId=15&this._securityControl,this._securityAuthentication=16==(16&this._securityControl),this._securityEncryption=32==(32&this._securityControl),this._securityKeySet=64==(64&this._securityControl)?r.KeySet.broadcast:r.KeySet.unicast,this._securityCompression=128==(128&this._securityControl)}get securityControl(){return this._securityControl}get securitySuiteId(){return this._securitySuiteId}get securityAuthentication(){return this._securityAuthentication}get securityEncryption(){return this._securityEncryption}get securityKeySet(){return this._securityKeySet}get securityCompression(){return this._securityCompression}setFrameCounter(e,t=0,n){this._frameCounter=e.subarray(t,n),this._frameCounterNumber=c.Tools.getNumberFromBuffer(this._frameCounter)}get frameCounter(){return this._frameCounter}get frameCounterNumber(){return this._frameCounterNumber}}t.ApplicationProtocolDataUnit=i,i.emptyBuffer=Buffer.from("")},323:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CosemDataReader=void 0;const r=n(770),c=n(782),i=n(185);t.CosemDataReader=class{constructor(e,t){this.cosemTypeDefinitionMap=e,this.startTypeDefinitionName=t,this.currentIndex=0,this.rawData=Buffer.from("")}read(e){return this.rawData=e,this.currentIndex=0,this.readTypeDefinition(this.startTypeDefinitionName,void 0,r.Occurrence.explicit,r.Occurrence.explicit,void 0)}readProperty(e,t,n,r){return"enum"==t.name&&(r=e=>this.enrichDataWithCosemEnumUnits(e)),this.getTypeValue(e,t,n,r)}enrichDataWithCosemEnumUnits(e){if("INTEGER"!=e.typeName)return;if(null==e.numberValue)return;const t=i.cosemEnumUnitMap.get(e.numberValue);t&&(e.stringValue=t.unit)}readAsn1TypeValue(e,t,n,r,i,o,a,s){var u,l;const m=c.asn1DataTypes.get(n);if(!m)return void console.error(`CosemDataReader.readAsn1Type: definition ${e.name}, property: ${null==t?void 0:t.name}: Asn.1 Type not found: ${n}`);const p=null==t?void 0:t.name,d=m.getLengthAndValue(p,this.rawData,this.currentIndex,r,i,o,a,s);if(d){if(this.currentIndex+=null==d?void 0:d.encodingLength,(null==d?void 0:d.asn1ResultType)==c.Asn1ResultType.subType)for(let e=0;e<(null!==(u=null==d?void 0:d.count)&&void 0!==u?u:0);e++){const e=this.readTypeDefinition(null!==(l=d.subType)&&void 0!==l?l:"",void 0,o,a,void 0);d.addSubResult(e)}return d}}getTypeValue(e,t,n,r){let c,i,o,a,s,u;return t?(c=t.customType,i=t.asn1Type,o=t.occurrence,a=t.subType,s=t.typeParameter,u=t):(c=e.customType,i=e.asn1Type,o=e.occurrence,s=e.typeParameter),c?this.readTypeDefinition(c,u,o,n,r):i?this.readAsn1TypeValue(e,t,i,a,s,o,n,r):void console.error(`CosemDataReader.checkForType: definition ${e.name}, property: ${null==t?void 0:t.name}: Not implemented`,e,t)}readTypeDefinition(e,t,n,i,o){n==r.Occurrence.none&&(n=i);const a=this.cosemTypeDefinitionMap.get(e);if(!a)return void console.error(`CosemDataReader.definitionReader: definition not found: ${e}`);const s=new c.Result({propertyName:null==t?void 0:t.name,typeName:a.name,asn1ResultType:c.Asn1ResultType.container});switch(a.blockMode){case r.BlockMode.single:{const e=this.getTypeValue(a,void 0,n,o);return s.addSubResult(e),s}case r.BlockMode.choice:{const t=this.rawData.readUint8(this.currentIndex),r=a.taggedProperties[t];if(!r)return void console.error(`CosemDataReader.definitionReader BlockMode.choice: definition ${e}: CHOICE: property with tag ${t} not found.`);this.currentIndex++;const c=this.readProperty(a,r,n,o);return s.addSubResult(c),s}case r.BlockMode.sequence:o&&console.warn("CosemDataReader.definitionReader enrichData function set. Should not occur if multiple child properties exists.");for(const e of a.properties)s.addSubResult(this.readProperty(a,e,n,void 0));return s;default:return void console.error(`CosemDataReader.definitionReader: definition ${e}: BlockMode not implemented: ${r.BlockMode[a.blockMode]}`)}}}},629:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CosemObisDataProcessor=void 0;const r=n(312),c=n(286);t.CosemObisDataProcessor=class{areResultNamesOk(e,t,n){return t&&(null==e?void 0:e.propertyName)!=t?(console.error(`Invalid COSEM/ASN.1 result. Property '${t}' missing. Found: ${null==e?void 0:e.propertyName}`),!1):!n||(null==e?void 0:e.typeName)==n||(console.error(`Invalid COSEM/ASN.1 result. Type '${n}' missing. Found: ${null==e?void 0:e.typeName}`),!1)}transform(e){var t;const n=null===(t=null==e?void 0:e.results)||void 0===t?void 0:t[0];if(!this.areResultNamesOk(n,"data-notification","Data-Notification"))return;const r=this.getLongInvokeIdAndPriority(n);if(!r)return;const c=this.getDataNotificationDateTime(n);if(!c)return;const i=this.getNotificationBody(n);return i?{longInvokeIdAndPriority:r,dateTime:c,notificationBody:i}:void 0}getLongInvokeIdAndPriority(e){var t,n,r,c;const i=null===(t=null==e?void 0:e.results)||void 0===t?void 0:t[0];if(!this.areResultNamesOk(i,"long-invoke-id-and-priority","Long-Invoke-Id-And-Priority"))return;const o=null===(n=i.results)||void 0===n?void 0:n[0];if(!this.areResultNamesOk(o,void 0,"Unsigned32"))return;const a=null===(r=o.results)||void 0===r?void 0:r[0];return this.areResultNamesOk(a,void 0,"INTEGER")?{hex:a.hexString,dec:null!==(c=a.numberValue)&&void 0!==c?c:0}:void 0}getDataNotificationDateTime(e){var t;const n=null===(t=null==e?void 0:e.results)||void 0===t?void 0:t[1];if(this.areResultNamesOk(n,"date-time","OCTET STRING"))return null==n?void 0:n.dateTimeValue}getNotificationBody(e){var t,n,i,o,a,s,u,l,m,p,d,y,g,h,T,f,b,O,w,v,S,P,D,N,E,I,R,k;const M=null===(t=null==e?void 0:e.results)||void 0===t?void 0:t[2];if(!this.areResultNamesOk(M,"notification-body","Notification-Body"))return;const A=null===(n=M.results)||void 0===n?void 0:n[0];if(!this.areResultNamesOk(A,"data-value","Data"))return;const q=null===(i=A.results)||void 0===i?void 0:i[0];if(!this.areResultNamesOk(q,"structure","SEQUENCE OF"))return;if(q.results.length<2)return void console.error("Invalid COSEM/ASN.1 result. DataNotification.NotificationBody.DataValue.Structure does not contain children.");const B=q.results[0];if(!this.areResultNamesOk(B,"","Data"))return;const C=B.results[0];if(!this.areResultNamesOk(C,"octet-string","OCTET STRING"))return;const U=q.results[1];if(!this.areResultNamesOk(U,"","Data"))return;const x=U.results[0];if(!this.areResultNamesOk(x,"octet-string","OCTET STRING"))return;const L=[],_={obisCodeRaw:C.rawValue,valueRaw:x.rawValue};if(!C.rawValue)return;const G=c.ObisTools.getObisCode(C.rawValue,r.DecodingSettings.language),V={obisCode:G.code,obisFullName:G.fullName,obisName:G.name,numberValue:null===(o=x.dateTimeValue)||void 0===o?void 0:o.epoch,stringValue:null!==(s=null===(a=x.dateTimeValue)||void 0===a?void 0:a.asString)&&void 0!==s?s:"",unit:"",obisRaw:_};L.push(V);for(let e=2;e<q.results.length;e++){const t=q.results[e];if(!this.areResultNamesOk(t,"","Data"))return;const n=null===(u=t.results)||void 0===u?void 0:u[0];if(!this.areResultNamesOk(n,"structure","SEQUENCE OF"))continue;const i=null===(l=n.results)||void 0===l?void 0:l[0];if(!this.areResultNamesOk(i,"","Data"))return;const o=null===(m=i.results)||void 0===m?void 0:m[0];if(!this.areResultNamesOk(o,"octet-string","OCTET STRING"))return;if(!o.rawValue)return;const a=c.ObisTools.getObisCode(o.rawValue,r.DecodingSettings.language);if(a.code.startsWith("0")){if(2!=n.results.length)return void console.error(`Invalid COSEM/ASN.1 result. Obis code ${a.code} is "${a.medium}" but parent element does not contain 2 children (obis code, obis value).`);const e=null===(p=n.results)||void 0===p?void 0:p[1];if(!this.areResultNamesOk(e,"","Data"))return;const t=null===(d=e.results)||void 0===d?void 0:d[0];if(!this.areResultNamesOk(t,"octet-string","OCTET STRING"))return;if(!t.rawValue)return;const r={obisCode:a.code,obisFullName:a.fullName,obisName:a.name,numberValue:t.numberValue,stringValue:null!==(y=t.stringValue)&&void 0!==y?y:"",unit:"",obisRaw:{obisCodeRaw:o.rawValue,valueRaw:t.rawValue}};L.push(r)}else{if(3!=n.results.length)return void console.error(`Invalid COSEM/ASN.1 result. Obis code ${a.code} is "${a.medium}" but parent element does not contain 3 children (obis code, obis raw value, obis value properties).`);const e=null===(g=n.results)||void 0===g?void 0:g[1];if(!this.areResultNamesOk(e,"","Data"))return;const t=null===(h=e.results)||void 0===h?void 0:h[0];let r;if("long-unsigned"==t.propertyName){if(!this.areResultNamesOk(t,"long-unsigned","Unsigned16"))return;if(r=null===(T=t.results)||void 0===T?void 0:T[0],!this.areResultNamesOk(r,"","INTEGER"))return}else{if(!this.areResultNamesOk(t,"double-long-unsigned","Unsigned32"))return;if(r=null===(f=t.results)||void 0===f?void 0:f[0],!this.areResultNamesOk(r,"","INTEGER"))return}if(!r.rawValue)return;const c=null===(b=n.results)||void 0===b?void 0:b[2];if(!this.areResultNamesOk(c,"","Data"))return;const i=null===(O=c.results)||void 0===O?void 0:O[0];if(!this.areResultNamesOk(i,"structure","SEQUENCE OF"))return;const s=null===(w=i.results)||void 0===w?void 0:w[0];if(!this.areResultNamesOk(s,"","Data"))return;const u=null===(v=s.results)||void 0===v?void 0:v[0];if(!this.areResultNamesOk(u,"integer","Integer8"))return;const l=null===(S=u.results)||void 0===S?void 0:S[0];if(!this.areResultNamesOk(l,"","INTEGER"))return;if(!l.rawValue)return;const m=null===(P=i.results)||void 0===P?void 0:P[1];if(!this.areResultNamesOk(m,"","Data"))return;const p=null===(D=m.results)||void 0===D?void 0:D[0];if(!this.areResultNamesOk(p,"enum","Unsigned8"))return;const d=null===(N=p.results)||void 0===N?void 0:N[0];if(!this.areResultNamesOk(d,"","INTEGER"))return;if(!d.rawValue)return;let y=null!==(E=r.numberValue)&&void 0!==E?E:0;const M=null!==(I=l.numberValue)&&void 0!==I?I:0;if(0!=M&&(y*=10**(null!==(R=l.numberValue)&&void 0!==R?R:0),M<0)){const e=10**-M;y=Math.round(y*e)/e}const A={obisCode:a.code,obisFullName:a.fullName,obisName:a.name,numberValue:y,stringValue:`${y} ${d.stringValue}`,unit:null!==(k=d.stringValue)&&void 0!==k?k:"",obisRaw:{obisCodeRaw:o.rawValue,valueRaw:r.rawValue,numberValue:r.numberValue,scaling:l.numberValue}};L.push(A)}}return{obisValues:L}}}},770:(e,t)=>{var n,r;Object.defineProperty(t,"__esModule",{value:!0}),t.Occurrence=t.BlockMode=void 0,(r=t.BlockMode||(t.BlockMode={}))[r.none=0]="none",r[r.single=1]="single",r[r.choice=2]="choice",r[r.sequence=3]="sequence",r[r.enumerated=4]="enumerated",r[r.bitString=5]="bitString",(n=t.Occurrence||(t.Occurrence={}))[n.none=0]="none",n[n.implicit=1]="implicit",n[n.explicit=2]="explicit"},782:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.asn1DataTypes=t.Asn1GeneralizedTime=t.Asn1Null=t.Asn1Utf8String=t.Asn1BNumericString=t.Asn1VisibleString=t.Asn1Ia5String=t.Asn1Choice=t.Asn1SequenceOf=t.Asn1Sequence=t.Asn1ObjectIdentifier=t.Asn1Enumerated=t.Asn1Real=t.Asn1DateTime=t.Asn1TimeOfDay=t.Asn1Date=t.Asn1OctetString=t.Asn1BitString=t.Asn1Integer=t.Asn1Boolean=t.Asn1DataType=t.Result=t.CosemResultType=t.Asn1ResultType=t.Asn1LengthType=void 0;const r=n(770);var c,i,o;!function(e){e[e.fixed=0]="fixed",e[e.data=1]="data",e[e.parameter=2]="parameter"}(c=t.Asn1LengthType||(t.Asn1LengthType={})),function(e){e[e.typeNumber=0]="typeNumber",e[e.typeString=1]="typeString",e[e.properties=2]="properties",e[e.subType=3]="subType",e[e.container=4]="container"}(i=t.Asn1ResultType||(t.Asn1ResultType={})),(o=t.CosemResultType||(t.CosemResultType={}))[o.typeNumber=0]="typeNumber",o[o.typeString=1]="typeString",o[o.typeDate=2]="typeDate",o[o.typeObisKey=3]="typeObisKey";class a{constructor(e){this.propertyName="",this.dataLength=0,this.encodingLength=0,this.count=void 0,this.hexString="",this.results=[],null!=e.propertyName&&(this.propertyName=e.propertyName),null!=e.typeName&&(this.typeName=e.typeName),null!=e.dataLength&&(this.dataLength=e.dataLength),null!=e.encodingLength&&(this.encodingLength=e.encodingLength),null!=e.count&&(this.count=e.count),null!=e.rawValue&&(this.rawValue=e.rawValue),null!=e.hexString&&(this.hexString=e.hexString),null!=e.asn1ResultType&&(this.asn1ResultType=e.asn1ResultType),null!=e.numberValue&&(this.numberValue=e.numberValue),null!=e.stringValue&&(this.stringValue=e.stringValue),null!=e.dateTimeValue&&(this.dateTimeValue=e.dateTimeValue),null!=e.subType&&(this.subType=e.subType),null!=e.results&&(this.results=e.results)}addSubResult(e){e&&this.results.push(e)}}t.Result=a;class s{constructor(e){this.typeName=e}getLengthType(){return c.fixed}hasSubType(){return!1}getLengthAndValue(e,t,n,r,c,i,o,a){console.error(`${this.constructor.name}.getLengthAndValueFromData() not implemented for ${name}`)}static getOccurrence(e,t){return e!=r.Occurrence.none?e:t}getDateTime(e,t,n,r){if(12!=e.length)return;if(r){const e=(new Date).getFullYear(),c=e-r,i=e+r;(null==t||t>c)&&(t=c),(null==n||n<i)&&(n=i)}const c=e.readUInt16BE(0);if(t&&c<t)return;if(n&&c>n)return;const i=e.readUint8(2);if(i>12)return;const o=e.readUint8(3);if(o>31)return;if(e.readUint8(4)>7)return;const a=e.readUint8(5);if(a>23)return;const s=e.readUint8(6);if(s>59)return;const u=e.readUint8(7);if(u>60)return;const l=e.readUint8(8);if(l>100)return;let m=e.readInt16BE(9);const p=e.readUint8(11),d=new Date(c,i-1,o,a,s,u,10*l),y=d.getTime();let g;return 2048==e.readUInt16BE(9)&&(m=void 0),255!=p&&(g=this.getClockStatus(p)),{date:d,epoch:y,asString:this.dateToLocalIso(d),deviation:m,clockStatus:g}}dateToLocalIso(e){const t=e.getTimezoneOffset();let n=new Date(e.getTime()-60*t*1e3).toISOString().substring(0,23);return n=`${n.substring(0,10)} ${n.substring(11,19)}`,n}getClockStatus(e){return{clockStatusRaw:e,invalid:1==(1&e),doubtful:2==(2&e),differentClockBase:4==(4&e),invalidClockStatus:8==(8&e),daylightSavingActive:128==(128&e)}}}t.Asn1DataType=s;class u extends s{getLength(){return 1}}t.Asn1Boolean=u;class l extends s{getLengthType(){return c.parameter}getLengthAndValue(e,t,n,c,o,u,l,m){if((u=s.getOccurrence(u,l))!=r.Occurrence.implicit)return void console.error("Asn1Integer.getLengthAndValue: IMPLICIT only implemented.");if(!o)return void console.error("Asn1Integer.getLengthAndValue: typeParameter missing.");const p=o.match(/^\((-?\d+)\.\.(-?\d+)\)/);if(!p||3!=p.length)return void console.error(`Asn1Integer.getLengthAndValue: invalid parameter ${o}.`);const d=+p[1],y=+p[2],g=y-d;let h=0;if(g<=256)h=1;else if(g<=65536)h=2;else if(g<=4294967296)h=4;else if(g<=0x10000000000000000)return void console.error(`Asn1Integer.getLengthAndValue: 64 bit integer not implemented. ${o}.`);const T=t.subarray(n,n+h);let f=0;if(0==d)switch(h){case 1:f=T.readUint8();break;case 2:f=T.readUint16BE();break;case 4:f=T.readUint32BE();break;default:return void console.error(`Asn1Integer.getLengthAndValue: Invalid length for unsigned. ${o}.`)}else if(-d==y+1)switch(h){case 1:f=T.readInt8();break;case 2:f=T.readInt16BE();break;case 4:f=T.readInt32BE();break;default:return void console.error(`Asn1Integer.getLengthAndValue: Invalid length for signed. ${o}.`)}const b={propertyName:e,typeName:this.typeName,dataLength:h,encodingLength:h,rawValue:T,hexString:T.toString("hex"),asn1ResultType:i.typeNumber,numberValue:f};return m&&m(b),new a(b)}}t.Asn1Integer=l;class m extends s{getLengthType(){return c.parameter}}t.Asn1BitString=m;class p extends s{getLengthType(){return c.data}getLengthAndValue(e,t,n,c,o,u,l,m){if((u=s.getOccurrence(u,l))!=r.Occurrence.implicit)return void console.error("Asn1OctetString.getLengthAndValue: IMPLICIT only implemented.");const p=t.readInt8(n);if(p>127)return void console.error(`Asn1OctetString.getLengthAndValue: First byte > 127 (${p}). Maybe special encoding applies if first bit is set.`);const d=t.subarray(n+1,n+1+p);return m&&console.warn("Asn1OctetString.getLengthAndValue: enrichData not implemented"),new a({propertyName:e,typeName:this.typeName,dataLength:p,encodingLength:p+1,rawValue:d,hexString:d.toString("hex"),asn1ResultType:i.typeString,stringValue:this.toString(d),dateTimeValue:this.getDateTime(d,void 0,void 0,10)})}isPrintableString(e){for(const t of e){if(t<32)return!1;if(t>127)return!1}return!0}toString(e){if(this.isPrintableString(e))return e.toString();let t="";const n=e.length;if(n>0){t=e[0].toString();for(let r=1;r<n;r++)t+=` ${e[r]}`}return t}}t.Asn1OctetString=p;class d extends s{}t.Asn1Date=d;class y extends s{}t.Asn1TimeOfDay=y;class g extends s{}t.Asn1DateTime=g;class h extends s{}t.Asn1Real=h;class T extends s{}t.Asn1Enumerated=T;class f extends s{}t.Asn1ObjectIdentifier=f;class b extends s{}t.Asn1Sequence=b;class O extends s{getLengthType(){return c.data}hasSubType(){return!0}getLengthAndValue(e,t,n,c,o,u,l,m){if((u=s.getOccurrence(u,l))!=r.Occurrence.implicit)return void console.error("Asn1SequenceOf.getLengthAndValue: IMPLICIT only implemented.");const p=t.readInt8(n);if(p>127)return void console.error(`Asn1SequenceOf.getLengthAndValue: First byte > 127 (${length}). Maybe special encoding applies if first bit is set.`);const d=t.subarray(n,n+1);return m&&console.warn("Asn1OctetString.getLengthAndValue: enrichData not valid here"),new a({propertyName:e,typeName:this.typeName,dataLength:0,encodingLength:1,count:p,rawValue:d,hexString:d.toString("hex"),asn1ResultType:i.subType,subType:c})}}t.Asn1SequenceOf=O;class w extends s{}t.Asn1Choice=w;class v extends s{}t.Asn1Ia5String=v;class S extends s{}t.Asn1VisibleString=S;class P extends s{}t.Asn1BNumericString=P;class D extends s{}t.Asn1Utf8String=D;class N extends s{}t.Asn1Null=N;class E extends s{}t.Asn1GeneralizedTime=E,t.asn1DataTypes=new Map([["BOOLEAN",new u("BOOLEAN")],["INTEGER",new l("INTEGER")],["BIT STRING",new m("BIT STRING")],["OCTET STRING",new p("OCTET STRING")],["DATE",new d("DATE")],["TIME-OF-DAY",new y("TIME-OF-DAY")],["DATE-TIME",new g("DATE-TIME")],["REAL",new h("REAL")],["ENUMERATED",new T("ENUMERATED")],["OBJECT IDENTIFIER",new f("OBJECT IDENTIFIER")],["SEQUENCE",new b("SEQUENCE")],["SEQUENCE OF",new O("SEQUENCE OF")],["CHOICE",new w("CHOICE")],["IA5String",new v("IA5String")],["VisibleString",new S("VisibleString")],["NumericString",new P("NumericString")],["UTF8String",new D("UTF8String")],["NULL",new N("NULL")],["GeneralizedTime",new E("GeneralizedTime")]])},455:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BitString=void 0,t.BitString=class{constructor(e,t){this.name=e,this.bit=t}}},185:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cosemEnumUnitMap=void 0,t.cosemEnumUnitMap=new Map([[1,{enum:1,unit:"a",quantity:"time",unitName:"year ",siDefinition:"",comment:""}],[2,{enum:2,unit:"mo",quantity:"time",unitName:"month ",siDefinition:"",comment:""}],[3,{enum:3,unit:"wk",quantity:"time",unitName:"week",siDefinition:"7*24*60*60 s ",comment:""}],[4,{enum:4,unit:"d",quantity:"time",unitName:"day",siDefinition:"24*60*60 s ",comment:""}],[5,{enum:5,unit:"h",quantity:"time",unitName:"hour",siDefinition:"60*60 s ",comment:""}],[6,{enum:6,unit:"min",quantity:"time",unitName:"minute",siDefinition:"60 s ",comment:""}],[7,{enum:7,unit:"s",quantity:"time (t)",unitName:"second",siDefinition:"s ",comment:""}],[8,{enum:8,unit:"°",quantity:"(phase) angle",unitName:"degree",siDefinition:"rad*180/π ",comment:""}],[9,{enum:9,unit:"°C",quantity:"temperature (T)",unitName:"degree-celsius",siDefinition:"K-273.15 ",comment:""}],[10,{enum:10,unit:"currency",quantity:"(local) currency ",unitName:"",siDefinition:"",comment:""}],[11,{enum:11,unit:"m",quantity:"length (l)",unitName:"metre",siDefinition:"m ",comment:""}],[12,{enum:12,unit:"m/s",quantity:"speed (v)",unitName:"metre per second",siDefinition:"ms-1 ",comment:""}],[13,{enum:13,unit:"m3",quantity:"volume (V) rV, meter constant or pulse value (volume) ",unitName:"cubic metre",siDefinition:"m3 ",comment:""}],[14,{enum:14,unit:"m3",quantity:"corrected volume a",unitName:"cubic metre",siDefinition:"m3 ",comment:""}],[15,{enum:15,unit:"m3/h",quantity:"volume flux",unitName:"cubic metre per hour",siDefinition:"m3s-1/(60*60) ",comment:""}],[16,{enum:16,unit:"m3/h",quantity:"corrected volume flux a",unitName:"cubic metre per hour",siDefinition:"m3s-1/(60*60) ",comment:""}],[17,{enum:17,unit:"m3/d",quantity:"volume flux",unitName:"cubic metre per day",siDefinition:"m3s-1/(24*60*60) ",comment:""}],[18,{enum:18,unit:"m3/d",quantity:"corrected volume flux a",unitName:"cubic metre per day",siDefinition:"m3s-1/(60*60) ",comment:""}],[19,{enum:19,unit:"l",quantity:"volume",unitName:"litre",siDefinition:"10-3 m3 ",comment:""}],[20,{enum:20,unit:"kg",quantity:"mass (m)",unitName:"kilogram ",siDefinition:"",comment:""}],[21,{enum:21,unit:"N",quantity:"force (F)",unitName:"newton",siDefinition:"N = kg.m.s-2 ",comment:""}],[22,{enum:22,unit:"Nm",quantity:"energy",unitName:"newton meter",siDefinition:"J = Nm = Ws ",comment:""}],[23,{enum:23,unit:"Pa",quantity:"pressure (p)",unitName:"pascal",siDefinition:"N/m2 ",comment:""}],[24,{enum:24,unit:"bar",quantity:"pressure (p)",unitName:"bar",siDefinition:"105 Nm-2 ",comment:""}],[25,{enum:25,unit:"J",quantity:"energy",unitName:"joule",siDefinition:"J = Nm = Ws ",comment:""}],[26,{enum:26,unit:"J/h",quantity:"thermal power, rate of change",unitName:"joule per hour",siDefinition:"Js-1/(60*60) ",comment:""}],[27,{enum:27,unit:"W",quantity:"active power (P)",unitName:"watt",siDefinition:"W = Js-1 ",comment:""}],[28,{enum:28,unit:"VA",quantity:"apparent power (S)",unitName:"volt-ampere ",siDefinition:"",comment:""}],[29,{enum:29,unit:"var",quantity:"reactive power (Q)",unitName:"var ",siDefinition:"",comment:""}],[30,{enum:30,unit:"Wh",quantity:"active energy rW, active energy meter constant or pulse value",unitName:"watt-hour",siDefinition:"Ws*(60*60) ",comment:""}],[31,{enum:31,unit:"VAh",quantity:"apparent energy rS, apparent energy meter constant or pulse value",unitName:"volt-ampere-hour",siDefinition:"VAs*(60*60) ",comment:""}],[32,{enum:32,unit:"varh",quantity:"reactive energy rB, reactive energy meter constant or pulse value",unitName:"var-hour",siDefinition:"var s *(60*60s ",comment:""}],[33,{enum:33,unit:"A",quantity:"current (I)",unitName:"ampere",siDefinition:"A ",comment:""}],[34,{enum:34,unit:"C",quantity:"electrical charge (Q)",unitName:"coulomb",siDefinition:"C = As ",comment:""}],[35,{enum:35,unit:"V",quantity:"voltage (U)",unitName:"volt",siDefinition:"V ",comment:""}],[36,{enum:36,unit:"V/m",quantity:"electric field strength (E)",unitName:"volt per metre",siDefinition:"Vm-1 ",comment:""}],[37,{enum:37,unit:"F",quantity:"capacitance (C)",unitName:"farad",siDefinition:"CV-1 = AsV-1 ",comment:""}],[38,{enum:38,unit:"Ω",quantity:"resistance (R)",unitName:"ohm",siDefinition:"Ω = VA-1 ",comment:""}],[39,{enum:39,unit:"Ωm2/m",quantity:"resistivity (ρ)",unitName:"m ",siDefinition:"",comment:""}],[40,{enum:40,unit:"Wb",quantity:"magnetic flux (Φ)",unitName:"weber",siDefinition:"Wb = Vs ",comment:""}],[41,{enum:41,unit:"T",quantity:"magnetic flux density (B)",unitName:"tesla",siDefinition:"Wbm-2 ",comment:""}],[42,{enum:42,unit:"A/m",quantity:"magnetic field strength (H)",unitName:"ampere per metre",siDefinition:"Am-1 ",comment:""}],[43,{enum:43,unit:"H",quantity:"inductance (L)",unitName:"henry",siDefinition:"H = WbA-1 ",comment:""}],[44,{enum:44,unit:"Hz",quantity:"frequency (f, ω)",unitName:"hertz",siDefinition:"s-1 ",comment:""}],[45,{enum:45,unit:"1/(Wh)",quantity:"RW, active energy meter constant or pulse value ",unitName:"",siDefinition:"",comment:""}],[46,{enum:46,unit:"1/(varh)",quantity:"RB, reactive energy meter constant or pulse value ",unitName:"",siDefinition:"",comment:""}],[47,{enum:47,unit:"1/(VAh)",quantity:"RS, apparent energy meter constant or pulse value ",unitName:"",siDefinition:"",comment:""}],[48,{enum:48,unit:"V2h",quantity:"volt-squared hour, rU2h, volt-squared hour meter constant or pulse value",unitName:"volt-squared-hours",siDefinition:"V2s-1 /(60*60) ",comment:""}],[49,{enum:49,unit:"A2h",quantity:"ampere-squared hour, rI2h, ampere-squared hour meter constant or pulse value ",unitName:"ampere-squared hours",siDefinition:"A2 s-1 /(60*60) ",comment:""}],[50,{enum:50,unit:"kg/s",quantity:"mass flux",unitName:"kilogram per second",siDefinition:"kg s-1 ",comment:""}],[51,{enum:51,unit:"S, mho",quantity:"conductance",unitName:"siemens",siDefinition:"Ω-1 ",comment:""}],[52,{enum:52,unit:"K",quantity:"temperature (T)",unitName:"kelvin ",siDefinition:"",comment:""}],[53,{enum:53,unit:"1/(V2h)",quantity:"RU2h, volt-squared hour meter constant or pulse value ",unitName:"",siDefinition:"",comment:""}],[54,{enum:54,unit:"1/(A2h)",quantity:"RI2h, ampere-squared hour meter constant or pulse value ",unitName:"",siDefinition:"",comment:""}],[55,{enum:55,unit:"1/m3",quantity:"RV, meter constant or pulse value (volume) ",unitName:"",siDefinition:"",comment:""}],[56,{enum:56,unit:"percentage",quantity:"% ",unitName:"",siDefinition:"",comment:""}],[57,{enum:57,unit:"Ah",quantity:"ampere-hours",unitName:"Ampere-hour ",siDefinition:"",comment:""}],[60,{enum:60,unit:"Wh/m3",quantity:"energy per volume",unitName:"3,6*103 J/m3 ",siDefinition:"",comment:""}],[61,{enum:61,unit:"J/m3",quantity:"calorific value, wobbe ",unitName:"",siDefinition:"",comment:""}],[62,{enum:62,unit:"Mol %",quantity:"molar fraction of gas composition",unitName:"mole percent",siDefinition:"",comment:""}],[63,{enum:63,unit:"g/m3",quantity:"mass density, quantity of material",unitName:"",siDefinition:"",comment:""}],[64,{enum:64,unit:"Pa s",quantity:"dynamic viscosity",unitName:"pascal second",siDefinition:"",comment:""}],[65,{enum:65,unit:"J/kg ",quantity:"specific energy NOTE The amount of energy per unit of mass of a substance ",unitName:"Joule / kilogram",siDefinition:"m2 . kg . s -2 / kg = m2 . s –2 ",comment:""}],[66,{enum:66,unit:"g/cm²",quantity:"pressure",unitName:"gram per square centimeter",siDefinition:"98,066 5 Pa ",comment:""}],[67,{enum:67,unit:"atm",quantity:"pressure",unitName:"atmosphere",siDefinition:"101,325*103 Pa ",comment:""}],[70,{enum:70,unit:"dBm",quantity:"signal strength, dB milliwatt (e.g. of GSM radio systems) ",unitName:"",siDefinition:"",comment:""}],[71,{enum:71,unit:"dbµV",quantity:"signal strength, dB microvolt ",unitName:"",siDefinition:"",comment:""}],[72,{enum:72,unit:"dB",quantity:"logarithmic unit that expresses the ratio between two values of a physical quantity ",unitName:"",siDefinition:"",comment:""}],[128,{enum:128,unit:"in",quantity:"length (l)",unitName:"inch ",siDefinition:"",comment:""}],[129,{enum:129,unit:"ft",quantity:"length (l)",unitName:"foot ",siDefinition:"",comment:""}],[130,{enum:130,unit:"lb",quantity:"mass (m)",unitName:"pound ",siDefinition:"",comment:""}],[131,{enum:131,unit:"°F",quantity:"temperature",unitName:"degree Fahrenheit ",siDefinition:"",comment:""}],[132,{enum:132,unit:"°R",quantity:"temperature",unitName:"degree Rankine ",siDefinition:"",comment:""}],[133,{enum:133,unit:"sq. in",quantity:"area",unitName:"square inch ",siDefinition:"",comment:""}],[134,{enum:134,unit:"sq ft",quantity:"area",unitName:"square foot ",siDefinition:"",comment:""}],[135,{enum:135,unit:"ac",quantity:"area",unitName:"acre ",siDefinition:"",comment:""}],[136,{enum:136,unit:"cu in",quantity:"volume",unitName:"cubic inch ",siDefinition:"",comment:""}],[137,{enum:137,unit:"cu ft",quantity:"volume",unitName:"cubic foot ",siDefinition:"",comment:""}],[138,{enum:138,unit:"ac ft",quantity:"volume",unitName:"acre-foot ",siDefinition:"",comment:""}],[139,{enum:139,unit:"gal (imp)",quantity:"volume",unitName:"gallon (imperial) ",siDefinition:"",comment:""}],[140,{enum:140,unit:"gal (US)",quantity:"volume",unitName:"gallon (US) ",siDefinition:"",comment:""}],[141,{enum:141,unit:"lbf",quantity:"force",unitName:"pound force ",siDefinition:"",comment:""}],[142,{enum:142,unit:"psi",quantity:"pressure (p)",unitName:"Pound force per square inch ",siDefinition:"",comment:""}],[143,{enum:143,unit:"lb/cu ft",quantity:"density",unitName:"pound per cubic foot ",siDefinition:"",comment:""}],[144,{enum:144,unit:"lb/(ft .s)",quantity:"dynamic viscosity",unitName:"pound per (foot . second) ",siDefinition:"",comment:""}],[145,{enum:145,unit:"sq ft/s",quantity:"kinematic viscosity",unitName:"square foot per second ",siDefinition:"",comment:""}],[146,{enum:146,unit:"Btu",quantity:"energy",unitName:"British thermal unit ",siDefinition:"",comment:""}],[147,{enum:147,unit:"thm(EC)",quantity:"energy",unitName:"Therm(EU) ",siDefinition:"",comment:""}],[148,{enum:148,unit:"thm(US)",quantity:"energy",unitName:"Therm(US) ",siDefinition:"",comment:""}],[149,{enum:149,unit:"Btu/lb",quantity:"calorific value of mass, enthalpy",unitName:"British thermal unit per pound ",siDefinition:"",comment:""}],[150,{enum:150,unit:"Btu/cu ft",quantity:"calorific value of volume, wobbe ",unitName:"British thermal unit per cubic foot ",siDefinition:"",comment:""}],[151,{enum:151,unit:"cu ft",quantity:"volume (V) rv, meter constant or pulse value (volume)",unitName:"cubic feet ",siDefinition:"",comment:""}],[152,{enum:152,unit:"ft/s",quantity:"speed (v)",unitName:"foot per second ",siDefinition:"",comment:""}],[153,{enum:153,unit:"cu ft/s",quantity:"volume flux",unitName:"cubic foot per second ",siDefinition:"",comment:""}],[154,{enum:154,unit:"cu ft/min",quantity:"volume flux",unitName:"cubic foot per min ",siDefinition:"",comment:""}],[155,{enum:155,unit:"cu ft/h",quantity:"volume flux",unitName:"cubic foot per hour ",siDefinition:"",comment:""}],[156,{enum:156,unit:"cu ft/d",quantity:"volume flux",unitName:"cubic foot per day ",siDefinition:"",comment:""}],[157,{enum:157,unit:"ac ft/s",quantity:"volume flux",unitName:"acre foot per second ",siDefinition:"",comment:""}],[158,{enum:158,unit:"ac ft/min",quantity:"volume flux",unitName:"acre foot per min ",siDefinition:"",comment:""}],[159,{enum:159,unit:"ac ft/h",quantity:"volume flux",unitName:"acre foot per hour ",siDefinition:"",comment:""}],[160,{enum:160,unit:"ac ft/d",quantity:"volume flux",unitName:"acre foot per day ",siDefinition:"",comment:""}],[161,{enum:161,unit:"gal (imp)",quantity:"volume (V) rv, meter constant or pulse value (volume)",unitName:"imperial gallon ",siDefinition:"",comment:""}],[162,{enum:162,unit:"gal (imp) / s",quantity:"volume flux",unitName:"imperial gallon per second ",siDefinition:"",comment:""}],[163,{enum:163,unit:"gal (imp) / min",quantity:"volume flux",unitName:"imperial gallon per min ",siDefinition:"",comment:""}],[164,{enum:164,unit:"gal (imp) / h",quantity:"volume flux",unitName:"imperial gallon per hour ",siDefinition:"",comment:""}],[165,{enum:165,unit:"gal (imp) / d",quantity:"volume flux",unitName:"imperial gallon per day ",siDefinition:"",comment:""}],[166,{enum:166,unit:"gal (US)",quantity:"volume (V) rv, meter constant or pulse value (volume)",unitName:"US gallon ",siDefinition:"",comment:""}],[167,{enum:167,unit:"gal (US) / s",quantity:"volume flux",unitName:"US gallon per second ",siDefinition:"",comment:""}],[168,{enum:168,unit:"gal (US) / min",quantity:"volume flux",unitName:"US gallon per min ",siDefinition:"",comment:""}],[169,{enum:169,unit:"gal (US) / h",quantity:"volume flux",unitName:"US gallon per hour ",siDefinition:"",comment:""}],[170,{enum:170,unit:"gal (US) / d",quantity:"volume flux",unitName:"US gallon per day ",siDefinition:"",comment:""}],[171,{enum:171,unit:"Btu/s",quantity:"energy flow, heat, power, change rate",unitName:"British thermal unit per second ",siDefinition:"",comment:""}],[172,{enum:172,unit:"Btu/min",quantity:"energy flow, heat, power, change rate",unitName:"British thermal unit per minute ",siDefinition:"",comment:""}],[173,{enum:173,unit:"Btu/h",quantity:"energy flow, heat, power, change rate",unitName:"British thermal unit per hour ",siDefinition:"",comment:""}],[174,{enum:174,unit:"Btu/d",quantity:"energy flow, heat, power, change rate",unitName:"British thermal unit per day ",siDefinition:"",comment:""}],[253,{enum:253,unit:"extended table of units ",quantity:"",unitName:"",siDefinition:"",comment:""}],[254,{enum:254,unit:"other",quantity:"other unit ",unitName:"",siDefinition:"",comment:""}],[255,{enum:255,unit:"count",quantity:"no unit, unitless, count ",unitName:"",siDefinition:"",comment:""}]])},773:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Enumeration=void 0,t.Enumeration=class{constructor(e,t){this.name=e,this.value=t}}},343:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Property=void 0;const r=n(770);t.Property=class{constructor(e){var t,n,c,i,o,a,s;this.name=null!==(t=e.name)&&void 0!==t?t:"",this.tag=e.tag,this.occurrence=null!==(n=e.occurrence)&&void 0!==n?n:r.Occurrence.none,this.customType=null!==(c=e.customType)&&void 0!==c?c:"",this.asn1Type=null!==(i=e.asn1Type)&&void 0!==i?i:"",this.subType=null!==(o=e.subType)&&void 0!==o?o:"",this.typeParameter=null!==(a=e.typeParameter)&&void 0!==a?a:"",this.isOptional=null!==(s=e.isOptional)&&void 0!==s&&s}}},823:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TypeDefinition=void 0;const r=n(770);t.TypeDefinition=class{constructor(e){var t,n,c,i;this.taggedProperties={},this.enumerations={},this.bitStrings={},this.name=null!==(t=e.name)&&void 0!==t?t:"",this.blockMode=null!==(n=e.blockMode)&&void 0!==n?n:r.BlockMode.none,this.occurrence=null!==(c=e.occurrence)&&void 0!==c?c:r.Occurrence.none,this.tag=e.tag,this.customTag=e.customTag,this.customType=e.customType,this.asn1Type=e.asn1Type,this.typeParameter=e.typeParameter,this.properties=null!==(i=e.properties)&&void 0!==i?i:[];for(const e of this.properties)null!=e.tag&&(this.taggedProperties[e.tag]=e);if(e.enumerations)for(const t of e.enumerations)this.enumerations[t.value]=t;if(e.bitStrings)for(const t of e.bitStrings)this.bitStrings[t.bit]=t}}},111:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cosemTypeDefinitionMap=void 0;const r=n(770),c=n(823),i=n(343),o=n(773),a=n(455),s=new c.TypeDefinition({name:"XDLMS-APDU",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"initiateRequest",tag:1,occurrence:r.Occurrence.implicit,customType:"InitiateRequest"}),new i.Property({name:"readRequest",tag:5,occurrence:r.Occurrence.implicit,customType:"ReadRequest"}),new i.Property({name:"writeRequest",tag:6,occurrence:r.Occurrence.implicit,customType:"WriteRequest"}),new i.Property({name:"initiateResponse",tag:8,occurrence:r.Occurrence.implicit,customType:"InitiateResponse"}),new i.Property({name:"readResponse",tag:12,occurrence:r.Occurrence.implicit,customType:"ReadResponse"}),new i.Property({name:"writeResponse",tag:13,occurrence:r.Occurrence.implicit,customType:"WriteResponse"}),new i.Property({name:"confirmedServiceError",tag:14,occurrence:r.Occurrence.none,customType:"ConfirmedServiceError"}),new i.Property({name:"data-notification",tag:15,occurrence:r.Occurrence.implicit,customType:"Data-Notification"}),new i.Property({name:"unconfirmedWriteRequest",tag:22,occurrence:r.Occurrence.implicit,customType:"UnconfirmedWriteRequest"}),new i.Property({name:"informationReportRequest",tag:24,occurrence:r.Occurrence.implicit,customType:"InformationReportRequest"}),new i.Property({name:"glo-initiateRequest",tag:33,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-readRequest",tag:37,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-writeRequest",tag:38,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-initiateResponse",tag:40,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-readResponse",tag:44,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-writeResponse",tag:45,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-confirmedServiceError",tag:46,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-unconfirmedWriteRequest",tag:54,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-informationReportRequest",tag:56,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-initiateRequest",tag:65,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-readRequest",tag:69,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-writeRequest",tag:70,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-initiateResponse",tag:72,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-readResponse",tag:76,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-writeResponse",tag:77,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-confirmedServiceError",tag:78,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-unconfirmedWriteRequest",tag:86,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-informationReportRequest",tag:88,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"get-request",tag:192,occurrence:r.Occurrence.implicit,customType:"Get-Request"}),new i.Property({name:"set-request",tag:193,occurrence:r.Occurrence.implicit,customType:"Set-Request"}),new i.Property({name:"event-notification-request",tag:194,occurrence:r.Occurrence.implicit,customType:"EventNotificationRequest"}),new i.Property({name:"action-request",tag:195,occurrence:r.Occurrence.implicit,customType:"Action-Request"}),new i.Property({name:"get-response",tag:196,occurrence:r.Occurrence.implicit,customType:"Get-Response"}),new i.Property({name:"set-response",tag:197,occurrence:r.Occurrence.implicit,customType:"Set-Response"}),new i.Property({name:"action-response",tag:199,occurrence:r.Occurrence.implicit,customType:"Action-Response"}),new i.Property({name:"glo-get-request",tag:200,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-set-request",tag:201,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-event-notification-request",tag:202,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-action-request",tag:203,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-get-response",tag:204,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-set-response",tag:205,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"glo-action-response",tag:207,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-get-request",tag:208,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-set-request",tag:209,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-event-notification-request",tag:210,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-actionRequest",tag:211,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-get-response",tag:212,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-set-response",tag:213,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"ded-action-response",tag:215,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"exception-response",tag:216,occurrence:r.Occurrence.implicit,customType:"ExceptionResponse"}),new i.Property({name:"access-request",tag:217,occurrence:r.Occurrence.implicit,customType:"Access-Request"}),new i.Property({name:"access-response",tag:218,occurrence:r.Occurrence.implicit,customType:"Access-Response"}),new i.Property({name:"general-glo-ciphering",tag:219,occurrence:r.Occurrence.implicit,customType:"General-Glo-Ciphering"}),new i.Property({name:"general-ded-ciphering",tag:220,occurrence:r.Occurrence.implicit,customType:"General-Ded-Ciphering"}),new i.Property({name:"general-ciphering",tag:221,occurrence:r.Occurrence.implicit,customType:"General-Ciphering"}),new i.Property({name:"general-signing",tag:223,occurrence:r.Occurrence.implicit,customType:"General-Signing"}),new i.Property({name:"general-block-transfer",tag:224,occurrence:r.Occurrence.implicit,customType:"General-Block-Transfer"})]}),u=new c.TypeDefinition({name:"InitiateRequest",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"dedicated-key",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING",isOptional:!0}),new i.Property({name:"response-allowed",occurrence:r.Occurrence.none,asn1Type:"BOOLEAN",typeParameter:"DEFAULT TRUE"}),new i.Property({name:"proposed-quality-of-service",tag:0,occurrence:r.Occurrence.implicit,customType:"Integer8",isOptional:!0}),new i.Property({name:"proposed-dlms-version-number",occurrence:r.Occurrence.none,customType:"Unsigned8"}),new i.Property({name:"proposed-conformance",occurrence:r.Occurrence.none,customType:"Conformance"}),new i.Property({name:"client-max-receive-pdu-size",occurrence:r.Occurrence.none,customType:"Unsigned16"})]}),l=new c.TypeDefinition({name:"ReadRequest",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",typeParameter:"Variable-Access-Specification"}),m=new c.TypeDefinition({name:"WriteRequest",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"variable-access-specification",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Variable-Access-Specification"}),new i.Property({name:"list-of-data",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Data"})]}),p=new c.TypeDefinition({name:"InitiateResponse",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"negotiated-quality-of-service",tag:0,occurrence:r.Occurrence.implicit,customType:"Integer8",isOptional:!0}),new i.Property({name:"negotiated-dlms-version-number",occurrence:r.Occurrence.none,customType:"Unsigned8"}),new i.Property({name:"negotiated-conformance",occurrence:r.Occurrence.none,customType:"Conformance"}),new i.Property({name:"server-max-receive-pdu-size",occurrence:r.Occurrence.none,customType:"Unsigned16"}),new i.Property({name:"vaa-name",occurrence:r.Occurrence.none,customType:"ObjectName"})]}),d=new c.TypeDefinition({name:"ReadResponse",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"data",tag:0,occurrence:r.Occurrence.none,customType:"Data"}),new i.Property({name:"data-access-error",tag:1,occurrence:r.Occurrence.implicit,customType:"Data-Access-Result"}),new i.Property({name:"data-block-result",tag:2,occurrence:r.Occurrence.implicit,customType:"Data-Block-Result"}),new i.Property({name:"block-number",tag:3,occurrence:r.Occurrence.implicit,customType:"Unsigned16"})]}),y=new c.TypeDefinition({name:"WriteResponse",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"success",tag:0,occurrence:r.Occurrence.implicit,asn1Type:"NULL"}),new i.Property({name:"data-access-error",tag:1,occurrence:r.Occurrence.implicit,customType:"Data-Access-Result"}),new i.Property({name:"block-number",tag:2,occurrence:r.Occurrence.none,customType:"Unsigned16"})]}),g=new c.TypeDefinition({name:"ConfirmedServiceError",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"initiateError",tag:1,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"getStatus",tag:2,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"getNameList",tag:3,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"getVariableAttribute",tag:4,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"read",tag:5,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"write",tag:6,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"getDataSetAttribute",tag:7,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"getTIAttribute",tag:8,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"changeScope",tag:9,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"start",tag:10,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"stop",tag:11,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"resume",tag:12,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"makeUsable",tag:13,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"initiateLoad",tag:14,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"loadSegment",tag:15,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"terminateLoad",tag:16,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"initiateUpLoad",tag:17,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"upLoadSegment",tag:18,occurrence:r.Occurrence.none,customType:"ServiceError"}),new i.Property({name:"terminateUpLoad",tag:19,occurrence:r.Occurrence.none,customType:"ServiceError"})]}),h=new c.TypeDefinition({name:"Data-Notification",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"long-invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Long-Invoke-Id-And-Priority"}),new i.Property({name:"date-time",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"notification-body",occurrence:r.Occurrence.none,customType:"Notification-Body"})]}),T=new c.TypeDefinition({name:"UnconfirmedWriteRequest",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"variable-access-specification",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Variable-Access-Specification"}),new i.Property({name:"list-of-data",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Data"})]}),f=new c.TypeDefinition({name:"InformationReportRequest",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"current-time",occurrence:r.Occurrence.none,asn1Type:"GeneralizedTime",isOptional:!0}),new i.Property({name:"variable-access-specification",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Variable-Access-Specification"}),new i.Property({name:"list-of-data",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Data"})]}),b=new c.TypeDefinition({name:"Get-Request",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"get-request-normal",tag:1,occurrence:r.Occurrence.implicit,customType:"Get-Request-Normal"}),new i.Property({name:"get-request-next",tag:2,occurrence:r.Occurrence.implicit,customType:"Get-Request-Next"}),new i.Property({name:"get-request-with-list",tag:3,occurrence:r.Occurrence.implicit,customType:"Get-Request-With-List"})]}),O=new c.TypeDefinition({name:"Set-Request",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"set-request-normal",tag:1,occurrence:r.Occurrence.implicit,customType:"Set-Request-Normal"}),new i.Property({name:"set-request-with-first-datablock",tag:2,occurrence:r.Occurrence.implicit,customType:"Set-Request-With-First-Datablock"}),new i.Property({name:"set-request-with-datablock",tag:3,occurrence:r.Occurrence.implicit,customType:"Set-Request-With-Datablock"}),new i.Property({name:"set-request-with-list",tag:4,occurrence:r.Occurrence.implicit,customType:"Set-Request-With-List"}),new i.Property({name:"set-request-with-list-and-first-datablock",tag:5,occurrence:r.Occurrence.implicit,customType:"Set-Request-With-List-And-First-Datablock"})]}),w=new c.TypeDefinition({name:"EventNotificationRequest",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"time",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING",isOptional:!0}),new i.Property({name:"cosem-attribute-descriptor",occurrence:r.Occurrence.none,customType:"Cosem-Attribute-Descriptor"}),new i.Property({name:"attribute-value",occurrence:r.Occurrence.none,customType:"Data"})]}),v=new c.TypeDefinition({name:"Action-Request",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"action-request-normal",tag:1,occurrence:r.Occurrence.implicit,customType:"Action-Request-Normal"}),new i.Property({name:"action-request-next-pblock",tag:2,occurrence:r.Occurrence.implicit,customType:"Action-Request-Next-Pblock"}),new i.Property({name:"action-request-with-list",tag:3,occurrence:r.Occurrence.implicit,customType:"Action-Request-With-List"}),new i.Property({name:"action-request-with-first-pblock",tag:4,occurrence:r.Occurrence.implicit,customType:"Action-Request-With-First-Pblock"}),new i.Property({name:"action-request-with-list-and-first-pblock",tag:5,occurrence:r.Occurrence.implicit,customType:"Action-Request-With-List-And-First-Pblock"}),new i.Property({name:"action-request-with-pblock",tag:6,occurrence:r.Occurrence.implicit,customType:"Action-Request-With-Pblock"})]}),S=new c.TypeDefinition({name:"Get-Response",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"get-response-normal",tag:1,occurrence:r.Occurrence.implicit,customType:"Get-Response-Normal"}),new i.Property({name:"get-response-with-datablock",tag:2,occurrence:r.Occurrence.implicit,customType:"Get-Response-With-Datablock"}),new i.Property({name:"get-response-with-list",tag:3,occurrence:r.Occurrence.implicit,customType:"Get-Response-With-List"})]}),P=new c.TypeDefinition({name:"Set-Response",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"set-response-normal",tag:1,occurrence:r.Occurrence.implicit,customType:"Set-Response-Normal"}),new i.Property({name:"set-response-datablock",tag:2,occurrence:r.Occurrence.implicit,customType:"Set-Response-Datablock"}),new i.Property({name:"set-response-last-datablock",tag:3,occurrence:r.Occurrence.implicit,customType:"Set-Response-Last-Datablock"}),new i.Property({name:"set-response-last-datablock-with-list",tag:4,occurrence:r.Occurrence.implicit,customType:"Set-Response-Last-Datablock-With-List"}),new i.Property({name:"set-response-with-list",tag:5,occurrence:r.Occurrence.implicit,customType:"Set-Response-With-List"})]}),D=new c.TypeDefinition({name:"Action-Response",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"action-response-normal",tag:1,occurrence:r.Occurrence.implicit,customType:"Action-Response-Normal"}),new i.Property({name:"action-response-with-pblock",tag:2,occurrence:r.Occurrence.implicit,customType:"Action-Response-With-Pblock"}),new i.Property({name:"action-response-with-list",tag:3,occurrence:r.Occurrence.implicit,customType:"Action-Response-With-List"}),new i.Property({name:"action-response-next-pblock",tag:4,occurrence:r.Occurrence.implicit,customType:"Action-Response-Next-Pblock"})]}),N=new c.TypeDefinition({name:"ExceptionResponse",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"state-error",tag:0,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ service-not-allowed (1)"}),new i.Property({name:"state-error",tag:0,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ service-not-allowed (1), service-unknown (2) }"}),new i.Property({name:"service-error",tag:1,occurrence:r.Occurrence.none,asn1Type:"CHOICE",typeParameter:"{ operation-not-possible [1] IMPLICIT NULL"}),new i.Property({name:"service-error",tag:1,occurrence:r.Occurrence.none,asn1Type:"CHOICE",typeParameter:"{ operation-not-possible [1] IMPLICIT NULL, service-not-supported [2] IMPLICIT NULL"}),new i.Property({name:"service-error",tag:1,occurrence:r.Occurrence.none,asn1Type:"CHOICE",typeParameter:"{ operation-not-possible [1] IMPLICIT NULL, service-not-supported [2] IMPLICIT NULL, other-reason [3] IMPLICIT NULL"}),new i.Property({name:"service-error",tag:1,occurrence:r.Occurrence.none,asn1Type:"CHOICE",typeParameter:"{ operation-not-possible [1] IMPLICIT NULL, service-not-supported [2] IMPLICIT NULL, other-reason [3] IMPLICIT NULL, pdu-too-long [4] IMPLICIT NULL"}),new i.Property({name:"service-error",tag:1,occurrence:r.Occurrence.none,asn1Type:"CHOICE",typeParameter:"{ operation-not-possible [1] IMPLICIT NULL, service-not-supported [2] IMPLICIT NULL, other-reason [3] IMPLICIT NULL, pdu-too-long [4] IMPLICIT NULL, deciphering-error [5] IMPLICIT NULL"}),new i.Property({name:"service-error",tag:1,occurrence:r.Occurrence.none,asn1Type:"CHOICE",typeParameter:"{ operation-not-possible [1] IMPLICIT NULL, service-not-supported [2] IMPLICIT NULL, other-reason [3] IMPLICIT NULL, pdu-too-long [4] IMPLICIT NULL, deciphering-error [5] IMPLICIT NULL, invocation-counter-error [6] IMPLICIT Unsigned32 }"})]}),E=new c.TypeDefinition({name:"Access-Request",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"long-invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Long-Invoke-Id-And-Priority"}),new i.Property({name:"date-time",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"access-request-body",occurrence:r.Occurrence.none,customType:"Access-Request-Body"})]}),I=new c.TypeDefinition({name:"Access-Response",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"long-invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Long-Invoke-Id-And-Priority"}),new i.Property({name:"date-time",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"access-response-body",occurrence:r.Occurrence.none,customType:"Access-Response-Body"})]}),R=new c.TypeDefinition({name:"General-Glo-Ciphering",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"system-title",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"ciphered-content",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"})]}),k=new c.TypeDefinition({name:"General-Ded-Ciphering",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"system-title",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"ciphered-content",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"})]}),M=new c.TypeDefinition({name:"General-Ciphering",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"transaction-id",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"originator-system-title",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"recipient-system-title",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"date-time",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"other-information",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"key-info",occurrence:r.Occurrence.none,customType:"Key-Info",isOptional:!0}),new i.Property({name:"ciphered-content",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"})]}),A=new c.TypeDefinition({name:"General-Signing",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"transaction-id",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"originator-system-title",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"recipient-system-title",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"date-time",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"other-information",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"content",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"signature",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"})]}),q=new c.TypeDefinition({name:"General-Block-Transfer",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"block-control",occurrence:r.Occurrence.none,customType:"Block-Control"}),new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned16"}),new i.Property({name:"block-number-ack",occurrence:r.Occurrence.none,customType:"Unsigned16"}),new i.Property({name:"block-data",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"})]}),B=new c.TypeDefinition({name:"Integer8",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"INTEGER",typeParameter:"(-128..127)"}),C=new c.TypeDefinition({name:"Unsigned8",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"INTEGER",typeParameter:"(0..255)"}),U=new c.TypeDefinition({name:"Conformance",blockMode:r.BlockMode.bitString,occurrence:r.Occurrence.implicit,tag:31,customTag:"APPLICATION",bitStrings:[new a.BitString("reserved-zero",0),new a.BitString("general-protection",1),new a.BitString("general-block-transfer",2),new a.BitString("read",3),new a.BitString("write",4),new a.BitString("unconfirmed-write",5),new a.BitString("reserved-six",6),new a.BitString("reserved-seven",7),new a.BitString("attribute0-supported-with-set",8),new a.BitString("priority-mgmt-supported",9),new a.BitString("attribute0-supported-with-get",10),new a.BitString("block-transfer-with-get-or-read",11),new a.BitString("block-transfer-with-set-or-write",12),new a.BitString("block-transfer-with-action",13),new a.BitString("multiple-references",14),new a.BitString("information-report",15),new a.BitString("data-notification",16),new a.BitString("access",17),new a.BitString("parameterized-access",18),new a.BitString("get",19),new a.BitString("set",20),new a.BitString("selective-access",21),new a.BitString("event-notification",22),new a.BitString("action",23)]}),x=new c.TypeDefinition({name:"Unsigned16",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"INTEGER",typeParameter:"(0..65535)"}),L=new c.TypeDefinition({name:"Variable-Access-Specification",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"variable-name",tag:2,occurrence:r.Occurrence.implicit,customType:"ObjectName"}),new i.Property({name:"parameterized-access",tag:4,occurrence:r.Occurrence.implicit,customType:"Parameterized-Access"}),new i.Property({name:"block-number-access",tag:5,occurrence:r.Occurrence.implicit,customType:"Block-Number-Access"}),new i.Property({name:"read-data-block-access",tag:6,occurrence:r.Occurrence.implicit,customType:"Read-Data-Block-Access"}),new i.Property({name:"write-data-block-access",tag:7,occurrence:r.Occurrence.implicit,customType:"Write-Data-Block-Access"})]}),_=new c.TypeDefinition({name:"Data",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"null-data",tag:0,occurrence:r.Occurrence.implicit,asn1Type:"NULL"}),new i.Property({name:"array",tag:1,occurrence:r.Occurrence.implicit,asn1Type:"SEQUENCE OF",subType:"Data"}),new i.Property({name:"structure",tag:2,occurrence:r.Occurrence.implicit,asn1Type:"SEQUENCE OF",subType:"Data"}),new i.Property({name:"boolean",tag:3,occurrence:r.Occurrence.implicit,asn1Type:"BOOLEAN"}),new i.Property({name:"bit-string",tag:4,occurrence:r.Occurrence.implicit,asn1Type:"BIT STRING"}),new i.Property({name:"double-long",tag:5,occurrence:r.Occurrence.implicit,customType:"Integer32"}),new i.Property({name:"double-long-unsigned",tag:6,occurrence:r.Occurrence.implicit,customType:"Unsigned32"}),new i.Property({name:"octet-string",tag:9,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING"}),new i.Property({name:"visible-string",tag:10,occurrence:r.Occurrence.implicit,asn1Type:"VisibleString"}),new i.Property({name:"utf8-string",tag:12,occurrence:r.Occurrence.implicit,asn1Type:"UTF8String"}),new i.Property({name:"bcd",tag:13,occurrence:r.Occurrence.implicit,customType:"Integer8"}),new i.Property({name:"integer",tag:15,occurrence:r.Occurrence.implicit,customType:"Integer8"}),new i.Property({name:"long",tag:16,occurrence:r.Occurrence.implicit,customType:"Integer16"}),new i.Property({name:"unsigned",tag:17,occurrence:r.Occurrence.implicit,customType:"Unsigned8"}),new i.Property({name:"long-unsigned",tag:18,occurrence:r.Occurrence.implicit,customType:"Unsigned16"}),new i.Property({name:"compact-array",tag:19,occurrence:r.Occurrence.implicit,asn1Type:"SEQUENCE",typeParameter:"{ contents-description [0] TypeDescription"}),new i.Property({name:"compact-array",tag:19,occurrence:r.Occurrence.implicit,asn1Type:"SEQUENCE",typeParameter:"{ contents-description [0] TypeDescription, array-contents [1] IMPLICIT OCTET STRING }"}),new i.Property({name:"long64",tag:20,occurrence:r.Occurrence.implicit,customType:"Integer64"}),new i.Property({name:"long64-unsigned",tag:21,occurrence:r.Occurrence.implicit,customType:"Unsigned64"}),new i.Property({name:"enum",tag:22,occurrence:r.Occurrence.implicit,customType:"Unsigned8"}),new i.Property({name:"float32",tag:23,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING",typeParameter:"(SIZE(4))"}),new i.Property({name:"float64",tag:24,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING",typeParameter:"(SIZE(8))"}),new i.Property({name:"date-time",tag:25,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING",typeParameter:"(SIZE(12))"}),new i.Property({name:"date",tag:26,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING",typeParameter:"(SIZE(5))"}),new i.Property({name:"time",tag:27,occurrence:r.Occurrence.implicit,asn1Type:"OCTET STRING",typeParameter:"(SIZE(4))"}),new i.Property({name:"dont-care",tag:255,occurrence:r.Occurrence.implicit,asn1Type:"NULL"})]}),G=new c.TypeDefinition({name:"ObjectName",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,customType:"Integer16"}),V=new c.TypeDefinition({name:"Data-Access-Result",blockMode:r.BlockMode.enumerated,occurrence:r.Occurrence.none,enumerations:[new o.Enumeration("success",0),new o.Enumeration("hardware-fault",1),new o.Enumeration("temporary-failure",2),new o.Enumeration("read-write-denied",3),new o.Enumeration("object-undefined",4),new o.Enumeration("object-class-inconsistent",9),new o.Enumeration("object-unavailable",11),new o.Enumeration("type-unmatched",12),new o.Enumeration("scope-of-access-violated",13),new o.Enumeration("data-block-unavailable",14),new o.Enumeration("long-get-aborted",15),new o.Enumeration("no-long-get-in-progress",16),new o.Enumeration("long-set-aborted",17),new o.Enumeration("no-long-set-in-progress",18),new o.Enumeration("data-block-number-invalid",19),new o.Enumeration("other-reason",250)]}),F=new c.TypeDefinition({name:"Data-Block-Result",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"last-block",occurrence:r.Occurrence.none,asn1Type:"BOOLEAN"}),new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned16"}),new i.Property({name:"raw-data",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"})]}),W=new c.TypeDefinition({name:"ServiceError",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"application-reference",tag:0,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0)"}),new i.Property({name:"application-reference",tag:0,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), time-elapsed (1)"}),new i.Property({name:"application-reference",tag:0,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), time-elapsed (1), application-unreachable (2)"}),new i.Property({name:"application-reference",tag:0,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), time-elapsed (1), application-unreachable (2), application-reference-invalid (3)"}),new i.Property({name:"application-reference",tag:0,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), time-elapsed (1), application-unreachable (2), application-reference-invalid (3), application-context-unsupported (4)"}),new i.Property({name:"application-reference",tag:0,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), time-elapsed (1), application-unreachable (2), application-reference-invalid (3), application-context-unsupported (4), provider-communication-error (5)"}),new i.Property({name:"application-reference",tag:0,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), time-elapsed (1), application-unreachable (2), application-reference-invalid (3), application-context-unsupported (4), provider-communication-error (5), deciphering-error (6) }"}),new i.Property({name:"hardware-resource",tag:1,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0)"}),new i.Property({name:"hardware-resource",tag:1,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), memory-unavailable (1)"}),new i.Property({name:"hardware-resource",tag:1,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), memory-unavailable (1), processor-resource-unavailable (2)"}),new i.Property({name:"hardware-resource",tag:1,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), memory-unavailable (1), processor-resource-unavailable (2), mass-storage-unavailable (3)"}),new i.Property({name:"hardware-resource",tag:1,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), memory-unavailable (1), processor-resource-unavailable (2), mass-storage-unavailable (3), other-resource-unavailable (4) }"}),new i.Property({name:"vde-state-error",tag:2,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0)"}),new i.Property({name:"vde-state-error",tag:2,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), no-dlms-context (1)"}),new i.Property({name:"vde-state-error",tag:2,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), no-dlms-context (1), loading-data-set (2)"}),new i.Property({name:"vde-state-error",tag:2,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), no-dlms-context (1), loading-data-set (2), status-nochange (3)"}),new i.Property({name:"vde-state-error",tag:2,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), no-dlms-context (1), loading-data-set (2), status-nochange (3), status-inoperable (4) }"}),new i.Property({name:"service",tag:3,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0)"}),new i.Property({name:"service",tag:3,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), pdu-size (1)"}),new i.Property({name:"service",tag:3,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), pdu-size (1), service-unsupported (2) }"}),new i.Property({name:"definition",tag:4,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0)"}),new i.Property({name:"definition",tag:4,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), object-undefined (1)"}),new i.Property({name:"definition",tag:4,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), object-undefined (1), object-class-inconsistent (2)"}),new i.Property({name:"definition",tag:4,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), object-undefined (1), object-class-inconsistent (2), object-attribute-inconsistent (3) }"}),new i.Property({name:"access",tag:5,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0)"}),new i.Property({name:"access",tag:5,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), scope-of-access-violated (1)"}),new i.Property({name:"access",tag:5,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), scope-of-access-violated (1), object-access-violated (2)"}),new i.Property({name:"access",tag:5,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), scope-of-access-violated (1), object-access-violated (2), hardware-fault (3)"}),new i.Property({name:"access",tag:5,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), scope-of-access-violated (1), object-access-violated (2), hardware-fault (3), object-unavailable (4) }"}),new i.Property({name:"initiate",tag:6,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0)"}),new i.Property({name:"initiate",tag:6,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), dlms-version-too-low (1)"}),new i.Property({name:"initiate",tag:6,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), dlms-version-too-low (1), incompatible-conformance (2)"}),new i.Property({name:"initiate",tag:6,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), dlms-version-too-low (1), incompatible-conformance (2), pdu-size-too-short (3)"}),new i.Property({name:"initiate",tag:6,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), dlms-version-too-low (1), incompatible-conformance (2), pdu-size-too-short (3), refused-by-the-VDE-Handler (4) }"}),new i.Property({name:"load-data-set",tag:7,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0)"}),new i.Property({name:"load-data-set",tag:7,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), primitive-out-of-sequence (1)"}),new i.Property({name:"load-data-set",tag:7,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), primitive-out-of-sequence (1), not-loadable (2)"}),new i.Property({name:"load-data-set",tag:7,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), primitive-out-of-sequence (1), not-loadable (2), dataset-size-too-large (3)"}),new i.Property({name:"load-data-set",tag:7,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), primitive-out-of-sequence (1), not-loadable (2), dataset-size-too-large (3), not-awaited-segment (4)"}),new i.Property({name:"load-data-set",tag:7,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), primitive-out-of-sequence (1), not-loadable (2), dataset-size-too-large (3), not-awaited-segment (4), interpretation-failure (5)"}),new i.Property({name:"load-data-set",tag:7,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), primitive-out-of-sequence (1), not-loadable (2), dataset-size-too-large (3), not-awaited-segment (4), interpretation-failure (5), storage-failure (6)"}),new i.Property({name:"load-data-set",tag:7,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), primitive-out-of-sequence (1), not-loadable (2), dataset-size-too-large (3), not-awaited-segment (4), interpretation-failure (5), storage-failure (6), data-set-not-ready (7) }"}),new i.Property({name:"task",tag:9,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0)"}),new i.Property({name:"task",tag:9,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), no-remote-control (1)"}),new i.Property({name:"task",tag:9,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), no-remote-control (1), ti-stopped (2)"}),new i.Property({name:"task",tag:9,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), no-remote-control (1), ti-stopped (2), ti-running (3)"}),new i.Property({name:"task",tag:9,occurrence:r.Occurrence.implicit,asn1Type:"ENUMERATED",typeParameter:"{ other (0), no-remote-control (1), ti-stopped (2), ti-running (3), ti-unusable (4) }"})]}),$=new c.TypeDefinition({name:"Long-Invoke-Id-And-Priority",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,customType:"Unsigned32"}),j=new c.TypeDefinition({name:"Notification-Body",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"data-value",occurrence:r.Occurrence.none,customType:"Data"})]}),z=new c.TypeDefinition({name:"Get-Request-Normal",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"cosem-attribute-descriptor",occurrence:r.Occurrence.none,customType:"Cosem-Attribute-Descriptor"}),new i.Property({name:"access-selection",occurrence:r.Occurrence.none,customType:"Selective-Access-Descriptor",isOptional:!0})]}),Q=new c.TypeDefinition({name:"Get-Request-Next",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned32"})]}),K=new c.TypeDefinition({name:"Get-Request-With-List",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"attribute-descriptor-list",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Cosem-Attribute-Descriptor-With-Selection"})]}),J=new c.TypeDefinition({name:"Set-Request-Normal",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"cosem-attribute-descriptor",occurrence:r.Occurrence.none,customType:"Cosem-Attribute-Descriptor"}),new i.Property({name:"access-selection",occurrence:r.Occurrence.none,customType:"Selective-Access-Descriptor",isOptional:!0}),new i.Property({name:"value",occurrence:r.Occurrence.none,customType:"Data"})]}),H=new c.TypeDefinition({name:"Set-Request-With-First-Datablock",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"cosem-attribute-descriptor",occurrence:r.Occurrence.none,customType:"Cosem-Attribute-Descriptor"}),new i.Property({name:"access-selection",tag:0,occurrence:r.Occurrence.implicit,customType:"Selective-Access-Descriptor",isOptional:!0}),new i.Property({name:"datablock",occurrence:r.Occurrence.none,customType:"DataBlock-SA"})]}),X=new c.TypeDefinition({name:"Set-Request-With-Datablock",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"datablock",occurrence:r.Occurrence.none,customType:"DataBlock-SA"})]}),Z=new c.TypeDefinition({name:"Set-Request-With-List",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"attribute-descriptor-list",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Cosem-Attribute-Descriptor-With-Selection"}),new i.Property({name:"value-list",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Data"})]}),Y=new c.TypeDefinition({name:"Set-Request-With-List-And-First-Datablock",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"attribute-descriptor-list",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Cosem-Attribute-Descriptor-With-Selection"}),new i.Property({name:"datablock",occurrence:r.Occurrence.none,customType:"DataBlock-SA"})]}),ee=new c.TypeDefinition({name:"Cosem-Attribute-Descriptor",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"class-id",occurrence:r.Occurrence.none,customType:"Cosem-Class-Id"}),new i.Property({name:"instance-id",occurrence:r.Occurrence.none,customType:"Cosem-Object-Instance-Id"}),new i.Property({name:"attribute-id",occurrence:r.Occurrence.none,customType:"Cosem-Object-Attribute-Id"})]}),te=new c.TypeDefinition({name:"Action-Request-Normal",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"cosem-method-descriptor",occurrence:r.Occurrence.none,customType:"Cosem-Method-Descriptor"}),new i.Property({name:"method-invocation-parameters",occurrence:r.Occurrence.none,customType:"Data",isOptional:!0})]}),ne=new c.TypeDefinition({name:"Action-Request-Next-Pblock",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned32"})]}),re=new c.TypeDefinition({name:"Action-Request-With-List",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"cosem-method-descriptor-list",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Cosem-Method-Descriptor"}),new i.Property({name:"method-invocation-parameters",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Data"})]}),ce=new c.TypeDefinition({name:"Action-Request-With-First-Pblock",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"cosem-method-descriptor",occurrence:r.Occurrence.none,customType:"Cosem-Method-Descriptor"}),new i.Property({name:"pblock",occurrence:r.Occurrence.none,customType:"DataBlock-SA"})]}),ie=new c.TypeDefinition({name:"Action-Request-With-List-And-First-Pblock",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"cosem-method-descriptor-list",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Cosem-Method-Descriptor"}),new i.Property({name:"pblock",occurrence:r.Occurrence.none,customType:"DataBlock-SA"})]}),oe=new c.TypeDefinition({name:"Action-Request-With-Pblock",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"pblock",occurrence:r.Occurrence.none,customType:"DataBlock-SA"})]}),ae=new c.TypeDefinition({name:"Get-Response-Normal",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"result",occurrence:r.Occurrence.none,customType:"Get-Data-Result"})]}),se=new c.TypeDefinition({name:"Get-Response-With-Datablock",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"result",occurrence:r.Occurrence.none,customType:"DataBlock-G"})]}),ue=new c.TypeDefinition({name:"Get-Response-With-List",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"result",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Get-Data-Result"})]}),le=new c.TypeDefinition({name:"Set-Response-Normal",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"result",occurrence:r.Occurrence.none,customType:"Data-Access-Result"})]}),me=new c.TypeDefinition({name:"Set-Response-Datablock",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned32"})]}),pe=new c.TypeDefinition({name:"Set-Response-Last-Datablock",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"result",occurrence:r.Occurrence.none,customType:"Data-Access-Result"}),new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned32"})]}),de=new c.TypeDefinition({name:"Set-Response-Last-Datablock-With-List",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"result",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Data-Access-Result"}),new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned32"})]}),ye=new c.TypeDefinition({name:"Set-Response-With-List",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"result",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Data-Access-Result"})]}),ge=new c.TypeDefinition({name:"Action-Response-Normal",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"single-response",occurrence:r.Occurrence.none,customType:"Action-Response-With-Optional-Data"})]}),he=new c.TypeDefinition({name:"Action-Response-With-Pblock",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"pblock",occurrence:r.Occurrence.none,customType:"DataBlock-SA"})]}),Te=new c.TypeDefinition({name:"Action-Response-With-List",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"list-of-responses",occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",subType:"Action-Response-With-Optional-Data"})]}),fe=new c.TypeDefinition({name:"Action-Response-Next-Pblock",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"invoke-id-and-priority",occurrence:r.Occurrence.none,customType:"Invoke-Id-And-Priority"}),new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned32"})]}),be=new c.TypeDefinition({name:"Access-Request-Body",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"access-request-specification",occurrence:r.Occurrence.none,customType:"List-Of-Access-Request-Specification"}),new i.Property({name:"access-request-list-of-data",occurrence:r.Occurrence.none,customType:"List-Of-Data"})]}),Oe=new c.TypeDefinition({name:"Access-Response-Body",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"access-request-specification",tag:0,occurrence:r.Occurrence.none,customType:"List-Of-Access-Request-Specification",isOptional:!0}),new i.Property({name:"access-response-list-of-data",occurrence:r.Occurrence.none,customType:"List-Of-Data"}),new i.Property({name:"access-response-specification",occurrence:r.Occurrence.none,customType:"List-Of-Access-Response-Specification"})]}),we=new c.TypeDefinition({name:"Key-Info",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"identified-key",tag:0,occurrence:r.Occurrence.none,customType:"Identified-Key"}),new i.Property({name:"wrapped-key",tag:1,occurrence:r.Occurrence.none,customType:"Wrapped-Key"}),new i.Property({name:"agreed-key",tag:2,occurrence:r.Occurrence.none,customType:"Agreed-Key"})]}),ve=new c.TypeDefinition({name:"Block-Control",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,customType:"Unsigned8"}),Se=new c.TypeDefinition({name:"Parameterized-Access",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"variable-name",occurrence:r.Occurrence.none,customType:"ObjectName"}),new i.Property({name:"selector",occurrence:r.Occurrence.none,customType:"Unsigned8"}),new i.Property({name:"parameter",occurrence:r.Occurrence.none,customType:"Data"})]}),Pe=new c.TypeDefinition({name:"Block-Number-Access",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned16"})]}),De=new c.TypeDefinition({name:"Read-Data-Block-Access",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"last-block",occurrence:r.Occurrence.none,asn1Type:"BOOLEAN"}),new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned16"}),new i.Property({name:"raw-data",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"})]}),Ne=new c.TypeDefinition({name:"Write-Data-Block-Access",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"last-block",occurrence:r.Occurrence.none,asn1Type:"BOOLEAN"}),new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned16"})]}),Ee=new c.TypeDefinition({name:"Integer32",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"INTEGER",typeParameter:"(-2147483648..2147483647)"}),Ie=new c.TypeDefinition({name:"Unsigned32",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"INTEGER",typeParameter:"(0..4294967295)"}),Re=new c.TypeDefinition({name:"Integer16",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"INTEGER",typeParameter:"(-32768..32767)"}),ke=new c.TypeDefinition({name:"Integer64",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"INTEGER",typeParameter:"(-9223372036854775808..9223372036854775807)"}),Me=new c.TypeDefinition({name:"Unsigned64",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"INTEGER",typeParameter:"(0..18446744073709551615)"}),Ae=new c.TypeDefinition({name:"Invoke-Id-And-Priority",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,customType:"Unsigned8"}),qe=new c.TypeDefinition({name:"Selective-Access-Descriptor",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"access-selector",occurrence:r.Occurrence.none,customType:"Unsigned8"}),new i.Property({name:"access-parameters",occurrence:r.Occurrence.none,customType:"Data"})]}),Be=new c.TypeDefinition({name:"Cosem-Attribute-Descriptor-With-Selection",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"cosem-attribute-descriptor",occurrence:r.Occurrence.none,customType:"Cosem-Attribute-Descriptor"}),new i.Property({name:"access-selection",occurrence:r.Occurrence.none,customType:"Selective-Access-Descriptor",isOptional:!0})]}),Ce=new c.TypeDefinition({name:"DataBlock-SA",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"last-block",occurrence:r.Occurrence.none,asn1Type:"BOOLEAN"}),new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned32"}),new i.Property({name:"raw-data",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"})]}),Ue=new c.TypeDefinition({name:"Cosem-Class-Id",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,customType:"Unsigned16"}),xe=new c.TypeDefinition({name:"Cosem-Object-Instance-Id",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"OCTET STRING",typeParameter:"(SIZE(6))"}),Le=new c.TypeDefinition({name:"Cosem-Object-Attribute-Id",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,customType:"Integer8"}),_e=new c.TypeDefinition({name:"Cosem-Method-Descriptor",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"class-id",occurrence:r.Occurrence.none,customType:"Cosem-Class-Id"}),new i.Property({name:"instance-id",occurrence:r.Occurrence.none,customType:"Cosem-Object-Instance-Id"}),new i.Property({name:"method-id",occurrence:r.Occurrence.none,customType:"Cosem-Object-Method-Id"})]}),Ge=new c.TypeDefinition({name:"Get-Data-Result",blockMode:r.BlockMode.choice,occurrence:r.Occurrence.none,properties:[new i.Property({name:"data",tag:0,occurrence:r.Occurrence.none,customType:"Data"}),new i.Property({name:"data-access-result",tag:1,occurrence:r.Occurrence.implicit,customType:"Data-Access-Result"})]}),Ve=new c.TypeDefinition({name:"DataBlock-G",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"last-block",occurrence:r.Occurrence.none,asn1Type:"BOOLEAN"}),new i.Property({name:"block-number",occurrence:r.Occurrence.none,customType:"Unsigned32"}),new i.Property({name:"result",occurrence:r.Occurrence.none,asn1Type:"CHOICE",typeParameter:"{ raw-data [0] IMPLICIT OCTET STRING"}),new i.Property({name:"result",occurrence:r.Occurrence.none,asn1Type:"CHOICE",typeParameter:"{ raw-data [0] IMPLICIT OCTET STRING, data-access-result [1] IMPLICIT Data-Access-Result }"})]}),Fe=new c.TypeDefinition({name:"Action-Response-With-Optional-Data",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"result",occurrence:r.Occurrence.none,customType:"Action-Result"}),new i.Property({name:"return-parameters",occurrence:r.Occurrence.none,customType:"Get-Data-Result",isOptional:!0})]}),We=new c.TypeDefinition({name:"List-Of-Access-Request-Specification",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",typeParameter:"Access-Request-Specification"}),$e=new c.TypeDefinition({name:"List-Of-Data",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",typeParameter:"Data"}),je=new c.TypeDefinition({name:"List-Of-Access-Response-Specification",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,asn1Type:"SEQUENCE OF",typeParameter:"Access-Response-Specification"}),ze=new c.TypeDefinition({name:"Identified-Key",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"key-id",occurrence:r.Occurrence.none,customType:"Key-Id"})]}),Qe=new c.TypeDefinition({name:"Wrapped-Key",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"kek-id",occurrence:r.Occurrence.none,customType:"Kek-Id"}),new i.Property({name:"key-ciphered-data",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"})]}),Ke=new c.TypeDefinition({name:"Agreed-Key",blockMode:r.BlockMode.sequence,occurrence:r.Occurrence.none,properties:[new i.Property({name:"key-parameters",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"}),new i.Property({name:"key-ciphered-data",occurrence:r.Occurrence.none,asn1Type:"OCTET STRING"})]}),Je=new c.TypeDefinition({name:"Cosem-Object-Method-Id",blockMode:r.BlockMode.single,occurrence:r.Occurrence.none,customType:"Integer8"}),He=new c.TypeDefinition({name:"Action-Result",blockMode:r.BlockMode.enumerated,occurrence:r.Occurrence.none,enumerations:[new o.Enumeration("success",0),new o.Enumeration("hardware-fault",1),new o.Enumeration("temporary-failure",2),new o.Enumeration("read-write-denied",3),new o.Enumeration("object-undefined",4),new o.Enumeration("object-class-inconsistent",9),new o.Enumeration("object-unavailable",11),new o.Enumeration("type-unmatched",12),new o.Enumeration("scope-of-access-violated",13),new o.Enumeration("data-block-unavailable",14),new o.Enumeration("long-action-aborted",15),new o.Enumeration("no-long-action-in-progress",16),new o.Enumeration("other-reason",250)]}),Xe=new c.TypeDefinition({name:"Key-Id",blockMode:r.BlockMode.enumerated,occurrence:r.Occurrence.none,enumerations:[new o.Enumeration("global-unicast-encryption-key",0),new o.Enumeration("global-broadcast-encryption-key",1)]}),Ze=new c.TypeDefinition({name:"Kek-Id",blockMode:r.BlockMode.enumerated,occurrence:r.Occurrence.none,enumerations:[new o.Enumeration("master-key",0)]});t.cosemTypeDefinitionMap=new Map([["XDLMS-APDU",s],["InitiateRequest",u],["ReadRequest",l],["WriteRequest",m],["InitiateResponse",p],["ReadResponse",d],["WriteResponse",y],["ConfirmedServiceError",g],["Data-Notification",h],["UnconfirmedWriteRequest",T],["InformationReportRequest",f],["Get-Request",b],["Set-Request",O],["EventNotificationRequest",w],["Action-Request",v],["Get-Response",S],["Set-Response",P],["Action-Response",D],["ExceptionResponse",N],["Access-Request",E],["Access-Response",I],["General-Glo-Ciphering",R],["General-Ded-Ciphering",k],["General-Ciphering",M],["General-Signing",A],["General-Block-Transfer",q],["Integer8",B],["Unsigned8",C],["Conformance",U],["Unsigned16",x],["Variable-Access-Specification",L],["Data",_],["ObjectName",G],["Data-Access-Result",V],["Data-Block-Result",F],["ServiceError",W],["Long-Invoke-Id-And-Priority",$],["Notification-Body",j],["Get-Request-Normal",z],["Get-Request-Next",Q],["Get-Request-With-List",K],["Set-Request-Normal",J],["Set-Request-With-First-Datablock",H],["Set-Request-With-Datablock",X],["Set-Request-With-List",Z],["Set-Request-With-List-And-First-Datablock",Y],["Cosem-Attribute-Descriptor",ee],["Action-Request-Normal",te],["Action-Request-Next-Pblock",ne],["Action-Request-With-List",re],["Action-Request-With-First-Pblock",ce],["Action-Request-With-List-And-First-Pblock",ie],["Action-Request-With-Pblock",oe],["Get-Response-Normal",ae],["Get-Response-With-Datablock",se],["Get-Response-With-List",ue],["Set-Response-Normal",le],["Set-Response-Datablock",me],["Set-Response-Last-Datablock",pe],["Set-Response-Last-Datablock-With-List",de],["Set-Response-With-List",ye],["Action-Response-Normal",ge],["Action-Response-With-Pblock",he],["Action-Response-With-List",Te],["Action-Response-Next-Pblock",fe],["Access-Request-Body",be],["Access-Response-Body",Oe],["Key-Info",we],["Block-Control",ve],["Parameterized-Access",Se],["Block-Number-Access",Pe],["Read-Data-Block-Access",De],["Write-Data-Block-Access",Ne],["Integer32",Ee],["Unsigned32",Ie],["Integer16",Re],["Integer64",ke],["Unsigned64",Me],["Invoke-Id-And-Priority",Ae],["Selective-Access-Descriptor",qe],["Cosem-Attribute-Descriptor-With-Selection",Be],["DataBlock-SA",Ce],["Cosem-Class-Id",Ue],["Cosem-Object-Instance-Id",xe],["Cosem-Object-Attribute-Id",Le],["Cosem-Method-Descriptor",_e],["Get-Data-Result",Ge],["DataBlock-G",Ve],["Action-Response-With-Optional-Data",Fe],["List-Of-Access-Request-Specification",We],["List-Of-Data",$e],["List-Of-Access-Response-Specification",je],["Identified-Key",ze],["Wrapped-Key",Qe],["Agreed-Key",Ke],["Cosem-Object-Method-Id",Je],["Action-Result",He],["Key-Id",Xe],["Kek-Id",Ze]])},958:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DebugLogger=void 0;const r=n(312),c=n(368),i=n(97);t.DebugLogger=class{constructor(){this.logSerialPortBuffers=[],this.logSerialPortByteCount=0,this.lastLogEpoch=0}logSerialPortData(e){r.DebugSettings.logSerialPortMinBytes<=1||0==this.logSerialPortByteCount&&e.length>=r.DebugSettings.logSerialPortMinBytes?console.log(e.toString("hex")):(this.logSerialPortBuffers.push(e),this.logSerialPortByteCount+=e.length,this.logSerialPortByteCount<r.DebugSettings.logSerialPortMinBytes||(console.log(Buffer.concat(this.logSerialPortBuffers).toString("hex")),this.logSerialPortBuffers=[],this.logSerialPortByteCount=0))}logSerialPortDataEnd(){r.DebugSettings.logSerialPort&&r.DebugSettings.logSerialPortMinBytes>1&&this.logSerialPortByteCount>0&&console.log(Buffer.concat(this.logSerialPortBuffers).toString("hex"))}logTelegrams(e){r.DebugSettings.logTelegramRaw&&e.forEach((e=>{var t;return console.log("Telegram: ",null===(t=e.telegramRaw)||void 0===t?void 0:t.toString("hex"))})),r.DebugSettings.logTelegramJson&&e.forEach((e=>console.log("Telegram: ",e)))}logApplicationDataUnits(e){r.DebugSettings.logApduRaw&&e.forEach((e=>console.log("APDU: ",e.apduRaw.toString("hex")))),r.DebugSettings.logApduJson&&e.forEach((e=>{console.log("APDU:"),console.dir(e,{depth:5})})),r.DebugSettings.logApduEncryptedRaw&&e.forEach((e=>console.log("APDU payload encrypted: ",e.encryptedPayload.toString("hex")))),r.DebugSettings.logApduDecryptedRaw&&e.forEach((e=>console.log("APDU payload decrypted: ",e.decryptedPayload.toString("hex"))))}logCosemData(e){if(r.DebugSettings.logApduCosemJson&&(console.log("APDU COSEM Data:"),console.dir(e,{depth:null})),r.DebugSettings.logApduCosemXml){const t=(new c.SimpleXmlProcessor).transform(e);console.log("APDU COSEM XML: ",t)}}logObisData(e){var t,n;if(r.DebugSettings.logObisValuesJson&&(console.log("Custom Data Notification Obis Data (JSON):"),console.dir(e,{depth:10})),r.DebugSettings.logObisValuesPlain){console.log("Custom Data Notification Obis Data (plain text):"),console.log("Invoke Id:",null===(t=null==e?void 0:e.longInvokeIdAndPriority)||void 0===t?void 0:t.dec),console.log("Datetime:",null===(n=null==e?void 0:e.dateTime)||void 0===n?void 0:n.asString);for(const t of e.notificationBody.obisValues)console.log(t.obisCode,t.obisName,t.stringValue)}}logTimes(e){const t=Date.now(),n=this.lastLogEpoch?((t-this.lastLogEpoch)/1e3).toString():"-",r=i.Tools.dateToLocalIsoWithMs(new Date(t));e?console.log(`${r} - ${n} s - ${e}`):console.log(`${r} - ${n} s - `),this.lastLogEpoch=t}}},82:(e,t)=>{var n,r,c,i;Object.defineProperty(t,"__esModule",{value:!0}),t.KeySet=t.ApplicationDataProvisioning=t.ApplicationDataState=t.TelegramState=void 0,(i=t.TelegramState||(t.TelegramState={}))[i.pending=0]="pending",i[i.available=1]="available",(c=t.ApplicationDataState||(t.ApplicationDataState={}))[c.pending=0]="pending",c[c.available=1]="available",(r=t.ApplicationDataProvisioning||(t.ApplicationDataProvisioning={}))[r.lastOnly=0]="lastOnly",r[r.all=1]="all",(n=t.KeySet||(t.KeySet={}))[n.unicast=0]="unicast",n[n.broadcast=1]="broadcast"},448:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqttClientWrapper=void 0;const r=n(778),c=n(312);t.MqttClientWrapper=class{constructor(){const e={host:c.MqttSettings.host,port:c.MqttSettings.port,clientId:c.MqttSettings.clientId,username:c.MqttSettings.username,password:c.MqttSettings.password,clean:!0};c.MqttSettings.testMode?c.MqttSettings.testModeNoLogging||console.log("MQTT test mode: connect to broker",e):(this.client=(0,r.connect)(e),this.client.on("error",(function(e){console.error(`Unable to connect to ${c.MqttSettings.host}:${c.MqttSettings.port}. Error: ${e}`)})))}publish(e,t){if(this.client&&!this.client.connected)return void console.error(`MQTT client is not connected to broker ${c.MqttSettings.host}:${c.MqttSettings.port}. Ignore publish.`);const n=c.MqttSettings.topicBase+e;c.MqttSettings.testMode?c.MqttSettings.testModeNoLogging||console.log(`MQTT test mode. Publish: '${n}': ${t}`):this.client?this.client.publish(n,t,{qos:0,retain:!1},(e=>{e&&console.error(`Error publishing MQTT topic ${n}. Error: ${e}`)})):console.error(`Error publishing MQTT topic ${n}. Mqtt client object is not defined.`)}}},518:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqttPublisher=void 0;const r=n(312),c=n(448);t.MqttPublisher=class{constructor(){this.lastPublishEpoch=0,this.currentSecondsIntervalIndex=-1,this.nextSecondIntervalEpoch=0,this.currentMinutesIntervalIndex=-1,this.nextMinuteIntervalEpoch=0,this.mqttClient=void 0,r.MqttSettings.enabled&&(this.mqttClient=new c.MqttClientWrapper)}publish(e,t){if(!r.MqttSettings.enabled||!this.mqttClient)return!1;if(t||(t=new Date),!this.checkWhetherToPublish(t))return!1;const n=[];let c;for(const t of e.notificationBody.obisValues){let e;if("0-0:1.0.0*255"!=t.obisCode)e=void 0===t.numberValue||r.MqttSettings.includeUnitInIndividualValues?t.stringValue:t.numberValue.toString(),n.push({code:t.obisCode,name:t.obisName,value:e,unit:t.unit});else{let e;e=t.numberValue?"epoch"===r.MqttSettings.valueDateTimeFormat?t.numberValue.toString():"iso"===r.MqttSettings.valueDateTimeFormat?new Date(t.numberValue).toISOString():"iso-local"===r.MqttSettings.valueDateTimeFormat?t.stringValue:"js"===r.MqttSettings.valueDateTimeFormat?new Date(t.numberValue).toString():t.stringValue:t.stringValue,c={code:t.obisCode,name:t.obisName,value:e}}}if(c&&n.push(c),r.MqttSettings.publishIndividualValues)for(const e of n)this.mqttClient.publish(this.getTopic(e),e.value);return r.MqttSettings.publishSingleJson&&(n.push({name:"InvokeId",value:e.longInvokeIdAndPriority.dec.toString()}),this.mqttClient.publish("json",JSON.stringify(n))),!0}getTopic(e){let t=e.name;if(r.MqttSettings.topicIdentifierReplaceUmlauts&&(t=t.replace("Ä","Ae").replace("Ö","Oe").replace("Ü","Ue").replace("ä","ae").replace("ö","oe").replace("ü","ue").replace("ß","ss")),r.MqttSettings.topicIdentifierInvalidCharsRegex){const e=new RegExp(r.MqttSettings.topicIdentifierInvalidCharsRegex,"g");t=t.replace(e,r.MqttSettings.topicIdentifierInvalidCharsReplacement)}return t}checkWhetherToPublish(e){const t=e.getTime(),n=t-this.lastPublishEpoch;return!(r.MqttSettings.minSecondsBetweenMessages>0&&n<1e3*r.MqttSettings.minSecondsBetweenMessages)&&(!!this.checkWhetherToPublishSecondsInterval(e,t,n)&&(!!this.checkWhetherToPublishMinutesInterval(e,t,n)&&(this.lastPublishEpoch=t,!0)))}checkWhetherToPublishSecondsInterval(e,t,n){if(r.MqttSettings.publishIntervalSeconds.length<=0)return!0;const c=e.getSeconds();if(1===r.MqttSettings.publishIntervalSeconds.length)return this.checkWhetherToPublishSecondsIntervalSingle(e,t,c);const i=this.findIntervalIndexes(r.MqttSettings.publishIntervalSeconds,c);return i.currentIndex==this.currentSecondsIntervalIndex?n>=59500:(this.currentSecondsIntervalIndex=i.currentIndex,!0)}checkWhetherToPublishSecondsIntervalSingle(e,t,n){if(t<this.nextSecondIntervalEpoch)return!1;const c=r.MqttSettings.publishIntervalSeconds[0],i=new Date(e);return i.setSeconds(c),this.nextSecondIntervalEpoch=i.getTime(),n>=c&&(this.nextSecondIntervalEpoch+=6e4),!0}checkWhetherToPublishMinutesInterval(e,t,n){if(r.MqttSettings.publishIntervalMinutes.length<=0)return!0;const c=e.getMinutes();if(1===r.MqttSettings.publishIntervalMinutes.length)return this.checkWhetherToPublishMinutesIntervalSingle(e,t,c);const i=this.findIntervalIndexes(r.MqttSettings.publishIntervalMinutes,c);return i.currentIndex==this.currentMinutesIntervalIndex?n>=3599500:(this.currentMinutesIntervalIndex=i.currentIndex,!0)}checkWhetherToPublishMinutesIntervalSingle(e,t,n){if(t<this.nextMinuteIntervalEpoch)return!1;const c=r.MqttSettings.publishIntervalMinutes[0],i=new Date(e);return i.setMinutes(c),i.setSeconds(0),this.nextMinuteIntervalEpoch=i.getTime(),n>=c&&(this.nextMinuteIntervalEpoch+=36e5),!0}findIntervalIndexes(e,t){if(0==e.length)return{currentIndex:0,nextIndex:0};const n=e.length-1;if(t<e[0])return{currentIndex:n,nextIndex:0};if(t>=e[n])return{currentIndex:n,nextIndex:0};let r=0;for(;t>=e[r+1];)r++;return{currentIndex:r,nextIndex:r+1}}}},222:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MultiTelegramReader=void 0;const r=n(82),c=n(535),i=n(91);class o{constructor(e,t=r.ApplicationDataProvisioning.all,n=!0){this.telegramReader=e,this.provisioning=t,this.decrypt=n,this.applicationDataUnits=[],this.currentApplicationDataUnit=new c.ApplicationProtocolDataUnit,this.currentApplicationDataUnits=[],this.currentSequenceNumber=0}areApplicationDataUnitsAvailable(){return this.applicationDataUnits.length>0?r.ApplicationDataState.available:r.ApplicationDataState.pending}addRawData(e){if(this.telegramReader.addRawData(e)==r.TelegramState.available){const e=this.telegramReader.getTelegrams();return this.addTelegrams(e)}return this.areApplicationDataUnitsAvailable()}addTelegrams(e){for(const t of e)if(t.sequenceNumber==this.currentSequenceNumber)if(t.applicationData){if(0===t.sequenceNumber){if(t.applicationData.length<17){console.warn(`MultiTelegramReader.addTelegrams: Application data length of first telegram in sequence invalid. Start over. Expected: >= 17. Received: ${t.applicationData.length}`),this.resetSearch();continue}if(this.currentApplicationDataUnit.cypheringService=t.applicationData[0],this.currentApplicationDataUnit.cypheringService!=o.cypheringServiceGeneralGloCiphering){console.warn(`MultiTelegramReader.addTelegrams: Application data cyphering service invalid. Start over. Expected: ${o.cypheringServiceGeneralGloCiphering.toString(16)}. Received: ${this.currentApplicationDataUnit.cypheringService.toString(16)}`),this.resetSearch();continue}this.currentApplicationDataUnit.setSystemTitle(t.applicationData.subarray(2,10));const e=this.currentApplicationDataUnit.setLength(t.applicationData,10,13);if(0==e){console.warn("MultiTelegramReader.addTelegrams: Invalid length field length. Start over."),this.resetSearch();continue}const n=e-1;this.currentApplicationDataUnit.securityControl=t.applicationData[11+n],this.currentApplicationDataUnit.setFrameCounter(t.applicationData,12+n,16+n)}this.currentApplicationDataUnits.push(t.applicationData),t.isLastSegment?(this.currentApplicationDataUnit.apduRaw=Buffer.concat(this.currentApplicationDataUnits),this.currentApplicationDataUnit.encryptedPayload=this.currentApplicationDataUnit.apduRaw.subarray(16+this.currentApplicationDataUnit.lengthFieldLength-1),this.decrypt&&(i.ApplicationDataDecrypter.Decrypt(this.currentApplicationDataUnit),this.currentApplicationDataUnit.lengthEncryptedPayload!=this.currentApplicationDataUnit.encryptedPayload.length)?(console.warn(`addTelegrams: Application data length of combined segments invalid. Start over. Expected: ${this.currentApplicationDataUnit.lengthEncryptedPayload}. Received: ${this.currentApplicationDataUnit.encryptedPayload.length}`),this.resetSearch()):(this.provisioning==r.ApplicationDataProvisioning.all?this.applicationDataUnits.push(this.currentApplicationDataUnit):this.applicationDataUnits=[this.currentApplicationDataUnit],this.resetSearch())):this.currentSequenceNumber++}else console.warn("MultiTelegramReader.addTelegrams: Application data not set."),this.resetSearch();else console.log(`MultiTelegramReader.addTelegrams: Sequence number does not match. Start over. Expected: ${this.currentSequenceNumber}. Received: ${t.sequenceNumber}`),this.resetSearch();return this.areApplicationDataUnitsAvailable()}getApplicationDataUnits(){const e=[...this.applicationDataUnits];return this.applicationDataUnits=[],e}resetSearch(){this.currentSequenceNumber=0,this.currentApplicationDataUnit=new c.ApplicationProtocolDataUnit,this.currentApplicationDataUnits=[]}}t.MultiTelegramReader=o,o.cypheringServiceGeneralGloCiphering=219},286:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ObisTools=void 0;const r=n(914),c=n(312);class i{static getObisCode(e,t="de"){let n,c,o,a,s,u="";const l=i.getSingleFromRaw(e,0);null!=l&&(u=l.toString(),n=i.getSingleFromRaw(e,1),null!=n&&(u+=`-${n}`,c=i.getSingleFromRaw(e,2),null!=c&&(u+=`:${c}`,o=i.getSingleFromRaw(e,3),null!=o&&(u+=`.${o}`,a=i.getSingleFromRaw(e,4),null!=a&&(u+=`.${a}`,s=i.getSingleFromRaw(e,5),null!=s&&(u+=`*${s}`))))));let m=i.getCustomObisNames(u,t);if(!m){const e=new r.ObisMeasurement;e.medium=null!=l?l:0,e.channel=null!=n?n:0,e.measurement=null!=c?c:0,e.measureType=null!=o?o:0,e.tariffRate=null!=a?a:0,e.previousMeasurement=null!=s?s:0,m=r.ObisNames.resolveObisName(e,"de"==t?"de":"en")}return{code:u,fullName:`${m.mediumName} ${m.obisName}`,name:this.getObisNameFromObisMeasurementNames(m),medium:m.mediumName,channel:m.channelName,measurement:m.measurementName,measurementType:m.measurementTypeName,tariff:m.tariffRateName,previousMeasurement:m.previousMeasurementName}}static getObisNameFromObisMeasurementNames(e){let t=c.DecodingSettings.obisNameFormat;t=t.replace("[medium]",e.mediumName),t=t.replace("[channel]",e.channelName),t=t.replace("[measurement]",e.measurementName),t=t.replace("[measurementType]",e.measurementTypeName),t=t.replace("[tariff]",e.tariffRateName),t=t.replace("[previousMeasurement]",e.previousMeasurementName);const n=c.DecodingSettings.obisNameDelimiterCharacters.split("");for(const e of n)t.replace(e+e+e,e),t.replace(e+e,e);let r=t.length-1;for(;r>=0&&c.DecodingSettings.obisNameDelimiterCharacters.indexOf(t[r])>=0;)t=t.substring(0,r),r--;return t}static getSingleFromRaw(e,t){if(!(e.length<=t))return e[t]}static getCustomObisNames(e,t){if("de"==t){if("0-0:1.0.0*255"==e)return this.getObisMeasurementNames("Abstrakt","Zeitpunkt");if("0-0:96.1.0*255"==e)return this.getObisMeasurementNames("Abstrakt","Zählernummer");if("0-0:42.0.0*255"==e)return this.getObisMeasurementNames("Abstrakt","Cosem logischer Gerätename");if("1-0:1.7.0*255"==e)return this.getObisMeasurementNames("Strom","Momentanleistung Bezug +P");if("1-0:2.7.0*255"==e)return this.getObisMeasurementNames("Strom","Momentanleistung Lieferung -P");if("1-0:1.8.0*255"==e)return this.getObisMeasurementNames("Strom","Summe Wirkenergie Bezug +A");if("1-0:2.8.0*255"==e)return this.getObisMeasurementNames("Strom","Summe Wirkenergie Lieferung -A");if("1-0:3.8.0*255"==e)return this.getObisMeasurementNames("Strom","Summe Blindenergie Bezug +R");if("1-0:4.8.0*255"==e)return this.getObisMeasurementNames("Strom","Summe Blindenergie Lieferung -R")}else{if("0-0:1.0.0*255"==e)return this.getObisMeasurementNames("Abstrakt","Timestamp");if("0-0:96.1.0*255"==e)return this.getObisMeasurementNames("Abstrakt","Smart meter number");if("0-0:42.0.0*255"==e)return this.getObisMeasurementNames("Abstrakt","Cosem logical device name")}}static getObisMeasurementNames(e,t){return{mediumName:e,channelName:"",measurementName:t,measurementTypeName:"",tariffRateName:"",previousMeasurementName:"",customName:"",obisName:""}}}t.ObisTools=i},794:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReceiveBuffer=void 0,t.ReceiveBuffer=class{get length(){return this._length}constructor(e,t=8192){this.initialSize=e,this.maxSize=t,this._length=0,this.buffer=Buffer.allocUnsafe(e)}reset(){this._length=0}addBuffer(e,t=0){const n=e.length-t+this._length;if(n>this.buffer.length){if(n>this.maxSize)return console.error(`ReceiveBuffer.addBuffer overflow. Buffer size: ${this.buffer.length}. Max size: ${this.maxSize}. Current length: ${this._length}. New data length: ${e.length-t}`),!1;if(this.buffer.length<this.maxSize){console.warn(`ReceiveBuffer.addBuffer overflow. Buffer size: ${this.buffer.length}. Current length: ${this._length}. New data length: ${e.length-t}. Size increased to ${this.maxSize}`);const n=Buffer.allocUnsafe(this.maxSize);this._length>0&&this.buffer.copy(n,0,0,this._length),this.buffer=n}}return e.copy(this.buffer,this._length,t),this._length=n,!0}checkForNewStartIndex(e){const t=this.buffer.indexOf(e,1);return t<1||t>=this._length?(this._length=0,!1):(this.buffer.copy(this.buffer,0,t,this._length),this._length-=t,!0)}asNumberArray(){const e=new Array(this._length);for(let t=0;t<this._length;t++)e[t]=this.buffer[t];return e}}},312:function(e,t,n){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Settings=t.DebugSettings=t.MqttSettings=t.DecodingSettings=t.DecryptionSettings=t.SerialPortSettings=void 0;const c=r(n(771));class i{static read(){i.port=c.default.get("serialPort.port"),i.baudRate=c.default.get("serialPort.baudRate"),i.dataBits=c.default.get("serialPort.dataBits"),i.parity=c.default.get("serialPort.parity"),i.stopBits=c.default.get("serialPort.stopBits")}}t.SerialPortSettings=i,i.port="",i.baudRate=2400,i.dataBits=8,i.parity="none",i.stopBits=1;class o{static read(){o.key=c.default.get("decryption.key")}}t.DecryptionSettings=o,o.key="";class a{static read(){a.language=c.default.get("decoding.obisLanguage"),a.obisNameFormat=c.default.get("decoding.obisNameFormat"),a.obisNameDelimiterCharacters=c.default.get("decoding.obisNameDelimiterCharacters")}}t.DecodingSettings=a,a.language="en",a.obisNameFormat="[measurement]",a.obisNameDelimiterCharacters="";class s{static read(){s.enabled=c.default.get("mqtt.enabled"),s.testMode=c.default.get("mqtt.testMode"),s.host=c.default.get("mqtt.host"),s.port=c.default.get("mqtt.port"),s.clientId=c.default.get("mqtt.clientId"),s.username=c.default.get("mqtt.username"),s.password=c.default.get("mqtt.password"),s.topicBase=c.default.get("mqtt.topicBase"),s.topicBase.endsWith("/")||(s.topicBase="/"),s.topicObisIdentifier=c.default.get("mqtt.topicObisIdentifier"),s.topicIdentifierInvalidCharsRegex=c.default.get("mqtt.topicIdentifierInvalidCharsRegex"),s.topicIdentifierInvalidCharsReplacement=c.default.get("mqtt.topicIdentifierInvalidCharsReplacement"),s.topicIdentifierReplaceUmlauts=c.default.get("mqtt.topicIdentifierReplaceUmlauts"),s.publishSingleJson=c.default.get("mqtt.publishSingleJson"),s.publishIndividualValues=c.default.get("mqtt.publishIndividualValues"),s.includeUnitInIndividualValues=c.default.get("mqtt.includeUnitInIndividualValues"),s.valueDateTimeFormat=c.default.get("mqtt.valueDateTimeFormat"),s.minSecondsBetweenMessages=c.default.get("mqtt.minSecondsBetweenMessages"),s.publishIntervalSeconds=s.stringToNumberArray(c.default.get("mqtt.publishIntervalSeconds"),"mqtt.publishIntervalSeconds"),s.publishIntervalMinutes=s.stringToNumberArray(c.default.get("mqtt.publishIntervalMinutes"),"mqtt.publishIntervalMinutes")}static stringToNumberArray(e,t){var n,r;if(!e)return[];const c=e.replace(/\s/g,"");if(!c)return[];const i=null!==(r=null===(n=c.split(","))||void 0===n?void 0:n.map((e=>+e)))&&void 0!==r?r:[];return i.join(",")!=c?(console.error(`Invalid value for setting "${t}". Must be comma separated string. Value: "${e}". Interpreted as: "${i.join(", ")}". Ignored!`),[]):i}}t.MqttSettings=s,s.enabled=!1,s.testMode=!1,s.testModeNoLogging=!1,s.host="",s.port=1883,s.clientId="",s.username="",s.password="",s.topicBase="SmartMeter/Electricity/",s.topicObisIdentifier="name",s.topicIdentifierInvalidCharsRegex="",s.topicIdentifierInvalidCharsReplacement="",s.topicIdentifierReplaceUmlauts=!0,s.publishSingleJson=!1,s.publishIndividualValues=!1,s.includeUnitInIndividualValues=!1,s.valueDateTimeFormat="epoch",s.minSecondsBetweenMessages=0,s.publishIntervalSeconds=[],s.publishIntervalMinutes=[];class u{static read(){u.maxBytes=c.default.get("debug.maxBytes"),u.maxTelegrams=c.default.get("debug.maxTelegrams"),u.maxApplicationDataUnits=c.default.get("debug.maxApplicationDataUnits"),u.logSerialPort=c.default.get("debug.logSerialPort"),u.logSerialPortMinBytes=c.default.get("debug.logSerialPortMinBytes"),u.logTelegramRaw=c.default.get("debug.logTelegramRaw"),u.logTelegramJson=c.default.get("debug.logTelegramJson"),u.logApduRaw=c.default.get("debug.logApduRaw"),u.logApduJson=c.default.get("debug.logApduJson"),u.logApduEncryptedRaw=c.default.get("debug.logApduEncryptedRaw"),u.logApduDecryptedRaw=c.default.get("debug.logApduDecryptedRaw"),u.logApduCosemJson=c.default.get("debug.logApduCosemJson"),u.logApduCosemXml=c.default.get("debug.logApduCosemXml"),u.logObisValuesJson=c.default.get("debug.logObisValuesJson"),u.logObisValuesPlain=c.default.get("debug.logObisValuesPlain"),u.logTimes=c.default.get("debug.logTimes")}}t.DebugSettings=u,u.maxBytes=0,u.maxTelegrams=0,u.maxApplicationDataUnits=0;class l{static read(){i.read(),o.read(),a.read(),s.read(),u.read()}}t.Settings=l,l.serialPort=i,l.decryption=o,l.decoding=a,l.mqtt=s,l.debug=u},368:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleXmlProcessor=void 0;class n{constructor(e,t,n=[],r){this.tagName=e,this.attributes=n,this.comment=r,this.children=[],t&&(this.children=t)}}t.SimpleXmlProcessor=class{transform(e){const t=this.analyzeTypeDefinition(e);return t.xmlNode?this.buildXml(t.xmlNode):(console.warn("SimpleXmlProcessor.SimpleXmlProcessor No nodes found."),"")}buildXml(e,t=0){var n,r;const c="\t".repeat(t);let i="";e.attributes.length>0&&(i=" "+e.attributes.map((e=>`${e.name}="${this.xmlAttributeEncoding(e.value)}"`)).join(" "));const o=e.comment?` \x3c!-- ${e.comment} --\x3e`:"",a=null!==(r=null===(n=e.children)||void 0===n?void 0:n.length)&&void 0!==r&&r,s=a?"":"/",u=this.xmlTagNameEncoding(e.tagName);let l=`${c}<${u}${i}${s}>${o}\n`;if(!a)return l;for(const n of e.children)l+=this.buildXml(n,t+1);return l+=`${c}</${u}>\n`,l}xmlAttributeEncoding(e){return e.replace("&","&").replace('"',""").replace("<","<")}xmlTagNameEncoding(e){return e.replace(/[^a-zA-Z0-9\-_]/,"_").split("-").map((e=>e[0].toUpperCase()+e.slice(1))).join("")}analyzeTypeDefinition(e){if(0==e.results.length){let t;return e.dateTimeValue?t=e.dateTimeValue.asString:null!=e.numberValue?(t=e.numberValue.toString(),e.stringValue&&(t+=`, ${e.stringValue}`)):t=e.stringValue,e.propertyName?{xmlNode:new n(e.propertyName,void 0,[{name:"Value",value:e.hexString}],t)}:{value:e.hexString,comment:t}}const t=[];if(1==e.results.length){const r=this.analyzeTypeDefinition(e.results[0]);if(!r.xmlNode){const t=null==r.value?void 0:[{name:"Value",value:r.value}];return e.propertyName?{xmlNode:new n(e.propertyName,void 0,t,r.comment)}:r}if(!e.propertyName)return r;t.push(r.xmlNode)}else for(const n of e.results){const r=this.analyzeTypeDefinition(n);r.xmlNode?t.push(r.xmlNode):console.error(`SimpleXmlProcessor.analyzeTypeDefinition cosemAsn1Result ${e.propertyName} ${e.typeName} has multiple children but ${n.typeName} is probably missing a propertyName ${n.propertyName} so xmlTag missing.`)}const r=[];return null!=e.count&&r.push({name:"Qty",value:e.count.toString()}),e.propertyName?{xmlNode:new n(e.propertyName,t,r)}:(console.error(`SimpleXmlProcessor.analyzeTypeDefinition cosemAsn1Result ${e.propertyName} ${e.typeName} has multiple children but has no propertyName. No valid XML.`),{xmlNode:new n("__MissingPropertyName__",t,r)})}}},145:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TelegramReader=void 0;const r=n(82),c=n(745),i=n(794);class o{constructor(){this.currentTelegram=new c.Telegram,this.possibleStartFound=!1,this.receiveBuffer=new i.ReceiveBuffer(o.receiveBufferInitialSize,o.receiveBufferMaxSize),this.telegrams=[]}areTelegramsAvailable(){return this.telegrams.length>0?r.TelegramState.available:r.TelegramState.pending}addRawData(e){let t=0;if(!this.possibleStartFound){if(t=e.indexOf(o.startByte),t<0)return this.areTelegramsAvailable();this.possibleStartFound=!0}return this.receiveBuffer.addBuffer(e,t)?this.checkTelegram():(this.receiveBuffer.reset(),this.resetSearch(),this.areTelegramsAvailable())}getTelegrams(){const e=[...this.telegrams];return this.telegrams=[],e}resetSearch(){this.possibleStartFound=!1,this.currentTelegram=new c.Telegram}checkTelegram(){if(this.receiveBuffer.length<4)return this.areTelegramsAvailable();if(this.currentTelegram.lengthData<=0){if(this.receiveBuffer.buffer[3]!=o.startByte||this.receiveBuffer.buffer[1]!=this.receiveBuffer.buffer[2])return this.checkForNewStartIndex();this.currentTelegram.lengthData=this.receiveBuffer.buffer[1]}if(this.currentTelegram.lengthData<=3)return this.checkForNewStartIndex();if(this.receiveBuffer.length<this.currentTelegram.lengthTotal)return this.areTelegramsAvailable();if(this.receiveBuffer.buffer[this.currentTelegram.lengthTotal-1]!=o.stopByte)return this.checkForNewStartIndex();const e=this.checkChecksum();if(this.currentTelegram.checkSum=this.receiveBuffer.buffer[this.currentTelegram.lengthTotal-2],e!=this.currentTelegram.checkSum)return console.warn("Invalid checksum",e,this.currentTelegram.checkSum),this.checkForNewStartIndex();this.currentTelegram.telegramRaw=this.receiveBuffer.buffer.subarray(0,this.currentTelegram.lengthTotal),this.currentTelegram.controlField=this.receiveBuffer.buffer[4],this.currentTelegram.addressField=this.receiveBuffer.buffer[5],this.currentTelegram.controlInformationField=this.receiveBuffer.buffer[6],this.currentTelegram.sourceAddress=this.receiveBuffer.buffer[7],this.currentTelegram.destinationAddress=this.receiveBuffer.buffer[8],this.currentTelegram.applicationData=this.receiveBuffer.buffer.subarray(9,this.currentTelegram.lengthTotal-2),this.telegrams.push(this.currentTelegram);const t=this.currentTelegram.lengthTotal;if(this.resetSearch(),this.receiveBuffer.length<=t)return this.receiveBuffer=new i.ReceiveBuffer(o.receiveBufferInitialSize,o.receiveBufferMaxSize),r.TelegramState.available;const n=this.receiveBuffer;return this.receiveBuffer=new i.ReceiveBuffer(o.receiveBufferInitialSize,o.receiveBufferMaxSize),this.receiveBuffer.addBuffer(n.buffer.subarray(0,n.length),t),this.checkTelegram()}checkForNewStartIndex(){return this.resetSearch(),this.receiveBuffer.checkForNewStartIndex(o.startByte)?(this.possibleStartFound=!0,this.checkTelegram()):this.areTelegramsAvailable()}checkChecksum(){const e=this.currentTelegram.lengthTotal-2;let t=0;for(let n=4;n<e;n++)t+=this.receiveBuffer.buffer[n];return 255&t}}t.TelegramReader=o,o.startByte=104,o.stopByte=22,o.receiveBufferInitialSize=512,o.receiveBufferMaxSize=8192},745:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Telegram=void 0,t.Telegram=class{constructor(){this._lengthData=0,this._lengthTotal=0,this._lengthTransportData=0,this._lengthApplicationData=0,this.checkSum=-1,this.controlField=0,this.addressField=0,this._controlInformationField=0,this._sequenceNumber=0,this._isLastSegment=!0,this.sourceAddress=0,this.destinationAddress=0}set lengthData(e){this._lengthData=e,this._lengthTotal=e+6,this._lengthTransportData=e-2,this._lengthApplicationData=e-5}get lengthData(){return this._lengthData}get lengthTotal(){return this._lengthTotal}get lengthTransportData(){return this._lengthTransportData}get lengthApplicationData(){return this._lengthApplicationData}set controlInformationField(e){this._controlInformationField=e,this._sequenceNumber=15&this._controlInformationField,this._isLastSegment=16==(16&this._controlInformationField)}get controlInformationField(){return this._controlInformationField}get sequenceNumber(){return this._sequenceNumber}get isLastSegment(){return this._isLastSegment}}},97:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Tools=void 0,t.Tools=class{static getStringFromByteArray(e){return String.fromCharCode(...e)}static getNumberFromByteArray(e){let t=0;for(let n=e.length-1,r=1;n>=0;n--)t+=e[n]*r,r*=256;return t}static getByteArrayFromHexString(e){e=e.replace(/\s+/g,"");const t=[];for(let n=0;n<e.length;n+=2)t.push(parseInt(e.substring(n,n+2),16));return t}static getHexStringFromByteArray(e,t=!1){const n=[];for(let t=0;t<e.length;t++){const r=e[t]<0?e[t]+256:e[t];n.push((r>>>4).toString(16)),n.push((15&r).toString(16))}return n.join(t?" ":"")}static getNumberFromBuffer(e,t=0,n){null==n&&(n=e.length);let r=0;for(let c=n-1,i=1;c>=t;c--)r+=e[c]*i,i*=256;return r}static dateToLocalIso(e){const t=e.getTimezoneOffset();let n=new Date(e.getTime()-60*t*1e3).toISOString();return n=`${n.substring(0,10)} ${n.substring(11,19)}`,n}static dateToLocalIsoWithMs(e){const t=e.getTimezoneOffset();let n=new Date(e.getTime()-60*t*1e3).toISOString();return n=`${n.substring(0,10)} ${n.substring(11,23)}`,n}}},771:e=>{e.exports=require("config")},778:e=>{e.exports=require("mqtt")},605:e=>{e.exports=require("serialport")},914:e=>{e.exports=require("smartmeter-obis")},113:e=>{e.exports=require("crypto")}},t={};function n(r){var c=t[r];if(void 0!==c)return c.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}var r={};for(var c in(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0});const t=n(605),c=n(145),i=n(82),o=n(222),a=n(312),s=n(323),u=n(111),l=n(629),m=n(958),p=n(518);let d,y=0,g=0,h=0,T=!1;const f=new m.DebugLogger;let b=!1;!function(){a.Settings.read(),T=a.DebugSettings.maxBytes>0||a.DebugSettings.maxTelegrams>0||a.DebugSettings.maxApplicationDataUnits>0,d=new t.SerialPort({path:a.SerialPortSettings.port,baudRate:a.SerialPortSettings.baudRate,dataBits:a.SerialPortSettings.dataBits,parity:a.SerialPortSettings.parity,stopBits:a.SerialPortSettings.stopBits});const e=new c.TelegramReader,n=new o.MultiTelegramReader(e),r=new s.CosemDataReader(u.cosemTypeDefinitionMap,"XDLMS-APDU"),m=new l.CosemObisDataProcessor,O=new p.MqttPublisher;d.on("data",(function(t){if(a.DebugSettings.logSerialPort&&f.logSerialPortData(t),y+=t.length,a.DebugSettings.logTimes&&!b&&(b=!0,f.logTimes("first serial port bytes")),e.addRawData(t)===i.TelegramState.available){const t=e.getTelegrams();if(a.DebugSettings.logTimes&&f.logTimes("telegramReader.addRawData && telegramReader.getTelegrams"),g+=t.length,f.logTelegrams(t),n.addTelegrams(t)===i.ApplicationDataState.available){const e=n.getApplicationDataUnits();a.DebugSettings.logTimes&&(b=!1,f.logTimes("multiTelegramReader.addTelegrams && multiTelegramReader.getApplicationDataUnits")),h+=e.length,f.logApplicationDataUnits(e);for(const t of e){const e=r.read(t.decryptedPayload);if(a.DebugSettings.logTimes&&f.logTimes("cosemDataReader.read"),!e)continue;f.logCosemData(e);const n=m.transform(e);a.DebugSettings.logTimes&&f.logTimes("cosemObisDataProcessor.transform"),n&&(f.logObisData(n),O.publish(n),a.DebugSettings.logTimes&&f.logTimes("mqttPublisher.publish"))}}}T&&((0===a.DebugSettings.maxBytes||y<a.DebugSettings.maxBytes)&&(0===a.DebugSettings.maxTelegrams||g<a.DebugSettings.maxTelegrams)&&(0===a.DebugSettings.maxApplicationDataUnits||h<a.DebugSettings.maxApplicationDataUnits)||(f.logSerialPortDataEnd(),d.close((e=>{e&&console.error(e),process.exit(1)})),console.log(`Stopping because of Debug config: maxBytes (${a.DebugSettings.maxBytes}), maxTelegrams (${a.DebugSettings.maxTelegrams}) or maxApplicationDataUnits (${a.DebugSettings.maxApplicationDataUnits}) > 0 ...`)))})),d.on("error",(function(e){console.error("Serial port error: ",e.message)}))}()})(),r)this[c]=r[c];r.__esModule&&Object.defineProperty(this,"__esModule",{value:!0})})();
//# sourceMappingURL=smart-meter-mbus-dlms.js.map