Hook the OCPP 2.0 stack into the main code
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 4 Jan 2023 21:23:49 +0000 (22:23 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 4 Jan 2023 21:23:49 +0000 (22:23 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
40 files changed:
src/charging-station/AutomaticTransactionGenerator.ts
src/charging-station/Bootstrap.ts
src/charging-station/ChargingStation.ts
src/charging-station/ChargingStationWorker.ts
src/charging-station/ChargingStationWorkerBroadcastChannel.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/charging-station/ocpp/1.6/OCPP16ServiceUtils.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/charging-station/ocpp/OCPPRequestService.ts
src/charging-station/ocpp/OCPPServiceUtils.ts
src/exception/OCPPError.ts
src/performance/PerformanceStatistics.ts
src/performance/storage/JsonFileStorage.ts
src/performance/storage/MikroOrmStorage.ts
src/performance/storage/MongoDBStorage.ts
src/performance/storage/Storage.ts
src/performance/storage/StorageFactory.ts
src/start.ts
src/types/ChargingStationWorker.ts
src/types/ConfigurationData.ts
src/types/Statistics.ts
src/types/ocpp/ChargePointErrorCode.ts
src/types/ocpp/ChargePointStatus.ts
src/types/ocpp/ChargingProfile.ts
src/types/ocpp/Configuration.ts
src/types/ocpp/MeterValues.ts
src/types/ocpp/OCPPVersion.ts
src/types/ocpp/Requests.ts
src/types/ocpp/Responses.ts
src/types/ocpp/Transaction.ts
src/utils/CircularArray.ts
src/utils/ElectricUtils.ts
src/utils/Utils.ts
src/worker/WorkerSet.ts
ui/web/src/types/ChargingStationType.ts

index e29ad4b839ac1286a1bfde585b317313c20d4d43..80c9a5176937a035dccc699fc39e6e6b2859a88d 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import { AsyncResource } from 'async_hooks';
 
index 0115cfe3a55ecd41f252acc973a073c5f4dc1369..8972119701cb9faee8206a9c2fa1d9a9e1444f36 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import path from 'path';
 import { fileURLToPath } from 'url';
index 6e35d864741abb3ed0e09431d79f3a7cb9be6895..689fe2d98099f844a42b1d15195def868f55746b 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import crypto from 'crypto';
 import fs from 'fs';
@@ -82,6 +82,9 @@ import OCPP16IncomingRequestService from './ocpp/1.6/OCPP16IncomingRequestServic
 import OCPP16RequestService from './ocpp/1.6/OCPP16RequestService';
 import OCPP16ResponseService from './ocpp/1.6/OCPP16ResponseService';
 import { OCPP16ServiceUtils } from './ocpp/1.6/OCPP16ServiceUtils';
+import OCPP20IncomingRequestService from './ocpp/2.0/OCPP20IncomingRequestService';
+import OCPP20RequestService from './ocpp/2.0/OCPP20RequestService';
+import OCPP20ResponseService from './ocpp/2.0/OCPP20ResponseService';
 import type OCPPIncomingRequestService from './ocpp/OCPPIncomingRequestService';
 import type OCPPRequestService from './ocpp/OCPPRequestService';
 import SharedLRUCache from './SharedLRUCache';
@@ -626,13 +629,16 @@ export default class ChargingStation {
     if (params?.terminateOpened) {
       this.terminateWSConnection();
     }
+    const ocppVersion = this.getOcppVersion();
     let protocol: string;
-    switch (this.getOcppVersion()) {
+    switch (ocppVersion) {
       case OCPPVersion.VERSION_16:
-        protocol = 'ocpp' + OCPPVersion.VERSION_16;
+      case OCPPVersion.VERSION_20:
+      case OCPPVersion.VERSION_201:
+        protocol = 'ocpp' + ocppVersion;
         break;
       default:
-        this.handleUnsupportedVersion(this.getOcppVersion());
+        this.handleUnsupportedVersion(ocppVersion);
         break;
     }
 
@@ -974,6 +980,14 @@ export default class ChargingStation {
           OCPP16ResponseService.getInstance<OCPP16ResponseService>()
         );
         break;
+      case OCPPVersion.VERSION_20:
+      case OCPPVersion.VERSION_201:
+        this.ocppIncomingRequestService =
+          OCPP20IncomingRequestService.getInstance<OCPP20IncomingRequestService>();
+        this.ocppRequestService = OCPP20RequestService.getInstance<OCPP20RequestService>(
+          OCPP20ResponseService.getInstance<OCPP20ResponseService>()
+        );
+        break;
       default:
         this.handleUnsupportedVersion(this.getOcppVersion());
         break;
index d032407533830eb86554c29450f63bfb1923e273..62bad35fc03ef72dd18c742991e0d4c54ca5e187 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import { parentPort, workerData } from 'worker_threads';
 
index 0eecb7b1bf16838fc81c9eaed0bce0f0970e192c..63b261d5db5b7a857686c63ce95f7ed47917f067 100644 (file)
@@ -213,7 +213,7 @@ export default class ChargingStationWorkerBroadcastChannel extends WorkerBroadca
     }
     if (requestPayload?.hashId !== undefined) {
       logger.error(
-        `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' instead`
+        `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' array instead`
       );
       return;
     }
index dc14d0064dceaa24e4ad658eb08a4f6912f5913a..420edf86b5e5f1af369b354e6540eb178716e9ca 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import fs from 'fs';
 import path from 'path';
index ffbc15d79f634af24399dee71e35ec941e2767e9..dce1e44a87a5ad636b4d415820f7aa55bde59f56 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import fs from 'fs';
 import path from 'path';
index 5cb69c7cb439bb4e235b83f4b6c4876648c96ca9..9300e44ac664e97e12d7fb44e6f3b425b713529c 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import fs from 'fs';
 import path from 'path';
index f3f22e45c8ff8f1456c9d9be4ebb3cc153e34495..089ecc76e065d4eb01d3ca36da3a71a571e7147c 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import OCPPError from '../../../exception/OCPPError';
 import { CurrentType, Voltage } from '../../../types/ChargingStationTemplate';
index 076832af515a78f80b8820ccf92eef3bab81ba1e..04715d5a3e4af77bc637971bc41b8d61bd0ad66f 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import type { JSONSchemaType } from 'ajv';
 
index 8dfdce680247c2e3c173a28ed6df19a56add7953..3b1e269556338a958568f2d4e16217a756716ddb 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import type { JSONSchemaType } from 'ajv';
 
index db320f6136275eaae68942c613a4eb4e9c597d30..39baa0e579bb41a7eed3587c9a89c02a3306ca9f 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import type { JSONSchemaType } from 'ajv';
 
index 7ff58444e0f8142332ab4f1be240b2577f260404..63e43115dabaf6db2ccdba3c3dee653b91948bb9 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import { OCPPServiceUtils } from '../OCPPServiceUtils';
 
index f1a05dd54381f5e54bcc281d88a9304f0631350e..125baf4073366623f05c67797d6e375ef532f148 100644 (file)
@@ -189,10 +189,10 @@ export default abstract class OCPPRequestService {
           // Check if wsConnection opened
           if (chargingStation.isWebSocketConnectionOpened() === true) {
             // Yes: Send Message
-            const beginId = PerformanceStatistics.beginMeasure(commandName);
+            const beginId = PerformanceStatistics.beginMeasure(commandName as string);
             // FIXME: Handle sending error
             chargingStation.wsConnection.send(messageToSend);
-            PerformanceStatistics.endMeasure(commandName, beginId);
+            PerformanceStatistics.endMeasure(commandName as string, beginId);
             logger.debug(
               `${chargingStation.logPrefix()} >> Command '${commandName}' sent ${this.getMessageTypeString(
                 messageType
index 6b7f709f29351bec1bdbc0b9b199bccc8eb8b1e7..33637c65a9e7501ea045cee9fd521863b27c1f0a 100644 (file)
@@ -37,7 +37,7 @@ export class OCPPServiceUtils {
     chargingStation: ChargingStation,
     command: RequestCommand
   ): boolean {
-    const isRequestCommand = Object.values(RequestCommand).includes(command);
+    const isRequestCommand = Object.values<RequestCommand>(RequestCommand).includes(command);
     if (
       isRequestCommand === true &&
       !chargingStation.stationInfo?.commandsSupport?.outgoingCommands
@@ -57,7 +57,8 @@ export class OCPPServiceUtils {
     chargingStation: ChargingStation,
     command: IncomingRequestCommand
   ): boolean {
-    const isIncomingRequestCommand = Object.values(IncomingRequestCommand).includes(command);
+    const isIncomingRequestCommand =
+      Object.values<IncomingRequestCommand>(IncomingRequestCommand).includes(command);
     if (
       isIncomingRequestCommand === true &&
       !chargingStation.stationInfo?.commandsSupport?.incomingCommands
index 90817649e9783b519bc506ff53e860b8f4d02123..e3c127fd22e375921f3303e0f70f2285ea7d6451 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import type { JsonType } from '../types/JsonType';
 import { ErrorType } from '../types/ocpp/ErrorType';
index 5f036805460662678f4ee44c1253ee6cfd9dd748..6383887af62167fb70e70e9ec61391dced5286dd 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import { PerformanceEntry, PerformanceObserver, performance } from 'perf_hooks';
 import type { URL } from 'url';
index 8465290325173d316a24e6ef26f1d6a252675ad1..2f90fc460063b335ef716a47b14ff6b694246445 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import fs from 'fs';
 
index 0c2b28ad920b1a256b1119b0f9c7e24a05cd62e6..f9c21290596b660bdecc1308c3a3fc079befbcd3 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import { Configuration, Connection, IDatabaseDriver, MikroORM, Options } from '@mikro-orm/core';
 import { TsMorphMetadataProvider } from '@mikro-orm/reflection';
index 711799083d28f1f36e775f3f83d8910b4eb3fb72..153f32ae0b7bcf33914eebfef56f522b09187037 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import { MongoClient } from 'mongodb';
 
index 66bbc5f5d6f724acfacae07a5e627aa95315d85d..9c4696faa5ad9e5a8373f372a1ff12487120ed4b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import { URL } from 'url';
 
index b0f9da58cff118cb2cfc5b929ff0b8f6a86abf62..741b16316320563a2eb9bd70612e46fa204fb68a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import { StorageType } from '../../types/Storage';
 import { JsonFileStorage } from './JsonFileStorage';
index 09ddf202439f3949317a59a3f1c08995e1db9841..8eca3a4a11e093983b7ab8f499b2c6406175a2fa 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import chalk from 'chalk';
 
index ac13f441a921d50eced020fd4defe5c122f77993..c27ec6eb32e3eeec4c3cd8290c3cd414502288fc 100644 (file)
@@ -38,12 +38,11 @@ enum ChargingStationMessageEvents {
   PERFORMANCE_STATISTICS = 'performanceStatistics',
 }
 
-export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | ChargingStationMessageEvents;
-
 export const ChargingStationWorkerMessageEvents = {
   ...WorkerMessageEvents,
   ...ChargingStationMessageEvents,
-};
+} as const;
+export type ChargingStationWorkerMessageEvents = WorkerMessageEvents | ChargingStationMessageEvents;
 
 export type ChargingStationWorkerMessageData = ChargingStationData | Statistics;
 
index 8ab9bcfdb95a55f0c6f8f784e63203c7f7b36231..b629dd3b0230fb116a73911a971c2ed7adb0a7c9 100644 (file)
@@ -55,19 +55,19 @@ export type ConfigurationData = {
   performanceStorage?: StorageConfiguration;
   worker?: WorkerConfiguration;
   autoReconnectMaxRetries?: number;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   workerProcess?: WorkerProcessType;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   workerStartDelay?: number;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   elementStartDelay?: number;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   workerPoolMinSize?: number;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   workerPoolMaxSize?: number;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   workerPoolStrategy?: WorkerChoiceStrategy;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   chargingStationsPerWorker?: number;
   logStatisticsInterval?: number;
   logFormat?: string;
index 37460aee97cb0382cc322a4f8745d77204045d1e..f5a13ebbb143e87c7c201ebd20f971387dc78f5c 100644 (file)
@@ -29,5 +29,5 @@ export type Statistics = WorkerData & {
   uri: string;
   createdAt: Date;
   updatedAt?: Date;
-  statisticsData: Map<string, Partial<StatisticsData>>;
+  statisticsData: Map<string | RequestCommand | IncomingRequestCommand, Partial<StatisticsData>>;
 };
index 75c5c482982096723c8e69f4aef8ccd91fbfb8d5..d08f17a07121c078011db81253e1c9c6f51ab03d 100644 (file)
@@ -1,7 +1,6 @@
 import { OCPP16ChargePointErrorCode } from './1.6/ChargePointErrorCode';
 
-export type ChargePointErrorCode = OCPP16ChargePointErrorCode;
-
 export const ChargePointErrorCode = {
   ...OCPP16ChargePointErrorCode,
-};
+} as const;
+export type ChargePointErrorCode = OCPP16ChargePointErrorCode;
index c28fd6efaf7ec69f575130f5391905e6616b2cbb..a8ae442f511aa61b7e800f40cadbad895281e0c4 100644 (file)
@@ -1,7 +1,6 @@
 import { OCPP16ChargePointStatus } from './1.6/ChargePointStatus';
 
-export type ChargePointStatus = OCPP16ChargePointStatus;
-
 export const ChargePointStatus = {
   ...OCPP16ChargePointStatus,
-};
+} as const;
+export type ChargePointStatus = OCPP16ChargePointStatus;
index d2c36d7d8903e7c9634bb2ecb03e1c536fdab7c6..a8b73a24175ffab4a824c585062210d4db189be3 100644 (file)
@@ -8,8 +8,7 @@ export type ChargingProfile = OCPP16ChargingProfile;
 
 export type ChargingSchedulePeriod = OCPP16ChargingSchedulePeriod;
 
-export type ChargingRateUnitType = OCPP16ChargingRateUnitType;
-
 export const ChargingRateUnitType = {
   ...OCPP16ChargingRateUnitType,
-};
+} as const;
+export type ChargingRateUnitType = OCPP16ChargingRateUnitType;
index f60c4f1c06712188ffdcc8bff47dc801e6c3a19f..aa50c75222623680885bb8e0b85950150dae0181 100644 (file)
@@ -5,23 +5,20 @@ import {
   OCPP16VendorDefaultParametersKey,
 } from './1.6/Configuration';
 
-export type StandardParametersKey = OCPP16StandardParametersKey;
-
 export const StandardParametersKey = {
   ...OCPP16StandardParametersKey,
-};
-
-export type VendorDefaultParametersKey = OCPP16VendorDefaultParametersKey;
+} as const;
+export type StandardParametersKey = OCPP16StandardParametersKey;
 
 export const VendorDefaultParametersKey = {
   ...OCPP16VendorDefaultParametersKey,
-};
-
-export type SupportedFeatureProfiles = OCPP16SupportedFeatureProfiles;
+} as const;
+export type VendorDefaultParametersKey = OCPP16VendorDefaultParametersKey;
 
 export const SupportedFeatureProfiles = {
   ...OCPP16SupportedFeatureProfiles,
-};
+} as const;
+export type SupportedFeatureProfiles = OCPP16SupportedFeatureProfiles;
 
 export enum ConnectorPhaseRotation {
   NotApplicable = 'NotApplicable',
index 2172ec1f925762826eba130ef579abcc7587230a..f34a8c176fd3cf711ee158bad3f9ac2e0f950c3e 100644 (file)
@@ -1,21 +1,19 @@
 import {
-  OCPP16MeterValue,
+  type OCPP16MeterValue,
   OCPP16MeterValueMeasurand,
   OCPP16MeterValuePhase,
-  OCPP16SampledValue,
+  type OCPP16SampledValue,
 } from './1.6/MeterValues';
 
-export type MeterValueMeasurand = OCPP16MeterValueMeasurand;
-
 export const MeterValueMeasurand = {
   ...OCPP16MeterValueMeasurand,
-};
-
-export type MeterValuePhase = OCPP16MeterValuePhase;
+} as const;
+export type MeterValueMeasurand = OCPP16MeterValueMeasurand;
 
 export const MeterValuePhase = {
   ...OCPP16MeterValuePhase,
-};
+} as const;
+export type MeterValuePhase = OCPP16MeterValuePhase;
 
 export type SampledValue = OCPP16SampledValue;
 
index 328ba2b4b6928b467240e2bd563f8bab035c79dc..a19fc28033e6afe9f9475cbd8d12334185ad3b04 100644 (file)
@@ -1,4 +1,5 @@
 export enum OCPPVersion {
   VERSION_16 = '1.6',
   VERSION_20 = '2.0',
+  VERSION_201 = '2.0.1',
 }
index 871015b6078855c30132ee27ac01f19dffaf5635..38596bfd4c611203d2999de8ad08c81aeb5ffb27 100644 (file)
@@ -16,12 +16,11 @@ import {
 import { OCPP20IncomingRequestCommand, OCPP20RequestCommand } from './2.0/Requests';
 import type { MessageType } from './MessageType';
 
-export type RequestCommand = OCPP16RequestCommand;
-
 export const RequestCommand = {
   ...OCPP16RequestCommand,
   ...OCPP20RequestCommand,
-};
+} as const;
+export type RequestCommand = OCPP16RequestCommand | OCPP20RequestCommand;
 
 export type OutgoingRequest = [MessageType.CALL_MESSAGE, string, RequestCommand, JsonType];
 
@@ -30,12 +29,11 @@ export type RequestParams = {
   triggerMessage?: boolean;
 };
 
-export type IncomingRequestCommand = OCPP16IncomingRequestCommand;
-
 export const IncomingRequestCommand = {
   ...OCPP16IncomingRequestCommand,
   ...OCPP20IncomingRequestCommand,
-};
+} as const;
+export type IncomingRequestCommand = OCPP16IncomingRequestCommand | OCPP20IncomingRequestCommand;
 
 export type IncomingRequest = [MessageType.CALL_MESSAGE, string, IncomingRequestCommand, JsonType];
 
@@ -50,11 +48,10 @@ export type CachedRequest = [
   JsonType
 ];
 
-export type MessageTrigger = OCPP16MessageTrigger;
-
 export const MessageTrigger = {
   ...OCPP16MessageTrigger,
-};
+} as const;
+export type MessageTrigger = OCPP16MessageTrigger;
 
 export type BootNotificationRequest = OCPP16BootNotificationRequest;
 
@@ -71,16 +68,14 @@ export type IncomingRequestHandler = (
   commandPayload: JsonType
 ) => JsonType | Promise<JsonType>;
 
-export type AvailabilityType = OCPP16AvailabilityType;
-
 export const AvailabilityType = {
   ...OCPP16AvailabilityType,
-};
-
-export type DiagnosticsStatus = OCPP16DiagnosticsStatus;
+} as const;
+export type AvailabilityType = OCPP16AvailabilityType;
 
 export const DiagnosticsStatus = {
   ...OCPP16DiagnosticsStatus,
-};
+} as const;
+export type DiagnosticsStatus = OCPP16DiagnosticsStatus;
 
 export type ResponseType = JsonType | OCPPError;
index 2ddb98f2d107ad57ff6b0fcd87798254d2e9ae13..59884dfd208fc127d71068177b6423a45b95ccdd 100644 (file)
@@ -3,15 +3,15 @@ import type { JsonType } from '../JsonType';
 import type { OCPP16MeterValuesResponse } from './1.6/MeterValues';
 import {
   OCPP16AvailabilityStatus,
-  OCPP16BootNotificationResponse,
+  type OCPP16BootNotificationResponse,
   OCPP16ChargingProfileStatus,
   OCPP16ClearChargingProfileStatus,
   OCPP16ConfigurationStatus,
-  OCPP16DataTransferResponse,
+  type OCPP16DataTransferResponse,
   OCPP16DataTransferStatus,
-  OCPP16HeartbeatResponse,
+  type OCPP16HeartbeatResponse,
   OCPP16RegistrationStatus,
-  OCPP16StatusNotificationResponse,
+  type OCPP16StatusNotificationResponse,
   OCPP16TriggerMessageStatus,
   OCPP16UnlockStatus,
 } from './1.6/Responses';
@@ -47,50 +47,42 @@ export type DefaultResponse = {
   status: DefaultStatus;
 };
 
-export type RegistrationStatus = OCPP16RegistrationStatus;
-
 export const RegistrationStatus = {
   ...OCPP16RegistrationStatus,
-};
-
-export type AvailabilityStatus = OCPP16AvailabilityStatus;
+} as const;
+export type RegistrationStatus = OCPP16RegistrationStatus;
 
 export const AvailabilityStatus = {
   ...OCPP16AvailabilityStatus,
-};
-
-export type ChargingProfileStatus = OCPP16ChargingProfileStatus;
+} as const;
+export type AvailabilityStatus = OCPP16AvailabilityStatus;
 
 export const ChargingProfileStatus = {
   ...OCPP16ChargingProfileStatus,
-};
-
-export type ClearChargingProfileStatus = OCPP16ClearChargingProfileStatus;
+} as const;
+export type ChargingProfileStatus = OCPP16ChargingProfileStatus;
 
 export const ClearChargingProfileStatus = {
   ...OCPP16ClearChargingProfileStatus,
-};
-
-export type ConfigurationStatus = OCPP16ConfigurationStatus;
+} as const;
+export type ClearChargingProfileStatus = OCPP16ClearChargingProfileStatus;
 
 export const ConfigurationStatus = {
   ...OCPP16ConfigurationStatus,
-};
-
-export type UnlockStatus = OCPP16UnlockStatus;
+} as const;
+export type ConfigurationStatus = OCPP16ConfigurationStatus;
 
 export const UnlockStatus = {
   ...OCPP16UnlockStatus,
-};
-
-export type TriggerMessageStatus = OCPP16TriggerMessageStatus;
+} as const;
+export type UnlockStatus = OCPP16UnlockStatus;
 
 export const TriggerMessageStatus = {
   ...OCPP16TriggerMessageStatus,
-};
-
-export type DataTransferStatus = OCPP16DataTransferStatus;
+} as const;
+export type TriggerMessageStatus = OCPP16TriggerMessageStatus;
 
 export const DataTransferStatus = {
   ...OCPP16DataTransferStatus,
-};
+} as const;
+export type DataTransferStatus = OCPP16DataTransferStatus;
index 3dd499c992697fa53da594c9ab3fcb2dcc8d6c98..2a8a0ad46648978d3fe8b0fbab43f3cf008b812d 100644 (file)
@@ -1,29 +1,27 @@
 import {
   OCPP16AuthorizationStatus,
-  OCPP16AuthorizeRequest,
-  OCPP16AuthorizeResponse,
-  OCPP16StartTransactionRequest,
-  OCPP16StartTransactionResponse,
+  type OCPP16AuthorizeRequest,
+  type OCPP16AuthorizeResponse,
+  type OCPP16StartTransactionRequest,
+  type OCPP16StartTransactionResponse,
   OCPP16StopTransactionReason,
-  OCPP16StopTransactionRequest,
-  OCPP16StopTransactionResponse,
+  type OCPP16StopTransactionRequest,
+  type OCPP16StopTransactionResponse,
 } from './1.6/Transaction';
 
-export type AuthorizationStatus = OCPP16AuthorizationStatus;
-
 export const AuthorizationStatus = {
   ...OCPP16AuthorizationStatus,
-};
+} as const;
+export type AuthorizationStatus = OCPP16AuthorizationStatus;
 
 export type AuthorizeRequest = OCPP16AuthorizeRequest;
 
 export type AuthorizeResponse = OCPP16AuthorizeResponse;
 
-export type StopTransactionReason = OCPP16StopTransactionReason;
-
 export const StopTransactionReason = {
   ...OCPP16StopTransactionReason,
-};
+} as const;
+export type StopTransactionReason = OCPP16StopTransactionReason;
 
 export type StartTransactionRequest = OCPP16StartTransactionRequest;
 
index 08a37220c1469e255873ab06482a3193b4c25d87..d4e965e7adf22bdc5c571b3701db9541a7631c23 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 export const DEFAULT_CIRCULAR_ARRAY_SIZE = Number.MAX_SAFE_INTEGER;
 
index b779bf1dffa1d83470ae19ed3754e167b3b1b149..7b91344296009c4e10c093774a8cdb905eb33f2c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 /**
  * Rationale: https://wiki.piment-noir.org/doku.php/en:cs:modelling_multi-phased_electrical_system_interconnexion
index 94fa3d186e432712238ceee87e7f3491244cb5b7..0da6289c242ea69e3b3b72aa32657a190a631b6f 100644 (file)
@@ -267,7 +267,7 @@ export default class Utils {
   }
 
   public static JSONStringifyWithMapSupport(
-    obj: Record<string, unknown> | Record<string, unknown>[] | Map<string, unknown>,
+    obj: Record<string, unknown> | Record<string, unknown>[] | Map<unknown, unknown>,
     space?: number
   ): string {
     return JSON.stringify(
index fba3516aabb3899a8dd005e2707dfb0a450c83f5..8a1aeb30bc5521f1701f6f1d190cda2aaf24aa37 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import { Worker } from 'worker_threads';
 
index 3aa769839848ba9da75f572b3cb349997fb58e62..80499a9fc8bf1f8b1bcd4ecde7c2d92b2be6d304 100644 (file)
@@ -86,11 +86,10 @@ export enum OCPP16IncomingRequestCommand {
   TRIGGER_MESSAGE = 'TriggerMessage',
 }
 
-export type IncomingRequestCommand = OCPP16IncomingRequestCommand;
-
 export const IncomingRequestCommand = {
   ...OCPP16IncomingRequestCommand,
-};
+} as const;
+export type IncomingRequestCommand = OCPP16IncomingRequestCommand;
 
 export enum OCPP16RequestCommand {
   BOOT_NOTIFICATION = 'BootNotification',
@@ -103,11 +102,10 @@ export enum OCPP16RequestCommand {
   DIAGNOSTICS_STATUS_NOTIFICATION = 'DiagnosticsStatusNotification',
 }
 
-export type RequestCommand = OCPP16RequestCommand;
-
 export const RequestCommand = {
   ...OCPP16RequestCommand,
-};
+} as const;
+export type RequestCommand = OCPP16RequestCommand;
 
 export type BootNotificationResponse = OCPP16BootNotificationResponse;
 
@@ -132,11 +130,10 @@ export enum OCPP16MessageTrigger {
   StatusNotification = 'StatusNotification',
 }
 
-export type MessageTrigger = OCPP16MessageTrigger;
-
 export const MessageTrigger = {
   ...OCPP16MessageTrigger,
-};
+} as const;
+export type MessageTrigger = OCPP16MessageTrigger;
 
 type CommandsSupport = {
   incomingCommands: Record<IncomingRequestCommand, boolean>;