Subversion Repositories HomeAutomation

Rev

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.     map<string, CanVariable> translateHeartbeatData(string dataHex);
  42.  
  43.     string lookupClassName(int classId);
  44.     int resolveClassId(string className);
  45.  
  46.     string lookupDirectionFlag(int directionFlag);
  47.     int resolveDirectionFlag(string directionName);
  48.  
  49.     string lookupModuleName(int moduleId);
  50.     int resolveModuleId(string moduleName);
  51.  
  52.     string lookupCommandName(int commandId, string moduleName);
  53.     int resolveCommandId(string commandName, string moduleName);
  54.  
  55.     string getDefineId(string name, string group);
  56.  
  57.     map<string, CanVariable> translateData(int commandId, string moduleName, string dataHex);
  58.     map<string, CanVariable> translateData(string commandName, string moduleName, string dataHex) { return translateData(resolveCommandId(commandName, moduleName), moduleName, dataHex); };
  59.     string translateDataToHex(int commandId, string moduleName, map<string, CanVariable> data);
  60.     string translateDataToHex(string commandName, string moduleName, map<string, CanVariable> data) { return translateDataToHex(resolveCommandId(commandName, moduleName), moduleName, data); };
  61.  
  62. protected:
  63.     CanIdTranslator();
  64.  
  65. private:
  66.     static CanIdTranslator* myInstance;
  67.     XmlNode xmlNode;
  68. };
  69.  
  70. #endif  /* _CANIDTRANSLATOR_H */
  71.  
  72.