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