Subversion Repositories HomeAutomation

Rev

Rev 986 | Blame | 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 "../Settings/settings.h"
  33. #include "../Xml/xmlnode.h"
  34.  
  35. class CanIdTranslator
  36. {
  37. public:
  38.     static CanIdTranslator& getInstance();
  39.     static void deleteInstance();
  40.  
  41.     string lookupClassName(int classId);
  42.     int resolveClassId(string className);
  43.  
  44.     string lookupDirectionFlag(int directionFlag);
  45.     int resolveDirectionFlag(string directionName);
  46.  
  47.     string lookupModuleName(int moduleId);
  48.     int resolveModuleId(string moduleName);
  49.  
  50.     string lookupCommandName(int commandId, string moduleName);
  51.     int resolveCommandId(string commandName, string moduleName);
  52.  
  53.     string getDefineId(string name, string group);
  54.  
  55.     map<string, CanVariable> translateData(int commandId, string moduleName, string dataHex);
  56.     string translateDataToHex(int commandId, string moduleName, map<string, CanVariable> &data);
  57.     void makeDataValid(int commandId, string moduleName, map<string, CanVariable> &data);
  58.  
  59.     string lookupNMTCommandName(int commandId);
  60.     int resolveNMTCommandId(string commandName);
  61.  
  62.     map<string, CanVariable> translateNMTData(int commandId, string rawHexData);
  63.     string translateNMTDataToHex(int commandId, map<string, CanVariable> &data);
  64.     void makeNMTDataValid(int commandId, map<string, CanVariable> &data);
  65.  
  66. protected:
  67.     CanIdTranslator();
  68.  
  69. private:
  70.     static CanIdTranslator* myInstance;
  71.     XmlNode xmlNode;
  72.  
  73.     void makeDataValid(vector<XmlNode> variableNodes, map<string, CanVariable> &data);
  74.     string translateValidDataToHex(map<string, CanVariable> &data);
  75.     map<string, CanVariable> translateData(vector<XmlNode> variableNodes, string dataHex);
  76. };
  77.  
  78. #endif  /* _CANIDTRANSLATOR_H */
  79.  
  80.