Skip to content

[FEATURE] OCPP 1.6: introduce per-station state WeakMap (prerequisite for supersession + timer-cancel + trigger cross-check) #1963

Closed

Description

@jerome-benoit

[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 handleRequestGetDiagnostics supersession (companion issue).
  • OCPP 1.6 updateFirmwareSimulation setTimeout cancellation on stop() (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:
    • stationsState declaration + OCPP20StationState interface: OCPP20IncomingRequestService.ts:260-289 (approx)
    • getOrCreateStationState lazy-init getter: OCPP20IncomingRequestService.ts:1414
    • stop() override with reset + delete: OCPP20IncomingRequestService.ts:786-801 (approx)
    • Related commits: c0b25553 (certSigningRetryManager.cancelRetryTimer() in stop()), be29b4c8 (log-upload AbortController + stop() abort)

Proposed scope for the prerequisite:

  1. Add OCPP16StationState interface with fields for the three companion issues (activeDiagnosticsRequestId, activeDiagnosticsAbortController, activeFirmwareUpdateTimer handle). Individual fields will be added by their respective companion issues; this issue only defines the base type and the WeakMap plumbing.
  2. Add private readonly stationsState = new WeakMap<ChargingStation, OCPP16StationState>() on OCPP16IncomingRequestService.
  3. Add private getOrCreateStationState(chargingStation: ChargingStation): OCPP16StationState mirroring the 2.0.1 signature.
  4. Add private resetActive*State(stationState: OCPP16StationState): void unconditional-clear helpers (companion issues add their fields).
  5. Add public override stop(chargingStation: ChargingStation): void that 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

  1. added
    enhancement
    simulator
    triage
    on Jul 6, 2026
  2. added 7 commits that reference this issue on Jul 8, 2026
    1531ae1
    7310ca4
    d1368bd
    82ea6d9
    bd6c1bb
    f796062
    de2a08a
  3. added a commit that references this issue on Jul 27, 2026
    0fff8b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsimulatortriage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions