source: branches/testFACT++branch/scripts/handleFtmIdle.js@ 18452

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