RobonetDataElement.cpp
Go to the documentation of this file.
00001 
00006 #include "robot_instance/RobonetDataElement.h"
00007 
00008 using namespace std;
00009 using namespace log4cpp;
00010 
00011 // DataMangler ---------------------------------------------------------
00012 
00013 // Located in header file:
00014 //     template <typename T> T DataMangler::fromUnsignedIntTo(unsigned int data) const
00015 //     template <typename T> uint32_t DataMangler::toUnsignedIntFrom(T value)
00016 
00020 uint32_t DataMangler::combineRawValues(pair<uint16_t, uint16_t> rawPair)
00021 {
00022     return (rawPair.first + (rawPair.second << 16));
00023 }
00024 
00028 pair<uint16_t, uint16_t> DataMangler::separateRawValues(uint32_t value)
00029 {
00030     return pair<uint16_t, uint16_t>((uint16_t) (value & BitMinion::SIXTEEN_BIT_MASK), (uint16_t) ((value >> 16) & BitMinion::SIXTEEN_BIT_MASK));
00031 }
00032 
00033 
00040 template <>
00041 bool DataMangler::fromUnsignedIntTo<bool>(uint32_t data)
00042 {
00043     return data;
00044 }
00045 
00046 // RobonetDataElement -------------------------------------------------------
00047 
00048 // Constants
00049 const BitMinion::BitIndexEnumType     RobonetDataElement::MOTCOM_SIGN_BIT_INDEX      = BitMinion::BIT_EIGHT_INDEX;
00050 const BitMinion::BitIndexEnumType     RobonetDataElement::MOTCOM_CERTIFICATE_INDEX   = BitMinion::BIT_NINE_INDEX;
00051 const BitMinion::BitCountMaskEnumType RobonetDataElement::MOTCOM_CERTIFICATE_SIZE    = BitMinion::THREE_BIT_MASK;
00052 const uint16_t                        RobonetDataElement::MOTCOM_CERTIFICATE_VALUE   = 0x7;
00053 const BitMinion::BitIndexEnumType     RobonetDataElement::BRAKEPWM_CERTIFICATE_INDEX = BitMinion::BIT_FOURTEEN_INDEX;
00054 const BitMinion::BitCountMaskEnumType RobonetDataElement::BRAKEPWM_CERTIFICATE_SIZE  = BitMinion::TWO_BIT_MASK;
00055 const uint16_t                        RobonetDataElement::BRAKEPWM_CERTIFICATE_VALUE = 0x3;
00056 
00071 RobonetDataElement::RobonetDataElement(const std::string& type, DataElement::ReadWrite readWrite, const std::string& channel, const std::string& node, OffsetPair offsetPair, const std::string& group, ElementStyle mangleOption, std::shared_ptr<SMT::Resource> resource)
00072     : DataElement(type, readWrite, resource), channel(channel), node(node), group(group), offsetPair(offsetPair), rawPair(RawPair(0, 0)), style(mangleOption)
00073 {
00074     if ((this->channel.empty()) || (this->node.empty()) || (this->offsetPair.first.empty()) || (this->group.empty()))
00075     {
00076         stringstream err;
00077         err << "RobonetDataElement::RobonetDataElement() - One of the following RobonetDataElement() arguments is empty: channel, node, offsetPair.first, group.";
00078         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00079         throw invalid_argument(err.str());
00080     }
00081 
00082     if ((this->getSize() == ThirtyTwoBit)            &&
00083             (this->offsetPair.second.empty())        &&
00084             (this->style != Temperature)             &&
00085             (this->style != FixedPointMilli)         &&
00086             (this->style != UnsignedFixedPointMilli) &&
00087             (this->style != FixedPointCenti)         &&
00088             (this->style != UnsignedFixedPointCenti) &&
00089             (this->style != PowConTemperature)       &&
00090             (this->style != PowConCurrentMany)       &&
00091             (this->style != PowConVoltageMany))
00092     {
00093         stringstream err;
00094         err << "RobonetDataElement::RobonetDataElement() - For 32-bit RobonetDataElements, offsetPair.second cannot be empty (style == " << this->style << ").";
00095         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00096         throw invalid_argument(err.str());
00097     }
00098 
00099     if ((this->style == MotCom)  && (value.type() != typeid(int16_t)))
00100     {
00101         stringstream err;
00102         err << "RobonetDataElement::RobonetDataElement() - RobonetDataElements for MotCom values must be of type int16_t.";
00103         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00104         throw invalid_argument(err.str());
00105     }
00106 
00107     if ((this->style == Temperature)  && (value.type() != typeid(float)))
00108     {
00109         stringstream err;
00110         err << "RobonetDataElement::RobonetDataElement() - RobonetDataElements for Temperature values must be of type float.";
00111         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00112         throw invalid_argument(err.str());
00113     }
00114 
00115     if ((this->style == BrakePwm)  && (value.type() != typeid(uint16_t)))
00116     {
00117         stringstream err;
00118         err << "RobonetDataElement::RobonetDataElement() - RobonetDataElements for Brake PWM values must be of type uint16_t.";
00119         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00120         throw invalid_argument(err.str());
00121     }
00122 
00123     if ((this->style == FixedPointMilli)  && (value.type() != typeid(float)))
00124     {
00125         stringstream err;
00126         err << "RobonetDataElement::RobonetDataElement() - RobonetDataElements for FixedPointMilli values must be of type float.";
00127         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00128         throw invalid_argument(err.str());
00129     }
00130 
00131     if ((this->style == UnsignedFixedPointMilli)  && (value.type() != typeid(float)))
00132     {
00133         stringstream err;
00134         err << "RobonetDataElement::RobonetDataElement() - RobonetDataElements for UnsignedFixedPointMilli values must be of type float.";
00135         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00136         throw invalid_argument(err.str());
00137     }
00138 
00139     if ((this->style == FixedPointCenti)  && (value.type() != typeid(float)))
00140     {
00141         stringstream err;
00142         err << "RobonetDataElement::RobonetDataElement() - RobonetDataElements for FixedPointCenti values must be of type float.";
00143         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00144         throw invalid_argument(err.str());
00145     }
00146 
00147     if ((this->style == UnsignedFixedPointCenti)  && (value.type() != typeid(float)))
00148     {
00149         stringstream err;
00150         err << "RobonetDataElement::RobonetDataElement() - RobonetDataElements for UnsignedFixedPointCenti values must be of type float.";
00151         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00152         throw invalid_argument(err.str());
00153     }
00154 
00155     if ((this->style == PowConTemperature)  && (value.type() != typeid(float)))
00156     {
00157         stringstream err;
00158         err << "RobonetDataElement::RobonetDataElement() - RobonetDataElements for PowConTemperature values must be of type float.";
00159         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00160         throw invalid_argument(err.str());
00161     }
00162 
00163     if ((this->style == PowConCurrentMany)  && (value.type() != typeid(float)))
00164     {
00165         stringstream err;
00166         err << "RobonetDataElement::RobonetDataElement() - RobonetDataElements for PowConCurrentMany values must be of type float.";
00167         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00168         throw invalid_argument(err.str());
00169     }
00170 
00171     if ((this->style == PowConVoltageMany)  && (value.type() != typeid(float)))
00172     {
00173         stringstream err;
00174         err << "RobonetDataElement::RobonetDataElement() - RobonetDataElements for PowConVoltageMany values must be of type float.";
00175         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00176         throw invalid_argument(err.str());
00177     }
00178 }
00179 
00183 RobonetDataElement::~RobonetDataElement()
00184 {
00185 }
00186 
00187 RobonetDataElement::ElementSize RobonetDataElement::getRawSize()
00188 {
00189     ElementSize size;
00190 
00191     switch (style)
00192     {
00193         case Temperature:
00194             size = SixteenBit;
00195             break;
00196 
00197         default:
00198             size = DataElement::getSize();
00199             break;
00200     }
00201 
00202     return size;
00203 }
00204 
00209 void RobonetDataElement::setChannel(const std::string& channel)
00210 {
00211     if (channel.empty())
00212     {
00213         stringstream err;
00214         err << "RobonetDataElement::setChannel() - Channel cannot be empty.";
00215         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00216         throw invalid_argument(err.str());
00217     }
00218     else
00219     {
00220         this->channel = channel;
00221     }
00222 }
00223 
00228 void RobonetDataElement::setNode(const std::string& node)
00229 {
00230     if (node.empty())
00231     {
00232         stringstream err;
00233         err << "RobonetDataElement::setNode() - Node cannot be empty.";
00234         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00235         throw invalid_argument(err.str());
00236     }
00237     else
00238     {
00239         this->node = node;
00240     }
00241 }
00242 
00247 void RobonetDataElement::setOffsetPair(OffsetPair offsetPair)
00248 {
00249     if (offsetPair.first.empty())
00250     {
00251         stringstream err;
00252         err << "RobonetDataElement::setOffsetPair() - offsetpair.first cannot be empty.";
00253         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00254         throw invalid_argument(err.str());
00255     }
00256     else if ((getSize() == ThirtyTwoBit) && (offsetPair.second.empty()))
00257     {
00258         stringstream err;
00259         err << "RobonetDataElement::setOffsetPair() - For 32-bit RobonetDataElements, offsetPair.second cannot be empty.";
00260         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00261         throw invalid_argument(err.str());
00262     }
00263     else
00264     {
00265         this->offsetPair = offsetPair;
00266     }
00267 }
00268 
00273 void RobonetDataElement::setGroup(const std::string& group)
00274 {
00275     if (group.empty())
00276     {
00277         stringstream err;
00278         err << "RobonetDataElement::setGroup() - group cannot be empty.";
00279         NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ERROR, err.str());
00280         throw invalid_argument(err.str());
00281     }
00282     else
00283     {
00284         this->group = group;
00285     }
00286 }
00287 
00293 std::string RobonetDataElement::getChannel()
00294 {
00295     return this->channel;
00296 }
00297 
00302 std::string RobonetDataElement::getNode()
00303 {
00304     return this->node;
00305 }
00306 
00311 RobonetDataElement::OffsetPair RobonetDataElement::getOffsetPair()
00312 {
00313     return this->offsetPair;
00314 }
00315 
00320 std::string RobonetDataElement::getGroup()
00321 {
00322     return this->group;
00323 }
00324 
00328 RobonetDataElement::RawPair RobonetDataElement::getRawPair()
00329 {
00330     return this->rawPair;
00331 }
00332 
00337 std::string RobonetDataElement::toString()
00338 {
00339     string s;
00340     char   buffer[50];
00341 
00342     s.append("Robonet");
00343     s.append(this->DataElement::toString());
00344     s.append("\n");
00345     s.append("   Raw Value 1: ");
00346     sprintf(buffer, "0x%04X (%d)\n", this->rawPair.first, this->rawPair.first);
00347     s.append(buffer);
00348     s.append("   Raw Value 2: ");
00349     sprintf(buffer, "0x%04X (%d)\n", this->rawPair.second, this->rawPair.second);
00350     s.append(buffer);
00351     s.append("       Channel: ");
00352     s.append(this->channel);
00353     s.append("\n");
00354     s.append("          Node: ");
00355     s.append(this->node);
00356     s.append("\n");
00357     s.append("      Offset 1: ");
00358     s.append(this->offsetPair.first);
00359     s.append("\n");
00360     s.append("      Offset 2: ");
00361     s.append(this->offsetPair.second);
00362     s.append("\n");
00363     s.append("         Group: ");
00364     s.append(this->group);
00365 
00366     return s;
00367 }
00368 
00374 const RobonetDataElement::RawPair RobonetDataElement::pull()
00375 {
00376     RawPair rawPair;
00377 
00378     if (getReadWrite() == Write)
00379     {
00380         const std::type_info* ti = getType();
00381 
00382         bool     negativeSign = false;
00383         uint16_t tempUInt16   = 0;
00384         int16_t  tempInt16    = 0;
00385 
00386         switch (style)
00387         {
00388             case Normal:
00389 
00390                 // possible data types: uint32_t, int32_t, float, uint16_t, int16_t, bool
00391                 if (*ti == typeid(uint32_t))
00392                 {
00393                     rawPair = DataMangler::separateRawValues(getValue<uint32_t>());
00394                 }
00395                 else if (*ti == typeid(int32_t))
00396                 {
00397                     rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<int32_t>(getValue<int32_t>()));
00398                 }
00399                 else if (*ti == typeid(float))
00400                 {
00401                     rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<float>(getValue<float>()));
00402                 }
00403                 else if (*ti == typeid(uint16_t))
00404                 {
00405                     rawPair = DataMangler::separateRawValues(getValue<uint16_t>());
00406                 }
00407                 else if (*ti == typeid(int16_t))
00408                 {
00409                     rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<int16_t>(getValue<int16_t>()) & BitMinion::SIXTEEN_BIT_MASK);
00410                 }
00411                 else if (*ti == typeid(bool))
00412                 {
00413                     rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<bool>(getValue<bool>()) & BitMinion::EIGHT_BIT_MASK);
00414                 }
00415                 else
00416                 {
00417                     stringstream err;
00418                     err << "RobonetDataElement::pull() - How did you get here?";
00419                     NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ALERT, err.str());
00420                     throw runtime_error(err.str());
00421                 }
00422 
00423                 if ((getSize() == SixteenBit) || ((getSize() == EightBit)))
00424                 {
00425                     rawPair.second = 0;
00426 
00427                     if (getSize() == EightBit)
00428                     {
00429                         rawPair.first &= BitMinion::EIGHT_BIT_MASK;
00430                     }
00431                 }
00432 
00433                 this->rawPair = rawPair;
00434                 break;
00435 
00436             case MotCom:
00438 
00439                 tempUInt16 = 0;
00440 
00442                 negativeSign = (getValue<int16_t>() < 0);
00444                 tempUInt16 = abs(getValue<int16_t>());
00446                 tempUInt16 = tempUInt16 & BitMinion::EIGHT_BIT_MASK;
00448                 bitWizard16.setBit(negativeSign, MOTCOM_SIGN_BIT_INDEX, tempUInt16);
00450                 bitWizard16.setBits(MOTCOM_CERTIFICATE_VALUE, MOTCOM_CERTIFICATE_INDEX, MOTCOM_CERTIFICATE_SIZE, tempUInt16);
00451 
00452                 this->rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<uint16_t>(tempUInt16) & BitMinion::SIXTEEN_BIT_MASK);
00453 
00454                 break;
00455 
00456             case Temperature:
00458 
00459                 tempUInt16 = getValue<float>() * 2;
00460 
00461                 this->rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<uint16_t>(tempUInt16) & BitMinion::SIXTEEN_BIT_MASK);
00462                 break;
00463 
00464             case BrakePwm:
00466 
00467                 tempUInt16 = getValue<uint16_t>();
00468 
00470                 bitWizard16.setBits(BRAKEPWM_CERTIFICATE_VALUE, BRAKEPWM_CERTIFICATE_INDEX, BRAKEPWM_CERTIFICATE_SIZE, tempUInt16);
00471 
00472                 this->rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<uint16_t>(tempUInt16)  & BitMinion::SIXTEEN_BIT_MASK);
00473                 break;
00474 
00475             case FixedPointMilli:
00477 
00478                 tempInt16 = getValue<float>() * 1000;
00479 
00480                 this->rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<int16_t>(tempInt16) & BitMinion::SIXTEEN_BIT_MASK);
00481                 break;
00482 
00483             case UnsignedFixedPointMilli:
00485 
00486                 tempUInt16 = getValue<float>() * 1000;
00487 
00488                 this->rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<uint16_t>(tempUInt16) & BitMinion::SIXTEEN_BIT_MASK);
00489                 break;
00490 
00491             case FixedPointCenti:
00493 
00494                 tempInt16 = getValue<float>() * 100;
00495 
00496                 this->rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<int16_t>(tempInt16) & BitMinion::SIXTEEN_BIT_MASK);
00497                 break;
00498 
00499             case UnsignedFixedPointCenti:
00501 
00502                 tempUInt16 = getValue<float>() * 100;
00503 
00504                 this->rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<uint16_t>(tempUInt16) & BitMinion::SIXTEEN_BIT_MASK);
00505                 break;
00506 
00507             case PowConTemperature:
00509 
00510                 tempUInt16 = (getValue<float>() / 100 + 0.5) * (0xFFF / 5);
00511 
00513                 tempUInt16 = tempUInt16 & BitMinion::TWELVE_BIT_MASK;
00514 
00515                 this->rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<uint16_t>(tempUInt16) & BitMinion::SIXTEEN_BIT_MASK);
00516                 break;
00517 
00518             case PowConCurrentMany:
00520 
00521                 tempUInt16 = (0.185 * getValue<float>() + 0.5) * (0xFFF / 5);
00522 
00524                 tempUInt16 = tempUInt16 & BitMinion::TWELVE_BIT_MASK;
00525 
00526                 this->rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<uint16_t>(tempUInt16) & BitMinion::SIXTEEN_BIT_MASK);
00527                 break;
00528 
00529             case PowConVoltageMany:
00531 
00532                 tempUInt16 = getValue<float>() * (0xFFF / 5);
00533 
00535                 tempUInt16 = tempUInt16 & BitMinion::TWELVE_BIT_MASK;
00536 
00537                 this->rawPair = DataMangler::separateRawValues(DataMangler::toUnsignedIntFrom<uint16_t>(tempUInt16) & BitMinion::SIXTEEN_BIT_MASK);
00538                 break;
00539         }
00540     }
00541 
00542     return this->rawPair;
00543 }
00544 
00551 void RobonetDataElement::push(RawPair rawPair)
00552 {
00553     if (getReadWrite() == Read)
00554     {
00555         if ((getSize() == SixteenBit) || ((getSize() == EightBit)))
00556         {
00557             rawPair.second = 0;
00558 
00559             if (getSize() == EightBit)
00560             {
00561                 rawPair.first &= BitMinion::EIGHT_BIT_MASK;
00562             }
00563         }
00564 
00565         this->rawPair = rawPair;
00566         const std::type_info* ti = getType();
00567 
00568         bool     negativeSign = false;
00569         uint16_t tempUInt16   = 0;
00570         int16_t  tempInt16    = 0;
00571         float    tempFloat    = 0;
00572 
00573         switch (style)
00574         {
00575             case Normal:
00576 
00577                 // possible data types: uint32_t, int32_t, float, uint16_t, int16_t, bool
00578                 if (*ti == typeid(uint32_t))
00579                 {
00580                     setValue<uint32_t>( DataMangler::combineRawValues(this->rawPair) );
00581                 }
00582                 else if (*ti == typeid(int32_t))
00583                 {
00584                     setValue<int32_t>( DataMangler::fromUnsignedIntTo<int32_t>(DataMangler::combineRawValues(this->rawPair)) );
00585                 }
00586                 else if (*ti == typeid(float))
00587                 {
00588                     setValue<float>( DataMangler::fromUnsignedIntTo<float>(DataMangler::combineRawValues(this->rawPair)) );
00589                 }
00590                 else if (*ti == typeid(uint16_t))
00591                 {
00592                     setValue<uint16_t>( DataMangler::fromUnsignedIntTo<uint16_t>(DataMangler::combineRawValues(this->rawPair)) & BitMinion::SIXTEEN_BIT_MASK );
00593                 }
00594                 else if (*ti == typeid(int16_t))
00595                 {
00596                     setValue<int16_t>( DataMangler::fromUnsignedIntTo<int16_t>(DataMangler::combineRawValues(this->rawPair)) & BitMinion::SIXTEEN_BIT_MASK );
00597                 }
00598                 else if (*ti == typeid(bool))
00599                 {
00600                     setValue<bool>( ( (DataMangler::fromUnsignedIntTo<bool>(DataMangler::combineRawValues(this->rawPair)) & BitMinion::EIGHT_BIT_MASK) > 0) ? true : false );
00601                 }
00602                 else
00603                 {
00604                     stringstream err;
00605                     err << "RobonetDataElement::push() - How did you get here?";
00606                     NasaCommonLogging::Logger::log("gov.nasa.robonet.RobonetDataElement", Priority::ALERT, err.str());
00607                     throw runtime_error(err.str());
00608                 }
00609 
00610                 break;
00611 
00612             case MotCom:
00614 
00616                 tempUInt16 = DataMangler::fromUnsignedIntTo<uint16_t>(DataMangler::combineRawValues(this->rawPair)) & BitMinion::SIXTEEN_BIT_MASK;
00618                 bitWizard16.setBits(0x0, MOTCOM_CERTIFICATE_INDEX, MOTCOM_CERTIFICATE_SIZE, tempUInt16);
00620                 negativeSign = bitWizard16.getBit(MOTCOM_SIGN_BIT_INDEX, tempUInt16);
00622                 tempUInt16 = tempUInt16 & BitMinion::EIGHT_BIT_MASK;
00623 
00625                 if (negativeSign)
00626                 {
00627                     setValue<int16_t>( -1 * tempUInt16 );
00628                 }
00629                 else
00630                 {
00631                     setValue<int16_t>( tempUInt16 );
00632                 }
00633 
00634                 break;
00635 
00636             case Temperature:
00638 
00639                 tempUInt16 = DataMangler::fromUnsignedIntTo<uint16_t>(DataMangler::combineRawValues(this->rawPair)) & BitMinion::SIXTEEN_BIT_MASK;
00640                 setValue<float>( tempUInt16 / 2.0 );
00641                 break;
00642 
00643             case BrakePwm:
00645 
00646                 tempUInt16 = DataMangler::fromUnsignedIntTo<uint16_t>(DataMangler::combineRawValues(this->rawPair)) & BitMinion::SIXTEEN_BIT_MASK;
00647 
00649                 bitWizard16.setBits(0x0, BRAKEPWM_CERTIFICATE_INDEX, BRAKEPWM_CERTIFICATE_SIZE, tempUInt16);
00650                 setValue<uint16_t>( tempUInt16 );
00651                 break;
00652 
00653             case FixedPointMilli:
00655 
00656                 tempInt16 = DataMangler::fromUnsignedIntTo<int16_t>(DataMangler::combineRawValues(this->rawPair) & BitMinion::SIXTEEN_BIT_MASK);
00657                 tempFloat = tempInt16;
00658                 setValue<float>(tempFloat / 1000.0);
00659                 break;
00660 
00661             case UnsignedFixedPointMilli:
00663 
00664                 tempUInt16 = DataMangler::fromUnsignedIntTo<uint16_t>(DataMangler::combineRawValues(this->rawPair) & BitMinion::SIXTEEN_BIT_MASK);
00665                 tempFloat  = tempUInt16;
00666                 setValue<float>(tempFloat / 1000.0);
00667                 break;
00668 
00669             case FixedPointCenti:
00671 
00672                 tempInt16 = DataMangler::fromUnsignedIntTo<int16_t>(DataMangler::combineRawValues(this->rawPair) & BitMinion::SIXTEEN_BIT_MASK);
00673                 tempFloat = tempInt16;
00674                 setValue<float>(tempFloat / 100.0);
00675                 break;
00676 
00677             case UnsignedFixedPointCenti:
00679 
00680                 tempUInt16 = DataMangler::fromUnsignedIntTo<uint16_t>(DataMangler::combineRawValues(this->rawPair) & BitMinion::SIXTEEN_BIT_MASK);
00681                 tempFloat  = tempUInt16;
00682                 setValue<float>(tempFloat / 100.0);
00683                 break;
00684 
00685             case PowConTemperature:
00687 
00688                 tempUInt16 = DataMangler::fromUnsignedIntTo<uint16_t>(DataMangler::combineRawValues(this->rawPair) & BitMinion::SIXTEEN_BIT_MASK);
00689                 tempFloat  = tempUInt16;
00690                 setValue<float>(100 * ((tempFloat * 5 / 0xFFF) - 0.5));
00691                 break;
00692 
00693             case PowConCurrentMany:
00695 
00696                 tempUInt16 = DataMangler::fromUnsignedIntTo<uint16_t>(DataMangler::combineRawValues(this->rawPair) & BitMinion::SIXTEEN_BIT_MASK);
00697                 tempFloat  = tempUInt16;
00698                 setValue<float>(((tempFloat * 5 / 0xFFF) - 0.5) / 0.185);
00699 
00700                 break;
00701 
00702             case PowConVoltageMany:
00704 
00705                 tempUInt16 = DataMangler::fromUnsignedIntTo<uint16_t>(DataMangler::combineRawValues(this->rawPair) & BitMinion::SIXTEEN_BIT_MASK);
00706                 tempFloat  = tempUInt16;
00707                 setValue<float>(tempFloat * 5 / 0xFFF);
00708                 break;
00709         }
00710     }
00711     else
00712     {
00713         PushToWriteElementException pushToWriteElementException;
00714         throw pushToWriteElementException;
00715     }
00716 }


robot_instance
Author(s):
autogenerated on Sat Jun 8 2019 20:43:12