MultiChannelCommunication: Resolve MSVC constexpr warning
parent
07afbebc6d
commit
6f8e073fd1
|
|
@ -5,8 +5,16 @@
|
|||
|
||||
using namespace icsneo;
|
||||
|
||||
MultiChannelCommunication::MultiChannelCommunication(device_eventhandler_t err, std::unique_ptr<Driver> com,
|
||||
std::function<std::unique_ptr<Packetizer>()> makeConfiguredPacketizer, std::unique_ptr<Encoder> e,
|
||||
std::unique_ptr<Decoder> md, size_t vnetCount) :
|
||||
Communication(err, std::move(com), makeConfiguredPacketizer, std::move(e), std::move(md)), numVnets(vnetCount) {
|
||||
vnetThreads.resize(numVnets);
|
||||
vnetQueues.resize(numVnets);
|
||||
}
|
||||
|
||||
void MultiChannelCommunication::spawnThreads() {
|
||||
for(size_t i = 0; i < NUM_SUPPORTED_VNETS; i++) {
|
||||
for(size_t i = 0; i < numVnets; i++) {
|
||||
while(vnetQueues[i].pop()) {} // Ensure the queue is empty
|
||||
vnetThreads[i] = std::thread(&MultiChannelCommunication::vnetReadTask, this, i);
|
||||
}
|
||||
|
|
@ -119,11 +127,11 @@ void MultiChannelCommunication::hidReadTask() {
|
|||
currentQueue = &vnetQueues[0];
|
||||
break;
|
||||
case CommandType::Vnet2_to_HostPC:
|
||||
if(NUM_SUPPORTED_VNETS >= 2)
|
||||
if(numVnets >= 2)
|
||||
currentQueue = &vnetQueues[1];
|
||||
break;
|
||||
case CommandType::Vnet3_to_HostPC:
|
||||
if(NUM_SUPPORTED_VNETS >= 3)
|
||||
if(numVnets >= 3)
|
||||
currentQueue = &vnetQueues[2];
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ public:
|
|||
std::unique_ptr<Driver> com,
|
||||
std::function<std::unique_ptr<Packetizer>()> makeConfiguredPacketizer,
|
||||
std::unique_ptr<Encoder> e,
|
||||
std::unique_ptr<Decoder> md) : Communication(err, std::move(com), makeConfiguredPacketizer, std::move(e), std::move(md)) {}
|
||||
std::unique_ptr<Decoder> md,
|
||||
size_t vnetCount);
|
||||
void spawnThreads() override;
|
||||
void joinThreads() override;
|
||||
bool sendPacket(std::vector<uint8_t>& bytes) override;
|
||||
|
|
@ -27,8 +28,6 @@ protected:
|
|||
bool preprocessPacket(std::deque<uint8_t>& usbReadFifo);
|
||||
|
||||
private:
|
||||
static constexpr const size_t NUM_SUPPORTED_VNETS = 1;
|
||||
|
||||
enum class CommandType : uint8_t {
|
||||
PlasmaReadRequest = 0x10, // Status read request to HSC
|
||||
PlasmaStatusResponse = 0x11, // Status response by HSC
|
||||
|
|
@ -106,9 +105,10 @@ private:
|
|||
CommandType currentCommandType;
|
||||
size_t currentReadIndex = 0;
|
||||
|
||||
const size_t numVnets;
|
||||
std::thread hidReadThread;
|
||||
std::array<std::thread, NUM_SUPPORTED_VNETS> vnetThreads;
|
||||
std::array<moodycamel::BlockingReaderWriterQueue< std::vector<uint8_t> >, NUM_SUPPORTED_VNETS> vnetQueues;
|
||||
std::vector<std::thread> vnetThreads;
|
||||
std::vector< moodycamel::BlockingReaderWriterQueue< std::vector<uint8_t> > > vnetQueues;
|
||||
void hidReadTask();
|
||||
void vnetReadTask(size_t vnetIndex);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -28,6 +28,22 @@ private:
|
|||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
||||
virtual std::shared_ptr<Communication> makeCommunication(
|
||||
std::unique_ptr<Driver> transport,
|
||||
std::function<std::unique_ptr<Packetizer>()> makeConfiguredPacketizer,
|
||||
std::unique_ptr<Encoder> encoder,
|
||||
std::unique_ptr<Decoder> decoder
|
||||
) override {
|
||||
return std::make_shared<MultiChannelCommunication>(
|
||||
report,
|
||||
std::move(transport),
|
||||
makeConfiguredPacketizer,
|
||||
std::move(encoder),
|
||||
std::move(decoder),
|
||||
1 // 2
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,22 @@ private:
|
|||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
||||
virtual std::shared_ptr<Communication> makeCommunication(
|
||||
std::unique_ptr<Driver> transport,
|
||||
std::function<std::unique_ptr<Packetizer>()> makeConfiguredPacketizer,
|
||||
std::unique_ptr<Encoder> encoder,
|
||||
std::unique_ptr<Decoder> decoder
|
||||
) override {
|
||||
return std::make_shared<MultiChannelCommunication>(
|
||||
report,
|
||||
std::move(transport),
|
||||
makeConfiguredPacketizer,
|
||||
std::move(encoder),
|
||||
std::move(decoder),
|
||||
1 // 3
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,21 +45,6 @@ public:
|
|||
size_t getEthernetActivationLineCount() const override { return 1; }
|
||||
|
||||
protected:
|
||||
virtual std::shared_ptr<Communication> makeCommunication(
|
||||
std::unique_ptr<Driver> transport,
|
||||
std::function<std::unique_ptr<Packetizer>()> makeConfiguredPacketizer,
|
||||
std::unique_ptr<Encoder> encoder,
|
||||
std::unique_ptr<Decoder> decoder
|
||||
) override {
|
||||
return std::make_shared<MultiChannelCommunication>(
|
||||
report,
|
||||
std::move(transport),
|
||||
makeConfiguredPacketizer,
|
||||
std::move(encoder),
|
||||
std::move(decoder)
|
||||
);
|
||||
}
|
||||
|
||||
// TODO This is done so that Plasion can still transmit it's basic networks, awaiting slave VNET support
|
||||
virtual bool isSupportedRXNetwork(const Network&) const override { return true; }
|
||||
virtual bool isSupportedTXNetwork(const Network&) const override { return true; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue