YouBotJointParameterReadOnly.cpp

Go to the documentation of this file.
00001 /****************************************************************
00002  *
00003  * Copyright (c) 2011
00004  * All rights reserved.
00005  *
00006  * Hochschule Bonn-Rhein-Sieg
00007  * University of Applied Sciences
00008  * Computer Science Department
00009  *
00010  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00011  *
00012  * Author:
00013  * Jan Paulus, Nico Hochgeschwender, Michael Reckhaus, Azamat Shakhimardanov
00014  * Supervised by:
00015  * Gerhard K. Kraetzschmar
00016  *
00017  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00018  *
00019  * This sofware is published under a dual-license: GNU Lesser General Public 
00020  * License LGPL 2.1 and BSD license. The dual-license implies that users of this
00021  * code may choose which terms they prefer.
00022  *
00023  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00024  *
00025  * Redistribution and use in source and binary forms, with or without
00026  * modification, are permitted provided that the following conditions are met:
00027  *
00028  *     * Redistributions of source code must retain the above copyright
00029  *       notice, this list of conditions and the following disclaimer.
00030  *     * Redistributions in binary form must reproduce the above copyright
00031  *       notice, this list of conditions and the following disclaimer in the
00032  *       documentation and/or other materials provided with the distribution.
00033  *     * Neither the name of the Hochschule Bonn-Rhein-Sieg nor the names of its
00034  *       contributors may be used to endorse or promote products derived from
00035  *       this software without specific prior written permission.
00036  *
00037  * This program is free software: you can redistribute it and/or modify
00038  * it under the terms of the GNU Lesser General Public License LGPL as
00039  * published by the Free Software Foundation, either version 2.1 of the
00040  * License, or (at your option) any later version or the BSD license.
00041  *
00042  * This program is distributed in the hope that it will be useful,
00043  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00044  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00045  * GNU Lesser General Public License LGPL and the BSD license for more details.
00046  *
00047  * You should have received a copy of the GNU Lesser General Public
00048  * License LGPL and BSD license along with this program.
00049  *
00050  ****************************************************************/
00051 #include "youbot/YouBotJointParameterReadOnly.hpp"
00052 namespace youbot {
00053 
00054 YouBotJointParameterReadOnly::YouBotJointParameterReadOnly() {
00055   // Bouml preserved body begin 0006FDF1
00056   // Bouml preserved body end 0006FDF1
00057 }
00058 
00059 YouBotJointParameterReadOnly::~YouBotJointParameterReadOnly() {
00060   // Bouml preserved body begin 0006FE71
00061   // Bouml preserved body end 0006FE71
00062 }
00063 
00064 ActualMotorVoltage::ActualMotorVoltage() {
00065   // Bouml preserved body begin 0007E071
00066     this->name = "ActualMotorVoltage";
00067     this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00068   // Bouml preserved body end 0007E071
00069 }
00070 
00071 ActualMotorVoltage::~ActualMotorVoltage() {
00072   // Bouml preserved body begin 0007E0F1
00073   // Bouml preserved body end 0007E0F1
00074 }
00075 
00076 void ActualMotorVoltage::getParameter(quantity<electric_potential>& parameter) const {
00077   // Bouml preserved body begin 0007E171
00078     parameter = this->value;
00079   // Bouml preserved body end 0007E171
00080 }
00081 
00082 void ActualMotorVoltage::toString(std::string& value) {
00083   // Bouml preserved body begin 0009EC71
00084   std::stringstream ss;
00085   ss << this->name << ": " << this->value;
00086   value  = ss.str();
00087   // Bouml preserved body end 0009EC71
00088 }
00089 
00090 void ActualMotorVoltage::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00091   // Bouml preserved body begin 0007E1F1
00092     message.stctOutput.commandNumber = msgType;
00093     message.stctOutput.moduleAddress = DRIVE;
00094     message.stctOutput.typeNumber = 151; //ActualMotorVoltage
00095   //  message.stctOutput.value = value;
00096 
00097   // Bouml preserved body end 0007E1F1
00098 }
00099 
00100 void ActualMotorVoltage::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00101   // Bouml preserved body begin 0007E271
00102     if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00103       double temp = message.stctInput.value;
00104       this->value = temp/100.0 * volt; //TODO do convertion
00105     }
00106   // Bouml preserved body end 0007E271
00107 }
00108 
00109 ErrorAndStatus::ErrorAndStatus() {
00110   // Bouml preserved body begin 0007E771
00111     this->name = "ErrorAndStatus";
00112     this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00113   // Bouml preserved body end 0007E771
00114 }
00115 
00116 ErrorAndStatus::~ErrorAndStatus() {
00117   // Bouml preserved body begin 0007E7F1
00118   // Bouml preserved body end 0007E7F1
00119 }
00120 
00121 void ErrorAndStatus::getParameter(unsigned int& parameter) const {
00122   // Bouml preserved body begin 0007E871
00123     parameter = this->value;
00124     this->parseYouBotErrorFlags();
00125   // Bouml preserved body end 0007E871
00126 }
00127 
00128 void ErrorAndStatus::toString(std::string& value) {
00129   // Bouml preserved body begin 0009ED71
00130   std::stringstream ss;
00131   ss << this->name << ": " << this->value;
00132   value  = ss.str();
00133   // Bouml preserved body end 0009ED71
00134 }
00135 
00136 void ErrorAndStatus::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00137   // Bouml preserved body begin 0007E8F1
00138     message.stctOutput.commandNumber = msgType;
00139     message.stctOutput.moduleAddress = DRIVE;
00140     message.stctOutput.typeNumber = 156; //ErrorAndStatus
00141  //   message.stctOutput.value = value;
00142 
00143   // Bouml preserved body end 0007E8F1
00144 }
00145 
00146 void ErrorAndStatus::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00147   // Bouml preserved body begin 0007E971
00148     if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00149       this->value = message.stctInput.value;
00150     }
00151   // Bouml preserved body end 0007E971
00152 }
00153 
00154 void ErrorAndStatus::parseYouBotErrorFlags() const {
00155   // Bouml preserved body begin 0007EAF1
00156    // std::stringstream errorMessageStream;
00157    // errorMessageStream << "Joint " << this->jointNumber << " ";
00158     std::string errorMessage;
00159    // errorMessage = errorMessageStream.str();
00160 
00161 
00162     if (value & OVER_CURRENT) {
00163       LOG(warning) << errorMessage << "over current";
00164       //    throw JointErrorException(errorMessage + "got over current");
00165     }
00166 
00167     if (value & UNDER_VOLTAGE) {
00168       LOG(warning) << errorMessage << "under voltage";
00169       //    throw JointErrorException(errorMessage + "got under voltage");
00170     }
00171 
00172     if (value & OVER_VOLTAGE) {
00173       LOG(warning) << errorMessage << "over voltage";
00174       //   throw JointErrorException(errorMessage + "got over voltage");
00175     }
00176 
00177     if (value & OVER_TEMPERATURE) {
00178       LOG(warning) << errorMessage << "over temperature";
00179       //   throw JointErrorException(errorMessage + "got over temperature");
00180     }
00181 
00182     if (value & MOTOR_HALTED) {
00183       LOG(info) << errorMessage << "is halted";
00184       //   throw JointErrorException(errorMessage + "is halted");
00185     }
00186 
00187     if (value & HALL_SENSOR_ERROR) {
00188       LOG(warning) << errorMessage << "hall sensor problem";
00189       //   throw JointErrorException(errorMessage + "got hall sensor problem");
00190     }
00191 
00192 //    if (value & PWM_MODE_ACTIVE) {
00193 //      LOG(info) << errorMessage << "PWM mode active";
00194       //   throw JointErrorException(errorMessage + "the cycle time is violated");
00195 //    }
00196 
00197     if (value & VELOCITY_MODE) {
00198       LOG(info) << errorMessage << "velocity mode active";
00199       //   throw JointErrorException(errorMessage + "need to initialize the sinus commutation");
00200     }
00201 
00202     if (value & POSITION_MODE) {
00203       LOG(info) << errorMessage << "position mode active";
00204       //   throw JointErrorException(errorMessage + "need to initialize the sinus commutation");
00205     }
00206 
00207     if (value & TORQUE_MODE) {
00208       LOG(info) << errorMessage << "torque mode active";
00209       //   throw JointErrorException(errorMessage + "need to initialize the sinus commutation");
00210     }
00211 
00212     if (value & POSITION_REACHED) {
00213       LOG(info) << errorMessage << "position reached";
00214       //   throw JointErrorException(errorMessage + "need to initialize the sinus commutation");
00215     }
00216 
00217     if (value & INITIALIZED) {
00218       LOG(info) << errorMessage << "is initialized";
00219       //   throw JointErrorException(errorMessage + "need to initialize the sinus commutation");
00220     }
00221 
00222     if (value & TIMEOUT) {
00223       LOG(warning) << errorMessage << "timeout";
00224       //   throw JointErrorException(errorMessage + "need to initialize the sinus commutation");
00225     }
00226 
00227     if (value & I2T_EXCEEDED) {
00228       LOG(warning) << errorMessage << "I2t exceeded";
00229       //   throw JointErrorException(errorMessage + "need to initialize the sinus commutation");
00230     }
00231 
00232   // Bouml preserved body end 0007EAF1
00233 }
00234 
00235 PositionError::PositionError() {
00236   // Bouml preserved body begin 00081771
00237     this->name = "PositionError";
00238     this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00239   // Bouml preserved body end 00081771
00240 }
00241 
00242 PositionError::~PositionError() {
00243   // Bouml preserved body begin 000817F1
00244   // Bouml preserved body end 000817F1
00245 }
00246 
00247 void PositionError::getParameter(quantity<plane_angle>& parameter) const {
00248   // Bouml preserved body begin 00081871
00249     parameter = this->value;
00250   // Bouml preserved body end 00081871
00251 }
00252 
00253 void PositionError::toString(std::string& value) {
00254   // Bouml preserved body begin 0009EDF1
00255   std::stringstream ss;
00256   ss << this->name << ": " << this->value;
00257   value  = ss.str();
00258   // Bouml preserved body end 0009EDF1
00259 }
00260 
00261 void PositionError::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00262   // Bouml preserved body begin 00081971
00263     message.stctOutput.commandNumber = msgType;
00264     message.stctOutput.moduleAddress = DRIVE;
00265     message.stctOutput.typeNumber = 226; //PositionError
00266 //    message.stctOutput.value = value;
00267   // Bouml preserved body end 00081971
00268 }
00269 
00270 void PositionError::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00271   // Bouml preserved body begin 000819F1
00272     double temp = (int)message.stctInput.value;
00273     value = (temp / storage.encoderTicksPerRound) * storage.gearRatio * (2.0 * M_PI) * radian;
00274   // Bouml preserved body end 000819F1
00275 }
00276 
00277 PositionErrorSum::PositionErrorSum() {
00278   // Bouml preserved body begin 00081B71
00279     this->name = "PositionErrorSum";
00280     this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00281   // Bouml preserved body end 00081B71
00282 }
00283 
00284 PositionErrorSum::~PositionErrorSum() {
00285   // Bouml preserved body begin 00081BF1
00286   // Bouml preserved body end 00081BF1
00287 }
00288 
00289 void PositionErrorSum::getParameter(quantity<plane_angle>& parameter) const {
00290   // Bouml preserved body begin 00081C71
00291     parameter = this->value;
00292   // Bouml preserved body end 00081C71
00293 }
00294 
00295 void PositionErrorSum::toString(std::string& value) {
00296   // Bouml preserved body begin 0009EE71
00297   std::stringstream ss;
00298   ss << this->name << ": " << this->value;
00299   value  = ss.str();
00300   // Bouml preserved body end 0009EE71
00301 }
00302 
00303 void PositionErrorSum::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00304   // Bouml preserved body begin 00081D71
00305 
00306     message.stctOutput.commandNumber = msgType;
00307     message.stctOutput.moduleAddress = DRIVE;
00308     message.stctOutput.typeNumber = 227; //PositionErrorSum
00309  //   message.stctOutput.value = value;
00310 
00311   // Bouml preserved body end 00081D71
00312 }
00313 
00314 void PositionErrorSum::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00315   // Bouml preserved body begin 00081DF1
00316     double temp = (int)message.stctInput.value;
00317     value = (temp / storage.encoderTicksPerRound) * storage.gearRatio * (2.0 * M_PI) * radian;
00318   // Bouml preserved body end 00081DF1
00319 }
00320 
00321 VelocityError::VelocityError() {
00322   // Bouml preserved body begin 00081F71
00323     this->name = "VelocityError";
00324     this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00325   // Bouml preserved body end 00081F71
00326 }
00327 
00328 VelocityError::~VelocityError() {
00329   // Bouml preserved body begin 00081FF1
00330   // Bouml preserved body end 00081FF1
00331 }
00332 
00333 void VelocityError::getParameter(quantity<si::angular_velocity>& parameter) const {
00334   // Bouml preserved body begin 00082071
00335     parameter = this->value;
00336   // Bouml preserved body end 00082071
00337 }
00338 
00339 void VelocityError::toString(std::string& value) {
00340   // Bouml preserved body begin 0009EEF1
00341   std::stringstream ss;
00342   ss << this->name << ": " << this->value;
00343   value  = ss.str();
00344   // Bouml preserved body end 0009EEF1
00345 }
00346 
00347 void VelocityError::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00348   // Bouml preserved body begin 00082171
00349 
00350     message.stctOutput.commandNumber = msgType;
00351     message.stctOutput.moduleAddress = DRIVE;
00352     message.stctOutput.typeNumber = 228; //VelocityError
00353  //   message.stctOutput.value = value;
00354 
00355   // Bouml preserved body end 00082171
00356 }
00357 
00358 void VelocityError::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00359   // Bouml preserved body begin 000821F1
00360     double temp = (int)message.stctInput.value;
00361     this->value = ((temp / 60.0) * storage.gearRatio * 2.0 * M_PI) * radian_per_second;
00362   // Bouml preserved body end 000821F1
00363 }
00364 
00365 VelocityErrorSum::VelocityErrorSum() {
00366   // Bouml preserved body begin 00082371
00367     this->name = "VelocityErrorSum";
00368     this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00369   // Bouml preserved body end 00082371
00370 }
00371 
00372 VelocityErrorSum::~VelocityErrorSum() {
00373   // Bouml preserved body begin 000823F1
00374   // Bouml preserved body end 000823F1
00375 }
00376 
00377 void VelocityErrorSum::getParameter(quantity<si::angular_velocity>& parameter) const {
00378   // Bouml preserved body begin 00082471
00379     parameter = this->value;
00380   // Bouml preserved body end 00082471
00381 }
00382 
00383 void VelocityErrorSum::toString(std::string& value) {
00384   // Bouml preserved body begin 0009EF71
00385   std::stringstream ss;
00386   ss << this->name << ": " << this->value;
00387   value  = ss.str();
00388   // Bouml preserved body end 0009EF71
00389 }
00390 
00391 void VelocityErrorSum::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00392   // Bouml preserved body begin 00082571
00393 
00394     message.stctOutput.commandNumber = msgType;
00395     message.stctOutput.moduleAddress = DRIVE;
00396     message.stctOutput.typeNumber = 229; //VelocityErrorSum
00397  //   message.stctOutput.value = value;
00398 
00399   // Bouml preserved body end 00082571
00400 }
00401 
00402 void VelocityErrorSum::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00403   // Bouml preserved body begin 000825F1
00404     double temp = (int32)message.stctInput.value;
00405     this->value = ((temp / 60.0) * storage.gearRatio * 2.0 * M_PI) * radian_per_second;
00406     
00407   // Bouml preserved body end 000825F1
00408 }
00409 
00410 CurrentError::CurrentError() {
00411   // Bouml preserved body begin 000DAEF1
00412     this->name = "CurrentError";
00413     this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00414   // Bouml preserved body end 000DAEF1
00415 }
00416 
00417 CurrentError::~CurrentError() {
00418   // Bouml preserved body begin 000DAF71
00419   // Bouml preserved body end 000DAF71
00420 }
00421 
00422 void CurrentError::getParameter(quantity<si::current>& parameter) const {
00423   // Bouml preserved body begin 000DAFF1
00424     parameter = this->value;
00425   // Bouml preserved body end 000DAFF1
00426 }
00427 
00428 void CurrentError::toString(std::string& value) {
00429   // Bouml preserved body begin 000DB071
00430   std::stringstream ss;
00431   ss << this->name << ": " << this->value;
00432   value  = ss.str();
00433   // Bouml preserved body end 000DB071
00434 }
00435 
00436 void CurrentError::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00437   // Bouml preserved body begin 000DB0F1
00438     message.stctOutput.commandNumber = msgType;
00439     message.stctOutput.moduleAddress = DRIVE;
00440     message.stctOutput.typeNumber = 200; //CurrentError
00441   //  message.stctOutput.value = value;
00442 
00443   // Bouml preserved body end 000DB0F1
00444 }
00445 
00446 void CurrentError::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00447   // Bouml preserved body begin 000DB171
00448     if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00449       double temp = (int)message.stctInput.value;
00450       this->value = temp /1000.0 * ampere; //convert from milli A to A
00451     }
00452   // Bouml preserved body end 000DB171
00453 }
00454 
00455 CurrentErrorSum::CurrentErrorSum() {
00456   // Bouml preserved body begin 000DB2F1
00457     this->name = "CurrentErrorSum";
00458     this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00459   // Bouml preserved body end 000DB2F1
00460 }
00461 
00462 CurrentErrorSum::~CurrentErrorSum() {
00463   // Bouml preserved body begin 000DB371
00464   // Bouml preserved body end 000DB371
00465 }
00466 
00467 void CurrentErrorSum::getParameter(quantity<si::current>& parameter) const {
00468   // Bouml preserved body begin 000DB3F1
00469     parameter = this->value;
00470   // Bouml preserved body end 000DB3F1
00471 }
00472 
00473 void CurrentErrorSum::toString(std::string& value) {
00474   // Bouml preserved body begin 000DB471
00475   std::stringstream ss;
00476   ss << this->name << ": " << this->value;
00477   value  = ss.str();
00478   // Bouml preserved body end 000DB471
00479 }
00480 
00481 void CurrentErrorSum::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00482   // Bouml preserved body begin 000DB4F1
00483     message.stctOutput.commandNumber = msgType;
00484     message.stctOutput.moduleAddress = DRIVE;
00485     message.stctOutput.typeNumber = 201; //CurrentErrorSum
00486   //  message.stctOutput.value = value;
00487 
00488   // Bouml preserved body end 000DB4F1
00489 }
00490 
00491 void CurrentErrorSum::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00492   // Bouml preserved body begin 000DB571
00493     if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00494       double temp = (int)message.stctInput.value;
00495       this->value = temp /1000.0 * ampere; //convert from milli A to A
00496     }
00497   // Bouml preserved body end 000DB571
00498 }
00499 
00500 RampGeneratorSpeed::RampGeneratorSpeed() {
00501   // Bouml preserved body begin 0009F271
00502     this->name = "RampGeneratorSpeed";
00503     this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00504   // Bouml preserved body end 0009F271
00505 }
00506 
00507 RampGeneratorSpeed::~RampGeneratorSpeed() {
00508   // Bouml preserved body begin 0009F2F1
00509   // Bouml preserved body end 0009F2F1
00510 }
00511 
00512 void RampGeneratorSpeed::getParameter(quantity<si::angular_velocity>& parameter) const {
00513   // Bouml preserved body begin 0009F371
00514     parameter = this->value;
00515   // Bouml preserved body end 0009F371
00516 }
00517 
00518 void RampGeneratorSpeed::toString(std::string& value) {
00519   // Bouml preserved body begin 0009F3F1
00520   std::stringstream ss;
00521   ss << this->name << ": " << this->value;
00522   value  = ss.str();
00523   // Bouml preserved body end 0009F3F1
00524 }
00525 
00526 void RampGeneratorSpeed::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00527   // Bouml preserved body begin 0009F471
00528 
00529     message.stctOutput.commandNumber = msgType;
00530     message.stctOutput.moduleAddress = DRIVE;
00531     message.stctOutput.typeNumber = 13; //RampGeneratorSpeed
00532  //   message.stctOutput.value = value;
00533 
00534   // Bouml preserved body end 0009F471
00535 }
00536 
00537 void RampGeneratorSpeed::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00538   // Bouml preserved body begin 0009F4F1
00539     double temp = (int)message.stctInput.value;
00540     this->value = ((temp / 60.0) * storage.gearRatio * 2.0 * M_PI) * radian_per_second;
00541   // Bouml preserved body end 0009F4F1
00542 }
00543 
00544 I2tSum::I2tSum() {
00545   // Bouml preserved body begin 000A0CF1
00546     this->name = "I2tSum";
00547     this->lowerLimit = 0;
00548     this->upperLimit = INT_MAX;
00549     this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00550   // Bouml preserved body end 000A0CF1
00551 }
00552 
00553 I2tSum::~I2tSum() {
00554   // Bouml preserved body begin 000A0D71
00555   // Bouml preserved body end 000A0D71
00556 }
00557 
00558 void I2tSum::getParameter(unsigned int& parameter) const {
00559   // Bouml preserved body begin 000A0DF1
00560     parameter = this->value;
00561   // Bouml preserved body end 000A0DF1
00562 }
00563 
00564 void I2tSum::setParameter(const unsigned int parameter) {
00565   // Bouml preserved body begin 000A0E71
00566     if (this->lowerLimit > parameter) {
00567       throw std::out_of_range("The parameter exceeds the lower limit");
00568     }
00569     if (this->upperLimit < parameter) {
00570       throw std::out_of_range("The parameter exceeds the upper limit");
00571     }
00572     this->value = parameter;
00573   // Bouml preserved body end 000A0E71
00574 }
00575 
00576 void I2tSum::toString(std::string& value) {
00577   // Bouml preserved body begin 000A0EF1
00578   std::stringstream ss;
00579   ss << this->name << ": " << this->value;
00580   value  = ss.str();
00581   // Bouml preserved body end 000A0EF1
00582 }
00583 
00584 void I2tSum::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00585   // Bouml preserved body begin 000A0F71
00586     message.stctOutput.commandNumber = msgType;
00587     message.stctOutput.moduleAddress = DRIVE;
00588     message.stctOutput.typeNumber = 27; //I2tSum
00589     message.stctOutput.value = value;
00590   // Bouml preserved body end 000A0F71
00591 }
00592 
00593 void I2tSum::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00594   // Bouml preserved body begin 000A0FF1
00595     if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00596       this->value = message.stctInput.value;
00597     }
00598   // Bouml preserved body end 000A0FF1
00599 }
00600 
00601 ActualMotorDriverTemperature::ActualMotorDriverTemperature() {
00602   // Bouml preserved body begin 000CB071
00603     this->name = "ActualMotorDriverTemperature";
00604     this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00605   // Bouml preserved body end 000CB071
00606 }
00607 
00608 ActualMotorDriverTemperature::~ActualMotorDriverTemperature() {
00609   // Bouml preserved body begin 000CB0F1
00610   // Bouml preserved body end 000CB0F1
00611 }
00612 
00613 void ActualMotorDriverTemperature::getParameter(quantity<celsius::temperature>& parameter) const {
00614   // Bouml preserved body begin 000CB171
00615     parameter = this->value;
00616   // Bouml preserved body end 000CB171
00617 }
00618 
00619 void ActualMotorDriverTemperature::toString(std::string& value) {
00620   // Bouml preserved body begin 000CB1F1
00621   std::stringstream ss;
00622   ss << this->name << ": " << this->value;
00623   value  = ss.str();
00624   // Bouml preserved body end 000CB1F1
00625 }
00626 
00627 void ActualMotorDriverTemperature::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00628   // Bouml preserved body begin 000CB271
00629     message.stctOutput.commandNumber = msgType;
00630     message.stctOutput.moduleAddress = DRIVE;
00631     message.stctOutput.typeNumber = 152; //ActualMotorDriverTemperature
00632   //  message.stctOutput.value = value;
00633 
00634   // Bouml preserved body end 000CB271
00635 }
00636 
00637 void ActualMotorDriverTemperature::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00638   // Bouml preserved body begin 000CB2F1
00639     if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00640       double materialConstant = 3434;
00641       double R_NTC = ((double)9011.2/message.stctInput.value) - 2.2;
00642       double nominator = materialConstant * 298.16;
00643       double denominator = materialConstant + (log(R_NTC/10.0) * 298.16);
00644       this->value = ((nominator/denominator) - 273.16) * celsius::degree;
00645     }
00646   // Bouml preserved body end 000CB2F1
00647 }
00648 
00649 ActualModuleSupplyCurrent::ActualModuleSupplyCurrent() {
00650   // Bouml preserved body begin 000CB471
00651     this->name = "ActualModuleSupplyCurrent";
00652     this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00653   // Bouml preserved body end 000CB471
00654 }
00655 
00656 ActualModuleSupplyCurrent::~ActualModuleSupplyCurrent() {
00657   // Bouml preserved body begin 000CB4F1
00658   // Bouml preserved body end 000CB4F1
00659 }
00660 
00661 void ActualModuleSupplyCurrent::getParameter(quantity<si::current>& parameter) const {
00662   // Bouml preserved body begin 000CB571
00663     parameter = this->value;
00664   // Bouml preserved body end 000CB571
00665 }
00666 
00667 void ActualModuleSupplyCurrent::toString(std::string& value) {
00668   // Bouml preserved body begin 000CB5F1
00669   std::stringstream ss;
00670   ss << this->name << ": " << this->value;
00671   value  = ss.str();
00672   // Bouml preserved body end 000CB5F1
00673 }
00674 
00675 void ActualModuleSupplyCurrent::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00676   // Bouml preserved body begin 000CB671
00677     message.stctOutput.commandNumber = msgType;
00678     message.stctOutput.moduleAddress = DRIVE;
00679     message.stctOutput.typeNumber = 157; //ActualModuleSupplyCurrent
00680   //  message.stctOutput.value = value;
00681 
00682   // Bouml preserved body end 000CB671
00683 }
00684 
00685 void ActualModuleSupplyCurrent::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00686   // Bouml preserved body begin 000CB6F1
00687     if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00688       this->value = (double)message.stctInput.value /1000.0 * ampere; //convert from milli A to A
00689     }
00690   // Bouml preserved body end 000CB6F1
00691 }
00692 
00693 
00694 } // namespace youbot
Generated by  doxygen 1.6.3