Changeset 16798
- Timestamp:
- 06/10/13 12:04:19 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/scripts/Main.js
r16533 r16798 92 92 function doDrsCalibration(where) 93 93 { 94 console.out(" TakeDRS calibration ["+where+"]");94 console.out(" "+new Date().toUTCString()+": Starting DRS calibration ["+where+"]"); 95 95 96 96 service_feedback.voltageOff(); … … 132 132 // 4'40 / 2'00 133 133 134 console.out(" DRS calibration done [%.1f]".$((new Date()-tm)/1000));134 console.out(" "+new Date().toUTCString()+": DRS calibration done [%.1f]".$((new Date()-tm)/1000)); 135 135 } 136 136 … … 157 157 if (isClosed) 158 158 { 159 console.out(" Open lid: start");159 console.out(" "+new Date().toUTCString()+": Opening lid"); 160 160 dim.send("LID_CONTROL/OPEN"); 161 161 } … … 163 163 164 164 if (isClosed) 165 console.out(" Open lid: done[%.1fs]".$((new Date()-tm)/1000));165 console.out(" "+new Date().toUTCString()+": Lid open [%.1fs]".$((new Date()-tm)/1000)); 166 166 } 167 167 … … 175 175 if (isOpen) 176 176 { 177 console.out(" Close lid: start");177 console.out(" "+new Date().toUTCString()+": Closing lid."); 178 178 dim.send("LID_CONTROL/CLOSE"); 179 179 } … … 181 181 182 182 if (isOpen) 183 console.out(" Close lid: end [%.1fs]".$((new Date()-tm)/1000));183 console.out(" "+new Date().toUTCString()+": Lid closed [%.1fs]".$((new Date()-tm)/1000)); 184 184 } 185 185 … … 238 238 if (isOn) 239 239 { 240 console.out(" Voltage off: start");240 console.out(" "+new Date().toUTCString()+": Switching voltage off."); 241 241 242 242 // Supress the possibility that the bias control is … … 246 246 if (isControl) 247 247 { 248 console.out(" Suspending feedback.");248 //console.out(" Suspending feedback."); 249 249 dim.send("FEEDBACK/ENABLE_OUTPUT", false); 250 250 dim.wait("FEEDBACK", "CurrentCtrlIdle", 3000); … … 252 252 253 253 // Switch voltage off 254 console.out(" "+new Date().toUTCString()+": Voltage off: switch off");254 //console.out(" "+new Date().toUTCString()+": Voltage off: switch off"); 255 255 dim.send("BIAS_CONTROL/SET_ZERO_VOLTAGE"); 256 256 … … 258 258 if (isControl) 259 259 { 260 console.out(" Resuming feedback.");260 //console.out(" Resuming feedback."); 261 261 dim.send("FEEDBACK/ENABLE_OUTPUT", true); 262 262 dim.wait("FEEDBACK", "CurrentControl", 3000); … … 270 270 271 271 if (isOn) 272 console.out(" Voltage off: end");272 console.out(" "+new Date().toUTCString()+": Voltage off."); 273 273 } 274 274 … … 302 302 if (isOff) 303 303 { 304 console.out(" "+new Date().toUTCString()+": Voltage on: switch on");304 console.out(" "+new Date().toUTCString()+": Switching voltage on."); 305 305 //console.out(JSON.stringify(dim.state("BIAS_CONTROL"))); 306 306 … … 317 317 if (isOff) 318 318 { 319 console.out(" Voltage on: cnt="+this.cnt);319 console.out(" "+new Date().toUTCString()+": Voltage on [cnt="+this.cnt+"]"); 320 320 321 321 this.previous = undefined; … … 344 344 345 345 // FIXME: timeout missing 346 console.out(" Feedback wait: start");346 console.out(" "+new Date().toUTCString()+": Waiting for voltage to be stable."); 347 347 348 348 function func() … … 357 357 v8.timeout(4*60000, func, this); 358 358 359 console.out(" Feedback wait: end[dV=%.3f, cnt=%d, %.2fs]".$(this.voltageStep, this.get().counter, (new Date()-now)/1000));359 console.out(" "+new Date().toUTCString()+": Voltage stable within limits [dV=%.3f, cnt=%d, %.2fs]".$(this.voltageStep, this.get().counter, (new Date()-now)/1000)); 360 360 } 361 361 … … 366 366 function Shutdown() 367 367 { 368 console.out(" Shutdown: start");368 console.out(" "+new Date().toUTCString()+": Starting shutdown."); 369 369 370 370 service_feedback.voltageOff(); … … 372 372 dim.send("DRIVE_CONTROL/PARK"); 373 373 374 console.out(" Waiting for telescope to park. This may take a while.");374 console.out("","Waiting for telescope to park. This may take a while."); 375 375 376 376 // FIXME: This might not work is the drive is already close to park position … … 401 401 dim.send("BIAS_CONTROL/DISCONNECT"); 402 402 403 dim.wait("FTM_CONTROL", " Idle",3000);403 dim.wait("FTM_CONTROL", "Valid", 3000); 404 404 dim.wait("BIAS_CONTROL", "Disconnected", 3000); 405 405 dim.wait("FEEDBACK", "Connected", 3000); … … 463 463 "FAD_CONTROL/START_RUN", 464 464 "FAD_CONTROL/STATISTICS1", 465 // "FAD_CONTROL/STATISTICS2",466 465 "FAD_CONTROL/STATS", 467 466 "FAD_CONTROL/STATUS", … … 531 530 532 531 // ================================================================ 532 // Code to monitor clock conditioner 533 // ================================================================ 534 535 var sub_counter = new Subscription("FTM_CONTROL/COUNTER"); 536 sub_counter.onchange = function(evt) 537 { 538 if (evt.qos>0 && evt.qos!=2 && evt.qos&0x100==0) 539 throw new Error("FTM reports: clock conditioner not locked."); 540 } 541 542 // ================================================================ 533 543 // Code related to monitoring the fad system 534 544 // ================================================================ … … 547 557 // (FIXME: Should that go to the general CheckState?) 548 558 // ---------------------------------------------------------------- 549 console.out("Checking send.");559 //console.out("Checking send."); 550 560 checkSend(["MCP", "DRIVE_CONTROL", "LID_CONTROL", "FAD_CONTROL", "FEEDBACK"]); 551 console.out("Checking send: done");561 //console.out("Checking send: done"); 552 562 553 563 // ---------------------------------------------------------------- 554 564 // Bring feedback into the correct operational state 555 565 // ---------------------------------------------------------------- 556 console.out("Feedback init: start.");566 //console.out("Feedback init: start."); 557 567 service_feedback.get(5000); 558 568 … … 565 575 // Connect to the DRS_RUNS service 566 576 // ---------------------------------------------------------------- 567 console.out("Drs runs init: start.");577 //console.out("Drs runs init: start."); 568 578 569 579 var sub_drsruns = new Subscription("FAD_CONTROL/DRS_RUNS"); … … 582 592 583 593 if (valid) 584 console.out(" Last DRS calib: %.1fmin ago".$(diff));594 console.out(" "+new Date().toUTCString()+": Last DRS calib: %.1fmin ago".$(diff)); 585 595 else 586 console.out(" No valid drs calibration available");596 console.out(" "+new Date().toUTCString()+": No valid drs calibration available."); 587 597 588 598 return valid ? diff : null; … … 615 625 // Start main loop 616 626 // ---------------------------------------------------------------- 617 console.out(" Startmain loop.");627 console.out(" "+new Date().toUTCString()+": Entering main loop."); 618 628 619 629 var run = -2; // getObservation never called … … 645 655 if (!was_up && sun.isUp) 646 656 { 647 console.out("", " Sun rise detected.... automatic shutdown initiated!");657 console.out("", " "+new Date().toUTCString()+": Sun rise detected.... automatic shutdown initiated!"); 648 658 // FIXME: State check? 649 659 Shutdown(); … … 743 753 [ "LID_CONTROL", [ "Open", "Closed" ] ], 744 754 [ "DRIVE_CONTROL", drive_states/*[ "Armed", "Tracking", "OnTrack" ]*/ ], 745 [ "FTM_CONTROL", [ " Idle", "TriggerOn"] ],755 [ "FTM_CONTROL", [ "Valid", "TriggerOn" ] ], 746 756 [ "FAD_CONTROL", [ "Connected", "RunInProgress" ] ], 747 757 [ "RATE_SCAN", [ "Connected" ] ], … … 763 773 { 764 774 case "STARTUP": 765 console.out(" STARTUP", "");775 console.out(" "+new Date().toUTCString()+": New task [STARTUP]", ""); 766 776 CloseLid(); 767 777 … … 772 782 773 783 // Before we can switch to 3000 we have to make the right DRS calibration 774 console.out(" Takesingle p.e. run.");784 console.out(" "+new Date().toUTCString()+": Taking single p.e. run."); 775 785 while (!takeRun("pedestal", 5000)); 776 786 … … 778 788 service_feedback.voltageOff(); 779 789 system_on = true; 790 console.out(" "+new Date().toUTCString()+": Task finished [STARTUP]", ""); 780 791 break; 781 792 782 793 case "SHUTDOWN": 783 console.out(" SHUTDOWN", "");794 console.out(" "+new Date().toUTCString()+": New task [SHUTDOWN]", ""); 784 795 Shutdown(); 785 796 system_on = false; … … 789 800 console.out(" Waiting for next startup.", ""); 790 801 sub++; 802 console.out(" "+new Date().toUTCString()+": Task finished [SHUTDOWN]", ""); 791 803 continue; 792 804 … … 796 808 797 809 case "DRSCALIB": 798 console.out(" DRSCALIB", "");810 console.out(" "+new Date().toUTCString()+": New task [DRSCALIB]", ""); 799 811 doDrsCalibration("drscalib"); // will switch the voltage off 812 console.out(" "+new Date().toUTCString()+": Task finished [DRSCALIB]", ""); 800 813 break; 801 814 802 815 case "SINGLEPE": 803 console.out(" SINGLE-PE", "");816 console.out(" "+new Date().toUTCString()+": New task [SINGLE-PE]", ""); 804 817 805 818 // The lid must be closes … … 816 829 817 830 // Before we can switch to 3000 we have to make the right DRS calibration 818 console.out(" Takesingle p.e. run.");831 console.out(" "+new Date().toUTCString()+": Taking single p.e. run."); 819 832 while (!takeRun("pedestal", 5000)); 820 833 821 834 // It is unclear what comes next, so we better switch off the voltage 822 835 service_feedback.voltageOff(); 836 console.out(" "+new Date().toUTCString()+": Task finished [SINGLE-PE]", ""); 823 837 break; 824 838 825 839 case "RATESCAN": 826 console.out(" RATESCAN", "");840 console.out(" "+new Date().toUTCString()+": New task [RATESCAN]", ""); 827 841 828 842 var tm1 = new Date(); … … 840 854 841 855 if (obs.source != undefined) 856 { 857 console.out(" "+new Date().toUTCString()+": Moving drive to '"+obs[cub].source+"'."); 842 858 dim.send("DRIVE_CONTROL/TRACK_ON", obs[sub].source); 859 } 843 860 else 861 { 862 console.out(" "+new Date().toUTCString()+": Moving drive to: ra="+obs[sub].ra+" dec="+obs[sub].dec); 844 863 dim.send("DRIVE_CONTROL/TRACK", obs[sub].ra, obs[sub].dec); 864 } 845 865 846 866 dim.wait("DRIVE_CONTROL", "OnTrack", 150000); // 110s for turning and 30s for stabilizing … … 849 869 850 870 var tm2 = new Date(); 871 872 console.out(" "+new Date().toUTCString()+": Starting ratescan."); 851 873 852 874 // Start rate scan … … 864 886 //dim.send("FAD_CONTROL/SET_FILE_FORMAT", 2); 865 887 866 console.out(" Ratescan done [%.1fs, %.1fs]".$((tm2-tm1)/1000, (new Date()-tm2)/1000)); 888 console.out(" "+new Date().toUTCString()+": Ratescan done [%.1fs, %.1fs]".$((tm2-tm1)/1000, (new Date()-tm2)/1000)); 889 console.out(" "+new Date().toUTCString()+": Task finished [RATESCAN]", ""); 867 890 break; // case "RATESCAN" 868 891 … … 884 907 // ------------------------------------------------------------ 885 908 886 console.out(" Run #"+run+" (remaining "+parseInt(remaining)+"min)");909 console.out(" "+new Date().toUTCString()+": Run #"+run+" (remaining "+parseInt(remaining)+"min)"); 887 910 888 911 // ----- Time since last DRS Calibration [min] ------ … … 910 933 911 934 //console.out(" Move telescope to '"+source+"' "+offset+" "+wobble); 912 console.out(" Move telescope to '"+obs[sub].source+"' ["+wobble+"]");935 console.out(" "+new Date().toUTCString()+": Moving telescope to '"+obs[sub].source+"' [wobble="+wobble+"]"); 913 936 914 937 //var offset = observations[obs][2]; … … 943 966 if (point) 944 967 { 945 console.out(" Calibration.");968 console.out(" "+new Date().toUTCString()+": Starting calibration."); 946 969 947 970 // Calibration (2% of 20') … … 956 979 } 957 980 958 console.out(" Taking data: start [5min]"); 981 //console.out(" Taking data: start [5min]"); 982 983 // FIXME: What do we do if during calibration something has happened 984 // e.g. drive went to ERROR? Maybe we have to check all states again? 959 985 960 986 var len = 300; … … 968 994 } 969 995 970 console.out(" Taking data: done");996 //console.out(" Taking data: done"); 971 997 run++; 972 998 … … 975 1001 976 1002 if (nextObs!=undefined && sub==obs.length-1) 977 console.out(" Waiting for next observation scheduled for"+nextObs.start.toUTCString(),"");1003 console.out(" "+new Date().toUTCString()+": Waiting for next observation scheduled at "+nextObs.start.toUTCString(),""); 978 1004 979 1005 sub++;
Note:
See TracChangeset
for help on using the changeset viewer.