Add test to example
parent
5bfd7e3300
commit
0b135e29a0
|
|
@ -12,4 +12,14 @@ void LiveDataCommandMessage::appendSignalArg(LiveDataValueType valueType) {
|
||||||
arg->valueType = valueType;
|
arg->valueType = valueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LiveDataSetValueMessage::appendSetValue(LiveDataValueType valueType, const LiveDataValue& value) {
|
||||||
|
auto& arg = args.emplace_back(std::make_shared<LiveDataArgument>());
|
||||||
|
arg->objectType = LiveDataObjectType::MISC;
|
||||||
|
arg->objectIndex = 0u;
|
||||||
|
arg->signalIndex = 0u;
|
||||||
|
arg->valueType = valueType;
|
||||||
|
|
||||||
|
values.push_back(std::make_shared<LiveDataValue>(value));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace icsneo
|
} // namespace icsneo
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@ int main() {
|
||||||
msg->appendSignalArg(icsneo::LiveDataValueType::GPS_LATITUDE);
|
msg->appendSignalArg(icsneo::LiveDataValueType::GPS_LATITUDE);
|
||||||
msg->appendSignalArg(icsneo::LiveDataValueType::GPS_LONGITUDE);
|
msg->appendSignalArg(icsneo::LiveDataValueType::GPS_LONGITUDE);
|
||||||
msg->appendSignalArg(icsneo::LiveDataValueType::GPS_ACCURACY);
|
msg->appendSignalArg(icsneo::LiveDataValueType::GPS_ACCURACY);
|
||||||
|
msg->appendSignalArg(icsneo::LiveDataValueType::DAQ_OVERRIDE);
|
||||||
|
msg->appendSignalArg(icsneo::LiveDataValueType::MANUAL_TRIGGER);
|
||||||
msg->cmd = icsneo::LiveDataCommand::SUBSCRIBE;
|
msg->cmd = icsneo::LiveDataCommand::SUBSCRIBE;
|
||||||
msg->handle = icsneo::LiveDataUtil::getNewHandle();
|
msg->handle = icsneo::LiveDataUtil::getNewHandle();
|
||||||
msg->updatePeriod = std::chrono::milliseconds(100);
|
msg->updatePeriod = std::chrono::milliseconds(100);
|
||||||
|
|
@ -77,6 +79,34 @@ 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>();
|
||||||
|
setValMsg->cmd = icsneo::LiveDataCommand::SET_VALUE;
|
||||||
|
setValMsg->handle = msg->handle;
|
||||||
|
bool onOff = true;
|
||||||
|
for (unsigned int i = 0; i < 10; ++i)
|
||||||
|
{
|
||||||
|
setValMsg->args.clear();
|
||||||
|
setValMsg->values.clear();
|
||||||
|
double val;
|
||||||
|
if (onOff)
|
||||||
|
{
|
||||||
|
val = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
val = 0;
|
||||||
|
}
|
||||||
|
onOff = !onOff;
|
||||||
|
icsneo::LiveDataValue ldValue;
|
||||||
|
if (icsneo::LiveDataUtil::liveDataDoubleToValue(ldValue, val) < 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setValMsg->appendSetValue(icsneo::LiveDataValueType::DAQ_OVERRIDE, ldValue);
|
||||||
|
device->setValueLiveData(setValMsg);
|
||||||
|
// Test setting values
|
||||||
|
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
|
||||||
// Unsubscription only requires a valid in-use handle, in this case from our previous subscription
|
// Unsubscription only requires a valid in-use handle, in this case from our previous subscription
|
||||||
ret = device->unsubscribeLiveData(msg->handle);
|
ret = device->unsubscribeLiveData(msg->handle);
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ namespace LiveDataUtil
|
||||||
|
|
||||||
LiveDataHandle getNewHandle();
|
LiveDataHandle getNewHandle();
|
||||||
double liveDataValueToDouble(const LiveDataValue& val);
|
double liveDataValueToDouble(const LiveDataValue& val);
|
||||||
|
int liveDataDoubleToValue(LiveDataValue& value, const double& dFloat);
|
||||||
static constexpr uint32_t LiveDataVersion = 1;
|
static constexpr uint32_t LiveDataVersion = 1;
|
||||||
|
|
||||||
} // namespace LiveDataUtil
|
} // namespace LiveDataUtil
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ public:
|
||||||
LiveDataSetValueMessage() {}
|
LiveDataSetValueMessage() {}
|
||||||
std::vector<std::shared_ptr<LiveDataArgument>> args;
|
std::vector<std::shared_ptr<LiveDataArgument>> args;
|
||||||
std::vector<std::shared_ptr<LiveDataValue>> values;
|
std::vector<std::shared_ptr<LiveDataValue>> values;
|
||||||
|
void appendSetValue(LiveDataValueType valueType, const LiveDataValue& value);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace icsneo
|
} // namespace icsneo
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue