// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
-import { parentPort } from 'node:worker_threads';
-
import type { JSONSchemaType } from 'ajv';
import { secondsToMilliseconds } from 'date-fns';
import { OCPPError } from '../../../exception';
import {
type ChangeConfigurationResponse,
+ ChargingStationEvents,
type ClearChargingProfileResponse,
ErrorType,
type GenericResponse,
type SetChargingProfileResponse,
type UnlockConnectorResponse,
} from '../../../types';
-import {
- Constants,
- buildUpdatedMessage,
- convertToInt,
- isNullOrUndefined,
- logger,
-} from '../../../utils';
+import { Constants, convertToInt, isNullOrUndefined, logger } from '../../../utils';
import { OCPPResponseService } from '../OCPPResponseService';
const moduleName = 'OCPP16ResponseService';
if (
connectorStatus?.transactionRemoteStarted === true &&
chargingStation.getAuthorizeRemoteTxRequests() === true &&
- chargingStation.getRemoteAuthorization() === true &&
+ chargingStation.stationInfo?.remoteAuthorization === true &&
connectorStatus?.idTagLocalAuthorized === false &&
connectorStatus?.idTagAuthorized === false
) {
}
if (connectorStatus?.transactionStarted === true) {
logger.error(
- `${chargingStation.logPrefix()} Trying to start a transaction on an already used connector id ${connectorId} by idTag ${connectorStatus?.transactionIdTag}}`,
+ `${chargingStation.logPrefix()} Trying to start a transaction on an already used connector id ${connectorId} by idTag ${connectorStatus?.transactionIdTag}`,
);
return;
}
for (const [id, status] of evseStatus.connectors) {
if (id !== connectorId && status?.transactionStarted === true) {
logger.error(
- `${chargingStation.logPrefix()} Trying to start a transaction on an already used evse id ${evseId} by connector id ${id} with idTag ${status?.transactionIdTag}}`,
+ `${chargingStation.logPrefix()} Trying to start a transaction on an already used evse id ${evseId} by connector id ${id} with idTag ${status?.transactionIdTag}`,
);
await this.resetConnectorOnStartTransactionError(chargingStation, connectorId);
return;
ReservationTerminationReason.TRANSACTION_STARTED,
);
}
- chargingStation.getBeginEndMeterValues() &&
+ chargingStation.stationInfo?.beginEndMeterValues &&
(await chargingStation.ocppRequestService.requestHandler<
OCPP16MeterValuesRequest,
OCPP16MeterValuesResponse
OCPP16ChargePointStatus.Available,
);
}
- parentPort?.postMessage(buildUpdatedMessage(chargingStation));
+ chargingStation.emit(ChargingStationEvents.updated);
}
private async handleResponseStopTransaction(
);
return;
}
- chargingStation.getBeginEndMeterValues() === true &&
- chargingStation.getOcppStrictCompliance() === false &&
- chargingStation.getOutOfOrderEndMeterValues() === true &&
+ chargingStation.stationInfo?.beginEndMeterValues === true &&
+ chargingStation.stationInfo?.ocppStrictCompliance === false &&
+ chargingStation.stationInfo?.outOfOrderEndMeterValues === true &&
(await chargingStation.ocppRequestService.requestHandler<
OCPP16MeterValuesRequest,
OCPP16MeterValuesResponse
}
resetConnectorStatus(chargingStation.getConnectorStatus(transactionConnectorId!)!);
chargingStation.stopMeterValues(transactionConnectorId!);
- parentPort?.postMessage(buildUpdatedMessage(chargingStation));
+ chargingStation.emit(ChargingStationEvents.updated);
const logMsg = `${chargingStation.logPrefix()} Transaction with id ${
requestPayload.transactionId
} STOPPED on ${
chargingStation.stationInfo.chargingStationId
- }#${transactionConnectorId} with status '${payload.idTagInfo?.status ?? 'undefined'}'`;
+ }#${transactionConnectorId} with status '${payload.idTagInfo?.status}'`;
if (
isNullOrUndefined(payload.idTagInfo) ||
payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED