source: branches/FACT++_lidctrl_usb/scripts/handleLidClosed.js@ 20051

Last change on this file since 20051 was 17920, checked in by tbretz, 10 years ago
Added NotReady and Ready
File size: 908 bytes
Line 
1'use strict';
2
3// Get Lids closed
4function handleLidClosed(wait_state)
5{
6 var state = dim.state("LID_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("LID_CONTROL: "+state.name+"["+state.index+"]");
14
15 switch (state.name)
16 {
17 // Do-nothing conditions
18 case "NotReady":
19 case "Ready":
20 case "NoConnection":
21 case "Connected":
22 case "Moving":
23 return wait_state;
24
25 case "Unknown":
26 case "Inconsistent":
27 case "PowerProblem":
28 case "Open":
29 console.out("Lidctrl in '"+state.name+"'... sending CLOSE... waiting for 'Closed'.");
30 dim.send("LID_CONTROL/CLOSE");
31 return "Closed";
32
33 case "Closed":
34 return "";
35 }
36
37 throw new Error("LID_CONTROL:"+state.name+"["+state.index+"] unknown or not handled.");
38}
Note: See TracBrowser for help on using the repository browser.