NDATA uses another list, ChangeList, in addition to the AllMetricsList.
The problem is, these elements can only belong to one list.
Solution:
Rather than how it currently is:
1. Cycle through Every Element
2. Add changed element to ChangeList (side effect: removing element from AllMetricsList)
3. Call the AddListOfMetrics, which cycles through every changed element and adds them to the Encoder
Should do:
1. Cycle through Every Element
2. Add changed element to Encoder
This ticket is implemented but also bring hurdles we did not see.
Problem:
1) The NDATA Encoder is not initialised(!) so when we detect changes to data we add them to the not initialised encoder.
2) The encoder thus throws a "NotEnoughPayload..."
3) more issue's down the road which involve wrong order initialisation.
Solution:
Revision of (NDATA) sending strategy:
BEFORE detection of changed data we must initialise the NDATA payload to accept data.
Add a new method named (some suggestions) might be
SparkPlugBSimple.PrepareNDATA( AllMetricsList );
or
SparkPlugBSimple.InitNDATA( AllMetricsList );
Then, if data CHANGES are detected we accept the changed values during this single cycle into the encoder (we take a 'data snapshot') during this cycle.
After this we BLOCK the change detection during the "Publish Period Blocking Time" so the Encoder will not receive changes during the block period(!)
Then we SEND the payload immediately also DURING this BLOCK period (at start of)
via the excisting albeit refactored method:
SparkPlugBSimple.PublishNDATA( Enable, AllMetricsList );
Summed up in short
1) Init Encoder in ususual way,
2) ChangeDetection (adds data to internal encoder),
3) Block ChangeDetection and immediately Send Payload,
4) Repeat from step 1.
Success!
Fixed minor issue with calling InitEncoder, which increases the seq by 1, even if no changes were detected. (Now only calls it once).