Clean up example

Add second signal set to the example
liveDataSetValue
Ben Kleinheksel 2025-06-16 14:44:28 -04:00
parent bb4176dec8
commit 6bc70b5f29
1 changed files with 14 additions and 20 deletions

View File

@ -79,32 +79,26 @@ int main() {
})); }));
// Run handler for three seconds to observe the signal data // Run handler for three seconds to observe the signal data
std::this_thread::sleep_for(std::chrono::seconds(3)); std::this_thread::sleep_for(std::chrono::seconds(3));
auto setValMsg = std::make_shared<icsneo::LiveDataSetValueMessage>(); double val = 0;
setValMsg->cmd = icsneo::LiveDataCommand::SET_VALUE;
setValMsg->handle = msg->handle;
bool onOff = true;
for (unsigned int i = 0; i < 10; ++i) for (unsigned int i = 0; i < 10; ++i)
{ {
setValMsg->args.clear(); // Set the values of signals we're watching so we can see them change live
setValMsg->values.clear(); auto setValMsg = std::make_shared<icsneo::LiveDataSetValueMessage>();
double val; setValMsg->cmd = icsneo::LiveDataCommand::SET_VALUE;
if (onOff) setValMsg->handle = msg->handle;
{ // Convert the value format
val = 1; icsneo::LiveDataValue ldValueDAQEnable;
} icsneo::LiveDataValue ldValueManTrig;
else if ((icsneo::LiveDataUtil::liveDataDoubleToValue(ldValueDAQEnable, val * 10) < 0) ||
{ (icsneo::LiveDataUtil::liveDataDoubleToValue(ldValueManTrig, val) < 0))
val = 0;
}
onOff = !onOff;
icsneo::LiveDataValue ldValue;
if (icsneo::LiveDataUtil::liveDataDoubleToValue(ldValue, val) < 0)
{ {
break; break;
} }
setValMsg->appendSetValue(icsneo::LiveDataValueType::DAQ_ENABLE, ldValue); setValMsg->appendSetValue(icsneo::LiveDataValueType::DAQ_ENABLE, ldValueDAQEnable);
setValMsg->appendSetValue(icsneo::LiveDataValueType::MANUAL_TRIGGER, ldValueManTrig);
device->setValueLiveData(setValMsg); device->setValueLiveData(setValMsg);
// Test setting values ++val;
// Run handler for three seconds to observe the signal data
std::this_thread::sleep_for(std::chrono::seconds(3)); std::this_thread::sleep_for(std::chrono::seconds(3));
} }
// Unsubscribe from the GPS signals and run handler for one more second // Unsubscribe from the GPS signals and run handler for one more second