Changeset 12331


Ignore:
Timestamp:
10/30/11 22:34:20 (13 years ago)
Author:
tbretz
Message:
Added the state kWritingData and avoid that run-numbers can be decreased manually.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/fadctrl.cc

    r12250 r12331  
    760760        {
    761761            ostringstream msg;
    762             msg << hex << "Value " << num << " out of range, max=" << FAD::kMaxRunNumber;
     762            msg << "Run number " << num << " out of range (max=" << FAD::kMaxRunNumber << ")";
    763763            T::Error(msg);
    764764            return false;
    765765        }
    766766
     767        if (num>0 && num<GetRunNumber())
     768        {
     769            ostringstream msg;
     770            msg << "Given run number smaller than next run number which will be opened by the event builder (" << GetRunNumber() << ")";
     771            T::Error(msg);
     772            return false;
     773        }
     774
     775        IncreaseRunNumber(num);
     776 
    767777        for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++)
    768778            i->second->CmdSetRunNumber(num);
     
    14521462            }
    14531463
    1454             return FAD::kConnected;
     1464            return GetNumFilesOpen()>0 ? FAD::kWritingData : FAD::kConnected;
    14551465        }
    14561466
     
    15401550
    15411551        T::AddStateName(FAD::kConfigured, "Configured",
    1542                         "The last header received through the command socket fits the requested configureation and has EventCounter==0.");
     1552                        "The configuration of all boards was successfully cross checked. Waiting for events with a new run number to receive.");
     1553
     1554        T::AddStateName(FAD::kWritingData, "WritingData",
     1555                        "The event builder has an open file (that does not mean that new events are currently received)");
    15431556
    15441557        // FAD Commands
    1545         T::AddEvent("SEND_CMD", "I:1", FAD::kConnecting, FAD::kConnected)
     1558        T::AddEvent("SEND_CMD", "I:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15461559            (bind(&StateMachineFAD::SendCmd, this, placeholders::_1))
    15471560            ("Send a command to the FADs. Values between 0 and 0xffff are allowed."
    15481561             "|command[uint16]:Command to be transmittted.");
    1549         T::AddEvent("SEND_DATA", "I:2", FAD::kConnecting, FAD::kConnected)
     1562        T::AddEvent("SEND_DATA", "I:2", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15501563            (bind(&StateMachineFAD::SendCmdData, this, placeholders::_1))
    15511564            ("Send a command with data to the FADs. Values between 0 and 0xffff are allowed."
     
    15531566             "|data[uint16]:Data to be sent with the command.");
    15541567
    1555         T::AddEvent("ENABLE_SRCLK", "B:1", FAD::kConnecting, FAD::kConnected)
     1568        T::AddEvent("ENABLE_SRCLK", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15561569            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdSrclk))
    15571570            ("Set SRCLK");
    1558         T::AddEvent("ENABLE_BUSY_OFF", "B:1", FAD::kConnecting, FAD::kConnected)
     1571        T::AddEvent("ENABLE_BUSY_OFF", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15591572            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdBusyOff))
    15601573            ("Set BUSY continously low");
    1561         T::AddEvent("ENABLE_BUSY_ON", "B:1", FAD::kConnecting, FAD::kConnected)
     1574        T::AddEvent("ENABLE_BUSY_ON", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15621575            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdBusyOn))
    15631576            ("Set BUSY constantly high (has priority over BUSY_OFF)");
    1564         T::AddEvent("ENABLE_SCLK", "B:1", FAD::kConnecting, FAD::kConnected)
     1577        T::AddEvent("ENABLE_SCLK", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15651578            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdSclk))
    15661579            ("Set SCLK");
    1567         T::AddEvent("ENABLE_DRS", "B:1", FAD::kConnecting, FAD::kConnected)
     1580        T::AddEvent("ENABLE_DRS", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15681581            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdDrsEnable))
    15691582            ("Switch Domino wave");
    1570         T::AddEvent("ENABLE_DWRITE", "B:1", FAD::kConnecting, FAD::kConnected)
     1583        T::AddEvent("ENABLE_DWRITE", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15711584            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdDwrite))
    15721585            ("Set Dwrite (possibly high / always low)");
    1573         T::AddEvent("ENABLE_CONTINOUS_TRIGGER", "B:1", FAD::kConnecting, FAD::kConnected)
     1586        T::AddEvent("ENABLE_CONTINOUS_TRIGGER", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15741587            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdContTrigger))
    15751588            ("Enable continous (internal) trigger.");
    1576         T::AddEvent("ENABLE_TRIGGER_LINE", "B:1", FAD::kConnecting, FAD::kConnected)
     1589        T::AddEvent("ENABLE_TRIGGER_LINE", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15771590            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdTriggerLine))
    15781591            ("Incoming triggers can be accepted/will not be accepted");
    1579         T::AddEvent("ENABLE_COMMAND_SOCKET_MODE", "B:1", FAD::kConnecting, FAD::kConnected)
     1592        T::AddEvent("ENABLE_COMMAND_SOCKET_MODE", "B:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15801593            (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdSocket))
    15811594            ("Set debug mode (yes: dump events through command socket, no=dump events through other sockets)");
    15821595
    1583         T::AddEvent("SET_TRIGGER_RATE", "I:1", FAD::kConnecting, FAD::kConnected)
     1596        T::AddEvent("SET_TRIGGER_RATE", "I:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15841597            (bind(&StateMachineFAD::SetTriggerRate, this, placeholders::_1))
    15851598            ("Enable continous trigger");
     
    15871600            (bind(&StateMachineFAD::Trigger, this, 1))
    15881601            ("Issue software triggers");
    1589         T::AddEvent("SEND_N_TRIGGERS", "I", FAD::kConnecting, FAD::kConnected)
     1602        T::AddEvent("SEND_N_TRIGGERS", "I", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15901603            (bind(&StateMachineFAD::SendTriggers, this, placeholders::_1))
    15911604            ("Issue software triggers");
    1592         T::AddEvent("START_RUN", "", FAD::kConnecting, FAD::kConnected)
     1605        T::AddEvent("START_RUN", "", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15931606            (bind(&StateMachineFAD::StartRun, this, placeholders::_1, true))
    15941607            ("Set FAD DAQ mode. when started, no configurations must be send.");
    1595         T::AddEvent("STOP_RUN", FAD::kConnecting, FAD::kConnected)
     1608        T::AddEvent("STOP_RUN", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15961609            (bind(&StateMachineFAD::StartRun, this, placeholders::_1, false))
    15971610            ("");
    1598         T::AddEvent("PHASE_SHIFT", "S:1", FAD::kConnecting, FAD::kConnected)
     1611        T::AddEvent("PHASE_SHIFT", "S:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    15991612            (bind(&StateMachineFAD::PhaseShift, this, placeholders::_1))
    16001613            ("Adjust ADC phase (in 'steps')");
    16011614
    1602         T::AddEvent("RESET_EVENT_COUNTER", FAD::kConnecting, FAD::kConnected)
     1615        T::AddEvent("RESET_EVENT_COUNTER", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    16031616            (bind(&StateMachineFAD::Cmd, this, FAD::kCmdResetEventCounter))
    16041617            ("");
    16051618
    1606         T::AddEvent("SET_RUN_NUMBER", "X:1", FAD::kConnecting, FAD::kConnected)
     1619        T::AddEvent("SET_RUN_NUMBER", "X:1", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    16071620            (bind(&StateMachineFAD::SetRunNumber, this, placeholders::_1))
    16081621            ("");
     
    16131626             "|memory[short]:Buffer size in Mega-bytes.");
    16141627
    1615         T::AddEvent("SET_REGISTER", "I:2", FAD::kConnecting, FAD::kConnected)
     1628        T::AddEvent("SET_REGISTER", "I:2", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    16161629            (bind(&StateMachineFAD::SetRegister, this, placeholders::_1))
    16171630            ("set register to value"
     
    16201633
    16211634        // FIXME:  Maybe add a mask which channels should be set?
    1622         T::AddEvent("SET_REGION_OF_INTEREST", "I:2", FAD::kConnecting, FAD::kConnected)
     1635        T::AddEvent("SET_REGION_OF_INTEREST", "I:2", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    16231636            (bind(&StateMachineFAD::SetRoi, this, placeholders::_1))
    16241637            ("Set region-of-interest to value"
     
    16271640
    16281641        // FIXME:  Maybe add a mask which channels should be set?
    1629         T::AddEvent("SET_DAC_VALUE", "I:2", FAD::kConnecting, FAD::kConnected)
     1642        T::AddEvent("SET_DAC_VALUE", "I:2", FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    16301643            (bind(&StateMachineFAD::SetDac, this, placeholders::_1))
    16311644            ("Set DAC numbers in range to value"
     
    16331646            "|val[short]:Value to be set");
    16341647
    1635         T::AddEvent("CONFIGURE", "X:2;C", FAD::kConnected, FAD::kConfigured)
     1648        T::AddEvent("CONFIGURE", "X:2;C", FAD::kConnected, FAD::kConfigured, FAD::kWritingData)
    16361649            (bind(&StateMachineFAD::StartConfigure, this, placeholders::_1))
    16371650            ("");
     
    17061719             "|enable[bool]:Whether the event builder should ignore data from this slot (yes) or allowed (no)");
    17071720
    1708         T::AddEvent("CLOSE_OPEN_FILES", FAD::kDisconnected, FAD::kConnecting, FAD::kConnected)
     1721        T::AddEvent("CLOSE_OPEN_FILES", FAD::kDisconnected, FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    17091722            (bind(&StateMachineFAD::CloseOpenFiles, this))
    17101723            ("Close all run files opened by the EventBuilder.");
     
    17211734            ("Start EventBuilder thread and connect all valid slots.");
    17221735
    1723         T::AddEvent("STOP",  FAD::kDisconnected, FAD::kConnecting, FAD::kConnected)
     1736        T::AddEvent("STOP",  FAD::kDisconnected, FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    17241737            (bind(&StateMachineFAD::StopConnection, this))
    17251738            ("Stop EventBuilder thread (still write buffered events) and disconnect all slots.");
    17261739
    1727         T::AddEvent("ABORT", FAD::kDisconnected, FAD::kConnecting, FAD::kConnected)
     1740        T::AddEvent("ABORT", FAD::kDisconnected, FAD::kConnecting, FAD::kConnected, FAD::kWritingData)
    17281741            (bind(&StateMachineFAD::AbortConnection, this))
    17291742            ("Immediately abort EventBuilder thread and disconnect all slots.");
    17301743
    1731         T::AddEvent("SOFT_RESET", FAD::kConnected)
     1744        T::AddEvent("SOFT_RESET", FAD::kConnected, FAD::kWritingData)
    17321745            (bind(&StateMachineFAD::Reset, this, true))
    17331746            ("Wait for buffers to drain, close all files and reinitialize event builder thread.");
    17341747
    1735         T::AddEvent("HARD_RESET", FAD::kConnected)
     1748        T::AddEvent("HARD_RESET", FAD::kConnected, FAD::kWritingData)
    17361749            (bind(&StateMachineFAD::Reset, this, false))
    17371750            ("Free all buffers, close all files and reinitialize event builder thread.");
Note: See TracChangeset for help on using the changeset viewer.