- completed error enum

- added command enum
This commit is contained in:
Dorian Zedler 2020-05-10 17:39:16 +02:00
parent 130213d09d
commit e7fa1e8348
Signed by: dorian
GPG key ID: 989DE36109AFA354
3 changed files with 85 additions and 6 deletions

View file

@ -78,17 +78,60 @@ public:
};
Q_ENUM(BaseStationSetting)
/*!
* \brief The SocketCommand enum contains all commands the base station can handle
*/
enum SocketCommand {
InvalidCommand = -1,
InitializeSessionCommand = 1,
StartTimersCommand = 1000,
StopTimersCommand = 1001,
ResetTimersCommand = 1002,
GetRaceStateCommand = 2000,
GetNextStartActionCommand = 2005,
GetExtensionsCommand = 2006,
GetTimersCommand = 2007,
GetNextStartActionDetailsCommand = 2009,
WriteSettingCommand = 3000,
ReadSettingCommand = 3001,
LoginAthleteCommand = 4000,
CreateAthleteCommand = 4001,
DeleteAthleteCommand = 4002,
GetAtheletesCommand = 4003,
GetAthleteResultsCommand = 4004,
UpdateFirmwareCommand = 5000,
UpdateSystemTimeCommand = 5001,
PairExtensionsCommand = 5002
};
Q_ENUM(SocketCommand);
/*!
* \brief The ErrorCode enum contains all error codes that can occur when sending a command to the basestation
*/
enum StatusCode {
Success = 200,
FirmwareAlreadyUpToDateInfo = 304,
CommandNotFoundError = 404,
ClientSessionAlreadyActiveError = 407,
UpdateSignatureInvalidError = 402,
TimestampTooSmallError = 406,
RequiredParameterNotGivenError = 405,
CurrentStateNotVaildForOperationError = 403,
AccessDeniedError = 401,
Error = 900,
NotConnectedError = 910,
TimeoutError = 911,
SettingNotAccessibleError = 901,
CurrentStateNotVaildForOperation = 904,
InternalError = 950,
InternalErrorTimerOperationFailed = 951
};
@ -151,6 +194,8 @@ public:
*/
static SignalKey signalKeyFromInt(int i);
static SocketCommand socketCommandFromInt(int i);
ScStw() : QObject(nullptr) {};
private:
};

View file

@ -39,3 +39,37 @@ ScStw::SignalKey ScStw::signalKeyFromInt(int i) {
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);
}

View file

@ -29,7 +29,7 @@ ScStwRace::ScStwRace(QObject *parent) : QObject(parent)
int ScStwRace::start(bool asyncronous) {
if(this->state != IDLE) {
return ScStw::CurrentStateNotVaildForOperation;
return ScStw::CurrentStateNotVaildForOperationError;
}
qDebug() << "+ [INFO] starting race";
@ -47,7 +47,7 @@ int ScStwRace::start(bool asyncronous) {
int ScStwRace::stop() {
if(this->state != RUNNING && this->state != STARTING) {
return ScStw::CurrentStateNotVaildForOperation;
return ScStw::CurrentStateNotVaildForOperationError;
}
qDebug() << "+ [INFO] stopping race";
@ -111,7 +111,7 @@ void ScStwRace::handleTimerStop() {
int ScStwRace::reset() {
if(this->state != STOPPED) {
return ScStw::CurrentStateNotVaildForOperation;
return ScStw::CurrentStateNotVaildForOperationError;
}
qDebug() << "+ [INFO] resetting race";
@ -133,7 +133,7 @@ int ScStwRace::reset() {
int ScStwRace::cancel() {
if(this->state != STARTING && this->state != RUNNING)
return ScStw::CurrentStateNotVaildForOperation;
return ScStw::CurrentStateNotVaildForOperationError;
qDebug() << "[INFO][RACE] cancelling race";
@ -154,7 +154,7 @@ int ScStwRace::cancel() {
int ScStwRace::handleFalseStart() {
if(this->getState() != STARTING && this->getState() != RUNNING)
return ScStw::CurrentStateNotVaildForOperation;
return ScStw::CurrentStateNotVaildForOperationError;
int returnCode = ScStw::Success;
// cancel all running timers