| 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 | 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, |
| 34 | stopTransactionsOnStopped: true |
| 35 | }) |
| 36 | |
| 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 |
| 40 | |
| 41 | static readonly DEFAULT_CHARGING_STATION_RESET_TIME = 60000 // Ms |
| 42 | |
| 43 | static readonly DEFAULT_ATG_WAIT_TIME = 1000 // Ms |
| 44 | static readonly DEFAULT_ATG_CONFIGURATION: AutomaticTransactionGeneratorConfiguration = |
| 45 | Object.freeze({ |
| 46 | enable: false, |
| 47 | minDuration: 60, |
| 48 | maxDuration: 120, |
| 49 | minDelayBetweenTwoTransactions: 15, |
| 50 | maxDelayBetweenTwoTransactions: 30, |
| 51 | probabilityOfStart: 1, |
| 52 | stopAfterHours: 0.25, |
| 53 | stopAbsoluteDuration: false |
| 54 | }) |
| 55 | |
| 56 | // See https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string |
| 57 | static readonly SEMVER_PATTERN = |
| 58 | '^(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-]+)*))?$' |
| 59 | |
| 60 | static readonly DEFAULT_CIRCULAR_BUFFER_CAPACITY = 4096 |
| 61 | |
| 62 | static readonly DEFAULT_HASH_ALGORITHM = 'sha384' |
| 63 | |
| 64 | static readonly DEFAULT_IDTAG = '00000000' |
| 65 | |
| 66 | static readonly DEFAULT_CONNECTION_TIMEOUT = 30 |
| 67 | |
| 68 | static readonly DEFAULT_LOG_STATISTICS_INTERVAL = 60 // Seconds |
| 69 | |
| 70 | static readonly DEFAULT_FLUCTUATION_PERCENT = 5 |
| 71 | |
| 72 | static readonly DEFAULT_PERFORMANCE_DIRECTORY = 'performance' |
| 73 | static readonly DEFAULT_PERFORMANCE_RECORDS_FILENAME = 'performanceRecords.json' |
| 74 | static readonly DEFAULT_PERFORMANCE_RECORDS_DB_NAME = 'e-mobility-charging-stations-simulator' |
| 75 | static readonly PERFORMANCE_RECORDS_TABLE = 'performance_records' |
| 76 | |
| 77 | static readonly DEFAULT_UI_SERVER_HOST = 'localhost' |
| 78 | static readonly DEFAULT_UI_SERVER_PORT = 8080 |
| 79 | |
| 80 | static readonly UNKNOWN_COMMAND = 'unknown command' as RequestCommand | IncomingRequestCommand |
| 81 | |
| 82 | static readonly MAX_RANDOM_INTEGER = 281474976710654 |
| 83 | |
| 84 | static readonly STOP_CHARGING_STATIONS_TIMEOUT = 60000 // Ms |
| 85 | |
| 86 | static readonly EMPTY_FROZEN_OBJECT = Object.freeze({}) |
| 87 | static readonly EMPTY_FUNCTION = Object.freeze(() => { |
| 88 | /* This is intentional */ |
| 89 | }) |
| 90 | |
| 91 | static readonly DEFAULT_MESSAGE_BUFFER_FLUSH_INTERVAL = 60000 // Ms |
| 92 | |
| 93 | private constructor () { |
| 94 | // This is intentional |
| 95 | } |
| 96 | } |