Subversion Repositories HomeAutomation

Rev

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

Rev Author Line No. Line
969 runge 1
/***************************************************************************
2
 *   Copyright (C) December 5, 2008 by Mattias Runge                             *
3
 *   mattias@runge.se                                                      *
4
 *   canvariable.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 _CANVARIABLE_H
23
#define _CANVARIABLE_H
24
 
25
using namespace std;
26
 
27
#include <string>
1046 runge 28
#include <map>
969 runge 29
 
1048 runge 30
#include "../Tools/tools.h"
31
 
969 runge 32
class CanVariable
33
{
34
public:
35
    CanVariable() {};
36
    CanVariable(string name, string value)
37
    {
38
        setName(name);
39
        setValue(value);
40
    };
41
    CanVariable(string name, string value, string type, string unit)
42
    {
43
        setName(name);
44
        setValue(value);
45
        setType(type);
46
        setUnit(unit);
47
    };
48
    ~CanVariable() {};
49
 
50
    string getName() { return myName; };
51
    void setName(string name) { myName = name; };
52
 
53
    string getValue() { return myValue; };
54
    void setValue(string value) { myValue = value; };
55
 
56
    string getType() { return myType; };
57
    void setType(string type) { myType = type; };
58
 
59
    string getUnit() { return myUnit; };
60
    void setUnit(string unit) { myUnit = unit; };
61
 
1046 runge 62
    unsigned int getBitLength() { return myBitLength; };
969 runge 63
    void setBitLength(int bitLength) { myBitLength = bitLength; };
64
 
1046 runge 65
    unsigned int getStartBit() { return myStartBit; };
969 runge 66
    void setStartBit(int startBit) { myStartBit = startBit; };
67
 
1046 runge 68
    string getEnumIdValue()
69
    {
1049 runge 70
        if (myEnumValues.find(myValue) != myEnumValues.end())
1046 runge 71
        {
1049 runge 72
            return myEnumValues[myValue];
1046 runge 73
        }
74
 
75
        return "";
76
    }
77
 
1048 runge 78
    string getEnumsString()
79
    {
80
        string enumString = "";
81
        for (map<string, string>::iterator iter; iter != myEnumValues.end(); iter++)
82
        {
83
            enumString += iter->first + "=" + iter->second + ",";
84
        }
85
 
86
        enumString = trim(enumString, ',');
87
 
88
        return enumString;
89
    }
90
 
1046 runge 91
    void addEnumValue(string id, string name)
92
    {
93
        myEnumValues[id] = name;
94
    }
95
 
969 runge 96
private:
97
    string myName;
98
    string myValue;
99
    string myType;
100
    string myUnit;
1046 runge 101
    unsigned int myBitLength;
102
    unsigned int myStartBit;
103
    map<string, string> myEnumValues;
969 runge 104
};
105
 
106
#endif  /* _CANVARIABLE_H */
107