Ensure 1:1 mapping between charging station instance and its OCPP services
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16RequestService.ts
index 3580cc52e18701ff05f8a6939b6714bb5be9113a..0385f45a5eee50714ad4db8e93c4a85c8c9020c8 100644 (file)
@@ -6,6 +6,7 @@ import { CurrentType, Voltage } from '../../../types/ChargingStationTemplate';
 import { DiagnosticsStatusNotificationRequest, HeartbeatRequest, OCPP16BootNotificationRequest, OCPP16IncomingRequestCommand, OCPP16RequestCommand, StatusNotificationRequest } from '../../../types/ocpp/1.6/Requests';
 import { MeterValueUnit, MeterValuesRequest, OCPP16MeterValue, OCPP16MeterValueMeasurand, OCPP16MeterValuePhase } from '../../../types/ocpp/1.6/MeterValues';
 
+import ChargingStation from '../../ChargingStation';
 import Constants from '../../../utils/Constants';
 import { ErrorType } from '../../../types/ocpp/ErrorType';
 import { JsonType } from '../../../types/JsonType';
@@ -19,11 +20,19 @@ import { OCPP16DiagnosticsStatus } from '../../../types/ocpp/1.6/DiagnosticsStat
 import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
 import OCPPError from '../../../exception/OCPPError';
 import OCPPRequestService from '../OCPPRequestService';
+import OCPPResponseService from '../OCPPResponseService';
 import { SendParams } from '../../../types/ocpp/Requests';
 import Utils from '../../../utils/Utils';
 import logger from '../../../utils/Logger';
 
 export default class OCPP16RequestService extends OCPPRequestService {
+  public constructor(chargingStation: ChargingStation, ocppResponseService: OCPPResponseService) {
+    if (new.target?.name === 'OCPP16RequestService') {
+      throw new TypeError('Cannot construct OCPP16RequestService instances directly');
+    }
+    super(chargingStation, ocppResponseService);
+  }
+
   public async sendHeartbeat(params?: SendParams): Promise<void> {
     try {
       const payload: HeartbeatRequest = {};