|
38 | 38 | #include "../../core/objectproperty.tpp" |
39 | 39 | #include "../../log/log.hpp" |
40 | 40 | #include "../../log/logmessageexception.hpp" |
| 41 | +#include "../../utils/category.hpp" |
41 | 42 | #include "../../utils/displayname.hpp" |
42 | 43 | #include "../../utils/inrange.hpp" |
43 | 44 | #include "../../utils/makearray.hpp" |
@@ -96,6 +97,8 @@ XpressNetInterface::XpressNetInterface(World& world, std::string_view _id) |
96 | 97 | , s88StartAddress{this, "s88_start_address", XpressNet::RoSoftS88XpressNetLI::S88StartAddress::startAddressDefault, PropertyFlags::ReadWrite | PropertyFlags::Store} |
97 | 98 | , s88ModuleCount{this, "s88_module_count", XpressNet::RoSoftS88XpressNetLI::S88ModuleCount::moduleCountDefault, PropertyFlags::ReadWrite | PropertyFlags::Store} |
98 | 99 | , xpressnet{this, "xpressnet", nullptr, PropertyFlags::ReadOnly | PropertyFlags::Store | PropertyFlags::SubObject} |
| 100 | + , xbusVersion{this, "xbus_version", "", PropertyFlags::ReadOnly | PropertyFlags::NoStore} |
| 101 | + , commandStationType{this, "command_station_type", "", PropertyFlags::ReadOnly | PropertyFlags::NoStore} |
99 | 102 | , luaSendMsg{*this, "send_msg", MethodFlags::ScriptCallable, |
100 | 103 | [this](const std::string &msgHexStr) |
101 | 104 | { |
@@ -159,6 +162,12 @@ XpressNetInterface::XpressNetInterface(World& world, std::string_view _id) |
159 | 162 |
|
160 | 163 | m_interfaceItems.insertBefore(outputs, notes); |
161 | 164 |
|
| 165 | + Attributes::addCategory(xbusVersion, Category::info); |
| 166 | + m_interfaceItems.insertBefore(xbusVersion, notes); |
| 167 | + |
| 168 | + Attributes::addCategory(commandStationType, Category::info); |
| 169 | + m_interfaceItems.insertBefore(commandStationType, notes); |
| 170 | + |
162 | 171 | m_interfaceItems.add(luaSendMsg); |
163 | 172 |
|
164 | 173 | decoderAddedRemovedConn = std::static_pointer_cast<Object>(decoders.value())->propertyChanged.connect( |
@@ -356,6 +365,20 @@ bool XpressNetInterface::setOnline(bool& value, bool simulation) |
356 | 365 | setState(InterfaceState::Error); |
357 | 366 | online = false; // communication no longer possible |
358 | 367 | }); |
| 368 | + m_kernel->setOnHardwareInfoChanged( |
| 369 | + [this](XpressNet::HardwareType hwType, uint8_t versionMajor, uint8_t versionMinor) |
| 370 | + { |
| 371 | + commandStationType.setValueInternal(std::string(XpressNet::toString(hwType))); |
| 372 | + Log::log(*this, LogMessage::I2002_HARDWARE_TYPE_X, commandStationType.value()); |
| 373 | + |
| 374 | + if(versionMajor != 0) |
| 375 | + { |
| 376 | + xbusVersion.setValueInternal(std::to_string(versionMajor).append(".").append(std::to_string(versionMinor))); |
| 377 | + Log::log(*this, LogMessage::I2003_FIRMWARE_VERSION_X, xbusVersion.value()); |
| 378 | + } |
| 379 | + else |
| 380 | + xbusVersion.setValueInternal(""); |
| 381 | + }); |
359 | 382 | m_kernel->setOnTrackPowerChanged( |
360 | 383 | [this](bool powerOn, bool isStopped) |
361 | 384 | { |
@@ -431,6 +454,8 @@ bool XpressNetInterface::setOnline(bool& value, bool simulation) |
431 | 454 | EventLoop::deleteLater(m_kernel.release()); |
432 | 455 |
|
433 | 456 | setState(InterfaceState::Offline); |
| 457 | + xbusVersion.setValueInternal(""); |
| 458 | + commandStationType.setValueInternal(""); |
434 | 459 | } |
435 | 460 | return true; |
436 | 461 | } |
|
0 commit comments