| 1 | import ChargingStation from '../ChargingStation'; |
| 2 | import { IncomingRequestCommand } from '../../types/ocpp/Requests'; |
| 3 | import logger from '../../utils/Logger'; |
| 4 | |
| 5 | export default abstract class OCPPIncomingRequestService { |
| 6 | protected chargingStation: ChargingStation; |
| 7 | |
| 8 | constructor(chargingStation: ChargingStation) { |
| 9 | this.chargingStation = chargingStation; |
| 10 | } |
| 11 | |
| 12 | protected handleIncomingRequestError<T>(commandName: IncomingRequestCommand, error: Error, errorOcppResponse?: T): T { |
| 13 | logger.error(this.chargingStation.logPrefix() + ' Incoming request command ' + commandName + ' error: %j', error); |
| 14 | if (errorOcppResponse) { |
| 15 | return errorOcppResponse; |
| 16 | } |
| 17 | throw error; |
| 18 | } |
| 19 | |
| 20 | public abstract handleRequest(messageId: string, commandName: IncomingRequestCommand, commandPayload: Record<string, unknown>): Promise<void>; |
| 21 | } |