this.connectorsStatus.clear();
this.initializeConnectorsStatus();
}
- for (const connectorId of this.chargingStation.connectors.keys()) {
- if (connectorId > 0) {
- this.startConnector(connectorId);
+ if (this.chargingStation.hasEvses) {
+ for (const [evseId, evseStatus] of this.chargingStation.evses) {
+ if (evseId > 0) {
+ for (const connectorId of evseStatus.connectors.keys()) {
+ this.startConnector(connectorId);
+ }
+ }
+ }
+ } else {
+ for (const connectorId of this.chargingStation.connectors.keys()) {
+ if (connectorId > 0) {
+ this.startConnector(connectorId);
+ }
}
}
}
private stopConnectors(): void {
- for (const connectorId of this.chargingStation.connectors.keys()) {
- if (connectorId > 0) {
- this.stopConnector(connectorId);
+ if (this.chargingStation.hasEvses) {
+ for (const [evseId, evseStatus] of this.chargingStation.evses) {
+ if (evseId > 0) {
+ for (const connectorId of evseStatus.connectors.keys()) {
+ this.stopConnector(connectorId);
+ }
+ }
+ }
+ } else {
+ for (const connectorId of this.chargingStation.connectors.keys()) {
+ if (connectorId > 0) {
+ this.stopConnector(connectorId);
+ }
}
}
}
}
private initializeConnectorsStatus(): void {
- for (const connectorId of this.chargingStation.connectors.keys()) {
- if (connectorId > 0) {
- this.connectorsStatus.set(connectorId, {
- start: false,
- authorizeRequests: 0,
- acceptedAuthorizeRequests: 0,
- rejectedAuthorizeRequests: 0,
- startTransactionRequests: 0,
- acceptedStartTransactionRequests: 0,
- rejectedStartTransactionRequests: 0,
- stopTransactionRequests: 0,
- acceptedStopTransactionRequests: 0,
- rejectedStopTransactionRequests: 0,
- skippedConsecutiveTransactions: 0,
- skippedTransactions: 0,
- });
+ if (this.chargingStation.hasEvses) {
+ for (const [evseId, evseStatus] of this.chargingStation.evses) {
+ if (evseId > 0) {
+ for (const connectorId of evseStatus.connectors.keys()) {
+ this.connectorsStatus.set(connectorId, {
+ start: false,
+ authorizeRequests: 0,
+ acceptedAuthorizeRequests: 0,
+ rejectedAuthorizeRequests: 0,
+ startTransactionRequests: 0,
+ acceptedStartTransactionRequests: 0,
+ rejectedStartTransactionRequests: 0,
+ stopTransactionRequests: 0,
+ acceptedStopTransactionRequests: 0,
+ rejectedStopTransactionRequests: 0,
+ skippedConsecutiveTransactions: 0,
+ skippedTransactions: 0,
+ });
+ }
+ }
+ }
+ } else {
+ for (const connectorId of this.chargingStation.connectors.keys()) {
+ if (connectorId > 0) {
+ this.connectorsStatus.set(connectorId, {
+ start: false,
+ authorizeRequests: 0,
+ acceptedAuthorizeRequests: 0,
+ rejectedAuthorizeRequests: 0,
+ startTransactionRequests: 0,
+ acceptedStartTransactionRequests: 0,
+ rejectedStartTransactionRequests: 0,
+ stopTransactionRequests: 0,
+ acceptedStopTransactionRequests: 0,
+ rejectedStopTransactionRequests: 0,
+ skippedConsecutiveTransactions: 0,
+ skippedTransactions: 0,
+ });
+ }
}
}
}
if (this.hasEvses) {
let numberOfConnectors = 0;
for (const [evseId, evseStatus] of this.evses) {
- if (evseId === 0) {
- continue;
+ if (evseId > 0) {
+ numberOfConnectors += evseStatus.connectors.size;
}
- numberOfConnectors += evseStatus.connectors.size;
}
return numberOfConnectors;
}
// Initialize connectors status
if (this.hasEvses) {
for (const [evseId, evseStatus] of this.evses) {
- if (evseId === 0) {
- continue;
+ if (evseId > 0) {
+ for (const [connectorId, connectorStatus] of evseStatus.connectors) {
+ const connectorBootStatus = ChargingStationUtils.getBootConnectorStatus(
+ this,
+ connectorId,
+ connectorStatus
+ );
+ await OCPPServiceUtils.sendAndSetConnectorStatus(
+ this,
+ connectorId,
+ connectorBootStatus
+ );
+ }
}
- for (const [connectorId, connectorStatus] of evseStatus.connectors) {
+ }
+ } else {
+ for (const connectorId of this.connectors.keys()) {
+ if (connectorId > 0) {
const connectorBootStatus = ChargingStationUtils.getBootConnectorStatus(
this,
connectorId,
- connectorStatus
+ this.getConnectorStatus(connectorId)
);
await OCPPServiceUtils.sendAndSetConnectorStatus(this, connectorId, connectorBootStatus);
}
}
- } else {
- for (const connectorId of this.connectors.keys()) {
- if (connectorId === 0) {
- continue;
- }
- const connectorBootStatus = ChargingStationUtils.getBootConnectorStatus(
- this,
- connectorId,
- this.getConnectorStatus(connectorId)
- );
- await OCPPServiceUtils.sendAndSetConnectorStatus(this, connectorId, connectorBootStatus);
- }
}
if (this.stationInfo?.firmwareStatus === FirmwareStatus.Installing) {
await this.ocppRequestService.requestHandler<
type ChangeConfigurationResponse,
type ClearChargingProfileRequest,
type ClearChargingProfileResponse,
+ type ConnectorStatus,
ErrorType,
type GenericResponse,
GenericStatus,
);
return OCPP16Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN;
}
- const connectorStatus = chargingStation.getConnectorStatus(commandPayload.connectorId);
if (
!Utils.isNullOrUndefined(commandPayload.connectorId) &&
- Utils.isNotEmptyArray(connectorStatus?.chargingProfiles)
+ Utils.isNotEmptyArray(
+ chargingStation.getConnectorStatus(commandPayload.connectorId)?.chargingProfiles
+ )
) {
- connectorStatus.chargingProfiles = [];
+ chargingStation.getConnectorStatus(commandPayload.connectorId).chargingProfiles = [];
logger.debug(
`${chargingStation.logPrefix()} Charging profile(s) cleared on connector id ${
commandPayload.connectorId
}
if (Utils.isNullOrUndefined(commandPayload.connectorId)) {
let clearedCP = false;
- for (const connectorId of chargingStation.connectors.keys()) {
- if (
- Utils.isNotEmptyArray(chargingStation.getConnectorStatus(connectorId)?.chargingProfiles)
- ) {
- chargingStation
- .getConnectorStatus(connectorId)
- ?.chargingProfiles?.forEach((chargingProfile: OCPP16ChargingProfile, index: number) => {
+ const clearChargingProfiles = (connectorStatus: ConnectorStatus) => {
+ if (Utils.isNotEmptyArray(connectorStatus?.chargingProfiles)) {
+ connectorStatus?.chargingProfiles?.forEach(
+ (chargingProfile: OCPP16ChargingProfile, index: number) => {
let clearCurrentCP = false;
if (chargingProfile.chargingProfileId === commandPayload.id) {
clearCurrentCP = true;
);
clearedCP = true;
}
- });
+ }
+ );
+ }
+ };
+ if (chargingStation.hasEvses) {
+ for (const evseStatus of chargingStation.evses.values()) {
+ for (const connectorStatus of evseStatus.connectors.values()) {
+ clearChargingProfiles(connectorStatus);
+ }
+ }
+ } else {
+ for (const connectorId of chargingStation.connectors.keys()) {
+ clearChargingProfiles(chargingStation.getConnectorStatus(connectorId));
}
}
if (clearedCP) {