Changeset 10542 for trunk/FACT++/src/ftmctrl.cc
- Timestamp:
- 05/03/11 18:28:38 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ftmctrl.cc
r10517 r10542 132 132 return; 133 133 134 Out() << endl << k Bold << "Error listreceived:" << endl;134 Out() << endl << kRed << "Error received:" << endl; 135 135 Out() << fError; 136 136 if (fIsHexOutput) … … 557 557 } 558 558 559 bool SetThreshold(int32_t patch, int32_t value) 560 { 561 562 if (patch>159) 563 return false; 564 565 if (value<0 || value>0xffff) 566 return false; 567 568 if (patch<0) 569 { 570 for (int i=0; i<160; i++) 571 fStaticData[i/4].fDAC[i%4] = value; 572 } 573 else 574 fStaticData[patch/4].fDAC[patch%4] = value; 575 576 CmdSendStatDat(); 577 578 return true; 579 } 580 559 581 int GetState() const { return IsConnected() ? fState : (int)FTM::kDisconnected; } 560 582 }; … … 673 695 kStateIdle = FTM::kIdle, 674 696 kStateTakingData = FTM::kTakingData, 675 /* 676 kCmdToggleLed, 677 kCmdPing, 678 kCmdReqDynData, 679 kCmdReqStatData, 680 kCmdReqRegister, 681 kCmdSetRegister, 682 */ 697 683 698 kCmdTest 684 699 }; 685 700 686 int SetRegister(const Event &evt) 687 { 688 if (evt.GetSize()!=8) 689 { 690 stringstream msg; 691 msg << "SetRegister - Received event has " << evt.GetSize() << " bytes, but expected 8."; 692 T::Fatal(msg); 693 701 bool CheckEventSize(size_t has, const char *name, size_t size) 702 { 703 if (has==size) 704 return true; 705 706 stringstream msg; 707 msg << name << " - Received event has " << has << " bytes, but expected " << size << "."; 708 T::Fatal(msg); 709 return false; 710 } 711 712 int SetRegister(const EventImp &evt) 713 { 714 if (!CheckEventSize(evt.GetSize(), "SetRegister", 8)) 694 715 return T::kSM_FatalError; 695 }696 716 697 717 const unsigned int *dat = reinterpret_cast<const unsigned int*>(evt.GetData()); … … 716 736 } 717 737 718 int GetRegister(const Event &evt) 719 { 720 if (evt.GetSize()!=4) 721 { 722 stringstream msg; 723 msg << "GetRegister - Received event has " << evt.GetSize() << "bytes, but expected 2."; 724 T::Fatal(msg); 738 int GetRegister(const EventImp &evt) 739 { 740 if (!CheckEventSize(evt.GetSize(), "GetRegister", 4)) 725 741 return T::kSM_FatalError; 726 }727 742 728 743 const unsigned int addr = evt.GetInt(); … … 737 752 } 738 753 739 int TakeNevents(const Event &evt) 740 { 741 if (evt.GetSize()!=4) 742 { 743 stringstream msg; 744 msg << "TakeNevents - Received event has " << evt.GetSize() << " bytes, but expected 4."; 745 T::Fatal(msg); 746 754 int TakeNevents(const EventImp &evt) 755 { 756 if (!CheckEventSize(evt.GetSize(), "TakeNevents", 4)) 747 757 return T::kSM_FatalError; 748 }749 758 750 759 const unsigned int dat = evt.GetUInt(); … … 764 773 } 765 774 766 int DisableReports(const Event &evt) 767 { 768 if (evt.GetSize()!=1) 769 { 770 stringstream msg; 771 msg << "DisableReports - Received event has " << evt.GetSize() << " bytes, but expected 1."; 772 T::Fatal(msg); 773 775 int DisableReports(const EventImp &evt) 776 { 777 if (!CheckEventSize(evt.GetSize(), "DisableReports", 1)) 774 778 return T::kSM_FatalError; 775 }776 779 777 780 fFTM.CmdDisableReports(evt.GetText()[0]!=0); … … 780 783 } 781 784 782 int SetVerbosity(const Event &evt) 783 { 784 if (evt.GetSize()!=1) 785 { 786 stringstream msg; 787 msg << "SetVerbosity - Received event has " << evt.GetSize() << " bytes, but expected 1."; 788 T::Fatal(msg); 789 785 int SetVerbosity(const EventImp &evt) 786 { 787 if (!CheckEventSize(evt.GetSize(), "SetVerbosity", 1)) 790 788 return T::kSM_FatalError; 791 }792 789 793 790 fFTM.SetVerbose(evt.GetText()[0]!=0); … … 796 793 } 797 794 798 int LoadStaticData(const Event &evt)795 int LoadStaticData(const EventImp &evt) 799 796 { 800 797 if (fFTM.LoadStaticData(evt.GetString())) … … 814 811 } 815 812 816 int SaveStaticData(const Event &evt)813 int SaveStaticData(const EventImp &evt) 817 814 { 818 815 if (fFTM.SaveStaticData(evt.GetString())) … … 828 825 } 829 826 827 int SetThreshold(const EventImp &evt) 828 { 829 if (!CheckEventSize(evt.GetSize(), "SetThreshold", 8)) 830 return T::kSM_FatalError; 831 832 const int32_t *data = reinterpret_cast<const int32_t*>(evt.GetData()); 833 834 if (!fFTM.SetThreshold(data[0], data[1])) 835 T::Warn("SetThreshold - Maximum allowed patch number 159, valid value range 0-0xffff"); 836 837 return T::GetCurrentState(); 838 } 830 839 831 840 int Disconnect() … … 843 852 } 844 853 845 int Reconnect(const Event &evt)854 int Reconnect(const EventImp &evt) 846 855 { 847 856 // Close all connections to supress the warning in SetEndpoint … … 957 966 "|status[bool]:disable or enable that the FTM sends rate reports (yes/no)"); 958 967 968 AddConfiguration("SET_THRESHOLD", "I:2", kStateIdle) 969 (boost::bind(&StateMachineFTM::SetThreshold, this, _1)) 970 ("Set the comparator threshold" 971 "|Patch[idx]:Index of the patch" 972 "|Threshold[counts]:Threshold to be set in binary counts"); 973 959 974 T::AddConfiguration("SET_VERBOSE", "B") 960 975 (boost::bind(&StateMachineFTM::SetVerbosity, this, _1)) … … 990 1005 991 1006 992 // RESET_THRESHOLD val993 // --> SetThreshold(-1, val)994 995 1007 // SET_THRESHOLD idx val 996 // ---> SetThreshold(idx, val) 997 998 999 // ENABLE_FTU idx bool (-1 for all) 1000 // ---> EnableFtu(idx, bool) 1001 1008 // ---> SetThreshold(idx==-1, val) 1009 1010 // ENABLE_FTU idx bool 1011 // ---> EnableFtu(idx==-1, bool) 1002 1012 1003 1013 // ENABLE_TRIGGER bool … … 1012 1022 // ---> SetTriggerSequence(val, val, val) 1013 1023 1014 1015 1024 // SET_TRIGGER_INTERVAL val 1016 1025 // SET_TRIGGER_DELAY val … … 1019 1028 // ---> SetXYZ(val) 1020 1029 1021 1022 1030 // SET_PRESCALING idx val 1023 // ---> SetPrescaling(-1, val) 1024 1025 // RESET_PRESCALING val 1026 // ---> SetPrescaling(idx, val) 1031 // ---> SetPrescaling(idx==-1, val) 1027 1032 } 1028 1033
Note:
See TracChangeset
for help on using the changeset viewer.