Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 51 additions & 50 deletions README.md

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions src/assets/station-templates/chargex.station-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"authorizationFile": "authorization-tags.json",
"baseName": "CS-CHARGEX",
"chargePointModel": "Aqueduct 1.0",
"chargePointVendor": "ChargeX GmbH",
"firmwareVersion": "MCC 1.2.0; SCC [0.12.0, 0.13.0]",
"power": 22080,
"powerUnit": "W",
"numberOfConnectors": 1,
"voltageOut": 230,
"beginEndMeterValues": true,
"outOfOrderEndMeterValues": true,
"commandsSupport": {
"incomingCommands": {
"Authorize": true,
"Reset": true,
"GetConfiguration": true,
"ChangeConfiguration": true,
"ClearCache": true,
"ChangeAvailability": false,
"UnlockConnector": true,
"SetChargingProfile": false,
"ClearChargingProfile": false,
"RemoteStartTransaction": true,
"RemoteStopTransaction": true,
"GetDiagnostics": false,
"TriggerMessage": false
}
},
"Configuration": {
"configurationKey": [
{
"key": "AllowOfflineTxForUnknownId",
"value": "True"
},
{
"key": "AuthorizeRemoteTxRequests",
"value": "True",
"readonly": true
},
{
"key": "LocalAuthListEnabled",
"value": "False",
"readonly": true
},
{
"key": "LocalPreAuthorize",
"value": "False",
"readonly": true
},
{
"key": "MeterValueSampleInterval",
"value": "300"
},
{
"key": "TransactionMessageAttempts",
"value": "3"
},
{
"key": "TransactionMessageRetryInterval",
"value": "20"
}
]
},
"AutomaticTransactionGenerator": {
"enable": false,
"minDuration": 60,
"maxDuration": 80,
"minDelayBetweenTwoTransactions": 15,
"maxDelayBetweenTwoTransactions": 30,
"probabilityOfStart": 1,
"stopAfterHours": 0.3,
"stopOnConnectionFailure": false,
"requireAuthorize": true
},
"Connectors": {
"0": {},
"1": {
"MeterValues": [
{
"unit": "Wh"
}
]
}
}
}
28 changes: 27 additions & 1 deletion src/charging-station/ChargingStationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import { ChargingProfileKindType, RecurrencyKindType } from '../types/ocpp/1.6/C
import { ChargingProfile, ChargingSchedulePeriod } from '../types/ocpp/ChargingProfile';
import { StandardParametersKey } from '../types/ocpp/Configuration';
import { MeterValueMeasurand, MeterValuePhase } from '../types/ocpp/MeterValues';
import { BootNotificationRequest } from '../types/ocpp/Requests';
import {
BootNotificationRequest,
IncomingRequestCommand,
RequestCommand,
} from '../types/ocpp/Requests';
import { WebSocketCloseEventStatusString } from '../types/WebSocket';
import { WorkerProcessType } from '../types/Worker';
import Configuration from '../utils/Configuration';
Expand Down Expand Up @@ -530,6 +534,28 @@ export class ChargingStationUtils {
);
}

public static isCommandSupported(
command: RequestCommand | IncomingRequestCommand,
stationInfo: ChargingStationInfo
): boolean {
if (
Object.values(IncomingRequestCommand).includes(command as IncomingRequestCommand) &&
!stationInfo?.commandsSupport?.incomingCommands
) {
return true;
}
if (
Object.values(RequestCommand).includes(command as RequestCommand) &&
!stationInfo?.commandsSupport?.outgoingCommands
) {
return true;
}
return (
((stationInfo?.commandsSupport?.incomingCommands[command] as boolean) ?? false) ||
((stationInfo?.commandsSupport?.outgoingCommands[command] as boolean) ?? false)
);
}

private static getRandomSerialNumberSuffix(params?: {
randomBytesLength?: number;
upperCase?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
chargingStation.isRegistered() ||
(!chargingStation.getOcppStrictCompliance() && chargingStation.isInUnknownState())
) {
if (this.incomingRequestHandlers.has(commandName)) {
if (
this.incomingRequestHandlers.has(commandName) &&
ChargingStationUtils.isCommandSupported(commandName, chargingStation.stationInfo)
) {
try {
// Call the method to build the response
response = await this.incomingRequestHandlers.get(commandName)(
Expand Down
6 changes: 5 additions & 1 deletion src/charging-station/ocpp/1.6/OCPP16RequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { RequestParams } from '../../../types/ocpp/Requests';
import Constants from '../../../utils/Constants';
import Utils from '../../../utils/Utils';
import type ChargingStation from '../../ChargingStation';
import { ChargingStationUtils } from '../../ChargingStationUtils';
import OCPPRequestService from '../OCPPRequestService';
import type OCPPResponseService from '../OCPPResponseService';
import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
Expand All @@ -28,7 +29,10 @@ export default class OCPP16RequestService extends OCPPRequestService {
commandParams?: JsonType,
params?: RequestParams
): Promise<Response> {
if (Object.values(OCPP16RequestCommand).includes(commandName)) {
if (
Object.values(OCPP16RequestCommand).includes(commandName) &&
ChargingStationUtils.isCommandSupported(commandName, chargingStation.stationInfo)
) {
return (await this.sendMessage(
chargingStation,
Utils.generateUUID(),
Expand Down
6 changes: 5 additions & 1 deletion src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import logger from '../../../utils/Logger';
import Utils from '../../../utils/Utils';
import type ChargingStation from '../../ChargingStation';
import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils';
import { ChargingStationUtils } from '../../ChargingStationUtils';
import OCPPResponseService from '../OCPPResponseService';
import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';

Expand Down Expand Up @@ -65,7 +66,10 @@ export default class OCPP16ResponseService extends OCPPResponseService {
requestPayload: JsonType
): Promise<void> {
if (chargingStation.isRegistered() || commandName === OCPP16RequestCommand.BOOT_NOTIFICATION) {
if (this.responseHandlers.has(commandName)) {
if (
this.responseHandlers.has(commandName) &&
ChargingStationUtils.isCommandSupported(commandName, chargingStation.stationInfo)
) {
try {
await this.responseHandlers.get(commandName)(chargingStation, payload, requestPayload);
} catch (error) {
Expand Down
7 changes: 7 additions & 0 deletions src/types/ChargingStationTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ChargingStationOcppConfiguration from './ChargingStationOcppConfiguration
import { ConnectorStatus } from './ConnectorStatus';
import { OCPPProtocol } from './ocpp/OCPPProtocol';
import { OCPPVersion } from './ocpp/OCPPVersion';
import { IncomingRequestCommand, RequestCommand } from './ocpp/Requests';

export enum CurrentType {
AC = 'AC',
Expand Down Expand Up @@ -34,6 +35,11 @@ export enum Voltage {

export type WsOptions = ClientOptions & ClientRequestArgs;

interface CommandsSupport {
incomingCommands: Record<IncomingRequestCommand, boolean>;
outgoingCommands?: Record<RequestCommand, boolean>;
}

export default interface ChargingStationTemplate {
templateHash?: string;
supervisionUrls?: string | string[];
Expand Down Expand Up @@ -85,6 +91,7 @@ export default interface ChargingStationTemplate {
mainVoltageMeterValues?: boolean;
phaseLineToLineVoltageMeterValues?: boolean;
customValueLimitationMeterValues?: boolean;
commandsSupport?: CommandsSupport;
Configuration?: ChargingStationOcppConfiguration;
AutomaticTransactionGenerator?: AutomaticTransactionGeneratorConfiguration;
Connectors: Record<string, ConnectorStatus>;
Expand Down