Changeset 12279
- Timestamp:
- 10/26/11 19:42:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/biasctrl.cc
r12270 r12279 60 60 bool fIsInitializing; 61 61 bool fIsRamping; 62 boolfWaitingForAnswer;62 int fWaitingForAnswer; 63 63 64 64 vector<uint64_t> fCounter; … … 505 505 case kCmdRead: 506 506 HandleReceivedData(fBuffer, bytes_received, command, send_counter); 507 fWaitingForAnswer = false;507 fWaitingForAnswer = -1; 508 508 return; 509 509 … … 578 578 void ConnectionEstablished() 579 579 { 580 // We connect for the first time or haven't received 581 // a valid warp counter yet... this procedure also sets 582 // our volatges to 0 if we have connected but never received 583 // any answer. 584 if (fWrapCounter<0) 585 { 586 fVolt.assign( kNumChannels, 0); 587 fVoltRef.assign(kNumChannels, 0); 588 fVoltCmd.assign(kNumChannels, 0); 589 } 590 580 591 // Reset everything.... 581 592 fSendCounter = -1; … … 583 594 fGlobalVoltCmd = -1; 584 595 fIsInitializing = true; 585 586 fVolt.assign( kNumChannels, 0); 587 fVoltRef.assign(kNumChannels, 0); 588 fVoltCmd.assign(kNumChannels, 0); 596 fIsRamping = false; 589 597 590 598 // Send a single 0 (and possible two consecutive 0's … … 592 600 PostMessage("\0", 1); 593 601 AsyncRead(ba::buffer(fBuffer, 3), kSynchronize, 0);//++fSendCounter); 594 fWaitingForAnswer = true;602 fWaitingForAnswer = kSynchronize; 595 603 596 604 // Wait for some time before sending the next 0 … … 660 668 661 669 if (special) 662 fWaitingForAnswer = true;670 fWaitingForAnswer = special ? kResetChannels : kCmdChannelSet; 663 671 } 664 672 … … 764 772 //fRefCurrent(kNumChannels), 765 773 fPresent(kNumBoards), 774 fWrapCounter(-1), 766 775 fRampStep(-1), 767 776 fRampTime(-1), … … 769 778 fSyncTime(333), 770 779 fIsRamping(false), 771 fWaitingForAnswer( false),780 fWaitingForAnswer(-1), 772 781 fCounter(8), 773 782 fVolt(kNumChannels), … … 781 790 void OverCurrentReset() 782 791 { 783 if (fWaitingForAnswer) 784 { 785 Error("Answer on last command not yet received."); 792 if (fWaitingForAnswer>=0) 793 { 794 ostringstream msg; 795 msg << "Answer on last command (id=" << fWaitingForAnswer << ") not yet received."; 796 Error(msg); 786 797 return; 787 798 } … … 803 814 void ReadAllChannels(bool special = false) 804 815 { 805 if (!special && fWaitingForAnswer) 806 { 807 Error("Answer on last command not yet received."); 816 if (!special && fWaitingForAnswer>=0) 817 { 818 ostringstream msg; 819 msg << "Answer on last command (id=" << fWaitingForAnswer << ") not yet received."; 820 Error(msg); 808 821 return; 809 822 } … … 825 838 826 839 if (!special) 827 fWaitingForAnswer = true;840 fWaitingForAnswer = special ? kUpdate : kCmdRead; 828 841 } 829 842 … … 1107 1120 void ExpertReset(bool expert_mode=true) 1108 1121 { 1109 if (fWaitingForAnswer) 1110 { 1111 Error("Answer on last command not yet received."); 1122 if (fWaitingForAnswer>=0) 1123 { 1124 ostringstream msg; 1125 msg << "Answer on last command (id=" << fWaitingForAnswer << ") not yet received."; 1126 Error(msg); 1112 1127 return; 1113 1128 } … … 1118 1133 PostMessage(GetCmd(kCmdReset)); 1119 1134 AsyncRead(ba::buffer(fBuffer, 3), kCmdReset, ++fSendCounter); 1120 fWaitingForAnswer = true;1135 fWaitingForAnswer = kCmdReset; 1121 1136 } 1122 1137 … … 1124 1139 bool ExpertChannelSetDac(uint16_t ch, uint16_t dac) 1125 1140 { 1126 if (fWaitingForAnswer) 1127 { 1128 Error("Answer on last command not yet received."); 1141 if (fWaitingForAnswer>=0) 1142 { 1143 ostringstream msg; 1144 msg << "Answer on last command (id=" << fWaitingForAnswer << ") not yet received."; 1145 Error(msg); 1129 1146 return false; 1130 1147 } … … 1142 1159 PostMessage(GetCmd(kCmdChannelSet, ch, dac)); 1143 1160 AsyncRead(ba::buffer(fBuffer, 3), kExpertChannelSet|(ch<<8), ++fSendCounter); 1144 fWaitingForAnswer = true;1161 fWaitingForAnswer = kExpertChannelSet|(ch<<8); 1145 1162 1146 1163 return true; … … 1154 1171 bool ExpertGlobalSetDac(uint16_t dac) 1155 1172 { 1156 if (fWaitingForAnswer) 1157 { 1158 Error("Answer on last command not yet received."); 1173 if (fWaitingForAnswer>=0) 1174 { 1175 ostringstream msg; 1176 msg << "Answer on last command (id=" << fWaitingForAnswer << ") not yet received."; 1177 Error(msg); 1159 1178 return false; 1160 1179 } … … 1177 1196 PostMessage(GetCmd(kCmdGlobalSet, 0, dac)); 1178 1197 AsyncRead(ba::buffer(fBuffer, 3), kCmdGlobalSet, ++fSendCounter); 1179 fWaitingForAnswer = true;1198 fWaitingForAnswer = kCmdGlobalSet; 1180 1199 1181 1200 return true;
Note:
See TracChangeset
for help on using the changeset viewer.