source: trunk/FACT++/scripts/handleFtmIdle.js@ 16852

Last change on this file since 16852 was 16828, checked in by tbretz, 12 years ago
In Configured2 we do just wait.
File size: 1.6 KB
Line 
1// Get ftm connected, idle and with working FTUs
2function handleFtmIdle(wait_state)
3{
4 var state = dim.state("FTM_CONTROL");
5 if (state===undefined)
6 return undefined;
7
8 // Only try to open the service if the server is already in the list
9 if (wait_state && wait_state.length>0 && state.name!=wait_state)
10 return wait_state;
11
12 //dim.log("FTM_CONTROL: "+state.name+"["+state.index+"]");
13
14 switch (state.name)
15 {
16 case "Disconnected":
17 console.out("Ftmctrl in 'Disconnected'... sending RECONNECT... wainting for 'Idle'.");
18 dim.send("FTM_CONTROL/RECONNECT");
19 return "Valid";
20
21 case "Idle":
22 console.out("Ftmctrl in 'Idle'... sending DISCONNECT... wainting for 'Disconnected'.");
23 dim.send("FTM_CONTROL/DISCONNECT");
24 v8.sleep(3000);
25 return "Disconnected";
26
27 case "Valid":
28 return "";
29
30 case "TriggerOn":
31 console.out("Ftmctrl in 'TriggerOn'... sending STOP_TRIGGER... waiting for 'Idle'.");
32 dim.send("FTM_CONTROL/STOP_TRIGGER");
33 return "Valid";
34
35 case "Configuring1":
36 case "Configuring2":
37 case "Configured1":
38 console.out("Ftmctrl in '"+state.name+"'... sending RESET_CONFIGURE... waiting for 'Idle'.");
39 dim.send("FTM_CONTROL/RESET_CONFIGURE");
40 return "Valid";
41
42 case "Configured2":
43 return "TriggerOn";
44
45 case "ConfigError1":
46 case "ConfigError2":
47 case "ConfigError3":
48 throw new Error("FTM_CONTROL:"+state.name+"["+state.index+"] in error state.");
49 }
50
51 throw new Error("FTM_CONTROL:"+state.name+"["+state.index+"] unknown or not handled.");
52}
Note: See TracBrowser for help on using the repository browser.