Changeset 11031 for trunk/FACT++


Ignore:
Timestamp:
06/16/11 11:09:52 (13 years ago)
Author:
tbretz
Message:
Implemented BLOCK_TRANSMISSION, SEND_CMD and SEND_DATA
File:
1 edited

Legend:

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

    r11014 r11031  
    4646    bool fIsHexOutput;
    4747    bool fIsDataOutput;
     48    bool fBlockTransmission;
    4849
    4950    uint64_t fCounter;
     
    304305    }
    305306
     307public:
    306308    void PostCmd(std::vector<uint16_t> cmd)
    307309    {
     310        if (fBlockTransmission)
     311            return;
     312
    308313#ifdef DEBUG_TX
    309314        ostringstream msg;
     
    320325    void PostCmd(uint16_t cmd)
    321326    {
     327        if (fBlockTransmission)
     328            return;
     329
    322330#ifdef DEBUG_TX
    323331        ostringstream msg;
     
    332340    void PostCmd(uint16_t cmd, uint16_t data)
    333341    {
     342        if (fBlockTransmission)
     343            return;
     344
    334345#ifdef DEBUG_TX
    335346        ostringstream msg;
     
    345356public:
    346357    ConnectionFAD(ba::io_service& ioservice, MessageImp &imp) :
    347     Connection(ioservice, imp()),
    348     fIsVerbose(false), fIsHexOutput(false), fIsDataOutput(false), fCounter(0)
     358        Connection(ioservice, imp()),
     359        fIsVerbose(false), fIsHexOutput(false), fIsDataOutput(false),
     360        fBlockTransmission(false), fCounter(0)
    349361    {
    350362        // Maximum possible needed space:
     
    508520    {
    509521        fIsDataOutput = b;
     522    }
     523
     524    void SetBlockTransmission(bool b)
     525    {
     526        fBlockTransmission = b;
    510527    }
    511528
     
    546563        for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++)
    547564            i->second.second->Cmd(command);
     565
     566        return T::GetCurrentState();
     567    }
     568
     569    int SendCmd(const EventImp &evt)
     570    {
     571        if (!CheckEventSize(evt.GetSize(), "SendCmd", 4))
     572            return T::kSM_FatalError;
     573
     574        if (evt.GetUInt()>0xffff)
     575        {
     576            T::Warn("Command value out of range (0-65535).");
     577            return T::GetCurrentState();
     578        }
     579
     580        for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++)
     581            i->second.second->PostCmd(evt.GetUInt());
     582
     583        return T::GetCurrentState();
     584    }
     585
     586    int SendCmdData(const EventImp &evt)
     587    {
     588        if (!CheckEventSize(evt.GetSize(), "SendCmdData", 8))
     589            return T::kSM_FatalError;
     590
     591        const uint32_t *ptr = evt.Ptr<uint32_t>();
     592
     593        if (ptr[0]>0xffff)
     594        {
     595            T::Warn("Command value out of range (0-65535).");
     596            return T::GetCurrentState();
     597        }
     598
     599        if (ptr[1]>0xffff)
     600        {
     601            T::Warn("Data value out of range (0-65535).");
     602            return T::GetCurrentState();
     603        }
     604
     605        for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++)
     606            i->second.second->PostCmd(ptr[0], ptr[1]);
    548607
    549608        return T::GetCurrentState();
     
    756815       for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++)
    757816            i->second.second->SetDataOutput(evt.GetBool());
     817
     818        return T::GetCurrentState();
     819    }
     820
     821    int SetBlockTransmission(const EventImp &evt)
     822    {
     823        if (!CheckEventSize(evt.GetSize(), "SetBlockTransmission", 5))
     824            return T::kSM_FatalError;
     825
     826        const int32_t slot = evt.Get<int32_t>();
     827
     828        const BoardList::iterator it=fBoards.find(slot);
     829        if (it==fBoards.end())
     830        {
     831            ostringstream str;
     832            str << "Slot " << slot << " not found.";
     833            T::Warn(str);
     834            return T::GetCurrentState();
     835        }
     836
     837        it->second.second->SetBlockTransmission(evt.Get<uint8_t>(4));
    758838
    759839        return T::GetCurrentState();
     
    10541134
    10551135        // FAD Commands
     1136        T::AddEvent("SEND_CMD", "I:1")
     1137            (boost::bind(&StateMachineFAD::SendCmd, this, _1))
     1138            ("Send a command to the FADs. Values between 0 and 65535 are allowed."
     1139             "|command[uint16]:Command to be transmittted.");
     1140        T::AddEvent("SEND_DATA", "I:2")
     1141            (boost::bind(&StateMachineFAD::SendCmdData, this, _1))
     1142            ("Send a command with data to the FADs. Values between 0 and 65535 are allowed."
     1143             "|command[uint16]:Command to be transmittted."
     1144             "|data[uint16]:Data to be sent with the command.");
     1145
    10561146        T::AddEvent("ENABLE_SRCLK", "B:1")
    10571147            (boost::bind(&StateMachineFAD::CmdEnable, this, _1, FAD::kCmdSrclk))
     
    11411231            ("");
    11421232
     1233        T::AddEvent("BLOCK_TRANSMISSION", "I:1;B:1")
     1234            (boost::bind(&StateMachineFAD::SetBlockTransmission, this, _1))
     1235            ("Blocks the transmission of commands to the given slot. Use with care! For debugging pupose only!"
     1236             "|slot[int]:Slot to which the command transmission should be blocked (0-39)"
     1237             "|enable[bool]:Whether the command transmission should be blockes (yes) or allowed (no)");
     1238
    11431239        // Conenction commands
    11441240        /*
Note: See TracChangeset for help on using the changeset viewer.