3 #include <wx/textctrl.h>
4 #include <wx/spinctrl.h>
11 #include <wx/listbox.h>
12 #include <wx/dynarray.h>
13 #include <wx/dcclient.h>
15 #include <wx/spinctrl.h>
17 //#include "monicone.xpm"
19 #if defined(WIN32) && !defined(__CYGWIN__)
28 #include "TestSlaveGui.h"
31 #include "canfestival.h"
34 #include "wx/wxprec.h"
52 #define MAXLENGTH_BUSNAME 32
53 #define MAXLENGTH_BAUDRATE 8
54 char _busname[MAXLENGTH_BUSNAME] = "vcan0";
55 char _baudrate[MAXLENGTH_BAUDRATE] = "500K";
56 s_BOARD SlaveBoard = { _busname, _baudrate };
58 #define MAXLENGTH_LIBPATH 1024
59 char LibraryPath[MAXLENGTH_LIBPATH] = "libcanfestival_can_virtual.so";
62 #define LIB_EXTENT wxT("*.dll")
64 #define LIB_EXTENT wxT("*.so")
67 // Declare some IDs. These are arbitrary.
68 const int BOOKCTRL = 100;
69 const int FILE_QUIT = wxID_EXIT;
70 const int HELP_ABOUT = wxID_ABOUT;
72 const int REMOVE = 108;
74 const int FREQBOX = 110;
75 const int START = 112;
76 const int TEXTBOX1 = 113;
79 const int INBT1 = 118;
80 const int INBT2 = 119;
81 const int INBT3 = 120;
82 const int INBT4 = 121;
83 const int INBT5 = 122;
84 const int INBT6 = 123;
85 const int INBT7 = 124;
86 const int INBT8 = 125;
95 const int TIMER_ID = 130;
96 const int INST1 = 131;
97 const int INST2 = 132;
98 const int INST3 = 133;
99 const int INST4 = 134;
100 const int INST5 = 135;
101 const int INST6 = 136;
102 const int INST7 = 137;
103 const int INST8 = 138;
105 // Attach the event handlers. Put this after MyFrame declaration.
106 BEGIN_EVENT_TABLE (MyFrame, wxFrame)
107 EVT_BUTTON (STOP, MyFrame::OnStop)
108 EVT_BUTTON (LOAD, MyFrame::OnLoad)
109 EVT_BUTTON (START, MyFrame::OnStart)
110 EVT_TOGGLEBUTTON (INBT1, MyFrame::OnInbt1)
111 EVT_TOGGLEBUTTON (INBT2, MyFrame::OnInbt2)
112 EVT_TOGGLEBUTTON (INBT3, MyFrame::OnInbt3)
113 EVT_TOGGLEBUTTON (INBT4, MyFrame::OnInbt4)
114 EVT_TOGGLEBUTTON (INBT5, MyFrame::OnInbt5)
115 EVT_TOGGLEBUTTON (INBT6, MyFrame::OnInbt6)
116 EVT_TOGGLEBUTTON (INBT7, MyFrame::OnInbt7)
117 EVT_TOGGLEBUTTON (INBT8, MyFrame::OnInbt8)
118 EVT_COMMAND_SCROLL (INS1, MyFrame::OnIns1)
119 EVT_COMMAND_SCROLL (INS2, MyFrame::OnIns2)
120 EVT_COMMAND_SCROLL (INS3, MyFrame::OnIns3)
121 EVT_COMMAND_SCROLL (INS4, MyFrame::OnIns4)
122 EVT_COMMAND_SCROLL (INS5, MyFrame::OnIns5)
123 EVT_COMMAND_SCROLL (INS6, MyFrame::OnIns6)
124 EVT_COMMAND_SCROLL (INS7, MyFrame::OnIns7)
125 EVT_COMMAND_SCROLL (INS8, MyFrame::OnIns8)
126 EVT_SPINCTRL (INST1, MyFrame::OnInst1)
127 EVT_SPINCTRL (INST2, MyFrame::OnInst2)
128 EVT_SPINCTRL (INST3, MyFrame::OnInst3)
129 EVT_SPINCTRL (INST4, MyFrame::OnInst4)
130 EVT_SPINCTRL (INST5, MyFrame::OnInst5)
131 EVT_SPINCTRL (INST6, MyFrame::OnInst6)
132 EVT_SPINCTRL (INST7, MyFrame::OnInst7)
133 EVT_SPINCTRL (INST8, MyFrame::OnInst8)
134 EVT_LISTBOX (FREQBOX, MyFrame::OnFreqBoxClick)
135 EVT_MENU (FILE_QUIT, MyFrame::OnQuit)
136 EVT_BUTTON (QUIT, MyFrame::OnQuit) EVT_MENU (HELP_ABOUT, MyFrame::OnAbout)
137 EVT_TIMER (TIMER_ID, MyFrame::OnTimer)
138 END_EVENT_TABLE ()IMPLEMENT_APP_NO_MAIN (MyApp);
139 IMPLEMENT_WX_THEME_SUPPORT;
144 printf ("**************************************************************\n");
145 printf ("* DS-401 Slave GUI *\n");
147 printf ("* Usage: *\n");
148 printf ("* ./DS401_Slave_Gui [OPTIONS] *\n");
150 printf ("* OPTIONS: *\n");
152 ("* -l : Can library [\"libcanfestival_can_virtual.so\"] *\n");
154 printf ("* Slave: *\n");
155 printf ("* -i : Node id format [0x01 , 0x7F] *\n");
157 printf ("* CAN bus: *\n");
159 ("* -b : bus name [\"1\"] *\n");
160 printf ("* -B : 1M,500K,250K,125K,100K,50K,20K,10K *\n");
162 printf ("**************************************************************\n");
167 main (int argc, char **argv)
173 while ((c = getopt (argc, argv, "-b:B:l:i:sIO")) != EOF)
183 SlaveBoard.busname = optarg;
191 SlaveBoard.baudrate = optarg;
199 strncpy (LibraryPath, optarg, MAXLENGTH_LIBPATH);
208 sscanf (snodeid, "%x", &node_id_ext);
224 wxEntry (argc, argv);
231 frame = new MyFrame (wxString::Format(wxT("CanOpen virtual DS-401 - Id : %d"),node_id_ext));
233 if(openInput) frame->book->SetSelection(2);
234 else if(openOutput) frame->book->SetSelection(3);
238 MyFrame::MyFrame (const wxString & title):wxFrame (NULL, wxID_ANY, title, wxDefaultPosition, wxSize (800, 740),
239 wxDEFAULT_FRAME_STYLE, wxT ("frame")), m_timer (this,
243 fileMenu = new wxMenu;
245 helpMenu = new wxMenu;
269 // SetIcon(wxICON(monicone));
270 SetBackgroundColour (wxSystemSettings::GetColour (wxSYS_COLOUR_BTNFACE));
271 helpMenu->Append (HELP_ABOUT, _T ("&About...\tF1"),
272 _T ("Show about dialog"));
273 fileMenu->Append (FILE_QUIT, _T ("E&xit\tAlt-X"), _T ("Quit this program"));
275 menuBar = new wxMenuBar ();
276 menuBar->Append (fileMenu, _T ("&File"));
277 menuBar->Append (helpMenu, _T ("&Help"));
278 SetMenuBar (menuBar);
280 SetStatusText (_T ("Lolitech."), 0);
281 SetStatusText (_T ("Welcome."), 1);
283 book = new wxNotebook (this, BOOKCTRL);
285 panel = new wxPanel (book);
286 book->AddPage (panel, _T ("Configuration"), true);
287 mysizer = new wxBoxSizer (wxVERTICAL);
288 panel->SetSizer (mysizer);
291 _T ("10K"), _T ("20K"), _T ("50K"), _T ("100K"),
292 _T ("125K"), _T ("250K"), _T ("500K"), _T ("1M")
296 new wxStaticBoxSizer (new
297 wxStaticBox (panel, wxID_ANY, _T ("Bus driver")),
299 mysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 5);
300 load = new wxButton (panel, LOAD, _T ("Load can driver"));
301 myhsizer->Add (load, 0, wxLEFT, 5);
303 new wxTextCtrl (panel, wxID_ANY,
304 wxString ((const char *) LibraryPath, wxConvLocal));
305 myhsizer->Add (drivername, 1, wxEXPAND | wxALL, 5);
306 myentrysizer = new wxBoxSizer (wxHORIZONTAL);
307 mysizer->Add (myentrysizer, 0, wxEXPAND | wxALL, 5);
309 new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, _T ("Bus name")),
311 myentrysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 5);
313 new wxTextCtrl (panel, wxID_ANY,
314 wxString ((const char *) SlaveBoard.busname,
316 myhsizer->Add (busname, 0, wxLEFT, 5);
318 new wxStaticBoxSizer (new
319 wxStaticBox (panel, wxID_ANY,
320 _T ("Node ID (Decimal)")), wxHORIZONTAL);
321 myentrysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 5);
323 new wxSpinCtrl (panel, wxID_ANY, wxEmptyString, wxDefaultPosition,
324 wxDefaultSize, wxSP_ARROW_KEYS, 1, 127, node_id_ext,
326 myhsizer->Add (node_id, 0, wxRIGHT, 5);
328 new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, _T ("Baudrate")),
330 mysizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 5);
332 new wxListBox (panel, FREQBOX, wxDefaultPosition, wxDefaultSize, 8,
333 choices, wxLB_SINGLE | wxLB_HSCROLL);
334 myhsizer->Add (freqlist, wxEXPAND | wxALL, wxEXPAND | wxALL, 5);
335 quit = new wxButton (panel, QUIT, _T ("QUIT"));
336 mysizer->Add (quit, 0, wxALL, 5);
339 panel = new wxPanel (book);
340 book->AddPage (panel, wxT ("Inputs"), true);
341 mysizer = new wxBoxSizer (wxVERTICAL);
342 panel->SetSizer (mysizer);
344 new wxStaticBoxSizer (new
345 wxStaticBox (panel, wxID_ANY,
346 _T ("Read Inputs UNSIGNED8")),
348 mysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 30);
349 inbt1 = new wxToggleButton (panel, INBT1, wxT ("1"));
350 inbt2 = new wxToggleButton (panel, INBT2, wxT ("2"));
351 inbt3 = new wxToggleButton (panel, INBT3, wxT ("3"));
352 inbt4 = new wxToggleButton (panel, INBT4, wxT ("4"));
353 inbt5 = new wxToggleButton (panel, INBT5, wxT ("5"));
354 inbt6 = new wxToggleButton (panel, INBT6, wxT ("6"));
355 inbt7 = new wxToggleButton (panel, INBT7, wxT ("7"));
356 inbt8 = new wxToggleButton (panel, INBT8, wxT ("8"));
357 myhsizer->Add (inbt1, wxEXPAND | wxALL, 0, 5);
358 myhsizer->Add (inbt2, wxEXPAND | wxALL, 0, 5);
359 myhsizer->Add (inbt3, wxEXPAND | wxALL, 0, 5);
360 myhsizer->Add (inbt4, wxEXPAND | wxALL, 0, 5);
361 myhsizer->Add (inbt5, wxEXPAND | wxALL, 0, 5);
362 myhsizer->Add (inbt6, wxEXPAND | wxALL, 0, 5);
363 myhsizer->Add (inbt7, wxEXPAND | wxALL, 0, 5);
364 myhsizer->Add (inbt8, wxEXPAND | wxALL, 0, 5);
366 new wxStaticBoxSizer (new
367 wxStaticBox (panel, wxID_ANY,
368 _T ("Analogue Inputs INTEGER16")),
370 mysizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 30);
371 mysssizer = new wxBoxSizer (wxHORIZONTAL);
372 myhsizer->Add (mysssizer, 0, wxEXPAND | wxALL, 0);
374 new wxSpinCtrl (panel, INST1, wxEmptyString, wxDefaultPosition,
375 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0,
378 new wxSpinCtrl (panel, INST2, wxEmptyString, wxDefaultPosition,
379 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0,
382 new wxSpinCtrl (panel, INST3, wxEmptyString, wxDefaultPosition,
383 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0,
386 new wxSpinCtrl (panel, INST4, wxEmptyString, wxDefaultPosition,
387 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0,
390 new wxSpinCtrl (panel, INST5, wxEmptyString, wxDefaultPosition,
391 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0,
394 new wxSpinCtrl (panel, INST6, wxEmptyString, wxDefaultPosition,
395 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0,
398 new wxSpinCtrl (panel, INST7, wxEmptyString, wxDefaultPosition,
399 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0,
402 new wxSpinCtrl (panel, INST8, wxEmptyString, wxDefaultPosition,
403 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0,
405 mysssizer->Add (inst1, wxALL, 0, 5);
406 mysssizer->Add (inst2, wxALL, 0, 5);
407 mysssizer->Add (inst3, wxALL, 0, 5);
408 mysssizer->Add (inst4, wxALL, 0, 5);
409 mysssizer->Add (inst5, wxALL, 0, 5);
410 mysssizer->Add (inst6, wxALL, 0, 5);
411 mysssizer->Add (inst7, wxALL, 0, 5);
412 mysssizer->Add (inst8, wxALL, 0, 5);
413 mysssizer = new wxBoxSizer (wxHORIZONTAL);
414 myhsizer->Add (mysssizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 0);
416 new wxSlider (panel, INS1, 0, -32768, 32767, wxDefaultPosition,
417 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE,
418 wxDefaultValidator, wxT ("slider"));
420 new wxSlider (panel, INS2, 0, -32768, 32767, wxDefaultPosition,
421 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE,
422 wxDefaultValidator, wxT ("slider"));
424 new wxSlider (panel, INS3, 0, -32768, 32767, wxDefaultPosition,
425 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE,
426 wxDefaultValidator, wxT ("slider"));
428 new wxSlider (panel, INS4, 0, -32768, 32767, wxDefaultPosition,
429 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE,
430 wxDefaultValidator, wxT ("slider"));
432 new wxSlider (panel, INS5, 0, -32768, 32767, wxDefaultPosition,
433 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE,
434 wxDefaultValidator, wxT ("slider"));
436 new wxSlider (panel, INS6, 0, -32768, 32767, wxDefaultPosition,
437 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE,
438 wxDefaultValidator, wxT ("slider"));
440 new wxSlider (panel, INS7, 0, -32768, 32767, wxDefaultPosition,
441 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE,
442 wxDefaultValidator, wxT ("slider"));
444 new wxSlider (panel, INS8, 0, -32768, 32767, wxDefaultPosition,
445 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE,
446 wxDefaultValidator, wxT ("slider"));
447 mysssizer->Add (ins1, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
448 mysssizer->Add (ins2, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
449 mysssizer->Add (ins3, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
450 mysssizer->Add (ins4, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
451 mysssizer->Add (ins5, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
452 mysssizer->Add (ins6, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
453 mysssizer->Add (ins7, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
454 mysssizer->Add (ins8, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
455 quit = new wxButton (panel, QUIT, _T ("QUIT"));
456 mysizer->Add (quit, 0, wxALL, 5);
458 panel = new wxPanel (book);
459 book->AddPage (panel, wxT ("Outputs"), true);
460 mysizer = new wxBoxSizer (wxVERTICAL);
461 panel->SetSizer (mysizer);
463 new wxStaticBoxSizer (new
464 wxStaticBox (panel, wxID_ANY,
465 _T ("Write Outputs UNSIGNED8")),
467 mysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 30);
468 outbt1 = new wxToggleButton (panel, wxID_ANY, wxT ("1"));
469 outbt2 = new wxToggleButton (panel, wxID_ANY, wxT ("2"));
470 outbt3 = new wxToggleButton (panel, wxID_ANY, wxT ("3"));
471 outbt4 = new wxToggleButton (panel, wxID_ANY, wxT ("4"));
472 outbt5 = new wxToggleButton (panel, wxID_ANY, wxT ("5"));
473 outbt6 = new wxToggleButton (panel, wxID_ANY, wxT ("6"));
474 outbt7 = new wxToggleButton (panel, wxID_ANY, wxT ("7"));
475 outbt8 = new wxToggleButton (panel, wxID_ANY, wxT ("8"));
476 myhsizer->Add (outbt1, wxEXPAND | wxALL, 0, 5);
477 myhsizer->Add (outbt2, wxEXPAND | wxALL, 0, 5);
478 myhsizer->Add (outbt3, wxEXPAND | wxALL, 0, 5);
479 myhsizer->Add (outbt4, wxEXPAND | wxALL, 0, 5);
480 myhsizer->Add (outbt5, wxEXPAND | wxALL, 0, 5);
481 myhsizer->Add (outbt6, wxEXPAND | wxALL, 0, 5);
482 myhsizer->Add (outbt7, wxEXPAND | wxALL, 0, 5);
483 myhsizer->Add (outbt8, wxEXPAND | wxALL, 0, 5);
485 new wxStaticBoxSizer (new
486 wxStaticBox (panel, wxID_ANY,
487 _T ("Analogue Output INTEGER16")),
489 mysizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 30);
490 mysssizer = new wxBoxSizer (wxHORIZONTAL);
491 myhsizer->Add (mysssizer, 0, wxEXPAND | wxALL, 0);
493 new wxStaticText (panel, wxID_ANY, wxT ("label"), wxDefaultPosition,
494 wxDefaultSize, 0, wxT ("staticText"));
496 new wxStaticText (panel, wxID_ANY, wxT ("label"), wxDefaultPosition,
497 wxDefaultSize, 0, wxT ("staticText"));
499 new wxStaticText (panel, wxID_ANY, wxT ("label"), wxDefaultPosition,
500 wxDefaultSize, 0, wxT ("staticText"));
502 new wxStaticText (panel, wxID_ANY, wxT ("label"), wxDefaultPosition,
503 wxDefaultSize, 0, wxT ("staticText"));
504 mysssizer->Add (outst1, wxEXPAND | wxALL, wxEXPAND | wxALL, 5);
505 mysssizer->Add (outst2, wxEXPAND | wxALL, wxEXPAND | wxALL, 5);
506 mysssizer->Add (outst3, wxEXPAND | wxALL, wxEXPAND | wxALL, 5);
507 mysssizer->Add (outst4, wxEXPAND | wxALL, wxEXPAND | wxALL, 5);
508 mysssizer = new wxBoxSizer (wxHORIZONTAL);
509 myhsizer->Add (mysssizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 0);
511 new wxGauge (panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize,
512 wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator,
515 new wxGauge (panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize,
516 wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator,
519 new wxGauge (panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize,
520 wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator,
523 new wxGauge (panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize,
524 wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator,
526 mysssizer->Add (outs1, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
527 mysssizer->Add (outs2, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
528 mysssizer->Add (outs3, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
529 mysssizer->Add (outs4, wxEXPAND | wxALL, wxEXPAND | wxALL, 15);
530 quit = new wxButton (panel, QUIT, _T ("QUIT"));
531 mysizer->Add (quit, 0, wxALL, 5);
535 _T ("Analogue Out 1"), _T ("Analogue Out 2"),
536 _T ("Analogue Out 3"), _T ("Analogue Out 4"),
537 _T ("Bool Out 1"), _T ("Bool Out 2"),
538 _T ("Bool Out 3"), _T ("Bool Out 4"),
539 _T ("Bool Out 5"), _T ("Bool Out 6"),
540 _T ("Bool Out 7"), _T ("Bool Out 8"),
541 _T ("Analogue Input 1"), _T ("Analogue Input 2"),
542 _T ("Analogue Input 3"), _T ("Analogue Input 4"),
543 _T ("Analogue Input 5"), _T ("Analogue Input 6"),
544 _T ("Analogue Input 7"), _T ("Analogue Input 8"),
545 _T ("Bool Input 1"), _T ("Bool Input 2"),
546 _T ("Bool Input 3"), _T ("Bool Input 4"),
547 _T ("Bool Input 5"), _T ("Bool Input 6"),
548 _T ("Bool Input 7"), _T ("Bool Input 8"),
551 panel = new wxPanel (book);
552 book->InsertPage (0, panel, wxT ("Control"), true);
553 mysizer = new wxBoxSizer (wxVERTICAL);
554 panel->SetSizer (mysizer);
555 myhsizer = new wxBoxSizer (wxHORIZONTAL);
557 new wxStaticBoxSizer (new
558 wxStaticBox (panel, wxID_ANY,
559 _T ("Control your node")),
561 mysizer->Add (myhsizer, 0, wxALL, 5);
562 start = new wxButton (panel, START, _T ("START"));
563 stop = new wxButton (panel, STOP, _T ("STOP"));
564 stop->Enable (false);
565 myhsizer->Add (start, 0, wxRIGHT, 5);
566 myhsizer->Add (stop, 0, wxLEFT, 5);
568 new wxStaticBoxSizer (new
569 wxStaticBox (panel, wxID_ANY, _T ("Operation log")),
571 mysizer->Add (myhsizer, wxALL, wxEXPAND | wxALL, 5);
573 new wxTextCtrl (panel, TEXTBOX1, _T (""), wxDefaultPosition,
574 wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator,
576 myhsizer->Add (textLog, wxALL, wxEXPAND | wxALL, 5);
577 quit = new wxButton (panel, QUIT, _T ("QUIT"));
578 mysizer->Add (quit, 0, wxALL, 5);
588 MyFrame::OnQuit (wxCommandEvent & WXUNUSED (event))
596 if (main_can (SlaveBoard, LibraryPath))
601 ("----------------------------------------------------Initialization [KO]\n");
608 ("----------------------------------------------------Initialization [OK]\n");
610 start->Enable (false);
615 MyFrame::OnStart (wxCommandEvent & WXUNUSED (event))
619 node_id_ext = node_id->GetValue ();
620 s = busname->GetValue ();
621 strncpy (SlaveBoard.busname, s.mb_str (), MAXLENGTH_BUSNAME);
622 *textLog << wxT ("-- Bus name: ------> ") << s << wxT ("\n");
623 *textLog << wxT ("-- Node ID: -------> ") << node_id->
624 GetValue () << wxT ("\n");
625 SetTitle(wxString::Format(wxT("CanOpen virtual DS-401 - Id : %d"),node_id->
632 MyFrame::OnStop (wxCommandEvent & WXUNUSED (event))
637 ("----------------------------------------------------Slave [STOPPED]") <<
640 stop->Enable (false);
641 start->Enable (true);
645 MyFrame::OnLoad (wxCommandEvent & WXUNUSED (event))
647 wxFileDialog fd (this, wxT ("Choose a can driver library"), wxT (""),
648 wxT (""), LIB_EXTENT);
650 if (fd.ShowModal () == wxID_OK)
652 drivername->Clear ();
653 drivername->AppendText (fd.GetPath ());
654 *textLog << wxT ("LibraryPath: ") << fd.GetPath () << wxT ("\n");
655 strncpy (LibraryPath, fd.GetPath ().mb_str (), MAXLENGTH_LIBPATH);
656 printf ("path=%s", LibraryPath);
661 MyFrame::OnInbt1 (wxCommandEvent & WXUNUSED (event))
663 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x1;
667 MyFrame::OnInbt2 (wxCommandEvent & WXUNUSED (event))
669 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x2;
673 MyFrame::OnInbt3 (wxCommandEvent & WXUNUSED (event))
675 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x4;
679 MyFrame::OnInbt4 (wxCommandEvent & WXUNUSED (event))
681 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x8;
685 MyFrame::OnInbt5 (wxCommandEvent & WXUNUSED (event))
687 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x10;
691 MyFrame::OnInbt6 (wxCommandEvent & WXUNUSED (event))
693 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x20;
697 MyFrame::OnInbt7 (wxCommandEvent & WXUNUSED (event))
699 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x40;
703 MyFrame::OnInbt8 (wxCommandEvent & WXUNUSED (event))
705 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x80;
711 MyFrame::OnIns1 (wxScrollEvent & event)
713 Read_Analogue_Input_16_Bit[0] = ins1->GetValue ();
714 inst1->SetValue (ins1->GetValue ());
718 MyFrame::OnIns2 (wxScrollEvent & event)
720 Read_Analogue_Input_16_Bit[1] = ins2->GetValue ();
721 inst2->SetValue (ins2->GetValue ());
725 MyFrame::OnIns3 (wxScrollEvent & event)
727 Read_Analogue_Input_16_Bit[2] = ins3->GetValue ();
728 inst3->SetValue (ins3->GetValue ());
732 MyFrame::OnIns4 (wxScrollEvent & event)
734 Read_Analogue_Input_16_Bit[3] = ins4->GetValue ();
735 inst4->SetValue (ins4->GetValue ());
739 MyFrame::OnIns5 (wxScrollEvent & event)
741 Read_Analogue_Input_16_Bit[4] = ins5->GetValue ();
742 inst5->SetValue (ins5->GetValue ());
746 MyFrame::OnIns6 (wxScrollEvent & event)
748 Read_Analogue_Input_16_Bit[5] = ins6->GetValue ();
749 inst6->SetValue (ins6->GetValue ());
753 MyFrame::OnIns7 (wxScrollEvent & event)
755 Read_Analogue_Input_16_Bit[6] = ins7->GetValue ();
756 inst7->SetValue (ins7->GetValue ());
760 MyFrame::OnIns8 (wxScrollEvent & event)
762 Read_Analogue_Input_16_Bit[7] = ins8->GetValue ();
763 inst8->SetValue (ins8->GetValue ());
768 MyFrame::OnInst1 (wxSpinEvent & ev)
770 Read_Analogue_Input_16_Bit[0] = inst1->GetValue ();
771 ins1->SetValue (inst1->GetValue ());
775 MyFrame::OnInst2 (wxSpinEvent & ev)
777 Read_Analogue_Input_16_Bit[1] = inst2->GetValue ();
778 ins2->SetValue (inst2->GetValue ());
782 MyFrame::OnInst3 (wxSpinEvent & ev)
784 Read_Analogue_Input_16_Bit[2] = inst3->GetValue ();
785 ins3->SetValue (inst3->GetValue ());
789 MyFrame::OnInst4 (wxSpinEvent & ev)
791 Read_Analogue_Input_16_Bit[3] = inst4->GetValue ();
792 ins4->SetValue (inst4->GetValue ());
796 MyFrame::OnInst5 (wxSpinEvent & ev)
798 Read_Analogue_Input_16_Bit[4] = inst5->GetValue ();
799 ins5->SetValue (inst5->GetValue ());
803 MyFrame::OnInst6 (wxSpinEvent & ev)
805 Read_Analogue_Input_16_Bit[5] = inst6->GetValue ();
806 ins6->SetValue (inst6->GetValue ());
810 MyFrame::OnInst7 (wxSpinEvent & ev)
812 Read_Analogue_Input_16_Bit[6] = inst7->GetValue ();
813 ins7->SetValue (inst7->GetValue ());
817 MyFrame::OnInst8 (wxSpinEvent & ev)
819 Read_Analogue_Input_16_Bit[7] = inst8->GetValue ();
820 ins8->SetValue (inst8->GetValue ());
825 MyFrame::OnAbout (wxCommandEvent & WXUNUSED (event))
828 msg.Printf (_T ("About.\n\n")
830 ("Input-Output simulation by GRANDEMANGE Nicolas for CanFestival!!"));
832 wxMessageBox (msg, _T ("About !!!"), wxOK | wxICON_INFORMATION, this);
837 MyFrame::OnFreqBoxClick (wxCommandEvent & event)
841 wxstr = event.GetString ();
842 strncpy (SlaveBoard.baudrate, wxstr.mb_str (), MAXLENGTH_BAUDRATE);
843 *textLog << wxT ("Baudrate:") << event.GetString () << wxT ("\n");
847 is_set (int i, wxListBox * inlist, wxArrayInt in)
849 inlist->GetSelections (in);
850 for (int j = 0; j < in.GetCount (); j++)
852 if (i == (in[j] + 1))
861 get_bit (UNS8 input, int bit)
863 return input & (((UNS8) 1) << bit - 1) ? 1 : 0;
871 frame->outbt1->SetValue (get_bit (Write_Outputs_8_Bit[0], 1));
872 frame->outbt2->SetValue (get_bit (Write_Outputs_8_Bit[0], 2));
873 frame->outbt3->SetValue (get_bit (Write_Outputs_8_Bit[0], 3));
874 frame->outbt4->SetValue (get_bit (Write_Outputs_8_Bit[0], 4));
875 frame->outbt5->SetValue (get_bit (Write_Outputs_8_Bit[0], 5));
876 frame->outbt6->SetValue (get_bit (Write_Outputs_8_Bit[0], 6));
877 frame->outbt7->SetValue (get_bit (Write_Outputs_8_Bit[0], 7));
878 frame->outbt8->SetValue (get_bit (Write_Outputs_8_Bit[0], 8));
880 frame->outs1->SetValue (Write_Analogue_Output_16_Bit[0] + 32768);
881 frame->outs2->SetValue (Write_Analogue_Output_16_Bit[1] + 32768);
882 frame->outs3->SetValue (Write_Analogue_Output_16_Bit[2] + 32768);
883 frame->outs4->SetValue (Write_Analogue_Output_16_Bit[3] + 32768);
884 tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[0]);
885 frame->outst1->SetLabel (tmp);
886 tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[1]);
887 frame->outst2->SetLabel (tmp);
888 tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[2]);
889 frame->outst3->SetLabel (tmp);
890 tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[3]);
891 frame->outst4->SetLabel (tmp);
901 MyFrame::OnTimer (wxTimerEvent & event)
903 actu (); // do whatever you want to do every second here
907 MyFrame::OnPaint (wxPaintEvent & event)