Subversion Repositories HomeAutomation

Rev

Rev 1599 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. /*
  2.  *
  3.  *    Copyright (C) 2010  Mattias Runge
  4.  *
  5.  *    This program is free software; you can redistribute it and/or modify
  6.  *    it under the terms of the GNU General Public License as published by
  7.  *    the Free Software Foundation; either version 2 of the License, or
  8.  *    (at your option) any later version.
  9.  *
  10.  *    This program is distributed in the hope that it will be useful,
  11.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *    GNU General Public License for more details.
  14.  *
  15.  *    You should have received a copy of the GNU General Public License along
  16.  *    with this program; if not, write to the Free Software Foundation, Inc.,
  17.  *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18.  *
  19.  */
  20.  
  21. #ifndef CAN_PROTOCOL_H
  22. #define CAN_PROTOCOL_H
  23.  
  24. #include <boost/shared_ptr.hpp>
  25.  
  26. #include <string>
  27.  
  28. #include "xml/Node.h"
  29. #include "logging/Logger.h"
  30.  
  31. namespace atom {
  32. namespace can {
  33.  
  34. class Protocol
  35. {
  36. public:
  37.     typedef boost::shared_ptr<Protocol> Pointer;
  38.    
  39.     virtual ~Protocol();
  40.    
  41.     static Pointer Instance();
  42.     static void Delete();
  43.    
  44.     bool Load(std::string filename);
  45.    
  46.    
  47.     std::string LookupClassName(unsigned int class_id);
  48.     unsigned int ResolveClassId(std::string className);
  49.    
  50.     std::string LookupDirectionFlag(unsigned int direction_flag);
  51.     unsigned int ResolveDirectionFlag(std::string direction_name);
  52.    
  53.     std::string LookupModuleName(unsigned int module_id);
  54.     unsigned int ResolveModuleId(std::string module_name);
  55.    
  56.     std::string LookupCommandName(unsigned int command_id, std::string module_name);
  57.     unsigned int ResolveCommandId(std::string command_name, std::string module_name);
  58.    
  59.     std::string GetDefineId(std::string name, std::string group);
  60.    
  61.     std::string LookupNMTCommandName(unsigned int command_id);
  62.     unsigned int ResolveNMTCommandId(std::string command_name);
  63.  
  64.     xml::Node::NodeList GetCommandVariables(std::string command_name, std::string module_name);
  65.     xml::Node::NodeList GetNMTCommandVariables(std::string command_name);
  66.    
  67.    
  68.     /*
  69.    
  70.     std::map<std::string, CanVariable> TranslateData(unsigned int command_id, std::string module_name, std::string data_hex);
  71.     std::string TranslateDataToHex(unsigned int command_id, std::string module_name, std::map<std::string, CanVariable> &data);
  72.    
  73.         void MakeDataValid(int command_id, std::string module_name, std::map<std::string, CanVariable> &data);
  74.    
  75.    
  76.         std::map<std::string, CanVariable> TranslateNMTData(unsigned int command_id, std::string raw_hex_data);
  77.         std::string TranslateNMTDataToHex(std::string command_name, std::map<std::string, CanVariable> &data);
  78.    
  79.         void MakeNMTDataValid(std::string command_name, std::map<std::string, CanVariable> &data);*/
  80.    
  81. private:
  82.     static Pointer instance_;
  83.    
  84.     xml::Node root_node_;
  85.    
  86.     Protocol();
  87.     /*
  88.         std::string translateValidDataToHex(std::map<std::string, CanVariable> &data);
  89.         std::map<std::string, CanVariable> translateData(xml::Node::NodeList variable_nodes, std::string data_hex);
  90.    
  91.         void makeDataValid(xml::Node::NodeList variable_nodes, std::map<std::string, CanVariable> &data);*/
  92.        
  93.     logging::Logger LOG;
  94. };
  95.  
  96. }; // namespace can
  97. }; // namespace atom
  98.  
  99. #endif // CAN_PROTOCOL_H
  100.