repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update dependencies.
[e-mobility-charging-stations-simulator.git]
/
src
/
charging-station
/
ChargingStation.ts
diff --git
a/src/charging-station/ChargingStation.ts
b/src/charging-station/ChargingStation.ts
index f60fc79ecdd5d98f4f6d5ccb4399a6f9897af45c..411c452217e7e166bf77a47a1bf486836054616c 100644
(file)
--- a/
src/charging-station/ChargingStation.ts
+++ b/
src/charging-station/ChargingStation.ts
@@
-29,6
+29,7
@@
import { WebSocketCloseEventStatusCode } from '../types/WebSocket';
import crypto from 'crypto';
import fs from 'fs';
import logger from '../utils/Logger';
import crypto from 'crypto';
import fs from 'fs';
import logger from '../utils/Logger';
+import path from 'path';
export default class ChargingStation {
public stationTemplateFile: string;
export default class ChargingStation {
public stationTemplateFile: string;
@@
-319,7
+320,7
@@
export default class ChargingStation {
}
}
}
}
- public add
MessageToBuffer
(message: string): void {
+ public add
ToMessageQueue
(message: string): void {
let dups = false;
// Handle dups in buffer
for (const bufferedMessage of this.messageQueue) {
let dups = false;
// Handle dups in buffer
for (const bufferedMessage of this.messageQueue) {
@@
-335,6
+336,15
@@
export default class ChargingStation {
}
}
}
}
+ private flushMessageQueue() {
+ if (!Utils.isEmptyArray(this.messageQueue)) {
+ this.messageQueue.forEach((message, index) => {
+ this.messageQueue.splice(index, 1);
+ this.wsConnection.send(message);
+ });
+ }
+ }
+
private getChargingStationId(stationTemplate: ChargingStationTemplate): string {
// In case of multiple instances: add instance index to charging station id
let instanceIndex = process.env.CF_INSTANCE_INDEX ? process.env.CF_INSTANCE_INDEX : 0;
private getChargingStationId(stationTemplate: ChargingStationTemplate): string {
// In case of multiple instances: add instance index to charging station id
let instanceIndex = process.env.CF_INSTANCE_INDEX ? process.env.CF_INSTANCE_INDEX : 0;
@@
-481,12
+491,7
@@
export default class ChargingStation {
await this.startMessageSequence();
this.hasStopped && (this.hasStopped = false);
if (this.hasSocketRestarted && this.isWebSocketOpen()) {
await this.startMessageSequence();
this.hasStopped && (this.hasStopped = false);
if (this.hasSocketRestarted && this.isWebSocketOpen()) {
- if (!Utils.isEmptyArray(this.messageQueue)) {
- this.messageQueue.forEach((message, index) => {
- this.messageQueue.splice(index, 1);
- this.wsConnection.send(message);
- });
- }
+ this.flushMessageQueue();
}
} else {
logger.error(`${this.logPrefix()} Registration failure: max retries reached (${this.getRegistrationMaxRetries()}) or retry disabled (${this.getRegistrationMaxRetries()})`);
}
} else {
logger.error(`${this.logPrefix()} Registration failure: max retries reached (${this.getRegistrationMaxRetries()}) or retry disabled (${this.getRegistrationMaxRetries()})`);
@@
-594,7
+599,7
@@
export default class ChargingStation {
}
private getAuthorizationFile(): string {
}
private getAuthorizationFile(): string {
- return this.stationInfo.authorizationFile &&
this.stationInfo.authorizationFile
;
+ return this.stationInfo.authorizationFile &&
path.join(path.resolve(__dirname, '../'), 'assets', path.basename(this.stationInfo.authorizationFile))
;
}
private getAuthorizedTags(): string[] {
}
private getAuthorizedTags(): string[] {