Changeset 16783 for trunk/FACT++/src
- Timestamp:
- 06/10/13 11:36:02 (11 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/HeadersFTM.h
r16771 r16783 43 43 kConfiguring1, 44 44 kConfiguring2, 45 kConfigured, 45 kConfigured1, 46 kConfigured2, 46 47 47 48 kConfigError1 = 0x101, -
trunk/FACT++/src/ftmctrl.cc
r16776 r16783 422 422 } 423 423 424 425 424 template<size_t N> 426 425 void PostCmd(array<uint16_t, N> dat, uint16_t u1=0, uint16_t u2=0, uint16_t u3=0, uint16_t u4=0) … … 520 519 } 521 520 522 void CmdStartRun( )521 void CmdStartRun(bool log=true) 523 522 { 524 523 PostCmd(FTM::kCmdStartRun, FTM::kStartRun); 525 524 CmdGetRegister(0); 526 525 527 Info("Sending start trigger."); 526 if (log) 527 Info("Sending start trigger."); 528 528 } 529 529 … … 917 917 bool SetTriggerInterval(uint32_t val) 918 918 { 919 return SetVal(&f BufStaticData.fTriggerInterval, val,919 return SetVal(&fStaticData.fTriggerInterval, val, 920 920 FTM::StaticData::kMaxTriggerInterval); 921 921 } … … 923 923 bool SetTriggerDelay(uint32_t val) 924 924 { 925 return SetVal(&f BufStaticData.fDelayTrigger, val,925 return SetVal(&fStaticData.fDelayTrigger, val, 926 926 FTM::StaticData::kMaxDelayTrigger); 927 927 } … … 929 929 bool SetTimeMarkerDelay(uint32_t val) 930 930 { 931 return SetVal(&f BufStaticData.fDelayTimeMarker, val,931 return SetVal(&fStaticData.fDelayTimeMarker, val, 932 932 FTM::StaticData::kMaxDelayTimeMarker); 933 933 } … … 935 935 bool SetDeadTime(uint32_t val) 936 936 { 937 return SetVal(&f BufStaticData.fDeadTime, val,937 return SetVal(&fStaticData.fDeadTime, val, 938 938 FTM::StaticData::kMaxDeadTime); 939 939 } … … 1518 1518 } 1519 1519 1520 int StartRun() 1521 { 1522 // This is a workaround... it seems that the FTM ignored the 'trigger on' 1523 // as long as it is still sending thresholds to the FTUs (and it seems 1524 // that this is the only command/confguration) which gets ignored. 1525 // So if we are configuring, we resent this command until we got a 1526 // reasonable answer (TriggerOn) back from the FTM. 1527 // There is no need to send the command here, because Execute 1528 // will be called immediately after this anyway before any 1529 // answer could be processed. So it would just guarantee that 1530 // the command is sent twice for no reason. 1531 1532 fFTM.CmdStartRun(); 1533 1534 if (T::GetCurrentState()!=FTM::State::kConfigured1) 1535 return T::GetCurrentState(); 1536 1537 fCounterReg = fFTM.GetCounter(FTM::kRegister); 1538 return FTM::State::kConfigured2; 1539 } 1540 1520 1541 int TakeNevents(const EventImp &evt) 1521 1542 { … … 1637 1658 { 1638 1659 ostringstream msg; 1639 msg << "Set AllThresholds - Value out of range, maximum 0xffff.";1660 msg << "SetSelectedThresholds - Value out of range, maximum 0xffff."; 1640 1661 T::Warn(msg); 1641 1662 } … … 2035 2056 // the counter for the registers has been increased 2036 2057 if (fFTM.GetCounter(FTM::kRegister)<=fCounterReg) 2037 break;2058 return FTM::State::kConfiguring1; 2038 2059 2039 2060 // If now the state is not idle as expected this means we had … … 2053 2074 2054 2075 case FTM::State::kConfiguring2: 2055 case FTM::State::kConfigured :2076 case FTM::State::kConfigured1: 2056 2077 // If FTM has received an anwer to the CmdSendStatDat 2057 2078 // the counter for static data has been increased … … 2075 2096 2076 2097 // Next state is: wait for the answer to our configuration 2077 return FTM::State::kConfigured; 2098 return FTM::State::kConfigured1; 2099 2100 // This state is set by StartRun [START_TRIGGER] 2101 case FTM::State::kConfigured2: 2102 // No answer to the CmdStartRun received yet... go on waiting 2103 if (fFTM.GetCounter(FTM::kRegister)<=fCounterReg) 2104 return FTM::State::kConfigured2; 2105 2106 // Answer received and trigger enable acknowledged 2107 if (fFTM.GetState()==ConnectionFTM::kTriggerOn) 2108 return FTM::State::kTriggerOn; 2109 2110 // If the trigger is not enabled, but the configuration 2111 // has changed go to error state (should never happen) 2112 if (fFTM.GetState()!=ConnectionFTM::kConfigured) 2113 return FTM::State::kConfigError2; 2114 2115 // Send a new command... the previous one might have gone 2116 // ignored by the ftm because it was just after a 2117 // threshold setting during the configured state 2118 fFTM.CmdStartRun(false); 2119 2120 // Set counter to wait for answer. 2121 fCounterReg = fFTM.GetCounter(FTM::kRegister); 2122 2123 // Go on waiting for a proper acknowledge of the trigger enable 2124 return FTM::State::kConfigured2; 2078 2125 2079 2126 case FTM::State::kConfigError1: … … 2093 2140 } 2094 2141 2095 if (T::GetCurrentState()==FTM::State::kConfigured &&2096 fFTM.GetState()==ConnectionFTM::kTriggerOn)2097 {2098 // if (!fFTM.IsLocked())2099 // {2100 // T::Warn("Configuration successfull, but clock conditioner not locked.");2101 // return FTM::State::kConfigError3;2102 // }2103 2104 return FTM::State::kTriggerOn;2105 }2106 2107 2142 return T::GetCurrentState(); 2108 2143 } … … 2129 2164 T::AddStateName(FTM::State::kConfiguring2, "Configuring2", 2130 2165 "New configuration sent... waiting for response."); 2131 T::AddStateName(FTM::State::kConfigured , "Configured",2166 T::AddStateName(FTM::State::kConfigured1, "Configured1", 2132 2167 "Received answer identical with target configuration."); 2168 T::AddStateName(FTM::State::kConfigured2, "Configured2", 2169 "Waiting for acknowledge of trigger enable."); 2133 2170 2134 2171 T::AddStateName(FTM::State::kTriggerOn, "TriggerOn", … … 2167 2204 "|val[short]:Value to be set"); 2168 2205 2169 T::AddEvent("START_TRIGGER", FTM::State::kIdle, FTM::State::kValid, FTM::State::kConfigured )2170 ( Wrapper(bind(&ConnectionFTM::CmdStartRun, &fFTM)))2206 T::AddEvent("START_TRIGGER", FTM::State::kIdle, FTM::State::kValid, FTM::State::kConfigured1, FTM::State::kConfigured2) 2207 (bind(&StateMachineFTM::StartRun, this)) 2171 2208 ("start a run (start distributing triggers)"); 2172 2209 … … 2184 2221 "|status[bool]:disable or enable that the FTM sends rate reports (yes/no)"); 2185 2222 2186 T::AddEvent("SET_THRESHOLD", "I:2", FTM::State::kIdle, FTM::State::kValid, FTM::State::kConfigured , FTM::State::kTriggerOn)2223 T::AddEvent("SET_THRESHOLD", "I:2", FTM::State::kIdle, FTM::State::kValid, FTM::State::kConfigured1, FTM::State::kTriggerOn) 2187 2224 (bind(&StateMachineFTM::SetThreshold, this, placeholders::_1)) 2188 2225 ("Set the comparator threshold" … … 2191 2228 2192 2229 T::AddEvent("SET_SELECTED_THRESHOLDS", "I:160", FTM::State::kTriggerOn) 2193 (bind(&StateMachineFTM::Set AllThresholds, this, placeholders::_1))2230 (bind(&StateMachineFTM::SetSelectedThresholds, this, placeholders::_1)) 2194 2231 ("Set the comparator thresholds. Only thresholds which are different and >=0 are sent." 2195 2232 "|Thresholds[counts]:Threshold to be set in binary counts"); 2196 2233 2197 T::AddEvent("SET_ALL_THRESHOLDS", "I:160", FTM::State::kIdle, FTM::State::kValid, FTM::State::kConfigured )2234 T::AddEvent("SET_ALL_THRESHOLDS", "I:160", FTM::State::kIdle, FTM::State::kValid, FTM::State::kConfigured1) 2198 2235 (bind(&StateMachineFTM::SetAllThresholds, this, placeholders::_1)) 2199 2236 ("Set the comparator thresholds" … … 2211 2248 "|time[0.5s]:The interval is given in units of 0.5s, i.e. 1 means 0.5s, 2 means 1s, ..."); 2212 2249 2213 T::AddEvent("ENABLE_FTU", "I:1;B:1", FTM::State::kIdle, FTM::State::kValid , FTM::State::kConfigured)2250 T::AddEvent("ENABLE_FTU", "I:1;B:1", FTM::State::kIdle, FTM::State::kValid) 2214 2251 (bind(&StateMachineFTM::EnableFTU, this, placeholders::_1)) 2215 2252 ("Enable or disable FTU" … … 2352 2389 // A new configure will first stop the FTM this means 2353 2390 // we can allow it in idle _and_ taking data 2354 T::AddEvent("CONFIGURE", "C")(FTM::State::kIdle)(FTM::State::kValid)(FTM::State::kConfiguring1)(FTM::State::kConfiguring2)(FTM::State::kConfigured )(FTM::State::kTriggerOn)2391 T::AddEvent("CONFIGURE", "C")(FTM::State::kIdle)(FTM::State::kValid)(FTM::State::kConfiguring1)(FTM::State::kConfiguring2)(FTM::State::kConfigured1)(FTM::State::kConfigured2)(FTM::State::kTriggerOn) 2355 2392 (bind(&StateMachineFTM::ConfigureFTM, this, placeholders::_1)) 2356 2393 (""); 2357 2394 2358 T::AddEvent("RESET_CONFIGURE")(FTM::State::kConfiguring1)(FTM::State::kConfiguring2)(FTM::State::kConfigured )(FTM::State::kConfigError1)(FTM::State::kConfigError2)(FTM::State::kConfigError2)2395 T::AddEvent("RESET_CONFIGURE")(FTM::State::kConfiguring1)(FTM::State::kConfiguring2)(FTM::State::kConfigured1)(FTM::State::kConfigured2)(FTM::State::kConfigError1)(FTM::State::kConfigError2)(FTM::State::kConfigError2) 2359 2396 (bind(&StateMachineFTM::ResetConfig, this)) 2360 2397 ("Reset states during a configuration or in case of configuration error"); … … 2362 2399 2363 2400 2364 T::AddEvent("RESET_CRATE", "S:1", FTM::State::kIdle, FTM::State::kValid , FTM::State::kConfigured)2401 T::AddEvent("RESET_CRATE", "S:1", FTM::State::kIdle, FTM::State::kValid) 2365 2402 (bind(&StateMachineFTM::ResetCrate, this, placeholders::_1)) 2366 2403 ("Reset one of the crates 0-3" … … 2407 2444 ("disconnect from ethernet"); 2408 2445 2409 T::AddEvent("RECONNECT", "O", FTM::State::kDisconnected, FTM::State::kConnected, FTM::State::kIdle, FTM::State::kValid , FTM::State::kConfigured)2446 T::AddEvent("RECONNECT", "O", FTM::State::kDisconnected, FTM::State::kConnected, FTM::State::kIdle, FTM::State::kValid) 2410 2447 (bind(&StateMachineFTM::Reconnect, this, placeholders::_1)) 2411 2448 ("(Re)connect ethernet connection to FTM, a new address can be given"
Note:
See TracChangeset
for help on using the changeset viewer.