Skip to content

Conversation

@tomaz-cvetko
Copy link

Example how to use multi reader to read data from multiple same-rate signals.

daqErrCode addExistingDevice(daqInstance** instance, daqDevice** device, const char* connectionStr);

/**
* Get signals to read.
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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?

Copy link
Author

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.

Comment on lines 89 to 92
// Setup simulated device generating samples on 8 channels.
//setupSimulator(&simulatorInstance);
addSimulator(&device, &instance);
addExistingDevice(&instance, &device, "daq://Dewesoft_DB24049746");
Copy link
Contributor

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);
Copy link
Contributor

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().

Comment on lines 136 to 137
// Buffer size for 100ms worth of samples
bufferSize = domain.sampleRate / 10;
Copy link
Contributor

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.

Comment on lines 147 to 150
// Get tick of the first sample
daqInt readStartTick = domain.ruleStart + domain.referenceDomainOffset + readOffset;

printf("\n-- TIMESTAMP --- | -------- DATA (%lld) --------\n", readCount);
Copy link
Contributor

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) {
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants