- Timestamp:
- 07/22/14 13:44:52 (10 years ago)
- Location:
- trunk/FACT++/scripts
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/scripts/CheckStates.js
r16874 r17922 40 40 * 41 41 */ 42 function checkStates(table, timeout )42 function checkStates(table, timeout, wait) 43 43 { 44 44 if (timeout===undefined) … … 69 69 continue; 70 70 71 dim.log(table[i][0]+" in ["+states[i]+"] not as it ought to be ["+table[i][1]+"]"); 71 if (!wait) 72 dim.log(table[i][0]+" in ["+states[i]+"] not as it ought to be ["+table[i][1]+"]"); 73 72 74 rc = false; 73 75 } 74 75 return rc; 76 if (rc) 77 return rc; 78 79 if (!wait) 80 return false; 76 81 } 77 82 -
trunk/FACT++/scripts/Main.js
r17673 r17922 195 195 196 196 // ================================================================ 197 // Interrupt data taking in case of high currents 198 // ================================================================ 199 dim.onchange['FEEDBACK'] = function(state) 200 { 201 if ((state.name=="Critical" || state.name=="OnStandby") && 202 (this.prev!="Critical" && this.prev!="OnStandby")) 203 { 204 console.out("Feedback state changed from "+this.prev+" to "+state.name+" [Main.js]"); 205 irq = "RESCHEDULE"; 206 } 207 this.prev=state.name; 208 } 209 210 // ================================================================ 197 211 // Code related to switching bias voltage on and off 198 212 // ================================================================ … … 203 217 { 204 218 if (!evt.data) 219 return; 220 221 if (this.ok==undefined) 205 222 return; 206 223 … … 223 240 } 224 241 avg /= 320; 225 226 if (this.ok==undefined)227 return;228 229 242 230 243 this.ok = cnt<3;// || (this.last!=undefined && Math.abs(this.last-avg)<0.002); … … 306 319 ov = 1.1; 307 320 308 if (this.ov!=ov && dim.state("FEEDBACK").name=="InProgress") 321 if (this.ov!=ov && dim.state("FEEDBACK").name=="InProgress") // FIXME: Warning, OnStandby, Critical if (ov<this.ov) 309 322 { 310 323 dim.log("Stoping feedback."); … … 328 341 329 342 dim.send("FEEDBACK/START", ov); 343 344 // FIXME: We could miss "InProgress" if it immediately changes to "Warning" 345 // Maybe a dim.timeout state>8 ? 330 346 dim.wait("FEEDBACK", "InProgress", 45000); 331 347 … … 365 381 // ================================================================ 366 382 367 function Shutdown( )383 function Shutdown(singlepe) 368 384 { 369 385 dim.log("Starting shutdown."); … … 419 435 }*/ 420 436 421 dim.log("Taking single-pe run."); 422 423 // The voltage must be on 424 service_feedback.voltageOn(); 425 service_feedback.waitForVoltageOn(); 426 427 // Before we can switch to 3000 we have to make the right DRS calibration 428 dim.log("Taking single p.e. run."); 429 while (!irq && !takeRun("single-pe", 10000)); 437 if (singlepe) 438 { 439 dim.log("Taking single-pe run."); 440 441 // The voltage must be on 442 service_feedback.voltageOn(); 443 service_feedback.waitForVoltageOn(); 444 445 // Before we can switch to 3000 we have to make the right DRS calibration 446 dim.log("Taking single p.e. run."); 447 while (!irq && !takeRun("single-pe", 10000)); 448 } 430 449 431 450 // It is unclear what comes next, so we better switch off the voltage … … 528 547 "FTM_CONTROL/TRIGGER_RATES", 529 548 "GPS_CONTROL/NEMA", 549 "SQM_CONTROL/DATA", 530 550 "LID_CONTROL/DATA", 531 551 "MAGIC_LIDAR/DATA", … … 554 574 555 575 var list = obj.data.split('\n').map(map); 556 576 // [A 557 577 function check(name) 558 578 { … … 613 633 //console.out("Feedback init: start."); 614 634 service_feedback.get(5000); 615 616 //v8.timeout(3000, function() { var n = dim.state("FEEDBACK").name; if (n=="CurrentCtrlIdle" || n=="CurrentControl") return true; });617 635 618 636 // ---------------------------------------------------------------- … … 708 726 709 727 if (irq.toUpperCase()=="RESCHEDULE") 710 return true; 728 { 729 irq = undefined; 730 return false; 731 } 711 732 712 733 if (irq.toUpperCase()=="OFF") … … 716 737 return true; 717 738 } 739 740 /* 741 if (irq.toUpperCase()=="STOP") 742 { 743 dim.send("FAD_CONTROL/CLOSE_OPEN_FILES"); 744 dim.send("MCP/STOP"); 745 return true; 746 }*/ 718 747 719 748 if (irq.toUpperCase()=="SHUTDOWN") … … 817 846 } 818 847 819 // Check if sun is still up... only DATA and RATESCAN must be suppressed848 // Check if sun is still up... only DATA and */ 820 849 if ((obs[sub].task=="DATA" || obs[sub].task=="RATESCAN") && sun.isUp) 821 850 { … … 836 865 // otherwise it is difficult to allow e.g. the STARTUP at the beginning of the night 837 866 var power_states = sun.isUp || !system_on ? [ "DriveOff", "SystemOn" ] : [ "SystemOn" ]; 838 var drive_states = sun.isUp || !system_on ? undefined: [ "Armed", "Tracking", "OnTrack" ];867 var drive_states = sun.isUp || !system_on ? undefined : [ "Armed", "Tracking", "OnTrack" ]; 839 868 840 869 // A scheduled task was found, lets check if all servers are … … 858 887 [ "AGILENT_CONTROL_80V", [ "VoltageOn" ] ], 859 888 [ "BIAS_CONTROL", [ "VoltageOff", "VoltageOn", "Ramping" ] ], 860 [ "FEEDBACK", [ "Calibrated", "InProgress" ] ],889 [ "FEEDBACK", [ "Calibrated", "InProgress", "OnStandby", "Warning", "Critical" ] ], 861 890 [ "LID_CONTROL", [ "Open", "Closed" ] ], 862 891 [ "DRIVE_CONTROL", drive_states/*[ "Armed", "Tracking", "OnTrack" ]*/ ], … … 866 895 [ "RATE_CONTROL", [ "Connected", "GlobalThresholdSet", "InProgress" ] ], 867 896 [ "GPS_CONTROL", [ "Locked" ] ], 897 [ "SQM_CONTROL", [ "Valid" ] ], 868 898 ]; 869 899 … … 872 902 { 873 903 throw new Error("Something unexpected has happened. One of the servers "+ 874 "is in a state in which it should not be. Please,"+ 904 "is in a state in which it should not be. Please,"+ 875 905 "try to find out what happened..."); 876 906 } 877 907 878 datalogger_subscriptions.check(); 908 datalogger_subscriptions.check(); 909 910 // If this is an observation which needs the voltage to be swicthed on 911 // skip that if the voltage is not stable 912 /* 913 if (obs[sub].task=="DATA" || obs[sub].task=="RATESCAN") 914 { 915 var state = dim.state("FEEDBACK").name; 916 if (state=="Warning" || state=="Critical" || state=="OnStandby") 917 { 918 v8.sleep(1000); 919 continue; 920 } 921 }*/ 922 879 923 880 924 // Check if obs.task is one of the one-time-tasks … … 909 953 910 954 case "SHUTDOWN": 911 Shutdown( );955 Shutdown(true); 912 956 system_on = false; 913 957 … … 1037 1081 service_feedback.waitForVoltageOn(); 1038 1082 1039 var tm2 = new Date(); 1040 1041 dim.log("Starting ratescan."); 1042 1043 // Start rate scan 1044 dim.send("RATE_SCAN/START_THRESHOLD_SCAN", 50, 1000, -10); 1045 1046 // Lets wait if the ratescan really starts... this might take a few 1047 // seconds because RATE_SCAN configures the ftm and is waiting for 1048 // it to be configured. 1049 dim.wait("RATE_SCAN", "InProgress", 10000); 1050 dim.wait("RATE_SCAN", "Connected", 2700000); 1051 1052 // this line is actually some kind of hack. 1053 // after the Ratescan, no data is written to disk. I don't know why, but it happens all the time 1054 // So I decided to put this line here as a kind of patchwork.... 1055 //dim.send("FAD_CONTROL/SET_FILE_FORMAT", 6); 1056 1057 dim.log("Ratescan done [%.1fs, %.1fs]".$((tm2-tm1)/1000, (new Date()-tm2)/1000)); 1083 if (!irq) 1084 { 1085 var tm2 = new Date(); 1086 1087 dim.log("Starting ratescan."); 1088 1089 // Start rate scan 1090 dim.send("RATE_SCAN/START_THRESHOLD_SCAN", 50, 1000, -10); 1091 1092 // Lets wait if the ratescan really starts... this might take a few 1093 // seconds because RATE_SCAN configures the ftm and is waiting for 1094 // it to be configured. 1095 dim.wait("RATE_SCAN", "InProgress", 10000); 1096 dim.wait("RATE_SCAN", "Connected", 2700000); 1097 1098 // Here one could implement a watchdog for the feedback as well, but what is the difference 1099 // whether finally one has to find out if the feedback was in the correct state 1100 // or the ratescan was interrupted? 1101 1102 // this line is actually some kind of hack. 1103 // after the Ratescan, no data is written to disk. I don't know why, but it happens all the time 1104 // So I decided to put this line here as a kind of patchwork.... 1105 //dim.send("FAD_CONTROL/SET_FILE_FORMAT", 6); 1106 1107 dim.log("Ratescan done [%.1fs, %.1fs]".$((tm2-tm1)/1000, (new Date()-tm2)/1000)); 1108 } 1109 1058 1110 dim.log("Task finished [RATESCAN]"); 1059 1111 console.out(""); … … 1072 1124 } 1073 1125 */ 1126 1074 1127 // Calculate remaining time for this observation in minutes 1075 1128 var remaining = nextObs==undefined ? 0 : (nextObs.start-new Date())/60000; … … 1134 1187 1135 1188 if (irq) 1136 break;1189 continue; 1137 1190 1138 1191 OpenLid(); … … 1140 1193 // This is now th right time to wait for th drive to be stable 1141 1194 dim.wait("DRIVE_CONTROL", "OnTrack", 150000); // 110s for turning and 30s for stabilizing 1195 1196 // Now check the voltage... (do not start a lot of stuff just to do nothing) 1197 var state = dim.state("FEEDBACK").name; 1198 if (state=="Warning" || state=="Critical" || state=="OnStandby") 1199 { 1200 v8.sleep(60000); 1201 continue; 1202 } 1142 1203 1143 1204 // Now we are 'OnTrack', so we can ramp to nominal voltage … … 1147 1208 1148 1209 // If pointing had changed, do calibration 1149 if ( point)1210 if (!irq && point) 1150 1211 { 1151 1212 dim.log("Starting calibration."); … … 1177 1238 { 1178 1239 var len = 300; 1179 while ( len>15)1240 while (!irq && len>15) 1180 1241 { 1181 1242 var time = new Date(); -
trunk/FACT++/scripts/Startup.js
r17673 r17922 96 96 loop.add(handleFeedbackConnected); // Feedback needs FAD to be Connected 97 97 loop.add(handleRatectrlConnected); 98 //loop.add(handleLidClosed);98 loop.add(handleLidClosed); 99 99 loop.run(); 100 100 … … 194 194 if ((dim.state("PWR_CONTROL").index&16)==0) 195 195 { 196 console.out("Drive cabinet not power ... Switching on.");196 console.out("Drive cabinet not powered... Switching on."); 197 197 dim.send("PWR_CONTROL/TOGGLE_DRIVE"); 198 198 v8.timeout(5000, function() { if (dim.state("PWR_CONTROL").index&16) return true; }); … … 290 290 // ================================================================ 291 291 292 // FIXME: Check if there is a startup s hceduled, if not do not force292 // FIXME: Check if there is a startup scheduled, if not do not force 293 293 // drive to be switched on 294 294 … … 300 300 [ "SMART_FACT" ], 301 301 [ "TEMPERATURE" ], 302 [ "EVENT_SERVER", [ "Running", "Standby" ] ], 302 303 [ "DATA_LOGGER", [ "NightlyFileOpen", "WaitForRun", "Logging" ] ], 303 304 [ "FSC_CONTROL", [ "Connected" ] ], … … 312 313 [ "RATE_SCAN", [ "Connected" ] ], 313 314 [ "RATE_CONTROL", [ "Connected" ] ], 315 [ "DRIVE_CONTROL", [ "Armed", "Tracking", "OnTrack", "Locked" ] ], 314 316 [ "LID_CONTROL", [ "Open", "Closed" ] ], 315 [ "DRIVE_CONTROL", [ "Armed", "Tracking", "OnTrack", "Locked" ] ],316 317 [ "FTM_CONTROL", [ "Valid", "TriggerOn" ] ], 317 318 [ "FAD_CONTROL", [ "Connected", "WritingData" ] ], 318 319 [ "GPS_CONTROL", [ "Locked" ] ], 320 [ "SQM_CONTROL", [ "Valid" ] ], 319 321 ]; 322 323 320 324 321 325 if (!checkStates(table)) -
trunk/FACT++/scripts/takeRun.js
r17352 r17922 173 173 //} 174 174 175 // ================================================================ 176 // Function for Critical voltage 177 // ================================================================ 178 179 // INSTALL a watchdog... send FAD_CONTROL/CLOSE_OPEN_FILES 180 // could send MCP/RESET as well but would result in a timeout 181 var callback = dim.onchange['FEEDBACK']; 182 dim.onchange['FEEDBACK'] = function(state) 183 { 184 if (callback) 185 callback.call(this, state); 186 187 if ((state.name=="Critical" || state.name=="OnStandby") && 188 (this.last!="Critical" && this.last!="OnStandby")) 189 { 190 console.out("Feedback state changed from "+this.last+" to "+state.name+" [takeRun.js]"); 191 192 // Includes FAD_CONTROL/CLOSE_ALL_OPEN_FILES 193 dim.send("MCP/STOP"); 194 } 195 196 this.last=state.name; 197 } 198 175 199 // Here we could check and handle fad losses 176 200 … … 241 265 } 242 266 267 // This is to check if we have missed the event. This can happen as 268 // a race condition when the MCP/STOP is sent by the event handler 269 // but the run was not yet fully configured. 270 var statefb = dim.state("FEEDBACK").name; 271 if (statefb=="Critical" || statefb=="OnStandby") 272 { 273 console.out("Run started by FEEDBACK in state "+statefb); 274 dim.send("MCP/STOP"); // Includes FAD_CONTROL/CLOSE_ALL_OPEN_FILES 275 276 dim.onchange['FEEDBACK'] = callback; 277 278 return true; 279 } 280 243 281 dim.wait("MCP", "Idle", time>0 ? time*1250 : undefined); // run time plus 25% 282 283 // REMOVE watchdog 284 dim.onchange['FEEDBACK'] = callback; 244 285 245 286 if (incomplete)
Note:
See TracChangeset
for help on using the changeset viewer.