RegistrationStatusEnumType,
RequestCommand,
type Reservation,
- type ReservationFilterKey,
+ type ReservationKey,
ReservationTerminationReason,
type Response,
StandardParametersKey,
}
public getReservationBy(
- filterKey: ReservationFilterKey,
+ filterKey: ReservationKey,
value: number | string,
): Reservation | undefined {
if (this.hasEvses) {
}
}
- private restartReservationExpiryDateSetInterval(): void {
- this.stopReservationExpirationSetInterval();
- this.startReservationExpirationSetInterval();
- }
+ // private restartReservationExpiryDateSetInterval(): void {
+ // this.stopReservationExpirationSetInterval();
+ // this.startReservationExpirationSetInterval();
+ // }
private getNumberOfReservableConnectors(): number {
let reservableConnectors = 0;
} from '../../../charging-station';
import { OCPPError } from '../../../exception';
import {
- type ChangeAvailabilityRequest,
- type ChangeAvailabilityResponse,
type ChangeConfigurationRequest,
type ChangeConfigurationResponse,
type ClearChargingProfileRequest,
type ClearChargingProfileResponse,
- type ConnectorStatus,
ErrorType,
type GenericResponse,
GenericStatus,
type OCPP16BootNotificationRequest,
type OCPP16BootNotificationResponse,
type OCPP16CancelReservationRequest,
+ type OCPP16ChangeAvailabilityRequest,
+ type OCPP16ChangeAvailabilityResponse,
OCPP16ChargePointErrorCode,
OCPP16ChargePointStatus,
type OCPP16ChargingProfile,
],
[
OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
- OCPP16ServiceUtils.parseJsonSchemaFile<ChangeAvailabilityRequest>(
+ OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16ChangeAvailabilityRequest>(
'assets/json-schemas/ocpp/1.6/ChangeAvailability.json',
moduleName,
'constructor',
private async handleRequestChangeAvailability(
chargingStation: ChargingStation,
- commandPayload: ChangeAvailabilityRequest,
- ): Promise<ChangeAvailabilityResponse> {
+ commandPayload: OCPP16ChangeAvailabilityRequest,
+ ): Promise<OCPP16ChangeAvailabilityResponse> {
const connectorId: number = commandPayload.connectorId;
if (chargingStation.hasConnector(connectorId) === false) {
logger.error(
? OCPP16ChargePointStatus.Available
: OCPP16ChargePointStatus.Unavailable;
if (connectorId === 0) {
- let response: ChangeAvailabilityResponse =
- OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED;
- const changeAvailability = async (id: number, connectorStatus: ConnectorStatus) => {
- if (connectorStatus?.transactionStarted === true) {
- response = OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED;
- }
- connectorStatus.availability = commandPayload.type;
- if (response === OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED) {
- await OCPP16ServiceUtils.sendAndSetConnectorStatus(
- chargingStation,
- id,
- chargePointStatus,
- );
- }
- };
+ let response: OCPP16ChangeAvailabilityResponse;
if (chargingStation.hasEvses) {
for (const evseStatus of chargingStation.evses.values()) {
- for (const [id, connectorStatus] of evseStatus.connectors) {
- await changeAvailability(id, connectorStatus);
+ for (const id of evseStatus.connectors.keys()) {
+ response = await OCPP16ServiceUtils.changeAvailability(
+ chargingStation,
+ id,
+ chargePointStatus,
+ commandPayload.type,
+ );
}
}
} else {
for (const id of chargingStation.connectors.keys()) {
- await changeAvailability(id, chargingStation.getConnectorStatus(id)!);
+ response = await OCPP16ServiceUtils.changeAvailability(
+ chargingStation,
+ id,
+ chargePointStatus,
+ commandPayload.type,
+ );
}
}
- return response;
+ return response!;
} else if (
connectorId > 0 &&
(chargingStation.isChargingStationAvailable() === true ||
} from '../../../charging-station';
import { OCPPError } from '../../../exception';
import {
- type ChangeAvailabilityResponse,
type ChangeConfigurationResponse,
type ClearChargingProfileResponse,
ErrorType,
type OCPP16AuthorizeRequest,
type OCPP16AuthorizeResponse,
type OCPP16BootNotificationResponse,
+ type OCPP16ChangeAvailabilityResponse,
OCPP16ChargePointStatus,
type OCPP16DataTransferResponse,
type OCPP16DiagnosticsStatusNotificationResponse,
],
[
OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
- OCPP16ServiceUtils.parseJsonSchemaFile<ChangeAvailabilityResponse>(
+ OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16ChangeAvailabilityResponse>(
'assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json',
moduleName,
'constructor',
import type { JSONSchemaType } from 'ajv';
+import { OCPP16Constants } from './OCPP16Constants';
import { type ChargingStation, hasFeatureProfile } from '../../../charging-station';
import { OCPPError } from '../../../exception';
import {
MeterValueContext,
MeterValueLocation,
MeterValueUnit,
+ OCPP16AvailabilityType,
+ type OCPP16ChangeAvailabilityResponse,
+ OCPP16ChargePointStatus,
type OCPP16ChargingProfile,
type OCPP16IncomingRequestCommand,
type OCPP16MeterValue,
return meterValues;
}
+ public static changeAvailability = async (
+ chargingStation: ChargingStation,
+ connectorId: number,
+ chargePointStatus: OCPP16ChargePointStatus,
+ availabilityType: OCPP16AvailabilityType,
+ ): Promise<OCPP16ChangeAvailabilityResponse> => {
+ let response: OCPP16ChangeAvailabilityResponse =
+ OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED;
+ const connectorStatus = chargingStation.getConnectorStatus(connectorId)!;
+ if (connectorStatus?.transactionStarted === true) {
+ response = OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED;
+ }
+ connectorStatus.availability = availabilityType;
+ if (response === OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED) {
+ await OCPP16ServiceUtils.sendAndSetConnectorStatus(
+ chargingStation,
+ connectorId,
+ chargePointStatus,
+ );
+ }
+ return response;
+ };
+
public static setChargingProfile(
chargingStation: ChargingStation,
connectorId: number,
type MessageEvent,
} from './WorkerBroadcastChannel';
export {
- type ChangeAvailabilityRequest,
+ type OCPP16ChangeAvailabilityRequest,
type ChangeConfigurationRequest,
type ClearChargingProfileRequest,
type GetConfigurationRequest,
type OCPP16CancelReservationRequest,
} from './ocpp/1.6/Requests';
export {
- type ChangeAvailabilityResponse,
+ type OCPP16ChangeAvailabilityResponse,
type ChangeConfigurationResponse,
type ClearChargingProfileResponse,
type GetConfigurationResponse,
} from './WebSocket';
export {
type Reservation,
- type ReservationFilterKey,
+ type ReservationKey,
ReservationTerminationReason,
} from './ocpp/Reservation';
Operative = 'Operative',
}
-export interface ChangeAvailabilityRequest extends JsonObject {
+export interface OCPP16ChangeAvailabilityRequest extends JsonObject {
connectorId: number;
type: OCPP16AvailabilityType;
}
SCHEDULED = 'Scheduled',
}
-export interface ChangeAvailabilityResponse extends JsonObject {
+export interface OCPP16ChangeAvailabilityResponse extends JsonObject {
status: OCPP16AvailabilityStatus;
}
REPLACE_EXISTING = 'ReplaceExisting',
}
-export type ReservationFilterKey = keyof OCPP16ReserveNowRequest;
+export type ReservationKey = keyof OCPP16ReserveNowRequest;