refactor: cleanup charging station events handling
[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 {
4f03d842
JB
13 static readonly DEFAULT_STATION_INFO: Partial<ChargingStationInfo> = Object.freeze({
14 enableStatistics: false,
15 remoteAuthorization: true,
16 currentOutType: CurrentType.AC,
17 mainVoltageMeterValues: true,
18 phaseLineToLineVoltageMeterValues: false,
19 customValueLimitationMeterValues: true,
20 ocppStrictCompliance: true,
21 outOfOrderEndMeterValues: false,
22 beginEndMeterValues: false,
23 meteringPerTransaction: true,
24 transactionDataMeterValues: false,
25 supervisionUrlOcppConfiguration: false,
26 supervisionUrlOcppKey: VendorParametersKey.ConnectionUrl,
27 ocppVersion: OCPPVersion.VERSION_16,
28 ocppPersistentConfiguration: true,
29 stationInfoPersistentConfiguration: true,
30 automaticTransactionGeneratorPersistentConfiguration: true,
31 autoReconnectMaxRetries: -1,
32 registrationMaxRetries: -1,
33 reconnectExponentialDelay: false,
66a7748d
JB
34 stopTransactionsOnStopped: true
35 })
4f03d842 36
66a7748d
JB
37 static readonly DEFAULT_BOOT_NOTIFICATION_INTERVAL = 60000 // Ms
38 static readonly DEFAULT_HEARTBEAT_INTERVAL = 60000 // Ms
39 static readonly DEFAULT_METER_VALUES_INTERVAL = 60000 // Ms
d2a64eb5 40
66a7748d
JB
41 static readonly CHARGING_STATION_DEFAULT_RESET_TIME = 60000 // Ms
42 static readonly CHARGING_STATION_ATG_AVAILABILITY_TIME = 1000 // Ms
43 static readonly CHARGING_STATION_ATG_INITIALIZATION_TIME = 1000 // Ms
1fe0632a 44
1fe0632a
JB
45 static readonly DEFAULT_ATG_CONFIGURATION: AutomaticTransactionGeneratorConfiguration =
46 Object.freeze({
47 enable: false,
86b46b49
JB
48 minDuration: 60,
49 maxDuration: 120,
50 minDelayBetweenTwoTransactions: 15,
51 maxDelayBetweenTwoTransactions: 30,
1fe0632a 52 probabilityOfStart: 1,
86b46b49 53 stopAfterHours: 0.25,
46a830d2 54 stopAbsoluteDuration: false,
66a7748d
JB
55 stopOnConnectionFailure: true
56 })
9ac86a7e 57
b25b8684 58 // See https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
3637ca2c 59 static readonly SEMVER_PATTERN =
66a7748d 60 '^(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-]+)*))?$'
b25b8684 61
66a7748d 62 static readonly DEFAULT_CIRCULAR_BUFFER_CAPACITY = 4096
1e080116 63
66a7748d 64 static readonly DEFAULT_HASH_ALGORITHM = 'sha384'
3f94cab5 65
66a7748d 66 static readonly DEFAULT_IDTAG = '00000000'
3d2ff9e4 67
66a7748d 68 static readonly DEFAULT_CONNECTION_TIMEOUT = 30
9ccca265 69
66a7748d 70 static readonly DEFAULT_LOG_STATISTICS_INTERVAL = 60 // Seconds
25f5a959 71
66a7748d 72 static readonly DEFAULT_FLUCTUATION_PERCENT = 5
2a370053 73
66a7748d
JB
74 static readonly DEFAULT_PERFORMANCE_DIRECTORY = 'performance'
75 static readonly DEFAULT_PERFORMANCE_RECORDS_FILENAME = 'performanceRecords.json'
76 static readonly DEFAULT_PERFORMANCE_RECORDS_DB_NAME = 'e-mobility-charging-stations-simulator'
77 static readonly PERFORMANCE_RECORDS_TABLE = 'performance_records'
6a49ad23 78
66a7748d
JB
79 static readonly DEFAULT_UI_SERVER_HOST = 'localhost'
80 static readonly DEFAULT_UI_SERVER_PORT = 8080
4db8406c 81
3ccfabff 82 static readonly UNKNOWN_COMMAND = 'unknown command' as RequestCommand | IncomingRequestCommand
2a232a18 83
66a7748d 84 static readonly MAX_RANDOM_INTEGER = 281474976710654
59395dc1 85
98f5aa8d 86 static readonly STOP_CHARGING_STATIONS_TIMEOUT = 60000 // Ms
1832a986 87
66a7748d 88 static readonly EMPTY_FROZEN_OBJECT = Object.freeze({})
59b6ed8d
JB
89 static readonly EMPTY_FUNCTION = Object.freeze(() => {
90 /* This is intentional */
66a7748d 91 })
59b6ed8d 92
66a7748d 93 static readonly DEFAULT_MESSAGE_BUFFER_FLUSH_INTERVAL = 60000 // Ms
d193a949 94
66a7748d 95 private constructor () {
4db8406c
JB
96 // This is intentional
97 }
f7869514 98}