Subversion Repositories HomeAutomation

Rev

Rev 1026 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. /***************************************************************************
  2.  *   Copyright (C) November 28, 2008 by Mattias Runge                             *
  3.  *   mattias@runge.se                                                      *
  4.  *   canidtranslator.h                                            *
  5.  *                                                                         *
  6.  *   This program is free software; you can redistribute it and/or modify  *
  7.  *   it under the terms of the GNU General Public License as published by  *
  8.  *   the Free Software Foundation; either version 2 of the License, or     *
  9.  *   (at your option) any later version.                                   *
  10.  *                                                                         *
  11.  *   This program is distributed in the hope that it will be useful,       *
  12.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  13.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
  14.  *   GNU General Public License for more details.                          *
  15.  *                                                                         *
  16.  *   You should have received a copy of the GNU General Public License     *
  17.  *   along with this program; if not, write to the                         *
  18.  *   Free Software Foundation, Inc.,                                       *
  19.  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  20.  ***************************************************************************/
  21.  
  22. #ifndef _CANIDTRANSLATOR_H
  23. #define _CANIDTRANSLATOR_H
  24.  
  25. using namespace std;
  26.  
  27. #include <string>
  28. #include <map>
  29.  
  30. #include "canvariable.h"
  31. #include "cantranslatorexception.h"
  32. #include "../Logger/logger.h"
  33. #include "../Settings/settings.h"
  34. #include "../Xml/xmlnode.h"
  35.  
  36. class CanIdTranslator
  37. {
  38. public:
  39.     static CanIdTranslator& getInstance();
  40.     static void deleteInstance();
  41.  
  42.     string lookupClassName(int classId);
  43.     int resolveClassId(string className);
  44.  
  45.     string lookupDirectionFlag(int directionFlag);
  46.     int resolveDirectionFlag(string directionName);
  47.  
  48.     string lookupModuleName(int moduleId);
  49.     int resolveModuleId(string moduleName);
  50.  
  51.     string lookupCommandName(int commandId, string moduleName);
  52.     int resolveCommandId(string commandName, string moduleName);
  53.  
  54.     string getDefineId(string name, string group);
  55.  
  56.     map<string, CanVariable> translateData(int commandId, string moduleName, string dataHex);
  57.     string translateDataToHex(int commandId, string moduleName, map<string, CanVariable> &data);
  58.     void makeDataValid(int commandId, string moduleName, map<string, CanVariable> &data);
  59.  
  60.     string lookupNMTCommandName(int commandId);
  61.     int resolveNMTCommandId(string commandName);
  62.  
  63.     map<string, CanVariable> translateNMTData(int commandId, string rawHexData);
  64.     string translateNMTDataToHex(string commandName, map<string, CanVariable> &data);
  65.     void makeNMTDataValid(string commandName, map<string, CanVariable> &data);
  66.  
  67. protected:
  68.     CanIdTranslator();
  69.  
  70. private:
  71.     static CanIdTranslator* myInstance;
  72.     XmlNode xmlNode;
  73.  
  74.     void makeDataValid(vector<XmlNode> variableNodes, map<string, CanVariable> &data);
  75.     string translateValidDataToHex(map<string, CanVariable> &data);
  76.     map<string, CanVariable> translateData(vector<XmlNode> variableNodes, string dataHex);
  77. };
  78.  
  79. #endif  /* _CANIDTRANSLATOR_H */
  80.  
  81.