00001 /* 00002 * MKValue.cpp 00003 * 00004 * Created on: Nov 25, 2011 00005 * Author: mriedel 00006 */ 00007 00008 #include <tk_mkinterface/MKValue.hpp> 00009 00010 // lexical cast 00011 #include <boost/lexical_cast.hpp> 00012 00013 namespace TELEKYB_NAMESPACE { 00014 00015 MKValue::MKValue(const std::string& name_, MKInt id_) 00016 : name(name_), id(id_), value(0), stamp(Time::Zero()) 00017 { 00018 // TODO Auto-generated constructor stub 00019 00020 } 00021 00022 MKValue::~MKValue() 00023 { 00024 // TODO Auto-generated destructor stub 00025 } 00026 00027 bool MKValue::isUnset() const 00028 { 00029 return stamp.isZero(); 00030 } 00031 00032 MKSingleValuePacket MKValue::getMKSingleValuePacket() const 00033 { 00034 return MKSingleValuePacket(id,value); 00035 } 00036 00037 MKSingleValuePacket MKValue::getMKSingleValuePacketWithValue(MKInt value_) const 00038 { 00039 return MKSingleValuePacket(id, value_); 00040 } 00041 00042 //MKSingleIdPacket MKValue::getMKSingleIdPacket() const 00043 //{ 00044 // MKSingleIdPacket packet; 00045 // packet.id = id; 00046 // return packet; 00047 //} 00048 00049 // Setters / Getters 00050 MKInt MKValue::getID() const 00051 { 00052 return id; 00053 } 00054 //void MKValue::setID(MKInt id_) 00055 //{ 00056 // id = id_; 00057 //} 00058 00059 MKInt MKValue::getValue() const 00060 { 00061 return value; 00062 } 00063 void MKValue::setValue(MKInt value_) 00064 { 00065 //ROS_INFO_STREAM("Updated " << name << " with " << value_); 00066 stamp = Time(); // current Time 00067 value = value_; 00068 } 00069 00070 std::string MKValue::toString() const 00071 { 00072 return name + "(" + boost::lexical_cast<std::string>(id) + ") " + boost::lexical_cast<std::string>(value); 00073 } 00074 00075 00076 } /* namespace telekyb */