+ this.connectorsStatus.get(connectorId)!.start = true;
+ }
+
+ private canStartConnector(connectorId: number): boolean {
+ if (new Date() > this.connectorsStatus.get(connectorId)!.stopDate!) {
+ return false;
+ }
+ if (this.chargingStation.inAcceptedState() === false) {
+ logger.error(
+ `${this.logPrefix(
+ connectorId,
+ )} entered in transaction loop while the charging station is not in accepted state`,
+ );
+ return false;
+ }
+ if (this.chargingStation.isChargingStationAvailable() === false) {
+ logger.info(
+ `${this.logPrefix(
+ connectorId,
+ )} entered in transaction loop while the charging station is unavailable`,
+ );
+ return false;
+ }
+ if (this.chargingStation.isConnectorAvailable(connectorId) === false) {
+ logger.info(
+ `${this.logPrefix(
+ connectorId,
+ )} entered in transaction loop while the connector ${connectorId} is unavailable`,
+ );
+ return false;
+ }
+ return true;
+ }
+
+ private async waitChargingStationServiceInitialization(connectorId: number): Promise<void> {
+ let logged = false;
+ while (!this.chargingStation?.ocppRequestService) {
+ if (!logged) {
+ logger.info(
+ `${this.logPrefix(
+ connectorId,
+ )} transaction loop waiting for charging station service to be initialized`,
+ );
+ logged = true;
+ }
+ await sleep(Constants.CHARGING_STATION_ATG_INITIALIZATION_TIME);
+ }
+ }
+
+ private async waitChargingStationAvailable(connectorId: number): Promise<void> {
+ let logged = false;
+ while (!this.chargingStation.isChargingStationAvailable()) {
+ if (!logged) {
+ logger.info(
+ `${this.logPrefix(
+ connectorId,
+ )} transaction loop waiting for charging station to be available`,
+ );
+ logged = true;
+ }
+ await sleep(Constants.CHARGING_STATION_ATG_AVAILABILITY_TIME);
+ }
+ }
+
+ private async waitConnectorAvailable(connectorId: number): Promise<void> {
+ let logged = false;
+ while (!this.chargingStation.isConnectorAvailable(connectorId)) {
+ if (!logged) {
+ logger.info(
+ `${this.logPrefix(
+ connectorId,
+ )} transaction loop waiting for connector ${connectorId} to be available`,
+ );
+ logged = true;
+ }
+ await sleep(Constants.CHARGING_STATION_ATG_AVAILABILITY_TIME);
+ }