Changeset 13751 for trunk/FACT++
- Timestamp:
- 05/16/12 09:34:05 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r13704 r13751 101 101 public: 102 102 DimState(const string &n, const string s="STATE") : 103 server(n), info(make_pair(Time(), - 2)),103 server(n), info(make_pair(Time(), -4)), 104 104 dim((n+"/"+s).c_str(), (void*)NULL, 0, this) { } 105 105 … … 123 123 124 124 info = make_pair(Time(tsec, tms*1000), 125 disconnected ? - 2: dim.getQuality());125 disconnected ? -4 : dim.getQuality()); 126 126 127 127 msg = disconnected ? "" : dim.getString(); … … 130 130 const Time &time() const { return info.first; } 131 131 const int &state() const { return info.second; } 132 133 bool online() const { return info.second>-4; } 132 134 133 135 const string &name() const { return server; } … … 211 213 } 212 214 215 // ------------------------------------------------------------------- 216 213 217 bool HandleService(DimInfo *curr, const DimInfo &service, void (StateMachineSmartFACT::*handle)(const DimData &)) 214 218 { … … 239 243 240 244 template<class T> 241 void WriteBinary(const string &fname, const T &t, double scale, double offset=0)245 void WriteBinary(const DimData &d, const string &fname, const T &t, double scale, double offset=0) 242 246 { 243 247 vector<uint8_t> val(t.size(), 0); … … 255 259 256 260 ofstream fout(fPath+"/"+fname+".bin"); 261 fout << d.time.JavaDate() << '\n'; 257 262 fout << offset << '\n'; 258 263 fout << offset+scale << '\n'; … … 324 329 ofstream(fPath+"/"+name+".txt") << out.str(); 325 330 326 WriteBinary( "magicweather-"+name+"-hist", fMagicWeatherHist[i], max-min, min);331 WriteBinary(d, "magicweather-"+name+"-hist", fMagicWeatherHist[i], max-min, min); 327 332 } 328 333 … … 472 477 473 478 // Write the 160 patch values to a file 474 WriteBinary( "feedback-deviation", dev, 1);479 WriteBinary(d, "feedback-deviation", dev, 1); 475 480 476 481 const Statistics stat(dev, 3); 477 482 478 483 ostringstream out; 479 out << setprecision(3);480 484 out << d.time.JavaDate() << '\n'; 481 485 out << kHtmlWhite << '\t' << fFeedbackUserOffset << '\n'; 486 out << setprecision(3); 482 487 out << kHtmlWhite << '\t' << fFeedbackTempOffset << '\n'; 483 488 out << kHtmlWhite << '\t' << stat.min << '\n'; … … 510 515 511 516 if (fDimBiasControl.state()==BIAS::kVoltageOn) 512 WriteBinary( "biascontrol-voltage", val, 10, 65);517 WriteBinary(d, "biascontrol-voltage", val, 10, 65); 513 518 else 514 WriteBinary( "biascontrol-voltage", val, 75);519 WriteBinary(d, "biascontrol-voltage", val, 75); 515 520 516 521 ostringstream out; … … 537 542 const bool cal = fFeedbackCalibration.size()>0 && fBiasControlVoltageVec.size()>0; 538 543 544 double power_tot = 0; 545 double power_apd = 0; 546 547 // 3900 Ohm/n + 1000 Ohm + 1100 Ohm (with n=4 or n=5) 548 const double R[2] = { 3075, 2870 }; 549 539 550 // Calibrate the data (subtract offset) 540 551 if (cal) 541 552 for (int i=0; i<320; i++) 542 553 { 554 // Measued current minus leakage current (bias crate calibration) 543 555 v[i] -= fBiasControlVoltageVec[i]/fFeedbackCalibration[i]*1e6; 544 v[i] /= fPixelMap.hv(i).group() ? 5 : 4; 556 557 // Total power participated in the camera at the G-APD 558 // and the serial resistors (total voltage minus voltage 559 // drop at resistors in bias crate) 560 power_tot += v[i]*(fBiasControlVoltageVec[i] - 1100e-6*v[i])*1e-6; 561 562 // Group index (0 or 1) of the of the pixel (4 or 5 pixel patch) 563 const int g = fPixelMap.hv(i).group(); 564 565 // Current per G-APD 566 v[i] /= g ? 5 : 4; 567 568 // Power consumption per G-APD 569 if (i!=66 && i!=191 && i!=193) 570 power_apd += v[i]*(fBiasControlVoltageVec[i]-R[g]*v[i]*1e-6)*1e-6; 545 571 } 572 573 // Divide by number of summed channels, concert to mW 574 power_apd /= 317e-3; // [mW] 575 576 if (power_tot<1e-3) 577 power_tot = 0; 578 if (power_apd<1e-3) 579 power_apd = 0; 546 580 547 581 // Get the maximum of each patch … … 554 588 555 589 // Write the 160 patch values to a file 556 WriteBinary( "biascontrol-current", val, 100);590 WriteBinary(d, "biascontrol-current", val, 100); 557 591 558 592 const Statistics stat(v, 0, 3); … … 568 602 569 603 // write the history to a file 570 WriteBinary( "biascontrol-current-hist", fBiasControlCurrentHist, 100);604 WriteBinary(d, "biascontrol-current-hist", fBiasControlCurrentHist, 100); 571 605 572 606 const string col0 = cal ? kHtmlGreen : kHtmlWhite; … … 598 632 599 633 ostringstream out; 600 out << setprecision( 3);634 out << setprecision(2); 601 635 out << d.time.JavaDate() << '\n'; 602 636 out << col0 << '\t' << (cal?"yes":"no") << '\n'; … … 605 639 out << col3 << '\t' << stat.avg << '\n'; 606 640 out << col4 << '\t' << stat.max << '\n'; 641 out << kHtmlWhite << '\t' << power_tot << "W [" << power_apd << "mW]\n"; 607 642 ofstream(fPath+"/current.txt") << out.str(); 608 643 } … … 689 724 // FIXME: Add statistics for all kind of rates 690 725 691 WriteBinary( "ftmcontrol-triggerrate-hist",726 WriteBinary(d, "ftmcontrol-triggerrate-hist", 692 727 fFtmControlTriggerRateHist, 100); 693 WriteBinary( "ftmcontrol-boardrates",728 WriteBinary(d, "ftmcontrol-boardrates", 694 729 vector<float>(brates, brates+40), 10); 695 WriteBinary( "ftmcontrol-patchrates",730 WriteBinary(d, "ftmcontrol-patchrates", 696 731 vector<float>(prates, prates+160), 10); 697 732 … … 731 766 vector<uint16_t> vec(ptr, ptr+160); 732 767 733 WriteBinary( "ftmcontrol-thresholds", vec, 1000);768 WriteBinary(d, "ftmcontrol-thresholds", vec, 1000); 734 769 735 770 const Statistics stat(vec); … … 768 803 switch (d.qos) 769 804 { 770 case 0: WriteBinary( "fadcontrol-eventdata", max, 2, -1); break;771 case 1: WriteBinary( "fadcontrol-eventdata", max, 2, 0); break;772 default: WriteBinary( "fadcontrol-eventdata", max, 0.25, 0); break;805 case 0: WriteBinary(d, "fadcontrol-eventdata", max, 2, -1); break; 806 case 1: WriteBinary(d, "fadcontrol-eventdata", max, 2, 0); break; 807 default: WriteBinary(d, "fadcontrol-eventdata", max, 0.25, 0); break; 773 808 } 774 809 } … … 827 862 ofstream(fPath+"/fsc.txt") << out.str(); 828 863 829 WriteBinary( "fsccontrol-temperature-hist",864 WriteBinary(d, "fsccontrol-temperature-hist", 830 865 fFscControlTemperatureHist, 30); 831 866 } … … 853 888 void HandleRateScanData(const DimData &d) 854 889 { 855 if (!CheckDataSize(d, "RateScan:Data", 24+200*40))890 if (!CheckDataSize(d, "RateScan:Data", 824)) 856 891 return; 857 892 … … 866 901 fRateScanDataHist.push_back(rate); 867 902 868 WriteBinary( "ratescan-hist", fRateScanDataHist, 10, -1);903 WriteBinary(d, "ratescan-hist", fRateScanDataHist, 10, -2); 869 904 } 870 905 … … 930 965 Out() << state.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - "; 931 966 Out() << kBold << state.name() << ": "; 967 if (rc.index==-3) 968 { 969 Out() << kReset << "Offline" << endl; 970 return; 971 } 932 972 if (rc.index==-2) 933 { 934 Out() << kReset << "Offline" << endl; 935 return; 936 } 937 Out() << rc.name << "[" << rc.index << "]"; 973 Out() << state.state(); 974 else 975 Out() << rc.name << "[" << rc.index << "]"; 938 976 Out() << kReset << " - " << kBlue << rc.comment << endl; 939 977 } … … 963 1001 string GetStateHtml(const DimState &state, int green) const 964 1002 { 1003 if (!state.online()) 1004 return kHtmlWhite+"\t—\n"; 1005 1006 if (&state==&fDimControl) 1007 { 1008 ostringstream out; 1009 out << kHtmlGreen << '\t'; 1010 return kHtmlGreen+'\t'+(state.state()==-3?"Idle":state.msg)+'\n'; 1011 } 1012 965 1013 const State rc = GetState(state); 966 1014 967 if (rc.index==-2 && state.state()>-2) 1015 // Sate not found in list, server online (-3: offline; -2: not found) 1016 if (rc.index==-2) 968 1017 { 969 1018 ostringstream out; 970 out << k White << '\t' << state.state() << '\n';1019 out << kHtmlWhite << '\t' << state.state() << '\n'; 971 1020 return out.str(); 972 1021 } … … 977 1026 978 1027 if (rc.index<1) 979 return kHtmlWhite + "\t ---\n";1028 return kHtmlWhite + "\t—\n"; 980 1029 981 1030 … … 1002 1051 1003 1052 ostringstream out; 1004 out << now.JavaDate() << '\ n';1053 out << now.JavaDate() << '\t' << fDimControl.online() << '\n'; 1005 1054 out << setprecision(3); 1006 1055 … … 1009 1058 { 1010 1059 string col = kHtmlBlue; 1011 if (fMcpConfigurationState!= 5 && 1012 fMcpConfigurationState!=11 && 1013 fMcpConfigurationState!=12) // 9 e.g. Configuring31060 if (fMcpConfigurationState!= 5 && // Idle 1061 fMcpConfigurationState!=11 && // Trigger On 1062 fMcpConfigurationState!=12) // Taking Data 1014 1063 col = kHtmlYellow; 1015 1064 else … … 1017 1066 col = kHtmlGreen; 1018 1067 1019 out << col << '\t' << fMcpConfigurationName;1020 1021 if (f McpConfigurationMaxEvents>0 || fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12)1022 out << " [";1023 if (fMcpConfigurationMaxEvents>0)1068 out << col << '\t'; 1069 1070 if (fDimRateControl.state()==5/*kStateSettingGlobalThreshold*/) 1071 out << "Rate control in progress"; 1072 else 1024 1073 { 1025 if (fFadControlNumEvents>0 && fMcpConfigurationState==12) 1026 out << fMcpConfigurationMaxEvents-fFadControlNumEvents; 1027 else 1028 out << fMcpConfigurationMaxEvents; 1074 if (fMcpConfigurationState!=5 && 1075 fMcpConfigurationState!=11 && 1076 fMcpConfigurationState!=12) 1077 out << "Configuring "; 1078 out << fMcpConfigurationName; 1029 1079 } 1030 if (fMcpConfigurationMaxEvents>0 && (fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12)) 1031 out << '/'; 1032 if (fMcpConfigurationMaxTime>0) 1080 1081 if (fDimMcp.state()>5 && fDimRateControl.state()!=5) 1033 1082 { 1034 if (fMcpConfigurationState==12) 1083 if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12) 1084 out << " ["; 1085 if (fMcpConfigurationMaxEvents>0) 1035 1086 { 1036 1037 const uint32_t dt = (Time()-fMcpConfigurationRunStart).total_seconds(); 1038 if (dt>fMcpConfigurationMaxTime) 1039 out << "---"; 1087 if (fFadControlNumEvents>0 && fMcpConfigurationState==12) 1088 out << fMcpConfigurationMaxEvents-fFadControlNumEvents; 1040 1089 else 1041 out << fMcpConfigurationMaxTime-dt << 's'; 1090 out << fMcpConfigurationMaxEvents; 1091 } 1092 if (fMcpConfigurationMaxEvents>0 && (fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12)) 1093 out << '/'; 1094 if (fMcpConfigurationMaxTime>0) 1095 { 1096 if (fMcpConfigurationState==12) 1097 { 1098 1099 const uint32_t dt = (Time()-fMcpConfigurationRunStart).total_seconds(); 1100 if (dt>fMcpConfigurationMaxTime) 1101 out << "---"; 1102 else 1103 out << fMcpConfigurationMaxTime-dt << 's'; 1104 } 1105 else 1106 out << fMcpConfigurationMaxTime << 's'; 1042 1107 } 1043 1108 else 1044 out << fMcpConfigurationMaxTime << 's'; 1109 { 1110 if (fMcpConfigurationState==12) 1111 { 1112 ostringstream d; 1113 d << Time()-fMcpConfigurationRunStart; 1114 out << d.str().substr(3, 5); 1115 } 1116 } 1117 1118 if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12) 1119 out << ']'; 1045 1120 } 1046 else1047 {1048 if (fMcpConfigurationState==12)1049 {1050 ostringstream d;1051 d << Time()-fMcpConfigurationRunStart;1052 out << d.str().substr(3, 5);1053 }1054 }1055 1056 if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12)1057 out << ']';1058 1121 } 1059 1122 else … … 1070 1133 if (rc.index==5) // Armed 1071 1134 col = kHtmlWhite; 1135 if (rc.index==7) // Tracking 1136 { 1137 if (fDriveControlTrackingDev>60) // ~1.5mm 1138 col = kHtmlYellow; 1139 if (fDriveControlTrackingDev>100) // ~1/4 of a pixel ~ 2.5mm 1140 col = kHtmlRed; 1141 } 1072 1142 out << col << '\t'; 1073 out << rc.name << '\t'; 1143 1144 //out << rc.name << '\t'; 1074 1145 out << fDriveControlPointingZd << '\t'; 1075 1146 out << fDriveControlPointingAz << '\t'; 1076 1147 if (fDimDriveControl.state()==7) 1077 1148 { 1149 out << fDriveControlSourceName << '\t'; 1078 1150 out << setprecision(2); 1079 out << fDriveControlTrackingDev << '\ t';1151 out << fDriveControlTrackingDev << '\n'; 1080 1152 out << setprecision(3); 1081 out << fDriveControlSourceName << '\n';1082 1153 } 1083 1154 else … … 1117 1188 out << col << '\t'; 1118 1189 out << fMagicWeatherHist[kHum].back() << '\t'; 1190 out << setprecision(2); 1119 1191 out << fMagicWeatherHist[kGusts].back() << '\n'; 1192 out << setprecision(3); 1120 1193 } 1121 1194 else … … 1123 1196 1124 1197 // --------------- FtmControl ------------- 1125 if (fDimFtmControl.state() >=FTM::kIdle)1198 if (fDimFtmControl.state()==FTM::kTriggerOn) 1126 1199 { 1127 1200 string col = kHtmlGreen; … … 1142 1215 fDimBiasControl.state()==BIAS::kVoltageOff) 1143 1216 { 1217 const bool off = fDimBiasControl.state()==BIAS::kVoltageOff; 1218 const bool oc = fDimBiasControl.state()==BIAS::kOverCurrent; 1219 1144 1220 string col = fBiasControlVoltageMed>3?kHtmlGreen:kHtmlWhite; 1145 1221 if (fBiasControlCurrentMax>65) … … 1170 1246 else 1171 1247 { 1248 out << setprecision(2); 1172 1249 out << col << '\t'; 1173 out << fBiasControlCurrentMed<< '\t';1174 if ( cal)1175 out << fBiasControlCurrentMax;1250 out << (off ? 0 : fBiasControlCurrentMed) << '\t'; 1251 if (oc) 1252 out << "(OC) "; 1176 1253 else 1177 out << "— "; 1254 { 1255 if (cal) 1256 out << (off ? 0 : fBiasControlCurrentMax); 1257 else 1258 out << "— "; 1259 } 1178 1260 out << '\t'; 1261 out << setprecision(3); 1179 1262 } 1180 out << fBiasControlVoltageMed<< '\n';1263 out << (off ? 0 : fBiasControlVoltageMed) << '\n'; 1181 1264 } 1182 1265 else … … 1191 1274 1192 1275 out.str(""); 1193 out << now.JavaDate() << '\ n';1276 out << now.JavaDate() << '\t' << fDimControl.online() << '\n'; 1194 1277 1195 1278 if (fDim.state()==0) … … 1200 1283 1201 1284 out << GetStateHtml(fDimMcp, 4); 1202 out << kHtmlWhite << '\t' << (fDimControl.state()>-2?fDimControl.msg:"---") << "\n";1285 out << GetStateHtml(fDimControl, 0); 1203 1286 out << GetStateHtml(fDimDataLogger, 1); 1204 1287 out << GetStateHtml(fDimDriveControl, 2);
Note:
See TracChangeset
for help on using the changeset viewer.