source: trunk/FACT++/scripts/handleFadConnected.js@ 16796

Last change on this file since 16796 was 16795, checked in by tbretz, 12 years ago
Added Configuring3 state; improved output whena command is sent:
File size: 1.5 KB
Line 
1// Get fad control connected
2function handleFadConnected(wait_state)
3{
4 var state = dim.state("FAD_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("BIAS_CONTROL: "+state.name+"["+state.index+"]");
12
13 switch (state.name)
14 {
15 case "Offline":
16 return undefined;
17
18 case "Disconnected":
19 console.out("Fadctrl in 'Diconnected'... sending START... waiting for 'Connected'.");
20 dim.send("FAD_CONTROL/START");
21 return "Connected";
22
23 // Do-nothing conditions
24 case "Connecting":
25 return wait_state;
26
27 // Do-something conditions
28 case "Configuring1":
29 case "Configuring2":
30 case "Configuring3":
31 case "Configured":
32 console.out("Fadctrl in Configure state... sending RESET_CONFIGURE... waiting for 'Connected'.");
33 dim.send("FAD_CONTROL/RESET_CONFIGURE");
34 return "Connected";
35
36 case "Disengaged":
37 console.out("Fadctrl in 'Disengaged'... sending START... waiting for 'Connected'.");
38 dim.send("FAD_CONTROL/START");
39 return "Connected";
40
41 case "RunInProgress":
42 console.out("Fadctrl in 'RunInProgress'... sending CLOSE_OPEN_FILES... waiting for 'Connected'.");
43 dim.send("FAD_CONTROL/CLOSE_OPEN_FILES");
44 return "Connected";
45
46 // Final state reached condition
47 case "Connected":
48 return "";
49 }
50
51 throw new Error("FAD_CONTROL:"+state.name+"["+state.index+"] unknown or not handled.");
52}
Note: See TracBrowser for help on using the repository browser.