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/FlairSensorActuator/src/SimuCamera.cpp

    r3 r15  
    2929using namespace flair::gui;
    3030
    31 namespace flair { namespace sensor {
     31namespace flair {
     32namespace sensor {
    3233
    33 SimuCamera::SimuCamera(const FrameworkManager* parent,string name,uint16_t width,uint16_t height,uint8_t channels,uint32_t dev_id,uint8_t priority) :Thread(parent,name,priority),Camera(parent,name,width,height,cvimage::Type::Format::BGR) {
    34     data_rate=new SpinBox(GetGroupBox()->NewRow(),"data rate"," Hz",1,100,1,50);
     34SimuCamera::SimuCamera(const FrameworkManager *parent, string name,
     35                       uint16_t width, uint16_t height, uint8_t channels,
     36                       uint32_t dev_id, uint8_t priority)
     37    : Thread(parent, name, priority),
     38      Camera(parent, name, width, height, cvimage::Type::Format::BGR) {
     39  data_rate =
     40      new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 100, 1, 50);
    3541
    36     buf_size=width*height*channels;
     42  buf_size = width * height * channels;
    3743
    38     img=cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,3);
    39     output->img->imageData=img->imageData;
     44  img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
     45  output->img->imageData = img->imageData;
    4046
    41     ostringstream dev_name;
    42     dev_name << "simu_cam_" << dev_id;
    43     shmem=new SharedMem((Thread*)this,dev_name.str().c_str(),buf_size);
     47  ostringstream dev_name;
     48  dev_name << "simu_cam_" << dev_id;
     49  shmem = new SharedMem((Thread *)this, dev_name.str().c_str(), buf_size);
    4450}
    4551
    46 SimuCamera::SimuCamera(const IODevice* parent,string name,uint16_t width,uint16_t height,uint8_t channels,uint32_t dev_id) : Thread(parent,name,0),Camera(parent,name) {
    47     data_rate=NULL;
     52SimuCamera::SimuCamera(const IODevice *parent, string name, uint16_t width,
     53                       uint16_t height, uint8_t channels, uint32_t dev_id)
     54    : Thread(parent, name, 0), Camera(parent, name) {
     55  data_rate = NULL;
    4856
    49     ostringstream dev_name;
    50     dev_name << "simu_cam_" << dev_id;
    51     shmem=new SharedMem((Thread*)this,dev_name.str().c_str(),width*height*channels);
     57  ostringstream dev_name;
     58  dev_name << "simu_cam_" << dev_id;
     59  shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     60                        width * height * channels);
    5261}
    5362
    5463SimuCamera::~SimuCamera() {
    55     SafeStop();
    56     Join();
     64  SafeStop();
     65  Join();
    5766}
    5867
    5968void SimuCamera::Run(void) {
    60     if(data_rate==NULL) {
    61         Thread::Err("not applicable for simulation part.\n");
    62         return;
     69  if (data_rate == NULL) {
     70    Thread::Err("not applicable for simulation part.\n");
     71    return;
     72  }
     73
     74  SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
     75
     76  while (!ToBeStopped()) {
     77    WaitPeriod();
     78
     79    if (data_rate->ValueChanged() == true) {
     80      SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
    6381    }
    6482
    65     SetPeriodUS((uint32_t)(1000000./data_rate->Value()));
     83    output->GetMutex();
     84    shmem->Read((char *)img->imageData, buf_size); // remplacer copie par
     85                                                   // échange de pointeur sur
     86                                                   // double buffering
     87    output->ReleaseMutex();
    6688
    67     while(!ToBeStopped()) {
    68         WaitPeriod();
     89    output->SetDataTime(GetTime());
    6990
    70         if(data_rate->ValueChanged()==true) {
    71             SetPeriodUS((uint32_t)(1000000./data_rate->Value()));
    72         }
    73 
    74         output->GetMutex();
    75         shmem->Read((char*)img->imageData,buf_size); // remplacer copie par échange de pointeur sur double buffering
    76         output->ReleaseMutex();
    77 
    78         output->SetDataTime(GetTime());
    79 
    80         ProcessUpdate(output);
    81     }
     91    ProcessUpdate(output);
     92  }
    8293}
    8394
Note: See TracChangeset for help on using the changeset viewer.