From 452a82cadd0f08148f5f3d5e5b78fa6cac9da0a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 2 Sep 2022 01:11:03 +0200 Subject: [PATCH] Align 'started' attribute usage to all classes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/Bootstrap.ts | 4 ++-- src/charging-station/ChargingStation.ts | 14 +++++++------- src/charging-station/MessageChannelUtils.ts | 2 +- src/types/ChargingStationWorker.ts | 2 +- .../src/components/charging-stations/CSData.vue | 6 +++--- .../src/components/charging-stations/CSTable.vue | 4 ++-- src/ui/web/src/types/ChargingStationType.ts | 2 +- src/ui/web/tests/unit/CSTable.spec.ts | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 27755836..5ed378c7 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -76,7 +76,7 @@ export class Bootstrap { } public async start(): Promise { - if (isMainThread && !this.started) { + if (isMainThread && this.started === false) { try { this.initialize(); await this.storage?.open(); @@ -145,7 +145,7 @@ export class Bootstrap { } public async stop(): Promise { - if (isMainThread && this.started) { + if (isMainThread && this.started === true) { await this.workerImplementation.stop(); this.workerImplementation = null; this.uiServer?.stop(); diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 89fffc3b..78db2058 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -86,7 +86,7 @@ import SharedLRUCache from './SharedLRUCache'; export default class ChargingStation { public readonly templateFile: string; public stationInfo!: ChargingStationInfo; - public stopped: boolean; + public started: boolean; public authorizedTagsCache: AuthorizedTagsCache; public automaticTransactionGenerator!: AutomaticTransactionGenerator; public ocppConfiguration!: ChargingStationOcppConfiguration; @@ -122,7 +122,7 @@ export default class ChargingStation { this.sharedLRUCache = SharedLRUCache.getInstance(); this.authorizedTagsCache = AuthorizedTagsCache.getInstance(); this.chargingStationWorkerBroadcastChannel = new ChargingStationWorkerBroadcastChannel(this); - this.stopped = false; + this.started = false; this.wsConnectionRestarted = false; this.autoReconnectRetryCount = 0; @@ -543,7 +543,7 @@ export default class ChargingStation { this.templateFileWatcher.close(); this.sharedLRUCache.deleteChargingStationTemplate(this.stationInfo?.templateHash); this.bootNotificationResponse = null; - this.stopped = true; + this.started = false; parentPort.postMessage(MessageChannelUtils.buildStoppedMessage(this)); } @@ -1392,7 +1392,7 @@ export default class ChargingStation { `${this.logPrefix()} Registration failure: max retries reached (${this.getRegistrationMaxRetries()}) or retry disabled (${this.getRegistrationMaxRetries()})` ); } - this.stopped && (this.stopped = false); + this.started === false && (this.started = true); this.autoReconnectRetryCount = 0; this.wsConnectionRestarted = false; } else { @@ -1732,7 +1732,7 @@ export default class ChargingStation { if (connectorId === 0) { continue; } else if ( - !this.stopped && + this.started === true && !this.getConnectorStatus(connectorId)?.status && this.getConnectorStatus(connectorId)?.bootStatus ) { @@ -1748,7 +1748,7 @@ export default class ChargingStation { this.getConnectorStatus(connectorId).status = this.getConnectorStatus(connectorId).bootStatus; } else if ( - this.stopped && + this.started === false && this.getConnectorStatus(connectorId)?.status && this.getConnectorStatus(connectorId)?.bootStatus ) { @@ -1763,7 +1763,7 @@ export default class ChargingStation { }); this.getConnectorStatus(connectorId).status = this.getConnectorStatus(connectorId).bootStatus; - } else if (!this.stopped && this.getConnectorStatus(connectorId)?.status) { + } else if (this.started === true && this.getConnectorStatus(connectorId)?.status) { // Send previous status at template reload await this.ocppRequestService.requestHandler< StatusNotificationRequest, diff --git a/src/charging-station/MessageChannelUtils.ts b/src/charging-station/MessageChannelUtils.ts index 11eea6e6..e87cdbc0 100644 --- a/src/charging-station/MessageChannelUtils.ts +++ b/src/charging-station/MessageChannelUtils.ts @@ -52,7 +52,7 @@ export class MessageChannelUtils { ): ChargingStationData { return { stationInfo: chargingStation.stationInfo, - stopped: chargingStation.stopped, + started: chargingStation.started, bootNotificationResponse: chargingStation.bootNotificationResponse, connectors: [...chargingStation.connectors.values()].map( // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index 8a8fd381..4cbe8ba7 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -17,7 +17,7 @@ export interface ChargingStationWorkerData extends WorkerData { export interface ChargingStationData extends WorkerData { stationInfo: ChargingStationInfo; - stopped: boolean; + started: boolean; bootNotificationResponse: BootNotificationResponse; connectors: ConnectorStatus[]; } diff --git a/src/ui/web/src/components/charging-stations/CSData.vue b/src/ui/web/src/components/charging-stations/CSData.vue index f4539469..a6a819aa 100644 --- a/src/ui/web/src/components/charging-stations/CSData.vue +++ b/src/ui/web/src/components/charging-stations/CSData.vue @@ -8,7 +8,7 @@ :id-tag="props.idTag" /> {{ getId() }} - {{ getStopped() }} + {{ getStarted() }} {{ getRegistrationStatus() }} {{ getVendor() }} {{ getModel() }} @@ -63,8 +63,8 @@ function getVendor(): string { function getFirmwareVersion(): string { return Utils.ifUndefined(getInfo().firmwareVersion, 'Ø'); } -function getStopped(): string { - return props.chargingStation.stopped === true ? 'Yes' : 'No'; +function getStarted(): string { + return props.chargingStation.started === true ? 'Yes' : 'No'; } function getRegistrationStatus(): string { return props.chargingStation?.bootNotificationResponse?.status ?? 'Ø'; diff --git a/src/ui/web/src/components/charging-stations/CSTable.vue b/src/ui/web/src/components/charging-stations/CSTable.vue index 97298b1a..cf0835bc 100644 --- a/src/ui/web/src/components/charging-stations/CSTable.vue +++ b/src/ui/web/src/components/charging-stations/CSTable.vue @@ -7,7 +7,7 @@ Status Transaction Name - Stopped + Started Registration Status Vendor Model @@ -81,7 +81,7 @@ const props = defineProps<{ .cs-table__status-col, .cs-table__transaction-col, .cs-table__name-col, -.cs-table__stopped-col, +.cs-table__started-col, .cs-table__registration-status-col, .cs-table__model-col, .cs-table__vendor-col, diff --git a/src/ui/web/src/types/ChargingStationType.ts b/src/ui/web/src/types/ChargingStationType.ts index 8d6f9685..d99aba18 100644 --- a/src/ui/web/src/types/ChargingStationType.ts +++ b/src/ui/web/src/types/ChargingStationType.ts @@ -2,7 +2,7 @@ import type { JsonObject } from './JsonType'; export type ChargingStationData = { stationInfo: ChargingStationInfo; - stopped: boolean; + started: boolean; bootNotificationResponse: BootNotificationResponse; connectors: ConnectorStatus[]; }; diff --git a/src/ui/web/tests/unit/CSTable.spec.ts b/src/ui/web/tests/unit/CSTable.spec.ts index b77fab86..570c9f1f 100644 --- a/src/ui/web/tests/unit/CSTable.spec.ts +++ b/src/ui/web/tests/unit/CSTable.spec.ts @@ -16,7 +16,7 @@ describe('CSTable.vue', () => { expect(wrapper.text()).to.include('Status'); expect(wrapper.text()).to.include('Transaction'); expect(wrapper.text()).to.include('Name'); - expect(wrapper.text()).to.include('Stopped'); + expect(wrapper.text()).to.include('Started'); expect(wrapper.text()).to.include('Registration Status'); expect(wrapper.text()).to.include('Vendor'); expect(wrapper.text()).to.include('Model'); -- 2.34.1