- Timestamp:
- 07/08/11 15:53:36 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ftmctrl.cc
r11264 r11297 27 27 class ConnectionFTM : public Connection 28 28 { 29 public: 30 enum States 31 { 32 // State Machine states 33 kDisconnected = 1, 34 kConnected, 35 kIdle, 36 kConfigured, // Returned if idle and fBufStaticData==fStaticData 37 kTakingData, 38 }; 39 40 private: 29 41 vector<uint16_t> fBuffer; 30 42 31 43 bool fHasHeader; 32 intfState;44 FTM::States fState; 33 45 34 46 bool fIsVerbose; … … 62 74 63 75 protected: 64 map<uint16_t, int> fCounter;76 map<uint16_t, uint32_t> fCounter; 65 77 66 78 FTM::Header fHeader; … … 69 81 FTM::DynamicData fDynamicData; 70 82 FTM::Error fError; 83 84 FTM::StaticData fBufStaticData; 71 85 72 86 virtual void UpdateFirstHeader() … … 155 169 } 156 170 157 bool CheckConsistency( )171 bool CheckConsistency(FTM::StaticData &data) 158 172 { 159 173 bool warn1 = false; 160 if ( fStaticData.IsEnabled(FTM::StaticData::kPedestal) != (fStaticData.GetSequencePed() >0) ||161 fStaticData.IsEnabled(FTM::StaticData::kLPint) != (fStaticData.GetSequenceLPint()>0) ||162 fStaticData.IsEnabled(FTM::StaticData::kLPext) != (fStaticData.GetSequenceLPext()>0))174 if (data.IsEnabled(FTM::StaticData::kPedestal) != (data.GetSequencePed() >0) || 175 data.IsEnabled(FTM::StaticData::kLPint) != (data.GetSequenceLPint()>0) || 176 data.IsEnabled(FTM::StaticData::kLPext) != (data.GetSequenceLPext()>0)) 163 177 { 164 178 warn1 = true; 165 fStaticData.Enable(FTM::StaticData::kPedestal, fStaticData.GetSequencePed()>0);166 fStaticData.Enable(FTM::StaticData::kLPint, fStaticData.GetSequenceLPint()>0);167 fStaticData.Enable(FTM::StaticData::kLPext, fStaticData.GetSequenceLPext()>0);179 data.Enable(FTM::StaticData::kPedestal, data.GetSequencePed()>0); 180 data.Enable(FTM::StaticData::kLPint, data.GetSequenceLPint()>0); 181 data.Enable(FTM::StaticData::kLPext, data.GetSequenceLPext()>0); 168 182 } 169 183 170 184 bool warn2 = false; 171 const uint16_t ref = fStaticData[0].fPrescaling;185 const uint16_t ref = data[0].fPrescaling; 172 186 for (int i=1; i<40; i++) 173 187 { 174 if ( fStaticData[i].fPrescaling != ref)188 if (data[i].fPrescaling != ref) 175 189 { 176 190 warn2 = true; 177 fStaticData[i].fPrescaling = ref;191 data[i].fPrescaling = ref; 178 192 } 179 193 } … … 239 253 240 254 // Convert FTM state into FtmCtrl state 241 switch (fHeader.fState)242 {243 case FTM::kFtmIdle:244 case FTM::kFtmConfig:245 fState = FTM::kIdle;246 break;247 248 case FTM::kFtmCalib:249 case FTM::kFtmRunning:250 fState = FTM::kTakingData;251 break;252 }253 254 255 if (++fCounter[FTM::kHeader]==1) 255 256 UpdateFirstHeader(); … … 315 316 316 317 case FTM::kStaticData: 317 fStaticData = fBuffer;318 319 318 if (fCounter[FTM::kStaticData]==1) 320 if (!CheckConsistency()) 319 { 320 // This check is only done at startup 321 FTM::StaticData data = fBuffer; 322 if (!CheckConsistency(data)) 321 323 { 322 CmdSendStatDat( );324 CmdSendStatDat(data); 323 325 break; 324 326 } 325 327 } 328 329 fStaticData = fBuffer; 326 330 UpdateStaticData(); 327 331 break; … … 365 369 fInTimeout.cancel(); 366 370 367 fHeader.clear();371 //fHeader.clear(); 368 372 fHasHeader = false; 369 373 fBuffer.resize(sizeof(FTM::Header)/2); … … 374 378 void ConnectionEstablished() 375 379 { 376 fState = FTM::kConnected;377 380 fCounter.clear(); 381 fBufStaticData.clear(); 378 382 379 383 fHeader.clear(); … … 483 487 public: 484 488 ConnectionFTM(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()), 485 f State(0), fIsVerbose(true), fIsDynamicOut(true), fIsHexOutput(true)489 fIsVerbose(true), fIsDynamicOut(true), fIsHexOutput(true) 486 490 { 487 491 SetLogStream(&imp); … … 508 512 } 509 513 510 void CmdSendStatDat() 511 { 512 PostCmd(fStaticData.HtoN(), FTM::kCmdWrite, FTM::kCmdStaticData); 514 void CmdSendStatDat(const FTM::StaticData &data) 515 { 516 fBufStaticData = data; 517 518 PostCmd(data.HtoN(), FTM::kCmdWrite, FTM::kCmdStaticData); 513 519 514 520 // Request the changed configuration to ensure the … … 549 555 const boost::array<uint16_t, 2> data = {{ addr, val }}; 550 556 PostCmd(data, FTM::kCmdWrite, FTM::kCmdRegister); 557 558 fBufStaticData.clear(); 551 559 552 560 // Request the changed configuration to ensure the … … 614 622 } 615 623 */ 624 616 625 bool LoadStaticData(string name) 617 626 { … … 636 645 return false; 637 646 638 fStaticData = data; 639 640 CmdSendStatDat(); 647 CmdSendStatDat(data); 641 648 642 649 return true; … … 665 672 return false; 666 673 674 FTM::StaticData data = fStaticData; 675 667 676 if (patch<0) 668 677 { 669 678 bool ident = true; 670 679 for (int i=0; i<160; i++) 671 if ( fStaticData[i/4].fDAC[patch%4] != value)680 if (data[i/4].fDAC[patch%4] != value) 672 681 { 673 682 ident = false; … … 679 688 680 689 for (int i=0; i<160; i++) 681 fStaticData[i/4].fDAC[i%4] = value;690 data[i/4].fDAC[i%4] = value; 682 691 } 683 692 else 684 693 { 685 if ( fStaticData[patch/4].fDAC[patch%4] == value)694 if (data[patch/4].fDAC[patch%4] == value) 686 695 return true; 687 696 688 fStaticData[patch/4].fDAC[patch%4] = value;697 data[patch/4].fDAC[patch%4] = value; 689 698 } 690 699 691 700 // Maybe move to a "COMMIT" command? 692 CmdSendStatDat( );701 CmdSendStatDat(data); 693 702 694 703 return true; … … 700 709 return false; 701 710 711 FTM::StaticData data = fStaticData; 712 702 713 bool ident = true; 703 714 for (int i=0; i<40; i++) 704 if ( fStaticData[i].fPrescaling != value)715 if (data[i].fPrescaling != value) 705 716 { 706 717 ident = false; … … 712 723 713 724 for (int i=0; i<40; i++) 714 fStaticData[i].fPrescaling = value;725 data[i].fPrescaling = value; 715 726 716 727 // Maybe move to a "COMMIT" command? 717 CmdSendStatDat( );728 CmdSendStatDat(data); 718 729 719 730 return true; … … 725 736 return false; 726 737 738 FTM::StaticData data = fStaticData; 739 727 740 if (board<0) 728 741 { 729 742 if (enable) 730 fStaticData.EnableAllFTU();743 data.EnableAllFTU(); 731 744 else 732 fStaticData.DisableAllFTU();745 data.DisableAllFTU(); 733 746 } 734 747 else 735 748 { 736 749 if (enable) 737 fStaticData.EnableFTU(board);750 data.EnableFTU(board); 738 751 else 739 fStaticData.DisableFTU(board);752 data.DisableFTU(board); 740 753 741 754 } 742 755 743 756 // Maybe move to a "COMMIT" command? 744 CmdSendStatDat( );757 CmdSendStatDat(data); 745 758 746 759 return true; … … 752 765 return false; 753 766 754 fStaticData.ToggleFTU(board); 767 FTM::StaticData data = fStaticData; 768 769 data.ToggleFTU(board); 755 770 756 771 // Maybe move to a "COMMIT" command? 757 CmdSendStatDat( );772 CmdSendStatDat(data); 758 773 759 774 return true; … … 768 783 return true; 769 784 785 FTM::StaticData data = fStaticData; 786 787 dest = reinterpret_cast<uint16_t*>(&data) + (dest - reinterpret_cast<uint16_t*>(&fStaticData)); 788 770 789 *dest = val; 771 790 772 CmdSendStatDat( );791 CmdSendStatDat(data); 773 792 774 793 return true; … … 801 820 void Enable(FTM::StaticData::GeneralSettings type, bool enable) 802 821 { 803 if (fStaticData.IsEnabled(type)!=enable) 804 { 805 fStaticData.Enable(type, enable); 806 CmdSendStatDat(); 807 } 822 //if (fStaticData.IsEnabled(type)==enable) 823 // return; 824 825 FTM::StaticData data = fStaticData; 826 data.Enable(type, enable); 827 CmdSendStatDat(data); 808 828 } 809 829 810 830 bool SetTriggerSeq(const uint16_t d[3]) 811 831 { 812 const uint16_t oldset = fStaticData.fGeneralSettings;813 const uint16_t oldseq = fStaticData.fTriggerSequence;814 815 832 if (d[0]>FTM::StaticData::kMaxSequence || 816 833 d[1]>FTM::StaticData::kMaxSequence || … … 818 835 return false; 819 836 820 fStaticData.Enable(FTM::StaticData::kPedestal, d[0]>0); 821 fStaticData.Enable(FTM::StaticData::kLPext, d[1]>0); 822 fStaticData.Enable(FTM::StaticData::kLPint, d[2]>0); 823 824 fStaticData.fTriggerSequence = 837 FTM::StaticData data = fStaticData; 838 839 data.Enable(FTM::StaticData::kPedestal, d[0]>0); 840 data.Enable(FTM::StaticData::kLPext, d[1]>0); 841 data.Enable(FTM::StaticData::kLPint, d[2]>0); 842 843 data.fTriggerSequence = 825 844 (uint16_t(d[0])<<10) | (uint16_t(d[2])<<5) | uint16_t(d[1]); 826 845 827 if (oldseq!=fStaticData.fTriggerSequence || oldset!=fStaticData.fGeneralSettings) 828 CmdSendStatDat(); 846 //if (fStaticData.fTriggerSeq !=data.fTriggerSequence || 847 // fStaticData.fGeneralSettings!=data.fGeneralSettings) 848 // CmdSendStatDat(data); 849 850 CmdSendStatDat(data); 829 851 830 852 return true; … … 839 861 return true; 840 862 841 fStaticData.fMultiplicityPhysics = n; 842 843 CmdSendStatDat(); 863 FTM::StaticData data = fStaticData; 864 865 data.fMultiplicityPhysics = n; 866 867 CmdSendStatDat(data); 844 868 845 869 return true; … … 854 878 return true; 855 879 856 fStaticData.fWindowPhysics = win; 857 858 CmdSendStatDat(); 880 FTM::StaticData data = fStaticData; 881 882 data.fWindowPhysics = win; 883 884 CmdSendStatDat(data); 859 885 860 886 return true; … … 869 895 return true; 870 896 871 fStaticData.fMultiplicityCalib = n; 872 873 CmdSendStatDat(); 897 FTM::StaticData data = fStaticData; 898 899 data.fMultiplicityCalib = n; 900 901 CmdSendStatDat(data); 874 902 875 903 return true; … … 884 912 return true; 885 913 886 fStaticData.fWindowCalib = win; 887 888 CmdSendStatDat(); 914 FTM::StaticData data = fStaticData; 915 916 data.fWindowCalib = win; 917 918 CmdSendStatDat(data); 889 919 890 920 return true; … … 893 923 bool SetClockRegister(const uint64_t reg[]) 894 924 { 925 FTM::StaticData data = fStaticData; 926 895 927 for (int i=0; i<8; i++) 896 928 { … … 898 930 return false; 899 931 900 fStaticData.fClockConditioner[i] = reg[i];901 } 902 903 CmdSendStatDat( );932 data.fClockConditioner[i] = reg[i]; 933 } 934 935 CmdSendStatDat(data); 904 936 905 937 return true; … … 911 943 return false; 912 944 945 FTM::StaticData data = fStaticData; 946 913 947 if (idx==-1) 914 948 for (int i=0; i<=FTM::StaticData::kMaxPixelIdx; i++) 915 fStaticData.EnablePixel(i, enable);949 data.EnablePixel(i, enable); 916 950 else 917 fStaticData.EnablePixel(idx, enable);918 919 CmdSendStatDat( );951 data.EnablePixel(idx, enable); 952 953 CmdSendStatDat(data); 920 954 921 955 return true; … … 927 961 return false; 928 962 963 FTM::StaticData data = fStaticData; 964 929 965 for (int i=0; i<=FTM::StaticData::kMaxPixelIdx; i++) 930 fStaticData.EnablePixel(i, i==idx);931 932 CmdSendStatDat( );966 data.EnablePixel(i, i==idx); 967 968 CmdSendStatDat(data); 933 969 934 970 return true; … … 940 976 return false; 941 977 978 FTM::StaticData data = fStaticData; 979 942 980 for (int i=0; i<=FTM::StaticData::kMaxPixelIdx; i++) 943 fStaticData.EnablePixel(i, i/9==idx);944 945 CmdSendStatDat( );981 data.EnablePixel(i, i/9==idx); 982 983 CmdSendStatDat(data); 946 984 947 985 return true; … … 953 991 return false; 954 992 955 fStaticData.EnablePixel(idx, !fStaticData.Enabled(idx)); 956 957 CmdSendStatDat(); 993 FTM::StaticData data = fStaticData; 994 995 data.EnablePixel(idx, !fStaticData.Enabled(idx)); 996 997 CmdSendStatDat(data); 958 998 959 999 return true; 960 1000 } 961 1001 962 int GetState() const { return IsConnected() ? fState : (int)FTM::kDisconnected; } 1002 States GetState() const 1003 { 1004 if (!IsConnected()) 1005 return kDisconnected; 1006 1007 switch (fHeader.fState) 1008 { 1009 case FTM::kFtmUndefined: 1010 return kConnected; 1011 1012 case FTM::kFtmRunning: 1013 case FTM::kFtmCalib: 1014 return kTakingData; 1015 1016 case FTM::kFtmIdle: 1017 case FTM::kFtmConfig: 1018 return fStaticData == fBufStaticData ? kConfigured : kIdle; 1019 } 1020 1021 throw runtime_error("ConnectionFTM::GetState - Impossible code reached."); 1022 } 1023 1024 int GetCounter(FTM::Types type) { return fCounter[type]; } 1025 1026 const FTM::StaticData &GetStaticData() const { return fStaticData; } 963 1027 }; 964 1028 … … 1084 1148 S fFTM; 1085 1149 1086 enum states_t1087 {1088 kStateDisconnected = FTM::kDisconnected,1089 kStateConnected = FTM::kConnected,1090 kStateIdle = FTM::kIdle,1091 kStateTakingData = FTM::kTakingData,1092 1093 kCmdTest1094 };1095 1096 1150 bool CheckEventSize(size_t has, const char *name, size_t size) 1097 1151 { … … 1550 1604 switch (evt.GetTargetState()) 1551 1605 { 1552 case k StateDisconnected:1553 case k StateConnected:1606 case kDisconnected: 1607 case kConnected: 1554 1608 } 1555 1609 1556 1610 return T::kSM_FatalError; 1557 1611 }*/ 1612 1613 int64_t fCounterReg; 1614 int64_t fCounterStat; 1615 1616 typedef map<string, FTM::StaticData> Configs; 1617 Configs fConfigs; 1618 Configs::const_iterator fTargetConfig; 1619 1620 int ConfigureFTM(const EventImp &evt) 1621 { 1622 const string name = evt.GetText(); 1623 1624 fTargetConfig = fConfigs.find(name); 1625 if (fTargetConfig==fConfigs.end()) 1626 { 1627 T::Error("Configuration '"+name+"' not found."); 1628 return T::GetCurrentState(); 1629 } 1630 1631 T::Message("Starting configuration for '"+name+"'"); 1632 1633 fCounterReg = fFTM.GetCounter(FTM::kRegister); 1634 fFTM.CmdStopRun(); 1635 1636 return FTM::kConfiguring1; 1637 } 1638 1639 int ResetConfig(const EventImp &) 1640 { 1641 return fFTM.GetState(); 1642 } 1558 1643 1559 1644 int Execute() … … 1566 1651 poll_one(); 1567 1652 1568 return fFTM.GetState(); 1653 // If FTM is neither in data taking nor idle, 1654 // leave configuration state 1655 switch (fFTM.GetState()) 1656 { 1657 case ConnectionFTM::kDisconnected: return FTM::kDisconnected; 1658 case ConnectionFTM::kConnected: return FTM::kConnected; 1659 case ConnectionFTM::kTakingData: return FTM::kTakingData; 1660 default: 1661 break; 1662 } 1663 1664 switch (T::GetCurrentState()) 1665 { 1666 case FTM::kConfiguring1: 1667 // If FTM has received an anwer to the stop_run command 1668 // the counter for the registers has been increased 1669 if (fFTM.GetCounter(FTM::kRegister)<=fCounterReg) 1670 break; 1671 1672 // If now the state is not idle as expected this means we had 1673 // an error (maybe old events waiting in the queue) 1674 if (fFTM.GetState()!=ConnectionFTM::kIdle && 1675 fFTM.GetState()!=ConnectionFTM::kConfigured) 1676 return FTM::kConfigError1; 1677 1678 fCounterStat = fFTM.GetCounter(FTM::kStaticData); 1679 1680 T::Message("Trigger successfully disabled... sending new configuration."); 1681 1682 fFTM.CmdSendStatDat(fTargetConfig->second); 1683 1684 // Next state is: wait for the answer to our configuration 1685 return FTM::kConfiguring2; 1686 1687 case FTM::kConfiguring2: 1688 case FTM::kConfigured: 1689 // If FTM has received an anwer to the stop_run command 1690 // the counter for the registers has been increased 1691 if (fFTM.GetCounter(FTM::kStaticData)<=fCounterStat) 1692 break; 1693 1694 // If now the configuration is not what we expected 1695 // we had an error (maybe old events waiting in the queue?) 1696 // ====================== 1697 if (fFTM.GetState()!=ConnectionFTM::kConfigured) 1698 return FTM::kConfigError2; 1699 // ====================== 1700 1701 // Check configuration again when a new static data block 1702 // will be received 1703 fCounterStat = fFTM.GetCounter(FTM::kStaticData); 1704 1705 T::Message("Sending new configuration was successfull."); 1706 1707 // Next state is: wait for the answer to our configuration 1708 return FTM::kConfigured; 1709 1710 default: 1711 switch (fFTM.GetState()) 1712 { 1713 case ConnectionFTM::kIdle: return FTM::kIdle; 1714 case ConnectionFTM::kConfigured: return FTM::kIdle; 1715 default: 1716 throw runtime_error("StateMachienFTM - Execute() - Inavlid state."); 1717 } 1718 } 1719 1720 return T::GetCurrentState(); 1569 1721 } 1570 1722 … … 1582 1734 1583 1735 // State names 1584 AddStateName(kStateDisconnected, "Disconnected", 1585 "FTM board not connected via ethernet."); 1586 1587 AddStateName(kStateConnected, "Connected", 1588 "Ethernet connection to FTM established (no state received yet)."); 1589 1590 AddStateName(kStateIdle, "Idle", 1591 "Ethernet connection to FTM established, FTM in idle state."); 1592 1593 AddStateName(kStateTakingData, "TakingData", 1594 "Ethernet connection to FTM established, FTM is in taking data state."); 1736 T::AddStateName(FTM::kDisconnected, "Disconnected", 1737 "FTM board not connected via ethernet."); 1738 1739 T::AddStateName(FTM::kConnected, "Connected", 1740 "Ethernet connection to FTM established (no state received yet)."); 1741 1742 T::AddStateName(FTM::kIdle, "Idle", 1743 "Ethernet connection to FTM established, FTM in idle state."); 1744 1745 T::AddStateName(FTM::kConfiguring1, "Configuring1", 1746 "Command to diable run sent... waiting for response."); 1747 T::AddStateName(FTM::kConfiguring2, "Configuring2", 1748 "New configuration sent... waiting for response."); 1749 T::AddStateName(FTM::kConfigured, "Configured", 1750 "Received answer identical with target configuration."); 1751 1752 T::AddStateName(FTM::kTakingData, "TakingData", 1753 "Ethernet connection to FTM established, FTM is in taking data state."); 1754 1755 T::AddStateName(FTM::kConfigError1, "ErrorInConfig1", ""); 1756 T::AddStateName(FTM::kConfigError2, "ErrorInConfig2", ""); 1595 1757 1596 1758 // FTM Commands 1597 AddEvent("TOGGLE_LED", kStateIdle)1759 T::AddEvent("TOGGLE_LED", FTM::kIdle) 1598 1760 (Wrapper(boost::bind(&ConnectionFTM::CmdToggleLed, &fFTM))) 1599 1761 ("toggle led"); 1600 1762 1601 AddEvent("PING", kStateIdle)1763 T::AddEvent("PING", FTM::kIdle) 1602 1764 (Wrapper(boost::bind(&ConnectionFTM::CmdPing, &fFTM))) 1603 1765 ("send ping"); 1604 1766 1605 AddEvent("REQUEST_DYNAMIC_DATA", kStateIdle)1767 T::AddEvent("REQUEST_DYNAMIC_DATA", FTM::kIdle) 1606 1768 (Wrapper(boost::bind(&ConnectionFTM::CmdReqDynDat, &fFTM))) 1607 1769 ("request transmission of dynamic data block"); 1608 1770 1609 AddEvent("REQUEST_STATIC_DATA", kStateIdle)1771 T::AddEvent("REQUEST_STATIC_DATA", FTM::kIdle) 1610 1772 (Wrapper(boost::bind(&ConnectionFTM::CmdReqStatDat, &fFTM))) 1611 1773 ("request transmission of static data from FTM to memory"); 1612 1774 1613 AddEvent("GET_REGISTER", "I", kStateIdle)1775 T::AddEvent("GET_REGISTER", "I", FTM::kIdle) 1614 1776 (boost::bind(&StateMachineFTM::GetRegister, this, _1)) 1615 1777 ("read register from address addr" 1616 1778 "|addr[short]:Address of register"); 1617 1779 1618 AddEvent("SET_REGISTER", "I:2", kStateIdle)1780 T::AddEvent("SET_REGISTER", "I:2", FTM::kIdle) 1619 1781 (boost::bind(&StateMachineFTM::SetRegister, this, _1)) 1620 1782 ("set register to value" … … 1622 1784 "|val[short]:Value to be set"); 1623 1785 1624 AddEvent("START_RUN", kStateIdle)1786 T::AddEvent("START_RUN", FTM::kIdle, FTM::kConfigured) 1625 1787 (Wrapper(boost::bind(&ConnectionFTM::CmdStartRun, &fFTM))) 1626 1788 ("start a run (start distributing triggers)"); 1627 1789 1628 AddEvent("STOP_RUN", kStateTakingData)1790 T::AddEvent("STOP_RUN", FTM::kTakingData) 1629 1791 (Wrapper(boost::bind(&ConnectionFTM::CmdStopRun, &fFTM))) 1630 1792 ("stop a run (stop distributing triggers)"); 1631 1793 1632 AddEvent("TAKE_N_EVENTS", "I", kStateIdle)1794 T::AddEvent("TAKE_N_EVENTS", "I", FTM::kIdle) 1633 1795 (boost::bind(&StateMachineFTM::TakeNevents, this, _1)) 1634 1796 ("take n events (distribute n triggers)|number[int]:Number of events to be taken"); 1635 1797 1636 AddEvent("DISABLE_REPORTS", "B", kStateIdle)1798 T::AddEvent("DISABLE_REPORTS", "B", FTM::kIdle) 1637 1799 (boost::bind(&StateMachineFTM::DisableReports, this, _1)) 1638 1800 ("disable sending rate reports" 1639 1801 "|status[bool]:disable or enable that the FTM sends rate reports (yes/no)"); 1640 1802 1641 AddEvent("SET_THRESHOLD", "I:2", kStateIdle)1803 T::AddEvent("SET_THRESHOLD", "I:2", FTM::kIdle) 1642 1804 (boost::bind(&StateMachineFTM::SetThreshold, this, _1)) 1643 1805 ("Set the comparator threshold" … … 1645 1807 "|Threshold[counts]:Threshold to be set in binary counts"); 1646 1808 1647 AddEvent("SET_PRESCALING", "I:1", kStateIdle)1809 T::AddEvent("SET_PRESCALING", "I:1", FTM::kIdle) 1648 1810 (boost::bind(&StateMachineFTM::SetPrescaling, this, _1)) 1649 1811 ("" 1650 1812 "|[]:"); 1651 1813 1652 AddEvent("ENABLE_FTU", "I:1;B:1", kStateIdle)1814 T::AddEvent("ENABLE_FTU", "I:1;B:1", FTM::kIdle) 1653 1815 (boost::bind(&StateMachineFTM::EnableFTU, this, _1)) 1654 1816 ("Enable or disable FTU" … … 1656 1818 "|Enable[bool]:Whether FTU should be enabled or disabled (yes/no)"); 1657 1819 1658 AddEvent("DISABLE_PIXEL", "S:1", kStateIdle)1820 T::AddEvent("DISABLE_PIXEL", "S:1", FTM::kIdle) 1659 1821 (boost::bind(&StateMachineFTM::EnablePixel, this, _1, false)) 1660 1822 ("(-1 or all)"); 1661 1823 1662 AddEvent("ENABLE_PIXEL", "S:1", kStateIdle)1824 T::AddEvent("ENABLE_PIXEL", "S:1", FTM::kIdle) 1663 1825 (boost::bind(&StateMachineFTM::EnablePixel, this, _1, true)) 1664 1826 ("(-1 or all)"); 1665 1827 1666 AddEvent("DISABLE_ALL_PIXELS_EXCEPT", "S:1", kStateIdle)1828 T::AddEvent("DISABLE_ALL_PIXELS_EXCEPT", "S:1", FTM::kIdle) 1667 1829 (boost::bind(&StateMachineFTM::DisableAllPixelsExcept, this, _1)) 1668 1830 (""); 1669 1831 1670 AddEvent("DISABLE_ALL_PATCHES_EXCEPT", "S:1", kStateIdle)1832 T::AddEvent("DISABLE_ALL_PATCHES_EXCEPT", "S:1", FTM::kIdle) 1671 1833 (boost::bind(&StateMachineFTM::DisableAllPatchesExcept, this, _1)) 1672 1834 (""); 1673 1835 1674 AddEvent("TOGGLE_PIXEL", "S:1", kStateIdle)1836 T::AddEvent("TOGGLE_PIXEL", "S:1", FTM::kIdle) 1675 1837 (boost::bind(&StateMachineFTM::TogglePixel, this, _1)) 1676 1838 (""); 1677 1839 1678 AddEvent("TOGGLE_FTU", "I:1", kStateIdle)1840 T::AddEvent("TOGGLE_FTU", "I:1", FTM::kIdle) 1679 1841 (boost::bind(&StateMachineFTM::ToggleFTU, this, _1)) 1680 1842 ("Toggle status of FTU (this is mainly meant to be used in the GUI)" 1681 1843 "|Board[idx]:Index of the board (0-39)"); 1682 1844 1683 AddEvent("SET_TRIGGER_INTERVAL", "I:1", kStateIdle)1845 T::AddEvent("SET_TRIGGER_INTERVAL", "I:1", FTM::kIdle) 1684 1846 (boost::bind(&StateMachineFTM::SetTriggerInterval, this, _1)) 1685 1847 ("Sets the trigger interval which is the distance between two consecutive artificial triggers." 1686 1848 "|interval[int]:The applied trigger interval is: interval*4ns+8ns"); 1687 1849 1688 AddEvent("SET_TRIGGER_DELAY", "I:1", kStateIdle)1850 T::AddEvent("SET_TRIGGER_DELAY", "I:1", FTM::kIdle) 1689 1851 (boost::bind(&StateMachineFTM::SetTriggerDelay, this, _1)) 1690 1852 ("" 1691 1853 "|delay[int]:The applied trigger delay is: delay*4ns+8ns"); 1692 1854 1693 AddEvent("SET_TIME_MARKER_DELAY", "I:1", kStateIdle)1855 T::AddEvent("SET_TIME_MARKER_DELAY", "I:1", FTM::kIdle) 1694 1856 (boost::bind(&StateMachineFTM::SetTimeMarkerDelay, this, _1)) 1695 1857 ("" 1696 1858 "|delay[int]:The applied time marker delay is: delay*4ns+8ns"); 1697 1859 1698 AddEvent("SET_DEAD_TIME", "I:1", kStateIdle)1860 T::AddEvent("SET_DEAD_TIME", "I:1", FTM::kIdle) 1699 1861 (boost::bind(&StateMachineFTM::SetDeadTime, this, _1)) 1700 1862 ("" 1701 1863 "|dead_time[int]:The applied dead time is: dead_time*4ns+8ns"); 1702 1864 1703 AddEvent("ENABLE_TRIGGER", "B:1", kStateIdle)1865 T::AddEvent("ENABLE_TRIGGER", "B:1", FTM::kIdle) 1704 1866 (boost::bind(&StateMachineFTM::Enable, this, _1, FTM::StaticData::kTrigger)) 1705 1867 ("Switch on the physics trigger" … … 1707 1869 1708 1870 // FIXME: Switch on/off depending on sequence 1709 AddEvent("ENABLE_EXT1", "B:1", kStateIdle)1871 T::AddEvent("ENABLE_EXT1", "B:1", FTM::kIdle) 1710 1872 (boost::bind(&StateMachineFTM::Enable, this, _1, FTM::StaticData::kExt1)) 1711 1873 ("Switch on the triggers through the first external line" … … 1713 1875 1714 1876 // FIXME: Switch on/off depending on sequence 1715 AddEvent("ENABLE_EXT2", "B:1", kStateIdle)1877 T::AddEvent("ENABLE_EXT2", "B:1", FTM::kIdle) 1716 1878 (boost::bind(&StateMachineFTM::Enable, this, _1, FTM::StaticData::kExt2)) 1717 1879 ("Switch on the triggers through the second external line" 1718 1880 "|Enable[bool]:Enable ext2 trigger (yes/no)"); 1719 1881 1720 AddEvent("ENABLE_VETO", "B:1", kStateIdle)1882 T::AddEvent("ENABLE_VETO", "B:1", FTM::kIdle) 1721 1883 (boost::bind(&StateMachineFTM::Enable, this, _1, FTM::StaticData::kVeto)) 1722 1884 ("Enable veto line" 1723 1885 "|Enable[bool]:Enable veto (yes/no)"); 1724 1886 1725 AddEvent("ENABLE_CLOCK_CONDITIONER", "B:1", kStateIdle)1887 T::AddEvent("ENABLE_CLOCK_CONDITIONER", "B:1", FTM::kIdle) 1726 1888 (boost::bind(&StateMachineFTM::Enable, this, _1, FTM::StaticData::kClockConditioner)) 1727 1889 ("Enable clock conidtioner output in favor of time marker output" 1728 1890 "|Enable[bool]:Enable clock conditioner (yes/no)"); 1729 1891 1730 AddEvent("SET_TRIGGER_SEQUENCE", "S:3", kStateIdle)1892 T::AddEvent("SET_TRIGGER_SEQUENCE", "S:3", FTM::kIdle) 1731 1893 (boost::bind(&StateMachineFTM::SetTriggerSeq, this, _1)) 1732 1894 ("Setup the sequence of artificial triggers produced by the FTM" … … 1735 1897 "|LPint[short]:number of triggers of the internal light pulser"); 1736 1898 1737 AddEvent("SET_TRIGGER_MULTIPLICITY", "S:1", kStateIdle)1899 T::AddEvent("SET_TRIGGER_MULTIPLICITY", "S:1", FTM::kIdle) 1738 1900 (boost::bind(&StateMachineFTM::SetTriggerMultiplicity, this, _1)) 1739 1901 ("Setup the Multiplicity condition for physcis triggers" 1740 1902 "|N[int]:Number of requirered coincident triggers from sum-patches (1-40)"); 1741 1903 1742 AddEvent("SET_TRIGGER_WINDOW", "S:1", kStateIdle)1904 T::AddEvent("SET_TRIGGER_WINDOW", "S:1", FTM::kIdle) 1743 1905 (boost::bind(&StateMachineFTM::SetTriggerWindow, this, _1)) 1744 1906 (""); 1745 1907 1746 AddEvent("SET_CALIBRATION_MULTIPLICITY", "S:1", kStateIdle)1908 T::AddEvent("SET_CALIBRATION_MULTIPLICITY", "S:1", FTM::kIdle) 1747 1909 (boost::bind(&StateMachineFTM::SetCalibMultiplicity, this, _1)) 1748 1910 ("Setup the Multiplicity condition for artificial (calibration) triggers" 1749 1911 "|N[int]:Number of requirered coincident triggers from sum-patches (1-40)"); 1750 1912 1751 AddEvent("SET_CALIBRATION_WINDOW", "S:1", kStateIdle)1913 T::AddEvent("SET_CALIBRATION_WINDOW", "S:1", FTM::kIdle) 1752 1914 (boost::bind(&StateMachineFTM::SetCalibWindow, this, _1)) 1753 1915 (""); 1754 1916 1755 AddEvent("SET_CLOCK_FREQUENCY", "I:1", kStateIdle)1917 T::AddEvent("SET_CLOCK_FREQUENCY", "I:1", FTM::kIdle) 1756 1918 (boost::bind(&StateMachineFTM::SetClockFrequency, this, _1)) 1757 1919 (""); 1758 1920 1759 AddEvent("SET_CLOCK_REGISTER", "X:8", kStateIdle)1921 T::AddEvent("SET_CLOCK_REGISTER", "X:8", FTM::kIdle) 1760 1922 (boost::bind(&StateMachineFTM::SetClockRegister, this, _1)) 1761 1923 (""); 1762 1924 1763 1764 1765 AddEvent("RESET_CRATE", "S:1", kStateIdle) 1925 T::AddEvent("CONFIGURE", "C", FTM::kIdle, FTM::kTakingData) 1926 (boost::bind(&StateMachineFTM::ConfigureFTM, this, _1)) 1927 (""); 1928 1929 T::AddEvent("RESET_CONFIGURE", FTM::kConfiguring1, FTM::kConfiguring2, FTM::kConfigured, FTM::kConfigError1, FTM::kConfigError2) 1930 (boost::bind(&StateMachineFTM::ResetConfig, this, _1)) 1931 (""); 1932 1933 1934 1935 T::AddEvent("RESET_CRATE", "S:1", FTM::kIdle) 1766 1936 (boost::bind(&StateMachineFTM::ResetCrate, this, _1)) 1767 1937 ("Reset one of the crates 0-3" 1768 1938 "|crate[short]:Crate number to be reseted (0-3)"); 1769 1939 1770 AddEvent("RESET_CAMERA", kStateIdle)1940 T::AddEvent("RESET_CAMERA", FTM::kIdle) 1771 1941 (Wrapper(boost::bind(&ConnectionFTM::CmdResetCamera, &fFTM))) 1772 1942 ("Reset all crates. The commands are sent in the order 0,1,2,3"); … … 1774 1944 1775 1945 // Load/save static data block 1776 T::AddEvent("SAVE", "C", kStateIdle)1946 T::AddEvent("SAVE", "C", FTM::kIdle) 1777 1947 (boost::bind(&StateMachineFTM::SaveStaticData, this, _1)) 1778 1948 ("Saves the static data (FTM configuration) from memory to a file" 1779 1949 "|filename[string]:Filename (can include a path), .bin is automatically added"); 1780 1950 1781 T::AddEvent("LOAD", "C", kStateIdle)1951 T::AddEvent("LOAD", "C", FTM::kIdle) 1782 1952 (boost::bind(&StateMachineFTM::LoadStaticData, this, _1)) 1783 1953 ("Loads the static data (FTM configuration) from a file into memory and sends it to the FTM" … … 1804 1974 1805 1975 // Conenction commands 1806 AddEvent("DISCONNECT", kStateConnected, kStateIdle)1976 T::AddEvent("DISCONNECT", FTM::kConnected, FTM::kIdle) 1807 1977 (boost::bind(&StateMachineFTM::Disconnect, this)) 1808 1978 ("disconnect from ethernet"); 1809 1979 1810 AddEvent("RECONNECT", "O", kStateDisconnected, kStateConnected, kStateIdle)1980 T::AddEvent("RECONNECT", "O", FTM::kDisconnected, FTM::kConnected, FTM::kIdle, FTM::kConfigured) 1811 1981 (boost::bind(&StateMachineFTM::Reconnect, this, _1)) 1812 1982 ("(Re)connect ethernet connection to FTM, a new address can be given" … … 1830 2000 1831 2001 // fFTM.SetDefaultSetup(conf.Get<string>("default-setup")); 2002 2003 fConfigs["test"] = FTM::StaticData(); 2004 1832 2005 1833 2006 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.