DecoderProtocol: removed Auto/Custom, added None

see #72
Dieser Commit ist enthalten in:
Reinder Feenstra 2023-06-24 23:41:58 +02:00
Ursprung 02c674e061
Commit e28a9a5d96
18 geänderte Dateien mit 22 neuen und 99 gelöschten Zeilen

Datei anzeigen

@ -1,37 +0,0 @@
/**
* server/src/enum/decoderprotocol.hpp
*
* This file is part of the traintastic source code.
*
* Copyright (C) 2019-2020,2022 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_SERVER_ENUM_DECODERPROTOCOL_HPP
#define TRAINTASTIC_SERVER_ENUM_DECODERPROTOCOL_HPP
#include <traintastic/enum/decoderprotocol.hpp>
#include <array>
inline constexpr std::array<DecoderProtocol, 5> decoderProtocolValues{{
DecoderProtocol::Auto,
DecoderProtocol::DCC,
DecoderProtocol::Motorola,
DecoderProtocol::Selectrix,
DecoderProtocol::Custom,
}};
#endif

Datei anzeigen

@ -67,7 +67,7 @@ Decoder::Decoder(World& world, std::string_view _id) :
}
return false;
}},
protocol{this, "protocol", DecoderProtocol::Auto, PropertyFlags::ReadWrite | PropertyFlags::Store,
protocol{this, "protocol", DecoderProtocol::None, PropertyFlags::ReadWrite | PropertyFlags::Store,
[this](const DecoderProtocol& value)
{
if(value == DecoderProtocol::DCC && DCC::isLongAddress(address))

Datei anzeigen

@ -26,7 +26,7 @@
#include <type_traits>
#include "../../core/idobject.hpp"
#include "../../core/objectproperty.hpp"
#include "../../enum/decoderprotocol.hpp"
#include <traintastic/enum/decoderprotocol.hpp>
#include "../../enum/direction.hpp"
#include "decodercontroller.hpp"
#include "decoderfunctions.hpp"

Datei anzeigen

@ -3,7 +3,7 @@
*
* This file is part of the traintastic source code.
*
* Copyright (C) 2021-2022 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
@ -42,9 +42,7 @@ DecoderController::DecoderController(IdObject& interface, DecoderListColumn colu
bool DecoderController::addDecoder(Decoder& decoder)
{
if(decoder.protocol != DecoderProtocol::Auto && findDecoder(decoder) != m_decoders.end())
return false;
if(findDecoder(DecoderProtocol::Auto, decoder.address) != m_decoders.end())
if(findDecoder(decoder) != m_decoders.end())
return false;
m_decoders.emplace_back(decoder.shared_ptr<Decoder>());
@ -64,13 +62,11 @@ bool DecoderController::removeDecoder(Decoder& decoder)
return false;
}
const std::shared_ptr<Decoder>& DecoderController::getDecoder(DecoderProtocol protocol, uint16_t address, bool dccLongAddress, bool fallbackToProtocolAuto)
const std::shared_ptr<Decoder>& DecoderController::getDecoder(DecoderProtocol protocol, uint16_t address, bool dccLongAddress)
{
auto it = findDecoder(protocol, address, dccLongAddress);
if(it != m_decoders.end())
return *it;
if(fallbackToProtocolAuto && protocol != DecoderProtocol::Auto && (it = findDecoder(DecoderProtocol::Auto, address)) != m_decoders.end())
return *it;
return Decoder::null;
}

Datei anzeigen

@ -72,7 +72,7 @@ class DecoderController
[[nodiscard]] bool addDecoder(Decoder& decoder);
[[nodiscard]] bool removeDecoder(Decoder& decoder);
const std::shared_ptr<Decoder>& getDecoder(DecoderProtocol protocol, uint16_t address, bool dccLongAddress = false, bool fallbackToProtocolAuto = false);
const std::shared_ptr<Decoder>& getDecoder(DecoderProtocol protocol, uint16_t address, bool dccLongAddress = false);//, bool fallbackToProtocolAuto = false);
virtual void decoderChanged(const Decoder& decoder, DecoderChangeFlags changes, uint32_t functionNumber) = 0;
};

Datei anzeigen

@ -282,9 +282,6 @@ void DCCPlusPlusInterface::check() const
void DCCPlusPlusInterface::checkDecoder(const Decoder& decoder) const
{
if(decoder.protocol != DecoderProtocol::Auto && decoder.protocol != DecoderProtocol::DCC)
Log::log(decoder, LogMessage::C2002_DCCPLUSPLUS_ONLY_SUPPORTS_THE_DCC_PROTOCOL);
if(decoder.protocol == DecoderProtocol::DCC && decoder.address <= 127 && decoder.longAddress)
Log::log(decoder, LogMessage::C2003_DCCPLUSPLUS_DOESNT_SUPPORT_DCC_LONG_ADDRESSES_BELOW_128);

Datei anzeigen

@ -67,7 +67,7 @@ static constexpr DecoderProtocol toDecoderProtocol(LocomotiveProtocol value)
case LocomotiveProtocol::MMFKT:
break;
}
return DecoderProtocol::Custom;
return DecoderProtocol::None;
}
Kernel::Kernel(const Config& config, bool simulation)
@ -264,7 +264,7 @@ Locomotive* Kernel::getLocomotive(DecoderProtocol protocol, uint16_t address, ui
auto* l = dynamic_cast<Locomotive*>(item.second.get());
return
l &&
(protocol == DecoderProtocol::Auto || protocol == toDecoderProtocol(l->protocol())) &&
protocol == toDecoderProtocol(l->protocol()) &&
address == l->address() &&
(speedSteps == 0 || speedSteps == l->speedSteps());
});

Datei anzeigen

@ -1317,7 +1317,7 @@ void Kernel::clearLocoSlot(uint8_t slot)
std::shared_ptr<Decoder> Kernel::getDecoder(uint16_t address)
{
assert(isEventLoopThread());
return m_decoderController->getDecoder(DecoderProtocol::DCC, address, DCC::isLongAddress(address), true);
return m_decoderController->getDecoder(DecoderProtocol::DCC, address, DCC::isLongAddress(address));
}
void Kernel::setIOHandler(std::unique_ptr<IOHandler> handler)

Datei anzeigen

@ -476,8 +476,6 @@ std::shared_ptr<Decoder> Kernel::getDecoder(uint16_t address, bool longAddress)
std::shared_ptr<Decoder> decoder;
if(longAddress)
decoder = decoderList.getDecoder(DecoderProtocol::DCC, address, longAddress);
if(!decoder)
decoder = decoderList.getDecoder(DecoderProtocol::Auto, address);
if(!decoder)
decoder = decoderList.getDecoder(address);
return decoder;

Datei anzeigen

@ -334,8 +334,6 @@ LanSystemStateDataChanged ServerKernel::getLanSystemStateDataChanged() const
std::shared_ptr<Decoder> ServerKernel::getDecoder(uint16_t address, bool longAddress) const
{
auto decoder = m_decoderList->getDecoder(DecoderProtocol::DCC, address, longAddress);
if(!decoder)
decoder = m_decoderList->getDecoder(DecoderProtocol::Auto, address);
if(!decoder)
decoder = m_decoderList->getDecoder(address);
return decoder;

Datei anzeigen

@ -54,8 +54,6 @@ Throttle::AcquireResult HardwareThrottle::acquire(DecoderProtocol protocol, uint
auto& decoderList = *m_world.decoders.value();
auto decoder = decoderList.getDecoder(protocol, address, isDCCLongAddress);
if(!decoder)
decoder = decoderList.getDecoder(DecoderProtocol::Auto, address);
if(!decoder)
decoder = decoderList.getDecoder(address);
if(!decoder)

Datei anzeigen

@ -25,7 +25,7 @@
#include <lua.hpp>
#include "enum.hpp"
#include "../../src/enum/decoderprotocol.hpp"
#include <traintastic/enum/decoderprotocol.hpp>
#include "../../src/enum/direction.hpp"
#include "../../src/enum/directioncontrolstate.hpp"
#include <traintastic/enum/identificationeventtype.hpp>

Datei anzeigen

@ -3,7 +3,7 @@
*
* This file is part of the traintastic source code.
*
* Copyright (C) 2019-2022 Reinder Feenstra
* Copyright (C) 2019-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,26 +24,32 @@
#define TRAINTASTIC_SHARED_TRAINTASTIC_ENUM_DECODERPROTOCOL_HPP
#include <cstdint>
#include <array>
#include "enum.hpp"
enum class DecoderProtocol : uint8_t
{
Auto = 0,
None = 0,
DCC = 1,
Motorola = 2,
//MFX = 3,
Selectrix = 4,
//FMZ = 5,
Custom = 255,
};
TRAINTASTIC_ENUM(DecoderProtocol, "decoder_protocol", 5,
TRAINTASTIC_ENUM(DecoderProtocol, "decoder_protocol", 4,
{
{DecoderProtocol::Auto, "auto"},
{DecoderProtocol::None, "none"},
{DecoderProtocol::DCC, "dcc"},
{DecoderProtocol::Motorola, "motorola"},
{DecoderProtocol::Selectrix, "selectrix"},
{DecoderProtocol::Custom, "custom"},
});
inline constexpr std::array<DecoderProtocol, 4> decoderProtocolValues{{
DecoderProtocol::None,
DecoderProtocol::DCC,
DecoderProtocol::Motorola,
DecoderProtocol::Selectrix,
}};
#endif

Datei anzeigen

@ -191,7 +191,6 @@ enum class LogMessage : uint32_t
C1012_UNKNOWN_CLASS_X_CANT_RECREATE_OBJECT_X = LogMessageOffset::critical + 1012,
C1013_CANT_LOAD_WORLD_SAVED_WITH_NEWER_VERSION_REQUIRES_AT_LEAST_X = LogMessageOffset::critical + 1013,
C2001_ADDRESS_ALREADY_USED_AT_X = LogMessageOffset::critical + 2001,
C2002_DCCPLUSPLUS_ONLY_SUPPORTS_THE_DCC_PROTOCOL = LogMessageOffset::critical + 2002,
C2003_DCCPLUSPLUS_DOESNT_SUPPORT_DCC_LONG_ADDRESSES_BELOW_128 = LogMessageOffset::critical + 2003,
C2004_CANT_GET_FREE_SLOT = LogMessageOffset::critical + 2004,
C9999_X = LogMessageOffset::critical + 9999,

Datei anzeigen

@ -2111,14 +2111,6 @@
"reference": "",
"comment": ""
},
{
"term": "message:C2002",
"definition": "DCC++ unterst\u00fctzt nur das DCC-Protokoll",
"context": "",
"term_plural": "",
"reference": "",
"comment": ""
},
{
"term": "message:C2003",
"definition": "DCC++ unterst\u00fctzt keine langen DCC-Adressen unter 128",

Datei anzeigen

@ -2111,14 +2111,6 @@
"reference": "",
"comment": ""
},
{
"term": "message:C2002",
"definition": "DCC++ only supports the DCC protocol",
"context": "",
"term_plural": "",
"reference": "",
"comment": ""
},
{
"term": "message:C2003",
"definition": "DCC++ doesn't support DCC long addresses below 128",

Datei anzeigen

@ -2111,14 +2111,6 @@
"reference": "",
"comment": ""
},
{
"term": "message:C2002",
"definition": "DCC++ supporta solo il protocollo DCC",
"context": "",
"term_plural": "",
"reference": "",
"comment": ""
},
{
"term": "message:C2003",
"definition": "DCC++ non supporta indirizzi estesi DCC inferiori a 128",

Datei anzeigen

@ -2111,14 +2111,6 @@
"reference": "",
"comment": ""
},
{
"term": "message:C2002",
"definition": "DCC++ ondersteund alleen het DCC protocol",
"context": "",
"term_plural": "",
"reference": "",
"comment": ""
},
{
"term": "message:C2003",
"definition": "DCC++ ondersteund geen lange adressen onder de 128",