Rev 1046 | Rev 1049 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1046 | Rev 1048 | ||
|---|---|---|---|
| Line 24... | Line 24... | ||
| 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 | ||
| - | 30 | #include "../Tools/tools.h" |
|
| 29 | 31 | ||
| 30 | class CanVariable |
32 | class CanVariable |
| 31 | { |
33 | { |
| 32 | public: |
34 | public: |
| 33 | CanVariable() {}; |
35 | CanVariable() {}; |
| 34 | CanVariable(string name, string value) |
36 | CanVariable(string name, string value) |
| 35 | { |
37 | { |
| 36 | setName(name); |
38 | setName(name); |
| 37 | setValue(value); |
39 | setValue(value); |
| 38 | }; |
40 | }; |
| 39 | CanVariable(string name, string value, string type, string unit) |
41 | CanVariable(string name, string value, string type, string unit) |
| 40 | { |
42 | { |
| Line 42... | Line 44... | ||
| 42 | setValue(value); |
44 | setValue(value); |
| 43 | setType(type); |
45 | setType(type); |
| 44 | setUnit(unit); |
46 | setUnit(unit); |
| 45 | }; |
47 | }; |
| 46 | ~CanVariable() {}; |
48 | ~CanVariable() {}; |
| 47 | 49 | ||
| 48 | string getName() { return myName; }; |
50 | string getName() { return myName; }; |
| 49 | void setName(string name) { myName = name; }; |
51 | void setName(string name) { myName = name; }; |
| 50 | 52 | ||
| 51 | string getValue() { return myValue; }; |
53 | string getValue() { return myValue; }; |
| 52 | void setValue(string value) { myValue = value; }; |
54 | void setValue(string value) { myValue = value; }; |
| 53 | 55 | ||
| 54 | string getType() { return myType; }; |
56 | string getType() { return myType; }; |
| 55 | void setType(string type) { myType = type; }; |
57 | void setType(string type) { myType = type; }; |
| 56 | 58 | ||
| 57 | string getUnit() { return myUnit; }; |
59 | string getUnit() { return myUnit; }; |
| 58 | void setUnit(string unit) { myUnit = unit; }; |
60 | void setUnit(string unit) { myUnit = unit; }; |
| 59 | 61 | ||
| 60 | unsigned int getBitLength() { return myBitLength; }; |
62 | unsigned int getBitLength() { return myBitLength; }; |
| 61 | void setBitLength(int bitLength) { myBitLength = bitLength; }; |
63 | void setBitLength(int bitLength) { myBitLength = bitLength; }; |
| 62 | 64 | ||
| 63 | unsigned int getStartBit() { return myStartBit; }; |
65 | unsigned int getStartBit() { return myStartBit; }; |
| 64 | void setStartBit(int startBit) { myStartBit = startBit; }; |
66 | void setStartBit(int startBit) { myStartBit = startBit; }; |
| 65 | 67 | ||
| 66 | string getEnumIdValue() |
68 | string getEnumIdValue() |
| 67 | { |
69 | { |
| 68 | for (map<string, string>::iterator iter; iter != myEnumValues.end(); iter++) |
70 | for (map<string, string>::iterator iter; iter != myEnumValues.end(); iter++) |
| 69 | { |
71 | { |
| 70 | if (iter->second == myValue) |
72 | if (iter->second == myValue) |
| 71 | { |
73 | { |
| 72 | return iter->first; |
74 | return iter->first; |
| 73 | } |
75 | } |
| - | 76 | } |
|
| - | 77 | ||
| - | 78 | return ""; |
|
| - | 79 | } |
|
| - | 80 | ||
| - | 81 | string getEnumsString() |
|
| - | 82 | { |
|
| - | 83 | string enumString = ""; |
|
| - | 84 | for (map<string, string>::iterator iter; iter != myEnumValues.end(); iter++) |
|
| - | 85 | { |
|
| - | 86 | enumString += iter->first + "=" + iter->second + ","; |
|
| 74 | } |
87 | } |
| 75 | 88 | ||
| - | 89 | enumString = trim(enumString, ','); |
|
| - | 90 | ||
| 76 | return |
91 | return enumString; |
| 77 | } |
92 | } |
| 78 | 93 | ||
| 79 | void addEnumValue(string id, string name) |
94 | void addEnumValue(string id, string name) |
| 80 | { |
95 | { |
| 81 | myEnumValues[id] = name; |
96 | myEnumValues[id] = name; |