Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1607 runge 1
 
2
function CanMessage(className, directionFlag, moduleName, moduleId, commandName, data)
3
{
4
    this.myClassName = className;
5
    this.myDirectionFlag = directionFlag;
6
    this.myModuleName = moduleName;
7
    this.myModuleId = moduleId;
8
    this.myCommandName = commandName;
9
 
10
    if (!data)
11
        data = new Array();
12
 
13
    this.myData = data;
14
}
15
 
16
CanMessage.prototype.myClassName = null;
17
CanMessage.prototype.myDirectionFlag = null;
18
CanMessage.prototype.myModuleName = null;
19
CanMessage.prototype.myModuleId = null;
20
CanMessage.prototype.myCommandName = null;
21
CanMessage.prototype.myData = null;
22
 
23
CanMessage.prototype.setClassName = function(className)
24
{
25
    this.myClassName = className;
26
}
27
 
28
CanMessage.prototype.getClassName = function()
29
{
30
    return this.myClassName;
31
}
32
 
33
CanMessage.prototype.setDirectionFlag = function(directionFlag)
34
{
35
    this.myDirectionFlag = directionFlag;
36
}
37
 
38
CanMessage.prototype.getDirectionFlag = function()
39
{
40
    return this.myDirectionFlag;
41
}
42
 
43
CanMessage.prototype.setModuleName = function(moduleName)
44
{
45
    this.myModuleName = moduleName;
46
}
47
 
48
CanMessage.prototype.getModuleName = function()
49
{
50
    return this.myModuleName;
51
}
52
 
53
CanMessage.prototype.setModuleId = function(moduleId)
54
{
55
    this.myModuleId = moduleId;
56
}
57
 
58
CanMessage.prototype.getModuleId = function()
59
{
60
    return this.myModuleId;
61
}
62
 
63
CanMessage.prototype.setCommandName = function(commandName)
64
{
65
    this.myCommandName = commandName;
66
}
67
 
68
CanMessage.prototype.getCommandName = function()
69
{
70
    return this.myCommandName;
71
}
72
 
73
CanMessage.prototype.setData = function(name, value)
74
{
75
    if (typeof this.myData[name] == 'undefined')
76
    {
77
        this.myData.length++;
78
    }
79
 
80
    this.myData[name] = value;
81
}
82
 
83
CanMessage.prototype.getData = function(name)
84
{
85
    return this.myData[name];
86
}
87
 
88
CanMessage.prototype.getDataString = function()
89
{
90
    var str = "";
91
    var tmp = "";
92
 
93
    for (var key in this.myData)
94
    {
95
        /* encode base64 on the data part */
96
        //this.myData[key] = encode64(this.myData[key]+'');
97
        //str += key + ":" + this.myData[key] + ",";
98
        tmp = encode64(this.myData[key]+'');
99
        str += key + ":" + tmp + ",";
100
    }
101
 
102
    return str.rtrim(",");
103
}
104
 
105
CanMessage.prototype.send = function()
106
{
107
    sendMessage(this);
108
}
109
 
110
CanMessage.prototype.toString = function()
111
{
112
    return "[CanMessage] " +    this.getClassName() + ", " +
113
                    this.getDirectionFlag() + ", " +
114
                    this.getModuleName() + ", " +
115
                    this.getModuleId() + ", " +
116
                    this.getCommandName() + ", " +
117
                    this.getDataString();
118
 
119
}