Changeset 14767
- Timestamp:
- 01/09/13 16:11:42 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/scripts/Main.js
r14766 r14767 76 76 // ---------------------------------------------------------------- 77 77 78 78 //DN: the name of the Subscription object 'service_con' is not really 79 // telling that its a subscription to FAD_CONTROL/CONNECTIONS 80 // fad_connections sound ok for be, since 81 // fad_connections.onchange() is pretty clear 82 // fad_connections.reconnect() is not really good, but at least it has FAD in it. 79 83 var service_con = new Subscription("FAD_CONTROL/CONNECTIONS"); 84 /** 85 * call-back function of FAD_CONTROL/CONNECTIONS 86 * store IDs of problematic FADs 87 * 88 */ 80 89 service_con.onchange = function(evt) 81 90 { … … 94 103 } 95 104 105 /** 106 * reconnect to problematic FADs 107 * 108 * Dis- and Reconnects to FADs, found to be problematic by call-back function 109 * onchange() to have a different CONNECTION value than 66 or 67. 110 * 111 * @returns 112 * a boolean is returned. 113 * reconnect returns true if: 114 * * nothing needed to be reset --> no problems found by onchange() 115 * * the reconnection went fine. 116 * 117 * reconnect *never returns false* so far. 118 * 119 * @example 120 * if (!service_con.reconnect()) 121 * exit(); 122 */ 96 123 service_con.reconnect = function() 97 124 { 125 // this.reset is a list containing the IDs of FADs, 126 // which have neither CONNECTION==66 nor ==67, whatever this means :-) 98 127 if (this.reset.length==0) 99 128 return true; … … 129 158 dim.send("MCP/START", time?time:-1, count?count:-1, type); 130 159 160 161 131 162 // What could be a reasonable timeout here? 132 163 // FIXME: Replace by callback? 164 // 165 // DN: I believe instead of waiting for 'TakingData' one could split this 166 // up into two checks with an extra condition: 167 // if type == 'data': 168 // wait until ThresholdCalibration starts: 169 // --> this time should be pretty identical for each run 170 // if this takes longer than say 3s: 171 // there might be a problem with one/more FADs 172 // 173 // wait until "TakingData": 174 // --> this seems to take even some minutes sometimes... 175 // (might be optimized rather soon, but still in the moment...) 176 // if this takes way too long: 177 // there might be something broken, 178 // so maybe a very high time limit is ok here. 179 // I think there is not much that can go wrong, 180 // when the Thr-Calib has already started. Still it might be nice 181 // If in the future RateControl is written so to find out that 182 // in case the threshold finding algorithm does 183 // *not converge as usual* 184 // it can complain, and in this way give a hint, that the weather 185 // might be a little bit too bad. 186 // else: 187 // wait until "TakingData": 188 // --> in a non-data run this time should be pretty short again 189 // if this takes longer than say 3s: 190 // there might be a problem with one/more FADs 191 // 192 133 193 if (!dim.wait("MCP", "TakingData", -300000) ) 134 194 { … … 137 197 dimctrl.setState(37); 138 198 dim.wait("MCP", "TakingData", 500); 139 140 199 } 141 200 dim.wait("MCP", "Idle"); … … 143 202 console.out(" Take run: end"); 144 203 204 // DN: currently reconnect() never returns false 205 // .. but it can fail of course. 145 206 if (!service_con.reconnect()) 146 207 exit(); … … 224 285 var service_feedback = new Subscription("FEEDBACK/DEVIATION"); 225 286 287 // DN: Why is voltageOff() implemented as 288 // a method of a Subscription to a specific Service 289 // I naively would think of voltageOff() as an unbound function. 290 // I seems to me it has to be a method of a Subscription object, in order 291 // to use the update counting method. But does it have to be 292 // a Subscription to FEEDBACK/DEVIATION, or could it work with other services as well? 293 service_feedback.voltageOff = function() 294 { 295 console.out(" Voltage off: start"); 296 297 var isOn = dim.state("BIAS_CONTROL").name=="VoltageOn"; 298 299 if (isOn) 300 { 301 console.out(" Voltage on: switch off"); 302 dim.send("BIAS_CONTROL/SET_ZERO_VOLTAGE"); 303 } 304 305 dim.wait("BIAS_CONTROL", "VoltageOff", 5000); 306 307 // FEEDBACK stays in CurrentCtrl when Voltage is off but output enabled 308 // dim.wait("FEEDBACK", "CurrentCtrlIdle", 1000); 309 310 console.out(" Voltage off: end"); 311 } 312 313 // DN: The name of the method voltageOn() in the context of the method 314 // voltageOff() is a little bit misleading, since when voltageOff() returns 315 // the caller can be sure the voltage is off, but when voltageOn() return 316 // this is not the case, in the sense, that the caller can now take data. 317 // instead the caller of voltageOn() *must* call waitForVoltageOn() afterwards 318 // in order to safely take good-quality data. 319 // This could lead to nasty bugs in the sense, that the second call might 320 // be forgotten by somebody 321 // 322 // so I suggest to rename voltageOn() --> prepareVoltageOn() 323 // waitForVoltageOn() stays as it is 324 // and one creates a third method called:voltageOn() like this 325 /* service_feedback.voltageOn = function() 326 * { 327 * this.prepareVoltageOn(); 328 * this.waitForVoltageOn(); 329 * } 330 * 331 * */ 332 // For convenience. 333 226 334 service_feedback.voltageOn = function() 227 335 { … … 257 365 } 258 366 259 service_feedback.voltageOff = function()260 {261 console.out(" Voltage off: start");262 263 var isOn = dim.state("BIAS_CONTROL").name=="VoltageOn";264 265 if (isOn)266 {267 console.out(" Voltage on: switch off");268 dim.send("BIAS_CONTROL/SET_ZERO_VOLTAGE");269 }270 271 dim.wait("BIAS_CONTROL", "VoltageOff", 5000);272 273 // FEEDBACK stays in CurrentCtrl when Voltage is off but output enabled274 // dim.wait("FEEDBACK", "CurrentCtrlIdle", 1000);275 276 console.out(" Voltage off: end");277 }278 367 279 368 … … 436 525 return observations.length-1; 437 526 } 527 528 529 // DN: using so called magic numbers to encode certain 530 // states of the logic is considered pretty bad coding as far as I understand. 531 // the reader at this point has no idea why run is -2 ... this is the first time she 532 // reads about this variable and there is not a word of explanation found. 438 533 var run = -2; 439 534 var lastObs;
Note:
See TracChangeset
for help on using the changeset viewer.