}
const templateMaxConnectors = this._getTemplateMaxNumberOfConnectors();
if (templateMaxConnectors <= 0) {
- logger.warn(`${this._logPrefix()} Charging station template ${this._stationTemplateFile} with no connector configurations`);
+ logger.warn(`${this._logPrefix()} Charging station template ${this._stationTemplateFile} with no connector configuration`);
+ }
+ if (!this._stationInfo.Connectors[0]) {
+ logger.warn(`${this._logPrefix()} Charging station template ${this._stationTemplateFile} with no connector Id 0 configuration`);
}
// Sanity check
if (maxConnectors > (this._stationInfo.Connectors[0] ? templateMaxConnectors - 1 : templateMaxConnectors) && !this._stationInfo.randomConnectors) {
// Add connector Id 0
let lastConnector = '0';
for (lastConnector in this._stationInfo.Connectors) {
- if (Utils.convertToInt(lastConnector) === 0 && this._stationInfo.useConnectorId0 && this._stationInfo.Connectors[lastConnector]) {
+ if (Utils.convertToInt(lastConnector) === 0 && this._getUseConnectorId0() && this._stationInfo.Connectors[lastConnector]) {
this._connectors[lastConnector] = Utils.cloneObject(this._stationInfo.Connectors[lastConnector]) as Connector;
}
}
delete this._stationInfo.Connectors;
// Initialize transaction attributes on connectors
for (const connector in this._connectors) {
- if (!this.getConnector(Utils.convertToInt(connector)).transactionStarted) {
+ if (Utils.convertToInt(connector) > 0 && !this.getConnector(Utils.convertToInt(connector)).transactionStarted) {
this._initTransactionOnConnector(Utils.convertToInt(connector));
}
}
return this._stationInfo.authorizationFile && this._stationInfo.authorizationFile;
}
+ _getUseConnectorId0(): boolean {
+ return !Utils.isUndefined(this._stationInfo.useConnectorId0) ? this._stationInfo.useConnectorId0 : true;
+ }
+
_loadAndGetAuthorizedTags(): string[] {
let authorizedTags: string[] = [];
const authorizationFile = this._getAuthorizationFile();
_getNumberOfRunningTransactions(): number {
let trxCount = 0;
for (const connector in this._connectors) {
- if (this.getConnector(Utils.convertToInt(connector)).transactionStarted) {
+ if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector)).transactionStarted) {
trxCount++;
}
}
_getTransactionIdTag(transactionId: number): string {
for (const connector in this._connectors) {
- if (this.getConnector(Utils.convertToInt(connector)).transactionId === transactionId) {
+ if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector)).transactionId === transactionId) {
return this.getConnector(Utils.convertToInt(connector)).idTag;
}
}
_getTransactionMeterStop(transactionId: number): number {
for (const connector in this._connectors) {
- if (this.getConnector(Utils.convertToInt(connector)).transactionId === transactionId) {
+ if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector)).transactionId === transactionId) {
return this.getConnector(Utils.convertToInt(connector)).lastEnergyActiveImportRegisterValue;
}
}
this._startHeartbeat();
// Initialize connectors status
for (const connector in this._connectors) {
- if (!this._hasStopped && !this.getConnector(Utils.convertToInt(connector)).status && this.getConnector(Utils.convertToInt(connector)).bootStatus) {
+ if (Utils.convertToInt(connector) === 0) {
+ continue;
+ } else if (!this._hasStopped && !this.getConnector(Utils.convertToInt(connector)).status && this.getConnector(Utils.convertToInt(connector)).bootStatus) {
// Send status in template at startup
await this.sendStatusNotification(Utils.convertToInt(connector), this.getConnector(Utils.convertToInt(connector)).bootStatus);
} else if (this._hasStopped && this.getConnector(Utils.convertToInt(connector)).bootStatus) {
await this._automaticTransactionGeneration.stop(reason);
} else {
for (const connector in this._connectors) {
- if (this.getConnector(Utils.convertToInt(connector)).transactionStarted) {
+ if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector)).transactionStarted) {
await this.sendStopTransaction(this.getConnector(Utils.convertToInt(connector)).transactionId, reason);
}
}
async stop(reason: StopTransactionReason = StopTransactionReason.NONE): Promise<void> {
// Stop message sequence
await this._stopMessageSequence(reason);
- // eslint-disable-next-line guard-for-in
for (const connector in this._connectors) {
- await this.sendStatusNotification(Utils.convertToInt(connector), ChargePointStatus.UNAVAILABLE);
+ if (Utils.convertToInt(connector) > 0) {
+ await this.sendStatusNotification(Utils.convertToInt(connector), ChargePointStatus.UNAVAILABLE);
+ }
}
if (this._wsConnection?.readyState === WebSocket.OPEN) {
this._wsConnection.close();
...!Utils.isUndefined(meterValuesTemplate[index].value) ? { value: meterValuesTemplate[index].value } : { value: voltageMeasurandValue.toString() },
});
for (let phase = 1; self._getNumberOfPhases() === 3 && phase <= self._getNumberOfPhases(); phase++) {
- const voltageValue = Utils.convertToFloat(meterValue.sampledValue[meterValue.sampledValue.length - 1].value);
let phaseValue: string;
- if (voltageValue >= 0 && voltageValue <= 250) {
+ if (self._getVoltageOut() >= 0 && self._getVoltageOut() <= 250) {
phaseValue = `L${phase}-N`;
- } else if (voltageValue > 250) {
+ } else if (self._getVoltageOut() > 250) {
phaseValue = `L${phase}-L${(phase + 1) % self._getNumberOfPhases() !== 0 ? (phase + 1) % self._getNumberOfPhases() : self._getNumberOfPhases()}`;
}
meterValue.sampledValue.push({
let transactionConnectorId: number;
for (const connector in this._connectors) {
- if (Utils.convertToInt(connector) === connectorId) {
+ if (Utils.convertToInt(connector) > 0 && Utils.convertToInt(connector) === connectorId) {
transactionConnectorId = Utils.convertToInt(connector);
break;
}
handleResponseStopTransaction(payload: StopTransactionResponse, requestPayload: StopTransactionRequest): void {
let transactionConnectorId: number;
for (const connector in this._connectors) {
- if (this.getConnector(Utils.convertToInt(connector)).transactionId === Utils.convertToInt(requestPayload.transactionId)) {
+ if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector)).transactionId === Utils.convertToInt(requestPayload.transactionId)) {
transactionConnectorId = Utils.convertToInt(connector);
break;
}
async handleRequestRemoteStopTransaction(commandPayload: RemoteStopTransactionRequest): Promise<DefaultResponse> {
const transactionId = Utils.convertToInt(commandPayload.transactionId);
for (const connector in this._connectors) {
- if (this.getConnector(Utils.convertToInt(connector)).transactionId === transactionId) {
+ if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector)).transactionId === transactionId) {
await this.sendStopTransaction(transactionId);
return Constants.OCPP_RESPONSE_ACCEPTED;
}