- Timestamp:
- 09/02/11 12:49:35 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/biasctrl.cc
r11943 r11948 756 756 bool ChannelSetVolt(uint16_t ch, double volt) 757 757 { 758 if (volt<0 || volt>90) 759 { 760 Error("ChannelSetVolt - Voltage out of range [0V,90V]."); 761 return false; 762 } 763 758 764 return ChannelSetDac(ch, volt*4096/90.); 759 765 } … … 775 781 bool GlobalSetVolt(float volt) 776 782 { 783 if (volt<0 || volt>90) 784 { 785 Error("GlobalSetVolt - Voltage out of range [0V,90V]."); 786 return false; 787 } 788 777 789 return GlobalSetDac(volt*4096/90); 778 790 } 779 791 780 // -------------------------------------------------------------------- 781 782 bool SetGapdVoltage() 792 bool GlobalAddDac(int16_t dac) 783 793 { 784 794 for (size_t ch=0; ch<kNumChannels; ch++) 785 if (fVoltGapd[ch]>kMaxDac) 795 { 796 if (fVoltRef[ch]+dac>kMaxDac) 786 797 { 787 Error(" SetGapdVoltage - Voltage reference for G-APD channelout of range.");798 Error("GlobalAddDac - New voltage reference out of range."); 788 799 return false; 789 800 } 790 801 802 if (fVoltRef[ch]+dac<0) 803 fVoltRef[ch] = 0; 804 else 805 fVoltRef[ch]+= dac; 806 } 807 808 if (!fIsRamping) 809 fIsRamping = RampOneStep(); 810 811 return true; 812 } 813 814 bool GlobalAddVolt(float offset) 815 { 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 } 824 825 // -------------------------------------------------------------------- 826 827 bool SetGapdVoltage(float offset) 828 { 829 if (offset<-90 || offset>90) 830 { 831 Error("SetGapdVoltage - Offset out of range [-90V,90V]."); 832 return false; 833 } 834 835 const int16_t dac = offset*4096/90; 836 791 837 for (size_t ch=0; ch<kNumChannels; ch++) 792 fVoltRef[ch] = fVoltGapd[ch]; 838 if (fVoltGapd[ch]+dac>kMaxDac) 839 { 840 Error("SetGapdVoltage - New voltage reference out of range."); 841 return false; 842 } 843 844 for (size_t ch=0; ch<kNumChannels; ch++) 845 fVoltRef[ch] = fVoltGapd[ch]+dac<0 ? 0 : fVoltGapd[ch]+dac; 793 846 794 847 if (!fIsRamping) … … 1192 1245 // -------------------------------------------------------------------- 1193 1246 1247 int SetGapdVoltage(const EventImp &evt) 1248 { 1249 if (!CheckEventSize(evt.GetSize(), "SetGapdVoltage", 4)) 1250 return false; 1251 1252 fBias.SetGapdVoltage(evt.GetFloat()); 1253 1254 return T::GetCurrentState(); 1255 } 1256 1257 // -------------------------------------------------------------------- 1258 1194 1259 int SetGlobalVolt(const EventImp &evt) 1195 1260 { … … 1197 1262 return false; 1198 1263 1199 if (!fBias.GlobalSetVolt(evt.GetFloat())) 1200 T::Error("Supplied voltage out of range (0-90)"); 1264 fBias.GlobalSetVolt(evt.GetFloat()); 1201 1265 1202 1266 return T::GetCurrentState(); … … 1208 1272 return false; 1209 1273 1210 if (!fBias.GlobalSetDac(evt.GetUShort())) 1211 T::Error("Supplied voltage out of range (0-90)"); 1274 fBias.GlobalSetDac(evt.GetUShort()); 1212 1275 1213 1276 return T::GetCurrentState(); 1214 1277 } 1215 1278 1279 int IncGlobalVolt(const EventImp &evt) 1280 { 1281 if (!CheckEventSize(evt.GetSize(), "IncGlobalVolt", 4)) 1282 return false; 1283 1284 fBias.GlobalAddVolt(evt.GetFloat()); 1285 1286 return T::GetCurrentState(); 1287 } 1288 1289 int IncGlobalDac(const EventImp &evt) 1290 { 1291 if (!CheckEventSize(evt.GetSize(), "IncGlobalDac", 2)) 1292 return false; 1293 1294 fBias.GlobalAddDac(evt.GetShort()); 1295 1296 return T::GetCurrentState(); 1297 } 1298 1299 int DecGlobalVolt(const EventImp &evt) 1300 { 1301 if (!CheckEventSize(evt.GetSize(), "DecGlobalVolt", 4)) 1302 return false; 1303 1304 fBias.GlobalAddVolt(-evt.GetFloat()); 1305 1306 return T::GetCurrentState(); 1307 } 1308 1309 int DecGlobalDac(const EventImp &evt) 1310 { 1311 if (!CheckEventSize(evt.GetSize(), "DecGlobalDac", 2)) 1312 return false; 1313 1314 fBias.GlobalAddDac(-evt.GetShort()); 1315 1316 return T::GetCurrentState(); 1317 } 1318 1216 1319 int SetChannelVolt(const EventImp &evt) 1217 1320 { … … 1219 1322 return false; 1220 1323 1221 if (!fBias.ChannelSetVolt(evt.GetUShort(), evt.Get<float>(2))) 1222 T::Error("Value out of range"); 1324 fBias.ChannelSetVolt(evt.GetUShort(), evt.Get<float>(2)); 1223 1325 1224 1326 return T::GetCurrentState(); … … 1230 1332 return false; 1231 1333 1232 if (!fBias.ChannelSetDac(evt.Get<uint16_t>(), evt.Get<uint16_t>(2))) 1233 T::Error("Value out of range"); 1334 fBias.ChannelSetDac(evt.Get<uint16_t>(), evt.Get<uint16_t>(2)); 1234 1335 1235 1336 return T::GetCurrentState(); … … 1243 1344 return false; 1244 1345 1245 if (!fBias.ExpertGlobalSetVolt(evt.GetFloat())) 1246 T::Error("Supplied voltage out of range (0-90)"); 1346 fBias.ExpertGlobalSetVolt(evt.GetFloat()); 1247 1347 1248 1348 return T::GetCurrentState(); … … 1254 1354 return false; 1255 1355 1256 if (!fBias.ExpertGlobalSetDac(evt.GetUShort())) 1257 T::Error("Supplied voltage out of range (0-90)"); 1356 fBias.ExpertGlobalSetDac(evt.GetUShort()); 1258 1357 1259 1358 return T::GetCurrentState(); … … 1265 1364 return false; 1266 1365 1267 if (!fBias.ExpertChannelSetVolt(evt.GetUShort(), evt.Get<float>(2))) 1268 T::Error("Value out of range"); 1366 fBias.ExpertChannelSetVolt(evt.GetUShort(), evt.Get<float>(2)); 1269 1367 1270 1368 return T::GetCurrentState(); … … 1276 1374 return false; 1277 1375 1278 if (!fBias.ExpertChannelSetDac(evt.Get<uint16_t>(), evt.Get<uint16_t>(2))) 1279 T::Error("Value out of range"); 1376 fBias.ExpertChannelSetDac(evt.Get<uint16_t>(), evt.Get<uint16_t>(2)); 1280 1377 1281 1378 return T::GetCurrentState(); … … 1425 1522 ("Set all channels to a new DAC reference. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)"); 1426 1523 1524 T::AddEvent("INCREASE_GLOBAL_VOLTAGE", "F:1", kConnected, kAtReference, kOverCurrent) 1525 (bind(&StateMachineBias::IncGlobalVolt, this, placeholders::_1)) 1526 ("Set all channels to a new reference voltage. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)"); 1527 1528 T::AddEvent("INCREASE_GLOBAL_DAC", "S:1", kConnected, kAtReference, kOverCurrent) 1529 (bind(&StateMachineBias::IncGlobalDac, this, placeholders::_1)) 1530 ("Set all channels to a new DAC reference. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)"); 1531 1532 T::AddEvent("DECREASE_GLOBAL_VOLTAGE", "F:1", kConnected, kAtReference, kOverCurrent) 1533 (bind(&StateMachineBias::DecGlobalVolt, this, placeholders::_1)) 1534 ("Set all channels to a new reference voltage. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)"); 1535 1536 T::AddEvent("DECREASE_GLOBAL_DAC", "S:1", kConnected, kAtReference, kOverCurrent) 1537 (bind(&StateMachineBias::DecGlobalDac, this, placeholders::_1)) 1538 ("Set all channels to a new DAC reference. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)"); 1539 1427 1540 T::AddEvent("SET_CHANNEL_VOLTAGE", "S:1;F:1", kConnected, kAtReference, kOverCurrent) 1428 1541 (bind(&StateMachineBias::SetChannelVolt, this, placeholders::_1)) … … 1434 1547 1435 1548 T::AddEvent("SET_GAPD_REFERENCE_VOLTAGE", kConnected, kAtReference, kOverCurrent) 1436 (Wrapper(bind(&ConnectionBias::SetGapdVoltage, &fBias )))1549 (Wrapper(bind(&ConnectionBias::SetGapdVoltage, &fBias, 0.))) 1437 1550 ("Set all channels to their G-APD reference voltage. Starts ramping if necessary."); 1551 1552 T::AddEvent("SET_GAPD_REFERENCE_OFFSET", "F:1", kConnected, kAtReference, kOverCurrent) 1553 (bind(&StateMachineBias::SetGapdVoltage, this, placeholders::_1)) 1554 ("Set all channels to their G-APD reference voltage plus the given offset. Starts ramping if necessary."); 1438 1555 1439 1556 T::AddEvent("SET_ZERO_VOLTAGE", kConnected, kAtReference, kOverCurrent) … … 1606 1723 ("dev", var<string>("FTE00FOH"), "Device address of USB port to bias-power supply") 1607 1724 ("quiet,q", po_bool(), "Disable printing contents of all received messages (except dynamic data) in clear text.") 1608 ("ramp-time", var<uint16_t>(15), "Delay between the answer of one ramping step sand sending the next ramp command to all channels in milliseconds.")1725 ("ramp-time", var<uint16_t>(15), "Delay between the answer of one ramping step and sending the next ramp command to all channels in milliseconds.") 1609 1726 ("ramp-step", var<uint16_t>(46), "Maximum step in DAC counts during ramping (Volt = DAC*90/4096)") 1610 1727 ("update-interval", var<uint16_t>(3000), "Interval between two current requests in milliseconds") … … 1630 1747 { 1631 1748 cout << 1632 "The biasctrl controls the bias-power supply boards.\n"1749 "The biasctrl program controls the bias-power supply boards.\n" 1633 1750 "\n" 1634 "The default is that the program is started without user intercation. " 1635 "All actions are supposed to arrive as DimCommands. Using the -c " 1636 "option, a local shell can be initialized. With h or help a short " 1637 "help message about the usuage can be brought to the screen.\n" 1751 "Note: At default the program is started without a command line (user) " 1752 "interface. In this case Actions/Commands are available via Dim " 1753 "exclusively.\n" 1754 "Use the -c option to start the program with a command line interface.\n" 1755 "\n" 1756 "In the running application:\n" 1757 "Use h or help to print a short help message about its usage.\n" 1638 1758 "\n" 1639 1759 "Usage: biasctrl [-c type] [OPTIONS]\n"
Note:
See TracChangeset
for help on using the changeset viewer.