]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor: cleanups OCPP2 types
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 21 Oct 2025 17:05:08 +0000 (19:05 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 21 Oct 2025 17:05:08 +0000 (19:05 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
src/types/index.ts
src/types/ocpp/2.0/Common.ts
src/types/ocpp/2.0/Requests.ts
src/types/ocpp/2.0/Variables.ts

index 1fb65e8c96f63eca2c11d3f01caf5e41a818123d..f2eb02ee6804d220be492b668d8832f7f80d825e 100644 (file)
@@ -348,7 +348,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
           const stationInfo = chargingStation.stationInfo
           if (stationInfo.chargePointModel) {
             reportData.push({
-              component: { name: 'ChargingStation' },
+              component: { name: OCPP20ComponentName.DeviceDataCtrlr },
               variable: { name: 'Model' },
               variableAttribute: [{ type: 'Actual', value: stationInfo.chargePointModel }],
               variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
@@ -356,7 +356,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
           }
           if (stationInfo.chargePointVendor) {
             reportData.push({
-              component: { name: 'ChargingStation' },
+              component: { name: OCPP20ComponentName.DeviceDataCtrlr },
               variable: { name: 'VendorName' },
               variableAttribute: [{ type: 'Actual', value: stationInfo.chargePointVendor }],
               variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
@@ -364,7 +364,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
           }
           if (stationInfo.firmwareVersion) {
             reportData.push({
-              component: { name: 'ChargingStation' },
+              component: { name: OCPP20ComponentName.DeviceDataCtrlr },
               variable: { name: 'FirmwareVersion' },
               variableAttribute: [{ type: 'Actual', value: stationInfo.firmwareVersion }],
               variableCharacteristics: { dataType: 'string', supportsMonitoring: false },
index 1ab04353dfb7878bb8b4c54b9bf81043062d9c8c..bf4024f43d9823046dbd36b0ee079ff588a39120 100644 (file)
@@ -144,8 +144,10 @@ export {
 export {
   BootReasonEnumType,
   GenericDeviceModelStatusEnumType,
+  OCPP20ComponentName,
   OCPP20ConnectorStatusEnumType,
   ReportBaseEnumType,
+  type ReportDataType,
 } from './ocpp/2.0/Common.js'
 export {
   type OCPP20BootNotificationRequest,
@@ -156,9 +158,6 @@ export {
   type OCPP20NotifyReportRequest,
   OCPP20RequestCommand,
   type OCPP20StatusNotificationRequest,
-  type ReportDataType,
-  type VariableAttributeType,
-  type VariableCharacteristicsType,
 } from './ocpp/2.0/Requests.js'
 export type {
   OCPP20BootNotificationResponse,
@@ -168,7 +167,7 @@ export type {
   OCPP20NotifyReportResponse,
   OCPP20StatusNotificationResponse,
 } from './ocpp/2.0/Responses.js'
-export { OCPP20ComponentName, OCPP20OptionalVariableName } from './ocpp/2.0/Variables.js'
+export { OCPP20OptionalVariableName } from './ocpp/2.0/Variables.js'
 export { ChargePointErrorCode } from './ocpp/ChargePointErrorCode.js'
 export {
   type ChargingProfile,
index a8a058a65548c952dd602a12e0270ef36826223a..2a16d8400b12967ef0b2fb1fd927c77f159f5321 100644 (file)
@@ -1,5 +1,6 @@
 import type { JsonObject } from '../../JsonType.js'
 import type { GenericStatus } from '../Common.js'
+import type { VariableType } from './Variables.js'
 
 export enum BootReasonEnumType {
   ApplicationReset = 'ApplicationReset',
@@ -84,6 +85,27 @@ export enum InstallCertificateUseEnumType {
   V2GRootCertificate = 'V2GRootCertificate',
 }
 
+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 OCPP20ConnectorEnumType {
   cCCS1 = 'cCCS1',
   cCCS2 = 'cCCS2',
@@ -143,6 +165,19 @@ export interface CertificateHashDataType extends JsonObject {
 
 export type CertificateSignedStatusEnumType = GenericStatusEnumType
 
+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 EVSEType extends JsonObject {
   connectorId?: string
   id: number
@@ -158,7 +193,29 @@ export interface OCSPRequestDataType extends JsonObject {
   serialNumber: string
 }
 
+export interface ReportDataType extends JsonObject {
+  component: ComponentType
+  variable: VariableType
+  variableAttribute?: VariableAttributeType[]
+  variableCharacteristics?: VariableCharacteristicsType
+}
+
 export interface StatusInfoType extends JsonObject {
   additionalInfo?: string
   reasonCode: string
 }
+
+interface ModemType extends JsonObject {
+  iccid?: string
+  imsi?: string
+}
+
+interface VariableAttributeType extends JsonObject {
+  type?: string
+  value?: string
+}
+
+interface VariableCharacteristicsType extends JsonObject {
+  dataType: string
+  supportsMonitoring: boolean
+}
index e4edd59702103b0815b8851d0f4fe79e6df7fa9e..f3c42d4d2e964ce029a406bb57d0279aeef28edb 100644 (file)
@@ -2,16 +2,13 @@ import type { EmptyObject } from '../../EmptyObject.js'
 import type { JsonObject } from '../../JsonType.js'
 import type {
   BootReasonEnumType,
+  ChargingStationType,
   InstallCertificateUseEnumType,
   OCPP20ConnectorStatusEnumType,
   ReportBaseEnumType,
+  ReportDataType,
 } from './Common.js'
-import type {
-  ChargingStationType,
-  ComponentType,
-  OCPP20SetVariableDataType,
-  VariableType,
-} from './Variables.js'
+import type { OCPP20SetVariableDataType } from './Variables.js'
 
 export enum OCPP20IncomingRequestCommand {
   CLEAR_CACHE = 'ClearCache',
@@ -64,20 +61,3 @@ export interface OCPP20StatusNotificationRequest extends JsonObject {
   evseId: number
   timestamp: Date
 }
-
-export interface ReportDataType extends JsonObject {
-  component: ComponentType
-  variable: VariableType
-  variableAttribute?: VariableAttributeType[]
-  variableCharacteristics?: VariableCharacteristicsType
-}
-
-export interface VariableAttributeType extends JsonObject {
-  type?: string
-  value?: string
-}
-
-export interface VariableCharacteristicsType extends JsonObject {
-  dataType: string
-  supportsMonitoring: boolean
-}
index 02a52eee8ff598f7571a389126dd3bbb7a4ff5fb..9168975caea582f832ba0de4c01fdff310f3b91e 100644 (file)
@@ -1,26 +1,5 @@
 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',
-}
+import type { ComponentType, StatusInfoType } from './Common.js'
 
 export enum OCPP20OptionalVariableName {
   HeartbeatInterval = 'HeartbeatInterval',
@@ -78,20 +57,6 @@ 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
@@ -117,11 +82,6 @@ export interface VariableType extends JsonObject {
   name: VariableName
 }
 
-interface ModemType extends JsonObject {
-  iccid?: string
-  imsi?: string
-}
-
 type VariableName =
   | OCPP20OptionalVariableName
   | OCPP20RequiredVariableName