Repository navigation
Description
[FEATURE] OCPP 1.6: introduce per-station state WeakMap (prerequisite for supersession + timer-cancel + trigger cross-check)
Component
Simulator
Description
Follow-up from PR #1962.
The OCPP 2.0.1 side of the codebase maintains a stationsState: WeakMap<ChargingStation, OCPP20StationState> on OCPP20IncomingRequestService (src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts:289+), plus a lazy-init getter getOrCreateStationState and a stop() override that resets/aborts state and deletes the WeakMap entry. Three separate follow-up issues on the OCPP 1.6 side require an analogous infrastructure:
- OCPP 1.6
handleRequestGetDiagnosticssupersession (companion issue). - OCPP 1.6
updateFirmwareSimulationsetTimeoutcancellation onstop()(companion issue). - OCPP 1.6
TriggerMessage(DiagnosticsStatusNotification / FirmwareStatusNotification)dual-source cross-check (companion issue).
None of the three fixes can land without this infrastructure. Filing it separately avoids duplicating the same "add per-station state WeakMap" work across three issues and keeps each companion issue focused on its specific bug.
Attachments
- PR refactor: audit backlog cleanup — JSDoc gaps, physics warning, ATG robustness, comment sweep #1962 discussion
- Reference implementation on the OCPP 2.0.1 side:
stationsStatedeclaration +OCPP20StationStateinterface:OCPP20IncomingRequestService.ts:260-289(approx)getOrCreateStationStatelazy-init getter:OCPP20IncomingRequestService.ts:1414stop()override with reset + delete:OCPP20IncomingRequestService.ts:786-801(approx)- Related commits:
c0b25553(certSigningRetryManager.cancelRetryTimer()instop()),be29b4c8(log-upload AbortController +stop()abort)
Proposed scope for the prerequisite:
- Add
OCPP16StationStateinterface with fields for the three companion issues (activeDiagnosticsRequestId,activeDiagnosticsAbortController,activeFirmwareUpdateTimerhandle). Individual fields will be added by their respective companion issues; this issue only defines the base type and the WeakMap plumbing. - Add
private readonly stationsState = new WeakMap<ChargingStation, OCPP16StationState>()onOCPP16IncomingRequestService. - Add
private getOrCreateStationState(chargingStation: ChargingStation): OCPP16StationStatemirroring the 2.0.1 signature. - Add
private resetActive*State(stationState: OCPP16StationState): voidunconditional-clear helpers (companion issues add their fields). - Add
public override stop(chargingStation: ChargingStation): voidthat gets the state, aborts / cancels / resets active fields, then deletes the WeakMap entry.
Once this issue lands, the three companion issues can independently add their specific fields and reset logic without duplicating the WeakMap plumbing.
Activity
refactor(ocpp): extract per-station state plumbing into shared OCPPIn…
refactor(ocpp): extract per-station state plumbing into shared OCPPIn…
refactor(ocpp): extract per-station state plumbing into shared OCPPIn…
refactor(ocpp): extract per-station state plumbing into shared OCPPIn…
refactor(ocpp): extract per-station state plumbing into shared OCPPIn…
refactor(ocpp): extract per-station state plumbing into shared OCPPIn…
refactor(ocpp): extract per-station state plumbing into shared OCPPIn…
fix(ocpp): cancel deferred OCPP 1.6 firmware setTimeout on stop()
fix(ocpp): cancel deferred OCPP 1.6 firmware setTimeout on stop()
fix(ocpp): cancel deferred OCPP 1.6 firmware setTimeout on stop()
fix(ocpp): cancel deferred OCPP 1.6 firmware setTimeout on stop()
fix(ocpp): cancel deferred OCPP 1.6 firmware setTimeout on stop()
fix(ocpp): cancel deferred OCPP 1.6 firmware setTimeout on stop() (#1984
refactor(ocpp): extract per-station state plumbing into shared OCPPIn…