source: trunk/FACT++/scripts/handleDriveArmed.js@ 15054

Last change on this file since 15054 was 14968, checked in by tbretz, 12 years ago
Replaced dim.print by dim.log
File size: 1.2 KB
Line 
1// Get Drive control armed
2function handleDriveArmed(wait_state)
3{
4 var state = dim.state("DRIVE_CONTROL");
5 if (state===undefined)
6 return undefined;
7
8 if (wait_state && wait_state.length>0 && state.name!=wait_state)
9 return wait_state;
10
11 dim.log("DRIVE_CONTROL: "+state.name+"["+state.index+"]");
12
13 switch (state.name)
14 {
15 case "Disconnected":
16 case "Connected":
17 case "NotReady":
18 case "Ready":
19 v8.sleep(1000);
20 return undefined;
21
22 case "Locked":
23 throw new Error("Drive is LOCKED. Please unlock manually.");
24 //return undefined;
25 //dim.log("Drive in Locked... unlock.");
26 //dim.send("DRIVE_CONTROL/UNLOCK");
27 //return "Armed";
28
29 case "Moving":
30 case "Tracking":
31 case "OnTrack":
32 dim.log("Drive moving... stop.");
33 dim.send("DRIVE_CONTROL/STOP");
34 return "Armed";
35
36 case "ERROR":
37 dim.log("Drive in error... trying to reinitialize.");
38 dim.send("DRIVE_CONTROL/STOP");
39 dim.wait("DRIVE_CONTROL", "Armed", 5000);
40 return undefined; // Process that again if necessary
41
42 case "Armed":
43 return "";
44 }
45
46 throw new Error("DRIVE_CONTROL:"+state.name+"["+state.index+"] unknown or not handled.");
47}
Note: See TracBrowser for help on using the repository browser.