Skip to content

Feature request: Preserve XML comments in .omsim project files #127

Description

@vinckcao

Problem

When a .omsim project file is opened and re-saved (including "Save As"), the following issues occur:

  1. XML comments are lost: Comments within AddressDescriptionMap are partially or fully discarded.
  2. Timestamps change every save: AddressTimestampMap is rewritten with millisecond precision on every save, even when data hasn't changed.
  3. Runtime values are saved: Register values modified by simulation scripts are written to the file, causing different content each time.
  4. View settings are mixed in: Column widths and window positions are saved alongside project data.

These issues make it difficult to manage .omsim files with version control (git), as every save produces unnecessary diffs that obscure meaningful changes.

Why this matters

XML comments in .omsim files are useful for documenting register mappings, grouping registers by device/function, and providing context for each address range. This is especially important when project files are generated or managed by AI tools — the AI typically includes explanatory comments and section headers alongside the register definitions. However, once the file is opened and re-saved in OpenModSim, these comments are lost.

Additionally, when .omsim files are tracked with git, every save produces noise from timestamps, runtime values, and view settings, making it hard to review actual project changes.

Expected behavior

  1. XML comments preserved: All XML comments within AddressDescriptionMap (and ideally other sections) should be retained when loading and saving .omsim project files, including section header comments like <!-- ===== Device 1: AnalogIO ===== -->.
  2. Timestamps stable: Consider making timestamps optional or excluding them from save by default.
  3. Runtime values separated: Consider separating "initial values" from "runtime values", or providing an option to save only the project configuration without runtime state.
  4. View settings separated: Consider storing view settings (column widths, window positions) in a separate file (e.g., .omsim.user) so that project data remains stable.

Example

Before saving in OpenModSim:

<AddressDescriptionMap>
  <!-- ===== Device 1: AnalogIO ===== -->
  <!-- Analog Input (Input Registers, Type=3) -->
  <Description DeviceId="1" Type="3" Address="0"><![CDATA[Temperature Setpoint]]></Description>
  <!-- Analog Output (Holding Registers, Type=4) -->
  <Description DeviceId="1" Type="4" Address="256"><![CDATA[Pump Control]]></Description>
</AddressDescriptionMap>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions