Changeset 11938 for trunk/FACT++
- Timestamp:
- 09/01/11 21:39:02 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/biasctrl.cc
r11937 r11938 78 78 79 79 uint16_t fUpdateTime; 80 uint16_t fSyncTime; 80 81 81 82 bool fIsInitializing; … … 89 90 vector<int16_t> fCurrent; // Current in ADC units (12bit = 5mA) 90 91 92 uint16_t fVoltMax; 93 91 94 virtual void UpdateA() 92 95 { … … 103 106 { 104 107 Error(cmd+" - DAC value out of range."); 108 return false; 109 } 110 if (dac>fVoltMax) 111 { 112 Error(cmd+" - DAC value exceeds fVoltMax."); 105 113 return false; 106 114 } … … 199 207 Warn("Initial answer doesn't seem to be a reset as naively expected."); 200 208 201 // FIXME:202 209 //ostringstream msg; 203 210 //msg << hex << setfill('0'); … … 463 470 void ScheduleSync(int counter=0) 464 471 { 465 fSyncTimer.expires_from_now(boost::posix_time::milliseconds( 1000));472 fSyncTimer.expires_from_now(boost::posix_time::milliseconds(fSyncTime)); 466 473 fSyncTimer.async_wait(boost::bind(&ConnectionBias::HandleSyncTimer, this, counter, dummy::error)); 467 474 } … … 511 518 } 512 519 513 if (is_open()) 514 { 515 if (fIsRamping) 516 { 517 Info("Schedule of update timer skipped."); 518 ScheduleUpdate(fUpdateTime); 519 } 520 else 521 ReadAllChannels(true); 522 } 520 if (!is_open()) 521 return; 522 523 if (fIsRamping) 524 ScheduleUpdate(fUpdateTime); 525 else 526 ReadAllChannels(true); 523 527 } 524 528 … … 565 569 bool RampOneStep() 566 570 { 571 if (fRampTime<0) 572 { 573 Warn("Ramping step time not yet set... ramping not started."); 574 return false; 575 } 576 if (fRampStep<0) 577 { 578 Warn("Ramping step not yet set... ramping not started."); 579 return false; 580 } 581 567 582 vector<uint16_t> dac(kNumChannels); 568 583 … … 626 641 void ScheduleRampStep() 627 642 { 628 Message("Schedule ramping");629 643 fRampTimer.expires_from_now(boost::posix_time::milliseconds(fRampTime)); 630 644 fRampTimer.async_wait(boost::bind(&ConnectionBias::HandleRampTimer, this, dummy::error)); … … 644 658 fRampStep(-1), 645 659 fRampTime(-1), 660 fSyncTime(333), 646 661 fUpdateTime(3000), 647 662 fIsRamping(false), … … 791 806 792 807 fIsRamping = RampOneStep(); 793 794 ostringstream msg;795 msg << "Ramp=" << fIsRamping;796 Message(msg);797 808 } 798 809 … … 826 837 827 838 fVoltCmd[ch] = dac; 828 829 // FIXME: How to ensure the correct evaluation of the answer?830 839 831 840 ostringstream msg; … … 983 992 984 993 // ------------------------------------------------------------------- 994 995 void SetUpdateInterval(uint16_t val) 996 { 997 fUpdateTime = val; 998 } 999 1000 void SetSyncDelay(uint16_t val) 1001 { 1002 fSyncTime = val; 1003 } 1004 1005 void SetVoltMax(float max) 1006 { 1007 fVoltMax = max*4096/90; 1008 if (fVoltMax>4095) 1009 fVoltMax = 4095; 1010 if (max<0) 1011 fVoltMax = 0; 1012 } 1013 1014 985 1015 /* 986 1016 void AdaptVoltages() … … 1292 1322 // deletion and creation of threads and more. 1293 1323 1294 T::Warn("FIXME -- implement a state for 'at reference'");1295 1296 1324 // State names 1297 1325 T::AddStateName(ConnectionBias::kDisconnected, "Disconnected", … … 1436 1464 return 1; 1437 1465 } 1438 if (time>10000) // 5V1439 {1440 T::Error("ramp-time exceeds allowed range.");1441 return 2;1442 }1443 1466 1444 1467 fBias.SetRampStep(step); 1445 1468 fBias.SetRampTime(time); 1469 fBias.SetUpdateInterval(conf.Get<uint16_t>("update-interval")); 1470 fBias.SetSyncDelay(conf.Get<uint16_t>("sync-delay")); 1471 1472 const float maxv = conf.Get<float>("volt-max"); 1473 if (maxv>90) 1474 { 1475 T::Error("volt-max exceeds 90V."); 1476 return 2; 1477 } 1478 if (maxv>75) 1479 T::Warn("volt-max exceeds 75V."); 1480 if (maxv<70) 1481 T::Warn("volt-max below 70V."); 1482 if (maxv<0) 1483 { 1484 T::Error("volt-max negative."); 1485 return 3; 1486 } 1487 1488 fBias.SetVoltMax(maxv); 1446 1489 1447 1490 // -------------------------------------------------------------------------- … … 1477 1520 { 1478 1521 T::Error("Invalid board/channel read from FACTmapV5.txt."); 1479 return 3;1522 return 4; 1480 1523 } 1481 1524 … … 1487 1530 { 1488 1531 T::Error("Reading reference voltages from FACTmapV5.txt failed."); 1489 return 4;1532 return 5; 1490 1533 } 1491 1534 … … 1493 1536 { 1494 1537 T::Error("Setting reference voltages failed."); 1495 return 5;1538 return 6; 1496 1539 } 1497 1540 … … 1518 1561 po::options_description control("BIAS control options"); 1519 1562 control.add_options() 1520 ("no-dim,d", po_bool(), "Disable dim services") 1521 ("dev", var<string>("FTE00FOH"), "Device address of USB port to bias-power supply") 1522 ("quiet,q", po_bool(), "Disable printing contents of all received messages (except dynamic data) in clear text.") 1523 ("ramp-time", var<uint16_t>(), "") 1524 ("ramp-step", var<uint16_t>(), "") 1563 ("no-dim,d", po_bool(), "Disable dim services") 1564 ("dev", var<string>("FTE00FOH"), "Device address of USB port to bias-power supply") 1565 ("quiet,q", po_bool(), "Disable printing contents of all received messages (except dynamic data) in clear text.") 1566 ("ramp-time", var<uint16_t>(15), "") 1567 ("ramp-step", var<uint16_t>(46), "") 1568 ("update-interval", var<uint16_t>(3000), "") 1569 ("sync-delay", var<uint16_t>(333), "") 1570 ("volt-max", var<float>(75), "") 1525 1571 ; 1526 // FIXME: Update interval 1527 // FIXME: Synchronization interval 1528 // FIXME: Make sure ramping / request and commands are not sent at the same time. 1529 // FIXME: Add limit of 75V 1572 // FIXME: Make sure ramping / request and commands are 1573 // not sent at the same time. 1530 1574 1531 1575 conf.AddOptions(control);
Note:
See TracChangeset
for help on using the changeset viewer.