diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 624488fc..b9678ba9 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -139,6 +139,8 @@ file(GLOB SOURCES "src/network/*.cpp" "src/os/*.hpp" "src/os/*.cpp" + "src/status/*.hpp" + "src/status/*.cpp" "src/train/*.hpp" "src/train/*.cpp" "src/traintastic/*.hpp" diff --git a/server/src/hardware/interface/dccplusplusinterface.cpp b/server/src/hardware/interface/dccplusplusinterface.cpp index b270a782..e3b75580 100644 --- a/server/src/hardware/interface/dccplusplusinterface.cpp +++ b/server/src/hardware/interface/dccplusplusinterface.cpp @@ -125,13 +125,13 @@ bool DCCPlusPlusInterface::setOnline(bool& value, bool simulation) m_kernel = DCCPlusPlus::Kernel::create(dccplusplus->config(), device.value(), baudrate.value(), SerialFlowControl::None); } - status.setValueInternal(InterfaceStatus::Initializing); + setState(InterfaceState::Initializing); m_kernel->setLogId(id.value()); m_kernel->setOnStarted( [this]() { - status.setValueInternal(InterfaceStatus::Online); + setState(InterfaceState::Online); const bool powerOn = contains(m_world.state.value(), WorldState::PowerOn); @@ -173,7 +173,7 @@ bool DCCPlusPlusInterface::setOnline(bool& value, bool simulation) } catch(const LogMessageException& e) { - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); Log::log(*this, e.message(), e.args()); return false; } @@ -187,7 +187,7 @@ bool DCCPlusPlusInterface::setOnline(bool& value, bool simulation) m_kernel->stop(); m_kernel.reset(); - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); } return true; } diff --git a/server/src/hardware/interface/ecosinterface.cpp b/server/src/hardware/interface/ecosinterface.cpp index 8a25a476..1c19730d 100644 --- a/server/src/hardware/interface/ecosinterface.cpp +++ b/server/src/hardware/interface/ecosinterface.cpp @@ -129,13 +129,13 @@ bool ECoSInterface::setOnline(bool& value, bool simulation) else m_kernel = ECoS::Kernel::create(ecos->config(), hostname.value()); - status.setValueInternal(InterfaceStatus::Initializing); + setState(InterfaceState::Initializing); m_kernel->setLogId(id.value()); m_kernel->setOnStarted( [this]() { - status.setValueInternal(InterfaceStatus::Online); + setState(InterfaceState::Online); }); m_kernel->setOnEmergencyStop( [this]() @@ -169,7 +169,7 @@ bool ECoSInterface::setOnline(bool& value, bool simulation) } catch(const LogMessageException& e) { - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); Log::log(*this, e.message(), e.args()); return false; } @@ -183,7 +183,7 @@ bool ECoSInterface::setOnline(bool& value, bool simulation) m_kernel->stop(simulation ? nullptr : &m_simulation); m_kernel.reset(); - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); } return true; } diff --git a/server/src/hardware/interface/interface.cpp b/server/src/hardware/interface/interface.cpp index fb881b63..3e49f013 100644 --- a/server/src/hardware/interface/interface.cpp +++ b/server/src/hardware/interface/interface.cpp @@ -29,15 +29,22 @@ Interface::Interface(World& world, std::string_view _id) : IdObject(world, _id) - , name{this, "name", "", PropertyFlags::ReadWrite | PropertyFlags::Store} + , name{this, "name", "", PropertyFlags::ReadWrite | PropertyFlags::Store, + [this](const std::string& value) + { + status->label.setValueInternal(value); + }} , online{this, "online", false, PropertyFlags::ReadWrite | PropertyFlags::NoStore, nullptr, [this](bool& value) { return setOnline(value, contains(m_world.state.value(), WorldState::Simulation)); }} - , status{this, "status", InterfaceStatus::Offline, PropertyFlags::ReadOnly | PropertyFlags::NoStore} + , status{this, "status", nullptr, PropertyFlags::ReadOnly | PropertyFlags::NoStore} , notes{this, "notes", "", PropertyFlags::ReadWrite | PropertyFlags::Store} { + status.setValueInternal(std::make_shared(*this, status.name())); + status->label.setValueInternal(name.value()); + const bool editable = contains(m_world.state.value(), WorldState::Edit); Attributes::addDisplayName(name, DisplayName::Object::name); @@ -48,9 +55,7 @@ Interface::Interface(World& world, std::string_view _id) Attributes::addEnabled(online, contains(m_world.state.value(), WorldState::Online)); m_interfaceItems.add(online); - Attributes::addDisplayName(status, DisplayName::Interface::status); Attributes::addObjectEditor(status, false); - Attributes::addValues(status, interfaceStatusValues); m_interfaceItems.add(status); Attributes::addDisplayName(notes, DisplayName::Object::notes); @@ -61,11 +66,13 @@ void Interface::addToWorld() { IdObject::addToWorld(); m_world.interfaces->addObject(shared_ptr()); + m_world.statuses.appendInternal(status.value()); } void Interface::destroying() { online = false; // make sure interface is offline before destroying it + m_world.statuses.removeInternal(status.value()); m_world.interfaces->removeObject(shared_ptr()); IdObject::destroying(); } @@ -98,3 +105,8 @@ void Interface::worldEvent(WorldState state, WorldEvent event) break; } } + +void Interface::setState(InterfaceState value) +{ + status->state.setValueInternal(value); +} diff --git a/server/src/hardware/interface/interface.hpp b/server/src/hardware/interface/interface.hpp index b8d1713e..38019837 100644 --- a/server/src/hardware/interface/interface.hpp +++ b/server/src/hardware/interface/interface.hpp @@ -3,7 +3,7 @@ * * This file is part of the traintastic source code. * - * Copyright (C) 2021 Reinder Feenstra + * Copyright (C) 2021,2023 Reinder Feenstra * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,7 +24,8 @@ #define TRAINTASTIC_SERVER_HARDWARE_INTERFACE_INTERFACE_HPP #include "../../core/idobject.hpp" -#include "../../enum/interfacestatus.hpp" +#include "../../core/objectproperty.hpp" +#include "../../status/interfacestatus.hpp" /** * @brief Base class for a hardware interface @@ -39,11 +40,12 @@ class Interface : public IdObject void worldEvent(WorldState state, WorldEvent event) override; virtual bool setOnline(bool& value, bool simulation) = 0; + void setState(InterfaceState value); public: Property name; Property online; - Property status; + ObjectProperty status; Property notes; }; diff --git a/server/src/hardware/interface/interfacelisttablemodel.cpp b/server/src/hardware/interface/interfacelisttablemodel.cpp index a1ee88e5..d7de688b 100644 --- a/server/src/hardware/interface/interfacelisttablemodel.cpp +++ b/server/src/hardware/interface/interfacelisttablemodel.cpp @@ -3,7 +3,7 @@ * * This file is part of the traintastic source code. * - * Copyright (C) 2021 Reinder Feenstra + * Copyright (C) 2021,2023 Reinder Feenstra * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -22,6 +22,7 @@ #include "interfacelisttablemodel.hpp" #include "interfacelist.hpp" +#include "../../core/objectproperty.tpp" #include "../../utils/displayname.hpp" constexpr uint32_t columnId = 0; @@ -61,8 +62,8 @@ std::string InterfaceListTableModel::getText(uint32_t column, uint32_t row) cons return interface.name; case columnStatus: - if(const auto* it = EnumValues::value.find(interface.status); it != EnumValues::value.end()) - return std::string("$").append(EnumName::value).append(":").append(it->second).append("$"); + if(const auto* it = EnumValues::value.find(interface.status->state); it != EnumValues::value.end()) + return std::string("$").append(EnumName::value).append(":").append(it->second).append("$"); break; default: diff --git a/server/src/hardware/interface/loconetinterface.cpp b/server/src/hardware/interface/loconetinterface.cpp index 1ea79dac..dd0e7423 100644 --- a/server/src/hardware/interface/loconetinterface.cpp +++ b/server/src/hardware/interface/loconetinterface.cpp @@ -249,18 +249,18 @@ bool LocoNetInterface::setOnline(bool& value, bool simulation) } } - status.setValueInternal(InterfaceStatus::Initializing); + setState(InterfaceState::Initializing); m_kernel->setLogId(id.value()); m_kernel->setOnStarted( [this]() { - status.setValueInternal(InterfaceStatus::Online); + setState(InterfaceState::Online); }); m_kernel->setOnError( [this]() { - status.setValueInternal(InterfaceStatus::Error); + setState(InterfaceState::Error); online = false; // communication no longer possible }); m_kernel->setOnGlobalPowerChanged( @@ -314,7 +314,7 @@ bool LocoNetInterface::setOnline(bool& value, bool simulation) } catch(const LogMessageException& e) { - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); Log::log(*this, e.message(), e.args()); return false; } @@ -333,8 +333,8 @@ bool LocoNetInterface::setOnline(bool& value, bool simulation) m_kernel->stop(); m_kernel.reset(); - if(status != InterfaceStatus::Error) - status.setValueInternal(InterfaceStatus::Offline); + if(status->state != InterfaceState::Error) + setState(InterfaceState::Offline); } return true; } diff --git a/server/src/hardware/interface/traintasticdiyinterface.cpp b/server/src/hardware/interface/traintasticdiyinterface.cpp index 3c27fcbe..c3a71fe9 100644 --- a/server/src/hardware/interface/traintasticdiyinterface.cpp +++ b/server/src/hardware/interface/traintasticdiyinterface.cpp @@ -141,13 +141,13 @@ bool TraintasticDIYInterface::setOnline(bool& value, bool simulation) return false; } - status.setValueInternal(InterfaceStatus::Initializing); + setState(InterfaceState::Initializing); m_kernel->setLogId(id.value()); m_kernel->setOnStarted( [this]() { - status.setValueInternal(InterfaceStatus::Online); + setState(InterfaceState::Online); }); m_kernel->setInputController(this); @@ -164,7 +164,7 @@ bool TraintasticDIYInterface::setOnline(bool& value, bool simulation) } catch(const LogMessageException& e) { - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); Log::log(*this, e.message(), e.args()); return false; } @@ -178,7 +178,7 @@ bool TraintasticDIYInterface::setOnline(bool& value, bool simulation) m_kernel->stop(); m_kernel.reset(); - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); } return true; } diff --git a/server/src/hardware/interface/withrottleinterface.cpp b/server/src/hardware/interface/withrottleinterface.cpp index 9ac75129..14fc039b 100644 --- a/server/src/hardware/interface/withrottleinterface.cpp +++ b/server/src/hardware/interface/withrottleinterface.cpp @@ -84,14 +84,14 @@ bool WiThrottleInterface::setOnline(bool& value, bool simulation) { m_kernel = WiThrottle::Kernel::create(wiThrottle->config(), port.value()); - status.setValueInternal(InterfaceStatus::Initializing); + setState(InterfaceState::Initializing); m_kernel->setLogId(id.value()); m_kernel->setOnStarted( [this]() { - status.setValueInternal(InterfaceStatus::Online); + setState(InterfaceState::Online); }); m_kernel->setClock(world().clock.value()); @@ -105,7 +105,7 @@ bool WiThrottleInterface::setOnline(bool& value, bool simulation) } catch(const LogMessageException& e) { - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); Log::log(*this, e.message(), e.args()); return false; } @@ -117,7 +117,7 @@ bool WiThrottleInterface::setOnline(bool& value, bool simulation) m_kernel->stop(); m_kernel.reset(); - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); } return true; diff --git a/server/src/hardware/interface/wlanmausinterface.cpp b/server/src/hardware/interface/wlanmausinterface.cpp index 22f0b79f..32a6d9eb 100644 --- a/server/src/hardware/interface/wlanmausinterface.cpp +++ b/server/src/hardware/interface/wlanmausinterface.cpp @@ -81,13 +81,13 @@ bool WlanMausInterface::setOnline(bool& value, bool simulation) { m_kernel = Z21::ServerKernel::create(z21->config(), m_world.decoders.value()); - status.setValueInternal(InterfaceStatus::Initializing); + setState(InterfaceState::Initializing); m_kernel->setLogId(id.value()); m_kernel->setOnStarted( [this]() { - status.setValueInternal(InterfaceStatus::Online); + setState(InterfaceState::Online); }); m_kernel->setOnTrackPowerOff( @@ -123,7 +123,7 @@ bool WlanMausInterface::setOnline(bool& value, bool simulation) } catch(const LogMessageException& e) { - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); Log::log(*this, e.message(), e.args()); return false; } @@ -133,7 +133,7 @@ bool WlanMausInterface::setOnline(bool& value, bool simulation) m_kernel->stop(); m_kernel.reset(); - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); } return true; } diff --git a/server/src/hardware/interface/xpressnetinterface.cpp b/server/src/hardware/interface/xpressnetinterface.cpp index 252307c8..49797940 100644 --- a/server/src/hardware/interface/xpressnetinterface.cpp +++ b/server/src/hardware/interface/xpressnetinterface.cpp @@ -218,13 +218,13 @@ bool XpressNetInterface::setOnline(bool& value, bool simulation) return false; } - status.setValueInternal(InterfaceStatus::Initializing); + setState(InterfaceState::Initializing); m_kernel->setLogId(id.value()); m_kernel->setOnStarted( [this]() { - status.setValueInternal(InterfaceStatus::Online); + setState(InterfaceState::Online); }); m_kernel->setOnNormalOperationResumed( [this]() @@ -271,7 +271,7 @@ bool XpressNetInterface::setOnline(bool& value, bool simulation) } catch(const LogMessageException& e) { - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); Log::log(*this, e.message(), e.args()); return false; } @@ -285,7 +285,7 @@ bool XpressNetInterface::setOnline(bool& value, bool simulation) m_kernel->stop(); m_kernel.reset(); - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); } return true; } diff --git a/server/src/hardware/interface/z21interface.cpp b/server/src/hardware/interface/z21interface.cpp index b1e98804..137d67ab 100644 --- a/server/src/hardware/interface/z21interface.cpp +++ b/server/src/hardware/interface/z21interface.cpp @@ -130,13 +130,13 @@ bool Z21Interface::setOnline(bool& value, bool simulation) else m_kernel = Z21::ClientKernel::create(z21->config(), hostname.value(), port.value()); - status.setValueInternal(InterfaceStatus::Initializing); + setState(InterfaceState::Initializing); m_kernel->setLogId(id.value()); m_kernel->setOnStarted( [this]() { - status.setValueInternal(InterfaceStatus::Online); + setState(InterfaceState::Online); }); m_kernel->setOnSerialNumberChanged( [this](uint32_t newValue) @@ -199,7 +199,7 @@ bool Z21Interface::setOnline(bool& value, bool simulation) } catch(const LogMessageException& e) { - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); Log::log(*this, e.message(), e.args()); return false; } @@ -213,7 +213,7 @@ bool Z21Interface::setOnline(bool& value, bool simulation) m_kernel->stop(); m_kernel.reset(); - status.setValueInternal(InterfaceStatus::Offline); + setState(InterfaceState::Offline); hardwareType.setValueInternal(""); serialNumber.setValueInternal(""); firmwareVersion.setValueInternal(""); diff --git a/server/src/status/interfacestatus.cpp b/server/src/status/interfacestatus.cpp new file mode 100644 index 00000000..360a86c5 --- /dev/null +++ b/server/src/status/interfacestatus.cpp @@ -0,0 +1,32 @@ +/** + * server/src/status/interfacestatus.cpp + * + * This file is part of the traintastic source code. + * + * Copyright (C) 2023 Reinder Feenstra + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "interfacestatus.hpp" +#include "../core/attributes.hpp" + +InterfaceStatus::InterfaceStatus(Object& parent_, std::string_view parentPropertyName_) + : Status(parent_, parentPropertyName_) + , state(this, "state", InterfaceState::Offline, PropertyFlags::ReadOnly | PropertyFlags::NoStore) +{ + Attributes::addValues(state, interfaceStateValues); + m_interfaceItems.add(state); +} diff --git a/shared/src/traintastic/enum/interfacestatus.hpp b/server/src/status/interfacestatus.hpp similarity index 58% rename from shared/src/traintastic/enum/interfacestatus.hpp rename to server/src/status/interfacestatus.hpp index fd69c840..969a33ca 100644 --- a/shared/src/traintastic/enum/interfacestatus.hpp +++ b/server/src/status/interfacestatus.hpp @@ -1,9 +1,9 @@ /** - * shared/src/enum/interfacestatus.hpp + * server/src/status/interfacestatus.hpp * * This file is part of the traintastic source code. * - * Copyright (C) 2021-2022 Reinder Feenstra + * Copyright (C) 2023 Reinder Feenstra * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,26 +20,22 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef TRAINTASTIC_SHARED_TRAINTASTIC_ENUM_INTERFACESTATUS_HPP -#define TRAINTASTIC_SHARED_TRAINTASTIC_ENUM_INTERFACESTATUS_HPP +#ifndef TRAINTASTIC_SERVER_STATUS_INTERFACESTATUS_HPP +#define TRAINTASTIC_SERVER_STATUS_INTERFACESTATUS_HPP -#include -#include "enum.hpp" +#include "status.hpp" +#include -enum class InterfaceStatus : uint8_t +class Interface; + +class InterfaceStatus : public Status { - Offline = 0, - Initializing = 1, - Online = 2, - Error = 255, + CLASS_ID("status.interface") + + public: + Property state; + + InterfaceStatus(Object& parent_, std::string_view parentPropertyName_); }; -TRAINTASTIC_ENUM(InterfaceStatus, "interface_status", 4, -{ - {InterfaceStatus::Offline, "offline"}, - {InterfaceStatus::Initializing, "initializing"}, - {InterfaceStatus::Online, "online"}, - {InterfaceStatus::Error, "error"}, -}); - #endif diff --git a/server/src/status/status.cpp b/server/src/status/status.cpp new file mode 100644 index 00000000..857d7044 --- /dev/null +++ b/server/src/status/status.cpp @@ -0,0 +1,30 @@ +/** + * server/src/status/status.cpp + * + * This file is part of the traintastic source code. + * + * Copyright (C) 2023 Reinder Feenstra + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "status.hpp" + +Status::Status(Object& parent_, std::string_view parentPropertyName_) + : SubObject(parent_, parentPropertyName_) + , label{this, "label", "", PropertyFlags::ReadOnly | PropertyFlags::NoStore} +{ + m_interfaceItems.add(label); +} diff --git a/server/src/enum/interfacestatus.hpp b/server/src/status/status.hpp similarity index 65% rename from server/src/enum/interfacestatus.hpp rename to server/src/status/status.hpp index abe04307..6e5db42c 100644 --- a/server/src/enum/interfacestatus.hpp +++ b/server/src/status/status.hpp @@ -1,9 +1,9 @@ /** - * server/src/enum/interfacestatus.hpp + * server/src/status/status.hpp * * This file is part of the traintastic source code. * - * Copyright (C) 2021 Reinder Feenstra + * Copyright (C) 2023 Reinder Feenstra * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,16 +20,18 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef TRAINTASTIC_SERVER_ENUM_INTERFACESTATUS_HPP -#define TRAINTASTIC_SERVER_ENUM_INTERFACESTATUS_HPP +#ifndef TRAINTASTIC_SERVER_STATUS_STATUS_HPP +#define TRAINTASTIC_SERVER_STATUS_STATUS_HPP -#include +#include "../core/subobject.hpp" +#include "../core/property.hpp" -inline constexpr std::array interfaceStatusValues{{ - InterfaceStatus::Offline, - InterfaceStatus::Initializing, - InterfaceStatus::Online, - InterfaceStatus::Error, -}}; +class Status : public SubObject +{ + public: + Property label; + + Status(Object& parent_, std::string_view parentPropertyName_); +}; #endif diff --git a/server/src/world/world.cpp b/server/src/world/world.cpp index 9d9b1a05..00f71d25 100644 --- a/server/src/world/world.cpp +++ b/server/src/world/world.cpp @@ -122,6 +122,7 @@ World::World(Private /*unused*/) : railVehicles{this, "rail_vehicles", nullptr, PropertyFlags::ReadOnly | PropertyFlags::SubObject | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly}, luaScripts{this, "lua_scripts", nullptr, PropertyFlags::ReadOnly | PropertyFlags::SubObject | PropertyFlags::NoStore}, linkRailTiles{this, "link_rail_tiles", nullptr, PropertyFlags::ReadOnly | PropertyFlags::SubObject | PropertyFlags::NoStore}, + statuses(*this, "statuses", {}, PropertyFlags::ReadOnly | PropertyFlags::Store), hardwareThrottles{this, "hardware_throttles", 0, PropertyFlags::ReadOnly | PropertyFlags::NoStore | PropertyFlags::NoScript}, state{this, "state", WorldState(), PropertyFlags::ReadOnly | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly}, edit{this, "edit", false, PropertyFlags::ReadWrite | PropertyFlags::NoStore, @@ -305,6 +306,9 @@ World::World(Private /*unused*/) : Attributes::addObjectEditor(linkRailTiles, false); m_interfaceItems.add(linkRailTiles); + Attributes::addObjectEditor(statuses, false); + m_interfaceItems.add(statuses); + Attributes::addObjectEditor(hardwareThrottles, false); m_interfaceItems.add(hardwareThrottles); diff --git a/server/src/world/world.hpp b/server/src/world/world.hpp index 0723be4d..93b09108 100644 --- a/server/src/world/world.hpp +++ b/server/src/world/world.hpp @@ -26,6 +26,7 @@ #include "../core/object.hpp" #include "../core/property.hpp" #include "../core/objectproperty.hpp" +#include "../core/objectvectorproperty.hpp" #include "../core/controllerlist.hpp" #include "../core/method.hpp" #include "../core/event.hpp" @@ -34,6 +35,7 @@ #include #include #include "../enum/worldscale.hpp" +#include "../status/status.hpp" #include class WorldLoader; @@ -114,6 +116,7 @@ class World : public Object ObjectProperty linkRailTiles; + ObjectVectorProperty statuses; Property hardwareThrottles; // state; diff --git a/shared/src/traintastic/enum/interfacestate.hpp b/shared/src/traintastic/enum/interfacestate.hpp new file mode 100644 index 00000000..b4f189a3 --- /dev/null +++ b/shared/src/traintastic/enum/interfacestate.hpp @@ -0,0 +1,53 @@ +/** + * shared/src/enum/interfacestate.hpp + * + * This file is part of the traintastic source code. + * + * Copyright (C) 2021-2023 Reinder Feenstra + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef TRAINTASTIC_SHARED_TRAINTASTIC_ENUM_INTERFACESTATE_HPP +#define TRAINTASTIC_SHARED_TRAINTASTIC_ENUM_INTERFACESTATE_HPP + +#include +#include +#include "enum.hpp" + +enum class InterfaceState : uint8_t +{ + Offline = 0, + Initializing = 1, + Online = 2, + Error = 255, +}; + +TRAINTASTIC_ENUM(InterfaceState, "interface_state", 4, +{ + {InterfaceState::Offline, "offline"}, + {InterfaceState::Initializing, "initializing"}, + {InterfaceState::Online, "online"}, + {InterfaceState::Error, "error"}, +}); + +inline constexpr std::array interfaceStateValues{{ + InterfaceState::Offline, + InterfaceState::Initializing, + InterfaceState::Online, + InterfaceState::Error, +}}; + +#endif diff --git a/shared/translations/de-de.txt b/shared/translations/de-de.txt index 2207f5c7..333b0b85 100644 --- a/shared/translations/de-de.txt +++ b/shared/translations/de-de.txt @@ -207,10 +207,10 @@ interface.z21:serial_number=Seriennummer #interface:status=Status interface:type=Typ -#interface_status:error=Error -#interface_status:initializing=Initializing -#interface_status:offline=Offline -#interface_status:online=Online +#interface_state:error=Error +#interface_state:initializing=Initializing +#interface_state:offline=Offline +#interface_state:online=Online ip:hostname=Hostname ip:port=Port diff --git a/shared/translations/en-us.txt b/shared/translations/en-us.txt index 76e61f7a..8d5b7417 100644 --- a/shared/translations/en-us.txt +++ b/shared/translations/en-us.txt @@ -213,10 +213,10 @@ interface:online=Online interface:status=Status interface:type=Type -interface_status:error=Error -interface_status:initializing=Initializing -interface_status:offline=Offline -interface_status:online=Online +interface_state:error=Error +interface_state:initializing=Initializing +interface_state:offline=Offline +interface_state:online=Online ip:hostname=Hostname ip:port=Port diff --git a/shared/translations/it-it.txt b/shared/translations/it-it.txt index efb7acb0..47dd39b6 100644 --- a/shared/translations/it-it.txt +++ b/shared/translations/it-it.txt @@ -208,10 +208,10 @@ interface:online=Online interface:status=Stato interface:type=Tipo -interface_status:error=Errore -interface_status:initializing=Inizializzando -interface_status:offline=Offline -interface_status:online=Online +interface_state:error=Errore +interface_state:initializing=Inizializzando +interface_state:offline=Offline +interface_state:online=Online ip:hostname=Hostname ip:port=Porta diff --git a/shared/translations/nl-nl.txt b/shared/translations/nl-nl.txt index a8c0ed61..49711595 100644 --- a/shared/translations/nl-nl.txt +++ b/shared/translations/nl-nl.txt @@ -207,10 +207,10 @@ interface:online=Online interface:status=Status interface:type=Type -interface_status:error=Fout -interface_status:initializing=Initialiseren -interface_status:offline=Offline -interface_status:online=Online +interface_state:error=Fout +interface_state:initializing=Initialiseren +interface_state:offline=Offline +interface_state:online=Online ip:hostname=Hostnaam ip:port=Poort