import {
type ChargingStation,
ChargingStationConfigurationUtils,
- ChargingStationUtils,
- MessageChannelUtils,
+ resetConnectorStatus,
} from '../../../charging-station';
import { OCPPError } from '../../../exception';
import {
type OCPP16MeterValuesRequest,
type OCPP16MeterValuesResponse,
OCPP16RequestCommand,
+ type OCPP16ReserveNowResponse,
OCPP16StandardParametersKey,
type OCPP16StartTransactionRequest,
type OCPP16StartTransactionResponse,
type SetChargingProfileResponse,
type UnlockConnectorResponse,
} from '../../../types';
-import { Constants, Utils, logger } from '../../../utils';
+import {
+ Constants,
+ buildUpdatedMessage,
+ convertToInt,
+ isNullOrUndefined,
+ logger,
+} from '../../../utils';
import { OCPPResponseService } from '../OCPPResponseService';
const moduleName = 'OCPP16ResponseService';
[
OCPP16RequestCommand.BOOT_NOTIFICATION,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16BootNotificationResponse>(
- '../../../assets/json-schemas/ocpp/1.6/BootNotificationResponse.json',
+ 'assets/json-schemas/ocpp/1.6/BootNotificationResponse.json',
moduleName,
'constructor'
),
[
OCPP16RequestCommand.HEARTBEAT,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16HeartbeatResponse>(
- '../../../assets/json-schemas/ocpp/1.6/HeartbeatResponse.json',
+ 'assets/json-schemas/ocpp/1.6/HeartbeatResponse.json',
moduleName,
'constructor'
),
[
OCPP16RequestCommand.AUTHORIZE,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16AuthorizeResponse>(
- '../../../assets/json-schemas/ocpp/1.6/AuthorizeResponse.json',
+ 'assets/json-schemas/ocpp/1.6/AuthorizeResponse.json',
moduleName,
'constructor'
),
[
OCPP16RequestCommand.START_TRANSACTION,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StartTransactionResponse>(
- '../../../assets/json-schemas/ocpp/1.6/StartTransactionResponse.json',
+ 'assets/json-schemas/ocpp/1.6/StartTransactionResponse.json',
moduleName,
'constructor'
),
[
OCPP16RequestCommand.STOP_TRANSACTION,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StopTransactionResponse>(
- '../../../assets/json-schemas/ocpp/1.6/StopTransactionResponse.json',
+ 'assets/json-schemas/ocpp/1.6/StopTransactionResponse.json',
moduleName,
'constructor'
),
[
OCPP16RequestCommand.STATUS_NOTIFICATION,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StatusNotificationResponse>(
- '../../../assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json',
+ 'assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json',
moduleName,
'constructor'
),
[
OCPP16RequestCommand.METER_VALUES,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16MeterValuesResponse>(
- '../../../assets/json-schemas/ocpp/1.6/MeterValuesResponse.json',
+ 'assets/json-schemas/ocpp/1.6/MeterValuesResponse.json',
moduleName,
'constructor'
),
[
OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DiagnosticsStatusNotificationResponse>(
- '../../../assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json',
+ 'assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json',
moduleName,
'constructor'
),
[
OCPP16RequestCommand.DATA_TRANSFER,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DataTransferResponse>(
- '../../../assets/json-schemas/ocpp/1.6/DataTransferResponse.json',
+ 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json',
moduleName,
'constructor'
),
[
OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16FirmwareStatusNotificationResponse>(
- '../../../assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json',
+ 'assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.RESET,
OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
- '../../../assets/json-schemas/ocpp/1.6/ResetResponse.json',
+ 'assets/json-schemas/ocpp/1.6/ResetResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.CLEAR_CACHE,
OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
- '../../../assets/json-schemas/ocpp/1.6/ClearCacheResponse.json',
+ 'assets/json-schemas/ocpp/1.6/ClearCacheResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
OCPP16ServiceUtils.parseJsonSchemaFile<ChangeAvailabilityResponse>(
- '../../../assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json',
+ 'assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
OCPP16ServiceUtils.parseJsonSchemaFile<UnlockConnectorResponse>(
- '../../../assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json',
+ 'assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.GET_CONFIGURATION,
OCPP16ServiceUtils.parseJsonSchemaFile<GetConfigurationResponse>(
- '../../../assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json',
+ 'assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
OCPP16ServiceUtils.parseJsonSchemaFile<ChangeConfigurationResponse>(
- '../../../assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json',
+ 'assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16GetCompositeScheduleResponse>(
- '../../../assets/json-schemas/ocpp/1.6/GetCompositeScheduleResponse.json',
+ 'assets/json-schemas/ocpp/1.6/GetCompositeScheduleResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
OCPP16ServiceUtils.parseJsonSchemaFile<SetChargingProfileResponse>(
- '../../../assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json',
+ 'assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
OCPP16ServiceUtils.parseJsonSchemaFile<ClearChargingProfileResponse>(
- '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json',
+ 'assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
- '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json',
+ 'assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
- '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json',
+ 'assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
OCPP16ServiceUtils.parseJsonSchemaFile<GetDiagnosticsResponse>(
- '../../../assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json',
+ 'assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16TriggerMessageResponse>(
- '../../../assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json',
+ 'assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.DATA_TRANSFER,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DataTransferResponse>(
- '../../../assets/json-schemas/ocpp/1.6/DataTransferResponse.json',
+ 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json',
moduleName,
'constructor'
),
[
OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16UpdateFirmwareResponse>(
- '../../../assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json',
+ 'assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json',
+ moduleName,
+ 'constructor'
+ ),
+ ],
+ [
+ OCPP16IncomingRequestCommand.RESERVE_NOW,
+ OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16ReserveNowResponse>(
+ 'assets/json-schemas/ocpp/1.6/ReserveNowResponse.json',
+ moduleName,
+ 'constructor'
+ ),
+ ],
+ [
+ OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
+ OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
+ 'assets/json-schemas/ocpp/1.6/CancelReservationResponse.json',
moduleName,
'constructor'
),
}
}
}
- const authorizeConnectorIdDefined = !Utils.isNullOrUndefined(authorizeConnectorId);
+ const authorizeConnectorIdDefined = !isNullOrUndefined(authorizeConnectorId);
if (payload.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED) {
authorizeConnectorIdDefined &&
(chargingStation.getConnectorStatus(authorizeConnectorId).idTagAuthorized = true);
payload.transactionId
}, converting to integer`
);
- payload.transactionId = Utils.convertToInt(payload.transactionId);
+ payload.transactionId = convertToInt(payload.transactionId);
}
if (payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) {
}#${transactionConnectorId.toString()} for idTag '${requestPayload.idTag}'`
);
if (chargingStation.stationInfo.powerSharedByConnectors) {
- chargingStation.powerDivider++;
+ ++chargingStation.powerDivider;
}
const configuredMeterValueSampleInterval =
ChargingStationConfigurationUtils.getConfigurationKey(
chargingStation.startMeterValues(
transactionConnectorId,
configuredMeterValueSampleInterval
- ? Utils.convertToInt(configuredMeterValueSampleInterval.value) * 1000
+ ? convertToInt(configuredMeterValueSampleInterval.value) * 1000
: Constants.DEFAULT_METER_VALUES_INTERVAL
);
} else {
chargingStation: ChargingStation,
connectorId: number
): Promise<void> {
- ChargingStationUtils.resetConnectorStatus(chargingStation.getConnectorStatus(connectorId));
+ resetConnectorStatus(chargingStation.getConnectorStatus(connectorId));
chargingStation.stopMeterValues(connectorId);
- parentPort?.postMessage(MessageChannelUtils.buildUpdatedMessage(chargingStation));
+ parentPort?.postMessage(buildUpdatedMessage(chargingStation));
if (
chargingStation.getConnectorStatus(connectorId)?.status !== OCPP16ChargePointStatus.Available
) {
const transactionConnectorId = chargingStation.getConnectorIdByTransactionId(
requestPayload.transactionId
);
- if (Utils.isNullOrUndefined(transactionConnectorId)) {
+ if (isNullOrUndefined(transactionConnectorId)) {
logger.error(
`${chargingStation.logPrefix()} Trying to stop a non existing transaction with id ${requestPayload.transactionId.toString()}`
);
if (chargingStation.stationInfo.powerSharedByConnectors) {
chargingStation.powerDivider--;
}
- ChargingStationUtils.resetConnectorStatus(
- chargingStation.getConnectorStatus(transactionConnectorId)
- );
+ resetConnectorStatus(chargingStation.getConnectorStatus(transactionConnectorId));
chargingStation.stopMeterValues(transactionConnectorId);
- parentPort?.postMessage(MessageChannelUtils.buildUpdatedMessage(chargingStation));
+ parentPort?.postMessage(buildUpdatedMessage(chargingStation));
const logMsg = `${chargingStation.logPrefix()} Transaction with id ${requestPayload.transactionId.toString()} STOPPED on ${
chargingStation.stationInfo.chargingStationId
}#${transactionConnectorId?.toString()} with status '${
payload.idTagInfo?.status ?? 'undefined'
}'`;
if (
- Utils.isNullOrUndefined(payload.idTagInfo) ||
+ isNullOrUndefined(payload.idTagInfo) ||
payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED
) {
logger.info(logMsg);