Ignore:
Timestamp:
Apr 8, 2016, 3:40:57 PM (6 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairFilter/src/NestedSat_impl.cpp

    r10 r15  
    2828using namespace flair::filter;
    2929
    30 NestedSat_impl::NestedSat_impl(NestedSat* self,const LayoutPosition* position,string name)
    31 {
    32     this->self=self;
    33         k=1;
     30NestedSat_impl::NestedSat_impl(NestedSat *self, const LayoutPosition *position,
     31                               string name) {
     32  this->self = self;
     33  k = 1;
    3434
    35     //init matrix
    36     self->input=new cvmatrix(self,3,1,floatType,name);
     35  // init matrix
     36  self->input = new cvmatrix(self, 3, 1, floatType, name);
    3737
    38     GroupBox* reglages_groupbox=new GroupBox(position,name);
    39             sat=new DoubleSpinBox(reglages_groupbox->NewRow(),"sat ref:",0,9000000,1);
    40             kp=new DoubleSpinBox(reglages_groupbox->NewRow(),"kp:",0,9000000,1);
    41             dsat=new DoubleSpinBox(reglages_groupbox->NewRow(),"sat dref:",0,9000000,1);
    42             kd=new DoubleSpinBox(reglages_groupbox->NewRow(),"kd:",0,9000000,0.1);
    43             usat=new DoubleSpinBox(reglages_groupbox->NewRow(),"sat u:",0,1,.1);
     38  GroupBox *reglages_groupbox = new GroupBox(position, name);
     39  sat =
     40      new DoubleSpinBox(reglages_groupbox->NewRow(), "sat ref:", 0, 9000000, 1);
     41  kp = new DoubleSpinBox(reglages_groupbox->NewRow(), "kp:", 0, 9000000, 1);
     42  dsat = new DoubleSpinBox(reglages_groupbox->NewRow(), "sat dref:", 0, 9000000,
     43                           1);
     44  kd = new DoubleSpinBox(reglages_groupbox->NewRow(), "kd:", 0, 9000000, 0.1);
     45  usat = new DoubleSpinBox(reglages_groupbox->NewRow(), "sat u:", 0, 1, .1);
    4446}
    4547
    46 NestedSat_impl::~NestedSat_impl(void)
    47 {
     48NestedSat_impl::~NestedSat_impl(void) {}
     49
     50void NestedSat_impl::UpdateFrom(const io_data *data) {
     51  float cons, dcons, law;
     52  cvmatrix *input = (cvmatrix *)data;
     53
     54  input->GetMutex();
     55
     56  cons = Sat(input->ValueNoMutex(0, 0), k * sat->Value());
     57  dcons = (cons - input->ValueNoMutex(1, 0)) * kp->Value();
     58  dcons = Sat(dcons, k * dsat->Value());
     59  law = (input->ValueNoMutex(2, 0) - dcons) * kd->Value();
     60  law = Sat(law, usat->Value());
     61
     62  input->ReleaseMutex();
     63
     64  self->output->SetValue(0, 0, law);
     65  self->output->SetDataTime(data->DataTime());
    4866}
    4967
    50 void NestedSat_impl::UpdateFrom(const io_data *data)
    51 {
    52     float cons,dcons,law;
    53     cvmatrix *input=(cvmatrix*)data;
    54 
    55     input->GetMutex();
    56 
    57     cons=Sat(input->ValueNoMutex(0,0),k*sat->Value());
    58     dcons=(cons-input->ValueNoMutex(1,0))*kp->Value();
    59     dcons=Sat(dcons,k*dsat->Value());
    60     law=(input->ValueNoMutex(2,0)-dcons)*kd->Value();
    61     law=Sat(law,usat->Value());
    62 
    63     input->ReleaseMutex();
    64 
    65     self->output->SetValue(0,0,law);
    66     self->output->SetDataTime(data->DataTime());
     68float NestedSat_impl::Sat(float value, float borne) {
     69  if (value < -borne)
     70    return -borne;
     71  if (value > borne)
     72    return borne;
     73  return value;
    6774}
    68 
    69 float NestedSat_impl::Sat(float value,float borne)
    70 {
    71     if(value<-borne) return -borne;
    72     if(value>borne) return borne;
    73     return value;
    74 }
Note: See TracChangeset for help on using the changeset viewer.