From 530a99d264b1872fb9e6dae8ea7c9ba320907e91 Mon Sep 17 00:00:00 2001 From: Thomas Stoddard Date: Fri, 9 Jan 2026 18:16:10 +0000 Subject: [PATCH] Add T1S PLCA and related settings support for Fire3T1S, RadComet3, RadGigaStar2, and RadMoonT1S devices --- .../icsneopy/device/idevicesettings.cpp | 22 ++- include/icsneo/device/idevicesettings.h | 68 ++++++++ .../neovifire3t1slinsettings.h | 147 ++++++++++++++++ .../device/tree/radcomet3/radcomet3settings.h | 143 +++++++++++++++ .../tree/radgigastar2/radgigastar2settings.h | 147 ++++++++++++++++ .../tree/radmoont1s/radmoont1ssettings.h | 163 ++++++++++++++++++ 6 files changed, 686 insertions(+), 4 deletions(-) diff --git a/bindings/python/icsneopy/device/idevicesettings.cpp b/bindings/python/icsneopy/device/idevicesettings.cpp index 19273fe..6f9c2a3 100644 --- a/bindings/python/icsneopy/device/idevicesettings.cpp +++ b/bindings/python/icsneopy/device/idevicesettings.cpp @@ -41,20 +41,20 @@ void init_idevicesettings(pybind11::module_& m) { .def("apply", &IDeviceSettings::apply, pybind11::arg("temporary") = 0, pybind11::call_guard()) .def("apply_defaults", &IDeviceSettings::applyDefaults, pybind11::arg("temporary") = 0, pybind11::call_guard()) .def("refresh", &IDeviceSettings::refresh, pybind11::call_guard()) - + // Baudrate methods .def("get_baudrate", &IDeviceSettings::getBaudrateFor, pybind11::call_guard()) .def("set_baudrate", &IDeviceSettings::setBaudrateFor, pybind11::call_guard()) .def("get_fd_baudrate", &IDeviceSettings::getFDBaudrateFor, pybind11::call_guard()) .def("set_fd_baudrate", &IDeviceSettings::setFDBaudrateFor, pybind11::call_guard()) - + // Termination methods .def("is_termination_supported", &IDeviceSettings::isTerminationSupportedFor, pybind11::call_guard()) .def("can_termination_be_enabled", &IDeviceSettings::canTerminationBeEnabledFor, pybind11::call_guard()) .def("is_termination_enabled", &IDeviceSettings::isTerminationEnabledFor, pybind11::call_guard()) .def("set_termination", &IDeviceSettings::setTerminationFor, pybind11::call_guard()) .def("get_termination_groups", &IDeviceSettings::getTerminationGroups, pybind11::call_guard()) - + // LIN methods .def("is_commander_resistor_enabled", &IDeviceSettings::isCommanderResistorEnabledFor, pybind11::call_guard()) .def("set_commander_resistor", &IDeviceSettings::setCommanderResistorFor, pybind11::call_guard()) @@ -62,7 +62,7 @@ void init_idevicesettings(pybind11::module_& m) { .def("set_lin_mode", &IDeviceSettings::setLINModeFor, pybind11::call_guard()) .def("get_lin_commander_response_time", &IDeviceSettings::getLINCommanderResponseTimeFor, pybind11::call_guard()) .def("set_lin_commander_response_time", &IDeviceSettings::setLINCommanderResponseTimeFor, pybind11::call_guard()) - + // Ethernet PHY methods .def("get_phy_enable", &IDeviceSettings::getPhyEnable, pybind11::call_guard()) .def("get_phy_mode", &IDeviceSettings::getPhyMode, pybind11::call_guard()) @@ -70,6 +70,20 @@ void init_idevicesettings(pybind11::module_& m) { .def("set_phy_enable", &IDeviceSettings::setPhyEnable, pybind11::call_guard()) .def("set_phy_mode", &IDeviceSettings::setPhyMode, pybind11::call_guard()) .def("set_phy_speed", &IDeviceSettings::setPhySpeed, pybind11::call_guard()) + + // 10BASE-T1S methods + .def("is_t1s_plca_enabled", &IDeviceSettings::isT1SPLCAEnabledFor, pybind11::call_guard()) + .def("set_t1s_plca", &IDeviceSettings::setT1SPLCAFor, pybind11::call_guard()) + .def("get_t1s_local_id", &IDeviceSettings::getT1SLocalIDFor, pybind11::call_guard()) + .def("set_t1s_local_id", &IDeviceSettings::setT1SLocalIDFor, pybind11::call_guard()) + .def("get_t1s_max_nodes", &IDeviceSettings::getT1SMaxNodesFor, pybind11::call_guard()) + .def("set_t1s_max_nodes", &IDeviceSettings::setT1SMaxNodesFor, pybind11::call_guard()) + .def("get_t1s_tx_opp_timer", &IDeviceSettings::getT1STxOppTimerFor, pybind11::call_guard()) + .def("set_t1s_tx_opp_timer", &IDeviceSettings::setT1STxOppTimerFor, pybind11::call_guard()) + .def("get_t1s_max_burst", &IDeviceSettings::getT1SMaxBurstFor, pybind11::call_guard()) + .def("set_t1s_max_burst", &IDeviceSettings::setT1SMaxBurstFor, pybind11::call_guard()) + .def("get_t1s_burst_timer", &IDeviceSettings::getT1SBurstTimerFor, pybind11::call_guard()) + .def("set_t1s_burst_timer", &IDeviceSettings::setT1SBurstTimerFor, pybind11::call_guard()) // Status properties .def_readonly("disabled", &IDeviceSettings::disabled) diff --git a/include/icsneo/device/idevicesettings.h b/include/icsneo/device/idevicesettings.h index 8998b7e..35443c7 100644 --- a/include/icsneo/device/idevicesettings.h +++ b/include/icsneo/device/idevicesettings.h @@ -940,6 +940,74 @@ public: report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning); return std::nullopt; } + + virtual std::optional isT1SPLCAEnabledFor(Network net) const { + (void)net; + report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning); + return std::nullopt; + } + + virtual bool setT1SPLCAFor(Network net, bool enable) { + (void)net; (void)enable; + report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning); + return false; + } + + virtual std::optional getT1SLocalIDFor(Network net) const { + (void)net; + report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning); + return std::nullopt; + } + + virtual bool setT1SLocalIDFor(Network net, uint8_t id) { + (void)net; (void)id; + return false; + } + + virtual std::optional getT1SMaxNodesFor(Network net) const { + (void)net; + report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning); + return std::nullopt; + } + + virtual bool setT1SMaxNodesFor(Network net, uint8_t nodes) { + (void)net; (void)nodes; + return false; + } + + virtual std::optional getT1STxOppTimerFor(Network net) const { + (void)net; + report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning); + return std::nullopt; + } + + virtual bool setT1STxOppTimerFor(Network net, uint8_t timer) { + (void)net; (void)timer; + return false; + } + + virtual std::optional getT1SMaxBurstFor(Network net) const { + (void)net; + report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning); + return std::nullopt; + } + + virtual bool setT1SMaxBurstFor(Network net, uint8_t burst) { + (void)net; (void)burst; + return false; + } + + virtual std::optional getT1SBurstTimerFor(Network net) const { + (void)net; + report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning); + return std::nullopt; + } + + virtual bool setT1SBurstTimerFor(Network net, uint8_t timer) { + (void)net; (void)timer; + return false; + } + const void* getRawStructurePointer() const { return settingsInDeviceRAM.data(); } void* getMutableRawStructurePointer() { return settings.data(); } template const T* getStructurePointer() const { return reinterpret_cast(getRawStructurePointer()); } diff --git a/include/icsneo/device/tree/neovifire3t1slin/neovifire3t1slinsettings.h b/include/icsneo/device/tree/neovifire3t1slin/neovifire3t1slinsettings.h index fc8eb73..d357415 100644 --- a/include/icsneo/device/tree/neovifire3t1slin/neovifire3t1slinsettings.h +++ b/include/icsneo/device/tree/neovifire3t1slin/neovifire3t1slinsettings.h @@ -257,6 +257,153 @@ public: } } + std::optional isT1SPLCAEnabledFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional((t1s->flags & ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA) != 0); + } + + bool setT1SPLCAFor(Network net, bool enable) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + if(enable) + t1s->flags |= ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA; + else + t1s->flags &= ~ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA; + + return true; + } + + std::optional getT1SLocalIDFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->local_id); + } + + bool setT1SLocalIDFor(Network net, uint8_t id) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->local_id = id; + return true; + } + + std::optional getT1SMaxNodesFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->max_num_nodes); + } + + bool setT1SMaxNodesFor(Network net, uint8_t nodes) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->max_num_nodes = nodes; + return true; + } + + std::optional getT1STxOppTimerFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->to_timer); + } + + bool setT1STxOppTimerFor(Network net, uint8_t timer) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->to_timer = timer; + return true; + } + + std::optional getT1SMaxBurstFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->max_burst_count); + } + + bool setT1SMaxBurstFor(Network net, uint8_t burst) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->max_burst_count = burst; + return true; + } + + std::optional getT1SBurstTimerFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->burst_timer); + } + + bool setT1SBurstTimerFor(Network net, uint8_t timer) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->burst_timer = timer; + return true; + } + +private: + const ETHERNET10T1S_SETTINGS* getT1SSettingsFor(Network net) const { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + + switch(net.getNetID()) { + case Network::NetID::AE_01: return &(cfg->t1s1); + case Network::NetID::AE_02: return &(cfg->t1s2); + case Network::NetID::AE_03: return &(cfg->t1s3); + case Network::NetID::AE_04: return &(cfg->t1s4); + case Network::NetID::AE_05: return &(cfg->t1s5); + case Network::NetID::AE_06: return &(cfg->t1s6); + case Network::NetID::AE_07: return &(cfg->t1s7); + case Network::NetID::AE_08: return &(cfg->t1s8); + default: + report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error); + return nullptr; + } + } + + ETHERNET10T1S_SETTINGS* getMutableT1SSettingsFor(Network net) { + auto cfg = getMutableStructurePointer(); + if(cfg == nullptr) + return nullptr; + + switch(net.getNetID()) { + case Network::NetID::AE_01: return &(cfg->t1s1); + case Network::NetID::AE_02: return &(cfg->t1s2); + case Network::NetID::AE_03: return &(cfg->t1s3); + case Network::NetID::AE_04: return &(cfg->t1s4); + case Network::NetID::AE_05: return &(cfg->t1s5); + case Network::NetID::AE_06: return &(cfg->t1s6); + case Network::NetID::AE_07: return &(cfg->t1s7); + case Network::NetID::AE_08: return &(cfg->t1s8); + default: + report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error); + return nullptr; + } + } + protected: ICSNEO_UNALIGNED(const uint64_t*) getTerminationEnables() const override { auto cfg = getStructurePointer(); diff --git a/include/icsneo/device/tree/radcomet3/radcomet3settings.h b/include/icsneo/device/tree/radcomet3/radcomet3settings.h index 7be7d7f..f5ef3dd 100644 --- a/include/icsneo/device/tree/radcomet3/radcomet3settings.h +++ b/include/icsneo/device/tree/radcomet3/radcomet3settings.h @@ -113,6 +113,149 @@ public: return nullptr; } } + + std::optional isT1SPLCAEnabledFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional((t1s->flags & ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA) != 0); + } + + bool setT1SPLCAFor(Network net, bool enable) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + if(enable) + t1s->flags |= ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA; + else + t1s->flags &= ~ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA; + + return true; + } + + std::optional getT1SLocalIDFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->local_id); + } + + bool setT1SLocalIDFor(Network net, uint8_t id) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->local_id = id; + return true; + } + + std::optional getT1SMaxNodesFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->max_num_nodes); + } + + bool setT1SMaxNodesFor(Network net, uint8_t nodes) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->max_num_nodes = nodes; + return true; + } + + std::optional getT1STxOppTimerFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->to_timer); + } + + bool setT1STxOppTimerFor(Network net, uint8_t timer) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->to_timer = timer; + return true; + } + + std::optional getT1SMaxBurstFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->max_burst_count); + } + + bool setT1SMaxBurstFor(Network net, uint8_t burst) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->max_burst_count = burst; + return true; + } + + std::optional getT1SBurstTimerFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->burst_timer); + } + + bool setT1SBurstTimerFor(Network net, uint8_t timer) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->burst_timer = timer; + return true; + } + +private: + const ETHERNET10T1S_SETTINGS* getT1SSettingsFor(Network net) const { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + + switch(net.getNetID()) { + case Network::NetID::AE_02: return &(cfg->t1s1); + case Network::NetID::AE_03: return &(cfg->t1s2); + case Network::NetID::AE_04: return &(cfg->t1s3); + case Network::NetID::AE_05: return &(cfg->t1s4); + case Network::NetID::AE_06: return &(cfg->t1s5); + case Network::NetID::AE_07: return &(cfg->t1s6); + default: + report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error); + return nullptr; + } + } + + ETHERNET10T1S_SETTINGS* getMutableT1SSettingsFor(Network net) { + auto cfg = getMutableStructurePointer(); + if(cfg == nullptr) + return nullptr; + + switch(net.getNetID()) { + case Network::NetID::AE_02: return &(cfg->t1s1); + case Network::NetID::AE_03: return &(cfg->t1s2); + case Network::NetID::AE_04: return &(cfg->t1s3); + case Network::NetID::AE_05: return &(cfg->t1s4); + case Network::NetID::AE_06: return &(cfg->t1s5); + case Network::NetID::AE_07: return &(cfg->t1s6); + default: + report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error); + return nullptr; + } + } }; } diff --git a/include/icsneo/device/tree/radgigastar2/radgigastar2settings.h b/include/icsneo/device/tree/radgigastar2/radgigastar2settings.h index cc4e4d6..c45ff12 100644 --- a/include/icsneo/device/tree/radgigastar2/radgigastar2settings.h +++ b/include/icsneo/device/tree/radgigastar2/radgigastar2settings.h @@ -249,6 +249,153 @@ namespace icsneo } } + std::optional isT1SPLCAEnabledFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional((t1s->flags & ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA) != 0); + } + + bool setT1SPLCAFor(Network net, bool enable) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + if(enable) + t1s->flags |= ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA; + else + t1s->flags &= ~ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA; + + return true; + } + + std::optional getT1SLocalIDFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->local_id); + } + + bool setT1SLocalIDFor(Network net, uint8_t id) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->local_id = id; + return true; + } + + std::optional getT1SMaxNodesFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->max_num_nodes); + } + + bool setT1SMaxNodesFor(Network net, uint8_t nodes) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->max_num_nodes = nodes; + return true; + } + + std::optional getT1STxOppTimerFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->to_timer); + } + + bool setT1STxOppTimerFor(Network net, uint8_t timer) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->to_timer = timer; + return true; + } + + std::optional getT1SMaxBurstFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->max_burst_count); + } + + bool setT1SMaxBurstFor(Network net, uint8_t burst) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->max_burst_count = burst; + return true; + } + + std::optional getT1SBurstTimerFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->burst_timer); + } + + bool setT1SBurstTimerFor(Network net, uint8_t timer) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->burst_timer = timer; + return true; + } + + private: + const ETHERNET10T1S_SETTINGS* getT1SSettingsFor(Network net) const { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + + switch(net.getNetID()) { + case Network::NetID::AE_03: return &(cfg->t1s1); + case Network::NetID::AE_04: return &(cfg->t1s2); + case Network::NetID::AE_05: return &(cfg->t1s3); + case Network::NetID::AE_06: return &(cfg->t1s4); + case Network::NetID::AE_07: return &(cfg->t1s5); + case Network::NetID::AE_08: return &(cfg->t1s6); + case Network::NetID::AE_09: return &(cfg->t1s7); + case Network::NetID::AE_10: return &(cfg->t1s8); + default: + report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error); + return nullptr; + } + } + + ETHERNET10T1S_SETTINGS* getMutableT1SSettingsFor(Network net) { + auto cfg = getMutableStructurePointer(); + if(cfg == nullptr) + return nullptr; + + switch(net.getNetID()) { + case Network::NetID::AE_03: return &(cfg->t1s1); + case Network::NetID::AE_04: return &(cfg->t1s2); + case Network::NetID::AE_05: return &(cfg->t1s3); + case Network::NetID::AE_06: return &(cfg->t1s4); + case Network::NetID::AE_07: return &(cfg->t1s5); + case Network::NetID::AE_08: return &(cfg->t1s6); + case Network::NetID::AE_09: return &(cfg->t1s7); + case Network::NetID::AE_10: return &(cfg->t1s8); + default: + report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error); + return nullptr; + } + } + protected: ICSNEO_UNALIGNED(const uint64_t *) getTerminationEnables() const override diff --git a/include/icsneo/device/tree/radmoont1s/radmoont1ssettings.h b/include/icsneo/device/tree/radmoont1s/radmoont1ssettings.h index d71c022..7afb90b 100644 --- a/include/icsneo/device/tree/radmoont1s/radmoont1ssettings.h +++ b/include/icsneo/device/tree/radmoont1s/radmoont1ssettings.h @@ -47,6 +47,169 @@ static_assert(sizeof(radmoont1s_settings_t) == 160, "RADMoonT1S settings size mi class RADMoonT1SSettings : public IDeviceSettings { public: RADMoonT1SSettings(std::shared_ptr com) : IDeviceSettings(com, sizeof(radmoont1s_settings_t)) {} + + std::optional isT1SPLCAEnabledFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional((t1s->flags & ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA) != 0); + } + + bool setT1SPLCAFor(Network net, bool enable) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + if(enable) + t1s->flags |= ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA; + else + t1s->flags &= ~ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA; + + return true; + } + + std::optional getT1SLocalIDFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->local_id); + } + + bool setT1SLocalIDFor(Network net, uint8_t id) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->local_id = id; + return true; + } + + std::optional getT1SMaxNodesFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->max_num_nodes); + } + + bool setT1SMaxNodesFor(Network net, uint8_t nodes) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->max_num_nodes = nodes; + return true; + } + + std::optional getT1STxOppTimerFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->to_timer); + } + + bool setT1STxOppTimerFor(Network net, uint8_t timer) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->to_timer = timer; + return true; + } + + std::optional getT1SMaxBurstFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->max_burst_count); + } + + bool setT1SMaxBurstFor(Network net, uint8_t burst) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->max_burst_count = burst; + return true; + } + + std::optional getT1SBurstTimerFor(Network net) const override { + const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net); + if(t1s == nullptr) + return std::nullopt; + + return std::make_optional(t1s->burst_timer); + } + + bool setT1SBurstTimerFor(Network net, uint8_t timer) override { + ETHERNET10T1S_SETTINGS* t1s = getMutableT1SSettingsFor(net); + if(t1s == nullptr) + return false; + + t1s->burst_timer = timer; + return true; + } + +private: + const ETHERNET10T1S_SETTINGS* getT1SSettingsFor(Network net) const { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + + switch(net.getNetID()) { + case Network::NetID::AE_01: + return &(cfg->t1s); + default: + report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error); + return nullptr; + } + } + + ETHERNET10T1S_SETTINGS* getMutableT1SSettingsFor(Network net) { + auto cfg = getMutableStructurePointer(); + if(cfg == nullptr) + return nullptr; + + switch(net.getNetID()) { + case Network::NetID::AE_01: + return &(cfg->t1s); + default: + report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error); + return nullptr; + } + } + + const ETHERNET10T1S_SETTINGS_EXT* getT1SSettingsExtFor(Network net) const { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + + switch(net.getNetID()) { + case Network::NetID::AE_01: + return &(cfg->t1sExt); + default: + report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error); + return nullptr; + } + } + + ETHERNET10T1S_SETTINGS_EXT* getMutableT1SSettingsExtFor(Network net) { + auto cfg = getMutableStructurePointer(); + if(cfg == nullptr) + return nullptr; + + switch(net.getNetID()) { + case Network::NetID::AE_01: + return &(cfg->t1sExt); + default: + report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error); + return nullptr; + } + } }; }