Changeset 17924 for trunk/FACT++/scripts
- Timestamp:
- 07/22/14 13:45:43 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/scripts/Main.js
r17922 r17924 195 195 196 196 // ================================================================ 197 // Interrupt data taking in case of high currents198 // ================================================================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 // ================================================================211 197 // Code related to switching bias voltage on and off 212 198 // ================================================================ … … 217 203 { 218 204 if (!evt.data) 219 return;220 221 if (this.ok==undefined)222 205 return; 223 206 … … 240 223 } 241 224 avg /= 320; 225 226 if (this.ok==undefined) 227 return; 228 242 229 243 230 this.ok = cnt<3;// || (this.last!=undefined && Math.abs(this.last-avg)<0.002); … … 319 306 ov = 1.1; 320 307 321 if (this.ov!=ov && dim.state("FEEDBACK").name=="InProgress") // FIXME: Warning, OnStandby, Critical if (ov<this.ov)308 if (this.ov!=ov && dim.state("FEEDBACK").name=="InProgress") 322 309 { 323 310 dim.log("Stoping feedback."); … … 341 328 342 329 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 ?346 330 dim.wait("FEEDBACK", "InProgress", 45000); 347 331 … … 381 365 // ================================================================ 382 366 383 function Shutdown( singlepe)367 function Shutdown() 384 368 { 385 369 dim.log("Starting shutdown."); … … 435 419 }*/ 436 420 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 } 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)); 449 430 450 431 // It is unclear what comes next, so we better switch off the voltage … … 547 528 "FTM_CONTROL/TRIGGER_RATES", 548 529 "GPS_CONTROL/NEMA", 549 "SQM_CONTROL/DATA",550 530 "LID_CONTROL/DATA", 551 531 "MAGIC_LIDAR/DATA", … … 574 554 575 555 var list = obj.data.split('\n').map(map); 576 // [A 556 577 557 function check(name) 578 558 { … … 633 613 //console.out("Feedback init: start."); 634 614 service_feedback.get(5000); 615 616 //v8.timeout(3000, function() { var n = dim.state("FEEDBACK").name; if (n=="CurrentCtrlIdle" || n=="CurrentControl") return true; }); 635 617 636 618 // ---------------------------------------------------------------- … … 726 708 727 709 if (irq.toUpperCase()=="RESCHEDULE") 728 { 729 irq = undefined; 730 return false; 731 } 710 return true; 732 711 733 712 if (irq.toUpperCase()=="OFF") … … 737 716 return true; 738 717 } 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 }*/747 718 748 719 if (irq.toUpperCase()=="SHUTDOWN") … … 846 817 } 847 818 848 // Check if sun is still up... only DATA and */819 // Check if sun is still up... only DATA and RATESCAN must be suppressed 849 820 if ((obs[sub].task=="DATA" || obs[sub].task=="RATESCAN") && sun.isUp) 850 821 { … … 865 836 // otherwise it is difficult to allow e.g. the STARTUP at the beginning of the night 866 837 var power_states = sun.isUp || !system_on ? [ "DriveOff", "SystemOn" ] : [ "SystemOn" ]; 867 var drive_states = sun.isUp || !system_on ? undefined: [ "Armed", "Tracking", "OnTrack" ];838 var drive_states = sun.isUp || !system_on ? undefined : [ "Armed", "Tracking", "OnTrack" ]; 868 839 869 840 // A scheduled task was found, lets check if all servers are … … 887 858 [ "AGILENT_CONTROL_80V", [ "VoltageOn" ] ], 888 859 [ "BIAS_CONTROL", [ "VoltageOff", "VoltageOn", "Ramping" ] ], 889 [ "FEEDBACK", [ "Calibrated", "InProgress" , "OnStandby", "Warning", "Critical"] ],860 [ "FEEDBACK", [ "Calibrated", "InProgress" ] ], 890 861 [ "LID_CONTROL", [ "Open", "Closed" ] ], 891 862 [ "DRIVE_CONTROL", drive_states/*[ "Armed", "Tracking", "OnTrack" ]*/ ], … … 895 866 [ "RATE_CONTROL", [ "Connected", "GlobalThresholdSet", "InProgress" ] ], 896 867 [ "GPS_CONTROL", [ "Locked" ] ], 897 [ "SQM_CONTROL", [ "Valid" ] ],898 868 ]; 899 869 … … 902 872 { 903 873 throw new Error("Something unexpected has happened. One of the servers "+ 904 "is in a state in which it should not be. Please,"+ 874 "is in a state in which it should not be. Please,"+ 905 875 "try to find out what happened..."); 906 876 } 907 877 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 878 datalogger_subscriptions.check(); 923 879 924 880 // Check if obs.task is one of the one-time-tasks … … 953 909 954 910 case "SHUTDOWN": 955 Shutdown( true);911 Shutdown(); 956 912 system_on = false; 957 913 … … 1081 1037 service_feedback.waitForVoltageOn(); 1082 1038 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 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)); 1110 1058 dim.log("Task finished [RATESCAN]"); 1111 1059 console.out(""); … … 1124 1072 } 1125 1073 */ 1126 1127 1074 // Calculate remaining time for this observation in minutes 1128 1075 var remaining = nextObs==undefined ? 0 : (nextObs.start-new Date())/60000; … … 1187 1134 1188 1135 if (irq) 1189 continue;1136 break; 1190 1137 1191 1138 OpenLid(); … … 1193 1140 // This is now th right time to wait for th drive to be stable 1194 1141 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 }1203 1142 1204 1143 // Now we are 'OnTrack', so we can ramp to nominal voltage … … 1208 1147 1209 1148 // If pointing had changed, do calibration 1210 if ( !irq &&point)1149 if (point) 1211 1150 { 1212 1151 dim.log("Starting calibration."); … … 1238 1177 { 1239 1178 var len = 300; 1240 while ( !irq &&len>15)1179 while (len>15) 1241 1180 { 1242 1181 var time = new Date();
Note:
See TracChangeset
for help on using the changeset viewer.