type ChargingStationInfo,
type ChargingStationOcppConfiguration,
type ChargingStationTemplate,
- ConnectorPhaseRotation,
type ConnectorStatus,
ConnectorStatusEnum,
CurrentType,
this.initialize();
}
+ public get hasEvses(): boolean {
+ return this.connectors.size === 0 && this.evses.size > 0;
+ }
+
private get wsConnectionUrl(): URL {
return new URL(
`${
);
}
- private get hasEvses(): boolean {
- return this.connectors.size === 0 && this.evses.size > 0;
- }
-
public logPrefix = (): string => {
return Utils.logPrefix(
` ${
return this.getConnectorStatus(0)?.availability === AvailabilityType.Operative;
}
+ public hasConnector(connectorId: number): boolean {
+ if (this.hasEvses) {
+ for (const evseStatus of this.evses.values()) {
+ if (evseStatus.connectors.has(connectorId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return this.connectors.has(connectorId);
+ }
+
public isConnectorAvailable(connectorId: number): boolean {
return (
connectorId > 0 &&
commandPayload: UnlockConnectorRequest
): Promise<UnlockConnectorResponse> {
const connectorId = commandPayload.connectorId;
- if (chargingStation.connectors.has(connectorId) === false) {
+ if (chargingStation.hasConnector(connectorId) === false) {
logger.error(
`${chargingStation.logPrefix()} Trying to unlock a non existing connector id ${connectorId.toString()}`
);
) {
return OCPP16Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED;
}
- if (chargingStation.connectors.has(commandPayload.connectorId) === false) {
+ if (chargingStation.hasConnector(commandPayload.connectorId) === false) {
logger.error(
`${chargingStation.logPrefix()} Trying to set charging profile(s) to a non existing connector id ${
commandPayload.connectorId
) {
return OCPP16Constants.OCPP_RESPONSE_REJECTED;
}
- if (chargingStation.connectors.has(commandPayload.connectorId) === false) {
+ if (chargingStation.hasConnector(commandPayload.connectorId) === false) {
logger.error(
`${chargingStation.logPrefix()} Trying to get composite schedule to a non existing connector id ${
commandPayload.connectorId
) {
return OCPP16Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN;
}
- if (chargingStation.connectors.has(commandPayload.connectorId) === false) {
+ if (chargingStation.hasConnector(commandPayload.connectorId) === false) {
logger.error(
`${chargingStation.logPrefix()} Trying to clear a charging profile(s) to a non existing connector id ${
commandPayload.connectorId
commandPayload: ChangeAvailabilityRequest
): Promise<ChangeAvailabilityResponse> {
const connectorId: number = commandPayload.connectorId;
- if (chargingStation.connectors.has(connectorId) === false) {
+ if (chargingStation.hasConnector(connectorId) === false) {
logger.error(
`${chargingStation.logPrefix()} Trying to change the availability of a non existing connector id ${connectorId.toString()}`
);
commandPayload: RemoteStartTransactionRequest
): Promise<GenericResponse> {
const transactionConnectorId = commandPayload.connectorId;
- if (chargingStation.connectors.has(transactionConnectorId) === true) {
+ if (chargingStation.hasConnector(transactionConnectorId) === true) {
const remoteStartTransactionLogMsg = `${chargingStation.logPrefix()} Transaction remotely STARTED on ${
chargingStation.stationInfo.chargingStationId
}#${transactionConnectorId.toString()} for idTag '${commandPayload.idTag}'`;