-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/multireader same rate example #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| daqErrCode addExistingDevice(daqInstance** instance, daqDevice** device, const char* connectionStr); | ||
|
|
||
| /** | ||
| * Get signals to read. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more details on what this retrieves would be good. It's actually just a wrapper around getSignalsRecursive if the AI tag is not used, so the name is a bit misleading.
I'd just have a helper available called getAIChannelSignals instead, and comment it out in the main application to note that it can be used with a device that has AI tags.
| /** | ||
| * Extracts sample rate, start and delta from linear data rule and updates metadata fields. | ||
| */ | ||
| daqErrCode processDataRule(daqDataDescriptor* domainDataDescriptor, struct DomainMetadata* metadata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, should also cache Origin and Unit. The name should be something along the lines of processDomainMetadata.
| /** | ||
| * Get a daqNumber from daqDict object. | ||
| */ | ||
| daqErrCode getNumberFromDict(daqDict* dict, const char* key, daqNumber** out); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need daqNumber or should this just return an integer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annoyingly it looks like we don't but then we have to convert the integer back to daqNumber* to calculate sampling rate via another "predefined" helper.
| // Setup simulated device generating samples on 8 channels. | ||
| //setupSimulator(&simulatorInstance); | ||
| addSimulator(&device, &instance); | ||
| addExistingDevice(&instance, &device, "daq://Dewesoft_DB24049746"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is leftover from our conversation, but should just be:
setupSimulator()
addExistingDevice(connStr=simulatorConnStr)A comment should note that the connection string can be replaced with any device.
| addSimulator(&device, &instance); | ||
| addExistingDevice(&instance, &device, "daq://Dewesoft_DB24049746"); | ||
|
|
||
| daqList* signals = getSignals(device, True); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should just be daqDevice_getSignalsRecursive or getAIChannelSignals().
| // Buffer size for 100ms worth of samples | ||
| bufferSize = domain.sampleRate / 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check for the unit being "s" earlier.
| // Get tick of the first sample | ||
| daqInt readStartTick = domain.ruleStart + domain.referenceDomainOffset + readOffset; | ||
|
|
||
| printf("\n-- TIMESTAMP --- | -------- DATA (%lld) --------\n", readCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, the tick should be converted a string representation of time since the epoch + epoch:
"Time: 56y 6m 21d 6h 32.123s since 1970-01-01T00:00:00"
I would add maybe a comment at the reference domain information parsing that the time protocol is not yet widely adopted, but users should double check whether the time is in the UTC, TAI or GPS standard.
| daqInt readStartTick = domain.ruleStart + domain.referenceDomainOffset + readOffset; | ||
|
|
||
| printf("\n-- TIMESTAMP --- | -------- DATA (%lld) --------\n", readCount); | ||
| for (daqSizeT sample = 0; sample < count; ++sample) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, simply print the first and last value + timestamp
|
|
||
| daqReleaseRef(statusAsReaderStatus); | ||
| daqReleaseRef(status); | ||
| Sleep(50); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably sleep for ~200ms and change the buffer size to 400ms to not flood stdout.
| addSimulator(&device, &instance); | ||
| addExistingDevice(&instance, &device, "daq://Dewesoft_DB24049746"); | ||
|
|
||
| daqList* signals = getSignals(device, True); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might make sense to include a checkSamplingRates method.
Example how to use multi reader to read data from multiple same-rate signals.