From: Jérôme Benoit Date: Tue, 29 Mar 2022 08:54:20 +0000 (+0200) Subject: Enforce SupportedFeatureProfiles check on some OCPP commands X-Git-Tag: v1.1.57~22 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=68cb8b91bd7ff2293557878c8898c89c323d2a6e;p=e-mobility-charging-stations-simulator.git Enforce SupportedFeatureProfiles check on some OCPP commands Signed-off-by: Jérôme Benoit --- diff --git a/README.md b/README.md index aa55b804..1be60673 100644 --- a/README.md +++ b/README.md @@ -298,7 +298,7 @@ make SUBMODULES_INIT=true #### Smart Charging Profile - :white_check_mark: ClearChargingProfile -- :white_check_mark: GetCompositeSchedule +- :x: GetCompositeSchedule - :white_check_mark: SetChargingProfile #### Remote Trigger Profile diff --git a/src/assets/station-templates/abb-atg.station-template.json b/src/assets/station-templates/abb-atg.station-template.json index f4c3c52b..8deb8d6f 100644 --- a/src/assets/station-templates/abb-atg.station-template.json +++ b/src/assets/station-templates/abb-atg.station-template.json @@ -28,7 +28,7 @@ { "key": "SupportedFeatureProfiles", "readonly": true, - "value": "Core,LocalAuthListManagement" + "value": "Core,FirmwareManagement,LocalAuthListManagement,SmartCharging,RemoteTrigger" }, { "key": "LocalAuthListEnabled", diff --git a/src/assets/station-templates/abb.station-template.json b/src/assets/station-templates/abb.station-template.json index 93b59b62..81f2d099 100644 --- a/src/assets/station-templates/abb.station-template.json +++ b/src/assets/station-templates/abb.station-template.json @@ -28,7 +28,7 @@ { "key": "SupportedFeatureProfiles", "readonly": true, - "value": "Core,LocalAuthListManagement" + "value": "Core,FirmwareManagement,LocalAuthListManagement,SmartCharging,RemoteTrigger" }, { "key": "LocalAuthListEnabled", diff --git a/src/assets/station-templates/evlink.station-template.json b/src/assets/station-templates/evlink.station-template.json index b96f1ae0..fbaa37e1 100644 --- a/src/assets/station-templates/evlink.station-template.json +++ b/src/assets/station-templates/evlink.station-template.json @@ -19,7 +19,7 @@ { "key": "MeterValuesSampledData", "readonly": false, - "value": "Energy.Active.Import.Register" + "value": "Energy.Active.Import.Register,Current.Import,Voltage" }, { "key": "MeterValueSampleInterval", @@ -29,7 +29,7 @@ { "key": "SupportedFeatureProfiles", "readonly": true, - "value": "Core,LocalAuthListManagement" + "value": "Core,FirmwareManagement,LocalAuthListManagement,SmartCharging,RemoteTrigger" }, { "key": "LocalAuthListEnabled", diff --git a/src/assets/station-templates/keba.station-template.json b/src/assets/station-templates/keba.station-template.json index 3bc060b5..a76741d9 100644 --- a/src/assets/station-templates/keba.station-template.json +++ b/src/assets/station-templates/keba.station-template.json @@ -25,7 +25,7 @@ { "key": "SupportedFeatureProfiles", "readonly": true, - "value": "Core,LocalAuthListManagement" + "value": "Core,FirmwareManagement,LocalAuthListManagement,SmartCharging,RemoteTrigger" }, { "key": "LocalAuthListEnabled", diff --git a/src/assets/station-templates/schneider-imredd.station-template.json b/src/assets/station-templates/schneider-imredd.station-template.json index 34bba08f..63ee8c01 100644 --- a/src/assets/station-templates/schneider-imredd.station-template.json +++ b/src/assets/station-templates/schneider-imredd.station-template.json @@ -18,7 +18,7 @@ { "key": "MeterValuesSampledData", "readonly": false, - "value": "Energy.Active.Import.Register" + "value": "Energy.Active.Import.Register,Current.Import,Voltage" }, { "key": "MeterValueSampleInterval", @@ -28,7 +28,7 @@ { "key": "SupportedFeatureProfiles", "readonly": true, - "value": "Core,LocalAuthListManagement" + "value": "Core,FirmwareManagement,LocalAuthListManagement,SmartCharging,RemoteTrigger" }, { "key": "LocalAuthListEnabled", diff --git a/src/assets/station-templates/schneider.station-template.json b/src/assets/station-templates/schneider.station-template.json index 17e20518..2482a439 100644 --- a/src/assets/station-templates/schneider.station-template.json +++ b/src/assets/station-templates/schneider.station-template.json @@ -28,7 +28,7 @@ { "key": "SupportedFeatureProfiles", "readonly": true, - "value": "Core,LocalAuthListManagement" + "value": "Core,FirmwareManagement,LocalAuthListManagement,SmartCharging,RemoteTrigger" }, { "key": "LocalAuthListEnabled", diff --git a/src/assets/station-templates/virtual-simple-atg.station-template.json b/src/assets/station-templates/virtual-simple-atg.station-template.json index 79d0cb4b..666be37b 100644 --- a/src/assets/station-templates/virtual-simple-atg.station-template.json +++ b/src/assets/station-templates/virtual-simple-atg.station-template.json @@ -14,7 +14,7 @@ { "key": "MeterValuesSampledData", "readonly": false, - "value": "SoC,Energy.Active.Import.Register" + "value": "SoC,Energy.Active.Import.Register,Voltage" }, { "key": "MeterValueSampleInterval", @@ -24,7 +24,7 @@ { "key": "SupportedFeatureProfiles", "readonly": true, - "value": "Core,LocalAuthListManagement" + "value": "Core,FirmwareManagement,LocalAuthListManagement,SmartCharging,RemoteTrigger" }, { "key": "LocalAuthListEnabled", diff --git a/src/assets/station-templates/virtual-simple.station-template.json b/src/assets/station-templates/virtual-simple.station-template.json index d3939c8e..ccec3ee5 100644 --- a/src/assets/station-templates/virtual-simple.station-template.json +++ b/src/assets/station-templates/virtual-simple.station-template.json @@ -24,7 +24,7 @@ { "key": "SupportedFeatureProfiles", "readonly": true, - "value": "Core,LocalAuthListManagement" + "value": "Core,FirmwareManagement,LocalAuthListManagement,SmartCharging,RemoteTrigger" }, { "key": "LocalAuthListEnabled", diff --git a/src/assets/station-templates/virtual.station-template.json b/src/assets/station-templates/virtual.station-template.json index d330a85c..1ecf8875 100644 --- a/src/assets/station-templates/virtual.station-template.json +++ b/src/assets/station-templates/virtual.station-template.json @@ -24,7 +24,7 @@ { "key": "SupportedFeatureProfiles", "readonly": true, - "value": "Core,LocalAuthListManagement" + "value": "Core,FirmwareManagement,LocalAuthListManagement,SmartCharging,RemoteTrigger" }, { "key": "LocalAuthListEnabled", diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index bceba844..bf7943f5 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -369,7 +369,7 @@ export default class ChargingStation { } if ( measurand !== MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER && - !this.getConfigurationKey(StandardParametersKey.MeterValuesSampledData).value.includes( + !this.getConfigurationKey(StandardParametersKey.MeterValuesSampledData)?.value.includes( measurand ) ) { @@ -400,7 +400,7 @@ export default class ChargingStation { phase && sampledValueTemplates[index]?.phase === phase && sampledValueTemplates[index]?.measurand === measurand && - this.getConfigurationKey(StandardParametersKey.MeterValuesSampledData).value.includes( + this.getConfigurationKey(StandardParametersKey.MeterValuesSampledData)?.value.includes( measurand ) ) { @@ -409,7 +409,7 @@ export default class ChargingStation { !phase && !sampledValueTemplates[index].phase && sampledValueTemplates[index]?.measurand === measurand && - this.getConfigurationKey(StandardParametersKey.MeterValuesSampledData).value.includes( + this.getConfigurationKey(StandardParametersKey.MeterValuesSampledData)?.value.includes( measurand ) ) { @@ -837,6 +837,12 @@ export default class ChargingStation { this.stopMeterValues(connectorId); } + public hasFeatureProfile(featureProfile: SupportedFeatureProfiles) { + return this.getConfigurationKey(StandardParametersKey.SupportedFeatureProfiles)?.value.includes( + featureProfile + ); + } + public bufferMessage(message: string): void { this.messageBuffer.add(message); } @@ -1230,7 +1236,7 @@ export default class ChargingStation { if (!this.getConfigurationKey(StandardParametersKey.SupportedFeatureProfiles)) { this.addConfigurationKey( StandardParametersKey.SupportedFeatureProfiles, - `${SupportedFeatureProfiles.Core},${SupportedFeatureProfiles.Local_Auth_List_Management},${SupportedFeatureProfiles.Smart_Charging}` + `${SupportedFeatureProfiles.Core},${SupportedFeatureProfiles.Firmware_Management},${SupportedFeatureProfiles.Local_Auth_List_Management},${SupportedFeatureProfiles.Smart_Charging},${SupportedFeatureProfiles.Remote_Trigger}` ); } this.addConfigurationKey( @@ -1270,7 +1276,7 @@ export default class ChargingStation { } if ( !this.getConfigurationKey(StandardParametersKey.LocalAuthListEnabled) && - this.getConfigurationKey(StandardParametersKey.SupportedFeatureProfiles).value.includes( + this.getConfigurationKey(StandardParametersKey.SupportedFeatureProfiles)?.value.includes( SupportedFeatureProfiles.Local_Auth_List_Management ) ) { diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 7e04e6bf..a9aaab79 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -54,6 +54,10 @@ import { OCPP16MeterValuesRequest, OCPP16MeterValuesResponse, } from '../../../types/ocpp/1.6/MeterValues'; +import { + OCPP16StandardParametersKey, + OCPP16SupportedFeatureProfiles, +} from '../../../types/ocpp/1.6/Configuration'; import type ChargingStation from '../../ChargingStation'; import Constants from '../../../utils/Constants'; @@ -65,7 +69,6 @@ import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointE import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStatus'; import { OCPP16DiagnosticsStatus } from '../../../types/ocpp/1.6/DiagnosticsStatus'; import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; -import { OCPP16StandardParametersKey } from '../../../types/ocpp/1.6/Configuration'; import { OCPPConfigurationKey } from '../../../types/ocpp/Configuration'; import OCPPError from '../../../exception/OCPPError'; import OCPPIncomingRequestService from '../OCPPIncomingRequestService'; @@ -378,6 +381,16 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer private handleRequestSetChargingProfile( commandPayload: SetChargingProfileRequest ): SetChargingProfileResponse { + if (!this.chargingStation.hasFeatureProfile(OCPP16SupportedFeatureProfiles.Smart_Charging)) { + logger.error( + `${this.chargingStation.logPrefix()} Trying to set charging profile(s) without '${ + OCPP16SupportedFeatureProfiles.Smart_Charging + }' feature enabled in ${ + OCPP16StandardParametersKey.SupportedFeatureProfiles + } in configuration` + ); + return Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED; + } if (!this.chargingStation.getConnectorStatus(commandPayload.connectorId)) { logger.error( `${this.chargingStation.logPrefix()} Trying to set charging profile(s) to a non existing connector Id ${ @@ -417,6 +430,16 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer private handleRequestClearChargingProfile( commandPayload: ClearChargingProfileRequest ): ClearChargingProfileResponse { + if (!this.chargingStation.hasFeatureProfile(OCPP16SupportedFeatureProfiles.Smart_Charging)) { + logger.error( + `${this.chargingStation.logPrefix()} Trying to clear charging profile(s) without '${ + OCPP16SupportedFeatureProfiles.Smart_Charging + }' feature enabled in ${ + OCPP16StandardParametersKey.SupportedFeatureProfiles + } in configuration` + ); + return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN; + } const connectorStatus = this.chargingStation.getConnectorStatus(commandPayload.connectorId); if (!connectorStatus) { logger.error( @@ -804,6 +827,18 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer private async handleRequestGetDiagnostics( commandPayload: GetDiagnosticsRequest ): Promise { + if ( + !this.chargingStation.hasFeatureProfile(OCPP16SupportedFeatureProfiles.Firmware_Management) + ) { + logger.error( + `${this.chargingStation.logPrefix()} Trying to get diagnostics without '${ + OCPP16SupportedFeatureProfiles.Firmware_Management + }' feature enabled in ${ + OCPP16StandardParametersKey.SupportedFeatureProfiles + } in configuration` + ); + return Constants.OCPP_RESPONSE_EMPTY; + } logger.debug( this.chargingStation.logPrefix() + ' ' + @@ -911,6 +946,16 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer private handleRequestTriggerMessage( commandPayload: OCPP16TriggerMessageRequest ): OCPP16TriggerMessageResponse { + if (!this.chargingStation.hasFeatureProfile(OCPP16SupportedFeatureProfiles.Remote_Trigger)) { + logger.error( + `${this.chargingStation.logPrefix()} Trying to remote trigger message without '${ + OCPP16SupportedFeatureProfiles.Remote_Trigger + }' feature enabled in ${ + OCPP16StandardParametersKey.SupportedFeatureProfiles + } in configuration` + ); + return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED; + } try { switch (commandPayload.requestedMessage) { case MessageTrigger.BootNotification: