Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
export class Bootstrap extends EventEmitter {
private static instance: Bootstrap | null = null
private workerImplementation?: WorkerAbstract<ChargingStationWorkerData>
export class Bootstrap extends EventEmitter {
private static instance: Bootstrap | null = null
private workerImplementation?: WorkerAbstract<ChargingStationWorkerData>
- private readonly uiServer?: AbstractUIServer
+ private readonly uiServer: AbstractUIServer
private storage?: Storage
private readonly templatesChargingStations: Map<string, TemplateChargingStations>
private readonly version: string = version
private storage?: Storage
private readonly templatesChargingStations: Map<string, TemplateChargingStations>
private readonly version: string = version
private started: boolean
private starting: boolean
private stopping: boolean
private started: boolean
private starting: boolean
private stopping: boolean
+ private uiServerStarted: boolean
private constructor () {
super()
private constructor () {
super()
this.started = false
this.starting = false
this.stopping = false
this.started = false
this.starting = false
this.stopping = false
- this.templatesChargingStations = new Map<string, TemplateChargingStations>()
+ this.uiServerStarted = false
this.uiServer = UIServerFactory.getUIServerImplementation(
Configuration.getConfigurationSection<UIServerConfiguration>(ConfigurationSection.uiServer)
)
this.uiServer = UIServerFactory.getUIServerImplementation(
Configuration.getConfigurationSection<UIServerConfiguration>(ConfigurationSection.uiServer)
)
+ this.templatesChargingStations = new Map<string, TemplateChargingStations>()
this.initializedCounters = false
this.initializeCounters()
Configuration.configurationChangeCallback = async () => {
this.initializedCounters = false
this.initializeCounters()
Configuration.configurationChangeCallback = async () => {
)
await this.storage?.open()
}
)
await this.storage?.open()
}
- Configuration.getConfigurationSection<UIServerConfiguration>(ConfigurationSection.uiServer)
- .enabled === true && this.uiServer?.start()
+ if (
+ !this.uiServerStarted &&
+ Configuration.getConfigurationSection<UIServerConfiguration>(
+ ConfigurationSection.uiServer
+ ).enabled === true
+ ) {
+ this.uiServer.start()
+ this.uiServerStarted = true
+ }
// Start ChargingStation object instance in worker thread
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
for (const stationTemplateUrl of Configuration.getStationTemplateUrls()!) {
// Start ChargingStation object instance in worker thread
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
for (const stationTemplateUrl of Configuration.getStationTemplateUrls()!) {
if (this.started) {
if (!this.stopping) {
this.stopping = true
if (this.started) {
if (!this.stopping) {
this.stopping = true
- await this.uiServer?.sendInternalRequest(
+ await this.uiServer.sendInternalRequest(
this.uiServer.buildProtocolRequest(
generateUUID(),
ProcedureName.STOP_CHARGING_STATION,
this.uiServer.buildProtocolRequest(
generateUUID(),
ProcedureName.STOP_CHARGING_STATION,
await this.workerImplementation?.stop()
delete this.workerImplementation
this.removeAllListeners()
await this.workerImplementation?.stop()
delete this.workerImplementation
this.removeAllListeners()
- this.uiServer?.chargingStations.clear()
+ this.uiServer.clearCaches()
this.initializedCounters = false
await this.storage?.close()
delete this.storage
this.initializedCounters = false
await this.storage?.close()
delete this.storage
private async restart (): Promise<void> {
await this.stop()
private async restart (): Promise<void> {
await this.stop()
- Configuration.getConfigurationSection<UIServerConfiguration>(ConfigurationSection.uiServer)
- .enabled !== true && this.uiServer?.stop()
+ if (
+ this.uiServerStarted &&
+ Configuration.getConfigurationSection<UIServerConfiguration>(ConfigurationSection.uiServer)
+ .enabled !== true
+ ) {
+ this.uiServer.stop()
+ this.uiServerStarted = false
+ }
}
private readonly workerEventAdded = (data: ChargingStationData): void => {
}
private readonly workerEventAdded = (data: ChargingStationData): void => {
- this.uiServer?.chargingStations.set(data.stationInfo.hashId, data)
+ this.uiServer.chargingStations.set(data.stationInfo.hashId, data)
logger.info(
`${this.logPrefix()} ${moduleName}.workerEventAdded: Charging station ${
data.stationInfo.chargingStationId
logger.info(
`${this.logPrefix()} ${moduleName}.workerEventAdded: Charging station ${
data.stationInfo.chargingStationId
}
private readonly workerEventDeleted = (data: ChargingStationData): void => {
}
private readonly workerEventDeleted = (data: ChargingStationData): void => {
- this.uiServer?.chargingStations.delete(data.stationInfo.hashId)
+ this.uiServer.chargingStations.delete(data.stationInfo.hashId)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const templateChargingStations = this.templatesChargingStations.get(
data.stationInfo.templateName
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const templateChargingStations = this.templatesChargingStations.get(
data.stationInfo.templateName
}
private readonly workerEventStarted = (data: ChargingStationData): void => {
}
private readonly workerEventStarted = (data: ChargingStationData): void => {
- this.uiServer?.chargingStations.set(data.stationInfo.hashId, data)
+ this.uiServer.chargingStations.set(data.stationInfo.hashId, data)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
++this.templatesChargingStations.get(data.stationInfo.templateName)!.started
logger.info(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
++this.templatesChargingStations.get(data.stationInfo.templateName)!.started
logger.info(
}
private readonly workerEventStopped = (data: ChargingStationData): void => {
}
private readonly workerEventStopped = (data: ChargingStationData): void => {
- this.uiServer?.chargingStations.set(data.stationInfo.hashId, data)
+ this.uiServer.chargingStations.set(data.stationInfo.hashId, data)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
--this.templatesChargingStations.get(data.stationInfo.templateName)!.started
logger.info(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
--this.templatesChargingStations.get(data.stationInfo.templateName)!.started
logger.info(
}
private readonly workerEventUpdated = (data: ChargingStationData): void => {
}
private readonly workerEventUpdated = (data: ChargingStationData): void => {
- this.uiServer?.chargingStations.set(data.stationInfo.hashId, data)
+ this.uiServer.chargingStations.set(data.stationInfo.hashId, data)
}
private readonly workerEventPerformanceStatistics = (data: Statistics): void => {
}
private readonly workerEventPerformanceStatistics = (data: Statistics): void => {
started: 0,
indexes: new Set<number>()
})
started: 0,
indexes: new Set<number>()
})
- this.uiServer?.chargingStationTemplates.add(templateName)
+ this.uiServer.chargingStationTemplates.add(templateName)
}
if (this.templatesChargingStations.size !== stationTemplateUrls.length) {
console.error(
}
if (this.templatesChargingStations.size !== stationTemplateUrls.length) {
console.error(
this.stop()
.then(() => {
console.info(chalk.green('Graceful shutdown'))
this.stop()
.then(() => {
console.info(chalk.green('Graceful shutdown'))
+ this.uiServer.stop()
+ this.uiServerStarted = false
this.waitChargingStationsStopped()
.then(() => {
exit(exitCodes.succeeded)
this.waitChargingStationsStopped()
.then(() => {
exit(exitCodes.succeeded)
- private clearCaches (): void {
+ public clearCaches (): void {
this.chargingStations.clear()
this.chargingStationTemplates.clear()
}
this.chargingStations.clear()
this.chargingStationTemplates.clear()
}
public static getUIServerImplementation (
uiServerConfiguration: UIServerConfiguration
public static getUIServerImplementation (
uiServerConfiguration: UIServerConfiguration
- ): AbstractUIServer | undefined {
if (
uiServerConfiguration.authentication?.enabled === true &&
!Object.values(AuthenticationType).includes(uiServerConfiguration.authentication.type)
if (
uiServerConfiguration.authentication?.enabled === true &&
!Object.values(AuthenticationType).includes(uiServerConfiguration.authentication.type)
uiServerConfiguration.version = ApplicationProtocolVersion.VERSION_11
}
switch (uiServerConfiguration.type) {
uiServerConfiguration.version = ApplicationProtocolVersion.VERSION_11
}
switch (uiServerConfiguration.type) {
- case ApplicationProtocol.WS:
- return new UIWebSocketServer(uiServerConfiguration)
case ApplicationProtocol.HTTP:
return new UIHttpServer(uiServerConfiguration)
case ApplicationProtocol.HTTP:
return new UIHttpServer(uiServerConfiguration)
+ case ApplicationProtocol.WS:
+ default:
+ return new UIWebSocketServer(uiServerConfiguration)
"sonarsource.sonarlint-vscode",
"streetsidesoftware.code-spell-checker",
"Vue.volar",
"sonarsource.sonarlint-vscode",
"streetsidesoftware.code-spell-checker",
"Vue.volar",
- "zixuanchen.vitest-explorer"
</template>
<script setup lang="ts">
</template>
<script setup lang="ts">
-import { defineProps, getCurrentInstance, reactive } from 'vue'
+import { getCurrentInstance, reactive } from 'vue'
import Button from '@/components/buttons/Button.vue'
const props = defineProps<{
import Button from '@/components/buttons/Button.vue'
const props = defineProps<{
</template>
<script setup lang="ts">
</template>
<script setup lang="ts">
-import { defineProps, getCurrentInstance, reactive } from 'vue'
+import { getCurrentInstance, reactive } from 'vue'
import Button from '@/components/buttons/Button.vue'
const props = defineProps<{
import Button from '@/components/buttons/Button.vue'
const props = defineProps<{
</template>
<script setup lang="ts">
</template>
<script setup lang="ts">
-import { defineProps } from 'vue'
import FlatButton from '@/components/buttons/FlatButton.vue'
defineProps<{
import FlatButton from '@/components/buttons/FlatButton.vue'
defineProps<{
</template>
<script setup lang="ts">
</template>
<script setup lang="ts">
-import { defineProps, getCurrentInstance } from 'vue'
+import { getCurrentInstance } from 'vue'
import { useToast } from 'vue-toast-notification'
import Button from '@/components/buttons/Button.vue'
import type { ConnectorStatus, Status } from '@/types'
import { useToast } from 'vue-toast-notification'
import Button from '@/components/buttons/Button.vue'
import type { ConnectorStatus, Status } from '@/types'
</template>
<script setup lang="ts">
</template>
<script setup lang="ts">
-import { defineProps, getCurrentInstance } from 'vue'
+import { getCurrentInstance } from 'vue'
import { useToast } from 'vue-toast-notification'
import CSConnector from '@/components/charging-stations/CSConnector.vue'
import Button from '@/components/buttons/Button.vue'
import { useToast } from 'vue-toast-notification'
import CSConnector from '@/components/charging-stations/CSConnector.vue'
import Button from '@/components/buttons/Button.vue'
<tbody id="cs-table__body">
<CSData
v-for="chargingStation in chargingStations"
<tbody id="cs-table__body">
<CSData
v-for="chargingStation in chargingStations"
- :key="chargingStation.stationInfo?.hashId"
+ :key="chargingStation.stationInfo?.chargingStationId"
:charging-station="chargingStation"
/>
</tbody>
:charging-station="chargingStation"
/>
</tbody>
</template>
<script setup lang="ts">
</template>
<script setup lang="ts">
-import { defineProps } from 'vue'
import CSData from '@/components/charging-stations/CSData.vue'
import type { ChargingStationData } from '@/types'
import CSData from '@/components/charging-stations/CSData.vue'
import type { ChargingStationData } from '@/types'