Changeset 17512 for trunk/FACT++/src
- Timestamp:
- 01/16/14 18:50:47 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/biasctrl.cc
r17174 r17512 1605 1605 1606 1606 bool fExpertMode; 1607 bool fEmergencyShutdown; 1608 1609 Time fSunRise; 1607 1610 1608 1611 // -------------------------------------------------------------------- … … 1861 1864 } 1862 1865 1866 int Shutdown() 1867 { 1868 fBias.RampAllDacs(0); 1869 fEmergencyShutdown = true; 1870 T::Info("Emergency Sutdown initiated."); 1871 return T::GetCurrentState(); 1872 } 1873 1874 int Unlock() 1875 { 1876 fEmergencyShutdown = false; 1877 return T::GetCurrentState(); 1878 } 1879 1863 1880 int Execute() 1864 1881 { 1865 return fExpertMode && fBias.GetStatus()>=State::kConnected ? 1866 State::kExpertMode : fBias.GetStatus(); 1882 const int state = fBias.GetStatus(); 1883 1884 const Time now; 1885 if (now>fSunRise) 1886 { 1887 if (state==State::kRamping || 1888 state==State::kVoltageOn || 1889 state==State::kNotReferenced) 1890 return Shutdown(); 1891 1892 if (state==State::kLocked) 1893 { 1894 fSunRise = now.GetNextSunRise(-6); 1895 1896 ostringstream msg; 1897 msg << "Next sun-rise will be at " << fSunRise; 1898 T::Info(msg); 1899 1900 return T::GetCurrentState(); 1901 } 1902 } 1903 1904 if (T::GetCurrentState()==State::kVoltageOff && T::GetCurrentState()==State::kLocked) 1905 return State::kLocked; 1906 1907 if (fExpertMode && state>=State::kLocked) 1908 return State::kExpertMode; 1909 1910 return state; 1867 1911 } 1868 1912 1869 1913 public: 1870 1914 StateMachineBias(ostream &out=cout) : 1871 StateMachineAsio<T>(out, "BIAS_CONTROL"), fBias(*this, *this), fExpertMode(false) 1915 StateMachineAsio<T>(out, "BIAS_CONTROL"), fBias(*this, *this), 1916 fExpertMode(false), fEmergencyShutdown(false), 1917 fSunRise(Time().GetNextSunRise(-6)) 1872 1918 { 1873 1919 // State names … … 1901 1947 T::AddStateName(State::kRamping, "Ramping", 1902 1948 "Voltage ramping in progress."); 1949 1950 T::AddStateName(State::kLocked, "Locked", 1951 "Locked, no commands accepted except UNLOCK."); 1903 1952 1904 1953 // Verbosity commands … … 1939 1988 1940 1989 1941 T::AddEvent("SET_CHANNEL_DAC", "S:1;S:1" , State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)1990 T::AddEvent("SET_CHANNEL_DAC", "S:1;S:1")(State::kConnected)(State::kVoltageOff)(State::kVoltageOn)(State::kNotReferenced)(State::kOverCurrent)(State::kRamping) 1942 1991 (bind(&StateMachineBias::SetChannelDac, this, placeholders::_1)) 1943 1992 ("Set a new target value in DAC counts for a single channel. Starts ramping if necessary." 1944 1993 "|channel[short]:Channel for which to set the target voltage [0-415]" 1945 1994 "|voltage[dac]:Target voltage in DAC units for the given channel"); 1946 T::AddEvent("SET_GLOBAL_DAC", "S:1" , State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)1995 T::AddEvent("SET_GLOBAL_DAC", "S:1")(State::kConnected)(State::kVoltageOff)(State::kVoltageOn)(State::kNotReferenced)(State::kOverCurrent)(State::kRamping) 1947 1996 (bind(&StateMachineBias::SetGlobalDac, this, placeholders::_1)) 1948 1997 ("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.)" … … 1950 1999 1951 2000 1952 T::AddEvent("SET_CHANNEL_VOLTAGE", "S:1;F:1" , State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)2001 T::AddEvent("SET_CHANNEL_VOLTAGE", "S:1;F:1")(State::kConnected)(State::kVoltageOff)(State::kVoltageOn)(State::kNotReferenced)(State::kOverCurrent)(State::kRamping) 1953 2002 (bind(&StateMachineBias::SetChannelVolt, this, placeholders::_1)) 1954 2003 ("Set a new target voltage for a single channel. Starts ramping if necessary." 1955 2004 "|channel[short]:Channel for which to set the target voltage [0-415]" 1956 2005 "|voltage[V]:Target voltage in volts for the given channel (will be converted to DAC units)"); 1957 T::AddEvent("SET_GLOBAL_VOLTAGE", "F:1" , State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)2006 T::AddEvent("SET_GLOBAL_VOLTAGE", "F:1")(State::kConnected)(State::kVoltageOff)(State::kVoltageOn)(State::kNotReferenced)(State::kOverCurrent)(State::kRamping) 1958 2007 (bind(&StateMachineBias::SetGlobalVolt, this, placeholders::_1)) 1959 2008 ("Set a new target voltage for all channels. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)" 1960 2009 "|voltage[V]:Global target voltage in volts (will be converted to DAC units)"); 1961 T::AddEvent("SET_ALL_CHANNELS_VOLTAGE", "F:416" , State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)2010 T::AddEvent("SET_ALL_CHANNELS_VOLTAGE", "F:416")(State::kConnected)(State::kVoltageOff)(State::kVoltageOn)(State::kNotReferenced)(State::kOverCurrent)(State::kRamping) 1962 2011 (bind(&StateMachineBias::SetAllChannelsVolt, this, placeholders::_1)) 1963 2012 ("Set all channels to the given new reference voltage. Starts ramping if necessary." … … 1982 2031 1983 2032 1984 T::AddEvent("SET_ZERO_VOLTAGE" , State::kConnected, State::kVoltageOff, State::kVoltageOn, State::kNotReferenced, State::kOverCurrent)2033 T::AddEvent("SET_ZERO_VOLTAGE")(State::kConnected)(State::kVoltageOff)(State::kVoltageOn)(State::kNotReferenced)(State::kOverCurrent)(State::kRamping) 1985 2034 (Wrapper(bind(&ConnectionBias::RampAllDacs, &fBias, 0))) 1986 2035 ("Set all channels to a zero reference voltage. Starts ramping if necessary."); 2036 T::AddEvent("SHUTDOWN")(State::kConnected)(State::kVoltageOff)(State::kVoltageOn)(State::kNotReferenced)(State::kOverCurrent)(State::kRamping) 2037 (bind(&StateMachineBias::Shutdown, this)) 2038 ("Same as SET_ZERO_VOLTAGE; but goes to locked state afterwards."); 2039 2040 T::AddEvent("UNLOCK", State::kLocked) 2041 (bind(&StateMachineBias::Unlock, this)) 2042 ("Unlock if in locked state."); 1987 2043 1988 2044
Note:
See TracChangeset
for help on using the changeset viewer.