-import type { JsonType } from '@/types/JsonType';
-import { ProcedureName, ResponseStatus } from '@/types/UIProtocol';
+import { ProcedureName, ResponseStatus, type RequestPayload } from '@/types/UIProtocol';
import type { ProtocolResponse, ResponsePayload } from '@/types/UIProtocol';
import Utils from './Utils';
}
public async startChargingStation(hashId: string): Promise<ResponsePayload> {
- return this.sendRequest(ProcedureName.START_CHARGING_STATION, { hashId });
+ return this.sendRequest(ProcedureName.START_CHARGING_STATION, { hashIds: [hashId] });
}
public async stopChargingStation(hashId: string): Promise<ResponsePayload> {
- return this.sendRequest(ProcedureName.STOP_CHARGING_STATION, { hashId });
+ return this.sendRequest(ProcedureName.STOP_CHARGING_STATION, { hashIds: [hashId] });
}
public async openConnection(hashId: string): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.OPEN_CONNECTION, {
- hashId,
+ hashIds: [hashId],
});
}
public async closeConnection(hashId: string): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.CLOSE_CONNECTION, {
- hashId,
+ hashIds: [hashId],
});
}
idTag: string | undefined
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.START_TRANSACTION, {
- hashId,
+ hashIds: [hashId],
connectorId,
idTag,
});
transactionId: number | undefined
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.STOP_TRANSACTION, {
- hashId,
+ hashIds: [hashId],
transactionId,
});
}
+ public async startAutomaticTransactionGenerator(
+ hashId: string,
+ connectorId: number
+ ): Promise<ResponsePayload> {
+ return this.sendRequest(ProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR, {
+ hashIds: [hashId],
+ connectorIds: [connectorId],
+ });
+ }
+
+ public async stopAutomaticTransactionGenerator(
+ hashId: string,
+ connectorId: number
+ ): Promise<ResponsePayload> {
+ return this.sendRequest(ProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR, {
+ hashIds: [hashId],
+ connectorIds: [connectorId],
+ });
+ }
+
private openWS(): void {
this._ws = new WebSocket(
`ws://${config.uiServer.host}:${config.uiServer.port}`,
return this._responseHandlers.delete(id);
}
- private async sendRequest(command: ProcedureName, data: JsonType): Promise<ResponsePayload> {
+ private async sendRequest(
+ command: ProcedureName,
+ data: RequestPayload
+ ): Promise<ResponsePayload> {
let uuid: string;
return Utils.promiseWithTimeout(
new Promise((resolve, reject) => {