Adding additional IDs to WSConnection and related files
MODIFY
src/client/ocpp/ChargingStationClientFactory.ts
src/client/ocpp/ChargingStationClientFactory.ts
@@ -22,7 +22,12 @@ export default class ChargingStationClientFactory {
case OCPPProtocol.JSON:
// Get the client from Json Server
if (global.centralSystemJsonServer) {
- chargingClient = global.centralSystemJsonServer.getChargingStationClient(tenant.id, chargingStation.id);
+ chargingClient = global.centralSystemJsonServer.getChargingStationClient(tenant.id, {
+ chargingStationID: chargingStation.id,
+ siteAreaID: chargingStation.siteAreaID,
+ siteID: chargingStation.siteID,
+ companyID: chargingStation.companyID,
+ });
}
// Not Found
if (!chargingClient) {

MODIFY
src/server/ocpp/json/JsonCentralSystemServer.ts
src/server/ocpp/json/JsonCentralSystemServer.ts
@@ -45,13 +45,22 @@ export default class JsonCentralSystemServer extends CentralSystemServer {
this.startWSServer();
}
- public getChargingStationClient(tenantID: string, chargingStationID: string): ChargingStationClient {
+ public getChargingStationClient(tenantID: string, chargingStationDetails: {
+ chargingStationID: string,
+ siteID: string,
+ siteAreaID: string,
+ companyID: string
+ }): ChargingStationClient {
// Get the Json Web Socket
- const jsonWebSocket = this.jsonChargingStationClients.get(`${tenantID}~${chargingStationID}`);
+ const jsonWebSocket = this.jsonChargingStationClients.get(`${tenantID}~${chargingStationDetails.chargingStationID}`);
if (!jsonWebSocket) {
void Logging.logError({
tenantID: tenantID,
- source: chargingStationID,
+ siteID: chargingStationDetails.siteID,
+ siteAreaID: chargingStationDetails.siteAreaID,
+ companyID: chargingStationDetails.companyID,
+ chargeBoxID: chargingStationDetails.chargingStationID,
+ source: chargingStationDetails.chargingStationID,
module: MODULE_NAME, method: 'getChargingStationClient',
action: ServerAction.WS_CONNECTION,
message: 'No open WebSocket connection found'
@@ -176,6 +185,10 @@ export default class JsonCentralSystemServer extends CentralSystemServer {
if (!jsonWSConnection.isConnectionAlive) {
void Logging.logError({
tenantID: jsonWSConnection.getTenantID(),
+ siteID: jsonWSConnection.getSiteID(),
+ siteAreaID: jsonWSConnection.getSiteAreaID(),
+ companyID: jsonWSConnection.getCompanyID(),
+ chargeBoxID: jsonWSConnection.getChargingStationID(),
source: jsonWSConnection.getChargingStationID(),
action: ServerAction.WS_JSON_CONNECTION_CLOSED,
module: MODULE_NAME, method: 'createWSServer',

MODIFY
src/server/ocpp/json/JsonRestWSConnection.ts
src/server/ocpp/json/JsonRestWSConnection.ts
@@ -73,7 +73,12 @@ export default class JsonRestWSConnection extends WSConnection {
});
}
// Get the client from JSON Server
- const chargingStationClient: ChargingStationClient = global.centralSystemJsonServer.getChargingStationClient(this.getTenantID(), this.getChargingStationID());
+ const chargingStationClient: ChargingStationClient = global.centralSystemJsonServer.getChargingStationClient(this.getTenantID(), {
+ chargingStationID: this.getChargingStationID(),
+ siteAreaID: this.getSiteAreaID(),
+ siteID: this.getSiteID(),
+ companyID: this.getCompanyID()
+ });
if (!chargingStationClient) {
throw new BackendError({
source: this.getChargingStationID(),

MODIFY
src/server/ocpp/json/JsonWSConnection.ts
src/server/ocpp/json/JsonWSConnection.ts
@@ -105,6 +105,10 @@ export default class JsonWSConnection extends WSConnection {
this.initialized = true;
await Logging.logInfo({
tenantID: this.getTenantID(),
+ siteID: this.getSiteID(),
+ siteAreaID: this.getSiteAreaID(),
+ companyID: this.getCompanyID(),
+ chargeBoxID: this.getChargingStationID(),
source: this.getChargingStationID(),
action: ServerAction.WS_JSON_CONNECTION_OPENED,
module: MODULE_NAME, method: 'initialize',
@@ -116,6 +120,10 @@ export default class JsonWSConnection extends WSConnection {
public onError(errorEvent: ErrorEvent): void {
void Logging.logError({
tenantID: this.getTenantID(),
+ siteID: this.getSiteID(),
+ siteAreaID: this.getSiteAreaID(),
+ companyID: this.getCompanyID(),
+ chargeBoxID: this.getChargingStationID(),
source: this.getChargingStationID(),
action: ServerAction.WS_JSON_CONNECTION_ERROR,
module: MODULE_NAME, method: 'onError',
@@ -127,6 +135,10 @@ export default class JsonWSConnection extends WSConnection {
public onClose(closeEvent: CloseEvent): void {
void Logging.logInfo({
tenantID: this.getTenantID(),
+ siteID: this.getSiteID(),
+ siteAreaID: this.getSiteAreaID(),
+ companyID: this.getCompanyID(),
+ chargeBoxID: this.getChargingStationID(),
source: this.getChargingStationID(),
action: ServerAction.WS_JSON_CONNECTION_CLOSED,
module: MODULE_NAME, method: 'onClose',
@@ -138,6 +150,10 @@ export default class JsonWSConnection extends WSConnection {
public async onPing(): Promise<void> {
void Logging.logDebug({
tenantID: this.getTenantID(),
+ siteID: this.getSiteID(),
+ siteAreaID: this.getSiteAreaID(),
+ companyID: this.getCompanyID(),
+ chargeBoxID: this.getChargingStationID(),
source: this.getChargingStationID(),
action: ServerAction.WS_JSON_CONNECTION_PINGED,
module: MODULE_NAME, method: 'onPing',
@@ -150,6 +166,10 @@ export default class JsonWSConnection extends WSConnection {
this.isConnectionAlive = true;
void Logging.logDebug({
tenantID: this.getTenantID(),
+ siteID: this.getSiteID(),
+ siteAreaID: this.getSiteAreaID(),
+ companyID: this.getCompanyID(),
+ chargeBoxID: this.getChargingStationID(),
source: this.getChargingStationID(),
action: ServerAction.WS_JSON_CONNECTION_PONGED,
module: MODULE_NAME, method: 'onPong',
@@ -188,6 +208,10 @@ export default class JsonWSConnection extends WSConnection {
if (!this.isWSConnectionOpen()) {
void Logging.logError({
tenantID: this.getTenantID(),
+ siteID: this.getSiteID(),
+ siteAreaID: this.getSiteAreaID(),
+ companyID: this.getCompanyID(),
+ chargeBoxID: this.getChargingStationID(),
source: this.getChargingStationID(),
module: MODULE_NAME, method: 'getChargingStationClient',
action: ServerAction.WS_CONNECTION,

MODIFY
src/server/ocpp/json/WSConnection.ts
src/server/ocpp/json/WSConnection.ts
@@ -20,6 +20,9 @@ const MODULE_NAME = 'WSConnection';
export default abstract class WSConnection {
protected initialized: boolean;
protected wsServer: JsonCentralSystemServer;
+ private siteID: string;
+ private siteAreaID: string;
+ private companyID: string;
private chargingStationID: string;
private tenantID: string;
private tenant: Tenant;
@@ -84,6 +87,10 @@ export default abstract class WSConnection {
}
void Logging.logDebug({
tenantID: this.tenantID,
+ siteID: this.siteID,
+ siteAreaID: this.siteAreaID,
+ companyID: this.companyID,
+ chargeBoxID: this.chargingStationID,
source: this.chargingStationID,
action: action,
module: MODULE_NAME, method: 'constructor',
@@ -320,6 +327,18 @@ export default abstract class WSConnection {
});
}
+ public getSiteID(): string {
+ return this.siteID;
+ }
+
+ public getSiteAreaID(): string {
+ return this.siteAreaID;
+ }
+
+ public getCompanyID(): string {
+ return this.companyID;
+ }
+
public getChargingStationID(): string {
return this.chargingStationID;
}

Adding additional IDs to WSConnection and related files