Subversion Repositories HomeAutomation

Rev

Rev 969 | 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.     map<string, CanVariable> translateData(string commandName, string moduleName, string dataHex) { return translateData(resolveCommandId(commandName, moduleName), moduleName, dataHex); };
  57.     string translateDataToHex(int commandId, string moduleName, map<string, CanVariable> data);
  58.     string translateDataToHex(string commandName, string moduleName, map<string, CanVariable> data) { return translateDataToHex(resolveCommandId(commandName, moduleName), moduleName, data); };
  59.  
  60.     string lookupNMTCommandName(int commandId);
  61.     int resolveNMTCommandId(string commandName);
  62.     map<string, CanVariable> translateNMTData(int commandId, string rawHexData);
  63.     string translateNMTDataToHex(int commandName, map<string, CanVariable> data);
  64.  
  65. protected:
  66.     CanIdTranslator();
  67.  
  68. private:
  69.     static CanIdTranslator* myInstance;
  70.     XmlNode xmlNode;
  71. };
  72.  
  73. #endif  /* _CANIDTRANSLATOR_H */
  74.  
  75.