Changeset 11860 for trunk/FACT++/src
- Timestamp:
- 08/09/11 14:49:58 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/biasctrl.cc
r11858 r11860 425 425 } 426 426 427 bool SetReferenceVoltage(const vector<float> &volt) 428 { 429 if (volt.size()!=kNumChannels) 430 { 431 ostringstream out; 432 out << "SetReferenceVoltage - Given vector has " << volt.size() << " elements - expected " << kNumChannels << endl; 433 Error(out); 434 return false; 435 } 436 437 for (size_t i=0; i<volt.size(); i++) 438 fRefVolt[i] = volt[i]*4096/90; 439 440 return true; 441 } 442 443 void ApplyReferenceVoltage() 444 { 445 for (size_t i=0; i<fRefVolt.size(); i++) 446 SetVoltage(i, fRefVolt[i]); 447 } 448 427 449 void SetVerbose(bool b) 428 450 { … … 696 718 (""); 697 719 720 AddEvent("APPLY_REFERENCE_VOLTAGE", kStateConnected) 721 (Wrapper(bind(&ConnectionBias::ApplyReferenceVoltage, &fBias))) 722 (""); 723 698 724 AddEvent("ADAPT_VOLTAGES", kStateConnected) 699 725 (Wrapper(bind(&ConnectionBias::AdaptVoltages, &fBias))) … … 711 737 fBias.SetEndpoint(conf.Get<string>("dev")); 712 738 T::Message("Setting device to "+fBias.URL()); 739 740 // -------------------------------------------------------------------------- 741 742 ifstream fin("FACTmapV5.txt"); 743 744 int l = 0; 745 746 vector<float> vec(ConnectionBias::kNumChannels); 747 748 string buf; 749 while (getline(fin, buf, '\n')) 750 { 751 if (l>1439) 752 break; 753 754 buf = Tools::Trim(buf); 755 if (buf[0]=='#') 756 continue; 757 758 stringstream str(buf); 759 760 int idummy, board, channel; 761 float fdummy, volt; 762 763 str >> idummy >> idummy >> idummy >> idummy >> idummy; 764 str >> volt; 765 str >> board; 766 str >> channel; 767 str >> fdummy >> fdummy >> fdummy; 768 769 if (channel+32*board>=ConnectionBias::kNumChannels) 770 { 771 T::Error("Invalid board/channel read from FACTmapV5.txt."); 772 return 1; 773 } 774 775 vec[channel+32*board] = volt; 776 l++; 777 } 778 779 if (l!=1440) 780 { 781 T::Error("Reading reference voltages from FACTmapV5.txt failed."); 782 return 2; 783 } 784 785 if (!fBias.SetReferenceVoltage(vec)) 786 { 787 T::Error("Setting reference voltages failed."); 788 return 3; 789 } 790 791 // -------------------------------------------------------------------------- 713 792 714 793 fBias.Connect();
Note:
See TracChangeset
for help on using the changeset viewer.