refactor: consolidate default values handling
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 10 Feb 2024 12:19:52 +0000 (13:19 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 10 Feb 2024 12:19:52 +0000 (13:19 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
14 files changed:
README.md
package.json
pnpm-lock.yaml
src/charging-station/Bootstrap.ts
src/charging-station/ChargingStation.ts
src/charging-station/Helpers.ts
src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
src/charging-station/ocpp/2.0/OCPP20RequestService.ts
src/charging-station/ocpp/2.0/OCPP20ResponseService.ts
src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts
src/exception/OCPPError.ts
src/types/ChargingStationWorker.ts
src/utils/Constants.ts
ui/web/pnpm-lock.yaml

index 3ee86b24a41897f364a4654370436f23e92168cd..2234043f48ec2078d2eb24b654a1271a3964c22f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -577,7 +577,8 @@ Set the Websocket header _Sec-Websocket-Protocol_ to `ui0.0.1`.
    `autoStart?`: boolean,  
    `autoRegister?`: boolean,  
    `enableStatistics?`: boolean,  
-   `ocppStrictCompliance?`: boolean  
+   `ocppStrictCompliance?`: boolean,  
+   `stopTransactionsOnStopped?`: boolean  
    }  
   }
 
index 5cafe50f0b1dda2217300acc6b58e4ed3e26aedd..40521799522e03958f9c8446b8e1ae41bc4a01bb 100644 (file)
     }
   },
   "dependencies": {
-    "@mikro-orm/core": "^6.1.0",
-    "@mikro-orm/mariadb": "^6.1.0",
-    "@mikro-orm/reflection": "^6.1.0",
-    "@mikro-orm/sqlite": "^6.1.0",
+    "@mikro-orm/core": "^6.1.1",
+    "@mikro-orm/mariadb": "^6.1.1",
+    "@mikro-orm/reflection": "^6.1.1",
+    "@mikro-orm/sqlite": "^6.1.1",
     "ajv": "^8.12.0",
     "ajv-formats": "^2.1.1",
     "basic-ftp": "^5.0.4",
   "devDependencies": {
     "@commitlint/cli": "^18.6.0",
     "@commitlint/config-conventional": "^18.6.0",
-    "@mikro-orm/cli": "^6.1.0",
+    "@mikro-orm/cli": "^6.1.1",
     "@release-it/bumper": "^6.0.1",
     "@types/node": "^20.11.17",
     "@types/tar": "^6.1.11",
     "rimraf": "^5.0.5",
     "semver": "^7.6.0",
     "ts-node": "^10.9.2",
-    "tsx": "^4.7.0",
+    "tsx": "^4.7.1",
     "typescript": "~5.3.3"
   }
 }
index 727d0e9e77e5c7565c7cb5e2d3dc042d42c2c135..e476785f168084c60faadde71d025f06abf75c3c 100644 (file)
@@ -15,17 +15,17 @@ overrides:
 
 dependencies:
   '@mikro-orm/core':
-    specifier: ^6.1.0
-    version: 6.1.0
+    specifier: ^6.1.1
+    version: 6.1.1
   '@mikro-orm/mariadb':
-    specifier: ^6.1.0
-    version: 6.1.0(@mikro-orm/core@6.1.0)
+    specifier: ^6.1.1
+    version: 6.1.1(@mikro-orm/core@6.1.1)
   '@mikro-orm/reflection':
-    specifier: ^6.1.0
-    version: 6.1.0(@mikro-orm/core@6.1.0)
+    specifier: ^6.1.1
+    version: 6.1.1(@mikro-orm/core@6.1.1)
   '@mikro-orm/sqlite':
-    specifier: ^6.1.0
-    version: 6.1.0(@mikro-orm/core@6.1.0)
+    specifier: ^6.1.1
+    version: 6.1.1(@mikro-orm/core@6.1.1)
   ajv:
     specifier: ^8.12.0
     version: 8.12.0
@@ -88,8 +88,8 @@ devDependencies:
     specifier: ^18.6.0
     version: 18.6.0
   '@mikro-orm/cli':
-    specifier: ^6.1.0
-    version: 6.1.0
+    specifier: ^6.1.1
+    version: 6.1.1
   '@release-it/bumper':
     specifier: ^6.0.1
     version: 6.0.1(release-it@17.0.3)
@@ -184,8 +184,8 @@ devDependencies:
     specifier: ^10.9.2
     version: 10.9.2(@types/node@20.11.17)(typescript@5.3.3)
   tsx:
-    specifier: ^4.7.0
-    version: 4.7.0
+    specifier: ^4.7.1
+    version: 4.7.1
   typescript:
     specifier: ~5.3.3
     version: 5.3.3
@@ -1171,14 +1171,14 @@ packages:
     resolution: {integrity: sha512-9b8mPpKrfeGRuhFH5iO1iwCLeIIsV6+H1sRfxbkoGXIyQE2BTsPd9zqSqQJ+pv5sJ/hT5M1zvOFL02MnEezFug==}
     dev: true
 
