Skip to content

Commit 9b9a822

Browse files
committed
refactor: simplify saving behavior and remove legacy properties in CustomValuesConfigObject and CustomValuesController. Update readme.md.
1 parent 23e3de7 commit 9b9a822

File tree

3 files changed

+17
-46
lines changed

3 files changed

+17
-46
lines changed

README.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,13 @@ Beginning with the updated implementation (post Oct 2025 changes), the plugin in
1111
### Control Digital Joins (SIMPL <-> Plugin)
1212
| Join | Direction | Name | Purpose |
1313
|------|-----------|------|---------|
14-
| 1 | Input | EnableSaving | Hold HIGH to allow persistence of changes. When LOW, saving disabled; if `trackChangesWhileSavingDisabled` is true changes are staged in memory, otherwise ignored. |
14+
| 1 | Input | EnableSaving | Hold HIGH to allow persistence of changes. When LOW, saving disabled; changes are still staged in memory and flushed when re-enabled. |
1515
| 2 | Output | SavingReadyFb | HIGH when plugin is internally mapped/ready AND EnableSaving asserted. LOW otherwise. |
1616

1717
Control join metadata (capabilities and descriptions) is now declared in the advanced join map (`EssentialsPluginBridgeJoinMapTemplate`). Input and output do NOT share join 1; using distinct join 2 for feedback avoids collisions with some bridge pathways that do not permit a single digital to act as both directions simultaneously.
1818

1919
### Digital Join Offset (Data Boolean Join Remapping)
20-
DEFAULTS UPDATED (Oct 2025+): `legacyDigitalJoinBehavior` now defaults to TRUE (you can omit it). When TRUE, boolean data joins are NOT offset and use their configured join numbers relative to `joinStart` (legacy behavior).
21-
22-
To opt-in to the safer high-range offset, explicitly set:
23-
```json
24-
"legacyDigitalJoinBehavior": false
25-
```
26-
When set false, all bridged boolean (digital) data values begin at join 101 (offset base) to reduce collision risk with low-number control joins. Integer, string, and object-based values always use their configured join numbering relative to `joinStart`.
20+
Behavior Simplified (Oct 2025+): Boolean (digital) data joins are ALWAYS offset starting at join 101. The previous configuration property `legacyDigitalJoinBehavior` has been removed. Integer, string, and object-based values continue to use their configured join numbering relative to `joinStart`.
2721

2822
### Behavior Sequence Summary
2923
1. Plugin loads JSON data from file or config `data` object.
@@ -32,15 +26,12 @@ When set false, all bridged boolean (digital) data values begin at join 101 (off
3226
- SavingReadyFb set HIGH (plugin ready + saving enabled).
3327
4. Subsequent value changes on the bridge:
3428
- If EnableSaving HIGH: changes schedule a save (debounced ~1s).
35-
- If EnableSaving LOW AND `trackChangesWhileSavingDisabled` true: changes update RAM/feedbacks only; flagged dirty until re-enabled.
36-
- If EnableSaving LOW AND `trackChangesWhileSavingDisabled` false: changes are ignored entirely (no staging, no feedback updates).
29+
- If EnableSaving LOW: changes update RAM/feedbacks only; flagged dirty until re-enabled (tracking is always on).
3730
5. When EnableSaving transitions LOW -> HIGH again: if tracking flag true pending staged changes are flushed (250ms debounce) and SavingReadyFb returns HIGH.
3831

3932
### Notes & Edge Cases
4033
- Turning EnableSaving LOW immediately drops SavingReadyFb, suppressing further saves.
41-
- Analog/String/Object changes while disabled:
42-
- If `trackChangesWhileSavingDisabled` true (DEFAULT): not persisted but remain staged and will be saved after enabling.
43-
- If `trackChangesWhileSavingDisabled` false: ignored completely.
34+
- Analog/String/Object changes while disabled: not persisted but remain staged and will be saved after enabling (tracking always on).
4435
- Boolean join offset only affects JTokenType.Boolean mapped joins.
4536
- The plugin does not automatically re-load from disk during runtime; it uses in-memory state. To force a reload, restart the device or extend logic (future enhancement).
4637

@@ -76,8 +67,6 @@ All values can also be set and retrived using the console command "customvalues
7667
"boolValue": true,
7768
"stringValue": "SomeString!"
7869
},
79-
"legacyDigitalJoinBehavior": true,
80-
"trackChangesWhileSavingDisabled": true
8170
}
8271
},
8372
{
@@ -135,7 +124,7 @@ All values can also be set and retrived using the console command "customvalues
135124
```
136125

137126
### Updated Join Mapping Example (Boolean Offset)
138-
If you explicitly set `"legacyDigitalJoinBehavior": false` and `joinStart` is 1, a boolean path configured with `"joinNumber": 1` will map to digital join **101** on the bridge instead of 1. (When the property is omitted or true, it maps directly to join 1.) Control joins 1-2 remain reserved.
127+
A `joinStart` of 1 will map digital joins starting at **101**, analog joins at **1**, and serial joins at **1** on the bridge. Bridge digital joins 1-2 remain reserved.
139128

140129
### Minimal Config Without File (In-Memory Only)
141130
```json

src/CustomValuesConfigObject.cs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,8 @@ public class CustomValuesConfigObject
2929
[JsonProperty("data")]
3030
public JObject Data { get; set; }
3131

32-
/// <summary>
33-
/// When true, preserves legacy digital join numbering (no offset). Default TRUE now (legacy compatibility) => digitals start at 101 only when this is false.
34-
/// Optional in config; missing property will assume TRUE for backward compatibility with older Essentials projects that did not include this property.
35-
/// </summary>
36-
[JsonProperty("legacyDigitalJoinBehavior", DefaultValueHandling = DefaultValueHandling.Populate)]
37-
[System.ComponentModel.DefaultValue(true)]
38-
public bool LegacyDigitalJoinBehavior { get; set; }
39-
40-
/// <summary>
41-
/// When true, bridge-originated value changes while EnableSaving is LOW will update in-memory JSON (but still not persist to file). Default TRUE now (legacy compatibility). When false, changes while disabled are ignored.
42-
/// Optional in config; missing property will assume TRUE for backward compatibility with older deployments that expect legacy behavior of tracking updates in memory even while saving is disabled.
43-
/// </summary>
44-
[JsonProperty("trackChangesWhileSavingDisabled", DefaultValueHandling = DefaultValueHandling.Populate)]
45-
[System.ComponentModel.DefaultValue(true)]
46-
public bool TrackChangesWhileSavingDisabled { get; set; }
32+
// NOTE: legacyDigitalJoinBehavior and trackChangesWhileSavingDisabled removed.
33+
// Behavior is now fixed: boolean data joins always offset (start at 101) and
34+
// changes while saving disabled are always tracked in memory and flushed when saving is re-enabled.
4735
}
4836
}

