Changeset 13236
- Timestamp:
- 03/26/12 22:01:13 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/biasctrl.cc
r13189 r13236 41 41 42 42 bool fIsVerbose; 43 44 vector<uint16_t> fDacCmd; // Current command voltage in DAC units (12bit = 90V) 43 bool fIsDummyMode; 45 44 46 45 vector<bool> fPresent; … … 50 49 51 50 int16_t fGlobalDacCmd; // Command value to be reached 52 // uint16_t fExpertVoltRef; // Command value to be reached53 51 54 52 int16_t fRampStep; … … 65 63 66 64 protected: 67 vector<uint16_t> fDac; // Current voltage in DAC units (12bit = 90V)68 vector<uint16_t> fDacRef; // Current reference voltage in DAC units (12bit = 90V)69 vector<uint16_t> fDacGapd; // Nominal G-APD voltages at 25deg C70 65 71 66 vector<int16_t> fCurrent; // Current in ADC units (12bit = 5mA) 72 67 73 uint16_t fDacMaxAbs;74 uint16_t fDacMaxRel;75 76 68 virtual void UpdateA() 77 69 { … … 86 78 } 87 79 80 // ==================================================== 81 82 vector<float> fBreakdownVoltage; // Breakdown voltage of GAPDs 83 vector<float> fOvervoltage; // Requested overvoltage of GAPDs 84 vector<float> fChannelCalibration; // Bias crate channel offset 85 vector<float> fChannelOffset; // User defined channel offset 86 87 float fVoltageMaxAbs; // Maximum voltage 88 float fVoltageMaxRel; // Maximum voltgage above (what?) 89 90 vector<uint16_t> fDacTarget; // Target values 91 vector<uint16_t> fDacCommand; // Last sent command value 92 vector<uint16_t> fDacActual; // Actual value 93 94 // ==================================================== 95 88 96 private: 89 bool CheckChDac(const string &cmd, uint16_t dac, uint16_t ch=0)90 {91 ostringstream str;92 str << cmd << " - ";93 94 if (ch>=kNumChannels)95 {96 str << "Channel " << ch << " out of range [0,416].";97 Error(str);98 return false;99 }100 101 if (dac>kMaxDac)102 {103 str << "DAC value " << dac << " out of range [0,4095].";104 Error(str);105 return false;106 }107 if (dac>fDacMaxAbs)108 {109 str << "DAC value " << dac << " exceeds allowed absolute maximum of " << fDacMaxAbs;110 Error(str);111 return false;112 }113 if (dac>fDacGapd[ch]+fDacMaxRel)114 {115 str << "DAC value " << dac << " exceeds allowed channel maximum of " << fDacGapd[ch] << " + " << fDacMaxRel;116 Error(str);117 return false;118 }119 120 return true;121 }122 123 97 vector<char> GetCmd(uint16_t board, uint16_t channel, Command_t cmd, uint16_t dac=0) 124 98 { … … 230 204 { 231 205 Message("Reset button on crate pressed!"); 232 SetZero();206 RampAllDacs(0); 233 207 return true; 234 208 } … … 251 225 { 252 226 for (int i=0; i<kNumChannels; i++) 253 fDac [i] = fGlobalDacCmd;227 fDacActual[i] = fGlobalDacCmd; 254 228 255 229 fGlobalDacCmd = -1; … … 293 267 294 268 if (cmd==kCmdChannelSet) 295 fDac [id] = fDacCmd[id];269 fDacActual[id] = fDacCommand[id]; 296 270 297 271 return true; … … 583 557 if (fWrapCounter<0) 584 558 { 585 fDac .assign(kNumChannels, 0);586 fDac Ref.assign(kNumChannels, 0);587 fDac Cmd.assign(kNumChannels, 0);559 fDacTarget.assign(kNumChannels, 0); 560 fDacCommand.assign(kNumChannels, 0); 561 fDacActual.assign(kNumChannels, 0); 588 562 } 589 563 … … 648 622 // -------------------------------------------------------------------- 649 623 624 void PrintLineCmdDac(int b, int ch, const vector<uint16_t> &dac) 625 { 626 Out() << setw(2) << b << "|"; 627 628 for (int c=ch; c<ch+4; c++) 629 { 630 const int id = c+kNumChannelsPerBoard*b; 631 Out() << " " << setw(4) << int32_t(dac[id])<<"/"<<fDacActual[id] << ":" << setw(5) << fDacTarget[id]*90./4096; 632 } 633 Out() << endl; 634 } 635 636 void PrintCommandDac(const vector<uint16_t> &dac) 637 { 638 Out() << dec << setprecision(2) << fixed << setfill(' '); 639 for (int b=0; b<kNumBoards; b++) 640 { 641 if (!fPresent[b]) 642 { 643 Out() << setw(2) << b << "-" << endl; 644 continue; 645 } 646 647 PrintLineCmdDac(b, 0, dac); 648 PrintLineCmdDac(b, 4, dac); 649 PrintLineCmdDac(b, 8, dac); 650 PrintLineCmdDac(b, 12, dac); 651 PrintLineCmdDac(b, 16, dac); 652 PrintLineCmdDac(b, 20, dac); 653 PrintLineCmdDac(b, 24, dac); 654 PrintLineCmdDac(b, 28, dac); 655 } 656 } 657 650 658 void SetAllChannels(const vector<uint16_t> &dac, bool special=false) 651 659 { 660 if (fIsDummyMode) 661 { 662 PrintCommandDac(dac); 663 return; 664 } 665 652 666 vector<char> data; 653 667 data.reserve(kNumChannels*3); … … 659 673 data.insert(data.end(), cmd.begin(), cmd.end()); 660 674 661 fDacC md[ch] = dac[ch];675 fDacCommand[ch] = dac[ch]; 662 676 } 663 677 … … 674 688 uint16_t RampOneStep(uint16_t ch) 675 689 { 676 if (fDac Ref[ch]>fDac[ch])677 return fDac [ch]+fRampStep>fDacRef[ch] ? fDacRef[ch] : fDac[ch]+fRampStep;678 679 if (fDac Ref[ch]<fDac[ch])680 return fDac [ch]-fRampStep<fDacRef[ch] ? fDacRef[ch] : fDac[ch]-fRampStep;681 682 return fDac [ch];690 if (fDacTarget[ch]>fDacActual[ch]) 691 return fDacActual[ch]+fRampStep>fDacTarget[ch] ? fDacTarget[ch] : fDacActual[ch]+fRampStep; 692 693 if (fDacTarget[ch]<fDacActual[ch]) 694 return fDacActual[ch]-fRampStep<fDacTarget[ch] ? fDacTarget[ch] : fDacActual[ch]-fRampStep; 695 696 return fDacActual[ch]; 683 697 } 684 698 … … 702 716 { 703 717 dac[ch] = RampOneStep(ch); 704 if (dac[ch]!=fDac [ch] && fPresent[ch/kNumChannelsPerBoard])718 if (dac[ch]!=fDacActual[ch] && fPresent[ch/kNumChannelsPerBoard]) 705 719 identical = false; 706 720 } … … 785 799 fBufferUpdate(3*kNumChannels), 786 800 fIsVerbose(false), 787 f DacCmd(kNumChannels),801 fIsDummyMode(false), 788 802 fPresent(kNumBoards), 789 803 fWrapCounter(-1), … … 795 809 fWaitingForAnswer(-1), 796 810 fCounter(8), 797 fDac(kNumChannels), 798 fDacRef(kNumChannels), 799 fDacGapd(kNumChannels), 800 fCurrent(kNumChannels) 811 fCurrent(kNumChannels), 812 fBreakdownVoltage(kNumChannels, 0), 813 fOvervoltage(kNumChannels), 814 fChannelCalibration(kNumChannels), 815 fChannelOffset(kNumChannels), 816 fVoltageMaxAbs(75), 817 fVoltageMaxRel(2), 818 fDacTarget(kNumChannels), 819 fDacCommand(kNumChannels), 820 fDacActual(kNumChannels) 801 821 { 802 822 SetLogStream(&imp); 803 823 } 824 825 // -------------------------------------------------------------------- 826 827 bool CheckDac(uint16_t dac) 828 { 829 if (dac<4096) 830 return true; 831 832 ostringstream msg; 833 msg << "CheckDac - Dac value of " << dac << " exceeds maximum of 4095."; 834 Error(msg); 835 return false; 836 } 837 838 bool CheckChannel(uint16_t ch) 839 { 840 if (ch<kNumChannels) 841 return true; 842 843 ostringstream msg; 844 msg << "CheckChannel - Channel " << ch << " out of range [0;" << kNumChannels-1 << "]."; 845 Error(msg); 846 return false; 847 } 848 849 bool CheckChannelVoltage(uint16_t ch, float volt) 850 { 851 if (volt>fVoltageMaxAbs) 852 { 853 ostringstream msg; 854 msg << "CheckChannelVoltage - Set voltage " << volt << "V of channel " << ch << " exeeds absolute limit of " << fVoltageMaxAbs << "V."; 855 Error(msg); 856 return false; 857 } 858 859 if (fBreakdownVoltage[ch]<=0) 860 return true; 861 862 if (volt>fBreakdownVoltage[ch]+fVoltageMaxRel) 863 { 864 ostringstream msg; 865 msg << "CheckChannelVoltage - Set voltage " << volt << "V of channel " << ch << " exeeds limit of " << fVoltageMaxRel << "V above breakdown voltage " << fBreakdownVoltage[ch] << "V + limit " << fVoltageMaxRel << "V."; 866 Error(msg); 867 return false; 868 } 869 870 return true; 871 } 872 873 // -------------------------------------------------------------------- 874 875 bool RampSingleChannelDac(uint16_t ch, uint16_t dac) 876 { 877 if (!CheckChannel(ch)) 878 return false; 879 880 if (!CheckDac(dac)) 881 return false; 882 883 fDacTarget[ch] = dac; 884 UpdateV(); 885 886 if (!fIsRamping) 887 fIsRamping = RampOneStep(); 888 889 return true; 890 } 891 892 bool RampAllChannelsDac(const vector<uint16_t> &dac) 893 { 894 for (int ch=0; ch<kNumChannels; ch++) 895 if (!CheckDac(dac[ch])) 896 return false; 897 898 fDacTarget = dac; 899 UpdateV(); 900 901 if (!fIsRamping) 902 fIsRamping = RampOneStep(); 903 904 return true; 905 } 906 907 bool RampAllDacs(uint16_t dac) 908 { 909 return RampAllChannelsDac(vector<uint16_t>(kNumChannels, dac)); 910 } 911 912 // -------------------------------------------------------------------- 913 914 uint16_t ConvertVoltToDac(uint16_t ch, double volt) 915 { 916 volt += fChannelCalibration[ch]; 917 if (volt<0) 918 volt = 0; 919 920 return volt*4096/90; 921 } 922 923 // -------------------------------------------------------------------- 924 925 bool RampSingleChannelVoltage(uint16_t ch, float volt) 926 { 927 if (!CheckChannel(ch)) 928 return false; 929 930 if (!CheckChannelVoltage(ch, volt)) 931 return false; 932 933 const uint16_t dac = ConvertVoltToDac(ch, volt); 934 return RampSingleChannelDac(ch, dac); 935 } 936 937 bool RampAllChannelsVoltage(const vector<float> &volt) 938 { 939 vector<uint16_t> dac(kNumChannels); 940 for (size_t ch=0; ch<kNumChannels; ch++) 941 { 942 if (!CheckChannelVoltage(ch, volt[ch])) 943 return false; 944 945 dac[ch] = ConvertVoltToDac(ch, volt[ch]); 946 } 947 948 return RampAllChannelsDac(dac); 949 } 950 951 bool RampAllVoltages(float volt) 952 { 953 return RampAllChannelsVoltage(vector<float>(kNumChannels, volt)); 954 } 955 956 // -------------------------------------------------------------------- 957 958 bool RampSingleChannelOffset(uint16_t ch, float offset, bool relative) 959 { 960 if (!CheckChannel(ch)) 961 return false; 962 963 if (relative) 964 offset += fDacActual[ch]*90./4096 - fBreakdownVoltage[ch] - fOvervoltage[ch]; 965 966 const float volt = fBreakdownVoltage[ch]>0 ? fBreakdownVoltage[ch] + fOvervoltage[ch] + offset : 0; 967 968 if (!RampSingleChannelVoltage(ch, volt)) 969 return false; 970 971 fChannelOffset[ch] = offset; 972 973 return true; 974 } 975 976 bool RampAllChannelsOffset(vector<float> offset, bool relative) 977 { 978 vector<float> volt(kNumChannels); 979 980 if (relative) 981 for (size_t ch=0; ch<kNumChannels; ch++) 982 offset[ch] += fDacActual[ch]*90./4096 - fBreakdownVoltage[ch] - fOvervoltage[ch]; 983 984 for (size_t ch=0; ch<kNumChannels; ch++) 985 volt[ch] = fBreakdownVoltage[ch]>0 ? fBreakdownVoltage[ch] + fOvervoltage[ch] + offset[ch] : 0; 986 987 if (!RampAllChannelsVoltage(volt)) 988 return false; 989 990 fChannelOffset = offset; 991 992 return true; 993 } 994 995 bool RampAllOffsets(float offset, bool relative) 996 { 997 return RampAllChannelsOffset(vector<float>(kNumChannels, offset), relative); 998 } 999 1000 /* 1001 bool RampSingleChannelOvervoltage(float offset) 1002 { 1003 return RampAllChannelsOvervoltage(vector<float>(kNumChannels, offset)); 1004 } 1005 bool RampAllOvervoltages(const vector<float> &overvoltage) 1006 { 1007 vector<float> volt(kNumChannels); 1008 1009 for (size_t ch=0; ch<kNumChannels; ch++) 1010 volt[ch] = fBreakdownVoltage[ch] + fOvervoltage[ch] + fChannelOffset[ch]; 1011 1012 #warning What about empty channels? 1013 1014 if (!RampAllChannelsVoltage(volt)) 1015 return false; 1016 1017 for (size_t ch=0; ch<kNumChannels; ch++) 1018 fOvervoltage[ch] = overvoltage[ch]; 1019 1020 return true; 1021 }*/ 1022 1023 // -------------------------------------------------------------------- 804 1024 805 1025 void OverCurrentReset() … … 819 1039 } 820 1040 821 vector<uint16_t> dac( kNumChannels);1041 vector<uint16_t> dac(fDacActual); 822 1042 823 1043 for (int ch=0; ch<kNumChannels; ch++) 824 dac[ch] = fCurrent[ch]<0 ? 0 : fDac[ch]; 1044 if (fCurrent[ch]<0) 1045 dac[ch] = 0; 825 1046 826 1047 SetAllChannels(dac, true); … … 856 1077 } 857 1078 858 // -------------------------------------------------------------------- 859 860 bool ChannelSetDac(uint16_t ch, uint16_t dac) 861 { 862 if (!CheckChDac("ChannelSetDac", dac, ch)) 863 return false; 864 865 fDacRef[ch] = dac; 866 867 if (!fIsRamping) 868 fIsRamping = RampOneStep(); 869 870 return true; 871 } 872 873 bool ChannelSetVolt(uint16_t ch, double volt) 874 { 875 if (volt<0 || volt>90) 876 { 877 ostringstream msg; 878 msg << "ChannelSetVolt - Given voltage " << volt << "V out of range [0V,90V]."; 879 Error(msg); 880 return false; 881 } 882 883 return ChannelSetDac(ch, volt*4096/90.); 884 } 885 /* 886 bool GlobalSetDac(uint16_t dac) 887 { 888 if (!CheckChDac("GlobalSetDac", dac)) 889 return false; 890 891 for (size_t ch=0; ch<kNumChannels; ch++) 892 fVoltRef[ch] = dac; 893 894 if (!fIsRamping) 895 fIsRamping = RampOneStep(); 896 897 return true; 898 } 899 900 bool GlobalSetVolt(float volt) 901 { 902 if (volt<0 || volt>90) 903 { 904 Error("GlobalSetVolt - Voltage out of range [0V,90V]."); 905 return false; 906 } 907 908 return GlobalSetDac(volt*4096/90); 909 } 910 */ 911 bool AddDac(const vector<int16_t> &dac) 912 { 913 if (dac.size()!=kNumChannels) 914 { 915 Error("AddDac - Wrong size of array."); 916 return false; 917 } 918 919 for (size_t ch=0; ch<kNumChannels; ch++) 920 { 921 if (fDacRef[ch]+dac[ch]>kMaxDac) 922 { 923 ostringstream msg; 924 msg << "AddDac - New voltage reference " << fDacRef[ch] << "+" << dac[ch] << " out of range [0," << kMaxDac << " for channel " << ch << "."; 925 Error(msg); 926 return false; 927 } 928 929 if (fDacRef[ch]+dac[ch]<0) 930 fDacRef[ch] = 0; 931 else 932 fDacRef[ch] += dac[ch]; 933 } 934 935 if (!fIsRamping) 936 fIsRamping = RampOneStep(); 937 938 return true; 939 } 940 941 bool AddVolt(const vector<float> &offset) 942 { 943 vector<int16_t> dac(offset.size()); 944 945 for (size_t ch=0; ch<offset.size(); ch++) 946 { 947 if (offset[ch]<-90 || offset[ch]>90) 948 { 949 ostringstream msg; 950 msg << "AddVolt - Offset voltage " << offset[ch] << "V for channel " << ch << " out of range [-90V,90V]."; 951 Error(msg); 952 return false; 953 } 954 dac[ch] = offset[ch]*4096/90; 955 } 956 957 return AddDac(dac); 958 } 959 960 bool GlobalAddDac(int16_t offset) 961 { 962 return AddDac(vector<int16_t>(kNumChannels, offset)); 963 } 964 965 bool GlobalAddVolt(float offset) 966 { 967 return AddVolt(vector<float>(kNumChannels, offset)); 968 } 969 970 bool SetDac(const vector<int16_t> &dac) 971 { 972 if (dac.size()!=kNumChannels) 973 { 974 Error("SetDac - Wrong size of array."); 975 return false; 976 } 977 978 for (size_t ch=0; ch<kNumChannels; ch++) 979 { 980 if (!CheckChDac("SetDac", dac[ch])) 981 return false; 982 983 fDacRef[ch] = dac[ch]; 984 } 985 986 if (!fIsRamping) 987 fIsRamping = RampOneStep(); 988 989 return true; 990 } 991 992 bool SetVolt(const vector<float> &volt) 993 { 994 vector<int16_t> dac(volt.size()); 995 996 for (size_t ch=0; ch<volt.size(); ch++) 997 { 998 if (volt[ch]<0 || volt[ch]>90) 999 { 1000 ostringstream msg; 1001 msg << "SetVolt - Voltage " << volt[ch] << "V out of range [0V,90V] for channel " << ch << "."; 1002 Error(msg); 1003 return false; 1004 } 1005 dac[ch] = volt[ch]*4096/90; 1006 } 1007 1008 return SetDac(dac); 1009 } 1010 1011 bool GlobalSetDac(int16_t dac) 1012 { 1013 return SetDac(vector<int16_t>(kNumChannels, dac)); 1014 } 1015 1016 bool GlobalSetVolt(float volt) 1017 { 1018 return SetVolt(vector<float>(kNumChannels, volt)); 1019 } 1020 1021 1022 // -------------------------------------------------------------------- 1023 1024 bool SetGapdVoltage(float offset) 1025 { 1026 if (offset<-90 || offset>90) 1027 { 1028 ostringstream msg; 1029 msg << "SetGapdVoltage - Offset voltage " << offset << "V out of range [-90V,90V]."; 1030 Error(msg); 1031 return false; 1032 } 1033 1034 const int16_t dac = offset*4096/90; 1035 1036 for (size_t ch=0; ch<kNumChannels; ch++) 1037 if (fDacGapd[ch]+dac>kMaxDac) 1038 { 1039 ostringstream msg; 1040 msg << "SetGapdVoltage - New voltage reference " << fDacGapd[ch] << "+" << dac << " out of range [0," << kMaxDac << " for channel " << ch << "."; 1041 Error(msg); 1042 return false; 1043 } 1044 1045 for (size_t ch=0; ch<kNumChannels; ch++) 1046 fDacRef[ch] = fDacGapd[ch]+dac<0 ? 0 : fDacGapd[ch]+dac; 1047 1048 if (!fIsRamping) 1049 fIsRamping = RampOneStep(); 1050 1051 return true; 1052 } 1053 1054 bool SetGapdVoltages(const vector<float> &offset) 1055 { 1056 vector<int16_t> dac(kNumChannels); 1057 for (size_t ch=0; ch<kNumChannels; ch++) 1058 { 1059 if (offset[ch]<-90 || offset[ch]>90) 1060 { 1061 ostringstream msg; 1062 msg << "SetGapdVoltage - Offset voltage " << offset[ch] << "V of channel " << ch << " out of range [-90V,90V]."; 1063 Error(msg); 1064 return false; 1065 } 1066 1067 dac[ch] = offset[ch]*4096/90; 1068 1069 if (fDacGapd[ch]+dac[ch]>kMaxDac) 1070 { 1071 ostringstream msg; 1072 msg << "SetGapdVoltage - New voltage reference " << fDacGapd[ch] << "+" << dac[ch] << " out of range [0," << kMaxDac << " for channel " << ch << "."; 1073 Error(msg); 1074 return false; 1075 } 1076 } 1077 1078 for (size_t ch=0; ch<kNumChannels; ch++) 1079 fDacRef[ch] = fDacGapd[ch]+dac[ch]<0 ? 0 : fDacGapd[ch]+dac[ch]; 1080 1081 if (!fIsRamping) 1082 fIsRamping = RampOneStep(); 1083 1084 return true; 1085 } 1086 1087 bool SetGapdReferenceCh(uint16_t ch) 1088 { 1089 if (!CheckChDac("SetGapdReferenceCh", fDacGapd[ch], ch)) 1090 return false; 1091 1092 fDacRef[ch] = fDacGapd[ch]; 1093 1094 if (!fIsRamping) 1095 fIsRamping = RampOneStep(); 1096 1097 return true; 1098 } 1099 1100 1101 void SetZero() 1102 { 1103 for (size_t ch=0; ch<kNumChannels; ch++) 1104 fDacRef[ch] = 0; 1105 1106 if (!fIsRamping) 1107 fIsRamping = RampOneStep(); 1108 } 1109 1110 bool SetNewGapdVoltage(const vector<float> &volt) 1079 bool SetReferences(const vector<float> &volt, const vector<float> &offset) 1111 1080 { 1112 1081 if (volt.size()!=kNumChannels) 1113 1082 { 1114 1083 ostringstream out; 1115 out << "Set NewGapdVoltage- Given vector has " << volt.size() << " elements - expected " << kNumChannels << endl;1084 out << "SetReferences - Given vector has " << volt.size() << " elements - expected " << kNumChannels << endl; 1116 1085 Error(out); 1117 1086 return false; 1118 1087 } 1119 1120 for (size_t i=0; i<kNumChannels; i++) 1121 fDacGapd[i] = volt[i]*4096/90; 1088 if (offset.size()!=kNumChannels) 1089 { 1090 ostringstream out; 1091 out << "SetReferences - Given vector has " << volt.size() << " elements - expected " << kNumChannels << endl; 1092 Error(out); 1093 return false; 1094 } 1095 1096 fBreakdownVoltage = volt; 1097 fChannelCalibration = offset; 1098 fOvervoltage.assign(kNumChannels, 0); 1122 1099 1123 1100 UpdateVgapd(); … … 1195 1172 } 1196 1173 1197 if (!Check ChDac("ExpertChannelSetDac", dac, ch))1198 return false; 1199 1200 fDacC md[ch] = dac;1174 if (!CheckDac(dac)) 1175 return false; 1176 1177 fDacCommand[ch] = dac; 1201 1178 1202 1179 ostringstream msg; … … 1227 1204 } 1228 1205 1229 if (!Check ChDac("ExpertGlobalSetDac",dac))1206 if (!CheckDac(dac)) 1230 1207 return false; 1231 1208 … … 1259 1236 { 1260 1237 fIsVerbose = b; 1238 } 1239 1240 void SetDummyMode(bool b) 1241 { 1242 fIsDummyMode = b; 1261 1243 } 1262 1244 … … 1319 1301 const int id = c+kNumChannelsPerBoard*b; 1320 1302 Out() << " "; 1321 Out() << (fDac [id]==fDacRef[id]?kGreen:kRed);1322 Out() << setw(5) << fDac [id]*90/4096. << '/';1323 Out() << setw(5) << fDac Ref[id]*90/4096.;1303 Out() << (fDacActual[id]==fDacTarget[id]?kGreen:kRed); 1304 Out() << setw(5) << fDacActual[id]*90/4096. << '/'; 1305 Out() << setw(5) << fDacTarget[id]*90/4096.; 1324 1306 } 1325 1307 Out() << endl; … … 1355 1337 { 1356 1338 const int id = c+kNumChannelsPerBoard*b; 1357 Out() << " " << setw(5) << f DacGapd[id]*90/4096.;1339 Out() << " " << setw(5) << fBreakdownVoltage[id]+fOvervoltage[id]; 1358 1340 } 1359 1341 Out() << endl; 1360 1342 } 1361 1343 1362 void Print Gapd()1344 void PrintReferenceVoltage() 1363 1345 { 1364 1346 Out() << dec << setprecision(2) << fixed << setfill(' '); … … 1400 1382 void SetVoltMaxAbs(float max) 1401 1383 { 1402 fDacMaxAbs = max*4096/90; 1403 if (fDacMaxAbs>4095) 1404 fDacMaxAbs = 4095; 1384 if (max>90) 1385 max = 90; 1405 1386 if (max<0) 1406 fDacMaxAbs = 0; 1387 max = 0; 1388 1389 fVoltageMaxAbs = max; 1407 1390 } 1408 1391 1409 1392 void SetVoltMaxRel(float max) 1410 1393 { 1411 fDacMaxRel = max*4096/90; 1412 if (fDacMaxRel>4095) 1413 fDacMaxRel = 4095; 1394 if (max>90) 1395 max = 90; 1414 1396 if (max<0) 1415 fDacMaxRel = 0; 1397 max = 0; 1398 1399 fVoltageMaxRel = max; 1416 1400 } 1417 1401 1418 1402 uint16_t GetVoltMaxAbs() const 1419 1403 { 1420 return f DacMaxAbs * 90./4096;1404 return fVoltageMaxAbs; 1421 1405 } 1422 1406 1423 1407 uint16_t GetVoltMaxRel() const 1424 1408 { 1425 return fDacMaxRel * 90./4096; 1426 } 1427 1428 /* 1429 void AdaptVoltages() 1430 { 1431 // Correct voltages according to current 1432 for (int i=0; i<kNumChannels; i++) 1433 { 1434 if (fVoltRef[i]==0 || fCurrent[i]<0 || fRefCurrent[i]<0) 1435 continue; 1436 1437 // Calculate difference and convert ADC units to Amp 1438 // const double diffcur = (fRefCurrent[i]-fCurrent[i])*5000/4096 1439 //const int32_t diffcur = int32_t(fRefCurrent[i]-fCurrent[i])*5000; 1440 1441 // Calculate voltage difference 1442 // #define RESISTOR 1000 // Ohm 1443 //const double diffvolt = diffcur*RESISTOR/1e6; 1444 1445 // Calculate new vlaue by onverting voltage difference to DAC units 1446 //const int32_t dac = fRefVolt[i] + diffvolt*4096/90.0; 1447 SetVoltage(i, fRefVolt[i] + (fRefCurrent[i]-fCurrent[i])/18); 1448 } 1449 } 1450 1451 void SetReferenceCurrent() 1452 { 1453 fRefCurrent = fCurrent; 1454 } 1455 */ 1409 return fVoltageMaxRel; 1410 } 1456 1411 1457 1412 States_t GetStatus() … … 1475 1430 bool isoff = true; 1476 1431 for (int ch=0; ch<kNumChannels; ch++) 1477 if (fPresent[ch/kNumChannelsPerBoard] && fDac [ch]!=0)1432 if (fPresent[ch/kNumChannelsPerBoard] && fDacActual[ch]!=0) 1478 1433 isoff = false; 1479 1434 if (isoff) … … 1481 1436 1482 1437 for (int ch=0; ch<kNumChannels; ch++) 1483 if (fPresent[ch/kNumChannelsPerBoard] && fDac [ch]!=fDacRef[ch])1438 if (fPresent[ch/kNumChannelsPerBoard] && fDacActual[ch]!=fDacTarget[ch]) 1484 1439 return BIAS::kNotReferenced; 1485 1440 … … 1497 1452 1498 1453 DimDescribedService fDimCurrent; 1499 DimDescribedService fDimVoltage; 1454 DimDescribedService fDimDac; 1455 DimDescribedService fDimVolt; 1500 1456 DimDescribedService fDimGapd; 1501 1457 … … 1507 1463 void UpdateV() 1508 1464 { 1509 vector<uint16_t> vec; 1510 vec.insert(vec.end(), fDac.begin(), fDac.end()); 1511 vec.insert(vec.end(), fDacRef.begin(), fDacRef.end()); 1512 fDimVoltage.Update(vec); 1465 vector<uint16_t> val(2*kNumChannels); 1466 memcpy(val.data(), fDacActual.data(), kNumChannels*2); 1467 memcpy(val.data()+kNumChannels, fDacTarget.data(), kNumChannels*2); 1468 fDimDac.Update(val); 1469 1470 vector<float> volt(kNumChannels); 1471 for (float ch=0; ch<kNumChannels; ch++) 1472 volt[ch] = fDacActual[ch]*90./4096 - fChannelCalibration[ch]; 1473 fDimVolt.Update(volt); 1513 1474 } 1514 1475 1515 1476 void UpdateVgapd() 1516 1477 { 1517 fDimGapd.Update(fDacGapd); 1478 vector<float> volt; 1479 volt.reserve(3*kNumChannels); 1480 volt.insert(volt.end(), fBreakdownVoltage.begin(), fBreakdownVoltage.end()); 1481 volt.insert(volt.end(), fOvervoltage.begin(), fOvervoltage.end()); 1482 volt.insert(volt.end(), fChannelCalibration.begin(), fChannelCalibration.end()); 1483 fDimGapd.Update(volt); 1518 1484 } 1519 1485 … … 1521 1487 ConnectionDimBias(ba::io_service& ioservice, MessageImp &imp) : 1522 1488 ConnectionBias(ioservice, imp), 1523 fDimCurrent("BIAS_CONTROL/CURRENT", "S:416", "|I[uA]:Bias current"), 1524 fDimVoltage("BIAS_CONTROL/VOLTAGE", "S:416;S:416", "|U[V]:Applied bias voltage|Uref[V]:Reference bias voltage"), 1525 fDimGapd( "BIAS_CONTROL/NOMINAL", "S:416", "|U[V]:Nominal G-APD voltage at 25deg C") 1489 fDimCurrent("BIAS_CONTROL/CURRENT", "S:416", 1490 "|I[uA]:Bias current"), 1491 fDimDac("BIAS_CONTROL/DAC", "S:416;S:416", 1492 "|U[dac]:Current dac setting" 1493 "|Uref[dac]:Reference dac setting"), 1494 fDimVolt("BIAS_CONTROL/VOLTAGE", "F:416", 1495 "|Uout[V]:Output voltage"), 1496 fDimGapd("BIAS_CONTROL/NOMINAL", "F:416;F:416;F:416", 1497 "|Ubr[V]:Nominal breakdown voltage at 25deg C" 1498 "|Uov[V]:Nominal overvoltage" 1499 "|Uoff[V]:Bias crate channel offsets") 1526 1500 { 1527 1501 } … … 1564 1538 // -------------------------------------------------------------------- 1565 1539 1566 int SetGapdVoltage(const EventImp &evt) 1567 { 1568 if (!CheckEventSize(evt.GetSize(), "SetGapdVoltage", 4)) 1569 return false; 1570 1571 fBias.SetGapdVoltage(evt.GetFloat()); 1540 // SET_GLOBAL_DAC_VALUE 1541 int SetGlobalDac(const EventImp &evt) 1542 { 1543 if (!CheckEventSize(evt.GetSize(), "SetGlobalDac", 2)) 1544 return false; 1545 1546 fBias.RampAllDacs(evt.GetUShort()); 1572 1547 1573 1548 return T::GetCurrentState(); 1574 1549 } 1575 1550 1576 int SetGapdVoltages(const EventImp &evt) 1577 { 1578 if (!CheckEventSize(evt.GetSize(), "SetGapdVoltages", 4*416)) 1551 // SET_CHANNEL_DAC_VALUE 1552 int SetChannelDac(const EventImp &evt) 1553 { 1554 if (!CheckEventSize(evt.GetSize(), "SetChannelDac", 4)) 1555 return false; 1556 1557 fBias.RampSingleChannelDac(evt.Get<uint16_t>(), evt.Get<uint16_t>(2)); 1558 1559 return T::GetCurrentState(); 1560 } 1561 1562 // -------------------------------------------------------------------- 1563 1564 // SET_CHANNEL_VOLTAGE 1565 int SetChannelVolt(const EventImp &evt) 1566 { 1567 if (!CheckEventSize(evt.GetSize(), "SetChannelVolt", 6)) 1568 return false; 1569 1570 fBias.RampSingleChannelVoltage(evt.GetUShort(), evt.Get<float>(2)); 1571 1572 return T::GetCurrentState(); 1573 } 1574 1575 // SET_GLOBAL_VOLTAGE 1576 int SetGlobalVolt(const EventImp &evt) 1577 { 1578 if (!CheckEventSize(evt.GetSize(), "SetGlobalVolt", 4)) 1579 return false; 1580 1581 fBias.RampAllVoltages(evt.GetFloat()); 1582 1583 return T::GetCurrentState(); 1584 } 1585 1586 // SET_ALL_CHANNELS_VOLTAGES 1587 int SetAllChannelsVolt(const EventImp &evt) 1588 { 1589 if (!CheckEventSize(evt.GetSize(), "SetAllChannelsVolt", 4*kNumChannels)) 1579 1590 return false; 1580 1591 1581 1592 const float *ptr = evt.Ptr<float>(); 1582 fBias. SetGapdVoltages(vector<float>(ptr, ptr+416));1593 fBias.RampAllChannelsVoltage(vector<float>(ptr, ptr+kNumChannels)); 1583 1594 1584 1595 return T::GetCurrentState(); … … 1587 1598 // -------------------------------------------------------------------- 1588 1599 1589 int SetGlobalVolt(const EventImp &evt) 1590 { 1591 if (!CheckEventSize(evt.GetSize(), "SetGlobalVolt", 4)) 1592 return false; 1593 1594 fBias.GlobalSetVolt(evt.GetFloat()); 1600 // SET_GLOBAL_OFFSET 1601 int SetGlobalOffset(const EventImp &evt) 1602 { 1603 if (!CheckEventSize(evt.GetSize(), "SetGlobalOffset", 4)) 1604 return false; 1605 1606 fBias.RampAllOffsets(evt.GetFloat(), false); 1595 1607 1596 1608 return T::GetCurrentState(); 1597 1609 } 1598 1610 1599 int SetGlobalDac(const EventImp &evt) 1600 { 1601 if (!CheckEventSize(evt.GetSize(), "SetGlobalDac", 2)) 1602 return false; 1603 1604 fBias.GlobalSetDac(evt.GetUShort()); 1611 // SET_SINGLE_CHANNEL_OFFSET 1612 int SetChannelOffset(const EventImp &evt) 1613 { 1614 if (!CheckEventSize(evt.GetSize(), "SetSingleChannelOffset", 6)) 1615 return false; 1616 1617 fBias.RampSingleChannelOffset(evt.Get<uint16_t>(), evt.Get<float>(2), false); 1605 1618 1606 1619 return T::GetCurrentState(); 1607 1620 } 1608 1621 1622 // SET_ALL_CHANNELS_OFFSET 1623 int SetAllChannelsOffset(const EventImp &evt) 1624 { 1625 if (!CheckEventSize(evt.GetSize(), "SetAllChannelsOffset", 4*kNumChannels)) 1626 return false; 1627 1628 const float *ptr = evt.Ptr<float>(); 1629 fBias.RampAllChannelsOffset(vector<float>(ptr, ptr+kNumChannels), false); 1630 1631 return T::GetCurrentState(); 1632 } 1633 1634 // -------------------------------------------------------------------- 1635 1636 // INCREASE_GLOBAL_VOLTAGE 1609 1637 int IncGlobalVolt(const EventImp &evt) 1610 1638 { … … 1612 1640 return false; 1613 1641 1614 fBias. GlobalAddVolt(evt.GetFloat());1642 fBias.RampAllOffsets(evt.GetFloat(), true); 1615 1643 1616 1644 return T::GetCurrentState(); 1617 1645 } 1618 1646 1619 int IncGlobalDac(const EventImp &evt) 1620 { 1621 if (!CheckEventSize(evt.GetSize(), "IncGlobalDac", 2)) 1622 return false; 1623 1624 fBias.GlobalAddDac(evt.GetShort()); 1647 // INCREASE_CHANNEL_VOLTAGE 1648 int IncChannelVolt(const EventImp &evt) 1649 { 1650 if (!CheckEventSize(evt.GetSize(), "IncChannelVolt", 6)) 1651 return false; 1652 1653 fBias.RampSingleChannelOffset(evt.Get<uint16_t>(), evt.Get<float>(2), true); 1625 1654 1626 1655 return T::GetCurrentState(); 1627 1656 } 1628 1657 1629 int DecGlobalVolt(const EventImp &evt) 1630 { 1631 if (!CheckEventSize(evt.GetSize(), "DecGlobalVolt", 4)) 1632 return false; 1633 1634 fBias.GlobalAddVolt(-evt.GetFloat()); 1658 // INCREASE_ALL_CHANNELS_VOLTAGES 1659 int IncAllChannelsVolt(const EventImp &evt) 1660 { 1661 if (!CheckEventSize(evt.GetSize(), "IncAllChannelsVolt", 4*kNumChannels)) 1662 return false; 1663 1664 const float *ptr = evt.Ptr<float>(); 1665 fBias.RampAllChannelsOffset(vector<float>(ptr, ptr+416), true); 1635 1666 1636 1667 return T::GetCurrentState(); 1637 1668 } 1638 1669 1639 int DecGlobalDac(const EventImp &evt)1640 {1641 if (!CheckEventSize(evt.GetSize(), "DecGlobalDac", 2))1642 return false;1643 1644 fBias.GlobalAddDac(-evt.GetShort());1645 1646 return T::GetCurrentState();1647 }1648 1649 int SetChannelVolt(const EventImp &evt)1650 {1651 if (!CheckEventSize(evt.GetSize(), "SetChannelVolt", 6))1652 return false;1653 1654 fBias.ChannelSetVolt(evt.GetUShort(), evt.Get<float>(2));1655 1656 return T::GetCurrentState();1657 }1658 1659 int SetChannelDac(const EventImp &evt)1660 {1661 if (!CheckEventSize(evt.GetSize(), "SetChannelDac", 4))1662 return false;1663 1664 fBias.ChannelSetDac(evt.Get<uint16_t>(), evt.Get<uint16_t>(2));1665 1666 return T::GetCurrentState();1667 }1668 1669 int SetGapdReferenceCh(const EventImp &evt)1670 {1671 if (!CheckEventSize(evt.GetSize(), "SetGapdReferenceCh", 2))1672 return false;1673 1674 fBias.SetGapdReferenceCh(evt.GetUShort());1675 1676 return T::GetCurrentState();1677 }1678 1679 1680 1670 // -------------------------------------------------------------------- 1681 1671 1682 int AddReferenceDac(const EventImp &evt) 1683 { 1684 if (!CheckEventSize(evt.GetSize(), "AddReferenceDac", 2*kNumChannels)) 1685 return false; 1686 1687 const int16_t *ptr = evt.Ptr<int16_t>(); 1688 fBias.AddDac(vector<int16_t>(ptr, ptr+416)); 1689 1690 return T::GetCurrentState(); 1691 } 1692 1693 int AddReferenceVolt(const EventImp &evt) 1694 { 1695 if (!CheckEventSize(evt.GetSize(), "AddReferenceVolt", 4*kNumChannels)) 1696 return false; 1697 1698 const float_t *ptr = evt.Ptr<float>(); 1699 fBias.AddVolt(vector<float>(ptr, ptr+416)); 1700 1701 return T::GetCurrentState(); 1702 } 1703 1704 int SetReferenceDac(const EventImp &evt) 1705 { 1706 if (!CheckEventSize(evt.GetSize(), "SetReferenceDac", 2*kNumChannels)) 1707 return false; 1708 1709 const int16_t *ptr = evt.Ptr<int16_t>(); 1710 fBias.SetDac(vector<int16_t>(ptr, ptr+416)); 1711 1712 return T::GetCurrentState(); 1713 } 1714 1715 int SetReferenceVolt(const EventImp &evt) 1716 { 1717 if (!CheckEventSize(evt.GetSize(), "SetReferenceVolt", 4*kNumChannels)) 1718 return false; 1719 1720 const float_t *ptr = evt.Ptr<float>(); 1721 fBias.SetVolt(vector<float>(ptr, ptr+416)); 1672 // SET_CHANNEL_OFFSET_TO_ZERO 1673 int SetChannelOffsetToZero(const EventImp &evt) 1674 { 1675 if (!CheckEventSize(evt.GetSize(), "SetChannelOffsetToZero", 2)) 1676 return false; 1677 1678 fBias.RampSingleChannelOffset(evt.GetUShort(), 0, false); 1722 1679 1723 1680 return T::GetCurrentState(); … … 1816 1773 1817 1774 fBias.SetVerbose(evt.GetBool()); 1775 1776 return T::GetCurrentState(); 1777 } 1778 1779 int SetDummyMode(const EventImp &evt) 1780 { 1781 if (!CheckEventSize(evt.GetSize(), "SetDummyMode", 1)) 1782 return T::kSM_FatalError; 1783 1784 fBias.SetDummyMode(evt.GetBool()); 1818 1785 1819 1786 return T::GetCurrentState(); … … 1890 1857 1891 1858 // Verbosity commands 1892 T::AddEvent("SET_VERBOSE", "B ")1859 T::AddEvent("SET_VERBOSE", "B:1") 1893 1860 (bind(&StateMachineBias::SetVerbosity, this, placeholders::_1)) 1894 1861 ("set verbosity state" 1895 1862 "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data"); 1863 1864 T::AddEvent("ENABLE_DUMMY_MODE", "B:1") 1865 (bind(&StateMachineBias::SetDummyMode, this, placeholders::_1)) 1866 ("Enable dummy mode. In this mode SetAllChannels prints informations instead of sending anything to the bias crate." 1867 "|enable[bool]:disable or enable dummy mode"); 1896 1868 1897 1869 // Conenction commands … … 1899 1871 (bind(&StateMachineBias::Disconnect, this)) 1900 1872 ("disconnect from USB"); 1901 1902 1873 T::AddEvent("RECONNECT", "O", kDisconnected, kConnected, kVoltageOff) 1903 1874 (bind(&StateMachineBias::Reconnect, this, placeholders::_1)) … … 1922 1893 1923 1894 1924 1895 T::AddEvent("SET_CHANNEL_DAC", "S:1;S:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1896 (bind(&StateMachineBias::SetChannelDac, this, placeholders::_1)) 1897 ("Set a new target value in DAC counts for a single channel. Starts ramping if necessary." 1898 "|channel[short]:Channel for which to set the target voltage [0-415]" 1899 "|voltage[dac]:Target voltage in DAC units for the given channel"); 1900 T::AddEvent("SET_GLOBAL_DAC", "S:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1901 (bind(&StateMachineBias::SetGlobalDac, this, placeholders::_1)) 1902 ("Set a new target value for all channels in DAC counts. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)" 1903 "|voltage[dac]:Global target voltage in DAC counts."); 1904 1905 1906 T::AddEvent("SET_CHANNEL_VOLTAGE", "S:1;F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1907 (bind(&StateMachineBias::SetChannelVolt, this, placeholders::_1)) 1908 ("Set a new target voltage for a single channel. Starts ramping if necessary." 1909 "|channel[short]:Channel for which to set the target voltage [0-415]" 1910 "|voltage[V]:Target voltage in volts for the given channel (will be converted to DAC units)"); 1925 1911 T::AddEvent("SET_GLOBAL_VOLTAGE", "F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1926 1912 (bind(&StateMachineBias::SetGlobalVolt, this, placeholders::_1)) 1927 ("Set a ll channels to a new reference voltage. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)"1913 ("Set a new target voltage for all channels. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)" 1928 1914 "|voltage[V]:Global target voltage in volts (will be converted to DAC units)"); 1929 1930 T::AddEvent("SET_GLOBAL_DAC", "S:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1931 (bind(&StateMachineBias::SetGlobalDac, this, placeholders::_1)) 1932 ("Set all channels to a new DAC reference. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)" 1933 "|voltage[dac]:Global target voltage as DAC counts."); 1934 1915 T::AddEvent("SET_ALL_CHANNELS_VOLTAGE", "F:416", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1916 (bind(&StateMachineBias::SetAllChannelsVolt, this, placeholders::_1)) 1917 ("Set all channels to the given new reference voltage. Starts ramping if necessary." 1918 "voltage[V]:New reference voltage for all channels"); 1919 1920 1921 T::AddEvent("INCREASE_CHANNEL_VOLTAGE", "S:1;F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1922 (bind(&StateMachineBias::IncChannelVolt, this, placeholders::_1)) 1923 ("Increases the voltage of all channels by the given offset. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)" 1924 "|channel[short]:Channel for which to adapt the voltage [0-415]" 1925 "|offset[V]:Offset to be added to all channels (will be converted to DAC counts)"); 1935 1926 T::AddEvent("INCREASE_GLOBAL_VOLTAGE", "F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1936 1927 (bind(&StateMachineBias::IncGlobalVolt, this, placeholders::_1)) 1937 (" Set all channels to a new reference voltage. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)"1928 ("Increases the voltage of all channels by the given offset. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)" 1938 1929 "|offset[V]:Offset to be added to all channels (will be converted to DAC counts)"); 1939 1940 T::AddEvent("INCREASE_GLOBAL_DAC", "S:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1941 (bind(&StateMachineBias::IncGlobalDac, this, placeholders::_1)) 1942 ("Set all channels to a new DAC reference. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)" 1943 "|offset[dac]:Offset to be added to all channels as DAC counts"); 1944 1945 T::AddEvent("DECREASE_GLOBAL_VOLTAGE", "F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1946 (bind(&StateMachineBias::DecGlobalVolt, this, placeholders::_1)) 1947 ("Set all channels to a new reference voltage. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)" 1948 "|offset[V]:Offset to be subtracted from all channels (will be converted to DAC counts)"); 1949 1950 T::AddEvent("DECREASE_GLOBAL_DAC", "S:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1951 (bind(&StateMachineBias::DecGlobalDac, this, placeholders::_1)) 1952 ("Set all channels to a new DAC reference. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)" 1953 "|offset[dac]:Offset to be subtracted from all channels as DAC counts"); 1954 1955 T::AddEvent("SET_CHANNEL_VOLTAGE", "S:1;F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1956 (bind(&StateMachineBias::SetChannelVolt, this, placeholders::_1)) 1957 ("Set a single channel to a new reference voltage. Starts ramping if necessary." 1958 "|channel[short]:Channel for which to set the target voltage [0-416]" 1959 "|voltage[V]:Target voltage in volts for the given channel (will be converted to DAC units)"); 1960 1961 T::AddEvent("SET_CHANNEL_DAC", "S:1;S:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1962 (bind(&StateMachineBias::SetChannelDac, this, placeholders::_1)) 1963 ("Set a single channel to a new DAC reference value. Starts ramping if necessary." 1964 "|channel[short]:Channel for which to set the target voltage [0-416]" 1965 "|voltage[dac]:Target voltage in DAC units for the given channel"); 1966 1967 T::AddEvent("SET_GLOBAL_GAPD_REFERENCE_VOLTAGE", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1968 (Wrapper(bind(&ConnectionBias::SetGapdVoltage, &fBias, 0.))) 1930 T::AddEvent("INCREASE_ALL_CHANNELS_VOLTAGE", "F:416", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1931 (bind(&StateMachineBias::IncAllChannelsVolt, this, placeholders::_1)) 1932 ("Add the given voltages to the current reference voltages. Starts ramping if necessary." 1933 "offset[V]:Offsets to be added to the reference voltage of all channels in volts"); 1934 1935 1936 // SET_SINGLE_CHANNEL_OFFSET 1937 T::AddEvent("SET_CHANNEL_OFFSET", "S:1;F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1938 (bind(&StateMachineBias::SetChannelOffset, this, placeholders::_1)) 1939 ("Set single channels to its G-APD breakdown voltage plus overvoltage plus the given offset. Starts ramping if necessary." 1940 "|channel[short]:Channel for which to set the target voltage [0-415]" 1941 "|offset[V]:Offset to be added to the G-APD reference voltage of the given channel"); 1942 T::AddEvent("SET_GLOBAL_OFFSET", "F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1943 (bind(&StateMachineBias::SetGlobalOffset, this, placeholders::_1)) 1944 ("Set all channels to their G-APD breakdown voltage plus overvoltage plus the given offset. Starts ramping if necessary." 1945 "|offset[V]:Offset to be added to the G-APD reference voltage globally"); 1946 T::AddEvent("SET_ALL_CHANNELS_OFFSET", "F:416", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1947 (bind(&StateMachineBias::SetAllChannelsOffset, this, placeholders::_1)) 1948 ("Set all channels to their G-APD reference voltage plus the given offset. Starts ramping if necessary." 1949 "|offset[V]:Offset to be added to teh G-APD reference voltage globally"); 1950 1951 1952 T::AddEvent("SET_GLOBAL_OFFSET_TO_ZERO", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1953 (Wrapper(bind(&ConnectionBias::RampAllOffsets, &fBias, 0., false))) 1969 1954 ("Set all channels to their G-APD reference voltage. Starts ramping if necessary."); 1970 1955 1971 T::AddEvent("SET_CHANNEL_ GAPD_REFERENCE_VOLTAGE", "S:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)1972 (bind(&StateMachineBias::Set GapdReferenceCh, this, placeholders::_1))1956 T::AddEvent("SET_CHANNEL_OFFSET_TO_ZERO", "S:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1957 (bind(&StateMachineBias::SetChannelOffsetToZero, this, placeholders::_1)) 1973 1958 ("Set a single channel channels to its G-APD reference voltage. Starts ramping if necessary." 1974 1959 "|channel[short]:Channel for which to set the target voltage [0-416]"); 1975 1960 1976 T::AddEvent("SET_GAPD_REFERENCE_OFFSET", "F:1", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1977 (bind(&StateMachineBias::SetGapdVoltage, this, placeholders::_1)) 1978 ("Set all channels to their G-APD reference voltage plus the given offset. Starts ramping if necessary." 1979 "|offset[V]:Offset to be added to teh G-APD reference voltage globally"); 1980 1981 T::AddEvent("SET_ALL_CHANNELS_OFFSET", "F:416", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1982 (bind(&StateMachineBias::SetGapdVoltages, this, placeholders::_1)) 1983 ("Set all channels to their G-APD reference voltage plus the given offset. Starts ramping if necessary." 1984 "|offset[V]:Offset to be added to teh G-APD reference voltage"); 1961 1985 1962 1986 1963 T::AddEvent("SET_ZERO_VOLTAGE", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent) 1987 (Wrapper(bind(&ConnectionBias:: SetZero, &fBias)))1964 (Wrapper(bind(&ConnectionBias::RampAllDacs, &fBias, 0))) 1988 1965 ("Set all channels to a zero reference voltage. Starts ramping if necessary."); 1989 1966 1990 T::AddEvent("SET_REFERENCE_VOLTAGES", "F:416", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)1991 (bind(&StateMachineBias::SetReferenceVolt, this, placeholders::_1))1992 ("Set all channels to the given new reference voltage. Starts ramping if necessary."1993 "voltage[V]:New reference voltage for all channels");1994 1995 T::AddEvent("SET_REFERENCE_DACS", "S:416", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)1996 (bind(&StateMachineBias::SetReferenceDac, this, placeholders::_1))1997 ("Set all channels to the given new reference voltage. Starts ramping if necessary."1998 "voltage[dac]:New reference voltage for all channels in DAC units");1999 2000 T::AddEvent("ADD_REFERENCE_VOLTAGES", "F:416", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)2001 (bind(&StateMachineBias::AddReferenceVolt, this, placeholders::_1))2002 ("Add the given voltages to the current reference voltages. Starts ramping if necessary."2003 "offset[V]:Offsets to be added to the reference voltage of all channels in volts");2004 2005 T::AddEvent("ADD_REFERENCE_DACS", "S:416", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)2006 (bind(&StateMachineBias::AddReferenceDac, this, placeholders::_1))2007 ("Add the given voltages to the current reference voltages. Starts ramping if necessary."2008 "offset[dac]:Offsets to be added to the reference voltage of all channels in DAC units");2009 1967 2010 1968 … … 2031 1989 ("Print a table with all voltages (current and reference voltages as currently in memory)"); 2032 1990 T::AddEvent("PRINT_GAPD_REFERENCE_VOLTAGES") 2033 (Wrapper(bind(&ConnectionBias::Print Gapd, &fBias)))2034 ("Print the G-APD reference values obtained from file");1991 (Wrapper(bind(&ConnectionBias::PrintReferenceVoltage, &fBias))) 1992 ("Print the G-APD reference values (breakdown voltage + overvoltage) obtained from file"); 2035 1993 2036 1994 … … 2068 2026 2069 2027 fBias.SetVerbose(!conf.Get<bool>("quiet")); 2028 fBias.SetDummyMode(conf.Get<bool>("dummy-mode")); 2070 2029 2071 2030 if (conf.Has("dev")) … … 2147 2106 } 2148 2107 2149 if (!fBias.Set NewGapdVoltage(map.Vgapd()))2108 if (!fBias.SetReferences(map.Vgapd(), map.Voffset())) 2150 2109 { 2151 2110 T::Error("Setting reference voltages failed."); … … 2179 2138 ("dev", var<string>(), "Device address of USB port to bias-power supply") 2180 2139 ("quiet,q", po_bool(), "Disable printing contents of all received messages (except dynamic data) in clear text.") 2140 ("dummy-mode", po_bool(), "Dummy mode - SetAllChannels prints info instead of sending new values.") 2181 2141 ("ramp-delay", var<uint16_t>(15), "Delay between the answer of one ramping step and sending the next ramp command to all channels in milliseconds.") 2182 2142 ("ramp-step", var<uint16_t>(46), "Maximum step in DAC counts during ramping (Volt = DAC*90/4096)")
Note:
See TracChangeset
for help on using the changeset viewer.