Changeset 15 in flair-src for trunk/lib/FlairSensorActuator/src/Bldc.cpp


Ignore:
Timestamp:
04/08/16 15:40:57 (7 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/Bldc.cpp

    r3 r15  
    2727using namespace flair::gui;
    2828
    29 namespace flair { namespace actuator {
     29namespace flair {
     30namespace actuator {
    3031
    31 Bldc::Bldc(const IODevice* parent,Layout* layout,string name,uint8_t motors_count) : IODevice(parent,name) {
    32     pimpl_=new Bldc_impl(this,layout,name,motors_count);
     32Bldc::Bldc(const IODevice *parent, Layout *layout, string name,
     33           uint8_t motors_count)
     34    : IODevice(parent, name) {
     35  pimpl_ = new Bldc_impl(this, layout, name, motors_count);
    3336
    34     cvmatrix_descriptor* desc=new cvmatrix_descriptor(motors_count,2);
    35     for(int i=0;i<motors_count;i++) {
    36         ostringstream speed,current;
    37         speed << "speed_" << i;
    38         desc->SetElementName(i,0,speed.str());
     37  cvmatrix_descriptor *desc = new cvmatrix_descriptor(motors_count, 2);
     38  for (int i = 0; i < motors_count; i++) {
     39    ostringstream speed, current;
     40    speed << "speed_" << i;
     41    desc->SetElementName(i, 0, speed.str());
    3942
    40         current << "current_" << i;
    41         desc->SetElementName(i,1,current.str());
    42     }
     43    current << "current_" << i;
     44    desc->SetElementName(i, 1, current.str());
     45  }
    4346
    44     output=new cvmatrix(this,desc,floatType);
    45     AddDataToLog(output);
     47  output = new cvmatrix(this, desc, floatType);
     48  AddDataToLog(output);
    4649}
    4750
    48 Bldc::Bldc(const Object* parent,string name,uint8_t motors_count) : IODevice(parent,name) {
    49     pimpl_=new Bldc_impl(this,motors_count);
     51Bldc::Bldc(const Object *parent, string name, uint8_t motors_count)
     52    : IODevice(parent, name) {
     53  pimpl_ = new Bldc_impl(this, motors_count);
    5054}
    5155
    52 Bldc::~Bldc() {
    53     delete pimpl_;
     56Bldc::~Bldc() { delete pimpl_; }
     57
     58void Bldc::UpdateFrom(const io_data *data) { pimpl_->UpdateFrom(data); }
     59
     60void Bldc::LockUserInterface(void) const { pimpl_->LockUserInterface(); }
     61
     62void Bldc::UnlockUserInterface(void) const { pimpl_->UnlockUserInterface(); }
     63
     64Layout *Bldc::GetLayout(void) const { return (Layout *)pimpl_->layout; }
     65
     66void Bldc::UseDefaultPlot(TabWidget *tabwidget) {
     67  pimpl_->UseDefaultPlot(tabwidget);
    5468}
    5569
    56 void Bldc::UpdateFrom(const io_data *data) {
    57     pimpl_->UpdateFrom(data);
     70uint8_t Bldc::MotorsCount(void) const { return pimpl_->motors_count; }
     71
     72cvmatrix *Bldc::Output(void) const { return output; }
     73
     74bool Bldc::AreEnabled(void) const { return pimpl_->are_enabled; }
     75
     76void Bldc::SetEnabled(bool status) {
     77  if (pimpl_->are_enabled != status) {
     78    pimpl_->are_enabled = status;
     79    if (pimpl_->are_enabled) {
     80      LockUserInterface();
     81    } else {
     82      UnlockUserInterface();
     83    }
     84  }
    5885}
    5986
    60 void Bldc::LockUserInterface(void) const {
    61     pimpl_->LockUserInterface();
    62 }
    63 
    64 void Bldc::UnlockUserInterface(void) const {
    65     pimpl_->UnlockUserInterface();
    66 }
    67 
    68 Layout* Bldc::GetLayout(void) const {
    69     return (Layout*)pimpl_->layout;
    70 }
    71 
    72 void Bldc::UseDefaultPlot(TabWidget* tabwidget) {
    73     pimpl_->UseDefaultPlot(tabwidget);
    74 }
    75 
    76 uint8_t Bldc::MotorsCount(void) const {
    77     return pimpl_->motors_count;
    78 }
    79 
    80 cvmatrix *Bldc::Output(void) const {
    81     return output;
    82 }
    83 
    84 bool Bldc::AreEnabled(void) const {
    85     return pimpl_->are_enabled;
    86 }
    87 
    88 void Bldc::SetEnabled(bool status) {
    89     if(pimpl_->are_enabled!=status) {
    90         pimpl_->are_enabled=status;
    91         if(pimpl_->are_enabled) {
    92             LockUserInterface();
    93         } else {
    94             UnlockUserInterface();
    95         }
    96     }
    97 }
    98 
    99 void Bldc::SetPower(int motor_id,float value) {
    100     //use output mutex to avoid making a new mutex
    101     output->GetMutex();
    102     pimpl_->power[motor_id]=value;
    103     output->ReleaseMutex();
     87void Bldc::SetPower(int motor_id, float value) {
     88  // use output mutex to avoid making a new mutex
     89  output->GetMutex();
     90  pimpl_->power[motor_id] = value;
     91  output->ReleaseMutex();
    10492}
    10593
Note: See TracChangeset for help on using the changeset viewer.