Subversion Repositories HomeAutomation

Rev

Rev 1283 | Rev 1301 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1283 Rev 1300
Line 5... Line 5...
5
}
5
}
6
 
6
 
7
extend(Touch, CanService);
7
extend(Touch, CanService);
8
 
8
 
9
Touch.prototype.myLastGesture = null;
9
Touch.prototype.myLastGesture = null;
-
 
10
Touch.prototype.myLastX = null;
-
 
11
Touch.prototype.myLastY = null;
-
 
12
Touch.prototype.myLastState = "Released";
-
 
13
 
-
 
14
Touch.prototype.getLastGesture = function()
-
 
15
{
-
 
16
    return this.myLastGesture;
-
 
17
}
-
 
18
Touch.prototype.getLastState = function()
-
 
19
{
-
 
20
    return this.myLastState;
-
 
21
}
-
 
22
Touch.prototype.getLastX = function()
-
 
23
{
-
 
24
    return this.myLastX;
-
 
25
}
-
 
26
Touch.prototype.getLastY = function()
-
 
27
{
-
 
28
    return this.myLastY;
-
 
29
}
10
 
30
 
11
Touch.prototype.canMessageHandler = function(canMessage)
31
Touch.prototype.canMessageHandler = function(canMessage)
12
{
32
{
13
    if (canMessage.getDirectionFlag() == "From_Owner")
33
    if (canMessage.getDirectionFlag() == "From_Owner")
14
    {
34
    {
Line 25... Line 45...
25
        {
45
            {
26
            log(this.myName + ":" + this.myId + "> New Gesture: " + this.myLastGesture + "\n");
46
                log(this.myName + ":" + this.myId + "> New Gesture: " + this.myLastGesture + "\n");
27
        }
47
            }
28
       
48
       
29
        this.callEvent("newGesture", null);
49
            this.callEvent("newGesture", null);
-
 
50
            break;
-
 
51
        case "Raw":
-
 
52
            if (this.myLastState == "Pressed" && canMessage.getData("Status") == "Released")
-
 
53
            {
-
 
54
                this.callEvent("rawStatus", null);
-
 
55
                this.myLastState = "Released"
-
 
56
            }
-
 
57
            else if (this.myLastState == "Released" && canMessage.getData("Status") == "Pressed")
-
 
58
            {
-
 
59
                this.callEvent("rawStatus", null);
-
 
60
                this.myLastState = "Pressed"
-
 
61
            }
-
 
62
            this.myLastX = canMessage.getData("X");
-
 
63
            this.myLastY = canMessage.getData("Y");
-
 
64
           
-
 
65
            this.callEvent("rawTouch", null);
30
        break;
66
            break;
31
        }
67
        }
32
    }
68
    }
33
   
69
   
34
    this.CanService.prototype.canMessageHandler.call(this, canMessage);
70
    this.CanService.prototype.canMessageHandler.call(this, canMessage);
35
}
71
}
36
 
72
 
37
 
73
 
38
Touch.prototype.lookupGesture = function(f1, f2, f3, f4, f5, f6, f7, f8, f9)
74
Touch.prototype.lookupGesture = function(f1, f2, f3, f4, f5, f6, f7, f8, f9)
39
{
75
{
40
    var gestureStore = DataStore.getStore("Gestures");
76
    var gestureStore = DataStore.getStore("Gestures");
41
    this.myLastGesture = null;
77
    this.myLastGesture = null;
42
    if (gestureStore)
78
    if (gestureStore)
43
    {
79
    {
44
        for (var n = 0; n < gestureStore['gestures'].length; n++)
80
        for (var n = 0; n < gestureStore['gestures'].length; n++)
45
        {
81
        {
46
            //log(this.myName + ":" + this.myId + "> Checking : " + gestureStore['gestures'][n]['name'] + "\n");
82
            //log(this.myName + ":" + this.myId + "> Checking : " + gestureStore['gestures'][n]['name'] + "\n");
47
            this.myLastGesture = null;
83
            this.myLastGesture = null;
48
            var result = 1;
84
            var result = 1;
49
            if (gestureStore['gestures'][n]['masks']['f1_lower'] > f1 || gestureStore['gestures'][n]['masks']['f1_upper'] < f1)
85
            if (gestureStore['gestures'][n]['masks']['f1_lower'] > f1 || gestureStore['gestures'][n]['masks']['f1_upper'] < f1)
50
            {
86
            {
51
            //  log("1");
87
            //  log("1");
52
                result = 0;
88
                result = 0;
53
                continue;
89
                continue;
54
            }
90
            }
55
            if (gestureStore['gestures'][n]['masks']['f2'] == 1 && gestureStore['gestures'][n]['functions']['f2'] != f2)
91
            if (gestureStore['gestures'][n]['masks']['f2'] == 1 && gestureStore['gestures'][n]['functions']['f2'] != f2)
Line 71... Line 107...
71
                continue;
107
                continue;
72
            }
108
            }
73
            if (gestureStore['gestures'][n]['masks']['f5'] == 1 && gestureStore['gestures'][n]['functions']['f5'] != f5)
109
            if (gestureStore['gestures'][n]['masks']['f5'] == 1 && gestureStore['gestures'][n]['functions']['f5'] != f5)
74
            {
110
            {
75
            //  log("5");
111
            //  log("5");
76
                result = 0;
112
                result = 0;
77
                continue;
113
                continue;
78
            }
114
            }
79
            if (gestureStore['gestures'][n]['masks']['f6'] == 1 && gestureStore['gestures'][n]['functions']['f6'] != f6)
115
            if (gestureStore['gestures'][n]['masks']['f6'] == 1 && gestureStore['gestures'][n]['functions']['f6'] != f6)
80
            {
116
            {
81
            //  log("6");
117
            //  log("6");
82
                result = 0;
118
                result = 0;
83
                continue;
119
                continue;
84
            }
120
            }
85
            if (gestureStore['gestures'][n]['masks']['f7_lower'] > f7 || gestureStore['gestures'][n]['masks']['f7_upper'] < f7)
121
            if (gestureStore['gestures'][n]['masks']['f7_lower'] > f7 || gestureStore['gestures'][n]['masks']['f7_upper'] < f7)
86
            {
122
            {
87
            //  log("7");
123
            //  log("7");
88
                result = 0;
124
                result = 0;
89
                continue;
125
                continue;
90
            }
126
            }
91
            if (gestureStore['gestures'][n]['masks']['f8'] == 1 && gestureStore['gestures'][n]['functions']['f8'] != f8)
127
            if (gestureStore['gestures'][n]['masks']['f8'] == 1 && gestureStore['gestures'][n]['functions']['f8'] != f8)
92
            {
128
            {
93
            //  log("8");
129
            //  log("8");
94
                result = 0;
130
                result = 0;
95
                continue;
131
                continue;
Line 107... Line 143...
107
        }
143
        }
108
    }
144
    }
109
   
145
   
110
}
146
}
111
 
147
 
112
 
-
 
113
Touch.prototype.getLastGesture = function()
-
 
114
{
-
 
115
    return this.myLastGesture;
-
 
116
}
-