import {
Constants,
cloneObject,
+ convertToDate,
formatDurationMilliSeconds,
getRandomInteger,
isValidTime,
private setStartConnectorStatus (connectorId: number): void {
const previousRunDuration =
isValidTime(this.connectorsStatus.get(connectorId)?.startDate) &&
- isValidTime(this.connectorsStatus.get(connectorId)?.lastRunDate)
+ isValidTime(this.connectorsStatus.get(connectorId)?.lastRunDate) &&
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.connectorsStatus.get(connectorId)!.lastRunDate! >
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.connectorsStatus.get(connectorId)!.startDate!
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.connectorsStatus.get(connectorId)!.lastRunDate!.getTime() -
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.chargingStation.getAutomaticTransactionGeneratorStatuses()![connectorId - 1]
)
: undefined
- this.resetConnectorStatus(connectorStatus)
+ if (connectorStatus != null) {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ connectorStatus.startDate = convertToDate(connectorStatus.startDate)!
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ connectorStatus.lastRunDate = convertToDate(connectorStatus.lastRunDate)!
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ connectorStatus.stopDate = convertToDate(connectorStatus.stopDate)!
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ connectorStatus.stoppedDate = convertToDate(connectorStatus.stoppedDate)!
+ if (
+ !this.started &&
+ (connectorStatus.start ||
+ this.chargingStation.getAutomaticTransactionGeneratorConfiguration()?.enable !== true)
+ ) {
+ connectorStatus.start = false
+ }
+ }
return (
connectorStatus ?? {
start: false,
)
}
- private resetConnectorStatus (connectorStatus: Status | undefined): void {
- if (connectorStatus == null) {
- return
- }
- if (
- !this.started &&
- (connectorStatus.start ||
- this.chargingStation.getAutomaticTransactionGeneratorConfiguration()?.enable !== true)
- ) {
- connectorStatus.start = false
- }
- }
-
private async startTransaction (
connectorId: number
): Promise<StartTransactionResponse | undefined> {
export const prepareChargingProfileKind = (
connectorStatus: ConnectorStatus,
chargingProfile: ChargingProfile,
- currentDate: Date,
+ currentDate: string | number | Date,
logPrefix: string
): boolean => {
switch (chargingProfile.chargingProfileKind) {
export const canProceedChargingProfile = (
chargingProfile: ChargingProfile,
- currentDate: Date,
+ currentDate: string | number | Date,
logPrefix: string
): boolean => {
if (
logger.debug(
`${logPrefix} ${moduleName}.canProceedChargingProfile: Charging profile id ${
chargingProfile.chargingProfileId
- } is not valid for the current date ${currentDate.toISOString()}`
+ } is not valid for the current date ${
+ currentDate instanceof Date ? currentDate.toISOString() : currentDate
+ }`
)
return false
}
*/
const prepareRecurringChargingProfile = (
chargingProfile: ChargingProfile,
- currentDate: Date,
+ currentDate: string | number | Date,
logPrefix: string
): boolean => {
const chargingSchedule = chargingProfile.chargingSchedule
).toISOString()}, ${toDate(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
recurringInterval!.end
- ).toISOString()}] has not been properly translated to current date ${currentDate.toISOString()} `
+ ).toISOString()}] has not been properly translated to current date ${
+ currentDate instanceof Date ? currentDate.toISOString() : currentDate
+ } `
)
}
return recurringIntervalTranslated
!prepareChargingProfileKind(
connectorStatus,
chargingProfile,
- compositeScheduleInterval.start as Date,
+ compositeScheduleInterval.start,
chargingStation.logPrefix()
)
) {
if (
!canProceedChargingProfile(
chargingProfile,
- compositeScheduleInterval.start as Date,
+ compositeScheduleInterval.start,
chargingStation.logPrefix()
)
) {