3 buildChargingStationAutomaticTransactionGeneratorConfiguration
,
6 } from
'./ChargingStationConfigurationUtils.js'
7 import { clone
} from
'./Utils.js'
8 import type { ChargingStation
} from
'../charging-station/index.js'
10 type ChargingStationData
,
11 type ChargingStationWorkerMessage
,
12 ChargingStationWorkerMessageEvents
,
13 type InternalTemplateStatistics
,
15 type TemplateStatistics
16 } from
'../types/index.js'
18 export const buildAddedMessage
= (
19 chargingStation
: ChargingStation
20 ): ChargingStationWorkerMessage
<ChargingStationData
> => {
22 event
: ChargingStationWorkerMessageEvents
.added
,
23 data
: buildChargingStationDataPayload(chargingStation
)
27 export const buildDeletedMessage
= (
28 chargingStation
: ChargingStation
29 ): ChargingStationWorkerMessage
<ChargingStationData
> => {
31 event
: ChargingStationWorkerMessageEvents
.deleted
,
32 data
: buildChargingStationDataPayload(chargingStation
)
36 export const buildStartedMessage
= (
37 chargingStation
: ChargingStation
38 ): ChargingStationWorkerMessage
<ChargingStationData
> => {
40 event
: ChargingStationWorkerMessageEvents
.started
,
41 data
: buildChargingStationDataPayload(chargingStation
)
45 export const buildStoppedMessage
= (
46 chargingStation
: ChargingStation
47 ): ChargingStationWorkerMessage
<ChargingStationData
> => {
49 event
: ChargingStationWorkerMessageEvents
.stopped
,
50 data
: buildChargingStationDataPayload(chargingStation
)
54 export const buildUpdatedMessage
= (
55 chargingStation
: ChargingStation
56 ): ChargingStationWorkerMessage
<ChargingStationData
> => {
58 event
: ChargingStationWorkerMessageEvents
.updated
,
59 data
: buildChargingStationDataPayload(chargingStation
)
63 export const buildPerformanceStatisticsMessage
= (
64 statistics
: Statistics
65 ): ChargingStationWorkerMessage
<Statistics
> => {
67 event
: ChargingStationWorkerMessageEvents
.performanceStatistics
,
72 export const buildChargingStationDataPayload
= (
73 chargingStation
: ChargingStation
74 ): ChargingStationData
=> {
76 started
: chargingStation
.started
,
77 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
78 stationInfo
: chargingStation
.stationInfo
!,
79 connectors
: buildConnectorsStatus(chargingStation
),
80 evses
: buildEvsesStatus(chargingStation
, OutputFormat
.worker
),
81 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
82 ocppConfiguration
: chargingStation
.ocppConfiguration
!,
83 supervisionUrl
: chargingStation
.wsConnectionUrl
.href
,
84 wsState
: chargingStation
.wsConnection
?.readyState
,
85 bootNotificationResponse
: chargingStation
.bootNotificationResponse
,
86 ...(chargingStation
.automaticTransactionGenerator
!= null && {
87 automaticTransactionGenerator
:
88 buildChargingStationAutomaticTransactionGeneratorConfiguration(chargingStation
)
93 export const buildTemplateStatisticsPayload
= (
94 map
: Map
<string, InternalTemplateStatistics
>
95 ): Record
<string, TemplateStatistics
> => {
97 for (const value
of map
.values()) {
98 (value
as unknown
as TemplateStatistics
).indexes
= [...value
.indexes
]
100 return Object.fromEntries(map
.entries() as unknown
as Array<[string, TemplateStatistics
]>)