Skip to content

[MAINTENANCE] Consolidate duplicate VISSIM driver model code into shared base #129

@yunlishao-vibe

Description

@yunlishao-vibe

Task Summary

DriverModel_RealSim.cpp and DriverModel_RealSim_v2021.cpp are nearly identical (~1887 and ~1922 lines respectively) with only minor API-level differences. Extract the shared logic into a common base to eliminate code duplication.

Why is this needed?

Currently any bug fix or feature must be applied to both files independently. The two files differ in only ~50 lines out of ~1900 (less than 3%), primarily:

  • long vs int type for VISSIM API parameters (v2021 API uses int)
  • A few global flags added to v2021: SUB_EGO_ONLY, ENABLE_WARMUP, isInitialTimeFinished
  • Variable name simTime vs simTime_g
  • Default value of NEED_SPEED_LIMIT (true vs false)

The remaining ~97% of code (message handling, socket communication, data processing, FIXS integration) is identical. Multiple // TODO: add code stubs appear in the same locations in both files.

Scope of Work

1. Analyze and document all differences

  • Run a full diff and categorize every difference
  • Document API-level differences (VISSIM 2022+ vs 2021 driver model API)

2. Extract shared logic

Option A: Single shared header DriverModel_FIXS_Common.h with inline implementation
Option B: Shared DriverModel_FIXS_Common.cpp compiled into both projects via shared source

3. Create thin version-specific wrappers

  • DriverModel_RealSim.cpp → thin wrapper using modern VISSIM API (long parameters)
  • DriverModel_RealSim_v2021.cpp → thin wrapper using legacy VISSIM API (int parameters)
  • Both include/link to shared common implementation

4. Resolve TODO stubs

  • The // TODO: add code stubs (at least 8 locations in each file) represent unimplemented message field handlers
  • Document what each TODO means and either implement or remove with a proper issue reference

5. Add Python auto-test

  • Add tests/Python/test_vissim_driver_parity.py that:
    • Parses both .cpp files
    • Verifies that non-API-signature sections are identical (or differ only in known documented ways)
    • Alerts if one file has a change that wasn't applied to the other

Files Involved

  • ProprietaryFiles/VISSIMserver/DriverModel_RealSim/DriverModel_RealSim.cpp
  • ProprietaryFiles/VISSIMserver/DriverModel_RealSim_v2021/DriverModel_RealSim_v2021.cpp
  • ProprietaryFiles/VISSIMserver/VISSIMserver.sln
  • Build scripts in scripts/dispatch/3_vissim_components.bat

Acceptance Criteria

  • Shared common code extracted and not duplicated
  • Both DLLs still build and function correctly
  • tests/Python/test_vissim_driver_parity.py passes
  • All TODO stubs addressed or converted to tracked issues
  • Diff between the two wrapper files is ≤ 100 lines

Branch and PR Target

  • All PRs for this issue should target the dev branch (not main)
  • First ensure main is merged into dev before starting work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions