Changeset 10875 for trunk/FACT++/src


Ignore:
Timestamp:
05/27/11 17:19:25 (13 years ago)
Author:
tbretz
Message:
Use EventImp::GetBool; implemented SET_RUN_NUMBER
File:
1 edited

Legend:

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

    r10863 r10875  
    380380    }
    381381
     382    void CmdSetRunNumber(uint32_t num)
     383    {
     384        PostCmd(FAD::kCmdWriteRunNumberLSW, num&0xffff);
     385        PostCmd(FAD::kCmdWriteRunNumberMSW, num>>16);
     386    }
     387
    382388    void CmdSetRegister(uint8_t addr, uint16_t val)
    383389    {
     
    398404    bool CmdSetRoi(int8_t addr, uint16_t val)
    399405    {
    400         if (addr>FAD::kMaxRoiAddr)
    401             return false;
    402 
    403406        if (val>FAD::kMaxRoiValue)
    404407            return false;
    405408
    406409        if (addr<0)
    407             for (int i=0; i<=FAD::kMaxRoiAddr; i++)
     410        {
     411            for (unsigned int i=0; i<=FAD::kMaxRoiAddr; i++)
    408412                PostCmd(FAD::kCmdWriteRoi + i, val);
    409         else
    410             PostCmd(FAD::kCmdWriteRoi + addr, val);
    411 
     413            return true;
     414        }
     415
     416        if (uint8_t(addr)>FAD::kMaxRoiAddr)
     417            return false;
     418
     419        PostCmd(FAD::kCmdWriteRoi + addr, val);
    412420        return true;
    413421    }
     
    732740    }
    733741
     742    int SetRunNumber(const EventImp &evt)
     743    {
     744        if (!CheckEventSize(evt.GetSize(), "SetRunNumber", 8))
     745            return T::kSM_FatalError;
     746
     747        const uint64_t num = evt.Get<uint64_t>();
     748
     749        if (num>FAD::kMaxRunNumber)
     750        {
     751            ostringstream msg;
     752            msg << hex << "Value " << num << " out of range, max=" << FAD::kMaxRunNumber;
     753            T::Error(msg);
     754            return false;
     755        }
     756
     757        for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++)
     758            i->second.second->CmdSetRunNumber(num);
     759
     760        return T::GetCurrentState();
     761    }
     762
    734763    int Test(const EventImp &evt)
    735764    {
     
    750779
    751780        for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++)
    752             i->second.second->SetVerbose(evt.GetText()[0]!=0);
     781            i->second.second->SetVerbose(evt.GetBool());
    753782
    754783        return T::GetCurrentState();
     
    761790
    762791        for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++)
    763             i->second.second->SetHexOutput(evt.GetText()[0]!=0);
     792            i->second.second->SetHexOutput(evt.GetBool());
    764793
    765794        return T::GetCurrentState();
     
    772801
    773802       for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++)
    774             i->second.second->SetDataOutput(evt.GetText()[0]!=0);
     803            i->second.second->SetDataOutput(evt.GetBool());
    775804
    776805        return T::GetCurrentState();
     
    11441173            ("");
    11451174
     1175        T::AddEvent("SET_RUN_NUMBER", "X:1")
     1176            (boost::bind(&StateMachineFAD::SetRunNumber, this, _1))
     1177            ("");
     1178
    11461179        T::AddEvent("SET_REGISTER", "I:2")
    11471180            (boost::bind(&StateMachineFAD::SetRegister, this, _1))
Note: See TracChangeset for help on using the changeset viewer.