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

Last change on this file since 16991 was 16857, checked in by tbretz, 11 years ago
Added the 'use strict'
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 "NotReady":
20 case "Ready":
21 v8.sleep(1000);
22 return undefined;
23
24 case "Locked":
25 //console.warn("Drive is LOCKED. Not all observation types will be supported.");
26 console.out("WARNING - Drive is LOCKED. Please unlock manually.");
27 return "";
28 //throw new Error("Drive is LOCKED. Please unlock manually.");
29 //return undefined;
30 //dim.log("Drive in Locked... unlock.");
31 //dim.send("DRIVE_CONTROL/UNLOCK");
32 //return "Armed";
33
34 case "Moving":
35 case "Tracking":
36 case "OnTrack":
37 console.out("Drive in '"+state.name+"'... sending STOP... waiting for 'Armed'.");
38 dim.send("DRIVE_CONTROL/STOP");
39 return "Armed";
40
41 case "ERROR":
42 console.out("Drive in 'ERROR'... sending STOP.");
43 dim.send("DRIVE_CONTROL/STOP");
44 dim.wait("DRIVE_CONTROL", "Armed", 5000);
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.