Changeset 13849
- Timestamp:
- 05/23/12 21:12:27 (13 years ago)
- Location:
- trunk/FACT++
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r13847 r13849 304 304 // ======================================================================== 305 305 306 class StateMachineSmartFACT : public StateMachineDim //, public DimInfoHandler306 class StateMachineSmartFACT : public StateMachineDim 307 307 { 308 308 private: … … 407 407 void WriteBinary(const EventImp &d, const string &fname, const T &t, double scale, double offset=0) 408 408 { 409 const Statistics stat(t); 410 409 411 vector<uint8_t> val(t.size(), 0); 410 412 for (uint64_t i=0; i<t.size(); i++) … … 424 426 out << offset << '\n'; 425 427 out << offset+scale << '\n'; 428 out << setprecision(3); 429 out << stat.min << '\n'; 430 out << stat.med << '\n'; 431 out << stat.max << '\n'; 426 432 out.write(ptr, val.size()*sizeof(uint8_t)); 427 433 … … 1391 1397 1392 1398 // -------------- System status -------------- 1393 if (f McpConfigurationState>=5) // Idle1399 if (fDimMcp.state()>=5) // Idle 1394 1400 { 1395 1401 string col = kHtmlBlue; -
trunk/FACT++/www/smartfact/index.js
r13845 r13849 204 204 switch (args[i]) 205 205 { 206 case "max": $("body").setAttribute("data-max", "yes"); continue; 206 case "max": $("body").setAttribute("data-max", "yes"); continue; 207 case "noslide": $("body").setAttribute("data-noslide", "yes"); continue; 207 208 } 208 209 … … 802 803 803 804 var W = window.innerWidth; 804 if (W==0) 805 { 806 $("table"+newz).style.left="0px"; 805 if (W==0 || $("body").getAttribute("data-noslide")=="yes") 806 { 807 807 $("body").setAttribute("data-visible", newz); 808 808 $("body").removeChild($("table"+oldz)); 809 $("table"+newz).style.left="0px"; 809 810 return; 810 811 } … … 819 820 // This is needed on my mobile to ensure that te browser 820 821 // doesn't try to zoom during shifting 821 //$("table"+newz).style.position="fixed";822 //$("table"+oldz).style.position="fixed";822 $("table"+newz).style.position="fixed"; 823 $("table"+oldz).style.position="fixed"; 823 824 824 825 intervalSlide = setInterval(function(){doShift(oldz,newz)}, 75); … … 835 836 $("body").removeChild(t0); 836 837 837 //t1.style.position="absolute";838 t1.style.position="absolute"; 838 839 839 840 // Now the scroll bar might have to appear or disappear … … 1264 1265 } 1265 1266 1266 function drawCamLegend(canv, min, max) 1267 { 1267 function drawCamLegend(canv, data) 1268 { 1269 var umin = data[1]; 1270 var umax = data[2]; 1271 1268 1272 var unit = canv.getAttribute("data-data");//.split("/"); 1269 if (unit.length>0) 1270 unit = " "+unit; 1271 1272 var v0 = parseFloat(min); 1273 var v1 = parseFloat(max); 1273 unit = unit.replace("°", "\u00B0"); 1274 unit = unit.replace("°", "\u00B5"); 1275 1276 var min = data[3]+unit 1277 var med = data[4]+unit; 1278 var max = data[5]+unit; 1279 1280 var v0 = parseFloat(umin); 1281 var v1 = parseFloat(umax); 1274 1282 1275 1283 var diff = v1-v0; … … 1289 1297 ctx.strokeText((v0+diff*i/10).toPrecision(3)+unit, cw-5, 125-i*12); 1290 1298 } 1291 } 1292 1293 function drawGraph(canv, min, max, data) 1299 1300 var mw = Math.max(ctx.measureText(min).width, 1301 ctx.measureText(med).width, 1302 ctx.measureText(max).width); 1303 1304 ctx.textBaseline = "top"; 1305 ctx.strokeStyle = "#000"; 1306 1307 ctx.strokeText(min, 5+mw, 5); 1308 ctx.strokeText(med, 5+mw, 5+12); 1309 ctx.strokeText(max, 5+mw, 5+24); 1310 } 1311 1312 function drawGraph(canv, vals, data) 1294 1313 { 1295 1314 var unit = canv.getAttribute("data-data");//.split("/"); 1296 if (unit.length>0) 1297 unit = " "+unit; 1315 unit = unit.replace("°", "\u00B0"); 1316 unit = unit.replace("µ", "\u00B5"); 1317 1318 var umin = vals[1]+unit; 1319 var umax = vals[2]+unit; 1320 1321 var stat = vals[3]+unit+" / "+vals[4]+unit+" / "+vals[5]+unit; 1298 1322 1299 1323 var cw = canv.width; … … 1309 1333 ctx.textAlign = "right"; 1310 1334 1311 var dim0 = ctx.measureText( min+unit);1312 var dim1 = ctx.measureText( max+unit);1335 var dim0 = ctx.measureText(umin); 1336 var dim1 = ctx.measureText(umax); 1313 1337 1314 1338 var tw = Math.max(dim0.width, dim1.width)+dw+2; … … 1317 1341 var mr = 10; // margin right 1318 1342 1319 var mt = fs/2+5; // margin top1320 var mb = fs/2+4; // margin bottom1343 var mt = 5+2*fs+4; // margin top 1344 var mb = fs/2+4; // margin bottom 1321 1345 1322 1346 var nx = 20; … … 1352 1376 for (var i=1; i<=nx; i++) 1353 1377 { 1354 ctx.moveTo(ml+w /nx*i, ch-mb);1355 ctx.lineTo(ml+w /nx*i, mt);1378 ctx.moveTo(ml+w*i/nx, ch-mb); 1379 ctx.lineTo(ml+w*i/nx, mt); 1356 1380 } 1357 1381 for (var i=0; i<ny; i++) 1358 1382 { 1359 ctx.moveTo(ml, m b+h/ny*i);1360 ctx.lineTo(ml+w, m b+h/ny*i);1383 ctx.moveTo(ml, mt+h*i/ny); 1384 ctx.lineTo(ml+w, mt+h*i/ny); 1361 1385 } 1362 1386 ctx.stroke(); … … 1373 1397 for (var i=1; i<=nx; i++) 1374 1398 { 1375 ctx.moveTo(ml+w /nx*i, ch-mb-dw);1376 ctx.lineTo(ml+w /nx*i, ch-mb+dw);1399 ctx.moveTo(ml+w*i/nx, ch-mb-dw); 1400 ctx.lineTo(ml+w*i/nx, ch-mb+dw); 1377 1401 } 1378 1402 for (var i=0; i<ny; i++) 1379 1403 { 1380 ctx.moveTo(ml-dw, m b+h/ny*i);1381 ctx.lineTo(ml+dw, m b+h/ny*i);1404 ctx.moveTo(ml-dw, mt+h*i/ny); 1405 ctx.lineTo(ml+dw, mt+h*i/ny); 1382 1406 } 1383 1407 ctx.stroke(); … … 1385 1409 1386 1410 ctx.textBaseline = "bottom"; 1387 ctx.strokeText(min+unit, ml-dw-2, ch-1); 1411 ctx.strokeText(umin, ml-dw-2, ch-1); 1412 1413 ctx.textBaseline = mt>fs/2 ? "middle" : "top"; 1414 ctx.strokeText(umax, ml-dw-2, mt); 1388 1415 1389 1416 ctx.textBaseline = "top"; 1390 ctx.strokeText(max+unit, ml-dw-2, 0); 1417 ctx.textAlign = "center"; 1418 ctx.strokeText(stat, ml+w/2, 5); 1391 1419 } 1392 1420 … … 1410 1438 return; 1411 1439 1412 var l = data[0].length+1+data[1].length+1+data[2].length+1; 1440 var len = 0; 1441 for (var i=0; i<6; i++) 1442 len += data[i].length+1; 1413 1443 1414 1444 switch (type) … … 1416 1446 //case "camera": drawCam(result); break; 1417 1447 case "hist": 1418 drawGraph(canv, data [1], data[2], result.substr(l));1448 drawGraph(canv, data, result.substr(len)); 1419 1449 break; 1420 1450 case "camera": 1421 drawFullCam(result.substr(l ));1422 drawCamLegend(canv, data [1], data[2]);1451 drawFullCam(result.substr(len)); 1452 drawCamLegend(canv, data); 1423 1453 break; 1424 1454 }
Note:
See TracChangeset
for help on using the changeset viewer.