Changeset 139 in flair-src for trunk/lib/FlairSensorActuator


Ignore:
Timestamp:
02/14/17 17:02:06 (7 years ago)
Author:
Sanahuja Guillaume
Message:

warn message if vrpnobject is added on running client

Location:
trunk/lib/FlairSensorActuator/src
Files:
2 edited

Legend:

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

    r136 r139  
    215215      }
    216216    } else {//!UseXbee()
    217                         if(connection->connected()==vrpn_true && !isConnected) {
    218                                 isConnected=true;
    219                                 Printf("VRPN connected\n");
    220                         }
    221                         if(connection->connected()==vrpn_false && isConnected) {
    222                                 isConnected=false;
    223                                 Printf("VRPN disconnected\n");
    224                         }
    225                        
    226                         //timeout in mainloop is not well handled if not connected...
    227                         if(isConnected) {
    228                                 //this is when trackables callbacks are called:
    229                                 if(connection->mainloop(&timeout)!=0) {
    230                                         self->Warn("connection dropped\n");
    231                                 }
    232                                 //printf("%lld\n",GetTime()/(1000*1000));
    233                                 mutex->GetMutex();
    234                                 for (unsigned int i = 0; i < trackables.size(); i++)
    235                                         trackables.at(i)->mainloop();
    236                                 mutex->ReleaseMutex();
    237                         } else {
    238                                 connection->mainloop();
    239                                 self->SleepMS(10);
    240                         }
     217        if(connection->connected()==vrpn_true && !isConnected) {
     218            isConnected=true;
     219            Printf("VRPN connected\n");
     220        }
     221        if(connection->connected()==vrpn_false && isConnected) {
     222            isConnected=false;
     223            Printf("VRPN disconnected\n");
     224        }
     225        //timeout in mainloop is not well handled if not connected...
     226        if(isConnected) {
     227            //this is when trackables callbacks are called:
     228            if(connection->mainloop(&timeout)!=0) {
     229                self->Warn("connection dropped\n");
     230            }
     231            //printf("%lld\n",GetTime()/(1000*1000));
     232            mutex->GetMutex();
     233            for (unsigned int i = 0; i < trackables.size(); i++)
     234                trackables.at(i)->mainloop();
     235            mutex->ReleaseMutex();
     236        } else {
     237            connection->mainloop();
     238            self->SleepMS(10);
     239        }
    241240    }
    242241  }
  • trunk/lib/FlairSensorActuator/src/VrpnObject_impl.cpp

    r135 r139  
    5656  }
    5757
    58   if (parent->UseXbee()) {
    59     parent->pimpl_->AddTrackable(this, id);
    60     tracker = NULL;
    61   } else {
    62     parent->pimpl_->AddTrackable(self);
    63     tracker = new vrpn_Tracker_Remote(name.c_str(), parent->pimpl_->connection);
    64     tracker->register_change_handler(this, handle_pos);
    65     tracker->shutup = true;
    66   }
    67 
    6858  // state
    6959  cvmatrix_descriptor *desc = new cvmatrix_descriptor(7, 1);
     
    9181  z_plot = new DataPlot1D(plot_tab->LastRowLastCol(), "z", -2, 0);
    9282  z_plot->AddCurve(output->Element(6));
     83 
     84  if(parent->IsRunning()) {
     85    self->Warn("adding VrpnObject on running VrpnClient can crash\n");
     86  }
     87 
     88  if (parent->UseXbee()) {
     89    tracker = NULL;
     90    parent->pimpl_->AddTrackable(this, id);
     91  } else {
     92    tracker = new vrpn_Tracker_Remote(name.c_str(), parent->pimpl_->connection);
     93    tracker->register_change_handler(this, handle_pos);
     94    tracker->shutup = true;
     95    parent->pimpl_->AddTrackable(self);
     96  }
    9397}
    9498
     
    106110}
    107111
    108 void VrpnObject_impl::mainloop(void) { tracker->mainloop(); }
     112void VrpnObject_impl::mainloop(void) {
     113     tracker->mainloop();
     114}
    109115
    110116bool VrpnObject_impl::IsTracked(unsigned int timeout_ms) {
Note: See TracChangeset for help on using the changeset viewer.