Changeset 13910 for trunk/FACT++


Ignore:
Timestamp:
05/26/12 14:18:15 (13 years ago)
Author:
tbretz
Message:
Moved state machine states to namespace State
Location:
trunk/FACT++/src
Files:
4 edited

Legend:

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

    r12998 r13910  
    5555    };
    5656
    57     enum States
    58     {
    59         // State Machine states
    60         kOffline = 1,   // StateMachineImp::kSM_UserMode
    61         kDisconnected,
    62         kConnecting,
    63         kConnected,
    64         kConfiguring1,
    65         kConfiguring2,
    66         kConfigured,
    67         kWritingData
    68     };
     57    namespace State
     58    {
     59        enum States
     60        {
     61            // State Machine states
     62            kOffline = 1,   // StateMachineImp::kSM_UserMode
     63            kDisconnected,
     64            kConnecting,
     65            kConnected,
     66            kConfiguring1,
     67            kConfiguring2,
     68            kConfigured,
     69            kWritingData
     70        };
     71    }
    6972
    7073    enum FileFormat_t
  • trunk/FACT++/src/HeadersFTM.h

    r13760 r13910  
    3232    // running: not locked: 0x2713
    3333
    34     enum StateMachine
    35     {
    36         kDisconnected = 1, //= ConnectionFTM::kDisconnected,
    37         kConnected,        //= ConnectionFTM::kConnected,
    38         kIdle,             //= ConnectionFTM::kIdle,
    39         kTriggerOn,        //= ConnectionFTM::kTriggerOn,
    40         kConfiguring1,
    41         kConfiguring2,
    42         kConfigured,
    43 
    44         kConfigError1 = 0x101,
    45         kConfigError2 = 0x102,
    46     };
     34    namespace State
     35    {
     36        enum StateMachine
     37        {
     38            kDisconnected = 1, //= ConnectionFTM::kDisconnected,
     39            kConnected,        //= ConnectionFTM::kConnected,
     40            kIdle,             //= ConnectionFTM::kIdle,
     41            kTriggerOn,        //= ConnectionFTM::kTriggerOn,
     42            kConfiguring1,
     43            kConfiguring2,
     44            kConfigured,
     45
     46            kConfigError1 = 0x101,
     47            kConfigError2 = 0x102,
     48        };
     49    }
    4750
    4851    /// Command codes for FTM communication
  • trunk/FACT++/src/fadctrl.cc

    r13900 r13910  
    10731073            fNightAsInt = InitRunNumber();
    10741074            if (fNightAsInt<0)
    1075                 return FAD::kConnected;
     1075                return FAD::State::kConnected;
    10761076        }
    10771077
     
    11251125        fConfigTimer = Time();
    11261126
    1127         return FAD::kConfiguring1;
     1127        return FAD::State::kConfiguring1;
    11281128    }
    11291129
     
    11331133        fDimStartRun.Update(runs);
    11341134
    1135         return FAD::kConnected;
     1135        return FAD::State::kConnected;
    11361136    }
    11371137
     
    14341434        if (nconnecting1==0 && nconnected1>0 && nconnected2==nconnected1)
    14351435        {
    1436             if (T::GetCurrentState()==FAD::kConfiguring1)
     1436            if (T::GetCurrentState()==FAD::State::kConfiguring1)
    14371437            {
    14381438                // We need some delay so that the FAD is not busy anymore
     
    14401440                // FIXME: Do we need this to be configurable?
    14411441                if (Time()-fConfigTimer<boost::posix_time::milliseconds(3000))
    1442                     return FAD::kConfiguring1;
     1442                    return FAD::State::kConfiguring1;
    14431443
    14441444                for (BoardList::iterator it=fBoards.begin(); it!=fBoards.end(); it++)
    14451445                    it->second->Cmd(FAD::kCmdSingleTrigger);
    14461446
    1447                 return FAD::kConfiguring2;
     1447                return FAD::State::kConfiguring2;
    14481448            }
    14491449
    14501450            // If all boards are configured and we are configuring
    14511451            // go on and start the FADs
    1452             if (T::GetCurrentState()==FAD::kConfiguring2)
     1452            if (T::GetCurrentState()==FAD::State::kConfiguring2)
    14531453            {
    14541454                // If not all boards have yet received the proper
    14551455                // configuration
    14561456                if (nconfigured!=nconnected1)
    1457                     return FAD::kConfiguring2;
     1457                    return FAD::State::kConfiguring2;
    14581458
    14591459                // FIXME: Distinguish between not all boards have received
     
    14771477                    //        successfully enabled the trigger lines?
    14781478                }
    1479                 return FAD::kConfigured;
    1480             }
    1481 
    1482             if (T::GetCurrentState()==FAD::kConfigured)
     1479                return FAD::State::kConfigured;
     1480            }
     1481
     1482            if (T::GetCurrentState()==FAD::State::kConfigured)
    14831483            {
    14841484                // Stay in Configured as long as we have a valid
     
    14871487                // first event)
    14881488                if (!IsRunStarted() && nconfigured==nconnected1)
    1489                     return FAD::kConfigured;
     1489                    return FAD::State::kConfigured;
    14901490
    14911491                if (IsRunStarted())
     
    14951495            }
    14961496
    1497             return GetNumFilesOpen()>0 ? FAD::kWritingData : FAD::kConnected;
     1497            return GetNumFilesOpen()>0 ? FAD::State::kWritingData : FAD::State::kConnected;
    14981498        }
    14991499
    15001500        if (nconnecting1>0 || nconnecting2>0 || nconnected1!=nconnected2)
    1501             return FAD::kConnecting;
     1501            return FAD::State::kConnecting;
    15021502
    15031503        // nconnected1 == nconnected2 == 0
    1504         return runs ? FAD::kDisconnected : FAD::kOffline;
     1504        return runs ? FAD::State::kDisconnected : FAD::State::kOffline;
    15051505    }
    15061506
     
    15711571
    15721572        // State names
    1573         T::AddStateName(FAD::kOffline, "Disengaged",
     1573        T::AddStateName(FAD::State::kOffline, "Disengaged",
    15741574                        "All enabled FAD boards are disconnected and the event-builer thread is not running.");
    15751575
    1576         T::AddStateName(FAD::kDisconnected, "Disconnected",
     1576        T::AddStateName(FAD::State::kDisconnected, "Disconnected",
    15771577                        "All enabled FAD boards are disconnected, but the event-builder thread is running.");
    15781578
    1579         T::AddStateName(FAD::kConnecting, "Connecting",
     1579        T::AddStateName(FAD::State::kConnecting, "Connecting",
    15801580                        "Only some enabled FAD boards are connected.");
    15811581
    1582         T::AddStateName(FAD::kConnected, "Connected",
     1582        T::AddStateName(FAD::State::kConnected, "Connected",
    15831583                        "All enabled FAD boards are connected..");
    15841584
    1585         T::AddStateName(FAD::kConfiguring1, "Configuring1",
     1585        T::AddStateName(FAD::State::kConfiguring1, "Configuring1",
    15861586                        "Waiting 3 seconds for all FADs to be configured before requesting configuration.");
    15871587
    1588         T::AddStateName(FAD::kConfiguring2, "Configuring2",
     1588        T::AddStateName(FAD::State::kConfiguring2, "Configuring2",
    15891589                        "Waiting until all boards returned their configuration and they are valid.");
    15901590
    1591         T::AddStateName(FAD::kConfigured, "Configured",
     1591        T::AddStateName(FAD::State::kConfigured, "Configured",
    15921592                        "The configuration of all boards was successfully cross checked. Waiting for events with a new run number to receive.");
    15931593
    1594         T::AddStateName(FAD::kWritingData, "WritingData",
     1594        T::AddStateName(FAD::State::kWritingData, "WritingData",
    15951595                        "The event builder has an open file (that does not mean that new events are currently received)");
    15961596
    15971597        // FAD Commands
    1598         T::AddEvent("SEND_CMD", "I:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1598        T::AddEvent("SEND_CMD", "I:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    15991599            (bind(&StateMachineFAD::SendCmd, this, placeholders::_1))
    16001600            ("Send a command to the FADs. Values between 0 and 0xffff are allowed."
    16011601             "|command[uint16]:Command to be transmittted.");
    1602         T::AddEvent("SEND_DATA", "I:2", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1602        T::AddEvent("SEND_DATA", "I:2", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16031603            (bind(&StateMachineFAD::SendCmdData, this, placeholders::_1))
    16041604            ("Send a command with data to the FADs. Values between 0 and 0xffff are allowed."
     
    16061606             "|data[uint16]:Data to be sent with the command.");
    16071607
    1608         T::AddEvent("ENABLE_SRCLK", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1608        T::AddEvent("ENABLE_SRCLK", "B:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16091609            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdSrclk))
    16101610            ("Set SRCLK");
    1611         T::AddEvent("ENABLE_BUSY_OFF", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1611        T::AddEvent("ENABLE_BUSY_OFF", "B:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16121612            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdBusyOff))
    16131613            ("Set BUSY continously low");
    1614         T::AddEvent("ENABLE_BUSY_ON", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1614        T::AddEvent("ENABLE_BUSY_ON", "B:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16151615            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdBusyOn))
    16161616            ("Set BUSY constantly high (has priority over BUSY_OFF)");
    1617         T::AddEvent("ENABLE_SCLK", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1617        T::AddEvent("ENABLE_SCLK", "B:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16181618            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdSclk))
    16191619            ("Set SCLK");
    1620         T::AddEvent("ENABLE_DRS", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1620        T::AddEvent("ENABLE_DRS", "B:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16211621            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdDrsEnable))
    16221622            ("Switch Domino wave");
    1623         T::AddEvent("ENABLE_DWRITE", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1623        T::AddEvent("ENABLE_DWRITE", "B:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16241624            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdDwrite))
    16251625            ("Set Dwrite (possibly high / always low)");
    1626         T::AddEvent("ENABLE_CONTINOUS_TRIGGER", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1626        T::AddEvent("ENABLE_CONTINOUS_TRIGGER", "B:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16271627            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdContTrigger))
    16281628            ("Enable continous (internal) trigger.");
    1629         T::AddEvent("ENABLE_TRIGGER_LINE", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1629        T::AddEvent("ENABLE_TRIGGER_LINE", "B:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16301630            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdTriggerLine))
    16311631            ("Incoming triggers can be accepted/will not be accepted");
    1632         T::AddEvent("ENABLE_COMMAND_SOCKET_MODE", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1632        T::AddEvent("ENABLE_COMMAND_SOCKET_MODE", "B:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16331633            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdSocket))
    16341634            ("Set debug mode (yes: dump events through command socket, no=dump events through other sockets)");
    16351635
    1636         T::AddEvent("SET_TRIGGER_RATE", "I:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1636        T::AddEvent("SET_TRIGGER_RATE", "I:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16371637            (bind(&StateMachineFAD::SetTriggerRate, this, placeholders::_1))
    16381638            ("Enable continous trigger");
     
    16401640            (bind(&StateMachineFAD::Trigger, this, 1))
    16411641            ("Issue software triggers");
    1642         T::AddEvent("SEND_N_TRIGGERS", "I", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1642        T::AddEvent("SEND_N_TRIGGERS", "I", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16431643            (bind(&StateMachineFAD::SendTriggers, this, placeholders::_1))
    16441644            ("Issue N software triggers (note that these are the triggers sent, not the triggers executed)"
     
    16521652            ("");
    16531653            */
    1654         T::AddEvent("PHASE_SHIFT", "S:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1654        T::AddEvent("PHASE_SHIFT", "S:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16551655            (bind(&StateMachineFAD::PhaseShift, this, placeholders::_1))
    16561656            ("Adjust ADC phase (in 'steps')"
    16571657             "|phase[short]");
    16581658
    1659         T::AddEvent("RESET_EVENT_COUNTER", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1659        T::AddEvent("RESET_EVENT_COUNTER", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16601660            (bind(&StateMachineFAD::Cmd, this, FAD::kCmdResetEventCounter))
    16611661            ("Reset the FAD boards' event counter to 0.");
    16621662
    1663         T::AddEvent("SET_RUN_NUMBER", "X:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1663        T::AddEvent("SET_RUN_NUMBER", "X:1", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16641664            (bind(&StateMachineFAD::SetRunNumber, this, placeholders::_1))
    16651665            ("Sent a new run-number to the boards"
     
    16711671             "|memory[short]:Buffer size in Mega-bytes.");
    16721672
    1673         T::AddEvent("SET_REGISTER", "I:2", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1673        T::AddEvent("SET_REGISTER", "I:2", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16741674            (bind(&StateMachineFAD::SetRegister, this, placeholders::_1))
    16751675            ("set register to value"
     
    16781678
    16791679        // FIXME:  Maybe add a mask which channels should be set?
    1680         T::AddEvent("SET_REGION_OF_INTEREST", "I:2", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1680        T::AddEvent("SET_REGION_OF_INTEREST", "I:2", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16811681            (bind(&StateMachineFAD::SetRoi, this, placeholders::_1))
    16821682            ("Set region-of-interest to value"
     
    16851685
    16861686        // FIXME:  Maybe add a mask which channels should be set?
    1687         T::AddEvent("SET_DAC_VALUE", "I:2", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1687        T::AddEvent("SET_DAC_VALUE", "I:2", FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    16881688            (bind(&StateMachineFAD::SetDac, this, placeholders::_1))
    16891689            ("Set DAC numbers in range to value"
     
    16911691            "|val[short]:Value to be set");
    16921692
    1693         T::AddEvent("CONFIGURE", "X:2;C", FAD::kConnected, FAD::kConfigured, FAD::kWritingData)
     1693        T::AddEvent("CONFIGURE", "X:2;C", FAD::State::kConnected, FAD::State::kConfigured, FAD::State::kWritingData)
    16941694            (bind(&StateMachineFAD::StartConfigure, this, placeholders::_1))
    16951695            ("Configure a new run. If the internla trigger is enabled this might even start a new run."
     
    16981698             "|run_type[string]:Run type which describes the runs");
    16991699
    1700         T::AddEvent("RESET_CONFIGURE", FAD::kConfiguring1, FAD::kConfiguring2, FAD::kConfigured)
     1700        T::AddEvent("RESET_CONFIGURE", FAD::State::kConfiguring1, FAD::State::kConfiguring2, FAD::State::kConfigured)
    17011701            (bind(&StateMachineFAD::ResetConfig, this))
    17021702            ("If configuration failed and the fadctrl is waiting for something, use this to reset the state.");
     
    17691769             "|enable[bool]:Whether the event builder should ignore data from this slot (yes) or allowed (no)");
    17701770
    1771         T::AddEvent("CLOSE_OPEN_FILES", FAD::kDisconnected, FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1771        T::AddEvent("CLOSE_OPEN_FILES", FAD::State::kDisconnected, FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    17721772            (bind(&StateMachineFAD::CloseOpenFiles, this))
    17731773            ("Close all run files opened by the EventBuilder.");
     
    17801780
    17811781        // Conenction commands
    1782         T::AddEvent("START", FAD::kOffline)
     1782        T::AddEvent("START", FAD::State::kOffline)
    17831783            (bind(&StateMachineFAD::StartConnection, this))
    17841784            ("Start EventBuilder thread and connect all valid slots.");
    17851785
    1786         T::AddEvent("STOP",  FAD::kDisconnected, FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1786        T::AddEvent("STOP",  FAD::State::kDisconnected, FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    17871787            (bind(&StateMachineFAD::StopConnection, this))
    17881788            ("Stop EventBuilder thread (still write buffered events) and disconnect all slots.");
    17891789
    1790         T::AddEvent("ABORT", FAD::kDisconnected, FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
     1790        T::AddEvent("ABORT", FAD::State::kDisconnected, FAD::State::kConnecting, FAD::State::kConnected, FAD::State::kWritingData)
    17911791            (bind(&StateMachineFAD::AbortConnection, this))
    17921792            ("Immediately abort EventBuilder thread and disconnect all slots.");
    17931793
    1794         T::AddEvent("SOFT_RESET", FAD::kConnected, FAD::kWritingData)
     1794        T::AddEvent("SOFT_RESET", FAD::State::kConnected, FAD::State::kWritingData)
    17951795            (bind(&StateMachineFAD::Reset, this, true))
    17961796            ("Wait for buffers to drain, close all files and reinitialize event builder thread.");
    17971797
    1798         T::AddEvent("HARD_RESET", FAD::kConnected, FAD::kWritingData)
     1798        T::AddEvent("HARD_RESET", FAD::State::kConnected, FAD::State::kWritingData)
    17991799            (bind(&StateMachineFAD::Reset, this, false))
    18001800            ("Free all buffers, close all files and reinitialize event builder thread.");
    18011801
    1802         T::AddEvent("CONNECT", "S:1", FAD::kDisconnected, FAD::kConnecting, FAD::kConnected)
     1802        T::AddEvent("CONNECT", "S:1", FAD::State::kDisconnected, FAD::State::kConnecting, FAD::State::kConnected)
    18031803            (bind(&StateMachineFAD::EnableSlot, this, placeholders::_1, true))
    18041804            ("Connect a disconnected slot.");
    18051805
    1806         T::AddEvent("DISCONNECT", "S:1", FAD::kConnecting, FAD::kConnected)
     1806        T::AddEvent("DISCONNECT", "S:1", FAD::State::kConnecting, FAD::State::kConnected)
    18071807            (bind(&StateMachineFAD::EnableSlot, this, placeholders::_1, false))
    18081808            ("Disconnect a connected slot.");
    18091809
    1810         T::AddEvent("TOGGLE", "S:1", FAD::kDisconnected, FAD::kConnecting, FAD::kConnected)
     1810        T::AddEvent("TOGGLE", "S:1", FAD::State::kDisconnected, FAD::State::kConnecting, FAD::State::kConnected)
    18111811            (bind(&StateMachineFAD::ToggleSlot, this, placeholders::_1))
    18121812            ("");
     
    18301830
    18311831
    1832         T::AddEvent("ADD_ADDRESS", "C", FAD::kOffline)
     1832        T::AddEvent("ADD_ADDRESS", "C", FAD::State::kOffline)
    18331833            (bind(&StateMachineFAD::AddAddress, this, placeholders::_1))
    18341834            ("Add the address of a DRS4 board to the first free slot"
    18351835             "|IP[string]:address in the format <address:port>");
    1836         T::AddEvent("REMOVE_SLOT", "S:1", FAD::kOffline)
     1836        T::AddEvent("REMOVE_SLOT", "S:1", FAD::State::kOffline)
    18371837            (bind(&StateMachineFAD::RemoveSlot, this, placeholders::_1))
    18381838            ("Remove the Iaddress in slot n. For a list see LIST"
  • trunk/FACT++/src/ftmctrl.cc

    r13829 r13910  
    2020
    2121using namespace std;
    22 using namespace std::placeholders;
    2322
    2423// ------------------------------------------------------------------------
     
    18881887        fFTM.CmdStopRun();
    18891888
    1890         return FTM::kConfiguring1;
     1889        return FTM::State::kConfiguring1;
    18911890    }
    18921891
     
    19091908        switch (fFTM.GetState())
    19101909        {
    1911         case ConnectionFTM::kDisconnected: return FTM::kDisconnected;
    1912         case ConnectionFTM::kConnected:    return FTM::kConnected;
     1910        case ConnectionFTM::kDisconnected: return FTM::State::kDisconnected;
     1911        case ConnectionFTM::kConnected:    return FTM::State::kConnected;
    19131912        default:
    19141913            break;
     
    19171916        switch (T::GetCurrentState())
    19181917        {
    1919         case FTM::kConfiguring1:
     1918        case FTM::State::kConfiguring1:
    19201919            // If FTM has received an anwer to the stop_run command
    19211920            // the counter for the registers has been increased
     
    19271926            if (fFTM.GetState()!=ConnectionFTM::kIdle &&
    19281927                fFTM.GetState()!=ConnectionFTM::kConfigured)
    1929                 return FTM::kConfigError1;
     1928                return FTM::State::kConfigError1;
    19301929
    19311930            fCounterStat = fFTM.GetCounter(FTM::kStaticData);
     
    19361935
    19371936            // Next state is: wait for the answer to our configuration
    1938             return FTM::kConfiguring2;
    1939 
    1940         case FTM::kConfiguring2:
    1941         case FTM::kConfigured:
     1937            return FTM::State::kConfiguring2;
     1938
     1939        case FTM::State::kConfiguring2:
     1940        case FTM::State::kConfigured:
    19421941            // If FTM has received an anwer to the stop_run command
    19431942            // the counter for the registers has been increased
     
    19491948            // ======================
    19501949            if (fFTM.GetState()!=ConnectionFTM::kConfigured)
    1951                 return FTM::kConfigError2;
     1950                return FTM::State::kConfigError2;
    19521951            // ======================
    19531952
     
    19601959
    19611960            // Next state is: wait for the answer to our configuration
    1962             return FTM::kConfigured;
     1961            return FTM::State::kConfigured;
    19631962
    19641963        default:
    19651964            switch (fFTM.GetState())
    19661965            {
    1967             case ConnectionFTM::kIdle:         return FTM::kIdle;
    1968             case ConnectionFTM::kConfigured:   return FTM::kIdle;
    1969             case ConnectionFTM::kTriggerOn:    return FTM::kTriggerOn;
     1966            case ConnectionFTM::kIdle:         return FTM::State::kIdle;
     1967            case ConnectionFTM::kConfigured:   return FTM::State::kIdle;
     1968            case ConnectionFTM::kTriggerOn:    return FTM::State::kTriggerOn;
    19701969            default:
    19711970                throw runtime_error("StateMachienFTM - Execute() - Inavlid state.");
     
    19731972        }
    19741973
    1975         if (T::GetCurrentState()==FTM::kConfigured &&
     1974        if (T::GetCurrentState()==FTM::State::kConfigured &&
    19761975            fFTM.GetState()==ConnectionFTM::kTriggerOn)
    1977             return FTM::kTriggerOn;
     1976            return FTM::State::kTriggerOn;
    19781977
    19791978        return T::GetCurrentState();
     
    19941993
    19951994        // State names
    1996         T::AddStateName(FTM::kDisconnected, "Disconnected",
     1995        T::AddStateName(FTM::State::kDisconnected, "Disconnected",
    19971996                        "FTM board not connected via ethernet.");
    19981997
    1999         T::AddStateName(FTM::kConnected, "Connected",
     1998        T::AddStateName(FTM::State::kConnected, "Connected",
    20001999                        "Ethernet connection to FTM established (no state received yet).");
    20012000
    2002         T::AddStateName(FTM::kIdle, "Idle",
     2001        T::AddStateName(FTM::State::kIdle, "Idle",
    20032002                        "Ethernet connection to FTM established, FTM in idle state.");
    20042003
    2005         T::AddStateName(FTM::kConfiguring1, "Configuring1",
     2004        T::AddStateName(FTM::State::kConfiguring1, "Configuring1",
    20062005                        "Command to diable run sent... waiting for response.");
    2007         T::AddStateName(FTM::kConfiguring2, "Configuring2",
     2006        T::AddStateName(FTM::State::kConfiguring2, "Configuring2",
    20082007                        "New configuration sent... waiting for response.");
    2009         T::AddStateName(FTM::kConfigured,   "Configured",
     2008        T::AddStateName(FTM::State::kConfigured,   "Configured",
    20102009                        "Received answer identical with target configuration.");
    20112010
    2012         T::AddStateName(FTM::kTriggerOn, "TriggerOn",
     2011        T::AddStateName(FTM::State::kTriggerOn, "TriggerOn",
    20132012                        "Ethernet connection to FTM established, FTM trigger output to FADs enabled.");
    20142013
    2015         T::AddStateName(FTM::kConfigError1, "ErrorInConfig1", "");
    2016         T::AddStateName(FTM::kConfigError2, "ErrorInConfig2", "");
     2014        T::AddStateName(FTM::State::kConfigError1, "ErrorInConfig1", "");
     2015        T::AddStateName(FTM::State::kConfigError2, "ErrorInConfig2", "");
    20172016
    20182017        // FTM Commands
    2019         T::AddEvent("TOGGLE_LED", FTM::kIdle)
     2018        T::AddEvent("TOGGLE_LED", FTM::State::kIdle)
    20202019            (Wrapper(bind(&ConnectionFTM::CmdToggleLed, &fFTM)))
    20212020            ("toggle led");
    20222021
    2023         T::AddEvent("PING", FTM::kIdle)
     2022        T::AddEvent("PING", FTM::State::kIdle)
    20242023            (Wrapper(bind(&ConnectionFTM::CmdPing, &fFTM)))
    20252024            ("send ping");
    20262025
    2027         T::AddEvent("REQUEST_DYNAMIC_DATA", FTM::kIdle)
     2026        T::AddEvent("REQUEST_DYNAMIC_DATA", FTM::State::kIdle)
    20282027            (Wrapper(bind(&ConnectionFTM::CmdReqDynDat, &fFTM)))
    20292028            ("request transmission of dynamic data block");
    20302029
    2031         T::AddEvent("REQUEST_STATIC_DATA", FTM::kIdle)
     2030        T::AddEvent("REQUEST_STATIC_DATA", FTM::State::kIdle)
    20322031            (Wrapper(bind(&ConnectionFTM::CmdReqStatDat, &fFTM)))
    20332032            ("request transmission of static data from FTM to memory");
    20342033
    2035         T::AddEvent("GET_REGISTER", "I", FTM::kIdle)
     2034        T::AddEvent("GET_REGISTER", "I", FTM::State::kIdle)
    20362035            (bind(&StateMachineFTM::GetRegister, this, placeholders::_1))
    20372036            ("read register from address addr"
    20382037            "|addr[short]:Address of register");
    20392038
    2040         T::AddEvent("SET_REGISTER", "I:2", FTM::kIdle)
     2039        T::AddEvent("SET_REGISTER", "I:2", FTM::State::kIdle)
    20412040            (bind(&StateMachineFTM::SetRegister, this, placeholders::_1))
    20422041            ("set register to value"
     
    20442043            "|val[short]:Value to be set");
    20452044
    2046         T::AddEvent("START_TRIGGER", FTM::kIdle, FTM::kConfigured)
     2045        T::AddEvent("START_TRIGGER", FTM::State::kIdle, FTM::State::kConfigured)
    20472046            (Wrapper(bind(&ConnectionFTM::CmdStartRun, &fFTM)))
    20482047            ("start a run (start distributing triggers)");
    20492048
    2050         T::AddEvent("STOP_TRIGGER", FTM::kTriggerOn)
     2049        T::AddEvent("STOP_TRIGGER", FTM::State::kTriggerOn)
    20512050            (Wrapper(bind(&ConnectionFTM::CmdStopRun, &fFTM)))
    20522051            ("stop a run (stop distributing triggers)");
    20532052
    2054         T::AddEvent("TAKE_N_EVENTS", "I", FTM::kIdle)
     2053        T::AddEvent("TAKE_N_EVENTS", "I", FTM::State::kIdle)
    20552054            (bind(&StateMachineFTM::TakeNevents, this, placeholders::_1))
    20562055            ("take n events (distribute n triggers)|number[int]:Number of events to be taken");
    20572056
    2058         T::AddEvent("DISABLE_REPORTS", "B", FTM::kIdle)
     2057        T::AddEvent("DISABLE_REPORTS", "B", FTM::State::kIdle)
    20592058            (bind(&StateMachineFTM::DisableReports, this, placeholders::_1))
    20602059            ("disable sending rate reports"
    20612060             "|status[bool]:disable or enable that the FTM sends rate reports (yes/no)");
    20622061
    2063         T::AddEvent("SET_THRESHOLD", "I:2", FTM::kIdle, FTM::kConfigured, FTM::kTriggerOn)
     2062        T::AddEvent("SET_THRESHOLD", "I:2", FTM::State::kIdle, FTM::State::kConfigured, FTM::State::kTriggerOn)
    20642063            (bind(&StateMachineFTM::SetThreshold, this, placeholders::_1))
    20652064            ("Set the comparator threshold"
     
    20672066             "|Threshold[counts]:Threshold to be set in binary counts");
    20682067
    2069         T::AddEvent("SET_N_OUT_OF_4", "I:2", FTM::kIdle, FTM::kTriggerOn)
     2068        T::AddEvent("SET_N_OUT_OF_4", "I:2", FTM::State::kIdle, FTM::State::kTriggerOn)
    20702069            (bind(&StateMachineFTM::SetNoutof4, this, placeholders::_1))
    20712070            ("Set the comparator threshold"
     
    20732072             "|Threshold[counts]:Threshold to be set in binary counts");
    20742073
    2075         T::AddEvent("SET_PRESCALING", "I:1", FTM::kIdle)
     2074        T::AddEvent("SET_PRESCALING", "I:1", FTM::State::kIdle)
    20762075            (bind(&StateMachineFTM::SetPrescaling, this, placeholders::_1))
    20772076            ("");
    20782077
    2079         T::AddEvent("ENABLE_FTU", "I:1;B:1", FTM::kIdle)
     2078        T::AddEvent("ENABLE_FTU", "I:1;B:1", FTM::State::kIdle)
    20802079            (bind(&StateMachineFTM::EnableFTU, this, placeholders::_1))
    20812080            ("Enable or disable FTU"
     
    20832082             "|Enable[bool]:Whether FTU should be enabled or disabled (yes/no)");
    20842083
    2085         T::AddEvent("DISABLE_PIXEL", "S:1", FTM::kIdle, FTM::kTriggerOn)
     2084        T::AddEvent("DISABLE_PIXEL", "S:1", FTM::State::kIdle, FTM::State::kTriggerOn)
    20862085            (bind(&StateMachineFTM::EnablePixel, this, placeholders::_1, false))
    20872086            ("(-1 or all)");
    20882087
    2089         T::AddEvent("ENABLE_PIXEL", "S:1", FTM::kIdle, FTM::kTriggerOn)
     2088        T::AddEvent("ENABLE_PIXEL", "S:1", FTM::State::kIdle, FTM::State::kTriggerOn)
    20902089            (bind(&StateMachineFTM::EnablePixel, this, placeholders::_1, true))
    20912090            ("(-1 or all)");
    20922091
    2093         T::AddEvent("DISABLE_ALL_PIXELS_EXCEPT", "S:1", FTM::kIdle)
     2092        T::AddEvent("DISABLE_ALL_PIXELS_EXCEPT", "S:1", FTM::State::kIdle)
    20942093            (bind(&StateMachineFTM::DisableAllPixelsExcept, this, placeholders::_1))
    20952094            ("");
    20962095
    2097         T::AddEvent("DISABLE_ALL_PATCHES_EXCEPT", "S:1", FTM::kIdle)
     2096        T::AddEvent("DISABLE_ALL_PATCHES_EXCEPT", "S:1", FTM::State::kIdle)
    20982097            (bind(&StateMachineFTM::DisableAllPatchesExcept, this, placeholders::_1))
    20992098            ("");
    21002099
    2101         T::AddEvent("ENABLE_PATCH", "S:1", FTM::kIdle)
     2100        T::AddEvent("ENABLE_PATCH", "S:1", FTM::State::kIdle)
    21022101            (bind(&StateMachineFTM::EnablePatch, this, placeholders::_1, true))
    21032102            ("");
    21042103
    2105         T::AddEvent("DISABLE_PATCH", "S:1", FTM::kIdle)
     2104        T::AddEvent("DISABLE_PATCH", "S:1", FTM::State::kIdle)
    21062105            (bind(&StateMachineFTM::EnablePatch, this, placeholders::_1, false))
    21072106            ("");
    21082107
    2109         T::AddEvent("TOGGLE_PIXEL", "S:1", FTM::kIdle)
     2108        T::AddEvent("TOGGLE_PIXEL", "S:1", FTM::State::kIdle)
    21102109            (bind(&StateMachineFTM::TogglePixel, this, placeholders::_1))
    21112110            ("");
    21122111
    2113         T::AddEvent("TOGGLE_FTU", "I:1", FTM::kIdle)
     2112        T::AddEvent("TOGGLE_FTU", "I:1", FTM::State::kIdle)
    21142113            (bind(&StateMachineFTM::ToggleFTU, this, placeholders::_1))
    21152114            ("Toggle status of FTU (this is mainly meant to be used in the GUI)"
    21162115             "|Board[idx]:Index of the board (0-39)");
    21172116
    2118         T::AddEvent("SET_TRIGGER_INTERVAL", "I:1", FTM::kIdle)
     2117        T::AddEvent("SET_TRIGGER_INTERVAL", "I:1", FTM::State::kIdle)
    21192118            (bind(&StateMachineFTM::SetTriggerInterval, this, placeholders::_1))
    21202119            ("Sets the trigger interval which is the distance between two consecutive artificial triggers."
    21212120             "|interval[int]:The applied trigger interval is: interval*4ns+8ns");
    21222121
    2123         T::AddEvent("SET_TRIGGER_DELAY", "I:1", FTM::kIdle)
     2122        T::AddEvent("SET_TRIGGER_DELAY", "I:1", FTM::State::kIdle)
    21242123            (bind(&StateMachineFTM::SetTriggerDelay, this, placeholders::_1))
    21252124            (""
    21262125             "|delay[int]:The applied trigger delay is: delay*4ns+8ns");
    21272126
    2128         T::AddEvent("SET_TIME_MARKER_DELAY", "I:1", FTM::kIdle)
     2127        T::AddEvent("SET_TIME_MARKER_DELAY", "I:1", FTM::State::kIdle)
    21292128            (bind(&StateMachineFTM::SetTimeMarkerDelay, this, placeholders::_1))
    21302129            (""
    21312130            "|delay[int]:The applied time marker delay is: delay*4ns+8ns");
    21322131
    2133         T::AddEvent("SET_DEAD_TIME", "I:1", FTM::kIdle)
     2132        T::AddEvent("SET_DEAD_TIME", "I:1", FTM::State::kIdle)
    21342133            (bind(&StateMachineFTM::SetDeadTime, this, placeholders::_1))
    21352134            (""
    21362135            "|dead_time[int]:The applied dead time is: dead_time*4ns+8ns");
    21372136
    2138         T::AddEvent("ENABLE_TRIGGER", "B:1", FTM::kIdle)
     2137        T::AddEvent("ENABLE_TRIGGER", "B:1", FTM::State::kIdle)
    21392138            (bind(&StateMachineFTM::Enable, this, placeholders::_1, FTM::StaticData::kTrigger))
    21402139            ("Switch on the physics trigger"
     
    21422141
    21432142        // FIXME: Switch on/off depending on sequence
    2144         T::AddEvent("ENABLE_EXT1", "B:1", FTM::kIdle)
     2143        T::AddEvent("ENABLE_EXT1", "B:1", FTM::State::kIdle)
    21452144            (bind(&StateMachineFTM::Enable, this, placeholders::_1, FTM::StaticData::kExt1))
    21462145            ("Switch on the triggers through the first external line"
     
    21482147
    21492148        // FIXME: Switch on/off depending on sequence
    2150         T::AddEvent("ENABLE_EXT2", "B:1", FTM::kIdle)
     2149        T::AddEvent("ENABLE_EXT2", "B:1", FTM::State::kIdle)
    21512150            (bind(&StateMachineFTM::Enable, this, placeholders::_1, FTM::StaticData::kExt2))
    21522151            ("Switch on the triggers through the second external line"
    21532152             "|Enable[bool]:Enable ext2 trigger (yes/no)");
    21542153
    2155         T::AddEvent("ENABLE_VETO", "B:1", FTM::kIdle)
     2154        T::AddEvent("ENABLE_VETO", "B:1", FTM::State::kIdle)
    21562155            (bind(&StateMachineFTM::Enable, this, placeholders::_1, FTM::StaticData::kVeto))
    21572156            ("Enable veto line"
    21582157             "|Enable[bool]:Enable veto (yes/no)");
    21592158
    2160         T::AddEvent("ENABLE_CLOCK_CONDITIONER", "B:1", FTM::kIdle)
     2159        T::AddEvent("ENABLE_CLOCK_CONDITIONER", "B:1", FTM::State::kIdle)
    21612160            (bind(&StateMachineFTM::Enable, this, placeholders::_1, FTM::StaticData::kClockConditioner))
    21622161            ("Enable clock conidtioner output in favor of time marker output"
    21632162             "|Enable[bool]:Enable clock conditioner (yes/no)");
    21642163
    2165         T::AddEvent("ENABLE_GROUP1_LPINT", "B:1", FTM::kIdle)
     2164        T::AddEvent("ENABLE_GROUP1_LPINT", "B:1", FTM::State::kIdle)
    21662165            (bind(&StateMachineFTM::EnableLP, this, placeholders::_1, FTM::StaticData::kLPint, FTM::StaticData::kGroup1))
    21672166            ("");
    2168         T::AddEvent("ENABLE_GROUP1_LPEXT", "B:1", FTM::kIdle)
     2167        T::AddEvent("ENABLE_GROUP1_LPEXT", "B:1", FTM::State::kIdle)
    21692168            (bind(&StateMachineFTM::EnableLP, this, placeholders::_1, FTM::StaticData::kLPext, FTM::StaticData::kGroup1))
    21702169            ("");
    2171         T::AddEvent("ENABLE_GROUP2_LPINT", "B:1", FTM::kIdle)
     2170        T::AddEvent("ENABLE_GROUP2_LPINT", "B:1", FTM::State::kIdle)
    21722171            (bind(&StateMachineFTM::EnableLP, this, placeholders::_1, FTM::StaticData::kLPint, FTM::StaticData::kGroup2))
    21732172            ("");
    2174         T::AddEvent("ENABLE_GROUP2_LPEXT", "B:1", FTM::kIdle)
     2173        T::AddEvent("ENABLE_GROUP2_LPEXT", "B:1", FTM::State::kIdle)
    21752174            (bind(&StateMachineFTM::EnableLP, this, placeholders::_1, FTM::StaticData::kLPext, FTM::StaticData::kGroup2))
    21762175            ("");
    2177         T::AddEvent("SET_INTENSITY_LPINT", "S:1", FTM::kIdle)
     2176        T::AddEvent("SET_INTENSITY_LPINT", "S:1", FTM::State::kIdle)
    21782177            (bind(&StateMachineFTM::SetIntensity, this, placeholders::_1, FTM::StaticData::kLPint))
    21792178            ("");
    2180         T::AddEvent("SET_INTENSITY_LPEXT", "S:1", FTM::kIdle)
     2179        T::AddEvent("SET_INTENSITY_LPEXT", "S:1", FTM::State::kIdle)
    21812180            (bind(&StateMachineFTM::SetIntensity, this, placeholders::_1, FTM::StaticData::kLPext))
    21822181            ("");
    21832182
    21842183
    2185         T::AddEvent("SET_TRIGGER_SEQUENCE", "S:3", FTM::kIdle)
     2184        T::AddEvent("SET_TRIGGER_SEQUENCE", "S:3", FTM::State::kIdle)
    21862185            (bind(&StateMachineFTM::SetTriggerSeq, this, placeholders::_1))
    21872186            ("Setup the sequence of artificial triggers produced by the FTM"
     
    21902189             "|LPint[short]:number of triggers of the internal light pulser");
    21912190
    2192         T::AddEvent("SET_TRIGGER_MULTIPLICITY", "S:1", FTM::kIdle)
     2191        T::AddEvent("SET_TRIGGER_MULTIPLICITY", "S:1", FTM::State::kIdle)
    21932192            (bind(&StateMachineFTM::SetTriggerMultiplicity, this, placeholders::_1))
    21942193            ("Setup the Multiplicity condition for physcis triggers"
    21952194             "|N[int]:Number of requirered coincident triggers from sum-patches (1-40)");
    21962195
    2197         T::AddEvent("SET_TRIGGER_WINDOW", "S:1", FTM::kIdle)
     2196        T::AddEvent("SET_TRIGGER_WINDOW", "S:1", FTM::State::kIdle)
    21982197            (bind(&StateMachineFTM::SetTriggerWindow, this, placeholders::_1))
    21992198            ("");
    22002199
    2201         T::AddEvent("SET_CALIBRATION_MULTIPLICITY", "S:1", FTM::kIdle)
     2200        T::AddEvent("SET_CALIBRATION_MULTIPLICITY", "S:1", FTM::State::kIdle)
    22022201            (bind(&StateMachineFTM::SetCalibMultiplicity, this, placeholders::_1))
    22032202            ("Setup the Multiplicity condition for artificial (calibration) triggers"
    22042203             "|N[int]:Number of requirered coincident triggers from sum-patches (1-40)");
    22052204
    2206         T::AddEvent("SET_CALIBRATION_WINDOW", "S:1", FTM::kIdle)
     2205        T::AddEvent("SET_CALIBRATION_WINDOW", "S:1", FTM::State::kIdle)
    22072206            (bind(&StateMachineFTM::SetCalibWindow, this, placeholders::_1))
    22082207            ("");
    22092208
    2210         T::AddEvent("SET_CLOCK_FREQUENCY", "S:1", FTM::kIdle)
     2209        T::AddEvent("SET_CLOCK_FREQUENCY", "S:1", FTM::State::kIdle)
    22112210            (bind(&StateMachineFTM::SetClockFrequency, this, placeholders::_1))
    22122211            ("");
    22132212
    2214         T::AddEvent("SET_CLOCK_REGISTER", "X:8", FTM::kIdle)
     2213        T::AddEvent("SET_CLOCK_REGISTER", "X:8", FTM::State::kIdle)
    22152214            (bind(&StateMachineFTM::SetClockRegister, this, placeholders::_1))
    22162215            ("");
     
    22182217        // A new configure will first stop the FTM this means
    22192218        // we can allow it in idle _and_ taking data
    2220         T::AddEvent("CONFIGURE", "C", FTM::kIdle, FTM::kConfiguring1, FTM::kConfiguring2, FTM::kConfigured, FTM::kTriggerOn)
     2219        T::AddEvent("CONFIGURE", "C", FTM::State::kIdle, FTM::State::kConfiguring1, FTM::State::kConfiguring2, FTM::State::kConfigured, FTM::State::kTriggerOn)
    22212220            (bind(&StateMachineFTM::ConfigureFTM, this, placeholders::_1))
    22222221            ("");
    22232222
    2224         T::AddEvent("RESET_CONFIGURE", FTM::kConfiguring1, FTM::kConfiguring2, FTM::kConfigured, FTM::kConfigError1, FTM::kConfigError2)
     2223        T::AddEvent("RESET_CONFIGURE", FTM::State::kConfiguring1, FTM::State::kConfiguring2, FTM::State::kConfigured, FTM::State::kConfigError1, FTM::State::kConfigError2)
    22252224            (bind(&StateMachineFTM::ResetConfig, this))
    22262225            ("");
     
    22282227
    22292228
    2230         T::AddEvent("RESET_CRATE", "S:1", FTM::kIdle)
     2229        T::AddEvent("RESET_CRATE", "S:1", FTM::State::kIdle)
    22312230            (bind(&StateMachineFTM::ResetCrate, this, placeholders::_1))
    22322231            ("Reset one of the crates 0-3"
    22332232             "|crate[short]:Crate number to be reseted (0-3)");
    22342233
    2235         T::AddEvent("RESET_CAMERA", FTM::kIdle)
     2234        T::AddEvent("RESET_CAMERA", FTM::State::kIdle)
    22362235            (Wrapper(bind(&ConnectionFTM::CmdResetCamera, &fFTM)))
    22372236            ("Reset all crates. The commands are sent in the order 0,1,2,3");
     
    22392238
    22402239        // Load/save static data block
    2241         T::AddEvent("SAVE", "C", FTM::kIdle)
     2240        T::AddEvent("SAVE", "C", FTM::State::kIdle)
    22422241            (bind(&StateMachineFTM::SaveStaticData, this, placeholders::_1))
    22432242            ("Saves the static data (FTM configuration) from memory to a file"
    22442243             "|filename[string]:Filename (can include a path), .bin is automatically added");
    22452244
    2246         T::AddEvent("LOAD", "C", FTM::kIdle)
     2245        T::AddEvent("LOAD", "C", FTM::State::kIdle)
    22472246            (bind(&StateMachineFTM::LoadStaticData, this, placeholders::_1))
    22482247            ("Loads the static data (FTM configuration) from a file into memory and sends it to the FTM"
     
    22692268
    22702269        // Conenction commands
    2271         T::AddEvent("DISCONNECT", FTM::kConnected, FTM::kIdle)
     2270        T::AddEvent("DISCONNECT", FTM::State::kConnected, FTM::State::kIdle)
    22722271            (bind(&StateMachineFTM::Disconnect, this))
    22732272            ("disconnect from ethernet");
    22742273
    2275         T::AddEvent("RECONNECT", "O", FTM::kDisconnected, FTM::kConnected, FTM::kIdle, FTM::kConfigured)
     2274        T::AddEvent("RECONNECT", "O", FTM::State::kDisconnected, FTM::State::kConnected, FTM::State::kIdle, FTM::State::kConfigured)
    22762275            (bind(&StateMachineFTM::Reconnect, this, placeholders::_1))
    22772276            ("(Re)connect ethernet connection to FTM, a new address can be given"
Note: See TracChangeset for help on using the changeset viewer.