refs #297 Removed old simulator settings, which were not even used.

This commit is contained in:
Mathew Sutcliffe
2015-06-30 20:48:04 +01:00
parent dace9e4da5
commit d971b073b7
12 changed files with 1 additions and 265 deletions

View File

@@ -1,87 +0,0 @@
/* Copyright (C) 2013
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "setsimulator.h"
#include "blackmisc/logmessage.h"
using namespace BlackMisc;
using namespace BlackMisc::Settings;
using namespace BlackMisc::PhysicalQuantities;
namespace BlackMisc
{
namespace Simulation
{
namespace Settings
{
CSettingsSimulator::CSettingsSimulator()
{
this->initDefaultValues();
}
QString CSettingsSimulator::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
QString s("Sel.driver:");
s.append(" ").append(m_selectedPlugin.toQString(i18n));
return s;
}
void CSettingsSimulator::initDefaultValues()
{
this->m_timeSyncOffset = CTime(0, CTimeUnit::hrmin());
this->m_timeSync = false;
}
BlackMisc::CStatusMessage CSettingsSimulator::value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag)
{
// TODO: This needs to be refactored to a smarter way to delegate commands
changedFlag = false;
if (path == CSettingsSimulator::ValueSelectedDriver())
{
if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate())
{
CSimulatorPluginInfo v = value.value<CSimulatorPluginInfo>();
changedFlag = (v != this->m_selectedPlugin);
this->m_selectedPlugin = v;
return CLogMessage(CLogCategory::settingsUpdate()).info("selected driver%1 changed") << (changedFlag ? "" : " not");
}
return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command;
}
else if (path == CSettingsSimulator::ValueSyncTime())
{
if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate())
{
bool v = value.value<bool>();
changedFlag = (v != this->m_timeSync);
this->m_timeSync = v;
return CLogMessage(CLogCategory::settingsUpdate()).info("time synchronization%1 changed") << (changedFlag ? "" : " not");
}
return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command;
}
else if (path == CSettingsSimulator::ValueSyncTimeOffset())
{
if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate())
{
CTime v = value.value<CTime>();
changedFlag = (v != this->m_timeSyncOffset);
this->m_timeSyncOffset = v;
return CLogMessage(CLogCategory::settingsUpdate()).info("time synchronization offset%1 changed") << (changedFlag ? "" : " not");
}
return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command;
}
else
{
return CLogMessage(CLogCategory::validation()).error("wrong path: %1") << path;
}
}
} // namespace
} // namespace
} // namespace

View File

@@ -1,98 +0,0 @@
/* Copyright (C) 2013
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKMISC_SETTINGS_SIMULATOR_H
#define BLACKMISC_SETTINGS_SIMULATOR_H
#include "blackmisc/blackmiscexport.h"
#include "blackmisc/valueobject.h"
#include "blackmisc/statusmessagelist.h"
#include "blackmisc/settingutilities.h"
#include "blackmisc/pq/time.h"
#include "simulatorplugininfo.h"
namespace BlackMisc
{
namespace Simulation
{
namespace Settings
{
//! Value object encapsulating information of simulator related settings.
//! \deprecated will be removed with new MS settings
class BLACKMISC_EXPORT CSettingsSimulator : public BlackMisc::CValueObject<CSettingsSimulator>
{
public:
//! Default constructor.
CSettingsSimulator();
//! Path
static const QString &ValueSelectedDriver()
{
static const QString value("selecteddriver");
return value;
}
//! Path
static const QString &ValueSyncTimeOffset()
{
static const QString value("synctimeoffset");
return value;
}
//! Path
static const QString &ValueSyncTime()
{
static const QString value("synctime");
return value;
}
//! Selected driver
const BlackMisc::Simulation::CSimulatorPluginInfo &getSelectedPlugin() const { return this->m_selectedPlugin; }
//! Selected driver
void setSelectedPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &plugin) { this->m_selectedPlugin = plugin; }
//! Time synchronization offset time
const BlackMisc::PhysicalQuantities::CTime &getSyncTimeOffset() const { return this->m_timeSyncOffset;}
//! Set time synchronization offset time
void setSyncTimeOffset(const BlackMisc::PhysicalQuantities::CTime &offset) { this->m_timeSyncOffset = offset; this->m_timeSyncOffset.switchUnit(BlackMisc::PhysicalQuantities::CTimeUnit::hrmin());}
//! Time syncronization enabled?
bool isTimeSyncEnabled() const { return this->m_timeSync;}
//! Set time synchronization
void setTimeSyncEnabled(bool enabled) { this->m_timeSync = enabled; }
//! Init with meaningful default values
void initDefaultValues();
//! \copydoc BlackCore::IContextSettings::value
BlackMisc::CStatusMessage value(const QString &path, const QString &command, const BlackMisc::CVariant &value, bool &changedFlag);
//! \copydoc CValueObject::convertToQString
QString convertToQString(bool i18n = false) const;
private:
BLACK_ENABLE_TUPLE_CONVERSION(CSettingsSimulator)
BlackMisc::Simulation::CSimulatorPluginInfo m_selectedPlugin;
bool m_timeSync = false;
BlackMisc::PhysicalQuantities::CTime m_timeSyncOffset;
};
} // namespace
} // namespace
} // namespace
Q_DECLARE_METATYPE(BlackMisc::Simulation::Settings::CSettingsSimulator)
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::Settings::CSettingsSimulator, (o.m_selectedPlugin, o.m_timeSync, o.m_timeSyncOffset))
#endif // guard