examples/DS401_Slave_Gui/main.cpp
changeset 246 d635cfc520ee
child 295 25ff2fadff89
equal deleted inserted replaced
245:d43ebbed895f 246:d635cfc520ee
       
     1 #include <wx/wxprec.h>
       
     2 #include <wx/wx.h>
       
     3 #include <wx/textctrl.h>
       
     4 #include <wx/spinctrl.h>
       
     5 #include <wx/tglbtn.h>
       
     6 #include <wx/slider.h>
       
     7 #include <iostream>
       
     8 #include <wx/brush.h>
       
     9 #include <sstream>
       
    10 #include <wx/listbox.h>
       
    11 #include <wx/dynarray.h>
       
    12 #include <wx/dcclient.h>
       
    13 #include <wx/gauge.h>
       
    14 #include <wx/spinctrl.h>
       
    15 
       
    16 #include "monicone.xpm"
       
    17 
       
    18 #include "main.h"
       
    19 #include "tools.h"
       
    20 #include "TestSlaveGui.h"
       
    21 extern "C" {
       
    22 	#include "canfestival.h"
       
    23 	#include "ObjDict.h"
       
    24 }
       
    25 #include "wx/wxprec.h"
       
    26 
       
    27 #ifdef __BORLANDC__
       
    28     #pragma hdrstop
       
    29 #endif
       
    30 
       
    31 #ifndef WX_PRECOMP
       
    32     #include "wx/wx.h"
       
    33 #endif
       
    34 
       
    35 
       
    36 wxTextCtrl		*textLog;
       
    37 int				node_id_ext;
       
    38 MyFrame 		*frame; 
       
    39 s_BOARD			SlaveBoard = {NULL, NULL};
       
    40 char* 			LibraryPath = NULL;
       
    41 double			Gtime = 0;
       
    42 double			y[28][45];
       
    43 double			hdelta = 0;
       
    44 double			old_max = 5;
       
    45 double			old_min = -5;
       
    46 
       
    47 // Declare some IDs. These are arbitrary.
       
    48 const int BOOKCTRL = 100;
       
    49 const int FILE_QUIT = wxID_EXIT;
       
    50 const int HELP_ABOUT = wxID_ABOUT;
       
    51 const int ADD = 105;
       
    52 const int REMOVE = 108;
       
    53 const int QUIT = 109;
       
    54 const int FREQBOX = 110;
       
    55 const int START = 112;
       
    56 const int TEXTBOX1 = 113;
       
    57 const int STOP = 114;
       
    58 const int LOAD = 115;
       
    59 const int INBT1 = 118;
       
    60 const int INBT2 = 119;
       
    61 const int INBT3 = 120;
       
    62 const int INBT4 = 121;
       
    63 const int INBT5 = 122;
       
    64 const int INBT6 = 123;
       
    65 const int INBT7 = 124;
       
    66 const int INBT8 = 125;
       
    67 const int INS1 = 126;
       
    68 const int INS2 = 127;
       
    69 const int INS3 = 128;
       
    70 const int INS4 = 129;
       
    71 const int INS5 = 135;
       
    72 const int INS6 = 136;
       
    73 const int INS7 = 137;
       
    74 const int INS8 = 138;
       
    75 const int TIMER_ID = 130;
       
    76 const int INST1 = 131;
       
    77 const int INST2 = 132;
       
    78 const int INST3 = 133;
       
    79 const int INST4 = 134;
       
    80 const int INST5 = 135;
       
    81 const int INST6 = 136;
       
    82 const int INST7 = 137;
       
    83 const int INST8 = 138;
       
    84 
       
    85 // Attach the event handlers. Put this after MyFrame declaration.
       
    86 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
       
    87  EVT_BUTTON(STOP, MyFrame::OnStop)
       
    88  EVT_BUTTON(LOAD, MyFrame::OnLoad)
       
    89  EVT_BUTTON(START, MyFrame::OnStart)
       
    90  EVT_TOGGLEBUTTON(INBT1, MyFrame::OnInbt1)
       
    91  EVT_TOGGLEBUTTON(INBT2, MyFrame::OnInbt2)
       
    92  EVT_TOGGLEBUTTON(INBT3, MyFrame::OnInbt3)
       
    93  EVT_TOGGLEBUTTON(INBT4, MyFrame::OnInbt4)
       
    94  EVT_TOGGLEBUTTON(INBT5, MyFrame::OnInbt5)
       
    95  EVT_TOGGLEBUTTON(INBT6, MyFrame::OnInbt6)
       
    96  EVT_TOGGLEBUTTON(INBT7, MyFrame::OnInbt7)
       
    97  EVT_TOGGLEBUTTON(INBT8, MyFrame::OnInbt8)
       
    98  EVT_COMMAND_SCROLL(INS1, MyFrame::OnIns1)
       
    99  EVT_COMMAND_SCROLL(INS2, MyFrame::OnIns2)
       
   100  EVT_COMMAND_SCROLL(INS3, MyFrame::OnIns3)
       
   101  EVT_COMMAND_SCROLL(INS4, MyFrame::OnIns4)
       
   102  EVT_COMMAND_SCROLL(INS5, MyFrame::OnIns5)
       
   103  EVT_COMMAND_SCROLL(INS6, MyFrame::OnIns6)
       
   104  EVT_COMMAND_SCROLL(INS7, MyFrame::OnIns7)
       
   105  EVT_COMMAND_SCROLL(INS8, MyFrame::OnIns8)
       
   106  EVT_SPINCTRL(INST1, MyFrame::OnInst1)
       
   107  EVT_SPINCTRL(INST2, MyFrame::OnInst2)
       
   108  EVT_SPINCTRL(INST3, MyFrame::OnInst3)
       
   109  EVT_SPINCTRL(INST4, MyFrame::OnInst4)
       
   110  EVT_SPINCTRL(INST5, MyFrame::OnInst5)
       
   111  EVT_SPINCTRL(INST6, MyFrame::OnInst6)
       
   112  EVT_SPINCTRL(INST7, MyFrame::OnInst7)
       
   113  EVT_SPINCTRL(INST8, MyFrame::OnInst8)
       
   114  
       
   115  EVT_LISTBOX(FREQBOX, MyFrame::OnFreqBoxClick)
       
   116  EVT_MENU(FILE_QUIT, MyFrame::OnQuit)
       
   117  EVT_BUTTON(QUIT, MyFrame::OnQuit)
       
   118  EVT_MENU(HELP_ABOUT, MyFrame::OnAbout)
       
   119  EVT_PAINT(MyFrame::OnPaint)
       
   120  
       
   121  EVT_TIMER(TIMER_ID, MyFrame::OnTimer)
       
   122 END_EVENT_TABLE()
       
   123 
       
   124 IMPLEMENT_APP(MyApp)
       
   125 
       
   126 bool MyApp::OnInit()
       
   127 {
       
   128  	frame = new MyFrame( _T("I-O simulator"));
       
   129  	frame->Show(true);
       
   130  return true;
       
   131 }
       
   132 
       
   133 MyFrame::MyFrame(const wxString& title)
       
   134   : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 740), wxDEFAULT_FRAME_STYLE, wxT("frame"))
       
   135   ,m_timer(this, TIMER_ID)
       
   136 {
       
   137  wxMenu			*fileMenu = new wxMenu;
       
   138  wxMenu			*helpMenu = new wxMenu;
       
   139  wxPanel		*panel;
       
   140  wxButton		*quit;
       
   141  wxButton		*load;
       
   142  wxBoxSizer		*mysizer;
       
   143  wxBoxSizer		*mysssizer;
       
   144  wxBoxSizer		*myhsizer;
       
   145  wxBoxSizer		*mybsizer;
       
   146  wxBoxSizer		*myentrysizer;
       
   147  wxListBox		*freqlist;
       
   148  wxStaticBox	*namebox;
       
   149  wxStaticBox	*freqbox;
       
   150 
       
   151  SetIcon(wxICON(monicone));
       
   152  SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
       
   153  helpMenu->Append(HELP_ABOUT, _T("&About...\tF1"),
       
   154  _T("Show about dialog"));
       
   155  fileMenu->Append(FILE_QUIT, _T("E&xit\tAlt-X"),
       
   156  _T("Quit this program"));
       
   157  wxMenuBar *menuBar = new wxMenuBar();
       
   158  menuBar->Append(fileMenu, _T("&File"));
       
   159  menuBar->Append(helpMenu, _T("&Help"));
       
   160  SetMenuBar(menuBar);
       
   161  CreateStatusBar(2);
       
   162  SetStatusText(_T("Lolitech."), 0);
       
   163  SetStatusText(_T("Welcome."), 1);
       
   164 
       
   165  book = new wxNotebook(this, BOOKCTRL);
       
   166   
       
   167  panel = new wxPanel(book);
       
   168  book->AddPage(panel, _T("Configuration"), true);
       
   169  mysizer = new wxBoxSizer( wxVERTICAL );
       
   170  panel->SetSizer(mysizer);
       
   171  wxString choices[] =
       
   172  {
       
   173   _T("10K"), _T("20K"), _T("50K"), _T("100K"), 
       
   174   _T("125K"), _T("250K"), _T("500K"), _T("1M")
       
   175  };
       
   176  
       
   177  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Bus driver")), wxHORIZONTAL );
       
   178  mysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 5);
       
   179  load = new wxButton( panel, LOAD, _T("Load can driver"));
       
   180  myhsizer->Add(load, 0, wxLEFT, 5);
       
   181  drivername = new wxTextCtrl(panel, wxID_ANY, _T("No driver loaded!!"));
       
   182  myhsizer->Add(drivername, 1, wxEXPAND | wxALL, 5);
       
   183  myentrysizer = new wxBoxSizer( wxHORIZONTAL );
       
   184  mysizer->Add(myentrysizer, 0, wxEXPAND | wxALL, 5);
       
   185  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Bus name")), wxHORIZONTAL );
       
   186  myentrysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 5);
       
   187  busname = new wxTextCtrl(panel, wxID_ANY, _T("0"));
       
   188  myhsizer->Add(busname, 0, wxLEFT, 5);
       
   189  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Node ID (Hexa)")), wxHORIZONTAL );
       
   190  myentrysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 5);
       
   191  node_id = new wxSpinCtrl(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 127, 1, _T("wxSpinCtrl"));
       
   192  myhsizer->Add(node_id, 0, wxRIGHT, 5);
       
   193  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Baudrate")), wxHORIZONTAL );
       
   194  mysizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 5);
       
   195  freqlist = new wxListBox( panel, FREQBOX, wxDefaultPosition, wxDefaultSize, 8, choices, wxLB_SINGLE | wxLB_HSCROLL);
       
   196  myhsizer->Add(freqlist, wxEXPAND | wxALL, wxEXPAND | wxALL, 5);
       
   197  quit = new wxButton( panel, QUIT, _T("QUIT"));
       
   198  mysizer->Add(quit, 0, wxALL, 5);
       
   199  
       
   200  
       
   201  panel = new wxPanel(book);
       
   202  book->AddPage(panel, wxT("Inputs"), true);
       
   203  mysizer = new wxBoxSizer( wxVERTICAL );
       
   204  panel->SetSizer(mysizer);
       
   205  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Read Inputs UNSIGNED8")), wxHORIZONTAL );
       
   206  mysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 30);
       
   207  inbt1 = new wxToggleButton(panel, INBT1, wxT("1"));
       
   208  inbt2 = new wxToggleButton(panel, INBT2, wxT("2"));
       
   209  inbt3 = new wxToggleButton(panel, INBT3, wxT("3"));
       
   210  inbt4 = new wxToggleButton(panel, INBT4, wxT("4"));
       
   211  inbt5 = new wxToggleButton(panel, INBT5, wxT("5"));
       
   212  inbt6 = new wxToggleButton(panel, INBT6, wxT("6"));
       
   213  inbt7 = new wxToggleButton(panel, INBT7, wxT("7"));
       
   214  inbt8 = new wxToggleButton(panel, INBT8, wxT("8"));
       
   215  myhsizer->Add(inbt1, wxEXPAND | wxALL, 0, 5);
       
   216  myhsizer->Add(inbt2, wxEXPAND | wxALL, 0, 5);
       
   217  myhsizer->Add(inbt3, wxEXPAND | wxALL, 0, 5);
       
   218  myhsizer->Add(inbt4, wxEXPAND | wxALL, 0, 5);
       
   219  myhsizer->Add(inbt5, wxEXPAND | wxALL, 0, 5);
       
   220  myhsizer->Add(inbt6, wxEXPAND | wxALL, 0, 5);
       
   221  myhsizer->Add(inbt7, wxEXPAND | wxALL, 0, 5);
       
   222  myhsizer->Add(inbt8, wxEXPAND | wxALL, 0, 5);
       
   223  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Analogue Inputs INTEGER16")), wxVERTICAL );
       
   224  mysizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 30);
       
   225  mysssizer = new wxBoxSizer( wxHORIZONTAL );
       
   226  myhsizer->Add(mysssizer, 0, wxEXPAND | wxALL, 0); 
       
   227  inst1 = new wxSpinCtrl(panel, INST1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0"));
       
   228  inst2 = new wxSpinCtrl(panel, INST2, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0"));
       
   229  inst3 = new wxSpinCtrl(panel, INST3, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0"));
       
   230  inst4 = new wxSpinCtrl(panel, INST4, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0"));
       
   231  inst5 = new wxSpinCtrl(panel, INST5, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0"));
       
   232  inst6 = new wxSpinCtrl(panel, INST6, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0"));
       
   233  inst7 = new wxSpinCtrl(panel, INST7, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0"));
       
   234  inst8 = new wxSpinCtrl(panel, INST8, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0"));
       
   235  mysssizer->Add(inst1, wxALL, 0, 5);
       
   236  mysssizer->Add(inst2, wxALL, 0, 5);
       
   237  mysssizer->Add(inst3, wxALL, 0, 5);
       
   238  mysssizer->Add(inst4, wxALL, 0, 5);
       
   239  mysssizer->Add(inst5, wxALL, 0, 5);
       
   240  mysssizer->Add(inst6, wxALL, 0, 5);
       
   241  mysssizer->Add(inst7, wxALL, 0, 5);
       
   242  mysssizer->Add(inst8, wxALL, 0, 5);
       
   243  mysssizer = new wxBoxSizer( wxHORIZONTAL );
       
   244  myhsizer->Add(mysssizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 0);
       
   245  ins1 = new wxSlider(panel, INS1, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider"));
       
   246  ins2 = new wxSlider(panel, INS2, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider"));
       
   247  ins3 = new wxSlider(panel, INS3, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider"));
       
   248  ins4 = new wxSlider(panel, INS4, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider"));
       
   249  ins5 = new wxSlider(panel, INS5, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider"));
       
   250  ins6 = new wxSlider(panel, INS6, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider"));
       
   251  ins7 = new wxSlider(panel, INS7, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider"));
       
   252  ins8 = new wxSlider(panel, INS8, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider"));
       
   253  mysssizer->Add(ins1, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
       
   254  mysssizer->Add(ins2, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
       
   255  mysssizer->Add(ins3, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
       
   256  mysssizer->Add(ins4, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
       
   257  mysssizer->Add(ins5, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
       
   258  mysssizer->Add(ins6, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
       
   259  mysssizer->Add(ins7, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
       
   260  mysssizer->Add(ins8, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
       
   261  quit = new wxButton( panel, QUIT, _T("QUIT"));
       
   262  mysizer->Add(quit, 0, wxALL, 5);
       
   263  
       
   264  panel = new wxPanel(book);
       
   265  book->AddPage(panel, wxT("Outputs"), true);
       
   266  mysizer = new wxBoxSizer( wxVERTICAL );
       
   267  panel->SetSizer(mysizer);
       
   268  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Write Outputs UNSIGNED8")), wxHORIZONTAL );
       
   269  mysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 30);
       
   270  outbt1 = new wxToggleButton(panel, wxID_ANY, wxT("1"));
       
   271  outbt2 = new wxToggleButton(panel, wxID_ANY, wxT("2"));
       
   272  outbt3 = new wxToggleButton(panel, wxID_ANY, wxT("3"));
       
   273  outbt4 = new wxToggleButton(panel, wxID_ANY, wxT("4"));
       
   274  outbt5 = new wxToggleButton(panel, wxID_ANY, wxT("5"));
       
   275  outbt6 = new wxToggleButton(panel, wxID_ANY, wxT("6"));
       
   276  outbt7 = new wxToggleButton(panel, wxID_ANY, wxT("7"));
       
   277  outbt8 = new wxToggleButton(panel, wxID_ANY, wxT("8"));
       
   278  myhsizer->Add(outbt1, wxEXPAND | wxALL, 0, 5);
       
   279  myhsizer->Add(outbt2, wxEXPAND | wxALL, 0, 5);
       
   280  myhsizer->Add(outbt3, wxEXPAND | wxALL, 0, 5);
       
   281  myhsizer->Add(outbt4, wxEXPAND | wxALL, 0, 5);
       
   282  myhsizer->Add(outbt5, wxEXPAND | wxALL, 0, 5);
       
   283  myhsizer->Add(outbt6, wxEXPAND | wxALL, 0, 5);
       
   284  myhsizer->Add(outbt7, wxEXPAND | wxALL, 0, 5);
       
   285  myhsizer->Add(outbt8, wxEXPAND | wxALL, 0, 5);
       
   286  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Analogue Output INTEGER16")), wxVERTICAL );
       
   287  mysizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 30);
       
   288  mysssizer = new wxBoxSizer( wxHORIZONTAL );
       
   289  myhsizer->Add(mysssizer, 0, wxEXPAND | wxALL, 0);
       
   290  outst1 = new wxStaticText(panel, wxID_ANY, wxT("label"), wxDefaultPosition, wxDefaultSize, 0, wxT("staticText"));
       
   291  outst2 = new wxStaticText(panel, wxID_ANY, wxT("label"), wxDefaultPosition, wxDefaultSize, 0, wxT("staticText"));
       
   292  outst3 = new wxStaticText(panel, wxID_ANY, wxT("label"), wxDefaultPosition, wxDefaultSize, 0, wxT("staticText"));
       
   293  outst4 = new wxStaticText(panel, wxID_ANY, wxT("label"), wxDefaultPosition, wxDefaultSize, 0, wxT("staticText"));
       
   294  mysssizer->Add(outst1, wxEXPAND | wxALL, wxEXPAND | wxALL, 5);
       
   295  mysssizer->Add(outst2, wxEXPAND | wxALL, wxEXPAND | wxALL, 5);
       
   296  mysssizer->Add(outst3, wxEXPAND | wxALL, wxEXPAND | wxALL, 5);
       
   297  mysssizer->Add(outst4, wxEXPAND | wxALL, wxEXPAND | wxALL, 5);
       
   298  mysssizer = new wxBoxSizer( wxHORIZONTAL );
       
   299  myhsizer->Add(mysssizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 0);
       
   300  outs1 = new wxGauge(panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("gauge"));
       
   301  outs2 = new wxGauge(panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("gauge"));
       
   302  outs3 = new wxGauge(panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("gauge"));
       
   303  outs4 = new wxGauge(panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("gauge"));
       
   304  mysssizer->Add(outs1, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
       
   305  mysssizer->Add(outs2, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
       
   306  mysssizer->Add(outs3, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
       
   307  mysssizer->Add(outs4, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
       
   308  quit = new wxButton( panel, QUIT, _T("QUIT"));
       
   309  mysizer->Add(quit, 0, wxALL, 5); 
       
   310  
       
   311   wxString choice[] =
       
   312  {
       
   313   _T("Analogue Out 1"), _T("Analogue Out 2"),
       
   314   _T("Analogue Out 3"), _T("Analogue Out 4"),
       
   315   _T("Bool Out 1"), _T("Bool Out 2"), 
       
   316   _T("Bool Out 3"), _T("Bool Out 4"), 
       
   317   _T("Bool Out 5"), _T("Bool Out 6"), 
       
   318   _T("Bool Out 7"), _T("Bool Out 8"), 
       
   319   _T("Analogue Input 1"), _T("Analogue Input 2"),
       
   320   _T("Analogue Input 3"), _T("Analogue Input 4"),
       
   321   _T("Analogue Input 5"), _T("Analogue Input 6"),
       
   322   _T("Analogue Input 7"), _T("Analogue Input 8"),
       
   323   _T("Bool Input 1"), _T("Bool Input 2"), 
       
   324   _T("Bool Input 3"), _T("Bool Input 4"), 
       
   325   _T("Bool Input 5"), _T("Bool Input 6"), 
       
   326   _T("Bool Input 7"), _T("Bool Input 8"), };
       
   327  panel = new wxPanel(book); 
       
   328  book->AddPage(panel, wxT("Graphic"), true); 
       
   329  mysizer = new wxBoxSizer( wxVERTICAL ); 
       
   330  panel->SetSizer(mysizer); 
       
   331  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Graphic")), wxVERTICAL ); 
       
   332  mysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 10); 
       
   333  mygraphpan = new wxPanel(panel, wxID_ANY, wxDefaultPosition, wxSize(0, 350), wxTAB_TRAVERSAL, wxT("Graphic")); 
       
   334  myhsizer->Add(mygraphpan, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); 
       
   335  echelle = new wxSlider(panel, wxID_ANY, 44, 44, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL , wxDefaultValidator, wxT("slider")); 
       
   336  myhsizer->Add(echelle, 0, wxEXPAND | wxALL, 0); 
       
   337  mybsizer = new wxBoxSizer( wxHORIZONTAL ); 
       
   338  mysizer->Add(mybsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); 
       
   339  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Select viewable Inputs")), wxHORIZONTAL ); 
       
   340  mybsizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 10); 
       
   341  inlist = new wxListBox( panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 28, choice, wxLB_EXTENDED | wxLB_HSCROLL); 
       
   342  myhsizer->Add(inlist, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); 
       
   343  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Legende")), wxHORIZONTAL ); 
       
   344  mybsizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 10); 
       
   345  mylegpan = new wxPanel(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxT("Legende")); 
       
   346  myhsizer->Add(mylegpan, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); 
       
   347  quit = new wxButton( panel, QUIT, _T("QUIT")); 
       
   348  mysizer->Add(quit, 0, wxALL, 5);
       
   349  
       
   350  panel = new wxPanel(book);
       
   351  book->InsertPage(0, panel, wxT("Control"), true);
       
   352  mysizer = new wxBoxSizer( wxVERTICAL );
       
   353  panel->SetSizer(mysizer);
       
   354  myhsizer = new wxBoxSizer( wxHORIZONTAL );
       
   355  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Control your node")), wxHORIZONTAL );
       
   356  mysizer->Add(myhsizer, 0, wxALL, 5);
       
   357  start = new wxButton( panel, START, _T("START")); 
       
   358  stop = new wxButton( panel, STOP, _T("STOP")); 
       
   359  stop->Enable(false);
       
   360  myhsizer->Add(start, 0, wxRIGHT, 5);
       
   361  myhsizer->Add(stop, 0, wxLEFT, 5);
       
   362  myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Operation log")), wxHORIZONTAL );
       
   363  mysizer->Add(myhsizer, wxALL, wxEXPAND | wxALL, 5);
       
   364  textLog = new wxTextCtrl( panel, TEXTBOX1, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, wxTextCtrlNameStr);
       
   365  myhsizer->Add(textLog, wxALL, wxEXPAND | wxALL, 5);
       
   366  quit = new wxButton( panel, QUIT, _T("QUIT"));
       
   367  mysizer->Add(quit, 0, wxALL, 5);
       
   368  
       
   369  for (int i= 0; i < 28; i++)
       
   370 	for (int j = 0; j < 44; j++)					
       
   371 		y[i][j] = 0;
       
   372  m_timer.Start(100);
       
   373 }
       
   374 
       
   375 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
       
   376 {
       
   377  Close(true);
       
   378 }
       
   379 
       
   380 void MyFrame::OnStart(wxCommandEvent& WXUNUSED(event))
       
   381 {	
       
   382  wxString	s;
       
   383 	
       
   384  if (LibraryPath == NULL)
       
   385  	{
       
   386  		*textLog << wxT("No driver found!! ----------------------------------Initialization [KO]\n");
       
   387  		return;
       
   388  	}
       
   389  if (SlaveBoard.baudrate == NULL)
       
   390  	{
       
   391  		*textLog << wxT("No baudrate found!! ----------------------------------Initialization [KO]\n");
       
   392  		return;
       
   393  	}	
       
   394  	
       
   395  node_id_ext = node_id->GetValue();
       
   396  s = busname->GetValue();
       
   397  SlaveBoard.busname = wxstr_to_charbuf(s);
       
   398  *textLog << wxT("-- Bus name: ------> ") << s << wxT("\n");
       
   399  *textLog << wxT("-- Node ID: -------> ") << node_id->GetValue() << wxT("\n");
       
   400  
       
   401  if (main_can(SlaveBoard, LibraryPath))
       
   402   {
       
   403  	printf("[KO]\n");
       
   404  	*textLog << wxT("----------------------------------------------------Initialization [KO]\n");
       
   405   }
       
   406  else
       
   407   {
       
   408  	printf("[OK]\n");
       
   409  	*textLog << wxT("----------------------------------------------------Initialization [OK]\n");
       
   410  	stop->Enable(true);
       
   411  	start->Enable(false);
       
   412   }
       
   413 }
       
   414 
       
   415 void MyFrame::OnStop(wxCommandEvent& WXUNUSED(event))
       
   416 {
       
   417 	
       
   418  	*textLog << wxT("----------------------------------------------------Slave [STOPPED]") << wxT("\n");
       
   419 	stop_slave();
       
   420 	stop->Enable(false);
       
   421 	start->Enable(true);
       
   422 	charbuf_free(SlaveBoard.busname);
       
   423 }
       
   424 
       
   425 void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event))
       
   426 {
       
   427     wxFileDialog fd(this, wxT("Choose a node configuration file"), wxT(""), wxT("Slave.od"), wxT("*.so"));
       
   428 
       
   429     if(fd.ShowModal() == wxID_OK)
       
   430     {
       
   431     	drivername->Clear();
       
   432         drivername->AppendText(fd.GetPath()); 
       
   433         *textLog << wxT("LibraryPath: ") << fd.GetPath() << wxT("\n");
       
   434         if (LibraryPath != NULL)
       
   435         	charbuf_free(LibraryPath);
       
   436         LibraryPath = wxstr_to_charbuf(fd.GetPath());
       
   437         printf("path=%s",LibraryPath);
       
   438     }
       
   439 }
       
   440 
       
   441 void MyFrame::OnInbt1(wxCommandEvent& WXUNUSED(event))
       
   442 {	
       
   443  Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x1;
       
   444 }
       
   445 void MyFrame::OnInbt2(wxCommandEvent& WXUNUSED(event))
       
   446 {	
       
   447  Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x2;
       
   448 }
       
   449 void MyFrame::OnInbt3(wxCommandEvent& WXUNUSED(event))
       
   450 {	
       
   451  Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x4;
       
   452 }
       
   453 void MyFrame::OnInbt4(wxCommandEvent& WXUNUSED(event))
       
   454 {	
       
   455  Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x8;
       
   456 }
       
   457 void MyFrame::OnInbt5(wxCommandEvent& WXUNUSED(event))
       
   458 {	
       
   459  Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x10;
       
   460 }
       
   461 void MyFrame::OnInbt6(wxCommandEvent& WXUNUSED(event))
       
   462 {	
       
   463  Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x20;
       
   464 }
       
   465 void MyFrame::OnInbt7(wxCommandEvent& WXUNUSED(event))
       
   466 {	
       
   467  Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x40;
       
   468 }
       
   469 void MyFrame::OnInbt8(wxCommandEvent& WXUNUSED(event))
       
   470 {	
       
   471  Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x80;
       
   472 }
       
   473 
       
   474 
       
   475 
       
   476 void MyFrame::OnIns1(wxScrollEvent &event)
       
   477 {
       
   478 	Read_Analogue_Input_16_Bit[0] = ins1->GetValue();
       
   479 	inst1->SetValue(ins1->GetValue());
       
   480 }
       
   481 void MyFrame::OnIns2(wxScrollEvent &event)
       
   482 {
       
   483 	Read_Analogue_Input_16_Bit[1] = ins2->GetValue();
       
   484 	inst2->SetValue(ins2->GetValue());
       
   485 }
       
   486 void MyFrame::OnIns3(wxScrollEvent &event)
       
   487 {
       
   488 	Read_Analogue_Input_16_Bit[2] = ins3->GetValue();
       
   489 	inst3->SetValue(ins3->GetValue());
       
   490 }
       
   491 void MyFrame::OnIns4(wxScrollEvent &event)
       
   492 {
       
   493 	Read_Analogue_Input_16_Bit[3] = ins4->GetValue();
       
   494 	inst4->SetValue(ins4->GetValue());
       
   495 }
       
   496 void MyFrame::OnIns5(wxScrollEvent &event)
       
   497 {
       
   498 	Read_Analogue_Input_16_Bit[4] = ins5->GetValue();
       
   499 	inst5->SetValue(ins5->GetValue());
       
   500 }
       
   501 void MyFrame::OnIns6(wxScrollEvent &event)
       
   502 {
       
   503 	Read_Analogue_Input_16_Bit[5] = ins6->GetValue();
       
   504 	inst6->SetValue(ins6->GetValue());
       
   505 }
       
   506 void MyFrame::OnIns7(wxScrollEvent &event)
       
   507 {
       
   508 	Read_Analogue_Input_16_Bit[6] = ins7->GetValue();
       
   509 	inst7->SetValue(ins7->GetValue());
       
   510 }
       
   511 void MyFrame::OnIns8(wxScrollEvent &event)
       
   512 {
       
   513 	Read_Analogue_Input_16_Bit[7] = ins8->GetValue();
       
   514 	inst8->SetValue(ins8->GetValue());
       
   515 }
       
   516 
       
   517 
       
   518 void MyFrame::OnInst1 ( wxSpinEvent &ev )
       
   519 {
       
   520 	Read_Analogue_Input_16_Bit[0] = inst1->GetValue();
       
   521 	ins1->SetValue(inst1->GetValue());	
       
   522 }
       
   523 void MyFrame::OnInst2 ( wxSpinEvent &ev )
       
   524 {
       
   525 	Read_Analogue_Input_16_Bit[1] = inst2->GetValue();
       
   526 	ins2->SetValue(inst2->GetValue());	
       
   527 }
       
   528 void MyFrame::OnInst3 ( wxSpinEvent &ev )
       
   529 {
       
   530 	Read_Analogue_Input_16_Bit[2] = inst3->GetValue();
       
   531 	ins3->SetValue(inst3->GetValue());	
       
   532 }
       
   533 void MyFrame::OnInst4 ( wxSpinEvent &ev )
       
   534 {
       
   535 	Read_Analogue_Input_16_Bit[3] = inst4->GetValue();
       
   536 	ins4->SetValue(inst4->GetValue());	
       
   537 }
       
   538 void MyFrame::OnInst5 ( wxSpinEvent &ev )
       
   539 {
       
   540 	Read_Analogue_Input_16_Bit[4] = inst5->GetValue();
       
   541 	ins5->SetValue(inst5->GetValue());	
       
   542 }
       
   543 void MyFrame::OnInst6 ( wxSpinEvent &ev )
       
   544 {
       
   545 	Read_Analogue_Input_16_Bit[5] = inst6->GetValue();
       
   546 	ins6->SetValue(inst6->GetValue());	
       
   547 }
       
   548 void MyFrame::OnInst7 ( wxSpinEvent &ev )
       
   549 {
       
   550 	Read_Analogue_Input_16_Bit[6] = inst7->GetValue();
       
   551 	ins7->SetValue(inst7->GetValue());	
       
   552 }
       
   553 void MyFrame::OnInst8 ( wxSpinEvent &ev )
       
   554 {
       
   555 	Read_Analogue_Input_16_Bit[7] = inst8->GetValue();
       
   556 	ins8->SetValue(inst8->GetValue());	
       
   557 }
       
   558 
       
   559 
       
   560 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
       
   561 {
       
   562  wxString msg;
       
   563  msg.Printf( _T("About.\n\n")
       
   564     _T("Input-Output simulation by GRANDEMANGE Nicolas for CanFestival!!"));
       
   565 
       
   566  wxMessageBox(msg, _T("About !!!"), wxOK | wxICON_INFORMATION, this);
       
   567 }
       
   568 
       
   569 
       
   570 void MyFrame::OnFreqBoxClick( wxCommandEvent &event )
       
   571 {
       
   572 	wxString	wxstr;
       
   573 	
       
   574  	wxstr = event.GetString();
       
   575  	if (SlaveBoard.baudrate != NULL)
       
   576  		charbuf_free(SlaveBoard.baudrate);
       
   577  	SlaveBoard.baudrate = wxstr_to_charbuf(wxstr);
       
   578  	*textLog << wxT("Baudrate:") << event.GetString() << wxT("\n");
       
   579 }
       
   580 
       
   581 static int	is_set(int			i,
       
   582 					wxListBox	*inlist,
       
   583 					wxArrayInt	in)
       
   584 {
       
   585 	inlist->GetSelections(in);
       
   586 	for (int j = 0; j < in.GetCount(); j++)
       
   587 		{
       
   588 			if (i == (in[j] + 1))
       
   589 			{
       
   590 				return (i);
       
   591 			}
       
   592 		}
       
   593 	return (0);
       
   594 }
       
   595 
       
   596 static int	get_bit(UNS8	input, int bit)
       
   597 {
       
   598 	if (bit == 1)
       
   599 		return ((input & 0x1) ? 1 : 0);
       
   600 	if (bit == 2)
       
   601 		return ((input & 0x2) ? 1 : 0);
       
   602 	if (bit == 3)
       
   603 		return ((input & 0x4) ? 1 : 0);
       
   604 	if (bit == 4)
       
   605 		return ((input & 0x8) ? 1 : 0);
       
   606 	if (bit == 5)
       
   607 		return ((input & 0x10) ? 1 : 0);
       
   608 	if (bit == 6)
       
   609 		return ((input & 0x20) ? 1 : 0);
       
   610 	if (bit == 7)
       
   611 		return ((input & 0x40) ? 1 : 0);
       
   612 	if (bit == 8)
       
   613 		return ((input & 0x80) ? 1 : 0);
       
   614 	return 0;
       
   615 }
       
   616 
       
   617 void MyFrame::Paint()
       
   618 {
       
   619 	double		vmax = old_max;
       
   620 	double		vmin = old_min;
       
   621 	double		vdelta = vmax - vmin;
       
   622 	double		vech = ((float)vdelta) / 10.0;
       
   623 	
       
   624 	double		hmax = frame->echelle->GetValue();
       
   625 	double		hech = hdelta / 11;
       
   626 	
       
   627 	double 		d = 300 / vdelta;
       
   628 	double		g = 0;
       
   629 	double		top = 5;
       
   630 	double		left = 50;
       
   631 
       
   632 	double		tmpi = 0;
       
   633 	wxString	tmps;
       
   634 	double		p = 0;
       
   635 	double		q = 0;
       
   636 	int			i = 0;
       
   637 	int			j = 0;
       
   638 	wxColor		col[8] = {wxColor("BLUE"), wxColor("RED"), wxColor("GREEN"), wxColor("GREY"),
       
   639 						wxColor("ORANGE"), wxColor("YELLOW"), wxColor("PINK"), wxColor("BLACK")};
       
   640 	hdelta = hmax - 0;
       
   641 	g = (Gtime / hdelta) * 44.00;
       
   642 						
       
   643 	wxClientDC MonDc(mygraphpan);	
       
   644 	MonDc.Clear();
       
   645 	
       
   646     MonDc.SetPen(wxPen(wxColour(200,200,200), 5, wxSOLID));
       
   647     MonDc.DrawRectangle((int) left, (int)top, 660, 300);
       
   648 
       
   649     MonDc.SetPen(wxPen(wxColor(150,200,150), 2, wxSOLID));
       
   650     MonDc.SetFont(wxFont(9, wxSWISS , wxNORMAL, wxNORMAL, false, wxT("Arial Black")));
       
   651     for (i=0; i < 11; i++)    
       
   652     	{
       
   653 			tmpi = (vmin + (vech * i));
       
   654 			tmps.Printf(wxT("%d"), (int)tmpi);
       
   655     		MonDc.DrawRotatedText(tmps, 0, (int)(293 - (30 * i) + top), 0);
       
   656     	}
       
   657         for (i=0; i < 12; i++)    
       
   658     	{
       
   659     		tmpi = (hech * i * 100);
       
   660     		if (tmpi < 1000)
       
   661 				tmps.Printf(wxT("%ims"), (int)tmpi);
       
   662     		if (tmpi > 1000)
       
   663 				tmps.Printf(wxT("%is"), (int)(tmpi / 1000));
       
   664     		MonDc.DrawRotatedText(tmps, (int)((60 * i) + left) - 10, (int)(317 + top), 0);
       
   665     	}
       
   666     for (j=1; j < 10; j++)    
       
   667 		MonDc.DrawLine((int)left, (int)(300 - (30 * j) + top), (int)(left + 660), (int)(300 - (30 * j) + top));
       
   668     MonDc.SetPen(wxPen(wxColor(150,200,150), 2, wxSOLID));
       
   669     for (j=1; j < 22; j++)    
       
   670     		MonDc.DrawLine((int)(30 * j + left), (int)(300 + top), (int)(30 * j + left), (int)(top));
       
   671 	  MonDc.SetPen(wxPen(wxColor(150,170,150), 1, wxSOLID));
       
   672    	for (j=1; j < 22; j++)    
       
   673     	MonDc.DrawLine((int)(30 * j + left - 15), (int)(300 + top), (int)(30 * j + left - 15), (int)(top));
       
   674     MonDc.DrawLine((int)(30 * 22 + left - 15), (int)(300 + top), (int)(30 * 22 + left - 15), (int)(top));
       
   675     
       
   676     double m = (- vmin) * d;
       
   677 	MonDc.SetPen(wxPen(wxColor(170,170,150), 3, wxSOLID));
       
   678 	MonDc.DrawLine((int)(left), (int)(300 + top - m), (int)(left + 660), (int)(300 + top - m));
       
   679 
       
   680 	wxClientDC MaLeg(mylegpan);
       
   681 	MaLeg.Clear();
       
   682 	
       
   683     MaLeg.SetPen(wxPen(wxColour(150,200,100), 2, wxSOLID));
       
   684     MaLeg.SetFont(wxFont(7, wxSWISS , wxNORMAL, wxNORMAL, false, wxT("Arial Black")));
       
   685     for (int	k=1, tmpi = 0; k < 30; k++)  
       
   686     {
       
   687     	if ((tmpi < 8) && is_set(k, inlist, in))
       
   688 			{
       
   689 				if (k <= 4)
       
   690 					tmps.Printf(wxT("Analogue Output %d"), k);
       
   691 				if ((k > 4) && (k <= 12))
       
   692 					tmps.Printf(wxT("Bool Output %d"), k - 4);
       
   693 				if ((k > 12) && (k <= 20))
       
   694 					tmps.Printf(wxT("Analogue Input %d"), k - 12);
       
   695 				if ((k > 20) && (k <= 28))
       
   696 					tmps.Printf(wxT("Bool Input %d"), k - 20);
       
   697 				
       
   698 				MaLeg.DrawRotatedText(tmps, 0, 10 * tmpi , 0);
       
   699 				MaLeg.SetPen(wxPen(col[tmpi], 4, wxSOLID));
       
   700 				MaLeg.DrawLine(100, 10 * tmpi + 6, 115, 10 * tmpi + 6);
       
   701 	//////////////////////////////////////////DAW////////////////////////////////////////
       
   702 				MonDc.SetPen(wxPen(col[tmpi], 4, wxSOLID));
       
   703 				if (k <= 4)
       
   704 					y[k - 1][(int)g] = Write_Analogue_Output_16_Bit[k - 1];
       
   705 				if ((k > 4) && (k <= 12))
       
   706 					y[k - 1][(int)g] = get_bit(Write_Outputs_8_Bit[0] ,k - 4);
       
   707 				if ((k > 12) && (k <= 20))
       
   708 					y[k - 1][(int)g] = Read_Analogue_Input_16_Bit[k - 1 -12];
       
   709 				if ((k > 20) && (k <= 28))
       
   710 					y[k - 1][(int)g] = get_bit(Read_Inputs_8_Bit[0] ,k - 20);
       
   711 					
       
   712 				if (y[k - 1][(int)g] > old_max)
       
   713 					old_max = y[k - 1][(int)g];
       
   714 				if (y[k - 1][(int)g] < old_min)
       
   715 					old_min = y[k - 1][(int)g];
       
   716 			    for (j=1; j < (g + 1) ; j++)    
       
   717     			{    				
       
   718 					p = (y[k - 1][j - 1] - vmin) * d;
       
   719 					q = (y[k - 1][j    ] - vmin) * d;
       
   720     				MonDc.DrawLine((int)(15 * (j - 1) + left), (int)(300 + top - p), (int)(15 * j + left), (int)(300 + top - q));
       
   721     			}	
       
   722 	/////////////////////////////////////////////////////////////////////////////////////
       
   723 				tmpi++;
       
   724 			}
       
   725     }
       
   726 }
       
   727 
       
   728 void actu_output(void)
       
   729 {
       
   730 	wxString	tmp;
       
   731 	
       
   732 	frame->outbt1->SetValue(get_bit(Write_Outputs_8_Bit[0], 1));
       
   733 	frame->outbt2->SetValue(get_bit(Write_Outputs_8_Bit[0], 2));
       
   734 	frame->outbt3->SetValue(get_bit(Write_Outputs_8_Bit[0], 3));
       
   735 	frame->outbt4->SetValue(get_bit(Write_Outputs_8_Bit[0], 4));
       
   736 	frame->outbt5->SetValue(get_bit(Write_Outputs_8_Bit[0], 5));
       
   737 	frame->outbt6->SetValue(get_bit(Write_Outputs_8_Bit[0], 6));
       
   738 	frame->outbt7->SetValue(get_bit(Write_Outputs_8_Bit[0], 7));
       
   739 	frame->outbt8->SetValue(get_bit(Write_Outputs_8_Bit[0], 8));
       
   740 
       
   741 	frame->outs1->SetValue(Write_Analogue_Output_16_Bit[0] + 32768);
       
   742 	frame->outs2->SetValue(Write_Analogue_Output_16_Bit[1] + 32768);
       
   743 	frame->outs3->SetValue(Write_Analogue_Output_16_Bit[2] + 32768);
       
   744 	frame->outs4->SetValue(Write_Analogue_Output_16_Bit[3] + 32768);
       
   745 	tmp.Printf(wxT("       %i"), Write_Analogue_Output_16_Bit[0]);
       
   746 	frame->outst1->SetLabel(tmp);
       
   747 	tmp.Printf(wxT("       %i"), Write_Analogue_Output_16_Bit[1]);
       
   748 	frame->outst2->SetLabel(tmp);
       
   749 	tmp.Printf(wxT("       %i"), Write_Analogue_Output_16_Bit[2]);
       
   750 	frame->outst3->SetLabel(tmp);
       
   751 	tmp.Printf(wxT("       %i"), Write_Analogue_Output_16_Bit[3]);
       
   752 	frame->outst4->SetLabel(tmp);
       
   753 }
       
   754 
       
   755 void actu(void)
       
   756 {
       
   757 	actu_output();
       
   758 	
       
   759 	Gtime++;
       
   760 	if (Gtime > hdelta)
       
   761 	{
       
   762 		old_max = 5;
       
   763 		old_min = -5;
       
   764 		Gtime = 0;
       
   765 	}
       
   766 	frame->Paint();
       
   767 }
       
   768 
       
   769 void MyFrame::OnTimer(wxTimerEvent& event)
       
   770 {
       
   771     actu();// do whatever you want to do every second here
       
   772 }
       
   773 
       
   774 void MyFrame::OnPaint( wxPaintEvent &event )
       
   775 {
       
   776 	//Paint();
       
   777 }