Changeset 18114
- Timestamp:
- 02/12/15 10:49:20 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/scripts/Main.js
r18085 r18114 381 381 // ================================================================ 382 382 383 function Shutdown(singlepe) 384 { 385 dim.log("Starting shutdown."); 383 function Shutdown(type) 384 { 385 if (!type) 386 type = "default"; 387 388 dim.log("Starting shutdown ["+type+"]."); 386 389 387 390 var now1 = new Date(); … … 395 398 var now2 = new Date(); 396 399 397 dim.send("DRIVE_CONTROL/PARK"); 400 if (type=="sleep") 401 dim.send("DRIVE_CONTROL/MOVE_TO", 101, 0); 402 else 403 dim.send("DRIVE_CONTROL/PARK"); 398 404 399 405 console.out("","Waiting for telescope to park. This may take a while."); 400 406 401 407 // FIXME: This might not work is the drive is already close to park position 402 dim.wait("DRIVE_CONTROL", "Locked", 3000); 408 if (type!="sleep") 409 dim.wait("DRIVE_CONTROL", "Locked", 3000); 403 410 404 411 var sub = new Subscription("DRIVE_CONTROL/POINTING_POSITION"); … … 424 431 dim.log('Park position not reached? Telescope at Zd='+p.obj['Zd']+' Az='+p.obj['Az']); 425 432 } 426 427 433 /* 428 434 // Check if DRS calibration is necessary … … 435 441 }*/ 436 442 437 if ( singlepe)443 if (type=="singlepe") 438 444 { 439 445 dim.log("Taking single-pe run."); … … 455 461 var now3 = new Date(); 456 462 457 //dim.send("FEEDBACK/STOP");458 463 dim.send("FTM_CONTROL/STOP_TRIGGER"); 459 460 464 dim.wait("FTM_CONTROL", "Valid", 3000); 461 dim.wait("FEEDBACK", "Calibrated", 3000); 462 463 dim.send("BIAS_CONTROL/DISCONNECT"); 464 dim.wait("BIAS_CONTROL", "Disconnected", 3000); 465 466 if (bias!="Disconnected") 467 dim.wait("FEEDBACK", "Calibrated", 3000); 468 469 if (type!="sleep") 470 { 471 dim.send("BIAS_CONTROL/DISCONNECT"); 472 dim.wait("BIAS_CONTROL", "Disconnected", 3000); 473 474 } 465 475 466 476 var report = sub.get(); 467 477 468 478 console.out(""); 469 console.out("Shutdown procedure seems to be finished...");479 console.out("Shutdown procedure ["+type+"] seems to be finished..."); 470 480 console.out(" "+new Date().toUTCString()); 471 481 console.out(" Telescope at Zd=%.1fdeg Az=%.1fdeg".$(report.obj['Zd'], report.obj['Az'])); … … 484 494 sub.close(); 485 495 } 496 497 498 // ================================================================ 499 // Function to set the system to sleep-mode 500 // ================================================================ 501 // FIXME: do not repeat code from shutdown-function 502 /* 503 function GoToSleep() 504 { 505 CloseLid(); 506 507 var isArmed = dim.state("DRIVE_CONTROL").name=="Armed"; 508 if (!isArmed) 509 { 510 dim.log("Drive not ready to move. -> send STOP"); 511 dim.send("DRIVE_CONTROL/STOP"); 512 dim.wait("DRIVE_CONTROL", "Armed", 5000); 513 } 514 515 dim.send("DRIVE_CONTROL/MOVE_TO 101 0");//park position 516 var sub = new Subscription("DRIVE_CONTROL/POINTING_POSITION"); 517 sub.get(5000); // FIXME: Proper error message in case of failure 518 519 function func() 520 { 521 var report = sub.get(); 522 523 var zd = report.obj['Zd']; 524 var az = report.obj['Az']; 525 526 if (zd>100 && Math.abs(az)<1) 527 return true; 528 529 return undefined; 530 } 531 532 try { v8.timeout(150000, func); } 533 catch (e) 534 { 535 var p = sub.get(); 536 dim.log('Park position not reached? Telescope at Zd='+p.obj['Zd']+' Az='+p.obj['Az']); 537 } 538 var p2 = sub.get(); 539 dim.log('Telescope at Zd=%.1fdeg Az=%.1fdeg'.$(p2.obj['Zd'], p2.obj['Az'])); 540 sub.close(); 541 } 542 */ 486 543 487 544 // ================================================================ … … 574 631 575 632 var list = obj.data.split('\n').map(map); 576 // [A577 633 function check(name) 578 634 { … … 930 986 continue; 931 987 988 case "SLEEP": 989 Shutdown("sleep"); //GoToSleep(); 990 991 sub++; 992 dim.log("Task finished [SLEEP]."); 993 console.out(""); 994 continue; 995 932 996 case "STARTUP": 933 997 CloseLid(); … … 954 1018 955 1019 case "SHUTDOWN": 956 Shutdown( true);1020 Shutdown("singlepe"); 957 1021 system_on = false; 958 1022 … … 1121 1185 dim.wait("DRIVE_CONTROL", "Armed", 15000); 1122 1186 1187 if (obs[sub].rstype=="dark-bias-off") 1188 service_feedback.voltageOff(); 1189 else 1190 { 1191 // Switch the voltage to a reduced level (Ubd) 1192 var bias = dim.state("BIAS_CONTROL").name; 1193 if (bias=="VoltageOn" || bias=="Ramping") 1194 service_feedback.voltageOn(0); 1195 } 1196 1123 1197 // Open the lid if required 1124 1198 if (!obs[sub].lidclosed) … … 1127 1201 CloseLid(); 1128 1202 1129 // Switch the voltage to a reduced level (Ubd)1130 service_feedback.voltageOn(0);1131 1132 1203 // track source/position or move to position 1133 1204 if (obs[sub].lidclosed) … … 1135 1206 dim.log("Moving telescope to zd="+obs[sub].zd+" az="+obs[sub].az); 1136 1207 dim.send("DRIVE_CONTROL/MOVE_TO", obs[sub].zd, obs[sub].az); 1137 v8.sleep( 1000);1208 v8.sleep(3000); 1138 1209 dim.wait("DRIVE_CONTROL", "Armed", 150000); // 110s for turning and 30s for stabilizing 1139 1210 } … … 1156 1227 // Now tracking stable, switch voltage to nominal level and wait 1157 1228 // for stability. 1158 if (obs[sub].rstype=="dark-bias-off") 1159 service_feedback.voltageOff(); 1160 else 1229 if (obs[sub].rstype!="dark-bias-off") 1161 1230 { 1162 1231 service_feedback.voltageOn(); 1163 1232 service_feedback.waitForVoltageOn(); 1164 1233 } 1165 dim.log("rs-type: "+obs[sub].rstype);1166 1234 1167 1235 if (!irq) … … 1169 1237 var tm2 = new Date(); 1170 1238 1171 dim.log("Starting ratescan 2/1 ");1239 dim.log("Starting ratescan 2/1 ["+obs[sub].rstype+"]"); 1172 1240 1173 1241 // Start rate scan … … 1178 1246 // it to be configured. 1179 1247 dim.wait("RATE_SCAN", "InProgress", 10000); 1180 dim.wait("RATE_SCAN", "Connected", 2700000); 1248 //FIXME: discuss what best value is here 1249 dim.wait("RATE_SCAN", "Connected", 2700000);//45min 1250 //dim.wait("RATE_SCAN", "Connected", 1200000);//3.3h 1181 1251 1182 1252 // Here one could implement a watchdog for the feedback as well, but what is the difference … … 1196 1266 var tm2 = new Date(); 1197 1267 1198 dim.log("Starting ratescan 2/2 ");1268 dim.log("Starting ratescan 2/2 ["+obs[sub].rstype+"]"); 1199 1269 1200 1270 // Start rate scan
Note:
See TracChangeset
for help on using the changeset viewer.