src/CustomValuesController.cs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class CustomValuesController : ReconfigurableDevice, IBridgeAdvanced
4444
private BasicTriList _trilist; // saved for control output updates
4545

4646
// Feedback objects for control outputs
47-
private BoolFeedback _savingReadyFeedback; // join 2
47+
private BoolFeedback _savingReadyFeedback;
4848

4949
/// <summary>
5050
/// Constructs the controller, loading initial data either from a file (when a filePath
@@ -155,7 +155,7 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
155155
_savingReady = _pluginReady && _enableSaving;
156156
_savingReadyFeedback.FireUpdate();
157157
// If tracked changes occurred while disabled (only tracked when flag true), flush them now
158-
if (_props.TrackChangesWhileSavingDisabled && _dirtyWhileDisabled)
158+
if (_dirtyWhileDisabled)
159159
{
160160
_dirtyWhileDisabled = false;
161161
_saveTimer.Reset(250); // quick write after enabling
@@ -198,11 +198,11 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
198198
{
199199
trilist.SetUShortSigAction(@join, x => WithLock(() =>
200200
{
201-
if (!_enableSaving && !_props.TrackChangesWhileSavingDisabled) return; // ignore while disabled
201+
// Always track changes in memory when saving disabled; only persist when enabled
202202
data.SelectToken(path).Replace(x);
203203
if (_enableSaving)
204204
_saveTimer.Reset(1000);
205-
else if (_props.TrackChangesWhileSavingDisabled)
205+
else
206206
_dirtyWhileDisabled = true;
207207
}));
208208

@@ -220,11 +220,10 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
220220
{
221221
trilist.SetStringSigAction(@join, x => WithLock(() =>
222222
{
223-
if (!_enableSaving && !_props.TrackChangesWhileSavingDisabled) return;
224223
data.SelectToken(path).Replace(x);
225224
if (_enableSaving)
226225
_saveTimer.Reset(1000);
227-
else if (_props.TrackChangesWhileSavingDisabled)
226+
else
228227
_dirtyWhileDisabled = true;
229228
}));
230229

@@ -242,11 +241,10 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
242241
{
243242
trilist.SetStringSigAction(@join, x =>
244243
{
245-
if (!_enableSaving && !_props.TrackChangesWhileSavingDisabled) return;
246244
data.SelectToken(path).Replace(x);
247245
if (_enableSaving)
248246
_saveTimer.Reset(1000);
249-
else if (_props.TrackChangesWhileSavingDisabled)
247+
else
250248
_dirtyWhileDisabled = true;
251249
});
252250

@@ -262,19 +260,15 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
262260
}
263261
case JTokenType.Boolean:
264262
{
265-
// Apply new digital join offset unless legacy behavior enabled
266-
if (!_props.LegacyDigitalJoinBehavior)
267-
{
268-
join = (ushort)(DigitalJoinBaseOffset + index - 1);
269-
}
263+
// Always apply digital join offset (legacy behavior removed)
264+
join = (ushort)(DigitalJoinBaseOffset + index - 1);
270265

271266
trilist.SetBoolSigAction(@join, x =>
272267
{
273-
if (!_enableSaving && !_props.TrackChangesWhileSavingDisabled) return;
274268
data.SelectToken(path).Replace(x);
275269
if (_enableSaving)
276270
_saveTimer.Reset(1000);
277-
else if (_props.TrackChangesWhileSavingDisabled)
271+
else
278272
_dirtyWhileDisabled = true;
279273
});
280274

0 commit comments

Comments
 (0)