import type { ChargingStation } from '../../../charging-station';
import { OCPPError } from '../../../exception';
import {
import type { ChargingStation } from '../../../charging-station';
import { OCPPError } from '../../../exception';
import {
protected jsonSchemas: Map<OCPP20RequestCommand, JSONSchemaType<JsonObject>>;
public constructor(ocppResponseService: OCPPResponseService) {
protected jsonSchemas: Map<OCPP20RequestCommand, JSONSchemaType<JsonObject>>;
public constructor(ocppResponseService: OCPPResponseService) {
- if (new.target?.name === moduleName) {
- throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
- }
+ // if (new.target?.name === moduleName) {
+ // throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
+ // }
super(OCPPVersion.VERSION_20, ocppResponseService);
this.jsonSchemas = new Map<OCPP20RequestCommand, JSONSchemaType<JsonObject>>([
[
OCPP20RequestCommand.BOOT_NOTIFICATION,
OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20BootNotificationRequest>(
super(OCPPVersion.VERSION_20, ocppResponseService);
this.jsonSchemas = new Map<OCPP20RequestCommand, JSONSchemaType<JsonObject>>([
[
OCPP20RequestCommand.BOOT_NOTIFICATION,
OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20BootNotificationRequest>(
[
OCPP20RequestCommand.HEARTBEAT,
OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20HeartbeatRequest>(
[
OCPP20RequestCommand.HEARTBEAT,
OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20HeartbeatRequest>(
[
OCPP20RequestCommand.STATUS_NOTIFICATION,
OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20StatusNotificationRequest>(
[
OCPP20RequestCommand.STATUS_NOTIFICATION,
OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20StatusNotificationRequest>(
- this.buildRequestPayload.bind(this);
+ this.buildRequestPayload = this.buildRequestPayload.bind(this) as <Request extends JsonType>(
+ chargingStation: ChargingStation,
+ commandName: OCPP20RequestCommand,
+ commandParams?: JsonType
+ ) => Request;
commandParams?: JsonType,
params?: RequestParams
): Promise<ResponseType> {
commandParams?: JsonType,
params?: RequestParams
): Promise<ResponseType> {
if (OCPP20ServiceUtils.isRequestCommandSupported(chargingStation, commandName) === true) {
return (await this.sendMessage(
chargingStation,
if (OCPP20ServiceUtils.isRequestCommandSupported(chargingStation, commandName) === true) {
return (await this.sendMessage(
chargingStation,
this.buildRequestPayload<RequestType>(chargingStation, commandName, commandParams),
commandName,
params
this.buildRequestPayload<RequestType>(chargingStation, commandName, commandParams),
commandName,
params
case OCPP20RequestCommand.BOOT_NOTIFICATION:
return commandParams as unknown as Request;
case OCPP20RequestCommand.HEARTBEAT:
case OCPP20RequestCommand.BOOT_NOTIFICATION:
return commandParams as unknown as Request;
case OCPP20RequestCommand.HEARTBEAT: