source: branches/fscctrl_safety_limits/scripts/handleDriveArmed.js@ 18558

Last change on this file since 18558 was 17351, checked in by tbretz, 11 years ago
Wait longer for Armed... it might take a moment.
File size: 1.5 KB
Line 
1'use strict';
2
3// Get Drive control armed
4function handleDriveArmed(wait_state)
5{
6 var state = dim.state("DRIVE_CONTROL");
7 if (state===undefined)
8 return undefined;
9
10 if (wait_state && wait_state.length>0 && state.name!=wait_state)
11 return wait_state;
12
13 //dim.log("DRIVE_CONTROL: "+state.name+"["+state.index+"]");
14
15 switch (state.name)
16 {
17 case "Disconnected":
18 case "Connected":
19 case "Ready":
20 v8.sleep(1000);
21 return undefined;
22
23 case "Locked":
24 //console.warn("Drive is LOCKED. Not all observation types will be supported.");
25 console.out("WARNING - Drive is LOCKED. Please unlock manually.");
26 return "";
27 //throw new Error("Drive is LOCKED. Please unlock manually.");
28 //return undefined;
29 //dim.log("Drive in Locked... unlock.");
30 //dim.send("DRIVE_CONTROL/UNLOCK");
31 //return "Armed";
32
33 case "Moving":
34 case "Tracking":
35 case "OnTrack":
36 console.out("Drive in '"+state.name+"'... sending STOP... waiting for 'Armed'.");
37 dim.send("DRIVE_CONTROL/STOP");
38 return "Armed";
39
40 case "NotReady":
41 case "ERROR":
42 console.out("Drive in '"+state.name+"'... sending STOP.");
43 dim.send("DRIVE_CONTROL/STOP");
44 dim.wait("DRIVE_CONTROL", "Armed", 60000);
45 return undefined; // Process that again if necessary
46
47 case "Armed":
48 return "";
49 }
50
51 throw new Error("DRIVE_CONTROL:"+state.name+"["+state.index+"] unknown or not handled.");
52}
Note: See TracBrowser for help on using the repository browser.