X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPConstants.ts;h=9d3fc74b14b6775b94baf5091722ebba2536e999;hb=022a231c76e227205b0124a7aef8e16ceb86a1d9;hp=f2f36cec2a280f75f01c1bf36be861abaa28361d;hpb=bf53cadfde620fe89e6438403658682feb5bd39e;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPConstants.ts b/src/charging-station/ocpp/OCPPConstants.ts index f2f36cec..9d3fc74b 100644 --- a/src/charging-station/ocpp/OCPPConstants.ts +++ b/src/charging-station/ocpp/OCPPConstants.ts @@ -4,15 +4,30 @@ import { ClearChargingProfileStatus, ConfigurationStatus, DataTransferStatus, - DefaultStatus, + GenericStatus, + MeterValueMeasurand, TriggerMessageStatus, UnlockStatus, -} from '../../types/ocpp/Responses'; - -export default class OCPPConstants { - static readonly OCPP_RESPONSE_EMPTY = Object.freeze({}); - static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: DefaultStatus.ACCEPTED }); - static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: DefaultStatus.REJECTED }); +} from '../../types'; +import { ReservationStatus } from '../../types/ocpp/Responses'; +import { Constants } from '../../utils'; + +export class OCPPConstants { + static readonly OCPP_WEBSOCKET_TIMEOUT = 60000; // Ms + static readonly OCPP_TRIGGER_MESSAGE_DELAY = 500; // Ms + + static readonly OCPP_MEASURANDS_SUPPORTED = Object.freeze([ + MeterValueMeasurand.STATE_OF_CHARGE, + MeterValueMeasurand.VOLTAGE, + MeterValueMeasurand.POWER_ACTIVE_IMPORT, + MeterValueMeasurand.CURRENT_IMPORT, + MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER, + ]); + + static readonly OCPP_REQUEST_EMPTY = Constants.EMPTY_FREEZED_OBJECT; + static readonly OCPP_RESPONSE_EMPTY = Constants.EMPTY_FREEZED_OBJECT; + static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: GenericStatus.Accepted }); + static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: GenericStatus.Rejected }); static readonly OCPP_CONFIGURATION_RESPONSE_ACCEPTED = Object.freeze({ status: ConfigurationStatus.ACCEPTED, @@ -83,11 +98,47 @@ export default class OCPPConstants { status: TriggerMessageStatus.NOT_IMPLEMENTED, }); + static readonly OCPP_DATA_TRANSFER_RESPONSE_ACCEPTED = Object.freeze({ + status: DataTransferStatus.ACCEPTED, + }); + static readonly OCPP_DATA_TRANSFER_RESPONSE_REJECTED = Object.freeze({ status: DataTransferStatus.REJECTED, }); - private constructor() { + static readonly OCPP_DATA_TRANSFER_RESPONSE_UNKNOWN_VENDOR_ID = Object.freeze({ + status: DataTransferStatus.UNKNOWN_VENDOR_ID, + }); + + static readonly OCPP_RESERVATION_RESPONSE_ACCEPTED = Object.freeze({ + status: ReservationStatus.ACCEPTED, + }); // Reservation has been made + + static readonly OCPP_RESERVATION_RESPONSE_FAULTED = Object.freeze({ + status: ReservationStatus.FAULTED, + }); // Reservation has not been made, because of connector in FAULTED state + + static readonly OCPP_RESERVATION_RESPONSE_OCCUPIED = Object.freeze({ + status: ReservationStatus.OCCUPIED, + }); // Reservation has not been made, because all connectors are OCCUPIED + + static readonly OCPP_RESERVATION_RESPONSE_REJECTED = Object.freeze({ + status: ReservationStatus.REJECTED, + }); // Reservation has not been made, because CS is not configured to accept reservations + + static readonly OCPP_RESERVATION_RESPONSE_UNAVAILABLE = Object.freeze({ + status: ReservationStatus.UNAVAILABLE, + }); // Reservation has not been made, because connectors are spec. connector is in UNAVAILABLE state + + static readonly OCPP_CANCEL_RESERVATION_RESPONSE_ACCEPTED = Object.freeze({ + status: GenericStatus.Accepted, + }); // Reservation for id has been cancelled has been made + + static readonly OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED = Object.freeze({ + status: GenericStatus.Rejected, + }); // Reservation could not be cancelled, because there is no reservation active for id + + protected constructor() { // This is intentional } }