Changeset 13913 for trunk/FACT++
- Timestamp:
- 05/26/12 14:28:46 (13 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/HeadersBIAS.h
r12108 r13913 30 30 }; 31 31 32 enum States_t32 namespace State 33 33 { 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 } 45 48 } 46 49 -
trunk/FACT++/src/biasctrl.cc
r13457 r13913 24 24 using namespace std::placeholders; 25 25 using namespace std; 26 27 // We can do that because we do not include other headers than HeadersBIAS 26 28 using namespace BIAS; 27 28 //#define DEBUG29 29 30 30 // ------------------------------------------------------------------------ … … 1438 1438 } 1439 1439 1440 State s_t GetStatus()1440 State::states_t GetStatus() 1441 1441 { 1442 1442 if (!IsConnected()) 1443 return BIAS::kDisconnected;1443 return State::kDisconnected; 1444 1444 1445 1445 if (IsConnecting()) 1446 return BIAS::kConnecting;1446 return State::kConnecting; 1447 1447 1448 1448 if (fIsInitializing) 1449 return BIAS::kInitializing;1449 return State::kInitializing; 1450 1450 1451 1451 if (fIsRamping) 1452 return BIAS::kRamping;1452 return State::kRamping; 1453 1453 1454 1454 for (int ch=0; ch<kNumChannels; ch++) 1455 1455 if (fPresent[ch/kNumChannelsPerBoard] && fCurrent[ch]<0) 1456 return BIAS::kOverCurrent;1456 return State::kOverCurrent; 1457 1457 1458 1458 bool isoff = true; … … 1461 1461 isoff = false; 1462 1462 if (isoff) 1463 return BIAS::kVoltageOff;1463 return State::kVoltageOff; 1464 1464 1465 1465 for (int ch=0; ch<kNumChannels; ch++) 1466 1466 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; 1470 1470 } 1471 1471 … … 1853 1853 poll_one(); 1854 1854 1855 return fExpertMode && fBias.GetStatus()>= kConnected ?1856 kExpertMode : fBias.GetStatus();1855 return fExpertMode && fBias.GetStatus()>=State::kConnected ? 1856 State::kExpertMode : fBias.GetStatus(); 1857 1857 } 1858 1858 … … 1870 1870 1871 1871 // State names 1872 T::AddStateName( kDisconnected, "Disconnected",1872 T::AddStateName(State::kDisconnected, "Disconnected", 1873 1873 "Bias-power supply not connected via USB."); 1874 1874 1875 T::AddStateName( kConnecting, "Connecting",1875 T::AddStateName(State::kConnecting, "Connecting", 1876 1876 "Trying to establish USB connection to bias-power supply."); 1877 1877 1878 T::AddStateName( kInitializing, "Initializing",1878 T::AddStateName(State::kInitializing, "Initializing", 1879 1879 "USB connection to bias-power supply established, synchronizing USB stream."); 1880 1880 1881 T::AddStateName( kConnected, "Connected",1881 T::AddStateName(State::kConnected, "Connected", 1882 1882 "USB connection to bias-power supply established."); 1883 1883 1884 T::AddStateName( kNotReferenced, "NotReferenced",1884 T::AddStateName(State::kNotReferenced, "NotReferenced", 1885 1885 "Internal reference voltage does not match last sent voltage."); 1886 1886 1887 T::AddStateName( kVoltageOff, "VoltageOff",1887 T::AddStateName(State::kVoltageOff, "VoltageOff", 1888 1888 "All voltages are supposed to be switched off."); 1889 1889 1890 T::AddStateName( kVoltageOn, "VoltageOn",1890 T::AddStateName(State::kVoltageOn, "VoltageOn", 1891 1891 "At least one voltage is switched on and all are at reference."); 1892 1892 1893 T::AddStateName( kOverCurrent, "OverCurrent",1893 T::AddStateName(State::kOverCurrent, "OverCurrent", 1894 1894 "At least one channel is in over current state."); 1895 1895 1896 T::AddStateName( kExpertMode, "ExpertMode",1896 T::AddStateName(State::kExpertMode, "ExpertMode", 1897 1897 "Special (risky!) mode to directly send command to the bias-power supply."); 1898 1898 1899 T::AddStateName( kRamping, "Ramping",1899 T::AddStateName(State::kRamping, "Ramping", 1900 1900 "Voltage ramping in progress."); 1901 1901 … … 1912 1912 1913 1913 // Conenction commands 1914 T::AddEvent("DISCONNECT", kConnected,kVoltageOff)1914 T::AddEvent("DISCONNECT", State::kConnected, State::kVoltageOff) 1915 1915 (bind(&StateMachineBias::Disconnect, this)) 1916 1916 ("disconnect from USB"); 1917 T::AddEvent("RECONNECT", "O", kDisconnected, kConnected,kVoltageOff)1917 T::AddEvent("RECONNECT", "O", State::kDisconnected, State::kConnected, State::kVoltageOff) 1918 1918 (bind(&StateMachineBias::Reconnect, this, placeholders::_1)) 1919 1919 ("(Re)connect USB connection to Bias power supply, a new address can be given" … … 1928 1928 1929 1929 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) 1931 1931 (Wrapper(bind(&ConnectionBias::ReadAllChannels, &fBias, false))) 1932 1932 ("Asynchronously request the status (current) of all channels."); 1933 1933 1934 T::AddEvent("RESET_OVER_CURRENT_STATUS", kOverCurrent)1934 T::AddEvent("RESET_OVER_CURRENT_STATUS", State::kOverCurrent) 1935 1935 (Wrapper(bind(&ConnectionBias::OverCurrentReset, &fBias))) 1936 1936 ("Set all channels in over current state to 0V and send a system reset to reset the over current flags."); 1937 1937 1938 1938 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) 1940 1940 (bind(&StateMachineBias::SetChannelDac, this, placeholders::_1)) 1941 1941 ("Set a new target value in DAC counts for a single channel. Starts ramping if necessary." 1942 1942 "|channel[short]:Channel for which to set the target voltage [0-415]" 1943 1943 "|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) 1945 1945 (bind(&StateMachineBias::SetGlobalDac, this, placeholders::_1)) 1946 1946 ("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.)" … … 1948 1948 1949 1949 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) 1951 1951 (bind(&StateMachineBias::SetChannelVolt, this, placeholders::_1)) 1952 1952 ("Set a new target voltage for a single channel. Starts ramping if necessary." 1953 1953 "|channel[short]:Channel for which to set the target voltage [0-415]" 1954 1954 "|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) 1956 1956 (bind(&StateMachineBias::SetGlobalVolt, this, placeholders::_1)) 1957 1957 ("Set a new target voltage for all channels. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)" 1958 1958 "|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) 1960 1960 (bind(&StateMachineBias::SetAllChannelsVolt, this, placeholders::_1)) 1961 1961 ("Set all channels to the given new reference voltage. Starts ramping if necessary." … … 1963 1963 1964 1964 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) 1966 1966 (bind(&StateMachineBias::IncChannelVolt, this, placeholders::_1)) 1967 1967 ("Increases the voltage of all channels by the given offset. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)" 1968 1968 "|channel[short]:Channel for which to adapt the voltage [0-415]" 1969 1969 "|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) 1971 1971 (bind(&StateMachineBias::IncGlobalVolt, this, placeholders::_1)) 1972 1972 ("Increases the voltage of all channels by the given offset. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)" 1973 1973 "|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) 1975 1975 (bind(&StateMachineBias::IncAllChannelsVolt, this, placeholders::_1)) 1976 1976 ("Add the given voltages to the current reference voltages. Starts ramping if necessary." … … 1979 1979 1980 1980 // 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) 1982 1982 (bind(&StateMachineBias::SetChannelOffset, this, placeholders::_1)) 1983 1983 ("Set single channels to its G-APD breakdown voltage plus overvoltage plus the given offset. Starts ramping if necessary." 1984 1984 "|channel[short]:Channel for which to set the target voltage [0-415]" 1985 1985 "|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) 1987 1987 (bind(&StateMachineBias::SetGlobalOffset, this, placeholders::_1)) 1988 1988 ("Set all channels to their G-APD breakdown voltage plus overvoltage plus the given offset. Starts ramping if necessary." 1989 1989 "|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) 1991 1991 (bind(&StateMachineBias::SetAllChannelsOffset, this, placeholders::_1)) 1992 1992 ("Set all channels to their G-APD reference voltage plus the given offset. Starts ramping if necessary." … … 1994 1994 1995 1995 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) 1997 1997 (Wrapper(bind(&ConnectionBias::RampAllOffsets, &fBias, 0., false))) 1998 1998 ("Set all channels to their G-APD reference voltage. Starts ramping if necessary."); 1999 1999 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) 2001 2001 (bind(&StateMachineBias::SetChannelOffsetToZero, this, placeholders::_1)) 2002 2002 ("Set a single channel channels to its G-APD reference voltage. Starts ramping if necessary." … … 2005 2005 2006 2006 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) 2008 2008 (Wrapper(bind(&ConnectionBias::RampAllDacs, &fBias, 0))) 2009 2009 ("Set all channels to a zero reference voltage. Starts ramping if necessary."); … … 2013 2013 2014 2014 2015 T::AddEvent("STOP", kConnected,kRamping)2015 T::AddEvent("STOP", State::kConnected, State::kRamping) 2016 2016 (Wrapper(bind(&ConnectionBias::RampStop, &fBias))) 2017 2017 ("Stop an on-going ramping"); 2018 2018 2019 T::AddEvent("START", kConnected,kNotReferenced)2019 T::AddEvent("START", State::kConnected, State::kNotReferenced) 2020 2020 (Wrapper(bind(&ConnectionBias::RampStart, &fBias))) 2021 2021 ("Start a ramping if no ramping is in progress and if reference values differ from current voltages"); … … 2041 2041 ("Enable usage of expert commands (note that for safty reasons the are exclusive with the standard commands)"); 2042 2042 2043 T::AddEvent("EXPERT_RESET", kExpertMode)2043 T::AddEvent("EXPERT_RESET", State::kExpertMode) 2044 2044 (Wrapper(bind(&ConnectionBias::ExpertReset, &fBias, true))) 2045 2045 ("Send the RESET command (note that this is possibly harmfull command)"); 2046 2046 2047 T::AddEvent("EXPERT_SET_GLOBAL_VOLTAGE", "F:1", kExpertMode)2047 T::AddEvent("EXPERT_SET_GLOBAL_VOLTAGE", "F:1", State::kExpertMode) 2048 2048 (bind(&StateMachineBias::ExpertSetGlobalVolt, this, placeholders::_1)) 2049 2049 ("Send the global set command. The given voltage is converted to DAC counts."); 2050 2050 2051 T::AddEvent("EXPERT_SET_GLOBAL_DAC", "S:1", kExpertMode)2051 T::AddEvent("EXPERT_SET_GLOBAL_DAC", "S:1", State::kExpertMode) 2052 2052 (bind(&StateMachineBias::ExpertSetGlobalDac, this, placeholders::_1)) 2053 2053 ("Send the global set command."); 2054 2054 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) 2056 2056 (bind(&StateMachineBias::ExpertSetChannelVolt, this, placeholders::_1)) 2057 2057 ("Send a single channel set command. The given voltage is converted to DAC commands."); 2058 2058 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) 2060 2060 (bind(&StateMachineBias::ExpertSetChannelDac, this, placeholders::_1)) 2061 2061 ("Send a single channel set command.");
Note:
See TracChangeset
for help on using the changeset viewer.