refactor(simulator): add more default values to ATG
[e-mobility-charging-stations-simulator.git] / src / utils / Constants.ts
1 import type { AutomaticTransactionGeneratorConfiguration } from '../types';
2
3 export class Constants {
4 static readonly DEFAULT_BOOT_NOTIFICATION_INTERVAL = 60000; // Ms
5 static readonly DEFAULT_HEARTBEAT_INTERVAL = 60000; // Ms
6 static readonly DEFAULT_METER_VALUES_INTERVAL = 60000; // Ms
7
8 static readonly CHARGING_STATION_DEFAULT_RESET_TIME = 60000; // Ms
9 static readonly CHARGING_STATION_ATG_INITIALIZATION_TIME = 1000; // Ms
10
11 static readonly DEFAULT_ATG_MIN_DURATION = 60;
12 static readonly DEFAULT_ATG_MAX_DURATION = 120;
13 static readonly DEFAULT_ATG_MIN_DELAY_BETWEEN_TWO_TRANSACTIONS = 15;
14 static readonly DEFAULT_ATG_MAX_DELAY_BETWEEN_TWO_TRANSACTIONS = 30;
15 static readonly DEFAULT_ATG_STOP_AFTER_HOURS = 0.25; // Hours
16 static readonly DEFAULT_ATG_CONFIGURATION: AutomaticTransactionGeneratorConfiguration =
17 Object.freeze({
18 enable: false,
19 minDuration: Constants.DEFAULT_ATG_MIN_DURATION,
20 maxDuration: Constants.DEFAULT_ATG_MAX_DURATION,
21 minDelayBetweenTwoTransactions: Constants.DEFAULT_ATG_MIN_DELAY_BETWEEN_TWO_TRANSACTIONS,
22 maxDelayBetweenTwoTransactions: Constants.DEFAULT_ATG_MAX_DELAY_BETWEEN_TWO_TRANSACTIONS,
23 probabilityOfStart: 1,
24 stopAfterHours: Constants.DEFAULT_ATG_STOP_AFTER_HOURS,
25 stopOnConnectionFailure: true,
26 });
27
28 // See https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
29 static readonly SEMVER_PATTERN =
30 '^(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-]+)*))?$';
31
32 static readonly DEFAULT_CIRCULAR_BUFFER_CAPACITY = 1024;
33
34 static readonly DEFAULT_HASH_ALGORITHM = 'sha384';
35
36 static readonly DEFAULT_IDTAG = '00000000';
37
38 static readonly DEFAULT_CONNECTION_TIMEOUT = 30;
39
40 static readonly DEFAULT_LOG_STATISTICS_INTERVAL = 60; // Seconds
41
42 static readonly DEFAULT_FLUCTUATION_PERCENT = 5;
43
44 static readonly DEFAULT_PERFORMANCE_RECORDS_FILENAME = 'performanceRecords.json';
45 static readonly DEFAULT_PERFORMANCE_RECORDS_DB_NAME = 'e-mobility-charging-stations-simulator';
46 static readonly PERFORMANCE_RECORDS_TABLE = 'performance_records';
47
48 static readonly DEFAULT_UI_SERVER_HOST = 'localhost';
49 static readonly DEFAULT_UI_SERVER_PORT = 8080;
50
51 static readonly UNKNOWN_COMMAND = 'unknown command';
52
53 static readonly MAX_RANDOM_INTEGER = 281474976710654;
54
55 static readonly EMPTY_FREEZED_OBJECT = Object.freeze({});
56 static readonly EMPTY_FUNCTION = Object.freeze(() => {
57 /* This is intentional */
58 });
59
60 private constructor() {
61 // This is intentional
62 }
63 }