a5e46f60673e3078afd9386c4b3995c0800477b5
[e-mobility-charging-stations-simulator.git] / src / utils / Constants.ts
1 import {
2 type AutomaticTransactionGeneratorConfiguration,
3 type ChargingStationInfo,
4 CurrentType,
5 type IncomingRequestCommand,
6 OCPPVersion,
7 type RequestCommand,
8 VendorParametersKey
9 } from '../types/index.js'
10
11 // eslint-disable-next-line @typescript-eslint/no-extraneous-class
12 export class Constants {
13 // See https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
14 private static readonly SEMVER_PATTERN =
15 '^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$'
16
17 private static readonly DEFAULT_CHARGING_STATION_RESET_TIME = 30000 // Ms
18
19 static readonly DEFAULT_STATION_INFO: Partial<ChargingStationInfo> = Object.freeze({
20 enableStatistics: false,
21 autoStart: true,
22 remoteAuthorization: true,
23 currentOutType: CurrentType.AC,
24 mainVoltageMeterValues: true,
25 phaseLineToLineVoltageMeterValues: false,
26 customValueLimitationMeterValues: true,
27 ocppStrictCompliance: true,
28 outOfOrderEndMeterValues: false,
29 beginEndMeterValues: false,
30 meteringPerTransaction: true,
31 transactionDataMeterValues: false,
32 supervisionUrlOcppConfiguration: false,
33 supervisionUrlOcppKey: VendorParametersKey.ConnectionUrl,
34 useConnectorId0: true,
35 ocppVersion: OCPPVersion.VERSION_16,
36 firmwareVersionPattern: Constants.SEMVER_PATTERN,
37 ocppPersistentConfiguration: true,
38 stationInfoPersistentConfiguration: true,
39 automaticTransactionGeneratorPersistentConfiguration: true,
40 resetTime: Constants.DEFAULT_CHARGING_STATION_RESET_TIME,
41 autoReconnectMaxRetries: -1,
42 registrationMaxRetries: -1,
43 reconnectExponentialDelay: false,
44 stopTransactionsOnStopped: true
45 })
46
47 static readonly DEFAULT_BOOT_NOTIFICATION_INTERVAL = 60000 // Ms
48 static readonly DEFAULT_HEARTBEAT_INTERVAL = 60000 // Ms
49 static readonly DEFAULT_METER_VALUES_INTERVAL = 60000 // Ms
50
51 static readonly DEFAULT_ATG_WAIT_TIME = 1000 // Ms
52 static readonly DEFAULT_ATG_CONFIGURATION: AutomaticTransactionGeneratorConfiguration =
53 Object.freeze({
54 enable: false,
55 minDuration: 60,
56 maxDuration: 120,
57 minDelayBetweenTwoTransactions: 15,
58 maxDelayBetweenTwoTransactions: 30,
59 probabilityOfStart: 1,
60 stopAfterHours: 0.25,
61 stopAbsoluteDuration: false
62 })
63
64 static readonly DEFAULT_CIRCULAR_BUFFER_CAPACITY = 4096
65
66 static readonly DEFAULT_HASH_ALGORITHM = 'sha384'
67
68 static readonly DEFAULT_IDTAG = '00000000'
69
70 static readonly DEFAULT_CONNECTION_TIMEOUT = 30
71
72 static readonly DEFAULT_LOG_STATISTICS_INTERVAL = 60 // Seconds
73
74 static readonly DEFAULT_FLUCTUATION_PERCENT = 5
75
76 static readonly DEFAULT_PERFORMANCE_DIRECTORY = 'performance'
77 static readonly DEFAULT_PERFORMANCE_RECORDS_FILENAME = 'performanceRecords.json'
78 static readonly DEFAULT_PERFORMANCE_RECORDS_DB_NAME = 'e-mobility-charging-stations-simulator'
79 static readonly PERFORMANCE_RECORDS_TABLE = 'performance_records'
80
81 static readonly DEFAULT_UI_SERVER_HOST = 'localhost'
82 static readonly DEFAULT_UI_SERVER_PORT = 8080
83
84 static readonly UNKNOWN_OCPP_COMMAND = 'unknown OCPP command' as
85 | RequestCommand
86 | IncomingRequestCommand
87
88 static readonly MAX_RANDOM_INTEGER = 281474976710655
89
90 static readonly STOP_CHARGING_STATIONS_TIMEOUT = 60000 // Ms
91
92 static readonly EMPTY_FROZEN_OBJECT = Object.freeze({})
93 static readonly EMPTY_FUNCTION = Object.freeze(() => {
94 /* This is intentional */
95 })
96
97 static readonly DEFAULT_MESSAGE_BUFFER_FLUSH_INTERVAL = 60000 // Ms
98
99 private constructor () {
100 // This is intentional
101 }
102 }