private handleRequestSetChargingProfile(
commandPayload: SetChargingProfileRequest
): SetChargingProfileResponse {
- if (!this.chargingStation.hasFeatureProfile(OCPP16SupportedFeatureProfiles.SmartCharging)) {
- logger.error(
- `${this.chargingStation.logPrefix()} Trying to set charging profile(s) without '${
- OCPP16SupportedFeatureProfiles.SmartCharging
- }' feature enabled in ${
- OCPP16StandardParametersKey.SupportedFeatureProfiles
- } in configuration`
- );
+ if (
+ !OCPP16ServiceUtils.checkFeatureProfile(
+ this.chargingStation,
+ OCPP16SupportedFeatureProfiles.SmartCharging,
+ OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE
+ )
+ ) {
return Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED;
}
if (!this.chargingStation.getConnectorStatus(commandPayload.connectorId)) {
private handleRequestClearChargingProfile(
commandPayload: ClearChargingProfileRequest
): ClearChargingProfileResponse {
- if (!this.chargingStation.hasFeatureProfile(OCPP16SupportedFeatureProfiles.SmartCharging)) {
- logger.error(
- `${this.chargingStation.logPrefix()} Trying to clear charging profile(s) without '${
- OCPP16SupportedFeatureProfiles.SmartCharging
- }' feature enabled in ${
- OCPP16StandardParametersKey.SupportedFeatureProfiles
- } in configuration`
- );
+ if (
+ !OCPP16ServiceUtils.checkFeatureProfile(
+ this.chargingStation,
+ OCPP16SupportedFeatureProfiles.SmartCharging,
+ OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE
+ )
+ ) {
return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN;
}
const connectorStatus = this.chargingStation.getConnectorStatus(commandPayload.connectorId);
commandPayload: GetDiagnosticsRequest
): Promise<GetDiagnosticsResponse> {
if (
- !this.chargingStation.hasFeatureProfile(OCPP16SupportedFeatureProfiles.FirmwareManagement)
+ !OCPP16ServiceUtils.checkFeatureProfile(
+ this.chargingStation,
+ OCPP16SupportedFeatureProfiles.FirmwareManagement,
+ OCPP16IncomingRequestCommand.GET_DIAGNOSTICS
+ )
) {
- logger.error(
- `${this.chargingStation.logPrefix()} Trying to get diagnostics without '${
- OCPP16SupportedFeatureProfiles.FirmwareManagement
- }' feature enabled in ${
- OCPP16StandardParametersKey.SupportedFeatureProfiles
- } in configuration`
- );
return Constants.OCPP_RESPONSE_EMPTY;
}
logger.debug(
private handleRequestTriggerMessage(
commandPayload: OCPP16TriggerMessageRequest
): OCPP16TriggerMessageResponse {
- if (!this.chargingStation.hasFeatureProfile(OCPP16SupportedFeatureProfiles.RemoteTrigger)) {
- logger.error(
- `${this.chargingStation.logPrefix()} Trying to remote trigger message without '${
- OCPP16SupportedFeatureProfiles.RemoteTrigger
- }' feature enabled in ${
- OCPP16StandardParametersKey.SupportedFeatureProfiles
- } in configuration`
- );
+ if (
+ !OCPP16ServiceUtils.checkFeatureProfile(
+ this.chargingStation,
+ OCPP16SupportedFeatureProfiles.RemoteTrigger,
+ OCPP16IncomingRequestCommand.TRIGGER_MESSAGE
+ )
+ ) {
return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED;
}
try {
OCPP16MeterValuePhase,
OCPP16SampledValue,
} from '../../../types/ocpp/1.6/MeterValues';
+import {
+ OCPP16IncomingRequestCommand,
+ OCPP16RequestCommand,
+} from '../../../types/ocpp/1.6/Requests';
+import {
+ OCPP16StandardParametersKey,
+ OCPP16SupportedFeatureProfiles,
+} from '../../../types/ocpp/1.6/Configuration';
import type ChargingStation from '../../ChargingStation';
import Constants from '../../../utils/Constants';
import { ErrorType } from '../../../types/ocpp/ErrorType';
import MeasurandValues from '../../../types/MeasurandValues';
-import { OCPP16RequestCommand } from '../../../types/ocpp/1.6/Requests';
import OCPPError from '../../../exception/OCPPError';
import Utils from '../../../utils/Utils';
import logger from '../../../utils/Logger';
}
}
+ public static checkFeatureProfile(
+ chargingStation: ChargingStation,
+ featureProfile: OCPP16SupportedFeatureProfiles,
+ command: OCPP16RequestCommand | OCPP16IncomingRequestCommand
+ ): boolean {
+ if (!chargingStation.hasFeatureProfile(featureProfile)) {
+ logger.warn(
+ `${chargingStation.logPrefix()} Trying to '${command}' without '${featureProfile}' feature enabled in ${
+ OCPP16StandardParametersKey.SupportedFeatureProfiles
+ } in configuration`
+ );
+ return false;
+ }
+ return true;
+ }
+
public static buildSampledValue(
sampledValueTemplate: SampledValueTemplate,
value: number,