-  /@mikro-orm/cli@6.1.0:
-    resolution: {integrity: sha512-uUbbSGPN9fuJEjtfQJ8RiTIAcf+kLgEinkvp7ywycsX02gXYtOpTqtvXm5Mj4Zju7XXpXcqJDlxav++GNR0gmg==}
+  /@mikro-orm/cli@6.1.1:
+    resolution: {integrity: sha512-1wh2dB60ScaOdQgyn6Zt7QJkk3r70ryiSC6vJ+uCuGzhjK5tnloGTzmYL/u/nIzCcLZhZKU113bcdShPsCx7/w==}
     engines: {node: '>= 18.12.0'}
     hasBin: true
     dependencies:
       '@jercle/yargonaut': 1.1.5
-      '@mikro-orm/core': 6.1.0
-      '@mikro-orm/knex': 6.1.0(@mikro-orm/core@6.1.0)(sqlite3@5.1.7)
+      '@mikro-orm/core': 6.1.1
+      '@mikro-orm/knex': 6.1.1(@mikro-orm/core@6.1.1)(sqlite3@5.1.7)
       fs-extra: 11.2.0
       tsconfig-paths: 4.2.0
       yargs: 17.7.2
@@ -1193,8 +1193,8 @@ packages:
       - tedious
     dev: true
 
-  /@mikro-orm/core@6.1.0:
-    resolution: {integrity: sha512-jP0UzzpyWuE/jxXMesix16SLCsg8nBbogSuKKx3HQOnjd1xafPo4cCjaNFLlmSQbllbEbgTgsvy8Zh354A0X2g==}
+  /@mikro-orm/core@6.1.1:
+    resolution: {integrity: sha512-djnTurlUqjF/dwC2C9Xjyj3TqfvzBpF3T8EbYNWivwhvwphCCQSL30txHxaGLn8TA0B220y5L+K3813PnNKsog==}
     engines: {node: '>= 18.12.0'}
     dependencies:
       dataloader: 2.2.2
@@ -1202,16 +1202,16 @@ packages:
       esprima: 4.0.1
       fs-extra: 11.2.0
       globby: 11.1.0
-      mikro-orm: 6.1.0
+      mikro-orm: 6.1.1
       reflect-metadata: 0.2.1
 
-  /@mikro-orm/knex@6.1.0(@mikro-orm/core@6.1.0)(sqlite3@5.1.7):
-    resolution: {integrity: sha512-GEY/ywUxfo/te+1STi8yVXRNUqqS76QC0doDwrh2JHC73iq5tuuq7Nfw7VdLU6QGbarzUIhJOQHclfwTdZuHlQ==}
+  /@mikro-orm/knex@6.1.1(@mikro-orm/core@6.1.1)(sqlite3@5.1.7):
+    resolution: {integrity: sha512-FwYf1s+VC2GzE0Bg0aasuelfu4NKhO+HDwPanr4L2ixP78aURPrSihKuX7m9SRh38GDm/XtmywHXyW7UANX3SQ==}
     engines: {node: '>= 18.12.0'}
     peerDependencies:
       '@mikro-orm/core': ^6.0.0
     dependencies:
-      '@mikro-orm/core': 6.1.0
+      '@mikro-orm/core': 6.1.1
       fs-extra: 11.2.0
       knex: 3.1.0(sqlite3@5.1.7)
       sqlstring: 2.3.3
@@ -1225,14 +1225,14 @@ packages:
       - supports-color
       - tedious
 
-  /@mikro-orm/mariadb@6.1.0(@mikro-orm/core@6.1.0):
-    resolution: {integrity: sha512-bMR2keGwVgstbWo+c6Dee5oPuoG3/8AlheUtq6D1SbD1PiQT4EoJ48knejLyxcqc/uBW35uIXZ0xnE0l3rsuCA==}
+  /@mikro-orm/mariadb@6.1.1(@mikro-orm/core@6.1.1):
+    resolution: {integrity: sha512-SJiBi0a5gVWtbPyxmQDizQdOM6Gt91Lp17okhLxEhsJ+oMcPPcqCl6SeRcZO2CXAQXixwgzq9lfaKBb0iMttaA==}
     engines: {node: '>= 18.12.0'}
     peerDependencies:
       '@mikro-orm/core': ^6.0.0
     dependencies:
-      '@mikro-orm/core': 6.1.0
-      '@mikro-orm/knex': 6.1.0(@mikro-orm/core@6.1.0)(sqlite3@5.1.7)
+      '@mikro-orm/core': 6.1.1
+      '@mikro-orm/knex': 6.1.1(@mikro-orm/core@6.1.1)(sqlite3@5.1.7)
       mariadb: 2.5.6
     transitivePeerDependencies:
       - better-sqlite3
@@ -1245,25 +1245,25 @@ packages:
       - tedious
     dev: false
 
