Changeset 11953 for trunk/FACT++
- Timestamp:
- 09/02/11 13:54:41 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/biasctrl.cc
r11950 r11953 764 764 return ChannelSetDac(ch, volt*4096/90.); 765 765 } 766 766 /* 767 767 bool GlobalSetDac(uint16_t dac) 768 768 { … … 789 789 return GlobalSetDac(volt*4096/90); 790 790 } 791 792 bool GlobalAddDac(int16_t dac) 793 { 791 */ 792 bool AddDac(const vector<int16_t> &dac) 793 { 794 if (dac.size()!=kNumChannels) 795 { 796 Error("AddDac - Wrong size of array."); 797 return false; 798 } 799 794 800 for (size_t ch=0; ch<kNumChannels; ch++) 795 801 { 796 if (fVoltRef[ch]+dac >kMaxDac)802 if (fVoltRef[ch]+dac[ch]>kMaxDac) 797 803 { 798 Error(" GlobalAddDac - New voltage reference out of range.");804 Error("AddDac - New voltage reference out of range."); 799 805 return false; 800 806 } 801 807 802 if (fVoltRef[ch]+dac <0)808 if (fVoltRef[ch]+dac[ch]<0) 803 809 fVoltRef[ch] = 0; 804 810 else 805 fVoltRef[ch] += dac;811 fVoltRef[ch] += dac[ch]; 806 812 } 807 813 … … 812 818 } 813 819 820 bool AddVolt(const vector<float> &offset) 821 { 822 vector<int16_t> dac(offset.size()); 823 824 for (size_t ch=0; ch<offset.size(); ch++) 825 { 826 if (offset[ch]<-90 || offset[ch]>90) 827 { 828 Error("AddVolt - Offset out of range [-90V,90V]."); 829 return false; 830 } 831 dac[ch] = offset[ch]*4096/90; 832 } 833 834 return AddDac(dac); 835 } 836 837 bool GlobalAddDac(int16_t offset) 838 { 839 return AddDac(vector<int16_t>(kNumChannels, offset)); 840 } 841 814 842 bool GlobalAddVolt(float offset) 815 843 { 816 if (offset<-90 || offset>90) 817 { 818 Error("GlobalAddVolt - Offset out of range [-90V,90V]."); 819 return false; 820 } 821 822 return GlobalAddDac(offset*4096/90); 823 } 844 return AddVolt(vector<float>(kNumChannels, offset)); 845 } 846 847 bool SetDac(const vector<int16_t> &dac) 848 { 849 if (dac.size()!=kNumChannels) 850 { 851 Error("SetDac - Wrong size of array."); 852 return false; 853 } 854 855 for (size_t ch=0; ch<kNumChannels; ch++) 856 { 857 if (!CheckChDac("SetDac", dac[ch])) 858 return false; 859 860 fVoltRef[ch] = dac[ch]; 861 } 862 863 if (!fIsRamping) 864 fIsRamping = RampOneStep(); 865 866 return true; 867 } 868 869 bool SetVolt(const vector<float> &volt) 870 { 871 vector<int16_t> dac(volt.size()); 872 873 for (size_t ch=0; ch<volt.size(); ch++) 874 { 875 if (volt[ch]<0 || volt[ch]>90) 876 { 877 Error("SetVolt - Voltage out of range [0V,90V]."); 878 return false; 879 } 880 dac[ch] = volt[ch]*4096/90; 881 } 882 883 return SetDac(dac); 884 } 885 886 bool GlobalSetDac(int16_t dac) 887 { 888 return SetDac(vector<int16_t>(kNumChannels, dac)); 889 } 890 891 bool GlobalSetVolt(float volt) 892 { 893 return SetVolt(vector<float>(kNumChannels, volt)); 894 } 895 824 896 825 897 // -------------------------------------------------------------------- … … 1337 1409 // -------------------------------------------------------------------- 1338 1410 1411 int AddReferenceDac(const EventImp &evt) 1412 { 1413 if (!CheckEventSize(evt.GetSize(), "AddReferenceDac", 2*kNumChannels)) 1414 return false; 1415 1416 const int16_t *ptr = evt.Ptr<int16_t>(); 1417 fBias.AddDac(vector<int16_t>(ptr, ptr+416)); 1418 1419 return T::GetCurrentState(); 1420 } 1421 1422 int AddReferenceVolt(const EventImp &evt) 1423 { 1424 if (!CheckEventSize(evt.GetSize(), "AddReferenceVolt", 4*kNumChannels)) 1425 return false; 1426 1427 const float_t *ptr = evt.Ptr<float>(); 1428 fBias.AddVolt(vector<float>(ptr, ptr+416)); 1429 1430 return T::GetCurrentState(); 1431 } 1432 1433 int SetReferenceDac(const EventImp &evt) 1434 { 1435 if (!CheckEventSize(evt.GetSize(), "SetReferenceDac", 2*kNumChannels)) 1436 return false; 1437 1438 const int16_t *ptr = evt.Ptr<int16_t>(); 1439 fBias.SetDac(vector<int16_t>(ptr, ptr+416)); 1440 1441 return T::GetCurrentState(); 1442 } 1443 1444 int SetReferenceVolt(const EventImp &evt) 1445 { 1446 if (!CheckEventSize(evt.GetSize(), "SetReferenceVolt", 4*kNumChannels)) 1447 return false; 1448 1449 const float_t *ptr = evt.Ptr<float>(); 1450 fBias.SetVolt(vector<float>(ptr, ptr+416)); 1451 1452 return T::GetCurrentState(); 1453 } 1454 1455 // -------------------------------------------------------------------- 1456 1339 1457 int ExpertSetGlobalVolt(const EventImp &evt) 1340 1458 { … … 1555 1673 (Wrapper(bind(&ConnectionBias::SetZero, &fBias))) 1556 1674 ("Set all channels to a zero reference voltage. Starts ramping if necessary."); 1675 1676 T::AddEvent("SET_REFERENCE_VOLTAGES", "F:416", kConnected, kAtReference, kOverCurrent) 1677 (bind(&StateMachineBias::SetReferenceVolt, this, placeholders::_1)) 1678 (""); 1679 1680 T::AddEvent("SET_REFERENCE_DACS", "S:416", kConnected, kAtReference, kOverCurrent) 1681 (bind(&StateMachineBias::SetReferenceDac, this, placeholders::_1)) 1682 (""); 1683 1684 T::AddEvent("ADD_REFERENCE_VOLTAGES", "F:416", kConnected, kAtReference, kOverCurrent) 1685 (bind(&StateMachineBias::AddReferenceVolt, this, placeholders::_1)) 1686 (""); 1687 1688 T::AddEvent("ADD_REFERENCE_DACS", "S:416", kConnected, kAtReference, kOverCurrent) 1689 (bind(&StateMachineBias::AddReferenceDac, this, placeholders::_1)) 1690 (""); 1691 1557 1692 1558 1693
Note:
See TracChangeset
for help on using the changeset viewer.