Subversion Repositories HomeAutomation

Rev

Rev 969 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 969 Rev 983
1
/***************************************************************************
1
/***************************************************************************
2
 *   Copyright (C) November 28, 2008 by Mattias Runge                             *
2
 *   Copyright (C) November 28, 2008 by Mattias Runge                             *
3
 *   mattias@runge.se                                                      *
3
 *   mattias@runge.se                                                      *
4
 *   canmessage.h                                            *
4
 *   canmessage.h                                            *
5
 *                                                                         *
5
 *                                                                         *
6
 *   This program is free software; you can redistribute it and/or modify  *
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  *
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     *
8
 *   the Free Software Foundation; either version 2 of the License, or     *
9
 *   (at your option) any later version.                                   *
9
 *   (at your option) any later version.                                   *
10
 *                                                                         *
10
 *                                                                         *
11
 *   This program is distributed in the hope that it will be useful,       *
11
 *   This program is distributed in the hope that it will be useful,       *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU General Public License for more details.                          *
14
 *   GNU General Public License for more details.                          *
15
 *                                                                         *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU General Public License     *
16
 *   You should have received a copy of the GNU General Public License     *
17
 *   along with this program; if not, write to the                         *
17
 *   along with this program; if not, write to the                         *
18
 *   Free Software Foundation, Inc.,                                       *
18
 *   Free Software Foundation, Inc.,                                       *
19
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
20
 ***************************************************************************/
20
 ***************************************************************************/
21
 
21
 
22
#ifndef _CANMESSAGE_H
22
#ifndef _CANMESSAGE_H
23
#define _CANMESSAGE_H
23
#define _CANMESSAGE_H
24
 
24
 
25
using namespace std;
25
using namespace std;
26
 
26
 
27
#include <string>
27
#include <string>
28
#include <map>
28
#include <map>
29
 
29
 
30
#include "canmessageexception.h"
30
#include "canmessageexception.h"
31
#include "canidtranslator.h"
31
#include "canidtranslator.h"
32
#include "canvariable.h"
32
#include "canvariable.h"
33
#include "../Tools/tools.h"
33
#include "../Tools/tools.h"
34
 
34
 
35
class CanMessage
35
class CanMessage
36
{
36
{
37
public:
37
public:
38
    CanMessage() { myIsUnknown = false; myModuleId = 0; };
38
    CanMessage() { myIsUnknown = false; myModuleId = 0; myIsHeartbeat = false; };
39
    CanMessage(string raw) { setRaw(raw); };
39
    CanMessage(string raw) { setRaw(raw); };
40
 
40
 
41
    void setRaw(string rawHex);
41
    void setRaw(string rawHex);
42
    string getRaw();
42
    string getRaw();
43
    string getJSON();
43
    string getJSON();
44
    void setJSON(string json);
44
    void setJSON(string json);
45
    string getRawHeaderBin() { return myRawHeaderBin; };
45
    string getRawHeaderBin() { return myRawHeaderBin; };
46
 
46
 
47
    bool isHeartbeat() { return myIsHeartbeat; };
47
    bool isHeartbeat() { return myIsHeartbeat; };
48
    bool isUnknown() { return myIsUnknown; };
48
    bool isUnknown() { return myIsUnknown; };
49
   
49
   
50
    string getClassName() { return myClassName; };
50
    string getClassName() { return myClassName; };
51
    void setClassName(string className) { myClassName = className; }; ///FIXME: Check if data is valid
51
    void setClassName(string className) { myClassName = className; }; ///FIXME: Check if data is valid
52
 
52
 
53
    string getDirectionFlag() { return myDirectionFlag; };
53
    string getDirectionFlag() { return myDirectionFlag; };
54
    void setDirectionFlag(string directionFlag) { myDirectionFlag = directionFlag; }; ///FIXME: Check if data is valid
54
    void setDirectionFlag(string directionFlag) { myDirectionFlag = directionFlag; }; ///FIXME: Check if data is valid
55
 
55
 
56
    string getModuleName() { return myModuleName; };
56
    string getModuleName() { return myModuleName; };
57
    void setModuleName(string moduleName) { myModuleName = moduleName; }; ///FIXME: Check if data is valid
57
    void setModuleName(string moduleName) { myModuleName = moduleName; }; ///FIXME: Check if data is valid
58
 
58
 
59
    unsigned int getModuleId() { return myModuleId; };
59
    unsigned int getModuleId() { return myModuleId; };
60
    void setModuleId(unsigned int moduleId) { myModuleId = moduleId; };
60
    void setModuleId(unsigned int moduleId) { myModuleId = moduleId; };
61
 
61
 
62
    string getCommandName() { return myCommandName; };
62
    string getCommandName() { return myCommandName; };
63
    void setCommandName(string commandName) { myCommandName = commandName; }; ///FIXME: Check if data is valid
63
    void setCommandName(string commandName) { myCommandName = commandName; }; ///FIXME: Check if data is valid
64
 
64
 
65
    map<string, CanVariable>& getData() { return myData; };
65
    map<string, CanVariable>& getData() { return myData; };
66
    string getJSONData();
66
    string getJSONData();
67
    void setData(map<string, CanVariable> data) { myData = data; }; ///FIXME: Check if data is valid
67
    void setData(map<string, CanVariable> data) { myData = data; }; ///FIXME: Check if data is valid
68
   
68
   
69
private:
69
private:
70
    bool myIsUnknown;
70
    bool myIsUnknown;
71
    bool myIsHeartbeat;
71
    bool myIsHeartbeat;
72
    string myClassName;
72
    string myClassName;
73
    string myDirectionFlag;
73
    string myDirectionFlag;
74
    string myModuleName;
74
    string myModuleName;
75
    unsigned int myModuleId;
75
    unsigned int myModuleId;
76
    string myCommandName;
76
    string myCommandName;
77
    map<string, CanVariable> myData;
77
    map<string, CanVariable> myData;
78
    string myRawHeaderBin;
78
    string myRawHeaderBin;
79
};
79
};
80
 
80
 
81
#endif  /* _CANMESSAGE_H */
81
#endif  /* _CANMESSAGE_H */
82
 
82
 
83
 
83