interface: added status object (for display in client status bar)
Dieser Commit ist enthalten in:
Ursprung
62c5388812
Commit
07e71677ca
@ -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"
|
||||
|
||||
@ -125,13 +125,13 @@ bool DCCPlusPlusInterface::setOnline(bool& value, bool simulation)
|
||||
m_kernel = DCCPlusPlus::Kernel::create<DCCPlusPlus::SerialIOHandler>(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;
|
||||
}
|
||||
|
||||
@ -129,13 +129,13 @@ bool ECoSInterface::setOnline(bool& value, bool simulation)
|
||||
else
|
||||
m_kernel = ECoS::Kernel::create<ECoS::TCPIOHandler>(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;
|
||||
}
|
||||
|
||||
@ -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<InterfaceStatus>(*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<Interface>());
|
||||
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<Interface>());
|
||||
IdObject::destroying();
|
||||
}
|
||||
@ -98,3 +105,8 @@ void Interface::worldEvent(WorldState state, WorldEvent event)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::setState(InterfaceState value)
|
||||
{
|
||||
status->state.setValueInternal(value);
|
||||
}
|
||||
|
||||
@ -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<std::string> name;
|
||||
Property<bool> online;
|
||||
Property<InterfaceStatus> status;
|
||||
ObjectProperty<InterfaceStatus> status;
|
||||
Property<std::string> notes;
|
||||
};
|
||||
|
||||
|
||||
@ -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<InterfaceStatus>::value.find(interface.status); it != EnumValues<InterfaceStatus>::value.end())
|
||||
return std::string("$").append(EnumName<InterfaceStatus>::value).append(":").append(it->second).append("$");
|
||||
if(const auto* it = EnumValues<InterfaceState>::value.find(interface.status->state); it != EnumValues<InterfaceState>::value.end())
|
||||
return std::string("$").append(EnumName<InterfaceState>::value).append(":").append(it->second).append("$");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -84,14 +84,14 @@ bool WiThrottleInterface::setOnline(bool& value, bool simulation)
|
||||
{
|
||||
m_kernel = WiThrottle::Kernel::create<WiThrottle::TCPIOHandler>(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;
|
||||
|
||||
@ -81,13 +81,13 @@ bool WlanMausInterface::setOnline(bool& value, bool simulation)
|
||||
{
|
||||
m_kernel = Z21::ServerKernel::create<Z21::UDPServerIOHandler>(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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -130,13 +130,13 @@ bool Z21Interface::setOnline(bool& value, bool simulation)
|
||||
else
|
||||
m_kernel = Z21::ClientKernel::create<Z21::UDPClientIOHandler>(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("");
|
||||
|
||||
32
server/src/status/interfacestatus.cpp
Normale Datei
32
server/src/status/interfacestatus.cpp
Normale Datei
@ -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);
|
||||
}
|
||||
@ -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 <cstdint>
|
||||
#include "enum.hpp"
|
||||
#include "status.hpp"
|
||||
#include <traintastic/enum/interfacestate.hpp>
|
||||
|
||||
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<InterfaceState> 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
|
||||
30
server/src/status/status.cpp
Normale Datei
30
server/src/status/status.cpp
Normale Datei
@ -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);
|
||||
}
|
||||
@ -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 <traintastic/enum/interfacestatus.hpp>
|
||||
#include "../core/subobject.hpp"
|
||||
#include "../core/property.hpp"
|
||||
|
||||
inline constexpr std::array<InterfaceStatus, 4> interfaceStatusValues{{
|
||||
InterfaceStatus::Offline,
|
||||
InterfaceStatus::Initializing,
|
||||
InterfaceStatus::Online,
|
||||
InterfaceStatus::Error,
|
||||
}};
|
||||
class Status : public SubObject
|
||||
{
|
||||
public:
|
||||
Property<std::string> label;
|
||||
|
||||
Status(Object& parent_, std::string_view parentPropertyName_);
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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 <boost/uuid/uuid.hpp>
|
||||
#include <traintastic/enum/worldevent.hpp>
|
||||
#include "../enum/worldscale.hpp"
|
||||
#include "../status/status.hpp"
|
||||
#include <traintastic/set/worldstate.hpp>
|
||||
|
||||
class WorldLoader;
|
||||
@ -114,6 +116,7 @@ class World : public Object
|
||||
|
||||
ObjectProperty<LinkRailTileList> linkRailTiles;
|
||||
|
||||
ObjectVectorProperty<Status> statuses;
|
||||
Property<uint32_t> hardwareThrottles; //<! number of connected hardware throttles
|
||||
|
||||
Property<WorldState> state;
|
||||
|
||||
53
shared/src/traintastic/enum/interfacestate.hpp
Normale Datei
53
shared/src/traintastic/enum/interfacestate.hpp
Normale Datei
@ -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 <cstdint>
|
||||
#include <array>
|
||||
#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<InterfaceState, 4> interfaceStateValues{{
|
||||
InterfaceState::Offline,
|
||||
InterfaceState::Initializing,
|
||||
InterfaceState::Online,
|
||||
InterfaceState::Error,
|
||||
}};
|
||||
|
||||
#endif
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren