mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
Device component initialization done more intelligently
This commit is contained in:
@@ -11,19 +11,21 @@ class NeoVIION : public Plasion {
|
||||
public:
|
||||
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::ION;
|
||||
static constexpr const uint16_t PRODUCT_ID = 0x0901;
|
||||
NeoVIION(neodevice_t neodevice) : Plasion(neodevice) {
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
||||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
|
||||
found.push_back(std::make_shared<NeoVIION>(neodevice));
|
||||
found.emplace_back(new NeoVIION(neodevice));
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
private:
|
||||
NeoVIION(neodevice_t neodevice) : Plasion(neodevice) {
|
||||
initialize<FTDI>();
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -11,19 +11,21 @@ class NeoVIPLASMA : public Plasion {
|
||||
public:
|
||||
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::PLASMA;
|
||||
static constexpr const uint16_t PRODUCT_ID = 0x0801;
|
||||
NeoVIPLASMA(neodevice_t neodevice) : Plasion(neodevice) {
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
||||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
|
||||
found.push_back(std::make_shared<NeoVIPLASMA>(neodevice));
|
||||
found.emplace_back(new NeoVIPLASMA(neodevice));
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
private:
|
||||
NeoVIPLASMA(neodevice_t neodevice) : Plasion(neodevice) {
|
||||
initialize<FTDI>();
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -8,14 +8,16 @@
|
||||
namespace icsneo {
|
||||
|
||||
class Plasion : public Device {
|
||||
protected:
|
||||
virtual std::shared_ptr<Communication> makeCommunication(
|
||||
std::unique_ptr<ICommunication> transport,
|
||||
std::shared_ptr<Packetizer> packetizer,
|
||||
std::unique_ptr<Encoder> encoder,
|
||||
std::unique_ptr<Decoder> decoder
|
||||
) override { return std::make_shared<MultiChannelCommunication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder)); }
|
||||
|
||||
public:
|
||||
Plasion(neodevice_t neodevice) : Device(neodevice) {
|
||||
auto transport = std::unique_ptr<ICommunication>(new FTDI(getWritableNeoDevice()));
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
|
||||
auto decoder = std::unique_ptr<Decoder>(new Decoder());
|
||||
com = std::make_shared<MultiChannelCommunication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
|
||||
}
|
||||
Plasion(neodevice_t neodevice) : Device(neodevice) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user