livoxGen1: Add correctness checks to attachDeviceReq
This commit is contained in:
@@ -258,6 +258,13 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if (1 || smoHooksPtr->OptionParser_getOptions().verbose)
|
||||
{
|
||||
std::cout << __func__ << ": Got return mode (" << (int)mode
|
||||
<< ") for device: " << context->spec->deviceSelector
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
/* Check if PcloudStimulusProducer already exists
|
||||
* (race condition or double-add)
|
||||
*/
|
||||
@@ -280,17 +287,43 @@ public:
|
||||
|
||||
context->stimProducer = pcloudDataProducer;
|
||||
context->deviceTmp->nAttachedStimulusProducers++;
|
||||
if (context->deviceTmp->nAttachedStimulusProducers > 2)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": Each LivoxGen1 device can only have "
|
||||
"at most two StimulusProducers attached to it. Found "
|
||||
+ std::to_string(
|
||||
context->deviceTmp->nAttachedStimulusProducers) + ".");
|
||||
}
|
||||
|
||||
attachedStimulusProducers.push_back(pcloudDataProducer);
|
||||
if (false
|
||||
/*attachedStimulusProducers.size() >= 2*nDevicesKnownToGen1Lib */)
|
||||
{
|
||||
/** TODO:
|
||||
* It would be nice to add an nDevicesKnownToGen1Lib counter, and
|
||||
* then add a check here to ensure that
|
||||
* attachedStimulusProducers.size() is always less than or equal to
|
||||
* 2*nDevicesKnownToGen1Lib.
|
||||
*
|
||||
* (2 stim producers per device).
|
||||
*/
|
||||
#if 0
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": Number of StimulusProducers attached "
|
||||
"to LivoxGen1 devices known to the library ("
|
||||
+ std::to_string(attachedStimulusProducers.size())
|
||||
+ ") is greater than "
|
||||
"expected. Lib knows about "
|
||||
+ std::to_string(nDevicesKnownToGen1Lib) + " devices, "
|
||||
"so there should be at most "
|
||||
+ std::to_string(2*nDevicesKnownToGen1Lib)
|
||||
+ " StimulusProducers attached to devices.");
|
||||
#endif
|
||||
}
|
||||
|
||||
pcloudDataProducer->start();
|
||||
|
||||
if (1 || smoHooksPtr->OptionParser_getOptions().verbose)
|
||||
{
|
||||
std::cout << __func__ << ": Got return mode (" << (int)mode
|
||||
<< ") for device: " << context->spec->deviceSelector
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
// Ensure StimBuffer is attached
|
||||
attachDeviceReq4_doCreateStimBuff_maybeDirectlyCalled(context);
|
||||
}
|
||||
@@ -651,12 +684,10 @@ extern "C" void livoxGen1_attachDeviceReq(
|
||||
auto request = std::make_shared<AttachDeviceReq>(desc, cb);
|
||||
|
||||
// Case 1: Check if StimBuffer already exists
|
||||
auto stimProducerBase = getStimulusProducer(desc);
|
||||
if (stimProducerBase)
|
||||
auto stimProducer = std::dynamic_pointer_cast<PcloudStimulusProducer>(
|
||||
getStimulusProducer(desc));
|
||||
if (stimProducer)
|
||||
{
|
||||
auto stimProducer = std::static_pointer_cast<PcloudStimulusProducer>(
|
||||
stimProducerBase);
|
||||
|
||||
auto existingBuffer = stimProducer->getAttachedStimulusBuffer(desc);
|
||||
if (existingBuffer)
|
||||
{
|
||||
|
||||
@@ -68,6 +68,9 @@ collationBuffer(
|
||||
|
||||
void PcloudStimulusProducer::start()
|
||||
{
|
||||
std::cout << __func__ << ": Starting PcloudStimulusProducer for device "
|
||||
<< device->discoveredDevice.deviceIdentifier << std::endl;
|
||||
|
||||
// Call ioUringAssemblyEngine setup() as the first step
|
||||
if (!ioUringAssemblyEngine.setup())
|
||||
{
|
||||
@@ -89,6 +92,9 @@ void PcloudStimulusProducer::start()
|
||||
|
||||
void PcloudStimulusProducer::stop()
|
||||
{
|
||||
std::cout << __func__ << ": Stopping PcloudStimulusProducer for device "
|
||||
<< device->discoveredDevice.deviceIdentifier << std::endl;
|
||||
|
||||
// Call base class stop() as the first step
|
||||
StimulusProducer::stop();
|
||||
// Call ioUringAssemblyEngine stop() as the final step
|
||||
|
||||
Reference in New Issue
Block a user