Subversion Repositories HomeAutomation

Rev

Rev 1642 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1642 Rev 1987
1
/*
1
/*
2
 *
2
 *
3
 *  Copyright (C) 2010  Mattias Runge
3
 *  Copyright (C) 2010  Mattias Runge
4
 *
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
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
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
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
8
 *  (at your option) any later version.
9
 *
9
 *
10
 *  This program is distributed in the hope that it will be useful,
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
13
 *  GNU General Public License for more details.
14
 *
14
 *
15
 *  You should have received a copy of the GNU General Public License along
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.,
16
 *  with this program; if not, write to the Free Software Foundation, Inc.,
17
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
 *
18
 *
19
 */
19
 */
20
 
20
 
21
#ifndef CONTROL_CODE_H
21
#ifndef CONTROL_CODE_H
22
#define CONTROL_CODE_H
22
#define CONTROL_CODE_H
23
 
23
 
24
#include <string>
24
#include <string>
25
 
25
 
26
#include <boost/shared_ptr.hpp>
26
#include <boost/shared_ptr.hpp>
27
 
27
 
28
#include "common/Byteset.h"
28
#include "common/Byteset.h"
29
#include "logging/Logger.h"
-
 
30
 
29
 
31
namespace atom {
30
namespace atom {
32
namespace control {
31
namespace control {
33
 
32
 
34
class Code
33
class Code
35
{
34
{
36
public:
35
public:
37
    typedef boost::shared_ptr<Code> Pointer;
36
  typedef boost::shared_ptr<Code> Pointer;
38
   
37
 
39
    Code();
38
  Code();
40
    virtual ~Code();
39
  virtual ~Code();
41
   
40
 
42
    bool LoadIntelHexFile(std::string filename);
41
  bool LoadIntelHexFile(std::string filename);
43
    bool ParseIntelHex(std::string data);
42
  bool ParseIntelHex(std::string data);
44
   
43
 
45
    unsigned int GetAddressLower();
44
  unsigned int GetAddressLower();
46
    unsigned int GetAddressUpper();
45
  unsigned int GetAddressUpper();
47
    unsigned char GetByte(unsigned int address);
46
  unsigned char GetByte(unsigned int address);
48
    unsigned int GetChecksum();
47
  unsigned int GetChecksum();
49
    unsigned int GetLength();
48
  unsigned int GetLength();
50
    bool IsValid();
49
  bool IsValid();
51
    void Reset();
50
  void Reset();
52
    void AddByte(unsigned char byte);
51
  void AddByte(unsigned char byte);
53
   
52
 
54
private:
53
private:
55
    common::Byteset data_;
54
  common::Byteset data_;
56
    bool is_valid_;
55
  bool            is_valid_;
57
    unsigned int address_lower_;
56
  unsigned int    address_lower_;
58
    unsigned int address_upper_;
57
  unsigned int    address_upper_;
59
    unsigned int checksum_;
58
  unsigned int    checksum_;
60
   
-
 
61
    logging::Logger LOG;
-
 
62
   
-
 
63
   
59
 
64
    void CalculateChecksum();
60
  void CalculateChecksum();
65
   
-
 
66
};
61
};
67
 
62
 
68
}; // namespace control
63
}; // namespace control
69
}; // namespace atom
64
}; // namespace atom
70
 
65
 
71
#endif // CONTROL_CODE_H
66
#endif // CONTROL_CODE_H
72
 
67