return connectorBootStatus;
}
+ public static checkTemplateFile(
+ stationTemplate: ChargingStationTemplate,
+ logPrefix: string,
+ templateFile: string
+ ) {
+ if (Utils.isNullOrUndefined(stationTemplate)) {
+ const errorMsg = `Failed to read charging station template file ${templateFile}`;
+ logger.error(`${logPrefix} ${errorMsg}`);
+ throw new BaseError(errorMsg);
+ }
+ if (Utils.isEmptyObject(stationTemplate)) {
+ const errorMsg = `Empty charging station information from template file ${templateFile}`;
+ logger.error(`${logPrefix} ${errorMsg}`);
+ throw new BaseError(errorMsg);
+ }
+ if (Utils.isEmptyObject(stationTemplate.AutomaticTransactionGenerator)) {
+ stationTemplate.AutomaticTransactionGenerator = {
+ enable: false,
+ minDuration: 60,
+ maxDuration: 120,
+ minDelayBetweenTwoTransactions: 15,
+ maxDelayBetweenTwoTransactions: 30,
+ probabilityOfStart: 1,
+ stopAfterHours: 0.3,
+ stopOnConnectionFailure: true,
+ };
+ logger.warn(
+ `${logPrefix} Empty automatic transaction generator configuration from template file ${templateFile}, set to default values`
+ );
+ }
+ }
+
public static checkConnectorsConfiguration(
- stationTemplate: ChargingStationTemplate | ChargingStationInfo,
- templateFile: string,
- logPrefix: string
+ stationTemplate: ChargingStationTemplate,
+ logPrefix: string,
+ templateFile: string
): {
configuredMaxConnectors: number;
templateMaxConnectors: number;
ChargingStationUtils.getConfiguredNumberOfConnectors(stationTemplate);
ChargingStationUtils.checkConfiguredMaxConnectors(
configuredMaxConnectors,
- templateFile,
- logPrefix
+ logPrefix,
+ templateFile
);
const templateMaxConnectors = ChargingStationUtils.getMaxNumberOfConnectors(
stationTemplate.Connectors
);
- ChargingStationUtils.checkTemplateMaxConnectors(templateMaxConnectors, templateFile, logPrefix);
+ ChargingStationUtils.checkTemplateMaxConnectors(templateMaxConnectors, logPrefix, templateFile);
const templateMaxAvailableConnectors = stationTemplate?.Connectors[0]
? templateMaxConnectors - 1
: templateMaxConnectors;
}
public static warnTemplateKeysDeprecation(
- templateFile: string,
stationTemplate: ChargingStationTemplate,
- logPrefix: string
+ logPrefix: string,
+ templateFile: string
) {
const templateKeys: { key: string; deprecatedKey: string }[] = [
{ key: 'supervisionUrls', deprecatedKey: 'supervisionUrl' },
ChargingStationUtils.warnDeprecatedTemplateKey(
stationTemplate,
templateKey.deprecatedKey,
- templateFile,
logPrefix,
+ templateFile,
`Use '${templateKey.key}' instead`
);
ChargingStationUtils.convertDeprecatedTemplateKey(
public static stationTemplateToStationInfo(
stationTemplate: ChargingStationTemplate
): ChargingStationInfo {
- stationTemplate = Utils.cloneObject(stationTemplate);
+ stationTemplate = Utils.cloneObject<ChargingStationTemplate>(stationTemplate);
delete stationTemplate.power;
delete stationTemplate.powerUnit;
+ delete stationTemplate?.Connectors;
+ delete stationTemplate?.Evses;
delete stationTemplate.Configuration;
delete stationTemplate.AutomaticTransactionGenerator;
delete stationTemplate.chargeBoxSerialNumberPrefix;
let limit: number, matchingChargingProfile: ChargingProfile;
// Get charging profiles for connector and sort by stack level
const chargingProfiles =
- Utils.cloneObject(chargingStation.getConnectorStatus(connectorId)?.chargingProfiles)?.sort(
- (a, b) => b.stackLevel - a.stackLevel
- ) ?? [];
+ Utils.cloneObject<ChargingProfile[]>(
+ chargingStation.getConnectorStatus(connectorId)?.chargingProfiles
+ )?.sort((a, b) => b.stackLevel - a.stackLevel) ?? [];
// Get profiles on connector 0
if (chargingStation.getConnectorStatus(0)?.chargingProfiles) {
chargingProfiles.push(
- ...Utils.cloneObject(chargingStation.getConnectorStatus(0).chargingProfiles).sort(
- (a, b) => b.stackLevel - a.stackLevel
- )
+ ...Utils.cloneObject<ChargingProfile[]>(
+ chargingStation.getConnectorStatus(0).chargingProfiles
+ ).sort((a, b) => b.stackLevel - a.stackLevel)
);
}
if (Utils.isNotEmptyArray(chargingProfiles)) {
public static getDefaultVoltageOut(
currentType: CurrentType,
- templateFile: string,
- logPrefix: string
+ logPrefix: string,
+ templateFile: string
): Voltage {
const errorMsg = `Unknown ${currentType} currentOutType in template file ${templateFile}, cannot define default voltage out`;
let defaultVoltageOut: number;
);
}
- private static getConfiguredNumberOfConnectors(
- stationTemplate: ChargingStationTemplate | ChargingStationInfo
- ): number {
+ private static getConfiguredNumberOfConnectors(stationTemplate: ChargingStationTemplate): number {
let configuredMaxConnectors: number;
if (Utils.isNotEmptyArray(stationTemplate.numberOfConnectors) === true) {
const numberOfConnectors = stationTemplate.numberOfConnectors as number[];
private static checkConfiguredMaxConnectors(
configuredMaxConnectors: number,
- templateFile: string,
- logPrefix: string
+ logPrefix: string,
+ templateFile: string
): void {
if (configuredMaxConnectors <= 0) {
logger.warn(
private static checkTemplateMaxConnectors(
templateMaxConnectors: number,
- templateFile: string,
- logPrefix: string
+ logPrefix: string,
+ templateFile: string
): void {
if (templateMaxConnectors === 0) {
logger.warn(
private static warnDeprecatedTemplateKey(
template: ChargingStationTemplate,
key: string,
- templateFile: string,
logPrefix: string,
+ templateFile: string,
logMsgToAppend = ''
): void {
if (!Utils.isUndefined(template[key])) {