Subversion Repositories HomeAutomation

Rev

Rev 997 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 997 Rev 1001
Line 299... Line 299...
299
 
299
 
300
    for (int n = 0; n < commandNodes.size(); n++)
300
    for (int n = 0; n < commandNodes.size(); n++)
301
    {
301
    {
302
        map<string, string> attributes = commandNodes[n].getAttributes();
302
        map<string, string> attributes = commandNodes[n].getAttributes();
303
 
303
 
-
 
304
        bool correct = false;
-
 
305
 
-
 
306
        if (commandId >= 128)
-
 
307
        {
304
        if ((stoi(attributes["id"]) == commandId) || (commandId >= 128 && (stoi(attributes["id"]) == commandId && attributes["module"] == moduleName)))
308
            if (stoi(attributes["id"]) == commandId && attributes["module"] == moduleName)
-
 
309
            {
-
 
310
                correct = true;
-
 
311
            }
-
 
312
        }
-
 
313
        else if (stoi(attributes["id"]) == commandId)
-
 
314
        {
-
 
315
            correct = true;
-
 
316
        }
-
 
317
 
-
 
318
        if (correct)
305
        {
319
        {
306
            XmlNode varablesNode = commandNodes[n].findChild("variables");
320
            XmlNode varablesNode = commandNodes[n].findChild("variables");
307
 
321
 
308
            makeDataValid(varablesNode.getChildren(), data);
322
            makeDataValid(varablesNode.getChildren(), data);
309
 
323
 
Line 323... Line 337...
323
        {
337
        {
324
            data[attributes["name"]].setType(attributes["type"]);
338
            data[attributes["name"]].setType(attributes["type"]);
325
            data[attributes["name"]].setUnit(attributes["unit"]);
339
            data[attributes["name"]].setUnit(attributes["unit"]);
326
            data[attributes["name"]].setBitLength(stoi(attributes["bit_length"]));
340
            data[attributes["name"]].setBitLength(stoi(attributes["bit_length"]));
327
            data[attributes["name"]].setStartBit(stoi(attributes["start_bit"]));
341
            data[attributes["name"]].setStartBit(stoi(attributes["start_bit"]));
328
        }
342
        }
329
    }
343
    }
330
}
344
}
331
 
345
 
332
string CanIdTranslator::translateDataToHex(int commandId, string moduleName, map<string, CanVariable> &data)
346
string CanIdTranslator::translateDataToHex(int commandId, string moduleName, map<string, CanVariable> &data)
333
{
347
{
334
    makeDataValid(commandId, moduleName, data);
348
    makeDataValid(commandId, moduleName, data);
335
 
349
 
336
    return translateValidDataToHex(data);
350
    return translateValidDataToHex(data);
337
}
351
}
338
 
352
 
339
 
353
 
340
map<string, CanVariable> CanIdTranslator::translateData(int commandId, string moduleName, string dataHex)
354
map<string, CanVariable> CanIdTranslator::translateData(int commandId, string moduleName, string dataHex)
341
{
355
{
342
    vector<XmlNode> commandNodes = xmlNode.findChild("commands").getChildren();
356
    vector<XmlNode> commandNodes = xmlNode.findChild("commands").getChildren();
343
 
357
 
344
    for (int n = 0; n < commandNodes.size(); n++)
358
    for (int n = 0; n < commandNodes.size(); n++)
345
    {
359
    {
346
        map<string, string> attributes = commandNodes[n].getAttributes();
360
        map<string, string> attributes = commandNodes[n].getAttributes();
347
 
361
 
-
 
362
        bool correct = false;
-
 
363
 
-
 
364
        if (commandId >= 128)
-
 
365
        {
348
        if ((stoi(attributes["id"]) == commandId) || (commandId >= 128 && (stoi(attributes["id"]) == commandId && attributes["module"] == moduleName)))
366
            if (stoi(attributes["id"]) == commandId && attributes["module"] == moduleName)
-
 
367
            {
-
 
368
                correct = true;
-
 
369
            }
-
 
370
        }
-
 
371
        else if (stoi(attributes["id"]) == commandId)
-
 
372
        {
-
 
373
            correct = true;
-
 
374
        }
-
 
375
 
-
 
376
        if (correct)
349
        {
377
        {
350
            XmlNode varablesNode = commandNodes[n].findChild("variables");
378
            XmlNode varablesNode = commandNodes[n].findChild("variables");
351
 
379
 
352
            return translateData(varablesNode.getChildren(), dataHex);
380
            return translateData(varablesNode.getChildren(), dataHex);
353
        }
381
        }