Changeset 14979
- Timestamp:
- 03/04/13 17:06:17 (12 years ago)
- Location:
- trunk/FACT++
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r14712 r14979 190 190 }; 191 191 192 description = state[name];192 description = name[state]; 193 193 194 194 const string arr = isday ? … … 592 592 593 593 template<class T> 594 void WriteBinaryVec(const Time &tm, const string &fname, const vector<T> &vec, double scale, double offset=0, const string &title="" )594 void WriteBinaryVec(const Time &tm, const string &fname, const vector<T> &vec, double scale, double offset=0, const string &title="", const string &col="") 595 595 { 596 596 if (vec.size()==0) … … 611 611 out << stat.max << '\x7f'; 612 612 } 613 if (!col.empty()) 614 out << col; 613 615 for (auto it=vec.begin(); it!=vec.end(); it++) 614 616 { … … 633 635 ofstream(fPath+"/"+fname+".bin") << out.str(); 634 636 } 635 637 /* 636 638 template<class T> 637 639 void WriteBinaryVec(const EventImp &d, const string &fname, const vector<T> &vec, double scale, double offset=0, const string &title="") … … 650 652 { 651 653 WriteBinaryVec(d.GetTime(), fname, vector<T>(&t, &t+1), scale, offset); 652 } 654 }*/ 655 656 template<class T> 657 void WriteHist(const EventImp &d, const string &fname, const T &t, double scale, double offset=0) 658 { 659 WriteBinaryVec(d.GetTime(), fname, vector<T>(&t, &t+1), scale, offset, "", "000"); 660 } 661 662 template<class T> 663 void WriteCam(const EventImp &d, const string &fname, const T &t, double scale, double offset=0) 664 { 665 WriteBinaryVec(d.GetTime(), fname, vector<T>(&t, &t+1), scale, offset, "", ""); 666 } 667 653 668 654 669 // ------------------------------------------------------------------- … … 741 756 #endif 742 757 743 // [0] DimControl::kReady (Idle) 744 // [1] DimControl::kLoad 745 // [2] DimControl::kStarted 758 // [0] DimControl::kIdle 759 // [1] DimControl::kLoading 760 // [2] DimControl::kCompiling 761 // [3] DimControl::kRinning 746 762 if (d.GetQoS()==1) 747 763 { … … 754 770 HandleControlMessageImp(Event(d, file.data(), file.length()+1)); 755 771 756 // Not that this will also "ding" just after program startup772 // Note that this will also "ding" just after program startup 757 773 // if the dimctrl is still in state -3 758 774 if (d.GetQoS()==0) … … 875 891 ofstream(fPath+"/"+name+".data") << out.str(); 876 892 877 Write Binary(d, "hist-magicweather-"+name, fMagicWeatherHist[i], max-min, min);893 WriteHist(d, "hist-magicweather-"+name, fMagicWeatherHist[i], max-min, min); 878 894 } 879 895 … … 938 954 const double scale = stat.max>0 ? pow(10, ceil(log10(stat.max))) : 0; 939 955 940 Write Binary(d, "hist-tng-dust", fTngWeatherDustHist, scale);956 WriteHist(d, "hist-tng-dust", fTngWeatherDustHist, scale); 941 957 942 958 ostringstream out; … … 1004 1020 fDriveControlTrackingDevHist.pop_front(); 1005 1021 1006 Write Binary(d, "hist-control-deviation", fDriveControlTrackingDevHist, 120);1022 WriteHist(d, "hist-control-deviation", fDriveControlTrackingDevHist, 120); 1007 1023 1008 1024 ostringstream out; … … 1094 1110 1095 1111 // Write the 160 patch values to a file 1096 Write Binary(d, "cam-feedback-deviation", dev, 1);1112 WriteCam(d, "cam-feedback-deviation", dev, 1); 1097 1113 1098 1114 const Statistics stat(dev, 3); … … 1134 1150 1135 1151 if (fDimBiasControl.state()==BIAS::State::kVoltageOn) 1136 Write Binary(d, "cam-biascontrol-voltage", val, 10, 65);1152 WriteCam(d, "cam-biascontrol-voltage", val, 10, 65); 1137 1153 else 1138 Write Binary(d, "cam-biascontrol-voltage", val, 75);1154 WriteCam(d, "cam-biascontrol-voltage", val, 75); 1139 1155 1140 1156 ostringstream out; … … 1210 1226 1211 1227 // Write the 160 patch values to a file 1212 Write Binary(d, "cam-biascontrol-current", val, 100);1228 WriteCam(d, "cam-biascontrol-current", val, 100); 1213 1229 1214 1230 const Statistics stat(v, 0, 3); … … 1224 1240 1225 1241 // write the history to a file 1226 Write Binary(d, "hist-biascontrol-current", fBiasControlCurrentHist, 100);1242 WriteHist(d, "hist-biascontrol-current", fBiasControlCurrentHist, 100); 1227 1243 1228 1244 const string col0 = cal ? HTML::kGreen : HTML::kWhite; … … 1414 1430 // FIXME: Add statistics for all kind of rates 1415 1431 1416 Write Binary(d, "hist-ftmcontrol-triggerrate",1417 1418 Write Binary(d, "cam-ftmcontrol-boardrates",1419 1420 Write Binary(d, "cam-ftmcontrol-patchrates",1421 1432 WriteHist(d, "hist-ftmcontrol-triggerrate", 1433 fFtmControlTriggerRateHist, 100); 1434 WriteCam(d, "cam-ftmcontrol-boardrates", 1435 vector<float>(brates, brates+40), 10); 1436 WriteCam(d, "cam-ftmcontrol-patchrates", 1437 vector<float>(prates, prates+160), 10); 1422 1438 1423 1439 ostringstream out; … … 1462 1478 vector<uint16_t> vecb(dat.fMultiplicity, dat.fMultiplicity+40); 1463 1479 1464 Write Binary(d, "cam-ftmcontrol-thresholds-patch", vecp, 1000);1465 Write Binary(d, "cam-ftmcontrol-thresholds-board", vecb, 100);1480 WriteCam(d, "cam-ftmcontrol-thresholds-patch", vecp, 1000); 1481 WriteCam(d, "cam-ftmcontrol-thresholds-board", vecb, 100); 1466 1482 1467 1483 const Statistics statp(vecp); … … 1597 1613 switch (fFadControlDrsStep) 1598 1614 { 1599 case 0: Write Binary(d, "cam-fadcontrol-eventdata", max, 2, -1); break;1600 case 1: Write Binary(d, "cam-fadcontrol-eventdata", max, 2, 0); break;1601 default: Write Binary(d, "cam-fadcontrol-eventdata", max, 0.25, 0); break;1615 case 0: WriteCam(d, "cam-fadcontrol-eventdata", max, 2, -1); break; 1616 case 1: WriteCam(d, "cam-fadcontrol-eventdata", max, 2, 0); break; 1617 default: WriteCam(d, "cam-fadcontrol-eventdata", max, 0.25, 0); break; 1602 1618 } 1603 1619 … … 1674 1690 ofstream(fPath+"/fsc.data") << out.str(); 1675 1691 1676 Write Binary(d, "hist-fsccontrol-temperature",1677 1692 WriteHist(d, "hist-fsccontrol-temperature", 1693 fFscControlTemperatureHist, 10); 1678 1694 1679 1695 return GetCurrentState(); … … 1730 1746 fRateScanBoard %= 40; 1731 1747 1732 Write Binary(d, "hist-ratescan", fRateScanDataHist[0], 10, -2);1733 Write Binary(d,"cam-ratescan-board", fRateScanDataHist[fRateScanBoard+1], 10, -4);1748 WriteHist(d, "hist-ratescan", fRateScanDataHist[0], 10, -2); 1749 WriteCam(d, "cam-ratescan-board", fRateScanDataHist[fRateScanBoard+1], 10, -4); 1734 1750 1735 1751 ostringstream out; … … 1764 1780 fRateControlThreshold.pop_front(); 1765 1781 1766 Write Binary(d, "hist-ratecontrol-threshold", fRateControlThreshold, 1000);1782 WriteHist(d, "hist-ratecontrol-threshold", fRateControlThreshold, 1000); 1767 1783 1768 1784 return GetCurrentState(); … … 1997 2013 const double angle = m.Angle(src->ra, src->dec); 1998 2014 1999 const double lc = angle*hrz.alt*pow(disk, 6)/360/360; 2000 2001 cur = 7.7+4942*lc; 2015 // Current prediction 2016 const double cang = sin(angle *M_PI/180); 2017 const double calt = sin(hrz.alt*M_PI/180); 2018 2019 const double lc = calt>0 ? cang*sqrt(calt)*pow(disk, 3) : -1; 2020 cur = lc>0 ? 8+104.5*lc : -1; 2002 2021 2003 2022 vec.push_back(cur); // Covert LC to pixel current in uA … … 2087 2106 out4 << now.JavaDate() << '\n'; 2088 2107 2089 multimap<Time, pair<string, float>> culmination; 2090 multimap<Time, pair<string, float>> lightcond; 2108 struct Entry 2109 { 2110 string name; 2111 float value; 2112 int color; 2113 Entry(const string &n, float v, int c) : name(n), value(v), color(c%8) { } 2114 2115 const string &Col() const 2116 { 2117 // If this list is updatd the number count in the constructor needs 2118 // to be updated, too 2119 static const string hcol[] = { "888", "8cf", "c8f", "bbb", "8fc", "cf8", "f8c", "fc8" }; 2120 return hcol[color]; 2121 } 2122 2123 vector<float> GetColor(double scale, double offset=0) const 2124 { 2125 vector<float> rc(3); 2126 rc[0] = double(Col()[0])*scale/126+offset; 2127 rc[1] = double(Col()[1])*scale/126+offset; 2128 rc[2] = double(Col()[2])*scale/126+offset; 2129 return rc; 2130 } 2131 }; 2132 2133 multimap<Time, Entry> culmination; 2134 multimap<Time, Entry> lightcond; 2091 2135 vector<vector<float>> alt; 2092 2136 vector<vector<float>> cur; … … 2097 2141 observer.lat = lat; 2098 2142 2099 const pair<vector<float>, pair<Time, float>> vism = GetVisibility(0, &observer, now.JD()); 2143 int ccol = 0; 2144 int lcol = 0; 2145 2146 /*const*/ pair<vector<float>, pair<Time, float>> vism = GetVisibility(0, &observer, now.JD()); 2100 2147 if (vism.first.size()>0) 2101 2148 { 2149 const Entry entry("Moon", vism.second.second, ccol); 2150 culmination.insert(make_pair(vism.second.first, entry)); 2151 const vector<float> col = entry.GetColor(75, 15); 2152 vism.first.insert(vism.first.begin(), col.begin(), col.end()); 2102 2153 alt.push_back(vism.first); 2103 culmination.insert(make_pair(vism.second.first, make_pair("Moon", vism.second.second))); 2154 2155 ccol++; 2104 2156 } 2105 2157 #endif … … 2129 2181 ln_get_hrz_from_equ(&pos, &observer, now.JD(), &hrz); 2130 2182 2131 constpair<vector<float>, pair<Time, float>> vis = GetVisibility(&pos, &observer, now.JD());2183 /*const*/ pair<vector<float>, pair<Time, float>> vis = GetVisibility(&pos, &observer, now.JD()); 2132 2184 if (vis.first.size()>0) 2133 2185 { 2186 const Entry entry(name, vis.second.second, ccol); 2187 culmination.insert(make_pair(vis.second.first, entry)); 2188 const vector<float> col = entry.GetColor(75, 15); 2189 vis.first.insert(vis.first.begin(), col.begin(), col.end()); 2134 2190 alt.push_back(vis.first); 2135 culmination.insert(make_pair(vis.second.first, make_pair(name, vis.second.second))); 2136 2137 const pair<vector<float>, pair<Time, float>> lc = GetLightCondition(&pos, &observer, now.JD()); 2191 2192 ccol++; 2193 2194 /*const*/ pair<vector<float>, pair<Time, float>> lc = GetLightCondition(&pos, &observer, now.JD()); 2138 2195 if (lc.first.size()>0) 2139 2196 { 2197 const Entry entry2(name, lc.second.second, lcol); 2198 lightcond.insert(make_pair(lc.second.first, entry2)); 2199 const vector<float> col2 = entry2.GetColor(100); 2200 lc.first.insert(lc.first.begin(), col2.begin(), col2.end()); 2140 2201 cur.push_back(lc.first); 2141 lightcond.insert(make_pair(lc.second.first, make_pair(name, lc.second.second))); 2202 2203 lcol++; 2142 2204 } 2143 2205 } … … 2172 2234 for (auto it=culmination.begin(); it!=culmination.end(); it++) 2173 2235 { 2236 const Entry &e = it->second; 2174 2237 if (it!=culmination.begin()) 2175 2238 out3 << ", "; 2176 out3 << "<B >" << it->second.first<< "</B>";2177 if ( it->second.second>0)2178 out3 << " [" << nearbyint(90- it->second.second) << "°]";2239 out3 << "<B#" << e.Col() << ">" << e.name << "</B>"; 2240 if (e.value>0) 2241 out3 << " [" << nearbyint(90-e.value) << "°]"; 2179 2242 } 2180 2243 2181 2244 out4 << setprecision(3); 2245 2182 2246 for (auto it=lightcond.begin(); it!=lightcond.end(); it++) 2183 2247 { 2248 const Entry &e = it->second; 2184 2249 if (it!=lightcond.begin()) 2185 2250 out4 << ", "; 2186 out4 << "<B >" << it->second.first<< "</B>";2187 if ( it->second.second>0)2188 out4 << " [" << nearbyint( it->second.second) << "]";2251 out4 << "<B#" << e.Col() << ">" << e.name << "</B>"; 2252 if (e.value>0) 2253 out4 << " [" << nearbyint(e.value) << "]"; 2189 2254 } 2190 2255 -
trunk/FACT++/www/smartfact/index.js
r14677 r14979 1091 1091 form = "—"; 1092 1092 1093 form = form.replace(/<B#(.*?)>/g, "<b style='background:#$1'>"); 1093 1094 form = form.replace(/<#(.*?)>/g, "<font color='$1'>"); 1094 1095 form = form.replace(/<([\+-])>/g, "<font size='$11'>"); … … 1430 1431 1431 1432 ctx.strokeStyle = "#666"; 1433 ctx.fillStyle = "#"+color(100); 1432 1434 1433 1435 // --- data --- … … 1435 1437 for (var j=1; j<data.length; j++) 1436 1438 { 1437 if (data[j].length< 2)1439 if (data[j].length<5) 1438 1440 continue; 1441 1442 ctx.strokeStyle = "#"+data[j].substr(0, 3); 1443 data[j] = data[j].substr(3); 1439 1444 1440 1445 ctx.beginPath(); … … 1446 1451 ctx.lineTo(cw-mr, ch-mb); 1447 1452 ctx.lineTo(ml, ch-mb); 1448 ctx.fillStyle = "#"+color(100);1449 1453 ctx.stroke(); 1450 1454
Note:
See TracChangeset
for help on using the changeset viewer.