Device component initialization done more intelligently

This commit is contained in:
Paul Hollinsky
2018-10-26 19:28:09 -04:00
parent 7e6282a7ad
commit a331a2afa8
24 changed files with 255 additions and 213 deletions
+8 -6
View File
@@ -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;
}
};
}
+8 -6
View File
@@ -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;
}
};
}
+9 -7
View File
@@ -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) {}
};
}