Configuration,
Constants,
DCElectricUtils,
+ buildAddedMessage,
buildChargingStationAutomaticTransactionGeneratorConfiguration,
buildConnectorsStatus,
buildEvsesStatus,
this.idTagsCache = IdTagsCache.getInstance()
this.chargingStationWorkerBroadcastChannel = new ChargingStationWorkerBroadcastChannel(this)
+ this.on(ChargingStationEvents.added, () => {
+ parentPort?.postMessage(buildAddedMessage(this))
+ })
this.on(ChargingStationEvents.started, () => {
parentPort?.postMessage(buildStartedMessage(this))
})
})
this.initialize()
+
+ this.add()
+
+ this.stationInfo?.autoStart === true && this.start()
}
public get hasEvses (): boolean {
}
}
+ private add (): void {
+ this.emit(ChargingStationEvents.added)
+ }
+
public start (): void {
if (!this.started) {
if (!this.starting) {
}
}
- public async stop (reason?: StopTransactionReason, stopTransactions?: boolean): Promise<void> {
+ public async stop (
+ reason?: StopTransactionReason,
+ stopTransactions = this.stationInfo?.stopTransactionsOnStopped
+ ): Promise<void> {
if (this.started) {
if (!this.stopping) {
this.stopping = true
}
const stationInfo = stationTemplateToStationInfo(stationTemplate)
stationInfo.hashId = getHashId(this.index, stationTemplate)
+ stationInfo.autoStart = stationTemplate.autoStart ?? true
stationInfo.templateName = parse(this.templateFile).name
stationInfo.chargingStationId = getChargingStationId(this.index, stationTemplate)
stationInfo.ocppVersion = stationTemplate.ocppVersion ?? OCPPVersion.VERSION_16
stationInfo.resetTime =
stationTemplate.resetTime != null
? secondsToMilliseconds(stationTemplate.resetTime)
- : Constants.CHARGING_STATION_DEFAULT_RESET_TIME
+ : Constants.DEFAULT_CHARGING_STATION_RESET_TIME
return stationInfo
}
if (stationInfo.templateName == null) {
stationInfo.templateName = parse(this.templateFile).name
}
+ if (stationInfo.autoStart == null) {
+ stationInfo.autoStart = true
+ }
}
}
return stationInfo
this.emit(ChargingStationEvents.updated)
}
- private getCachedRequest (messageType: MessageType, messageId: string): CachedRequest | undefined {
+ private getCachedRequest (
+ messageType: MessageType | undefined,
+ messageId: string
+ ): CachedRequest | undefined {
const cachedRequest = this.requests.get(messageId)
if (Array.isArray(cachedRequest)) {
return cachedRequest
commandName ?? requestCommandName ?? Constants.UNKNOWN_COMMAND
// eslint-disable-next-line @typescript-eslint/no-base-to-string
}' message '${data.toString()}'${
- messageType !== MessageType.CALL_MESSAGE
- ? ` matching cached request '${JSON.stringify(this.requests.get(messageId))}'`
+ this.requests.has(messageId)
+ ? ` matching cached request '${JSON.stringify(this.getCachedRequest(messageType, messageId))}'`
: ''
} processing error:`,
error
private async stopMessageSequence (
reason?: StopTransactionReason,
- stopTransactions = this.stationInfo?.stopTransactionsOnStopped
+ stopTransactions?: boolean
): Promise<void> {
this.internalStopMessageSequence()
// Stop ongoing transactions