75 lines
2.1 KiB
C++
75 lines
2.1 KiB
C++
#include "../headers/ScStw.hpp"
|
|
|
|
const char *ScStw::SOCKET_MESSAGE_START_KEY = "<message>";
|
|
const char *ScStw::SOCKET_MESSAGE_END_KEY = "</message>";
|
|
|
|
const QMap<QString, ScStw::BaseStationSetting> ScStw::baseStationSettings = {
|
|
{"ReadySoundEnable", ScStw::ReadySoundEnableSetting},
|
|
{"ReadySoundDelay", ScStw::ReadySoundDelaySetting},
|
|
{"AtYourMarksSoundEnable", ScStw::AtYourMarksSoundEnableSetting},
|
|
{"AtYourMarksSoundDelay", ScStw::AtYourMarksSoundDelaySetting},
|
|
{"SoundVolume", ScStw::SoundVolumeSetting}
|
|
};
|
|
|
|
ScStw::BaseStationSetting ScStw::baseStationSettingFromString(QString s) {
|
|
if(!ScStw::baseStationSettings.contains(s))
|
|
return ScStw::InvalidSetting;
|
|
|
|
return ScStw::baseStationSettings[s];
|
|
}
|
|
|
|
QString ScStw::baseStationSettingToString(ScStw::BaseStationSetting s) {
|
|
for(QString key: ScStw::baseStationSettings.keys()) {
|
|
if(ScStw::baseStationSettings[key] == s)
|
|
return key;
|
|
}
|
|
return "Invalid";
|
|
}
|
|
|
|
ScStw::BaseStationSetting ScStw::baseStationSettingfromInt(int i) {
|
|
if(i < 0 || i > 4)
|
|
return InvalidSetting;
|
|
else
|
|
return BaseStationSetting(i);
|
|
}
|
|
|
|
ScStw::SignalKey ScStw::signalKeyFromInt(int i) {
|
|
if(i < 9000 || i > 9003)
|
|
return InvalidSignal;
|
|
else
|
|
return SignalKey(i);
|
|
}
|
|
|
|
ScStw::SocketCommand ScStw::socketCommandFromInt(int i) {
|
|
QList<SocketCommand> allCommands = {
|
|
InitializeSessionCommand,
|
|
|
|
StartTimersCommand,
|
|
StopTimersCommand,
|
|
ResetTimersCommand,
|
|
|
|
GetRaceStateCommand,
|
|
GetNextStartActionCommand,
|
|
GetExtensionsCommand,
|
|
GetTimersCommand,
|
|
GetNextStartActionDetailsCommand,
|
|
|
|
WriteSettingCommand,
|
|
ReadSettingCommand,
|
|
|
|
LoginAthleteCommand,
|
|
CreateAthleteCommand,
|
|
DeleteAthleteCommand,
|
|
GetAtheletesCommand,
|
|
GetAthleteResultsCommand,
|
|
|
|
UpdateFirmwareCommand,
|
|
UpdateSystemTimeCommand,
|
|
PairExtensionsCommand
|
|
};
|
|
|
|
if(!allCommands.contains(SocketCommand(i)))
|
|
return InvalidCommand;
|
|
else
|
|
return SocketCommand(i);
|
|
}
|