Changeset 15048 for trunk/FACT++/scripts
- Timestamp:
- 03/13/13 11:09:52 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/scripts/CheckUnderflow.js
r15038 r15048 60 60 if (!runs) 61 61 throw new Error("Could not connect to FAD_CONTROL/DRS_RUNS"); 62 /*63 runs = {64 "name" : "FAD_CONTROL/DRS_RUNS",65 "format" : "I:1;I:3",66 "qos" : 0,67 "size" : 16,68 "counter" : 0,69 "time" : new Date("2012-11-20T05:23:52.804Z"),70 "data" : [300,[148,149,154]]71 };72 */73 62 74 63 // Wait for agilent to be online with state information … … 85 74 console.out(" * Last power cycle: "+power); 86 75 console.out(" * Last DRS calib set: "+(runs.data?runs.time:"none")); 87 //console.out(JSON.stringify(dim.state("AGILENT_CONTROL")));88 76 89 77 90 78 if (1)//diff>8 && now.getHours()>16 || runs.time<power) 91 79 { 80 console.out("Checking send."); 81 checkSend(["FAD_CONTROL", "MCP", "RATE_CONTROL"]); 82 console.out("Checking send: done"); 83 92 84 //console.out("Most probablay the camera has not been checked for underflows yet."); 93 94 // Wait for dim.send to be ready95 // FIXME: timeout96 while (!dim.send("FAD_CONTROL"))97 v8.sleep();98 99 // FAD_CONTROL/RAW_DATA:100 // roi,roi_tm,num_fad,num_ftm,type,num_boards,error,101 // dummy,time,time_board,start_pix,start_tm,adc102 103 // FAD_CONTROL/EVENT_DATA104 // avg,rms,max,pos105 85 106 86 var service_event = new Subscription("FAD_CONTROL/EVENT_DATA"); 107 87 var event = service_event.get(5000, false); 108 //if (!event)109 // throw new Error("Could not connect to FAD_CONTROL/EVENT_DATA");110 88 111 89 var event_counter = event.counter; … … 125 103 console.out("Event received: "+(new Date()-d)+"ms"); 126 104 127 console.out("Stop run");128 105 dim.send("MCP/STOP"); 129 while (!dim.send("RATE_CONTROL")) 130 { 131 v8.sleep(800); 132 console.out("waiting for RATE_CONTROL to send the necessary format information"); 133 } 106 107 event = service_event.get(0, false); 108 service_event.close(); 109 110 console.out("Run stopped."); 111 134 112 dim.send("RATE_CONTROL/STOP"); // GlobalThresholdSet -> Connected 135 113 dim.wait("MCP", "Idle", 3000); 136 114 137 var nn = run s.data && runs.data[0]>0 ? runs.data[1].reduce(Func.max) : -1;115 var nn = run.data && runs.data.length>0 && runs.obj['roi']>0 ? runs.obj['run'][1].reduce(Func.max) : -1; 138 116 if (nn>0) 139 117 { … … 154 132 } 155 133 156 //console.out(JSON.stringify(service_drs.get(0, false)));157 158 event = service_event.get(0, false);159 160 service_event.close();161 162 134 var hist = Hist2D(16, -2048.5, 2048.5, 11, -10, 100); 163 135 136 var data = event.obj; 137 164 138 for (var i=0; i<1440; i++) 165 hist.fill( event.data[0][i], isNaN(event.data[1][i])?-1:event.data[1][i]);139 hist.fill(data.avg[i], isNaN(data.rms[i])?-1:data.rms[i]); 166 140 167 //console.out(("%78s".$("")).replace(/ /g, "-"));168 141 hist.print(); 169 //console.out(("%78s".$("")).replace(/ /g, "-"));170 142 171 // Could also be <512 172 var stat0 = Func.stat(event.data[0], function(val) { if (val<0) console.out(" VAL="+val); return val<0; }); 173 var stat1 = Func.stat(event.data[1]); 143 var stat0 = Func.stat(data.avg, function(val) { if (val<0) console.out(" VAL="+val); return val<0; }); 144 var stat1 = Func.stat(data.rms); 174 145 175 146 console.out("Avg[min]=%.1f".$(stat0.min)); … … 182 153 console.out("Rms[max]=%.1f".$(stat1.max)); 183 154 console.out(("%78s\n".$("")).replace(/ /g, "=")); 155 156 // OK UNDERFLOW 157 // ------------------------------------------------------ 158 // Avg[min]=722.0 Avg[min]=-380.0 159 // Avg[avg]=815.9 +- 45.9 Avg[avg]= 808.0 +- 102.0 160 // Avg[max]=930.5 Avg[max]= 931.1 161 // Avg[cnt]=0 Avg[cnt]= 9 162 163 // Rms[min]=14.0 Rms[min]=13.9 164 // Rms[avg]=16.5 +- 1.6 Rms[avg]=18.8 +- 26.8 165 // Rms[max]=44.0 Rms[max]=382.1 166 167 if (stat0.count==0) 168 return; 169 170 if (stat0.count>8) 171 throw new Error("Underflow condition detected in about "+stat0.count/9+" DRS."); 172 173 log.warn("There is probably an underflow condition in one DRS... please check manually."); 184 174 } 185 175
Note:
See TracChangeset
for help on using the changeset viewer.