Subversion Repositories HomeAutomation

Rev

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

Rev 1008 Rev 1013
Line 3... Line 3...
3
{
3
{
4
    this.myHardwareId = hardwareId;
4
    this.myHardwareId = hardwareId;
5
    this.myNumberOfModules = numberOfModules;
5
    this.myNumberOfModules = numberOfModules;
6
    this.myModules = new Array();
6
    this.myModules = new Array();
7
    this.myHeartbeatTime = 0;
7
    this.myHeartbeatTime = 0;
-
 
8
    this.myProgrammingHexAddress = 0;
8
    this.myIsOnline = false;
9
    this.myIsOnline = false;
9
   
10
   
10
    this.stopProgramming();
11
    this.stopProgramming();
11
}
12
}
12
 
13
 
Line 16... Line 17...
16
CanNode.prototype.myModules = null;
17
CanNode.prototype.myModules = null;
17
CanNode.prototype.myHeartbeatTime = null;
18
CanNode.prototype.myHeartbeatTime = null;
18
CanNode.prototype.myProgrammingIsBios = null;
19
CanNode.prototype.myProgrammingIsBios = null;
19
CanNode.prototype.myProgramming = null;
20
CanNode.prototype.myProgramming = null;
20
CanNode.prototype.myProgrammingHex = null;
21
CanNode.prototype.myProgrammingHex = null;
21
CanNode.prototype.myProgrammingHexIndex = null;
22
CanNode.prototype.myProgrammingHexAddress = null;
22
CanNode.prototype.myProgrammingCallback = null;
23
CanNode.prototype.myProgrammingCallback = null;
23
CanNode.prototype.myProgrammingWantAck = null;
24
CanNode.prototype.myProgrammingWantAck = null;
24
 
25
 
25
CanNode.prototype.isOnline = function()
26
CanNode.prototype.isOnline = function()
26
{
27
{
Line 67... Line 68...
67
 
68
 
68
CanNode.prototype.startProgramming = function(hexData, progressCallback, isBios)
69
CanNode.prototype.startProgramming = function(hexData, progressCallback, isBios)
69
{
70
{
70
    if (isBios)
71
    if (isBios)
71
    {
72
    {
72
        this.myProgrammingIsBios = bios;
73
        this.myProgrammingIsBios = isBios;
73
    }
74
    }
74
    else
75
    else
75
    {
76
    {
76
        this.myProgrammingIsBios = false;
77
        this.myProgrammingIsBios = false;
77
    }
78
    }
Line 83... Line 84...
83
    this.reset();
84
    this.reset();
84
}
85
}
85
 
86
 
86
CanNode.prototype.handleBiosStart = function(biosVersion, hasApplication)
87
CanNode.prototype.handleBiosStart = function(biosVersion, hasApplication)
87
{
88
{
-
 
89
//print("node was reset and bios just started, ver:" + biosVersion);
88
    if (this.myProgramming)
90
    if (this.myProgramming)
89
    {
91
    {
90
        var hexLine = this.myProgrammingHex[this.myProgrammingHexIndex];
92
        var address = this.myProgrammingHex.getAddrLower();
91
        this.myProgrammingHexIndex++;
93
        this.myProgrammingWantAck = address&0xffff;
92
   
-
 
93
        var address = ""; ///TODO: Fill in something here
-
 
94
   
-
 
95
        this.myProgrammingWantAck = "";  ///TODO: Fill in the 16 lower bits of address
-
 
96
   
94
   
97
        var canMessage = new CanNMTMessage("nmt", "Pgm_Start");
95
        var canMessage = new CanNMTMessage("nmt", "Pgm_Start");
98
        canMessage.setData("HardwareId", this.myHardwareId);
96
        canMessage.setData("HardwareId", this.myHardwareId);
99
        canMessage.setData("Address", address);
97
        canMessage.setData("AddressLow", address&0xffff);
-
 
98
        canMessage.setData("AddressHigh", (address>16)&0xffff);
100
        canMessage.send();
99
        canMessage.send();
101
       
100
       
102
        this.myProgrammingCallback(true, "START", "Started programming of node");
101
        this.myProgrammingCallback(true, "START", "Started programming of node");
103
    }
102
    }
104
}
103
}
105
 
104
 
106
CanNode.prototype.handleAck = function(data)
105
CanNode.prototype.handleAck = function(data)
107
{
106
{
-
 
107
this.myProgrammingCallback(true, "DBG", "data: "+data+", myProgrammingWantAck: "+this.myProgrammingWantAck+"\n");
-
 
108
   
-
 
109
//dont do this right now
108
    if (data == this.myProgrammingWantAck)
110
    if (data == this.myProgrammingWantAck && false)
109
    {
111
    {
110
        var hexLine = this.myProgrammingHex[this.myProgrammingHexIndex];
-
 
111
        this.myProgrammingHexIndex++;
-
 
112
       
112
       
113
        var type = ""; ///TODO: Fill in which type of data we have
113
        var type = ""; ///TODO: Fill in which type of data we have
114
       
114
       
115
        switch (type)
115
        switch (type)
116
        {
116
        {
Line 123... Line 123...
123
            var canMessage = new CanNMTMessage("nmt", "Pgm_Data");
123
            var canMessage = new CanNMTMessage("nmt", "Pgm_Data");
124
            canMessage.setData("Offset", offset);
124
            canMessage.setData("Offset", offset);
125
            canMessage.setData("Data", data);
125
            canMessage.setData("Data", data);
126
            canMessage.send();
126
            canMessage.send();
127
           
127
           
128
            this.myProgrammingCallback(true, "PROGRESS", this.myProgrammingHexIndex + ":" + this.myProgrammingHex.length);
128
            this.myProgrammingCallback(true, "PROGRESS", this.myProgrammingHexAddress + ":" + this.myProgrammingHex.length);
129
            break;
129
            break;
130
       
130
       
131
        case "END":///TODO: Maybe it is called something else, maybe a number
131
        case "END":///TODO: Maybe it is called something else, maybe a number
132
            this.myProgrammingWantAck = "";  ///TODO: Fill in something here
132
            this.myProgrammingWantAck = "";  ///TODO: Fill in something here
133
       
133
       
Line 173... Line 173...
173
    }
173
    }
174
   
174
   
175
    this.myProgrammingIsBios = false;
175
    this.myProgrammingIsBios = false;
176
    this.myProgramming = false;
176
    this.myProgramming = false;
177
    this.myProgrammingHex = new Array();
177
    this.myProgrammingHex = new Array();
178
    this.myProgrammingHexIndex = 0;
178
    this.myProgrammingHexAddress = 0;
179
    this.myProgrammingCallback = function() {};
179
    this.myProgrammingCallback = function() {};
180
    this.myProgrammingWantAck = null;
180
    this.myProgrammingWantAck = null;
181
}
181
}
182
 
182
 
183
 
183