user_interface.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010, Bosch LLC
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of Bosch LLC nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 //\Author Joerg Wagner, Philip Roan, Bosch LLC
00031 
00032 //wxwidgets stuff
00033 #include <wx/stattext.h>
00034 #include <wx/statline.h>
00035 #include <wx/checkbox.h>
00036 
00037 //common stuff
00038 #include "proximity_sensor_dashboard/user_interface.h"
00039 #include "proximity_sensor_dashboard/skin.h"
00040 
00041 #include <math.h>
00042 #include <iostream>
00043 
00044 //TODO:
00045 //      - change the software to handle 192 instead of 191 sensors
00046 //      - Implementation of error handling routines
00047 
00048 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size): wxFrame( NULL, -1, title, pos, size )
00049 {
00050   //Timer to execute ros::spinOnce();
00051   timer_ = new wxTimer(this, skin_id::ID_TIMER);
00052   timer_->Start(250);
00053   Connect(skin_id::ID_TIMER, wxEVT_TIMER, wxTimerEventHandler(MyFrame::gridUpdate), NULL, this);
00054   
00055   //Menubar
00056   menubar = new wxMenuBar;
00057   file = new wxMenu;
00058   file->Append(skin_id::ID_About, wxT("&About..."));
00059   file->AppendSeparator();
00060   file->Append(wxID_EXIT, wxT("&Quit"));
00061   menubar->Append(file, wxT("&File"));
00062   SetMenuBar(menubar);
00063   
00064   Connect(skin_id::ID_About, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyFrame::OnAbout));
00065   Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyFrame::OnQuit));
00066 
00067   wxBoxSizer* v_sizer = new wxBoxSizer( wxVERTICAL ); 
00068   views = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP); 
00069   expert_panel = new wxPanel(views, wxID_ANY); // expert and debug information
00070   basic_panel = new wxPanel(views, wxID_ANY); // basic measurements
00071   
00072   //headline of Frame
00073   wxStaticText *headline = new wxStaticText(expert_panel, wxID_ANY, title,wxPoint(15,15));
00074   
00075   wxFont headline_font = headline->GetFont(); //Set Font of headline
00076   headline_font.SetWeight(wxBOLD);
00077   headline_font.SetPointSize(15);
00078   headline->SetFont(headline_font);
00079   
00080   //Line
00081   //wxStaticLine *sl1 = new wxStaticLine(expert_panel, wxID_ANY, wxPoint(15,40), wxSize(730,1));
00082   
00083   //Creates grid and sets size of cells
00084   const wxString col_title_[18] = { wxT("Adr"),
00085                                     wxT("Stat"),
00086                                     wxT("X"),
00087                                     wxT("Ini"),
00088                                     wxT("Limit"),
00089                                     wxT("U1"),
00090                                     wxT("U2"),
00091                                     wxT("U3"),
00092                                     wxT("Dyn"),
00093                                     wxT(""),
00094                                     wxT("SE-NR."),
00095                                     wxT(""),
00096                                     wxT("A"),
00097                                     wxT("B"),
00098                                     wxT("C"),
00099                                     wxT("D"),
00100                                     wxT("E") };
00101   grid = new wxGrid(expert_panel, wxID_ANY, wxPoint(30,85), wxSize(699, 770));
00102   grid->CreateGrid(skind_def::max_sensor_number, 16);
00103   
00104   grid->SetColLabelSize(30);
00105   grid->SetRowLabelSize(50);
00106   
00107   wxColour label_background_colour;
00108   label_background_colour = grid->GetLabelBackgroundColour();
00109   
00110   for(int i = 0; i < skind_def::max_sensor_number ; i++)//Sets Row Size + Sets backgroundcolour of column 8, 9 and  10 + set aligns position of text
00111   {
00112     grid->SetRowSize(i, 20);
00113     grid->SetCellBackgroundColour(i, 8, label_background_colour);
00114     grid->SetCellBackgroundColour(i, 10, label_background_colour);
00115     grid->SetCellBackgroundColour(i, 9, *wxWHITE);
00116     for(int j = 0; j < 16; j++)
00117     {
00118       grid->SetCellAlignment(i, j, wxALIGN_CENTRE, wxALIGN_CENTRE);
00119     }
00120   }
00121   
00122   for(int j = 0; j < 8 ; j++)//Sets Column Size (column 0-7)
00123   {
00124     grid->SetColSize(j, 50);
00125   }
00126   
00127   grid->SetColSize(8, 25);//Sets Column Size (column 8-10)
00128   grid->SetColSize(9, 80);
00129   grid->SetColSize(10, 25);
00130   
00131   for(int i = 11 ; i < 16 ; i++)//Sets Column Size (column 11-15)
00132   {
00133     grid->SetColSize(i, 20);
00134   }
00135   
00136   //sets Value of column-labels
00137   for(int k = 0; k < 16; k++)
00138   {
00139     grid->SetColLabelValue((k),col_title_[k+1]);
00140   }
00141   
00142   //Inserts sensor number in the  9th column, change text colour, set background colour
00143   for(int i = 0; i < skin_dat_.u8sensor_number_ ; i++)
00144   {
00145     grid->SetCellValue(i,9,wxString::Format(wxT("%i"),i+1));
00146     grid->SetCellTextColour(i,9,wxColour(255,255,0));
00147   }
00148   
00149   //Disables user manipulations
00150   grid->EnableEditing(false);
00151   grid->EnableDragRowSize(false);
00152   grid->EnableDragColSize(false);
00153   
00154   //Sets the number of pixels per scroll increment
00155   grid->SetScrollLineY(20);
00156   
00157   //Inserts the text of the first cell
00158   wxPoint first_cell_point;
00159   first_cell_point = grid->GetPosition();
00160   wxSize first_cell_size;
00161   first_cell_size.Set(grid->GetRowLabelSize(), grid->GetColLabelSize());
00162   wxColour background_colour = grid->GetLabelBackgroundColour();
00163   
00164   wxPanel *cover_first_cell = new wxPanel(expert_panel, wxID_ANY, first_cell_point, first_cell_size, wxSUNKEN_BORDER);
00165   cover_first_cell->SetBackgroundColour(background_colour);
00166   
00167   wxStaticText *first_cell_text = new wxStaticText(cover_first_cell, wxID_ANY, col_title_[0],wxPoint(10, 5), wxDefaultSize);
00168   
00169   wxFont grid_label_font = grid->GetLabelFont();
00170   first_cell_text->SetFont(grid_label_font);
00171   
00172   //Insert Cover for Col 8
00173   wxPanel *cover_col8 = new wxPanel(expert_panel, wxID_ANY, wxPoint(479, first_cell_point.y+28), wxSize(grid->GetColSize(8)+1,grid->GetRowSize(0)*38 + 10 - 28), wxSUNKEN_BORDER);
00174   cover_col8->SetBackgroundColour(background_colour);
00175   
00176   //Insert Cover for Col 10
00177   wxPanel *cover_col10 = new wxPanel(expert_panel, wxID_ANY, wxPoint(479 + grid->GetColSize(8) + grid->GetColSize(9), first_cell_point.y+28), wxSize(grid->GetColSize(8)+1,grid->GetRowSize(0)*38 + 10 - 28), wxSUNKEN_BORDER);
00178   cover_col10->SetBackgroundColour(background_colour);
00179   
00180   //Textlabel "X Col Bar"
00181   wxPanel *textlabel_x_col_bar = new wxPanel(expert_panel, wxID_ANY, wxPoint(479 + grid->GetColSize(8),first_cell_point.y - grid->GetColLabelSize()), wxSize(grid->GetColSize(9) + 1, grid->GetColLabelSize()), wxSUNKEN_BORDER);
00182   textlabel_x_col_bar->SetBackgroundColour(background_colour);
00183   
00184   wxStaticText *text_x_col_bar = new wxStaticText(textlabel_x_col_bar, wxID_ANY, wxT("X Col.Bar"),wxPoint(3, 5), wxDefaultSize);
00185   
00186   text_x_col_bar->SetFont(grid_label_font);
00187   
00188   //TextLabel "ErrorBar"
00189   wxPanel *textlabel_errorbar = new wxPanel(expert_panel, wxID_ANY, wxPoint(479 + grid->GetColSize(8) + grid->GetColSize(9)+ grid->GetColSize(10),first_cell_point.y - grid->GetColLabelSize()), wxSize(grid->GetColSize(11)*5 + 1, grid->GetColLabelSize()), wxSUNKEN_BORDER);
00190   textlabel_errorbar->SetBackgroundColour(background_colour);
00191   
00192   wxStaticText *text_errorbar = new wxStaticText(textlabel_errorbar, wxID_ANY, wxT("ErrorBar"),wxPoint(16, 5), wxDefaultSize);
00193   
00194   text_errorbar->SetFont(grid_label_font);
00195   
00196   //Checkbox for switch between Hex and Dec
00197   wxCheckBox *cb_hex_dec = new wxCheckBox(expert_panel, skin_id::ID_HEX, wxT("Hex"), wxPoint(100,55), wxDefaultSize);
00198   Connect(skin_id::ID_HEX, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(MyFrame::OnCheck));
00199   cb_hex_dec->SetValue(false);
00200   bhex_ = cb_hex_dec->GetValue();
00201   
00202   //Statusbar (Go/NoGo, NoErr/Err)
00203   wxStaticText *text_status = new wxStaticText(expert_panel, wxID_ANY, wxT("Status:"),wxPoint(200, 57), wxDefaultSize);
00204   text_status->SetFont(grid_label_font);
00205   
00206   text_go_nogo = new wxStaticText(expert_panel, wxID_ANY, wxT(""),wxPoint(270, 57), wxDefaultSize, wxALIGN_CENTRE);
00207   text_err_noerr = new wxStaticText(expert_panel, wxID_ANY, wxT(""),wxPoint(320, 57), wxDefaultSize, wxALIGN_CENTRE);
00208   
00209   
00210   //Creating the address row
00211   
00212   for(int k = 0; k < skind_def::max_sensor_number; k++)
00213   {
00214     if(bhex_)
00215     {
00216       grid->SetRowLabelValue(k,hexadezimal(skin_dat_.u8readadr_lo_+256*skin_dat_.u8readadr_hi_+skind_def::anz_byte_per_sensor*k));
00217     }
00218     else
00219     {
00220       grid->SetRowLabelValue(k, wxString::Format(wxT("%i"),(skin_dat_.u8readadr_lo_+256*skin_dat_.u8readadr_hi_+skind_def::anz_byte_per_sensor*k)));
00221     }
00222   }
00223   
00224 
00225 
00226 
00227   // create basic panel
00228   wxBoxSizer* layout_v1 = new wxBoxSizer( wxVERTICAL );
00229   wxBoxSizer* layout_h1 = new wxBoxSizer( wxHORIZONTAL );  
00230   wxStaticText* basic_text = new wxStaticText(basic_panel, wxID_ANY, wxT("Welcome to the Basic Dashboard"));
00231   basic_text->SetFont(headline_font);
00232   
00233   basic_data = new wxGrid(basic_panel, wxID_ANY);
00234   basic_data->CreateGrid(skind_def::max_sensor_number, 3);
00235 
00236   //grid->SetColLabelSize(30);
00237   //grid->SetRowLabelSize(50)
00238   for( int i = 0; i < skind_def::max_sensor_number; i++ )
00239   {
00240     basic_data->SetRowSize(i, 20);
00241     for(int j = 0; j < 3; j++)
00242     {
00243       basic_data->SetCellAlignment(i, j, wxALIGN_CENTRE, wxALIGN_CENTRE);
00244     }
00245   }
00246   basic_data->SetColSize(0, 80);
00247   basic_data->SetColSize(1, 80);
00248   basic_data->SetColSize(2, 80);
00249   basic_data->SetColLabelValue( 0, wxT("Sensor") );
00250   basic_data->SetColLabelValue( 1, wxT("Value") );
00251   basic_data->SetColLabelValue( 2, wxT("Visual") );
00252 
00253 
00254   //Sets the number of pixels per scroll increment
00255   basic_data->SetScrollLineY(20);
00256 
00257   //Disables user manipulations
00258   basic_data->EnableEditing(false);
00259   basic_data->EnableDragRowSize(false);
00260   basic_data->EnableDragColSize(false);
00261   
00262   layout_v1->Add(basic_text, 0, wxEXPAND);
00263   layout_v1->Add(basic_data, 1, wxEXPAND);
00264 
00265   layout_h1->Add(layout_v1, 1, wxEXPAND);
00266 
00267   layout_v1->SetSizeHints(basic_panel);
00268   layout_h1->SetSizeHints(basic_panel);
00269   basic_panel->SetSizer(layout_h1);
00270   
00271   
00272   // create tabbed pane
00273   views->AddPage(basic_panel, wxT("Basic"));  // add basic
00274   views->AddPage(expert_panel, wxT("Expert")); // add expert
00275   
00276   v_sizer->Add(views, 1, wxEXPAND);
00277   SetSizer(v_sizer);
00278 
00279 
00280   //display initialze data
00281   publish_data_2_gui();
00282     
00283 }
00284 
00285 
00286 void MyFrame::gridUpdate(wxTimerEvent& evt)//trigger a new message callback
00287 {
00288   ros::spinOnce();
00289   ROS_DEBUG("Update results grid.");
00290   publish_data_2_gui();//publish data to GUI
00291   
00292   if (!ros::ok())
00293   {
00294     Close();
00295   }
00296 }
00297 
00298 
00299 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
00300 {
00301   Close(true);
00302 }
00303 
00304 
00305 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
00306 {
00307   wxMessageBox( wxT(".....      text  text  text     ....."), wxT("Proximity Sensor Dashboard from Bosch RTC"), wxICON_INFORMATION, this );
00308 }
00309 
00310 
00311 void MyFrame::OnCheck(wxCommandEvent& event)//switch between Hex and Dec
00312 {
00313   if(bhex_)
00314   {
00315     bhex_ = false;
00316   }
00317   else
00318   {
00319     bhex_ = true;
00320   }
00321 }
00322 
00323 
00324 wxString MyFrame::hexadezimal(uint32_t conv_value)//convert a dec. value into a hex-string
00325 {
00326   const wxString ziffern[16] = { wxT("0"),
00327                                  wxT("1"),
00328                                  wxT("2"),
00329                                  wxT("3"),
00330                                  wxT("4"),
00331                                  wxT("5"),
00332                                  wxT("6"),
00333                                  wxT("7"),
00334                                  wxT("8"),
00335                                  wxT("9"),
00336                                  wxT("A"),
00337                                  wxT("B"),
00338                                  wxT("C"),
00339                                  wxT("D"),
00340                                  wxT("E"),
00341                                  wxT("F") };
00342   int i = 0;
00343   wxString ts;
00344   
00345   ts = wxT("");
00346   for(i = 3 ; i >= 0 ; i--)
00347   {
00348     ts = ts + ziffern[((conv_value >> (4*i)) & (15))]; // 15 = 000FH = 1111B
00349   }
00350   return ts;
00351 }
00352 
00353 
00354 void MyFrame::publish_data_2_gui()
00355 {
00356   ROS_DEBUG("Publishing data to GUI.");
00357   
00358   //clear gui if sensor number was changed
00359   if(skin_dat_.bsens_num_changed == true)
00360   {
00361     grid->ClearGrid();
00362     basic_data->ClearGrid();
00363     skin_dat_.bsens_num_changed = false;
00364     
00365     //Inserts sensor number in the  9th column, change text colour, set background colour
00366     for(int i = 0; i < skind_def::max_sensor_number ; i++)
00367     {
00368       grid->SetCellValue(i,9,wxString::Format(wxT("%i"),i+1));
00369       grid->SetCellTextColour(i,9,wxColour(255,255,0));
00370 
00371       basic_data->SetCellValue( i, 0, wxString::Format(wxT("%i"), i+1) );
00372     }
00373 
00374     //clear background colour
00375     for(int k = skin_dat_.u8sensor_number_; k < skind_def::max_sensor_number; k++)
00376     {
00377       grid->SetCellBackgroundColour(k, 9, *wxWHITE);//x Col.Bar
00378       grid->SetCellBackgroundColour(k, 11, *wxWHITE);//ErrorBar
00379       grid->SetCellBackgroundColour(k, 12, *wxWHITE);//ErrorBar
00380       grid->SetCellBackgroundColour(k, 13, *wxWHITE);//ErrorBar
00381       grid->SetCellBackgroundColour(k, 14, *wxWHITE);//ErrorBar
00382       grid->SetCellBackgroundColour(k, 15, *wxWHITE);//ErrorBar
00383     }
00384   }
00385   
00386 
00387 
00388   //check if publisher node is online (online: time stamp of the last subscription < (ceil(float(skin_dat_.u8sensor_number_) / 32.0) -1 ) * 0.1 + 0.3 ago)
00389   //1 Sens - 32 Sens            - limit : 0.25
00390   //33 Sens - 64 Sens   - limit : 0.35
00391   //65 Sens - 96 Sens   - limit : 0.45
00392   //97 Sens - 128 Sens  - limit : 0.55
00393   //129 Sens - 160 Sens         - limit : 0.65
00394   //161 Sens - 192 Sens         - limit : 0.75
00395   //determination of the limit: (ceil(float(skin_dat_.u8sensor_number_) / 32.0) -1 ) * 0.1 + 0.3
00396   
00397   ros::Time dcurrent_time = ros::Time::now();
00398   if( ( dcurrent_time > (skin_dat_.dtime_subscription_ + ros::Duration((ceil(float(skin_dat_.u8sensor_number_) / 32.0) -1 ) * 0.1 + 0.3))) )
00399   {
00400     skin_dat_.initialize_sensor_data();//reset data to initial values
00401     
00402     text_go_nogo->SetLabel(wxT(""));//status diplay is empty if publisher node is offline
00403     text_err_noerr->SetLabel(wxT(""));
00404   }
00405   else
00406   {
00407     //status diplay
00408     if(skin_dat_.bstatus_go_ == true)
00409     {
00410       text_go_nogo->SetLabel(wxT("Go"));
00411       text_go_nogo->SetForegroundColour(*wxGREEN);
00412     }
00413     else
00414     {
00415       text_go_nogo->SetLabel(wxT("NoGo"));
00416       text_go_nogo->SetForegroundColour(*wxRED);
00417     }
00418     
00419     if(skin_dat_.bstatus_err_ == false)
00420     {
00421       text_err_noerr->SetLabel(wxT("NoErr"));
00422       text_err_noerr->SetForegroundColour(*wxGREEN);
00423     }
00424     else
00425     {
00426       text_err_noerr->SetLabel(wxT("Err"));
00427       text_err_noerr->SetForegroundColour(*wxRED);
00428     }
00429   }
00430   
00431   //create new address-row depending on bhex_
00432   for(int l = 0; l < skind_def::max_sensor_number; l++)
00433   {
00434     if(bhex_)
00435     {
00436       grid->SetRowLabelValue(l,hexadezimal(skin_dat_.u8readadr_lo_+256*skin_dat_.u8readadr_hi_+skind_def::anz_byte_per_sensor*l));
00437     }
00438     else
00439     {
00440       grid->SetRowLabelValue(l, wxString::Format(wxT("%i"),(skin_dat_.u8readadr_lo_+256*skin_dat_.u8readadr_hi_+skind_def::anz_byte_per_sensor*l)));
00441     }
00442   }
00443   
00444   for(int k = 0; k < skin_dat_.u8sensor_number_; k++)
00445   {
00446     //publish skin_data to main grid (Col0 to Col7)
00447     for(int j = 0; j < 8; j++)
00448     {
00449       //write data to grid
00450       if(bhex_)
00451       {
00452         grid->SetCellValue(k,j,hexadezimal(skin_dat_.u8asensor_data_[k][j]));//convert data to hex-string
00453       }
00454       else
00455       {
00456         grid->SetCellValue(k,j,wxString::Format(wxT("%i"),skin_dat_.u8asensor_data_[k][j]));
00457       }
00458 
00459     }
00460     basic_data->SetCellValue( k, 1, wxString::Format(wxT("%i"), skin_dat_.u8asensor_data_[k][1] - skin_dat_.u8asensor_data_[k][2]) );
00461     
00462     
00464     //         Creating the ErrorBar
00466     
00467     //self diagnosis display for each sensor element (errorbar)
00468     //  green: no error
00469     //  red:   error found
00470     //  white: no sensor element
00471     //  error conditions:
00472     //    A: U2 > 32            (= berrcond_[0])
00473     //    B: U3 < 16            (= berrcond_[1])
00474     //    C: U3-U1 < 16         (= berrcond_[2])
00475     //    D: Err_IO = 1         (= berrcond_[3])
00476     //    E: ErrTMS = 1         (= berrcond_[4])
00477     //    U1 = sensor_data[k][4]
00478     //    U2 = sensor_data[k][5]
00479     //    U3 = sensor_data[k][6]
00480     //    Stat  = sensor_data[k][0]
00481     //    Limit = sensor_data[k][3]
00482     
00483     
00484     berrcond_[0] = ( (skin_dat_.u8asensor_data_[k][5]) > 32 );
00485     berrcond_[1] = ( (skin_dat_.u8asensor_data_[k][6]) < 16 );
00486     berrcond_[2] = ( ((skin_dat_.u8asensor_data_[k][6]) - (skin_dat_.u8asensor_data_[k][4])) < 16 );
00487     berrcond_[3] = ( ((skin_dat_.u8asensor_data_[k][0]) & 16) > 0 );    //masking of Stat: if ((sensor_data[k][0]) & 16)>0 -> Err_IO = 1
00488     berrcond_[4] = ( ((skin_dat_.u8asensor_data_[k][0]) & 32) > 0 );    //masking of Stat: if ((sensor_data[k][0]) & 32)>0 -> ErrTMS = 1
00489     
00490     wxColour errcol;
00491     
00492     for(int i = 0; i < 5; i++)
00493     {
00494       errcol = *wxWHITE;
00495       if((skin_dat_.u8sensor_number_ > 0) & (skin_dat_.u8sensor_number_ <= skind_def::max_sensor_number))//number of sensors:  0 < Sennr <= 192
00496       {
00497         if( ((skin_dat_.u8asensor_data_[k][0]) & 1) == 1)//(Sensorelement is evaluated)
00498         {
00499           if(berrcond_[i])
00500           {
00501             errcol = *wxRED;
00502           }
00503           else
00504           {
00505             errcol = *wxGREEN;
00506           }
00507         }
00508         grid->SetCellBackgroundColour(k, i + 11, errcol);
00509       }
00510     }
00511     
00512     //sensor element readings (X COL.BAR)
00513     //    Limit = sensor_data[k][3]
00514     //    X     = sensor_data[k][1]
00515     //    Ini   = sensor_data[k][2]
00516     
00518     //    Creating the X. Col.Bar
00520     
00521     float tr;
00522     wxColour statcol;
00523     
00524     if( skin_dat_.u8asensor_data_[k][3] != 0 )
00525     {
00526       tr = float ( (skin_dat_.u8asensor_data_[k][1]) - (skin_dat_.u8asensor_data_[k][2]) ) / float (skin_dat_.u8asensor_data_[k][3]); // tr = (X - Ini) / Limit
00527     }
00528     else
00529     {
00530       tr = 2;
00531     }
00532     
00533     
00534     if(tr > 0)
00535     {
00536       if(tr > 1)
00537       {
00538         tr = 1;
00539       }
00540       statcol.Set(int (tr * 255)*65536);
00541       grid->SetCellBackgroundColour(k, 9, statcol);
00542       basic_data->SetCellBackgroundColour(k, 2, statcol);
00543     }
00544     else
00545     {
00546       tr = -tr;
00547       if(tr > 1)
00548       {
00549         tr = 1;
00550       }
00551       statcol.Set(int (tr * 255));
00552       grid->SetCellBackgroundColour(k, 9, statcol);
00553       basic_data->SetCellBackgroundColour(k, 2, statcol);
00554     }
00555   }
00556   
00557   grid->ForceRefresh();
00558   basic_data->ForceRefresh();
00559 }
00560 
00561 
00562 
00563 
00564 
00565 
00566 
00567 


proximity_sensor_dashboard
Author(s): Joerg Wagner, Adrian Funk (Maintained by Philip Roan)
autogenerated on Fri Jan 3 2014 11:09:05