Align 'started' attribute usage to all classes
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 1 Sep 2022 23:11:03 +0000 (01:11 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 1 Sep 2022 23:11:03 +0000 (01:11 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/Bootstrap.ts
src/charging-station/ChargingStation.ts
src/charging-station/MessageChannelUtils.ts
src/types/ChargingStationWorker.ts
src/ui/web/src/components/charging-stations/CSData.vue
src/ui/web/src/components/charging-stations/CSTable.vue
src/ui/web/src/types/ChargingStationType.ts
src/ui/web/tests/unit/CSTable.spec.ts

index 277558360ad732b498dd7d8b20b4476521772d82..5ed378c7894b99e29b754a2c0a98e24dec7d4dda 100644 (file)
@@ -76,7 +76,7 @@ export class Bootstrap {
   }
 
   public async start(): Promise<void> {
-    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<void> {
-    if (isMainThread && this.started) {
+    if (isMainThread && this.started === true) {
       await this.workerImplementation.stop();
       this.workerImplementation = null;
       this.uiServer?.stop();
index 89fffc3bffc03b3399837d211a9d8d31ea5411c3..78db2058c3bcac8b170a823b354cb7431a5b1013 100644 (file)
@@ -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,
index 11eea6e66d28b79ccf3fab437725b50bd2d696da..e87cdbc0b6cbaa4d326cd55e79a10b5a46bc872a 100644 (file)
@@ -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
index 8a8fd381d3080f16a6cb1e434a0d5413eb57586e..4cbe8ba7069706ea6080f41b2560705ed39c5f10 100644 (file)
@@ -17,7 +17,7 @@ export interface ChargingStationWorkerData extends WorkerData {
 
 export interface ChargingStationData extends WorkerData {
   stationInfo: ChargingStationInfo;
-  stopped: boolean;
+  started: boolean;
   bootNotificationResponse: BootNotificationResponse;
   connectors: ConnectorStatus[];
 }
index f4539469ccc97b795e0b7386ed6e40792aefa7d6..a6a819aa45fd14fddcfa5bce3410fc27e9199140 100644 (file)
@@ -8,7 +8,7 @@
       :id-tag="props.idTag"
     />
     <td class="cs-table__name-col">{{ getId() }}</td>
-    <td class="cs-table__stopped-col">{{ getStopped() }}</td>
+    <td class="cs-table__started-col">{{ getStarted() }}</td>
     <td class="cs-table__registration-status-col">{{ getRegistrationStatus() }}</td>
     <td class="cs-table__vendor-col">{{ getVendor() }}</td>
     <td class="cs-table__model-col">{{ getModel() }}</td>
@@ -63,8 +63,8 @@ function getVendor(): string {
 function getFirmwareVersion(): string {
   return Utils.ifUndefined<string>(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 ?? 'Ø';
index 97298b1a3fe5a6bfa8b95e582f2a77f9007c61cd..cf0835bcf9a9561686c45a2c0092bf02c1f22667 100644 (file)
@@ -7,7 +7,7 @@
         <th scope="col" class="cs-table__status-col">Status</th>
         <th scope="col" class="cs-table__transaction-col">Transaction</th>
         <th scope="col" class="cs-table__name-col">Name</th>
-        <th scope="col" class="cs-table__stopped-col">Stopped</th>
+        <th scope="col" class="cs-table__started-col">Started</th>
         <th scope="col" class="cs-table__registration-status-col">Registration Status</th>
         <th scope="col" class="cs-table__vendor-col">Vendor</th>
         <th scope="col" class="cs-table__model-col">Model</th>
@@ -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,
index 8d6f968537eeefbf4d2ade590aca799db811d1bb..d99aba18999acd083272e3d2d37b421df8f5497a 100644 (file)
@@ -2,7 +2,7 @@ import type { JsonObject } from './JsonType';
 
 export type ChargingStationData = {
   stationInfo: ChargingStationInfo;
-  stopped: boolean;
+  started: boolean;
   bootNotificationResponse: BootNotificationResponse;
   connectors: ConnectorStatus[];
 };
index b77fab86b9e1ba819edd20d067f3c59edb79105c..570c9f1fb066f675c139820b7be54952a7a241a2 100644 (file)
@@ -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');