Source · fairmq/
States.cxxsource
Described in Device states, States and transitions.
1/********************************************************************************2 * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *3 * *4 * This software is distributed under the terms of the *5 * GNU Lesser General Public Licence (LGPL) version 3, *6 * copied verbatim in the file "LICENSE" *7 ********************************************************************************/8 9#include <fairmq/States.h>10 11#include <array>12#include <unordered_map>13 14using namespace std;15 16namespace fair::mq17{18 19const array<string, 16> stateNames =20{21 {22 "UNDEFINED",23 "OK",24 "ERROR",25 "IDLE",26 "INITIALIZING DEVICE",27 "INITIALIZED",28 "BINDING",29 "BOUND",30 "CONNECTING",31 "DEVICE READY",32 "INITIALIZING TASK",33 "READY",34 "RUNNING",35 "RESETTING TASK",36 "RESETTING DEVICE",37 "EXITING"38 }39};40 41const unordered_map<string, State> states =42{43 { "UNDEFINED", State::Undefined },44 { "OK", State::Ok },45 { "ERROR", State::Error },46 { "IDLE", State::Idle },47 { "INITIALIZING DEVICE", State::InitializingDevice },48 { "INITIALIZED", State::Initialized },49 { "BINDING", State::Binding },50 { "BOUND", State::Bound },51 { "CONNECTING", State::Connecting },52 { "DEVICE READY", State::DeviceReady },53 { "INITIALIZING TASK", State::InitializingTask },54 { "READY", State::Ready },55 { "RUNNING", State::Running },56 { "RESETTING TASK", State::ResettingTask },57 { "RESETTING DEVICE", State::ResettingDevice },58 { "EXITING", State::Exiting }59};60 61const array<string, 12> transitionNames =62{63 {64 "AUTO",65 "INIT DEVICE",66 "COMPLETE INIT",67 "BIND",68 "CONNECT",69 "INIT TASK",70 "RUN",71 "STOP",72 "RESET TASK",73 "RESET DEVICE",74 "END",75 "ERROR FOUND"76 }77};78 79const unordered_map<string, Transition> transitions =80{81 { "AUTO", Transition::Auto },82 { "INIT DEVICE", Transition::InitDevice },83 { "COMPLETE INIT", Transition::CompleteInit },84 { "BIND", Transition::Bind },85 { "CONNECT", Transition::Connect },86 { "INIT TASK", Transition::InitTask },87 { "RUN", Transition::Run },88 { "STOP", Transition::Stop },89 { "RESET TASK", Transition::ResetTask },90 { "RESET DEVICE", Transition::ResetDevice },91 { "END", Transition::End },92 { "ERROR FOUND", Transition::ErrorFound }93};94 95string GetStateName(const State state)96{97 return stateNames.at(static_cast<int>(state));98}99 100string GetTransitionName(const Transition transition)101{102 return transitionNames.at(static_cast<int>(transition));103}104 105State GetState(const string& state)106{107 return states.at(state);108}109 110Transition GetTransition(const string& transition)111{112 return transitions.at(transition);113}114 115} // namespace fair::mq