Changeset 16783 for trunk/FACT++/src


Ignore:
Timestamp:
06/10/13 11:36:02 (11 years ago)
Author:
tbretz
Message:
Replaced kConfigured by kConfigured1. This is the state in which sending thresholds is allowed. As soon as the trigger is enabled we go to kConfugred2. Since the ftm ignores trigger on while still configuring the FTUs, the trigger on is resent until we get a proper answer.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r16771 r16783  
    4343            kConfiguring1,
    4444            kConfiguring2,
    45             kConfigured,
     45            kConfigured1,
     46            kConfigured2,
    4647
    4748            kConfigError1 = 0x101,
  • trunk/FACT++/src/ftmctrl.cc

    r16776 r16783  
    422422    }
    423423
    424 
    425424    template<size_t N>
    426425    void PostCmd(array<uint16_t, N> dat, uint16_t u1=0, uint16_t u2=0, uint16_t u3=0, uint16_t u4=0)
     
    520519    }
    521520
    522     void CmdStartRun()
     521    void CmdStartRun(bool log=true)
    523522    {
    524523        PostCmd(FTM::kCmdStartRun, FTM::kStartRun);
    525524        CmdGetRegister(0);
    526525
    527         Info("Sending start trigger.");
     526        if (log)
     527            Info("Sending start trigger.");
    528528    }
    529529
     
    917917    bool SetTriggerInterval(uint32_t val)
    918918    {
    919         return SetVal(&fBufStaticData.fTriggerInterval, val,
     919        return SetVal(&fStaticData.fTriggerInterval, val,
    920920                      FTM::StaticData::kMaxTriggerInterval);
    921921    }
     
    923923    bool SetTriggerDelay(uint32_t val)
    924924    {
    925         return SetVal(&fBufStaticData.fDelayTrigger, val,
     925        return SetVal(&fStaticData.fDelayTrigger, val,
    926926                      FTM::StaticData::kMaxDelayTrigger);
    927927    }
     
    929929    bool SetTimeMarkerDelay(uint32_t val)
    930930    {
    931         return SetVal(&fBufStaticData.fDelayTimeMarker, val,
     931        return SetVal(&fStaticData.fDelayTimeMarker, val,
    932932                      FTM::StaticData::kMaxDelayTimeMarker);
    933933    }
     
    935935    bool SetDeadTime(uint32_t val)
    936936    {
    937         return SetVal(&fBufStaticData.fDeadTime, val,
     937        return SetVal(&fStaticData.fDeadTime, val,
    938938                      FTM::StaticData::kMaxDeadTime);
    939939    }
     
    15181518    }
    15191519
     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
    15201541    int TakeNevents(const EventImp &evt)
    15211542    {
     
    16371658        {
    16381659            ostringstream msg;
    1639             msg << "SetAllThresholds - Value out of range, maximum 0xffff.";
     1660            msg << "SetSelectedThresholds - Value out of range, maximum 0xffff.";
    16401661            T::Warn(msg);
    16411662        }
     
    20352056            // the counter for the registers has been increased
    20362057            if (fFTM.GetCounter(FTM::kRegister)<=fCounterReg)
    2037                 break;
     2058                return FTM::State::kConfiguring1;
    20382059
    20392060            // If now the state is not idle as expected this means we had
     
    20532074
    20542075        case FTM::State::kConfiguring2:
    2055         case FTM::State::kConfigured:
     2076        case FTM::State::kConfigured1:
    20562077            // If FTM has received an anwer to the CmdSendStatDat
    20572078            // the counter for static data has been increased
     
    20752096
    20762097            // 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;
    20782125
    20792126        case FTM::State::kConfigError1:
     
    20932140        }
    20942141
    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 
    21072142        return T::GetCurrentState();
    21082143    }
     
    21292164        T::AddStateName(FTM::State::kConfiguring2, "Configuring2",
    21302165                        "New configuration sent... waiting for response.");
    2131         T::AddStateName(FTM::State::kConfigured,   "Configured",
     2166        T::AddStateName(FTM::State::kConfigured1,   "Configured1",
    21322167                        "Received answer identical with target configuration.");
     2168        T::AddStateName(FTM::State::kConfigured2, "Configured2",
     2169                        "Waiting for acknowledge of trigger enable.");
    21332170
    21342171        T::AddStateName(FTM::State::kTriggerOn, "TriggerOn",
     
    21672204            "|val[short]:Value to be set");
    21682205
    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))
    21712208            ("start a run (start distributing triggers)");
    21722209
     
    21842221             "|status[bool]:disable or enable that the FTM sends rate reports (yes/no)");
    21852222
    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)
    21872224            (bind(&StateMachineFTM::SetThreshold, this, placeholders::_1))
    21882225            ("Set the comparator threshold"
     
    21912228
    21922229        T::AddEvent("SET_SELECTED_THRESHOLDS", "I:160", FTM::State::kTriggerOn)
    2193             (bind(&StateMachineFTM::SetAllThresholds, this, placeholders::_1))
     2230            (bind(&StateMachineFTM::SetSelectedThresholds, this, placeholders::_1))
    21942231            ("Set the comparator thresholds. Only thresholds which are different and >=0 are sent."
    21952232             "|Thresholds[counts]:Threshold to be set in binary counts");
    21962233
    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)
    21982235            (bind(&StateMachineFTM::SetAllThresholds, this, placeholders::_1))
    21992236            ("Set the comparator thresholds"
     
    22112248             "|time[0.5s]:The interval is given in units of 0.5s, i.e. 1 means 0.5s, 2 means 1s, ...");
    22122249
    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)
    22142251            (bind(&StateMachineFTM::EnableFTU, this, placeholders::_1))
    22152252            ("Enable or disable FTU"
     
    23522389        // A new configure will first stop the FTM this means
    23532390        // 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)
    23552392            (bind(&StateMachineFTM::ConfigureFTM, this, placeholders::_1))
    23562393            ("");
    23572394
    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)
    23592396            (bind(&StateMachineFTM::ResetConfig, this))
    23602397            ("Reset states during a configuration or in case of configuration error");
     
    23622399
    23632400
    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)
    23652402            (bind(&StateMachineFTM::ResetCrate, this, placeholders::_1))
    23662403            ("Reset one of the crates 0-3"
     
    24072444            ("disconnect from ethernet");
    24082445
    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)
    24102447            (bind(&StateMachineFTM::Reconnect, this, placeholders::_1))
    24112448            ("(Re)connect ethernet connection to FTM, a new address can be given"
Note: See TracChangeset for help on using the changeset viewer.