refactor: cleanup constants namespace
[e-mobility-charging-stations-simulator.git] / src / utils / Constants.ts
1 import { MeterValueMeasurand } from '../types';
2
3 export class Constants {
4 static readonly DEFAULT_BOOT_NOTIFICATION_INTERVAL = 60000; // Ms
5
6 static readonly CHARGING_STATION_DEFAULT_RESET_TIME = 60000; // Ms
7 static readonly CHARGING_STATION_ATG_INITIALIZATION_TIME = 1000; // Ms
8 static readonly CHARGING_STATION_ATG_DEFAULT_STOP_AFTER_HOURS = 0.25; // Hours
9
10 // See https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
11 static readonly SEMVER_PATTERN =
12 '^(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-]+)*))?$';
13
14 static readonly DEFAULT_CIRCULAR_BUFFER_CAPACITY = 1024;
15
16 static readonly DEFAULT_HASH_ALGORITHM = 'sha384';
17
18 static readonly DEFAULT_IDTAG = '00000000';
19
20 static readonly DEFAULT_CONNECTION_TIMEOUT = 30;
21
22 static readonly DEFAULT_LOG_STATISTICS_INTERVAL = 60; // Seconds
23
24 static readonly DEFAULT_HEARTBEAT_INTERVAL = 60000; // Ms
25 static readonly DEFAULT_METER_VALUES_INTERVAL = 60000; // Ms
26
27 static readonly SUPPORTED_MEASURANDS = Object.freeze([
28 MeterValueMeasurand.STATE_OF_CHARGE,
29 MeterValueMeasurand.VOLTAGE,
30 MeterValueMeasurand.POWER_ACTIVE_IMPORT,
31 MeterValueMeasurand.CURRENT_IMPORT,
32 MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER,
33 ]);
34
35 static readonly DEFAULT_FLUCTUATION_PERCENT = 5;
36
37 static readonly DEFAULT_PERFORMANCE_RECORDS_FILENAME = 'performanceRecords.json';
38 static readonly DEFAULT_PERFORMANCE_RECORDS_DB_NAME = 'e-mobility-charging-stations-simulator';
39 static readonly PERFORMANCE_RECORDS_TABLE = 'performance_records';
40
41 static readonly DEFAULT_UI_SERVER_HOST = 'localhost';
42 static readonly DEFAULT_UI_SERVER_PORT = 8080;
43
44 static readonly UNKNOWN_COMMAND = 'unknown command';
45
46 static readonly MAX_RANDOM_INTEGER = 281474976710654;
47
48 static readonly EMPTY_FREEZED_OBJECT = Object.freeze({});
49 static readonly EMPTY_FUNCTION = Object.freeze(() => {
50 /* This is intentional */
51 });
52
53 private constructor() {
54 // This is intentional
55 }
56 }