Subversion Repositories HomeAutomation

Rev

Rev 1378 | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
969 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
    this.myData[name] = value;
76
}
77
 
78
CanMessage.prototype.getData = function(name)
79
{
80
    return this.myData[name];
81
}
82
 
83
CanMessage.prototype.getDataString = function()
84
{
85
    var str = "";
1378 arune 86
    var tmp = "";
969 runge 87
 
88
    for (var key in this.myData)
89
    {
1229 arune 90
        /* encode base64 on the data part */
1378 arune 91
        //this.myData[key] = encode64(this.myData[key]+'');
92
        //str += key + ":" + this.myData[key] + ",";
93
        tmp = encode64(this.myData[key]+'');
94
        str += key + ":" + tmp + ",";
969 runge 95
    }
96
 
971 runge 97
    return str.rtrim(",");
969 runge 98
}
971 runge 99
 
1008 runge 100
CanMessage.prototype.send = function()
101
{
102
    sendCanMessage( this.getClassName(),
103
            this.getDirectionFlag(),
104
            this.getModuleName(),
105
            this.getModuleId(),
106
            this.getCommandName(),
107
            this.getDataString());
108
}
109
 
971 runge 110
CanMessage.prototype.toString = function()
111
{
112
    return "[CanMessage] " +    this.getClassName() + ", " +
113
                    this.getDirectionFlag() + ", " +
114
                    this.getModuleName() + ", " +
115
                    this.getModuleId() + ", " +
986 runge 116
                    this.getCommandName() + ", " +
971 runge 117
                    this.getDataString();
118
 
119
}