-  /@mikro-orm/reflection@6.1.0(@mikro-orm/core@6.1.0):
-    resolution: {integrity: sha512-AzYt/l5FTNjc5seYPNBAeJUg3UoJHFxvwXwU0//BnEstn4b0c3/nnVYJeEO+1LgyPNQi/v/j5kT0w3Q2WExlbA==}
+  /@mikro-orm/reflection@6.1.1(@mikro-orm/core@6.1.1):
+    resolution: {integrity: sha512-NngKD3RAQEKWqIXxkqTfcnOoUWSQy4AcjqziEXHAzwiYhQlCz5nL1nM+Nr06et0oxEakW87eciRZOpfEpPmgNQ==}
     engines: {node: '>= 18.12.0'}
     peerDependencies:
       '@mikro-orm/core': ^6.0.0
     dependencies:
-      '@mikro-orm/core': 6.1.0
+      '@mikro-orm/core': 6.1.1
       globby: 11.1.0
       ts-morph: 21.0.1
     dev: false
 
-  /@mikro-orm/sqlite@6.1.0(@mikro-orm/core@6.1.0):
-    resolution: {integrity: sha512-JGc8/Xae6o6LZswKQuRvk5/zMS50l53a0iHG4TMX/QCXYYnuuvEfhcPfRObHVzyBCjBGPXbt9t5ZDUmRYbe7pw==}
+  /@mikro-orm/sqlite@6.1.1(@mikro-orm/core@6.1.1):
+    resolution: {integrity: sha512-e+Y7fkLkG2GyMpvoboPKgUIP8MrQsqaazDMosOb220vgEWVQ8u7ouBK20LBX2JENXXv5ok9e4xOMKX/dLgkElg==}
     engines: {node: '>= 18.12.0'}
     peerDependencies:
       '@mikro-orm/core': ^6.0.0
     dependencies:
-      '@mikro-orm/core': 6.1.0
-      '@mikro-orm/knex': 6.1.0(@mikro-orm/core@6.1.0)(sqlite3@5.1.7)
+      '@mikro-orm/core': 6.1.1
+      '@mikro-orm/knex': 6.1.1(@mikro-orm/core@6.1.1)(sqlite3@5.1.7)
       fs-extra: 11.2.0
       sqlite3: 5.1.7
       sqlstring-sqlite: 0.1.1
@@ -6621,8 +6621,8 @@ packages:
       braces: 3.0.2
       picomatch: 2.3.1
 
-  /mikro-orm@6.1.0:
-    resolution: {integrity: sha512-NLdDdAE6rAj3886am2GSz7E7ntSXVTNDLGdU349q4PfkRFZniZBmc16bWW0JNBhZYZYkBVqfdm2Y2h39iqmI4g==}
+  /mikro-orm@6.1.1:
+    resolution: {integrity: sha512-Qadd/5c86+IFd+vHhimxlu1j5436FbiGGYP5+7a3PO+PKWXfHs4dAQ7wYEl0jjN1VGzQnuzEDHXsbnUPQSPETA==}
     engines: {node: '>= 18.12.0'}
 
   /miller-rabin@4.0.1:
@@ -9310,8 +9310,8 @@ packages:
     resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
     dev: true
 
-  /tsx@4.7.0:
-    resolution: {integrity: sha512-I+t79RYPlEYlHn9a+KzwrvEwhJg35h/1zHsLC2JXvhC2mdynMv6Zxzvhv5EMV6VF5qJlLlkSnMVvdZV3PSIGcg==}
+  /tsx@4.7.1:
+    resolution: {integrity: sha512-8d6VuibXHtlN5E3zFkgY8u4DX7Y3Z27zvvPKVmLon/D4AjuKzarkUBTLDBgj9iTQ0hg5xM7c/mYiRVM+HETf0g==}
     engines: {node: '>=18.0.0'}
     hasBin: true
     dependencies:
index acd8e73cb23ea1b7cf0b41e5e6cd3436cc4ee0f9..ddf8ee7016c7ab5bf82f09d9f80ca1bec32ee68b 100644 (file)
@@ -300,17 +300,18 @@ export class Bootstrap extends EventEmitter {
     if (!isMainThread) {
       return
     }
-    let elementsPerWorker: number | undefined
+    let elementsPerWorker: number
     switch (workerConfiguration.elementsPerWorker) {
+      case 'all':
+        elementsPerWorker = this.numberOfConfiguredChargingStations
+        break
       case 'auto':
+      default:
         elementsPerWorker =
           this.numberOfConfiguredChargingStations > availableParallelism()
             ? Math.round(this.numberOfConfiguredChargingStations / (availableParallelism() * 1.5))
             : 1
         break
-      case 'all':
-        elementsPerWorker = this.numberOfConfiguredChargingStations
-        break
     }
     this.workerImplementation = WorkerFactory.getWorkerImplementation<ChargingStationWorkerData>(
       join(
@@ -326,7 +327,7 @@ export class Bootstrap extends EventEmitter {
         poolMaxSize: workerConfiguration.poolMaxSize!,
         // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
         poolMinSize: workerConfiguration.poolMinSize!,
-        elementsPerWorker: elementsPerWorker ?? (workerConfiguration.elementsPerWorker as number),
+        elementsPerWorker,
         poolOptions: {
           messageHandler: this.messageHandler.bind(this) as MessageHandler<Worker>,
           workerOptions: { resourceLimits: workerConfiguration.resourceLimits }
index c9c8208a32bbe797d1be024d40ddabaa85099fee..4ef9ab5d92e5d1f80307f44314d3e5bbb3cbc894 100644 (file)
@@ -1147,10 +1147,8 @@ export class ChargingStation extends EventEmitter {
     }
     const stationInfo = stationTemplateToStationInfo(stationTemplate)
     stationInfo.hashId = getHashId(this.index, stationTemplate)
-    stationInfo.autoStart = stationTemplate.autoStart ?? true
     stationInfo.templateName = parse(this.templateFile).name
     stationInfo.chargingStationId = getChargingStationId(this.index, stationTemplate)
-    stationInfo.ocppVersion = stationTemplate.ocppVersion ?? OCPPVersion.VERSION_16
     createSerialNumber(stationTemplate, stationInfo)
     stationInfo.voltageOut = this.getVoltageOut(stationInfo)
     if (isNotEmptyArray(stationTemplate.power)) {
@@ -1167,9 +1165,8 @@ export class ChargingStation extends EventEmitter {
           : stationTemplate.power
     }
     stationInfo.maximumAmperage = this.getMaximumAmperage(stationInfo)
-    stationInfo.firmwareVersionPattern =
-      stationTemplate.firmwareVersionPattern ?? Constants.SEMVER_PATTERN
     if (
+      isNotEmptyString(stationInfo.firmwareVersionPattern) &&
       isNotEmptyString(stationInfo.firmwareVersion) &&
       !new RegExp(stationInfo.firmwareVersionPattern).test(stationInfo.firmwareVersion)
     ) {
@@ -1188,10 +1185,9 @@ export class ChargingStation extends EventEmitter {
       },
       stationTemplate.firmwareUpgrade ?? {}
     )
-    stationInfo.resetTime =
-      stationTemplate.resetTime != null
-        ? secondsToMilliseconds(stationTemplate.resetTime)
-        : Constants.DEFAULT_CHARGING_STATION_RESET_TIME
+    if (stationTemplate.resetTime != null) {
+      stationInfo.resetTime = secondsToMilliseconds(stationTemplate.resetTime)
+    }
     return stationInfo
   }
 
@@ -1208,9 +1204,6 @@ export class ChargingStation extends EventEmitter {
         if (stationInfo.templateName == null) {
           stationInfo.templateName = parse(this.templateFile).name
         }
-        if (stationInfo.autoStart == null) {
-          stationInfo.autoStart = true
-        }
       }
     }
     return stationInfo
@@ -1275,8 +1268,6 @@ export class ChargingStation extends EventEmitter {
     this.stationInfo = this.getStationInfo(options?.persistentConfiguration)
     if (options?.persistentConfiguration != null) {
       this.stationInfo.ocppPersistentConfiguration = options.persistentConfiguration
-    }
-    if (options?.persistentConfiguration != null) {
       this.stationInfo.automaticTransactionGeneratorPersistentConfiguration =
         options.persistentConfiguration
     }
@@ -1289,10 +1280,13 @@ export class ChargingStation extends EventEmitter {
     if (options?.ocppStrictCompliance != null) {
       this.stationInfo.ocppStrictCompliance = options.ocppStrictCompliance
     }
+    if (options?.stopTransactionsOnStopped != null) {
+      this.stationInfo.stopTransactionsOnStopped = options.stopTransactionsOnStopped
+    }
     if (
       this.stationInfo.firmwareStatus === FirmwareStatus.Installing &&
-      isNotEmptyString(this.stationInfo.firmwareVersion) &&
-      isNotEmptyString(this.stationInfo.firmwareVersionPattern)
+      isNotEmptyString(this.stationInfo.firmwareVersionPattern) &&
+      isNotEmptyString(this.stationInfo.firmwareVersion)
     ) {
       const patternGroup =
         this.stationInfo.firmwareUpgrade?.versionUpgrade?.patternGroup ??
@@ -1809,8 +1803,7 @@ export class ChargingStation extends EventEmitter {
   }
 
   private getOcppConfiguration (
-    ocppPersistentConfiguration: boolean | undefined = Constants.DEFAULT_STATION_INFO
-      .ocppPersistentConfiguration
+    ocppPersistentConfiguration: boolean | undefined = this.stationInfo?.ocppPersistentConfiguration
   ): ChargingStationOcppConfiguration | undefined {
     let ocppConfiguration: ChargingStationOcppConfiguration | undefined =
       this.getOcppConfigurationFromFile(ocppPersistentConfiguration)
@@ -2066,7 +2059,7 @@ export class ChargingStation extends EventEmitter {
       if (!(error instanceof OCPPError)) {
         logger.warn(
           `${this.logPrefix()} Error thrown at incoming OCPP command '${
-            commandName ?? requestCommandName ?? Constants.UNKNOWN_COMMAND
+            commandName ?? requestCommandName ?? Constants.UNKNOWN_OCPP_COMMAND
             // eslint-disable-next-line @typescript-eslint/no-base-to-string
           }' message '${data.toString()}' handling is not an OCPPError:`,
           error
@@ -2074,7 +2067,7 @@ export class ChargingStation extends EventEmitter {
       }
       logger.error(
         `${this.logPrefix()} Incoming OCPP command '${
-          commandName ?? requestCommandName ?? Constants.UNKNOWN_COMMAND
+          commandName ?? requestCommandName ?? Constants.UNKNOWN_OCPP_COMMAND
           // eslint-disable-next-line @typescript-eslint/no-base-to-string
         }' message '${data.toString()}'${
           this.requests.has(messageId)
@@ -2122,7 +2115,8 @@ export class ChargingStation extends EventEmitter {
   }
 
   private getUseConnectorId0 (stationTemplate?: ChargingStationTemplate): boolean {
-    return stationTemplate?.useConnectorId0 ?? true
+    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+    return stationTemplate?.useConnectorId0 ?? Constants.DEFAULT_STATION_INFO.useConnectorId0!
   }
 
   private async stopRunningTransactions (reason?: StopTransactionReason): Promise<void> {
@@ -2181,8 +2175,12 @@ export class ChargingStation extends EventEmitter {
   }
 
   private getCurrentOutType (stationInfo?: ChargingStationInfo): CurrentType {
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-    return (stationInfo ?? this.stationInfo!).currentOutType ?? CurrentType.AC
+    return (
+      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+      (stationInfo ?? this.stationInfo!).currentOutType ??
+      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+      Constants.DEFAULT_STATION_INFO.currentOutType!
+    )
   }
 
   private getVoltageOut (stationInfo?: ChargingStationInfo): Voltage {
index 8be89fe1a65d3ee812ddd88ad11e43bdf292a895..df3d03082ea3053969c386b8e9c39300426c5e39 100644 (file)
@@ -247,14 +247,6 @@ export const checkTemplate = (
     logger.error(`${logPrefix} ${errorMsg}`)
     throw new BaseError(errorMsg)
   }
-  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-  if (isEmptyObject(stationTemplate.AutomaticTransactionGenerator!)) {
-    stationTemplate.AutomaticTransactionGenerator = Constants.DEFAULT_ATG_CONFIGURATION
-    logger.warn(
-      `${logPrefix} Empty automatic transaction generator configuration from template file ${templateFile}, set to default: %j`,
-      Constants.DEFAULT_ATG_CONFIGURATION
-    )
-  }
   if (stationTemplate.idTagsFile == null || isEmptyString(stationTemplate.idTagsFile)) {
     logger.warn(
       `${logPrefix} Missing id tags file in template file ${templateFile}. That can lead to issues with the Automatic Transaction Generator`
index b45345a6faf316febc7c0b283901d708802f8462..32843895142ea43e136ae226d6e61cbe91eb68bd 100644 (file)
@@ -30,7 +30,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
     // if (new.target.name === moduleName) {
     //   throw new TypeError(`Cannot construct ${new.target.name} instances directly`)
     // }
-    super(OCPPVersion.VERSION_20)
+    super(OCPPVersion.VERSION_201)
     this.incomingRequestHandlers = new Map<OCPP20IncomingRequestCommand, IncomingRequestHandler>([
       [OCPP20IncomingRequestCommand.CLEAR_CACHE, this.handleRequestClearCache.bind(this)]
     ])
index a61fc2aee090d4d7dfa836e3a7c5d90a1f96aeee..03921891105e745103479904b0b87dbd1bd03c7a 100644 (file)
@@ -30,7 +30,7 @@ export class OCPP20RequestService extends OCPPRequestService {
     // if (new.target.name === moduleName) {
     //   throw new TypeError(`Cannot construct ${new.target.name} instances directly`)
     // }
-    super(OCPPVersion.VERSION_20, ocppResponseService)
+    super(OCPPVersion.VERSION_201, ocppResponseService)
     this.payloadValidateFunctions = new Map<OCPP20RequestCommand, ValidateFunction<JsonType>>([
       [
         OCPP20RequestCommand.BOOT_NOTIFICATION,
index ef0a0360bcf5e0a41e12452bc8c49ff020459f22..09b319c9a653b9375920703f3a57cb4b073f8a13 100644 (file)
@@ -37,7 +37,7 @@ export class OCPP20ResponseService extends OCPPResponseService {
     // if (new.target.name === moduleName) {
     //   throw new TypeError(`Cannot construct ${new.target.name} instances directly`)
     // }
-    super(OCPPVersion.VERSION_20)
+    super(OCPPVersion.VERSION_201)
     this.responseHandlers = new Map<OCPP20RequestCommand, ResponseHandler>([
       [
         OCPP20RequestCommand.BOOT_NOTIFICATION,
index 38110e6f9873300c7fd3e3fcaa12475adfda6dd0..75d61731e8c72c00db49e075d7f1af6e311207d6 100644 (file)
@@ -13,7 +13,7 @@ export class OCPP20ServiceUtils extends OCPPServiceUtils {
   ): JSONSchemaType<T> {
     return super.parseJsonSchemaFile<T>(
       relativePath,
-      OCPPVersion.VERSION_20,
+      OCPPVersion.VERSION_201,
       moduleName,
       methodName
     )
index 41414fe9a8a04240bccf06f7a51a1417f29c3f19..27876dadfef495d674f6cae7422fa793129a09b5 100644 (file)
@@ -18,7 +18,7 @@ export class OCPPError extends BaseError {
     super(message)
 
     this.code = code
-    this.command = command ?? Constants.UNKNOWN_COMMAND
+    this.command = command ?? Constants.UNKNOWN_OCPP_COMMAND
     this.details = details
   }
 }
index e6e34a8962f1f70b374c2f7eceaea4b3c7c3263e..6dbd879310592796529df358364c65c69f672734 100644 (file)
@@ -17,6 +17,7 @@ export interface ChargingStationOptions extends JsonObject {
   autoRegister?: boolean
   enableStatistics?: boolean
   ocppStrictCompliance?: boolean
+  stopTransactionsOnStopped?: boolean
 }
 
 export interface ChargingStationWorkerData extends WorkerData {
index 38890575f176c9f4f635a0d91a91d1b077570e01..c467df73a853574ec274c69e93d791b17a0e97a5 100644 (file)
@@ -10,8 +10,15 @@ import {
 
 // eslint-disable-next-line @typescript-eslint/no-extraneous-class
 export class Constants {
+  // See https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
+  private static readonly SEMVER_PATTERN =
+    '^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$'
+
+  private static readonly DEFAULT_CHARGING_STATION_RESET_TIME = 60000 // Ms
+
   static readonly DEFAULT_STATION_INFO: Partial<ChargingStationInfo> = Object.freeze({
     enableStatistics: false,
+    autoStart: true,
     remoteAuthorization: true,
     currentOutType: CurrentType.AC,
     mainVoltageMeterValues: true,
@@ -24,10 +31,13 @@ export class Constants {
     transactionDataMeterValues: false,
     supervisionUrlOcppConfiguration: false,
     supervisionUrlOcppKey: VendorParametersKey.ConnectionUrl,
+    useConnectorId0: true,
     ocppVersion: OCPPVersion.VERSION_16,
+    firmwareVersionPattern: Constants.SEMVER_PATTERN,
     ocppPersistentConfiguration: true,
     stationInfoPersistentConfiguration: true,
     automaticTransactionGeneratorPersistentConfiguration: true,
+    resetTime: Constants.DEFAULT_CHARGING_STATION_RESET_TIME,
     autoReconnectMaxRetries: -1,
     registrationMaxRetries: -1,
     reconnectExponentialDelay: false,
@@ -38,8 +48,6 @@ export class Constants {
   static readonly DEFAULT_HEARTBEAT_INTERVAL = 60000 // Ms
   static readonly DEFAULT_METER_VALUES_INTERVAL = 60000 // Ms
 
-  static readonly DEFAULT_CHARGING_STATION_RESET_TIME = 60000 // Ms
-
   static readonly DEFAULT_ATG_WAIT_TIME = 1000 // Ms
   static readonly DEFAULT_ATG_CONFIGURATION: AutomaticTransactionGeneratorConfiguration =
     Object.freeze({
@@ -53,10 +61,6 @@ export class Constants {
       stopAbsoluteDuration: false
     })
 
-  // See https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
-  static readonly SEMVER_PATTERN =
-    '^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$'
-
   static readonly DEFAULT_CIRCULAR_BUFFER_CAPACITY = 4096
 
   static readonly DEFAULT_HASH_ALGORITHM = 'sha384'
@@ -77,7 +81,9 @@ export class Constants {
   static readonly DEFAULT_UI_SERVER_HOST = 'localhost'
   static readonly DEFAULT_UI_SERVER_PORT = 8080
 
-  static readonly UNKNOWN_COMMAND = 'unknown command' as RequestCommand | IncomingRequestCommand
+  static readonly UNKNOWN_OCPP_COMMAND = 'unknown OCPP command' as
+    | RequestCommand
+    | IncomingRequestCommand
 
   static readonly MAX_RANDOM_INTEGER = 281474976710654
 
index 4b8be6ee0ecf288a8bad8bac2a509c16298e7262..07bfbb1a133cee856e4c01022df96e8b7d7052f7 100644 (file)
@@ -754,104 +754,104 @@ packages:
     engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
     dev: true
 
-  /@rollup/rollup-android-arm-eabi@4.9.6:
-    resolution: {integrity: sha512-MVNXSSYN6QXOulbHpLMKYi60ppyO13W9my1qogeiAqtjb2yR4LSmfU2+POvDkLzhjYLXz9Rf9+9a3zFHW1Lecg==}
+  /@rollup/rollup-android-arm-eabi@4.10.0:
+    resolution: {integrity: sha512-/MeDQmcD96nVoRumKUljsYOLqfv1YFJps+0pTrb2Z9Nl/w5qNUysMaWQsrd1mvAlNT4yza1iVyIu4Q4AgF6V3A==}
     cpu: [arm]
     os: [android]
     requiresBuild: true
     dev: true
     optional: true
 
-  /@rollup/rollup-android-arm64@4.9.6:
-    resolution: {integrity: sha512-T14aNLpqJ5wzKNf5jEDpv5zgyIqcpn1MlwCrUXLrwoADr2RkWA0vOWP4XxbO9aiO3dvMCQICZdKeDrFl7UMClw==}
+  /@rollup/rollup-android-arm64@4.10.0:
+    resolution: {integrity: sha512-lvu0jK97mZDJdpZKDnZI93I0Om8lSDaiPx3OiCk0RXn3E8CMPJNS/wxjAvSJJzhhZpfjXsjLWL8LnS6qET4VNQ==}
     cpu: [arm64]
     os: [android]
     requiresBuild: true
     dev: true
     optional: true
 
-  /@rollup/rollup-darwin-arm64@4.9.6:
-    resolution: {integrity: sha512-CqNNAyhRkTbo8VVZ5R85X73H3R5NX9ONnKbXuHisGWC0qRbTTxnF1U4V9NafzJbgGM0sHZpdO83pLPzq8uOZFw==}
+  /@rollup/rollup-darwin-arm64@4.10.0:
+    resolution: {integrity: sha512-uFpayx8I8tyOvDkD7X6n0PriDRWxcqEjqgtlxnUA/G9oS93ur9aZ8c8BEpzFmsed1TH5WZNG5IONB8IiW90TQg==}
     cpu: [arm64]
     os: [darwin]
     requiresBuild: true
     dev: true
     optional: true
 
-  /@rollup/rollup-darwin-x64@4.9.6:
-    resolution: {integrity: sha512-zRDtdJuRvA1dc9Mp6BWYqAsU5oeLixdfUvkTHuiYOHwqYuQ4YgSmi6+/lPvSsqc/I0Omw3DdICx4Tfacdzmhog==}
+  /@rollup/rollup-darwin-x64@4.10.0:
+    resolution: {integrity: sha512-nIdCX03qFKoR/MwQegQBK+qZoSpO3LESurVAC6s6jazLA1Mpmgzo3Nj3H1vydXp/JM29bkCiuF7tDuToj4+U9Q==}
     cpu: [x64]
     os: [darwin]
     requiresBuild: true
     dev: true
     optional: true
 
-  /@rollup/rollup-linux-arm-gnueabihf@4.9.6:
-    resolution: {integrity: sha512-oNk8YXDDnNyG4qlNb6is1ojTOGL/tRhbbKeE/YuccItzerEZT68Z9gHrY3ROh7axDc974+zYAPxK5SH0j/G+QQ==}
+  /@rollup/rollup-linux-arm-gnueabihf@4.10.0:
+    resolution: {integrity: sha512-Fz7a+y5sYhYZMQFRkOyCs4PLhICAnxRX/GnWYReaAoruUzuRtcf+Qnw+T0CoAWbHCuz2gBUwmWnUgQ67fb3FYw==}
     cpu: [arm]
     os: [linux]
     requiresBuild: true
     dev: true
     optional: true
 
-  /@rollup/rollup-linux-arm64-gnu@4.9.6:
-    resolution: {integrity: sha512-Z3O60yxPtuCYobrtzjo0wlmvDdx2qZfeAWTyfOjEDqd08kthDKexLpV97KfAeUXPosENKd8uyJMRDfFMxcYkDQ==}
+  /@rollup/rollup-linux-arm64-gnu@4.10.0:
+    resolution: {integrity: sha512-yPtF9jIix88orwfTi0lJiqINnlWo6p93MtZEoaehZnmCzEmLL0eqjA3eGVeyQhMtxdV+Mlsgfwhh0+M/k1/V7Q==}
     cpu: [arm64]
     os: [linux]
     requiresBuild: true
     dev: true
     optional: true
 
-  /@rollup/rollup-linux-arm64-musl@4.9.6:
-    resolution: {integrity: sha512-gpiG0qQJNdYEVad+1iAsGAbgAnZ8j07FapmnIAQgODKcOTjLEWM9sRb+MbQyVsYCnA0Im6M6QIq6ax7liws6eQ==}
+  /@rollup/rollup-linux-arm64-musl@4.10.0:
+    resolution: {integrity: sha512-9GW9yA30ib+vfFiwjX+N7PnjTnCMiUffhWj4vkG4ukYv1kJ4T9gHNg8zw+ChsOccM27G9yXrEtMScf1LaCuoWQ==}
     cpu: [arm64]
     os: [linux]
     requiresBuild: true
     dev: true
     optional: true
 
-  /@rollup/rollup-linux-riscv64-gnu@4.9.6:
-    resolution: {integrity: sha512-+uCOcvVmFUYvVDr27aiyun9WgZk0tXe7ThuzoUTAukZJOwS5MrGbmSlNOhx1j80GdpqbOty05XqSl5w4dQvcOA==}
+  /@rollup/rollup-linux-riscv64-gnu@4.10.0:
+    resolution: {integrity: sha512-X1ES+V4bMq2ws5fF4zHornxebNxMXye0ZZjUrzOrf7UMx1d6wMQtfcchZ8SqUnQPPHdOyOLW6fTcUiFgHFadRA==}
     cpu: [riscv64]
     os: [linux]
     requiresBuild: true
     dev: true
     optional: true
 
-  /@rollup/rollup-linux-x64-gnu@4.9.6:
-    resolution: {integrity: sha512-HUNqM32dGzfBKuaDUBqFB7tP6VMN74eLZ33Q9Y1TBqRDn+qDonkAUyKWwF9BR9unV7QUzffLnz9GrnKvMqC/fw==}
+  /@rollup/rollup-linux-x64-gnu@4.10.0:
+    resolution: {integrity: sha512-w/5OpT2EnI/Xvypw4FIhV34jmNqU5PZjZue2l2Y3ty1Ootm3SqhI+AmfhlUYGBTd9JnpneZCDnt3uNOiOBkMyw==}
     cpu: [x64]
     os: [linux]
     requiresBuild: true
     dev: true
     optional: true
 
-  /@rollup/rollup-linux-x64-musl@4.9.6:
-    resolution: {integrity: sha512-ch7M+9Tr5R4FK40FHQk8VnML0Szi2KRujUgHXd/HjuH9ifH72GUmw6lStZBo3c3GB82vHa0ZoUfjfcM7JiiMrQ==}
+  /@rollup/rollup-linux-x64-musl@4.10.0:
+    resolution: {integrity: sha512-q/meftEe3QlwQiGYxD9rWwB21DoKQ9Q8wA40of/of6yGHhZuGfZO0c3WYkN9dNlopHlNT3mf5BPsUSxoPuVQaw==}
     cpu: [x64]
     os: [linux]
     requiresBuild: true
     dev: true
     optional: true
 
-  /@rollup/rollup-win32-arm64-msvc@4.9.6:
-    resolution: {integrity: sha512-VD6qnR99dhmTQ1mJhIzXsRcTBvTjbfbGGwKAHcu+52cVl15AC/kplkhxzW/uT0Xl62Y/meBKDZvoJSJN+vTeGA==}
+  /@rollup/rollup-win32-arm64-msvc@4.10.0:
+    resolution: {integrity: sha512-NrR6667wlUfP0BHaEIKgYM/2va+Oj+RjZSASbBMnszM9k+1AmliRjHc3lJIiOehtSSjqYiO7R6KLNrWOX+YNSQ==}
     cpu: [arm64]
     os: [win32]
     requiresBuild: true
     dev: true
     optional: true
 
-  /@rollup/rollup-win32-ia32-msvc@4.9.6:
-    resolution: {integrity: sha512-J9AFDq/xiRI58eR2NIDfyVmTYGyIZmRcvcAoJ48oDld/NTR8wyiPUu2X/v1navJ+N/FGg68LEbX3Ejd6l8B7MQ==}
+  /@rollup/rollup-win32-ia32-msvc@4.10.0:
+    resolution: {integrity: sha512-FV0Tpt84LPYDduIDcXvEC7HKtyXxdvhdAOvOeWMWbQNulxViH2O07QXkT/FffX4FqEI02jEbCJbr+YcuKdyyMg==}
     cpu: [ia32]
     os: [win32]
     requiresBuild: true
     dev: true
     optional: true
 
-  /@rollup/rollup-win32-x64-msvc@4.9.6:
-    resolution: {integrity: sha512-jqzNLhNDvIZOrt69Ce4UjGRpXJBzhUBzawMwnaDAwyHriki3XollsewxWzOzz+4yOFDkuJHtTsZFwMxhYJWmLQ==}
+  /@rollup/rollup-win32-x64-msvc@4.10.0:
+    resolution: {integrity: sha512-OZoJd+o5TaTSQeFFQ6WjFCiltiYVjIdsXxwu/XZ8qRpsvMQr4UsVrE5UyT9RIvsnuF47DqkJKhhVZ2Q9YW9IpQ==}
     cpu: [x64]
     os: [win32]
     requiresBuild: true
@@ -3410,26 +3410,26 @@ packages:
       glob: 10.3.10
     dev: true
 
-  /rollup@4.9.6:
-    resolution: {integrity: sha512-05lzkCS2uASX0CiLFybYfVkwNbKZG5NFQ6Go0VWyogFTXXbR039UVsegViTntkk4OglHBdF54ccApXRRuXRbsg==}
+  /rollup@4.10.0:
+    resolution: {integrity: sha512-t2v9G2AKxcQ8yrG+WGxctBes1AomT0M4ND7jTFBCVPXQ/WFTvNSefIrNSmLKhIKBrvN8SG+CZslimJcT3W2u2g==}
     engines: {node: '>=18.0.0', npm: '>=8.0.0'}
     hasBin: true
     dependencies:
       '@types/estree': 1.0.5
     optionalDependencies:
-      '@rollup/rollup-android-arm-eabi': 4.9.6
-      '@rollup/rollup-android-arm64': 4.9.6
-      '@rollup/rollup-darwin-arm64': 4.9.6
-      '@rollup/rollup-darwin-x64': 4.9.6
-      '@rollup/rollup-linux-arm-gnueabihf': 4.9.6
-      '@rollup/rollup-linux-arm64-gnu': 4.9.6
-      '@rollup/rollup-linux-arm64-musl': 4.9.6
-      '@rollup/rollup-linux-riscv64-gnu': 4.9.6
-      '@rollup/rollup-linux-x64-gnu': 4.9.6
-      '@rollup/rollup-linux-x64-musl': 4.9.6
-      '@rollup/rollup-win32-arm64-msvc': 4.9.6
-      '@rollup/rollup-win32-ia32-msvc': 4.9.6
-      '@rollup/rollup-win32-x64-msvc': 4.9.6
+      '@rollup/rollup-android-arm-eabi': 4.10.0
+      '@rollup/rollup-android-arm64': 4.10.0
+      '@rollup/rollup-darwin-arm64': 4.10.0
+      '@rollup/rollup-darwin-x64': 4.10.0
+      '@rollup/rollup-linux-arm-gnueabihf': 4.10.0
+      '@rollup/rollup-linux-arm64-gnu': 4.10.0
+      '@rollup/rollup-linux-arm64-musl': 4.10.0
+      '@rollup/rollup-linux-riscv64-gnu': 4.10.0
+      '@rollup/rollup-linux-x64-gnu': 4.10.0
+      '@rollup/rollup-linux-x64-musl': 4.10.0
+      '@rollup/rollup-win32-arm64-msvc': 4.10.0
+      '@rollup/rollup-win32-ia32-msvc': 4.10.0
+      '@rollup/rollup-win32-x64-msvc': 4.10.0
       fsevents: 2.3.3
     dev: true
 
@@ -3973,7 +3973,7 @@ packages:
       '@types/node': 20.11.17
       esbuild: 0.19.12
       postcss: 8.4.35
-      rollup: 4.9.6
+      rollup: 4.10.0
     optionalDependencies:
       fsevents: 2.3.3
     dev: true