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
@@ -11,22 +11,22 @@ class ValueCAN4_2 : public ValueCAN4 {
public:
// Serial numbers start with V2 for 4-2
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_2;
ValueCAN4_2(neodevice_t neodevice) : ValueCAN4(neodevice) {
com = MakeCommunication(getWritableNeoDevice());
settings = std::unique_ptr<IDeviceSettings>(new ValueCAN4_2Settings(com));
getWritableNeoDevice().type = DEVICE_TYPE;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID)) {
if(std::string(neodevice.serial).substr(0, 2) == "V2")
found.push_back(std::make_shared<ValueCAN4_2>(neodevice));
found.emplace_back(new ValueCAN4_2(neodevice));
}
return found;
}
private:
ValueCAN4_2(neodevice_t neodevice) : ValueCAN4(neodevice) {
initialize<STM32, ValueCAN4_2Settings>();
getWritableNeoDevice().type = DEVICE_TYPE;
}
};
}