1 import type ChargingStation from
'../ChargingStation';
2 import { JsonType
} from
'../../types/JsonType';
3 import { RequestCommand
} from
'../../types/ocpp/Requests';
5 export default abstract class OCPPResponseService
{
6 private static readonly instances
: Map
<string, OCPPResponseService
> = new Map
<string, OCPPResponseService
>();
7 protected readonly chargingStation
: ChargingStation
;
9 protected constructor(chargingStation
: ChargingStation
) {
10 this.chargingStation
= chargingStation
;
13 public static getInstance
<T
extends OCPPResponseService
>(this: new (chargingStation
: ChargingStation
) => T
, chargingStation
: ChargingStation
): T
{
14 if (!OCPPResponseService
.instances
.has(chargingStation
.id
)) {
15 OCPPResponseService
.instances
.set(chargingStation
.id
, new this(chargingStation
));
17 return OCPPResponseService
.instances
.get(chargingStation
.id
) as T
;
20 public abstract handleResponse(commandName
: RequestCommand
, payload
: JsonType
| string, requestPayload
: JsonType
): Promise
<void>;