refactor: move template firmware defaults to constants
[e-mobility-charging-stations-simulator.git] / src / utils / Constants.ts
CommitLineData
4f03d842
JB
1import {
2 type AutomaticTransactionGeneratorConfiguration,
3 type ChargingStationInfo,
4 CurrentType,
3ccfabff 5 type IncomingRequestCommand,
4f03d842 6 OCPPVersion,
3ccfabff 7 type RequestCommand,
66a7748d
JB
8 VendorParametersKey
9} from '../types/index.js'
1fe0632a 10
66a7748d 11// eslint-disable-next-line @typescript-eslint/no-extraneous-class
268a74bb 12export class Constants {
1feac591
JB
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
09e5a7a8 17 private static readonly DEFAULT_CHARGING_STATION_RESET_TIME = 30000 // Ms
1feac591 18
4f03d842
JB
19 static readonly DEFAULT_STATION_INFO: Partial<ChargingStationInfo> = Object.freeze({
20 enableStatistics: false,
1feac591 21 autoStart: true,
4f03d842
JB
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,
1feac591 34 useConnectorId0: true,
4f03d842 35 ocppVersion: OCPPVersion.VERSION_16,
1feac591 36 firmwareVersionPattern: Constants.SEMVER_PATTERN,
5dcb9d49
JB
37 firmwareUpgrade: {
38 versionUpgrade: {
39 step: 1
40 },
41 reset: true
42 },
4f03d842
JB
43 ocppPersistentConfiguration: true,
44 stationInfoPersistentConfiguration: true,
45 automaticTransactionGeneratorPersistentConfiguration: true,
1feac591 46 resetTime: Constants.DEFAULT_CHARGING_STATION_RESET_TIME,
4f03d842
JB
47 autoReconnectMaxRetries: -1,
48 registrationMaxRetries: -1,
49 reconnectExponentialDelay: false,
66a7748d
JB
50 stopTransactionsOnStopped: true
51 })
4f03d842 52
66a7748d
JB
53 static readonly DEFAULT_BOOT_NOTIFICATION_INTERVAL = 60000 // Ms
54 static readonly DEFAULT_HEARTBEAT_INTERVAL = 60000 // Ms
55 static readonly DEFAULT_METER_VALUES_INTERVAL = 60000 // Ms
d2a64eb5 56
7e3bde4f 57 static readonly DEFAULT_ATG_WAIT_TIME = 1000 // Ms
1fe0632a
JB
58 static readonly DEFAULT_ATG_CONFIGURATION: AutomaticTransactionGeneratorConfiguration =
59 Object.freeze({
60 enable: false,
86b46b49
JB
61 minDuration: 60,
62 maxDuration: 120,
63 minDelayBetweenTwoTransactions: 15,
64 maxDelayBetweenTwoTransactions: 30,
1fe0632a 65 probabilityOfStart: 1,
86b46b49 66 stopAfterHours: 0.25,
e054fc1c 67 stopAbsoluteDuration: false
66a7748d 68 })
9ac86a7e 69
66a7748d 70 static readonly DEFAULT_CIRCULAR_BUFFER_CAPACITY = 4096
1e080116 71
66a7748d 72 static readonly DEFAULT_HASH_ALGORITHM = 'sha384'
3f94cab5 73
66a7748d 74 static readonly DEFAULT_IDTAG = '00000000'
3d2ff9e4 75
66a7748d 76 static readonly DEFAULT_CONNECTION_TIMEOUT = 30
9ccca265 77
66a7748d 78 static readonly DEFAULT_LOG_STATISTICS_INTERVAL = 60 // Seconds
25f5a959 79
66a7748d 80 static readonly DEFAULT_FLUCTUATION_PERCENT = 5
2a370053 81
66a7748d
JB
82 static readonly DEFAULT_PERFORMANCE_DIRECTORY = 'performance'
83 static readonly DEFAULT_PERFORMANCE_RECORDS_FILENAME = 'performanceRecords.json'
84 static readonly DEFAULT_PERFORMANCE_RECORDS_DB_NAME = 'e-mobility-charging-stations-simulator'
85 static readonly PERFORMANCE_RECORDS_TABLE = 'performance_records'
6a49ad23 86
66a7748d
JB
87 static readonly DEFAULT_UI_SERVER_HOST = 'localhost'
88 static readonly DEFAULT_UI_SERVER_PORT = 8080
4db8406c 89
1feac591
JB
90 static readonly UNKNOWN_OCPP_COMMAND = 'unknown OCPP command' as
91 | RequestCommand
92 | IncomingRequestCommand
2a232a18 93
fcda9151 94 static readonly MAX_RANDOM_INTEGER = 281474976710655
59395dc1 95
98f5aa8d 96 static readonly STOP_CHARGING_STATIONS_TIMEOUT = 60000 // Ms
1832a986 97
66a7748d 98 static readonly EMPTY_FROZEN_OBJECT = Object.freeze({})
59b6ed8d
JB
99 static readonly EMPTY_FUNCTION = Object.freeze(() => {
100 /* This is intentional */
66a7748d 101 })
59b6ed8d 102
66a7748d 103 static readonly DEFAULT_MESSAGE_BUFFER_FLUSH_INTERVAL = 60000 // Ms
d193a949 104
66a7748d 105 private constructor () {
4db8406c
JB
106 // This is intentional
107 }
f7869514 108}