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,17 +11,15 @@ class NeoVIFIRE2 : public Device {
|
||||
public:
|
||||
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::FIRE2;
|
||||
static constexpr const char* SERIAL_START = "CY";
|
||||
|
||||
protected:
|
||||
NeoVIFIRE2(neodevice_t neodevice) : Device(neodevice) {
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
}
|
||||
|
||||
protected:
|
||||
static std::shared_ptr<Communication> MakeCommunication(std::unique_ptr<ICommunication> transport) {
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
|
||||
virtual void setupEncoder(Encoder* encoder) override {
|
||||
Device::setupEncoder(encoder);
|
||||
encoder->supportCANFD = true;
|
||||
auto decoder = std::unique_ptr<Decoder>(new Decoder());
|
||||
return std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -11,13 +11,6 @@ namespace icsneo {
|
||||
class NeoVIFIRE2ETH : public NeoVIFIRE2 {
|
||||
public:
|
||||
static constexpr const uint16_t PRODUCT_ID = 0x0004;
|
||||
NeoVIFIRE2ETH(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
|
||||
com = MakeCommunication(std::unique_ptr<ICommunication>(new PCAP(getWritableNeoDevice())));
|
||||
settings = std::unique_ptr<IDeviceSettings>(new NeoVIFIRE2Settings(com));
|
||||
settings->readonly = true;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
||||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
@@ -50,6 +43,18 @@ public:
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void setupSettings(IDeviceSettings* settings) {
|
||||
// TODO Check firmware version, old firmwares will reset Ethernet settings on settings send
|
||||
settings->readonly = true;
|
||||
}
|
||||
|
||||
private:
|
||||
NeoVIFIRE2ETH(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
|
||||
initialize<PCAP, NeoVIFIRE2Settings>();
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,20 +10,20 @@ namespace icsneo {
|
||||
class NeoVIFIRE2USB : public NeoVIFIRE2 {
|
||||
public:
|
||||
static constexpr const uint16_t PRODUCT_ID = 0x1000;
|
||||
NeoVIFIRE2USB(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
|
||||
com = MakeCommunication(std::unique_ptr<ICommunication>(new FTDI(getWritableNeoDevice())));
|
||||
settings = std::unique_ptr<IDeviceSettings>(new NeoVIFIRE2Settings(com));
|
||||
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<NeoVIFIRE2USB>(neodevice));
|
||||
found.emplace_back(new NeoVIFIRE2USB(neodevice)); // Creation of the shared_ptr
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
private:
|
||||
NeoVIFIRE2USB(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
|
||||
initialize<FTDI, NeoVIFIRE2Settings>();
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user