]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor: cleanup OCPP2 commands implementation
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 21 Oct 2025 16:26:03 +0000 (18:26 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 21 Oct 2025 16:26:03 +0000 (18:26 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/2.0/OCPP20Constants.ts
src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
src/charging-station/ocpp/2.0/OCPP20RequestService.ts
src/types/ConnectorStatus.ts
src/types/index.ts
src/types/ocpp/2.0/Common.ts
src/types/ocpp/2.0/Requests.ts
src/types/ocpp/2.0/Responses.ts
src/types/ocpp/2.0/Variables.ts
src/types/ocpp/ConnectorEnumType.ts [new file with mode: 0644]

index 9ebf8aa0281a254a50f47d02989d29f10b61fc3e..8b530e2a972137fa99a84f50371965aee90e9519 100644 (file)
@@ -146,7 +146,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
       ],
       [
         OCPP16IncomingRequestCommand.CLEAR_CACHE,
-        this.handleRequestClearCache.bind(this) as IncomingRequestHandler,
+        super.handleRequestClearCache.bind(this) as IncomingRequestHandler,
       ],
       [
         OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
index 93c37f4058f35dff6120af9e67328b39dd06476f..c94fbe9f10d486e2eeb6a98b52bf25ad8a7e70d7 100644 (file)
@@ -5,13 +5,6 @@ import {
 import { OCPPConstants } from '../OCPPConstants.js'
 
 export class OCPP20Constants extends OCPPConstants {
-  static readonly ComponentName = {
-    CHARGING_STATION: 'ChargingStation',
-    CONNECTOR: 'Connector',
-    EVSE: 'EVSE',
-    OCPP_COMM_CTRLR: 'OCPPCommCtrlr',
-  } as const
-
   static readonly ChargingStationStatusTransitions: readonly ConnectorStatusTransition[] =
     Object.freeze([
       { to: OCPP20ConnectorStatusEnumType.Available },
index 05ce66aa9165917b228aaa2c98c5e929365487da..1fb65e8c96f63eca2c11d3f01caf5e41a818123d 100644 (file)
@@ -6,13 +6,13 @@ import type { ChargingStation } from '../../../charging-station/index.js'
 
 import { OCPPError } from '../../../exception/index.js'
 import {
-  type ComponentType,
+  ConnectorEnumType,
   ErrorType,
-  type EVSEType,
   GenericDeviceModelStatusEnumType,
   type IncomingRequestHandler,
   type JsonType,
   type OCPP20ClearCacheRequest,
+  OCPP20ComponentName,
   type OCPP20GetBaseReportRequest,
   type OCPP20GetBaseReportResponse,
   OCPP20IncomingRequestCommand,
@@ -22,13 +22,9 @@ import {
   OCPPVersion,
   ReportBaseEnumType,
   type ReportDataType,
-  type VariableAttributeType,
-  type VariableCharacteristicsType,
-  type VariableType,
 } from '../../../types/index.js'
 import { isAsyncFunction, logger } from '../../../utils/index.js'
 import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService.js'
-import { OCPP20Constants } from './OCPP20Constants.js'
 import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js'
 
 const moduleName = 'OCPP20IncomingRequestService'
@@ -47,7 +43,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
     // }
     super(OCPPVersion.VERSION_201)
     this.incomingRequestHandlers = new Map<OCPP20IncomingRequestCommand, IncomingRequestHandler>([
-      [OCPP20IncomingRequestCommand.CLEAR_CACHE, this.handleRequestClearCache.bind(this)],
+      [OCPP20IncomingRequestCommand.CLEAR_CACHE, super.handleRequestClearCache.bind(this)],
       [OCPP20IncomingRequestCommand.GET_BASE_REPORT, this.handleRequestGetBaseReport.bind(this)],
     ])
     this.payloadValidateFunctions = new Map<
@@ -84,13 +80,14 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
         response: OCPP20GetBaseReportResponse
       ) => {
         if (response.status === GenericDeviceModelStatusEnumType.Accepted) {
-          const { requestId, reportBase } = request
+          const { reportBase, requestId } = request
           const reportData = this.buildReportData(chargingStation, reportBase)
           chargingStation.ocppRequestService
             .requestHandler<OCPP20NotifyReportRequest, OCPP20NotifyReportResponse>(
               chargingStation,
               OCPP20RequestCommand.NOTIFY_REPORT,
               {
+                generatedAt: new Date(),
                 reportData,
                 requestId,
                 seqNo: 0,
@@ -98,9 +95,11 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
               }
             )
             .then(() => {
-              logger.info(
+              logger.debug(
+                // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
                 `${chargingStation.logPrefix()} ${moduleName}.constructor: NotifyReport sent for requestId ${requestId} with ${reportData.length} report items`
               )
+              return undefined
             })
             .catch((error: unknown) => {
               logger.error(
@@ -203,34 +202,12 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
     this.emit(commandName, chargingStation, commandPayload, response)
   }
 
-  private handleRequestGetBaseReport (
-    chargingStation: ChargingStation,
-    commandPayload: OCPP20GetBaseReportRequest
-  ): OCPP20GetBaseReportResponse {
-    logger.info(
-      `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetBaseReport: GetBaseReport request received with requestId ${commandPayload.requestId} and reportBase ${commandPayload.reportBase}`
-    )
-    // Build report data to check if any data is available
-    const reportData = this.buildReportData(chargingStation, commandPayload.reportBase)
-    if (reportData.length === 0) {
-      logger.info(
-        `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetBaseReport: No data available for reportBase ${commandPayload.reportBase}`
-      )
-      return {
-        status: GenericDeviceModelStatusEnumType.EmptyResultSet,
-      }
-    }
-    return {
-      status: GenericDeviceModelStatusEnumType.Accepted,
-    }
-  }
-
   private buildReportData (
     chargingStation: ChargingStation,
-    reportBase: string
+    reportBase: ReportBaseEnumType
   ): ReportDataType[] {
     // Validate reportBase parameter
-    if (!Object.values(ReportBaseEnumType).includes(reportBase as ReportBaseEnumType)) {
+    if (!Object.values(ReportBaseEnumType).includes(reportBase)) {
       logger.warn(
         `${chargingStation.logPrefix()} ${moduleName}.buildReportData: Invalid reportBase '${reportBase}'`
       )
@@ -246,7 +223,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
           for (const configKey of chargingStation.ocppConfiguration.configurationKey) {
             reportData.push({
               component: {
-                name: OCPP20Constants.ComponentName.OCPP_COMM_CTRLR,
+                name: OCPP20ComponentName.OCPPCommCtrlr,
               },
               variable: {
                 name: configKey.key,
@@ -273,7 +250,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
           const stationInfo = chargingStation.stationInfo
           if (stationInfo.chargePointModel) {
             reportData.push({
-              component: { name: OCPP20Constants.ComponentName.CHARGING_STATION },
+              component: { name: OCPP20ComponentName.DeviceDataCtrlr },
               variable: { name: 'Model' },
               variableAttribute: [{ type: 'Actual', value: stationInfo.chargePointModel }],
               variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
@@ -281,7 +258,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
           }
           if (stationInfo.chargePointVendor) {
             reportData.push({
-              component: { name: OCPP20Constants.ComponentName.CHARGING_STATION },
+              component: { name: OCPP20ComponentName.DeviceDataCtrlr },
               variable: { name: 'VendorName' },
               variableAttribute: [{ type: 'Actual', value: stationInfo.chargePointVendor }],
               variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
@@ -289,7 +266,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
           }
           if (stationInfo.chargePointSerialNumber) {
             reportData.push({
-              component: { name: OCPP20Constants.ComponentName.CHARGING_STATION },
+              component: { name: OCPP20ComponentName.DeviceDataCtrlr },
               variable: { name: 'SerialNumber' },
               variableAttribute: [{ type: 'Actual', value: stationInfo.chargePointSerialNumber }],
               variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
@@ -297,7 +274,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
           }
           if (stationInfo.firmwareVersion) {
             reportData.push({
-              component: { name: OCPP20Constants.ComponentName.CHARGING_STATION },
+              component: { name: OCPP20ComponentName.DeviceDataCtrlr },
               variable: { name: 'FirmwareVersion' },
               variableAttribute: [{ type: 'Actual', value: stationInfo.firmwareVersion }],
               variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
@@ -309,7 +286,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
         if (chargingStation.ocppConfiguration?.configurationKey) {
           for (const configKey of chargingStation.ocppConfiguration.configurationKey) {
             reportData.push({
-              component: { name: OCPP20Constants.ComponentName.OCPP_COMM_CTRLR },
+              component: { name: OCPP20ComponentName.OCPPCommCtrlr },
               variable: { name: configKey.key },
               variableAttribute: [{ type: 'Actual', value: configKey.value }],
               variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
@@ -323,22 +300,22 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
             reportData.push({
               component: {
                 evse: { id: evseId },
-                name: 'EVSE',
+                name: OCPP20ComponentName.DeviceDataCtrlr,
               },
               variable: { name: 'AvailabilityState' },
               variableAttribute: [{ type: 'Actual', value: evse.availability }],
               variableCharacteristics: { dataType: 'string', supportsMonitoring: true },
             })
-            if (evse.connectors) {
+            if (evse.connectors.size > 0) {
               for (const [connectorId, connector] of evse.connectors) {
                 reportData.push({
                   component: {
-                    evse: { connectorId, id: evseId },
-                    name: 'Connector',
+                    evse: { connectorId: connectorId.toString(), id: evseId },
+                    name: OCPP20ComponentName.DeviceDataCtrlr,
                   },
                   variable: { name: 'ConnectorType' },
                   variableAttribute: [
-                    { type: 'Actual', value: String(connector.connectorType) },
+                    { type: 'Actual', value: connector.type ?? ConnectorEnumType.Unknown },
                   ],
                   variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
                 })
@@ -351,11 +328,13 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
             if (connectorId > 0) {
               reportData.push({
                 component: {
-                  evse: { connectorId, id: 1 },
+                  evse: { connectorId: connectorId.toString(), id: 1 },
                   name: 'Connector',
                 },
                 variable: { name: 'ConnectorType' },
-                variableAttribute: [{ type: 'Actual', value: String(connector.connectorType) }],
+                variableAttribute: [
+                  { type: 'Actual', value: connector.type ?? ConnectorEnumType.Unknown },
+                ],
                 variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
               })
             }
@@ -369,7 +348,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
           const stationInfo = chargingStation.stationInfo
           if (stationInfo.chargePointModel) {
             reportData.push({
-              component: { name: OCPP20Constants.ComponentName.CHARGING_STATION },
+              component: { name: 'ChargingStation' },
               variable: { name: 'Model' },
               variableAttribute: [{ type: 'Actual', value: stationInfo.chargePointModel }],
               variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
@@ -377,7 +356,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
           }
           if (stationInfo.chargePointVendor) {
             reportData.push({
-              component: { name: OCPP20Constants.ComponentName.CHARGING_STATION },
+              component: { name: 'ChargingStation' },
               variable: { name: 'VendorName' },
               variableAttribute: [{ type: 'Actual', value: stationInfo.chargePointVendor }],
               variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
@@ -385,7 +364,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
           }
           if (stationInfo.firmwareVersion) {
             reportData.push({
-              component: { name: OCPP20Constants.ComponentName.CHARGING_STATION },
+              component: { name: 'ChargingStation' },
               variable: { name: 'FirmwareVersion' },
               variableAttribute: [{ type: 'Actual', value: stationInfo.firmwareVersion }],
               variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
@@ -396,6 +375,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
 
       default:
         logger.warn(
+          // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
           `${chargingStation.logPrefix()} ${moduleName}.buildReportData: Unknown reportBase '${reportBase}'`
         )
     }
@@ -403,6 +383,29 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
     return reportData
   }
 
+  private handleRequestGetBaseReport (
+    chargingStation: ChargingStation,
+    commandPayload: OCPP20GetBaseReportRequest
+  ): OCPP20GetBaseReportResponse {
+    logger.debug(
+      // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+      `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetBaseReport: GetBaseReport request received with requestId ${commandPayload.requestId} and reportBase ${commandPayload.reportBase}`
+    )
+    // Build report data to check if any data is available
+    const reportData = this.buildReportData(chargingStation, commandPayload.reportBase)
+    if (reportData.length === 0) {
+      logger.info(
+        `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetBaseReport: No data available for reportBase ${commandPayload.reportBase}`
+      )
+      return {
+        status: GenericDeviceModelStatusEnumType.EmptyResultSet,
+      }
+    }
+    return {
+      status: GenericDeviceModelStatusEnumType.Accepted,
+    }
+  }
+
   private validatePayload (
     chargingStation: ChargingStation,
     commandName: OCPP20IncomingRequestCommand,
index 57eeaca6a6587a3481fea0f5c67628e7d309bde0..926d4d17aeda8f7364c3f05f6f1dde14875fea92 100644 (file)
@@ -119,7 +119,6 @@ export class OCPP20RequestService extends OCPPRequestService {
         return OCPP20Constants.OCPP_RESPONSE_EMPTY as unknown as Request
       case OCPP20RequestCommand.NOTIFY_REPORT:
         return {
-          generatedAt: new Date(),
           ...commandParams,
         } as unknown as Request
       case OCPP20RequestCommand.STATUS_NOTIFICATION:
index b9fef35e0026e540c3501e7f147018490d1bf8d9..d77a874422c540b8a11b4bcf051049f54d75d301 100644 (file)
@@ -1,5 +1,6 @@
 import type { SampledValueTemplate } from './MeasurandPerPhaseSampledValueTemplates.js'
 import type { ChargingProfile } from './ocpp/ChargingProfile.js'
+import type { ConnectorEnumType } from './ocpp/ConnectorEnumType.js'
 import type { ConnectorStatusEnum } from './ocpp/ConnectorStatusEnum.js'
 import type { MeterValue } from './ocpp/MeterValues.js'
 import type { AvailabilityType } from './ocpp/Requests.js'
@@ -25,4 +26,5 @@ export interface ConnectorStatus {
   transactionSetInterval?: NodeJS.Timeout
   transactionStart?: Date
   transactionStarted?: boolean
+  type?: ConnectorEnumType
 }
index 64450bb55c9db993a22fde1fb43db273558ddcce..1ab04353dfb7878bb8b4c54b9bf81043062d9c8c 100644 (file)
@@ -148,8 +148,6 @@ export {
   ReportBaseEnumType,
 } from './ocpp/2.0/Common.js'
 export {
-  type ComponentType,
-  type EVSEType,
   type OCPP20BootNotificationRequest,
   type OCPP20ClearCacheRequest,
   type OCPP20GetBaseReportRequest,
@@ -161,7 +159,6 @@ export {
   type ReportDataType,
   type VariableAttributeType,
   type VariableCharacteristicsType,
-  type VariableType,
 } from './ocpp/2.0/Requests.js'
 export type {
   OCPP20BootNotificationResponse,
@@ -171,7 +168,7 @@ export type {
   OCPP20NotifyReportResponse,
   OCPP20StatusNotificationResponse,
 } from './ocpp/2.0/Responses.js'
-export { OCPP20OptionalVariableName } from './ocpp/2.0/Variables.js'
+export { OCPP20ComponentName, OCPP20OptionalVariableName } from './ocpp/2.0/Variables.js'
 export { ChargePointErrorCode } from './ocpp/ChargePointErrorCode.js'
 export {
   type ChargingProfile,
@@ -190,6 +187,7 @@ export {
   SupportedFeatureProfiles,
   VendorParametersKey,
 } from './ocpp/Configuration.js'
+export { ConnectorEnumType } from './ocpp/ConnectorEnumType.js'
 export { ConnectorStatusEnum, type ConnectorStatusTransition } from './ocpp/ConnectorStatusEnum.js'
 export { ErrorType } from './ocpp/ErrorType.js'
 export { MessageType } from './ocpp/MessageType.js'
index d1ed68ed026268540c88dbe0371c3286caa1ccee..a8a058a65548c952dd602a12e0270ef36826223a 100644 (file)
@@ -40,6 +40,13 @@ export enum DeleteCertificateStatusEnumType {
   NotFound = 'NotFound',
 }
 
+export enum GenericDeviceModelStatusEnumType {
+  Accepted = 'Accepted',
+  EmptyResultSet = 'EmptyResultSet',
+  NotSupported = 'NotSupported',
+  Rejected = 'Rejected',
+}
+
 export enum GetCertificateIdUseEnumType {
   CSMSRootCertificate = 'CSMSRootCertificate',
   ManufacturerRootCertificate = 'ManufacturerRootCertificate',
@@ -53,13 +60,6 @@ export enum GetCertificateStatusEnumType {
   Failed = 'Failed',
 }
 
-export enum GenericDeviceModelStatusEnumType {
-  Accepted = 'Accepted',
-  EmptyResultSet = 'EmptyResultSet',
-  NotSupported = 'NotSupported',
-  Rejected = 'Rejected',
-}
-
 export enum GetInstalledCertificateStatusEnumType {
   Accepted = 'Accepted',
   NotFound = 'NotFound',
@@ -84,6 +84,31 @@ export enum InstallCertificateUseEnumType {
   V2GRootCertificate = 'V2GRootCertificate',
 }
 
+export enum OCPP20ConnectorEnumType {
+  cCCS1 = 'cCCS1',
+  cCCS2 = 'cCCS2',
+  cG105 = 'cG105',
+  cTesla = 'cTesla',
+  cType1 = 'cType1',
+  cType2 = 'cType2',
+  Other1PhMax16A = 'Other1PhMax16A',
+  Other1PhOver16A = 'Other1PhOver16A',
+  Other3Ph = 'Other3Ph',
+  Pan = 'Pan',
+  s309_1P_16A = 's309-1P-16A',
+  s309_1P_32A = 's309-1P-32A',
+  s309_3P_16A = 's309-3P-16A',
+  s309_3P_32A = 's309-3P-32A',
+  sBS1361 = 'sBS1361',
+  sCEE_7_7 = 'sCEE-7-7',
+  sType2 = 'sType2',
+  sType3 = 'sType3',
+  Undetermined = 'Undetermined',
+  Unknown = 'Unknown',
+  wInductive = 'wInductive',
+  wResonant = 'wResonant',
+}
+
 export enum OCPP20ConnectorStatusEnumType {
   Available = 'Available',
   Faulted = 'Faulted',
index 1c2fb339c96a5b12743318b97126a815bdfcde49..e4edd59702103b0815b8851d0f4fe79e6df7fa9e 100644 (file)
@@ -6,7 +6,12 @@ import type {
   OCPP20ConnectorStatusEnumType,
   ReportBaseEnumType,
 } from './Common.js'
-import type { OCPP20SetVariableDataType } from './Variables.js'
+import type {
+  ChargingStationType,
+  ComponentType,
+  OCPP20SetVariableDataType,
+  VariableType,
+} from './Variables.js'
 
 export enum OCPP20IncomingRequestCommand {
   CLEAR_CACHE = 'ClearCache',
@@ -36,19 +41,19 @@ export interface OCPP20GetBaseReportRequest extends JsonObject {
 
 export type OCPP20HeartbeatRequest = EmptyObject
 
+export interface OCPP20InstallCertificateRequest extends JsonObject {
+  certificate: string
+  certificateType: InstallCertificateUseEnumType
+}
+
 export interface OCPP20NotifyReportRequest extends JsonObject {
   generatedAt: Date
-  requestId: number
   reportData?: ReportDataType[]
+  requestId: number
   seqNo: number
   tbc?: boolean
 }
 
-export interface OCPP20InstallCertificateRequest extends JsonObject {
-  certificate: string
-  certificateType: InstallCertificateUseEnumType
-}
-
 export interface OCPP20SetVariablesRequest extends JsonObject {
   setVariableData: OCPP20SetVariableDataType[]
 }
@@ -60,19 +65,6 @@ export interface OCPP20StatusNotificationRequest extends JsonObject {
   timestamp: Date
 }
 
-interface ChargingStationType extends JsonObject {
-  firmwareVersion?: string
-  model: string
-  modem?: ModemType
-  serialNumber?: string
-  vendorName: string
-}
-
-interface ModemType extends JsonObject {
-  iccid?: string
-  imsi?: string
-}
-
 export interface ReportDataType extends JsonObject {
   component: ComponentType
   variable: VariableType
@@ -80,17 +72,6 @@ export interface ReportDataType extends JsonObject {
   variableCharacteristics?: VariableCharacteristicsType
 }
 
-export interface ComponentType extends JsonObject {
-  evse?: EVSEType
-  instance?: string
-  name: string
-}
-
-export interface VariableType extends JsonObject {
-  instance?: string
-  name: string
-}
-
 export interface VariableAttributeType extends JsonObject {
   type?: string
   value?: string
@@ -100,8 +81,3 @@ export interface VariableCharacteristicsType extends JsonObject {
   dataType: string
   supportsMonitoring: boolean
 }
-
-export interface EVSEType extends JsonObject {
-  connectorId?: number
-  id: number
-}
index 225c5aae07a423b550ff6fc3d89a85d1ebf9f60c..7f49836754e2f6b0c5e2d192a4f1952dec817854 100644 (file)
@@ -30,13 +30,13 @@ export interface OCPP20HeartbeatResponse extends JsonObject {
   currentTime: Date
 }
 
-export type OCPP20NotifyReportResponse = EmptyObject
-
 export interface OCPP20InstallCertificateResponse extends JsonObject {
   status: InstallCertificateStatusEnumType
   statusInfo?: StatusInfoType
 }
 
+export type OCPP20NotifyReportResponse = EmptyObject
+
 export interface OCPP20SetVariablesResponse extends JsonObject {
   setVariableResult: OCPP20SetVariableResultType[]
 }
index e31da2202cc34383f03f437bfe457b2a9b0dc794..02a52eee8ff598f7571a389126dd3bbb7a4ff5fb 100644 (file)
@@ -1,6 +1,27 @@
 import type { JsonObject } from '../../JsonType.js'
 import type { EVSEType, StatusInfoType } from './Common.js'
 
+export enum OCPP20ComponentName {
+  AlignedDataCtrlr = 'AlignedDataCtrlr',
+  AuthCacheCtrlr = 'AuthCacheCtrlr',
+  AuthCtrlr = 'AuthCtrlr',
+  CHAdeMOCtrlr = 'CHAdeMOCtrlr',
+  ClockCtrlr = 'ClockCtrlr',
+  CustomizationCtrlr = 'CustomizationCtrlr',
+  DeviceDataCtrlr = 'DeviceDataCtrlr',
+  DisplayMessageCtrlr = 'DisplayMessageCtrlr',
+  ISO15118Ctrlr = 'ISO15118Ctrlr',
+  LocalAuthListCtrlr = 'LocalAuthListCtrlr',
+  MonitoringCtrlr = 'MonitoringCtrlr',
+  OCPPCommCtrlr = 'OCPPCommCtrlr',
+  ReservationCtrlr = 'ReservationCtrlr',
+  SampledDataCtrlr = 'SampledDataCtrlr',
+  SecurityCtrlr = 'SecurityCtrlr',
+  SmartChargingCtrlr = 'SmartChargingCtrlr',
+  TariffCostCtrlr = 'TariffCostCtrlr',
+  TxCtrlr = 'TxCtrlr',
+}
+
 export enum OCPP20OptionalVariableName {
   HeartbeatInterval = 'HeartbeatInterval',
   WebSocketPingInterval = 'WebSocketPingInterval',
@@ -48,27 +69,6 @@ enum AttributeEnumType {
   Target = 'Target',
 }
 
-enum OCPP20ComponentName {
-  AlignedDataCtrlr = 'AlignedDataCtrlr',
-  AuthCacheCtrlr = 'AuthCacheCtrlr',
-  AuthCtrlr = 'AuthCtrlr',
-  CHAdeMOCtrlr = 'CHAdeMOCtrlr',
-  ClockCtrlr = 'ClockCtrlr',
-  CustomizationCtrlr = 'CustomizationCtrlr',
-  DeviceDataCtrlr = 'DeviceDataCtrlr',
-  DisplayMessageCtrlr = 'DisplayMessageCtrlr',
-  ISO15118Ctrlr = 'ISO15118Ctrlr',
-  LocalAuthListCtrlr = 'LocalAuthListCtrlr',
-  MonitoringCtrlr = 'MonitoringCtrlr',
-  OCPPCommCtrlr = 'OCPPCommCtrlr',
-  ReservationCtrlr = 'ReservationCtrlr',
-  SampledDataCtrlr = 'SampledDataCtrlr',
-  SecurityCtrlr = 'SecurityCtrlr',
-  SmartChargingCtrlr = 'SmartChargingCtrlr',
-  TariffCostCtrlr = 'TariffCostCtrlr',
-  TxCtrlr = 'TxCtrlr',
-}
-
 enum SetVariableStatusEnumType {
   Accepted = 'Accepted',
   NotSupportedAttributeType = 'NotSupportedAttributeType',
@@ -78,6 +78,20 @@ enum SetVariableStatusEnumType {
   UnknownVariable = 'UnknownVariable',
 }
 
+export interface ChargingStationType extends JsonObject {
+  firmwareVersion?: string
+  model: string
+  modem?: ModemType
+  serialNumber?: string
+  vendorName: string
+}
+
+export interface ComponentType extends JsonObject {
+  evse?: EVSEType
+  instance?: string
+  name: OCPP20ComponentName | string
+}
+
 export interface OCPP20ComponentVariableType extends JsonObject {
   component: ComponentType
   variable?: VariableType
@@ -98,10 +112,14 @@ export interface OCPP20SetVariableResultType extends JsonObject {
   variable: VariableType
 }
 
-interface ComponentType extends JsonObject {
-  evse?: EVSEType
+export interface VariableType extends JsonObject {
   instance?: string
-  name: OCPP20ComponentName | string
+  name: VariableName
+}
+
+interface ModemType extends JsonObject {
+  iccid?: string
+  imsi?: string
 }
 
 type VariableName =
@@ -109,8 +127,3 @@ type VariableName =
   | OCPP20RequiredVariableName
   | OCPP20VendorVariableName
   | string
-
-interface VariableType extends JsonObject {
-  instance?: string
-  name: VariableName
-}
diff --git a/src/types/ocpp/ConnectorEnumType.ts b/src/types/ocpp/ConnectorEnumType.ts
new file mode 100644 (file)
index 0000000..cc36ef5
--- /dev/null
@@ -0,0 +1,7 @@
+import { OCPP20ConnectorEnumType } from './2.0/Common.js'
+
+export const ConnectorEnumType = {
+  ...OCPP20ConnectorEnumType,
+} as const
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export type ConnectorEnumType = OCPP20ConnectorEnumType