{
"$schema": "https://json.schemastore.org/prettierrc",
"printWidth": 100,
- "semi": false,
+ "arrowParens": "avoid",
"singleQuote": true,
+ "semi": false,
"trailingComma": "none"
}
exit(exitCodes.gracefulShutdownError)
})
})
- .catch((error) => {
+ .catch(error => {
console.error(chalk.red('Error while shutdowning charging stations simulator: '), error)
exit(exitCodes.gracefulShutdownError)
})
this.heartbeatSetInterval = setInterval(() => {
this.ocppRequestService
.requestHandler<HeartbeatRequest, HeartbeatResponse>(this, RequestCommand.HEARTBEAT)
- .catch((error) => {
+ .catch(error => {
logger.error(
`${this.logPrefix()} Error while sending '${RequestCommand.HEARTBEAT}':`,
error
meterValue: [meterValue]
}
)
- .catch((error) => {
+ .catch(error => {
logger.error(
`${this.logPrefix()} Error while sending '${RequestCommand.METER_VALUES}':`,
error
this.initializeOcppConfiguration()
this.initializeOcppServices()
this.once(ChargingStationEvents.accepted, () => {
- this.startMessageSequence().catch((error) => {
+ this.startMessageSequence().catch(error => {
logger.error(`${this.logPrefix()} Error while starting the message sequence:`, error)
})
})
this.sharedLRUCache.deleteChargingStationConfiguration(this.configurationFileHash)
this.sharedLRUCache.setChargingStationConfiguration(configurationData)
this.configurationFileHash = configurationHash
- }).catch((error) => {
+ }).catch(error => {
handleFileException(
this.configurationFile,
FileType.ChargingStationConfiguration,
key: ConfigurationKeyType,
caseInsensitive = false
): ConfigurationKey | undefined => {
- return chargingStation.ocppConfiguration?.configurationKey?.find((configElement) => {
+ return chargingStation.ocppConfiguration?.configurationKey?.find(configElement => {
if (caseInsensitive) {
return configElement.key.toLowerCase() === key.toLowerCase()
}
connectorStatus.chargingProfiles =
connectorStatus.transactionId != null && isNotEmptyArray(connectorStatus.chargingProfiles)
? connectorStatus.chargingProfiles?.filter(
- (chargingProfile) => chargingProfile.transactionId !== connectorStatus.transactionId
+ chargingProfile => chargingProfile.transactionId !== connectorStatus.transactionId
)
: []
connectorStatus.idTagLocalAuthorized = false
event: ChargingStationWorkerMessageEvents,
eventsToWait: number
): Promise<number> => {
- return await new Promise<number>((resolve) => {
+ return await new Promise<number>(resolve => {
let events = 0
if (eventsToWait === 0) {
resolve(events)
deleted.push(this.idTagsCachesAddressableIndexes.delete(key))
}
}
- return !deleted.some((value) => !value)
+ return !deleted.some(value => !value)
}
private getIdTagsCacheIndexesAddressableKey (prefix: string, uid: string): string {
}
return undefined
})
- .filter((hashId) => hashId != null) as string[],
+ .filter(hashId => hashId != null) as string[],
...(responsesStatus === ResponseStatus.FAILURE && {
hashIdsFailed: this.responses
.get(uuid)
}
return undefined
})
- .filter((hashId) => hashId != null) as string[]
+ .filter(hashId => hashId != null) as string[]
}),
...(responsesStatus === ResponseStatus.FAILURE && {
responsesFailed: this.responses
.get(uuid)
- ?.responses.map((response) => {
+ ?.responses.map(response => {
if (response.status === ResponseStatus.FAILURE) {
return response
}
return undefined
})
- .filter((response) => response != null) as BroadcastChannelResponsePayload[]
+ .filter(response => response != null) as BroadcastChannelResponsePayload[]
})
}
}
let ftpClient: Client | undefined
try {
const logFiles = readdirSync(resolve(dirname(fileURLToPath(import.meta.url)), '../'))
- .filter((file) => file.endsWith('.log'))
- .map((file) => join('./', file))
+ .filter(file => file.endsWith('.log'))
+ .map(file => join('./', file))
const diagnosticsArchive = `${chargingStation.stationInfo?.chargingStationId}_logs.tar.gz`
create({ gzip: true }, logFiles).pipe(createWriteStream(diagnosticsArchive))
ftpClient = new Client()
})
let uploadResponse: FTPResponse | undefined
if (accessResponse.code === 220) {
- ftpClient.trackProgress((info) => {
+ ftpClient.trackProgress(info => {
logger.info(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: ${
info.bytes / 1024
>(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
status: OCPP16DiagnosticsStatus.Uploading
})
- .catch((error) => {
+ .catch(error => {
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: Error while sending '${
OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION
chargingStation.bootNotificationRequest,
{ skipBufferingOnError: true, triggerMessage: true }
)
- .then((response) => {
+ .then(response => {
chargingStation.bootNotificationResponse = response
})
.catch(Constants.EMPTY_FUNCTION)
),
chargingSchedulePeriod: [
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map((schedulePeriod) => {
+ ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map(schedulePeriod => {
return {
...schedulePeriod,
startPeriod: higherFirst
}
}),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ...compositeChargingScheduleLower!.chargingSchedulePeriod.map((schedulePeriod) => {
+ ...compositeChargingScheduleLower!.chargingSchedulePeriod.map(schedulePeriod => {
return {
...schedulePeriod,
startPeriod: higherFirst
),
chargingSchedulePeriod: [
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map((schedulePeriod) => {
+ ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map(schedulePeriod => {
return {
...schedulePeriod,
startPeriod: higherFirst
compositeInterval.end as Date,
chargingScheduleInterval.start
),
- chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter((schedulePeriod) =>
+ chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter(schedulePeriod =>
isWithinInterval(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!,
chargingStation.idTagsCache
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
.getIdTags(getIdTagsFile(chargingStation.stationInfo!)!)
- ?.find((tag) => tag === idTag)
+ ?.find(tag => tag === idTag)
)
)
}
if (
(connectorId === 0 &&
OCPP16Constants.ChargePointStatusChargingStationTransitions.findIndex(
- (transition) => transition.from === fromStatus && transition.to === status
+ transition => transition.from === fromStatus && transition.to === status
) !== -1) ||
(connectorId > 0 &&
OCPP16Constants.ChargePointStatusConnectorTransitions.findIndex(
- (transition) => transition.from === fromStatus && transition.to === status
+ transition => transition.from === fromStatus && transition.to === status
) !== -1)
) {
transitionAllowed = true
if (
(connectorId === 0 &&
OCPP20Constants.ChargingStationStatusTransitions.findIndex(
- (transition) => transition.from === fromStatus && transition.to === status
+ transition => transition.from === fromStatus && transition.to === status
) !== -1) ||
(connectorId > 0 &&
OCPP20Constants.ConnectorStatusTransitions.findIndex(
- (transition) => transition.from === fromStatus && transition.to === status
+ transition => transition.from === fromStatus && transition.to === status
) !== -1)
) {
transitionAllowed = true
}
private requestListener (req: IncomingMessage, res: ServerResponse): void {
- this.authenticate(req, (err) => {
+ this.authenticate(req, err => {
if (err != null) {
res
.writeHead(StatusCodes.UNAUTHORIZED, {
throw new BaseError(`Unsupported UI protocol version: '${fullProtocol}'`)
}
this.registerProtocolVersionUIService(version)
- req.on('error', (error) => {
+ req.on('error', error => {
logger.error(
`${this.logPrefix(moduleName, 'requestListener.req.onerror')} Error on HTTP request:`,
error
}
const [, version] = UIServerUtils.getProtocolAndVersion(ws.protocol)
this.registerProtocolVersionUIService(version)
- ws.on('message', (rawData) => {
+ ws.on('message', rawData => {
const request = this.validateRawDataRequest(rawData)
if (request === false) {
ws.close(WebSocketCloseEventStatusCode.CLOSE_INVALID_PAYLOAD)
})
.catch(Constants.EMPTY_FUNCTION)
})
- ws.on('error', (error) => {
+ ws.on('error', error => {
logger.error(`${this.logPrefix(moduleName, 'start.ws.onerror')} WebSocket error:`, error)
})
ws.on('close', (code, reason) => {
}
})
this.httpServer.on('upgrade', (req: IncomingMessage, socket: Duplex, head: Buffer): void => {
- this.authenticate(req, (err) => {
+ this.authenticate(req, err => {
if (err != null) {
socket.write(`HTTP/1.1 ${StatusCodes.UNAUTHORIZED} Unauthorized\r\n\r\n`)
socket.destroy()
): void {
if (isNotEmptyArray(payload.hashIds)) {
payload.hashIds = payload.hashIds
- ?.map((hashId) => {
+ ?.map(hashId => {
if (this.uiServer.chargingStations.has(hashId)) {
return hashId
}
)
return undefined
})
- .filter((hashId) => hashId != null) as string[]
+ .filter(hashId => hashId != null) as string[]
} else {
delete payload.hashIds
}
}
private initializePerformanceObserver (): void {
- this.performanceObserver = new PerformanceObserver((performanceObserverList) => {
+ this.performanceObserver = new PerformanceObserver(performanceObserverList => {
const lastPerformanceEntry = performanceObserverList.getEntries()[0]
// logger.debug(
// `${this.logPrefix()} '${lastPerformanceEntry.name}' performance entry: %j`,
0,
'utf8'
)
- }).catch((error) => {
+ }).catch(error => {
handleFileException(
this.dbName,
FileType.PerformanceRecords,
asyncLock.acquired = true
return
}
- await new Promise<void>((resolve) => {
+ await new Promise<void>(resolve => {
asyncLock.resolveQueue.enqueue(resolve)
})
}
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const queuedResolve = asyncLock.resolveQueue.dequeue()!
- await new Promise<void>((resolve) => {
+ await new Promise<void>(resolve => {
queuedResolve()
resolve()
})
outputFormat: OutputFormat = OutputFormat.configuration
): Array<EvseStatusWorkerType | EvseStatusConfiguration> => {
// eslint-disable-next-line array-callback-return
- return [...chargingStation.evses.values()].map((evseStatus) => {
+ return [...chargingStation.evses.values()].map(evseStatus => {
const connectorsStatus = [...evseStatus.connectors.values()].map(
({ transactionSetInterval, ...connectorStatusRest }) => connectorStatusRest
)
Configuration.configurationSectionCache.clear()
if (Configuration.configurationChangeCallback !== undefined) {
Configuration.configurationChangeCallback()
- .catch((error) => {
+ .catch(error => {
throw typeof error === 'string' ? new Error(error) : error
})
.finally(() => {
}
export const sleep = async (milliSeconds: number): Promise<NodeJS.Timeout> => {
- return await new Promise<NodeJS.Timeout>((resolve) =>
+ return await new Promise<NodeJS.Timeout>(resolve =>
setTimeout(resolve as () => void, milliSeconds)
)
}
}
export const extractTimeSeriesValues = (timeSeries: TimestampedData[]): number[] => {
- return timeSeries.map((timeSeriesItem) => timeSeriesItem.value)
+ return timeSeries.map(timeSeriesItem => timeSeriesItem.value)
}
export const isObject = (item: unknown): boolean => {
public async stop (): Promise<void> {
for (const workerSetElement of this.workerSet) {
const worker = workerSetElement.worker
- const waitWorkerExit = new Promise<void>((resolve) => {
+ const waitWorkerExit = new Promise<void>(resolve => {
worker.once('exit', () => {
resolve()
})
}
})
worker.on('error', this.workerOptions.poolOptions?.errorHandler ?? EMPTY_FUNCTION)
- worker.on('error', (error) => {
+ worker.on('error', error => {
this.emitter?.emit(WorkerSetEvents.error, error)
if (
this.workerOptions.poolOptions?.restartWorkerOnError === true &&
import chalk from 'chalk'
export const sleep = async (milliSeconds: number): Promise<NodeJS.Timeout> => {
- return await new Promise<NodeJS.Timeout>((resolve) =>
+ return await new Promise<NodeJS.Timeout>(resolve =>
setTimeout(resolve as () => void, milliSeconds)
)
}
root: true,
env: {
- node: true,
+ node: true
},
plugins: ['import'],
'plugin:import/recommended',
'plugin:vue/vue3-recommended',
'@vue/eslint-config-typescript/recommended',
- '@vue/eslint-config-prettier',
+ '@vue/eslint-config-prettier'
],
settings: {
'import/resolver': {
typescript: {
- project: './tsconfig.json',
- },
- },
+ project: './tsconfig.json'
+ }
+ }
},
parserOptions: {
- ecmaVersion: 'latest',
+ ecmaVersion: 'latest'
},
rules: {
'sort-imports': [
'error',
{
- ignoreDeclarationSort: true,
- },
+ ignoreDeclarationSort: true
+ }
],
- 'import/order': 'error',
- },
+ 'import/order': 'error'
+ }
})
export default {
'*.{.css,json,md,yml,yaml,html,js,jsx,cjs,mjs,ts,tsx,cts,mts}': 'prettier --cache --write',
'*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}':
- 'eslint . --cache --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore',
+ 'eslint . --cache --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore'
}
{
"$schema": "https://json.schemastore.org/prettierrc",
"printWidth": 100,
- "semi": false,
+ "arrowParens": "avoid",
"singleQuote": true,
+ "semi": false,
"trailingComma": "none"
}
uiServer: {
host: 'localhost',
port: 8080,
- protocol: 'ui0.0.1',
- },
+ protocol: 'ui0.0.1'
+ }
}
export default config
type ProtocolResponse,
type RequestPayload,
type ResponsePayload,
- ResponseStatus,
+ ResponseStatus
} from '@/types'
import config from '@/assets/config'
public async openConnection(hashId: string): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.OPEN_CONNECTION, {
- hashIds: [hashId],
+ hashIds: [hashId]
})
}
public async closeConnection(hashId: string): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.CLOSE_CONNECTION, {
- hashIds: [hashId],
+ hashIds: [hashId]
})
}
return this.sendRequest(ProcedureName.START_TRANSACTION, {
hashIds: [hashId],
connectorId,
- idTag,
+ idTag
})
}
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.STOP_TRANSACTION, {
hashIds: [hashId],
- transactionId,
+ transactionId
})
}
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR, {
hashIds: [hashId],
- connectorIds: [connectorId],
+ connectorIds: [connectorId]
})
}
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR, {
hashIds: [hashId],
- connectorIds: [connectorId],
+ connectorIds: [connectorId]
})
}
config.uiServer.protocol
)
this.ws.onmessage = this.responseHandler.bind(this)
- this.ws.onerror = (errorEvent) => {
+ this.ws.onerror = errorEvent => {
console.error('WebSocket error: ', errorEvent)
}
- this.ws.onclose = (closeEvent) => {
+ this.ws.onclose = closeEvent => {
console.info('WebSocket closed: ', closeEvent)
}
}
{
path: '/',
name: 'charging-stations',
- component: ChargingStationsView,
- },
+ component: ChargingStationsView
+ }
]
const router = createRouter({
history: createWebHistory(),
- routes,
+ routes
})
export default router
Idle = 'Idle',
InstallationFailed = 'InstallationFailed',
Installing = 'Installing',
- Installed = 'Installed',
+ Installed = 'Installed'
}
export const FirmwareStatus = {
- ...OCPP16FirmwareStatus,
+ ...OCPP16FirmwareStatus
} as const
export type FirmwareStatus = OCPP16FirmwareStatus
REMOTE_START_TRANSACTION = 'RemoteStartTransaction',
REMOTE_STOP_TRANSACTION = 'RemoteStopTransaction',
GET_DIAGNOSTICS = 'GetDiagnostics',
- TRIGGER_MESSAGE = 'TriggerMessage',
+ TRIGGER_MESSAGE = 'TriggerMessage'
}
export const IncomingRequestCommand = {
- ...OCPP16IncomingRequestCommand,
+ ...OCPP16IncomingRequestCommand
} as const
export type IncomingRequestCommand = OCPP16IncomingRequestCommand
START_TRANSACTION = 'StartTransaction',
STOP_TRANSACTION = 'StopTransaction',
METER_VALUES = 'MeterValues',
- DIAGNOSTICS_STATUS_NOTIFICATION = 'DiagnosticsStatusNotification',
+ DIAGNOSTICS_STATUS_NOTIFICATION = 'DiagnosticsStatusNotification'
}
export const RequestCommand = {
- ...OCPP16RequestCommand,
+ ...OCPP16RequestCommand
} as const
export type RequestCommand = OCPP16RequestCommand
export enum OCPP16RegistrationStatus {
ACCEPTED = 'Accepted',
PENDING = 'Pending',
- REJECTED = 'Rejected',
+ REJECTED = 'Rejected'
}
export interface OCPP16BootNotificationResponse extends JsonObject {
FirmwareStatusNotification = 'FirmwareStatusNotification',
Heartbeat = 'Heartbeat',
MeterValues = 'MeterValues',
- StatusNotification = 'StatusNotification',
+ StatusNotification = 'StatusNotification'
}
export const MessageTrigger = {
- ...OCPP16MessageTrigger,
+ ...OCPP16MessageTrigger
} as const
export type MessageTrigger = OCPP16MessageTrigger
export enum OCPPVersion {
VERSION_16 = '1.6',
- VERSION_20 = '2.0',
+ VERSION_20 = '2.0'
}
export enum OCPPProtocol {
- JSON = 'json',
+ JSON = 'json'
}
export enum CurrentType {
AC = 'AC',
- DC = 'DC',
+ DC = 'DC'
}
export enum Voltage {
VOLTAGE_110 = 110,
VOLTAGE_230 = 230,
VOLTAGE_400 = 400,
- VOLTAGE_800 = 800,
+ VOLTAGE_800 = 800
}
export enum AmpereUnits {
MILLI_AMPERE = 'mA',
CENTI_AMPERE = 'cA',
DECI_AMPERE = 'dA',
- AMPERE = 'A',
+ AMPERE = 'A'
}
export type ConnectorStatus = {
export enum OCPP16AvailabilityType {
INOPERATIVE = 'Inoperative',
- OPERATIVE = 'Operative',
+ OPERATIVE = 'Operative'
}
export type AvailabilityType = OCPP16AvailabilityType
FINISHING = 'Finishing',
RESERVED = 'Reserved',
UNAVAILABLE = 'Unavailable',
- FAULTED = 'Faulted',
+ FAULTED = 'Faulted'
}
export type ChargePointStatus = OCPP16ChargePointStatus
import type { JsonObject } from './JsonType'
export enum Protocol {
- UI = 'ui',
+ UI = 'ui'
}
export enum ApplicationProtocol {
HTTP = 'http',
- WS = 'ws',
+ WS = 'ws'
}
export enum ProtocolVersion {
- '0.0.1' = '0.0.1',
+ '0.0.1' = '0.0.1'
}
export type ProtocolRequest = [string, ProcedureName, RequestPayload]
START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator',
STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator',
START_TRANSACTION = 'startTransaction',
- STOP_TRANSACTION = 'stopTransaction',
+ STOP_TRANSACTION = 'stopTransaction'
}
export interface RequestPayload extends JsonObject {
export enum ResponseStatus {
SUCCESS = 'success',
- FAILURE = 'failure',
+ FAILURE = 'failure'
}
export interface ResponsePayload extends JsonObject {
export type {
ChargingStationData,
ChargingStationInfo,
- ConnectorStatus,
+ ConnectorStatus
} from './ChargingStationType'
export type { BaseConfig } from './ConfigurationType'
export {
type ProtocolResponse,
type RequestPayload,
type ResponsePayload,
- ResponseStatus,
+ ResponseStatus
} from './UIProtocol'
const state: State = reactive({
isLoading: false,
chargingStations: [],
- idTag: '',
+ idTag: ''
})
async function load(): Promise<void> {
test('renders CS table columns name', () => {
const chargingStations: ChargingStationData[] = []
const wrapper = shallowMount(CSTable, {
- props: { chargingStations, idTag: '0' },
+ props: { chargingStations, idTag: '0' }
})
expect(wrapper.text()).to.include('Action')
expect(wrapper.text()).to.include('Connector')
plugins: [vue(), vueJsx()],
resolve: {
alias: {
- '@': fileURLToPath(new URL('./src', import.meta.url)),
- },
- },
+ '@': fileURLToPath(new URL('./src', import.meta.url))
+ }
+ }
})
root: fileURLToPath(new URL('./', import.meta.url)),
coverage: {
provider: 'v8',
- reporter: ['text', 'lcov'],
- },
- },
+ reporter: ['text', 'lcov']
+ }
+ }
})
)