Changeset 13913 for trunk/FACT++


Ignore:
Timestamp:
05/26/12 14:28:46 (13 years ago)
Author:
tbretz
Message:
Moved states to namespace State
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/HeadersBIAS.h

    r12108 r13913  
    3030    };
    3131
    32     enum States_t
     32    namespace State
    3333    {
    34         kDisconnected = 1,//StateMachineImp::kSM_UserMode,
    35         kConnecting,
    36         kInitializing,
    37         kConnected,
    38         kRamping,
    39         kOverCurrent,
    40         kVoltageOff,
    41         kNotReferenced,
    42         kVoltageOn,
    43         kExpertMode // 'forward' declaration to be used in StateMachineBias
    44     };
     34        enum states_t
     35        {
     36            kDisconnected = 1,//StateMachineImp::kSM_UserMode,
     37            kConnecting,
     38            kInitializing,
     39            kConnected,
     40            kRamping,
     41            kOverCurrent,
     42            kVoltageOff,
     43            kNotReferenced,
     44            kVoltageOn,
     45            kExpertMode // 'forward' declaration to be used in StateMachineBias
     46        };
     47    }
    4548}
    4649
  • trunk/FACT++/src/biasctrl.cc

    r13457 r13913  
    2424using namespace std::placeholders;
    2525using namespace std;
     26
     27// We can do that because we do not include other headers than HeadersBIAS
    2628using namespace BIAS;
    27 
    28 //#define DEBUG
    2929
    3030// ------------------------------------------------------------------------
     
    14381438    }
    14391439
    1440     States_t GetStatus()
     1440    State::states_t GetStatus()
    14411441    {
    14421442        if (!IsConnected())
    1443             return BIAS::kDisconnected;
     1443            return State::kDisconnected;
    14441444
    14451445        if (IsConnecting())
    1446             return BIAS::kConnecting;
     1446            return State::kConnecting;
    14471447
    14481448        if (fIsInitializing)
    1449             return BIAS::kInitializing;
     1449            return State::kInitializing;
    14501450
    14511451        if (fIsRamping)
    1452             return BIAS::kRamping;
     1452            return State::kRamping;
    14531453
    14541454        for (int ch=0; ch<kNumChannels; ch++)
    14551455            if (fPresent[ch/kNumChannelsPerBoard] && fCurrent[ch]<0)
    1456                 return BIAS::kOverCurrent;
     1456                return State::kOverCurrent;
    14571457
    14581458        bool isoff = true;
     
    14611461                isoff = false;
    14621462        if (isoff)
    1463             return BIAS::kVoltageOff;
     1463            return State::kVoltageOff;
    14641464
    14651465        for (int ch=0; ch<kNumChannels; ch++)
    14661466            if (fPresent[ch/kNumChannelsPerBoard] && fDacActual[ch]!=fDacTarget[ch])
    1467                 return BIAS::kNotReferenced;
    1468 
    1469         return BIAS::kVoltageOn;
     1467                return State::kNotReferenced;
     1468
     1469        return State::kVoltageOn;
    14701470    }
    14711471
     
    18531853        poll_one();
    18541854
    1855         return fExpertMode && fBias.GetStatus()>=kConnected ?
    1856             kExpertMode : fBias.GetStatus();
     1855        return fExpertMode && fBias.GetStatus()>=State::kConnected ?
     1856            State::kExpertMode : fBias.GetStatus();
    18571857    }
    18581858
     
    18701870
    18711871        // State names
    1872         T::AddStateName(kDisconnected, "Disconnected",
     1872        T::AddStateName(State::kDisconnected, "Disconnected",
    18731873                        "Bias-power supply not connected via USB.");
    18741874
    1875         T::AddStateName(kConnecting, "Connecting",
     1875        T::AddStateName(State::kConnecting, "Connecting",
    18761876                        "Trying to establish USB connection to bias-power supply.");
    18771877
    1878         T::AddStateName(kInitializing, "Initializing",
     1878        T::AddStateName(State::kInitializing, "Initializing",
    18791879                        "USB connection to bias-power supply established, synchronizing USB stream.");
    18801880
    1881         T::AddStateName(kConnected, "Connected",
     1881        T::AddStateName(State::kConnected, "Connected",
    18821882                        "USB connection to bias-power supply established.");
    18831883
    1884         T::AddStateName(kNotReferenced, "NotReferenced",
     1884        T::AddStateName(State::kNotReferenced, "NotReferenced",
    18851885                        "Internal reference voltage does not match last sent voltage.");
    18861886
    1887         T::AddStateName(kVoltageOff, "VoltageOff",
     1887        T::AddStateName(State::kVoltageOff, "VoltageOff",
    18881888                        "All voltages are supposed to be switched off.");
    18891889
    1890         T::AddStateName(kVoltageOn, "VoltageOn",
     1890        T::AddStateName(State::kVoltageOn, "VoltageOn",
    18911891                        "At least one voltage is switched on and all are at reference.");
    18921892
    1893         T::AddStateName(kOverCurrent, "OverCurrent",
     1893        T::AddStateName(State::kOverCurrent, "OverCurrent",
    18941894                        "At least one channel is in over current state.");
    18951895
    1896         T::AddStateName(kExpertMode, "ExpertMode",
     1896        T::AddStateName(State::kExpertMode, "ExpertMode",
    18971897                        "Special (risky!) mode to directly send command to the bias-power supply.");
    18981898
    1899         T::AddStateName(kRamping, "Ramping",
     1899        T::AddStateName(State::kRamping, "Ramping",
    19001900                        "Voltage ramping in progress.");
    19011901
     
    19121912
    19131913        // Conenction commands
    1914         T::AddEvent("DISCONNECT", kConnected, kVoltageOff)
     1914        T::AddEvent("DISCONNECT", State::kConnected, State::kVoltageOff)
    19151915            (bind(&StateMachineBias::Disconnect, this))
    19161916            ("disconnect from USB");
    1917         T::AddEvent("RECONNECT", "O", kDisconnected, kConnected, kVoltageOff)
     1917        T::AddEvent("RECONNECT", "O", State::kDisconnected, State::kConnected, State::kVoltageOff)
    19181918            (bind(&StateMachineBias::Reconnect, this, placeholders::_1))
    19191919            ("(Re)connect USB connection to Bias power supply, a new address can be given"
     
    19281928
    19291929
    1930         T::AddEvent("REQUEST_STATUS", kConnected, kVoltageOn, kVoltageOff, kNotReferenced, kOverCurrent)
     1930        T::AddEvent("REQUEST_STATUS", State::kConnected, State::kVoltageOn, State::kVoltageOff, State::kNotReferenced, State::kOverCurrent)
    19311931            (Wrapper(bind(&ConnectionBias::ReadAllChannels, &fBias, false)))
    19321932            ("Asynchronously request the status (current) of all channels.");
    19331933
    1934         T::AddEvent("RESET_OVER_CURRENT_STATUS", kOverCurrent)
     1934        T::AddEvent("RESET_OVER_CURRENT_STATUS", State::kOverCurrent)
    19351935            (Wrapper(bind(&ConnectionBias::OverCurrentReset, &fBias)))
    19361936            ("Set all channels in over current state to 0V and send a system reset to reset the over current flags.");
    19371937
    19381938
    1939         T::AddEvent("SET_CHANNEL_DAC", "S:1;S:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1939        T::AddEvent("SET_CHANNEL_DAC", "S:1;S:1", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    19401940            (bind(&StateMachineBias::SetChannelDac, this, placeholders::_1))
    19411941            ("Set a new target value in DAC counts for a single channel. Starts ramping if necessary."
    19421942             "|channel[short]:Channel for which to set the target voltage [0-415]"
    19431943             "|voltage[dac]:Target voltage in DAC units for the given channel");
    1944         T::AddEvent("SET_GLOBAL_DAC", "S:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1944        T::AddEvent("SET_GLOBAL_DAC", "S:1", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    19451945            (bind(&StateMachineBias::SetGlobalDac, this, placeholders::_1))
    19461946            ("Set a new target value for all channels in DAC counts. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)"
     
    19481948
    19491949
    1950         T::AddEvent("SET_CHANNEL_VOLTAGE", "S:1;F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1950        T::AddEvent("SET_CHANNEL_VOLTAGE", "S:1;F:1", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    19511951            (bind(&StateMachineBias::SetChannelVolt, this, placeholders::_1))
    19521952            ("Set a new target voltage for a single channel. Starts ramping if necessary."
    19531953             "|channel[short]:Channel for which to set the target voltage [0-415]"
    19541954             "|voltage[V]:Target voltage in volts for the given channel (will be converted to DAC units)");
    1955         T::AddEvent("SET_GLOBAL_VOLTAGE", "F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1955        T::AddEvent("SET_GLOBAL_VOLTAGE", "F:1", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    19561956            (bind(&StateMachineBias::SetGlobalVolt, this, placeholders::_1))
    19571957            ("Set a new target voltage for all channels. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)"
    19581958             "|voltage[V]:Global target voltage in volts (will be converted to DAC units)");
    1959         T::AddEvent("SET_ALL_CHANNELS_VOLTAGE", "F:416", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1959        T::AddEvent("SET_ALL_CHANNELS_VOLTAGE", "F:416", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    19601960            (bind(&StateMachineBias::SetAllChannelsVolt, this, placeholders::_1))
    19611961            ("Set all channels to the given new reference voltage. Starts ramping if necessary."
     
    19631963
    19641964
    1965         T::AddEvent("INCREASE_CHANNEL_VOLTAGE", "S:1;F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1965        T::AddEvent("INCREASE_CHANNEL_VOLTAGE", "S:1;F:1", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    19661966            (bind(&StateMachineBias::IncChannelVolt, this, placeholders::_1))
    19671967            ("Increases the voltage of all channels by the given offset. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)"
    19681968             "|channel[short]:Channel for which to adapt the voltage [0-415]"
    19691969             "|offset[V]:Offset to be added to all channels (will be converted to DAC counts)");
    1970         T::AddEvent("INCREASE_GLOBAL_VOLTAGE", "F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1970        T::AddEvent("INCREASE_GLOBAL_VOLTAGE", "F:1", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    19711971            (bind(&StateMachineBias::IncGlobalVolt, this, placeholders::_1))
    19721972            ("Increases the voltage of all channels by the given offset. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)"
    19731973             "|offset[V]:Offset to be added to all channels (will be converted to DAC counts)");
    1974         T::AddEvent("INCREASE_ALL_CHANNELS_VOLTAGE", "F:416", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1974        T::AddEvent("INCREASE_ALL_CHANNELS_VOLTAGE", "F:416", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    19751975            (bind(&StateMachineBias::IncAllChannelsVolt, this, placeholders::_1))
    19761976            ("Add the given voltages to the current reference voltages. Starts ramping if necessary."
     
    19791979
    19801980        // SET_SINGLE_CHANNEL_OFFSET
    1981         T::AddEvent("SET_CHANNEL_OFFSET", "S:1;F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1981        T::AddEvent("SET_CHANNEL_OFFSET", "S:1;F:1", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    19821982            (bind(&StateMachineBias::SetChannelOffset, this, placeholders::_1))
    19831983            ("Set single channels to its G-APD breakdown voltage plus overvoltage plus the given offset. Starts ramping if necessary."
    19841984             "|channel[short]:Channel for which to set the target voltage [0-415]"
    19851985             "|offset[V]:Offset to be added to the G-APD reference voltage of the given channel");
    1986         T::AddEvent("SET_GLOBAL_OFFSET", "F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1986        T::AddEvent("SET_GLOBAL_OFFSET", "F:1", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    19871987            (bind(&StateMachineBias::SetGlobalOffset, this, placeholders::_1))
    19881988            ("Set all channels to their G-APD breakdown voltage plus overvoltage plus the given offset. Starts ramping if necessary."
    19891989             "|offset[V]:Offset to be added to the G-APD reference voltage globally");
    1990         T::AddEvent("SET_ALL_CHANNELS_OFFSET", "F:416", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1990        T::AddEvent("SET_ALL_CHANNELS_OFFSET", "F:416", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    19911991            (bind(&StateMachineBias::SetAllChannelsOffset, this, placeholders::_1))
    19921992            ("Set all channels to their G-APD reference voltage plus the given offset. Starts ramping if necessary."
     
    19941994
    19951995
    1996         T::AddEvent("SET_GLOBAL_OFFSET_TO_ZERO", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1996        T::AddEvent("SET_GLOBAL_OFFSET_TO_ZERO", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    19971997            (Wrapper(bind(&ConnectionBias::RampAllOffsets, &fBias, 0., false)))
    19981998            ("Set all channels to their G-APD reference voltage. Starts ramping if necessary.");
    19991999
    2000         T::AddEvent("SET_CHANNEL_OFFSET_TO_ZERO", "S:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     2000        T::AddEvent("SET_CHANNEL_OFFSET_TO_ZERO", "S:1", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    20012001            (bind(&StateMachineBias::SetChannelOffsetToZero, this, placeholders::_1))
    20022002            ("Set a single channel channels to its G-APD reference voltage. Starts ramping if necessary."
     
    20052005
    20062006
    2007         T::AddEvent("SET_ZERO_VOLTAGE", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     2007        T::AddEvent("SET_ZERO_VOLTAGE", State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)
    20082008            (Wrapper(bind(&ConnectionBias::RampAllDacs, &fBias, 0)))
    20092009            ("Set all channels to a zero reference voltage. Starts ramping if necessary.");
     
    20132013
    20142014
    2015         T::AddEvent("STOP", kConnected, kRamping)
     2015        T::AddEvent("STOP", State::kConnected, State::kRamping)
    20162016            (Wrapper(bind(&ConnectionBias::RampStop, &fBias)))
    20172017            ("Stop an on-going ramping");
    20182018
    2019         T::AddEvent("START", kConnected, kNotReferenced)
     2019        T::AddEvent("START", State::kConnected, State::kNotReferenced)
    20202020            (Wrapper(bind(&ConnectionBias::RampStart, &fBias)))
    20212021            ("Start a ramping if no ramping is in progress and if reference values differ from current voltages");
     
    20412041            ("Enable usage of expert commands (note that for safty reasons the are exclusive with the standard commands)");
    20422042
    2043         T::AddEvent("EXPERT_RESET", kExpertMode)
     2043        T::AddEvent("EXPERT_RESET", State::kExpertMode)
    20442044            (Wrapper(bind(&ConnectionBias::ExpertReset, &fBias, true)))
    20452045            ("Send the RESET command (note that this is possibly harmfull command)");
    20462046
    2047         T::AddEvent("EXPERT_SET_GLOBAL_VOLTAGE", "F:1", kExpertMode)
     2047        T::AddEvent("EXPERT_SET_GLOBAL_VOLTAGE", "F:1", State::kExpertMode)
    20482048            (bind(&StateMachineBias::ExpertSetGlobalVolt, this, placeholders::_1))
    20492049            ("Send the global set command. The given voltage is converted to DAC counts.");
    20502050
    2051         T::AddEvent("EXPERT_SET_GLOBAL_DAC", "S:1", kExpertMode)
     2051        T::AddEvent("EXPERT_SET_GLOBAL_DAC", "S:1", State::kExpertMode)
    20522052            (bind(&StateMachineBias::ExpertSetGlobalDac, this, placeholders::_1))
    20532053            ("Send the global set command.");
    20542054
    2055         T::AddEvent("EXPERT_SET_CHANNEL_VOLTAGE", "S:1;F:1", kExpertMode)
     2055        T::AddEvent("EXPERT_SET_CHANNEL_VOLTAGE", "S:1;F:1", State::kExpertMode)
    20562056            (bind(&StateMachineBias::ExpertSetChannelVolt, this, placeholders::_1))
    20572057            ("Send a single channel set command. The given voltage is converted to DAC commands.");
    20582058
    2059         T::AddEvent("EXPERT_SET_CHANNEL_DAC", "S:1;S:1", kExpertMode)
     2059        T::AddEvent("EXPERT_SET_CHANNEL_DAC", "S:1;S:1", State::kExpertMode)
    20602060            (bind(&StateMachineBias::ExpertSetChannelDac, this, placeholders::_1))
    20612061            ("Send a single channel set command.");
Note: See TracChangeset for help on using the changeset viewer.