author | Christian Taedcke <hacking@taedcke.com> |
Tue, 12 Jun 2012 00:13:39 +0200 | |
changeset 735 | d3db2140d3e6 |
parent 641 | 404a51700f40 |
permissions | -rw-r--r-- |
641
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
615
diff
changeset
|
1 |
#if defined(WIN32) && !defined(__CYGWIN__) |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
615
diff
changeset
|
2 |
#include <windows.h> |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
615
diff
changeset
|
3 |
#include "getopt.h" |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
615
diff
changeset
|
4 |
#endif |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
615
diff
changeset
|
5 |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
6 |
#include <wx/wxprec.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
7 |
#include <wx/wx.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
8 |
#include <wx/textctrl.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
9 |
#include <wx/spinctrl.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
10 |
#include <wx/tglbtn.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
11 |
#include <wx/slider.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
12 |
#include <iostream> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
13 |
#include <wx/brush.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
14 |
#include <sstream> |
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
15 |
#include <string.h> |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
16 |
#include <wx/listbox.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
17 |
#include <wx/dynarray.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
18 |
#include <wx/dcclient.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
19 |
#include <wx/gauge.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
20 |
#include <wx/spinctrl.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
21 |
|
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
22 |
//#include "monicone.xpm" |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
23 |
|
641
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
615
diff
changeset
|
24 |
//#if defined(WIN32) && !defined(__CYGWIN__) |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
615
diff
changeset
|
25 |
//#include <windows.h> |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
615
diff
changeset
|
26 |
//extern "C" |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
615
diff
changeset
|
27 |
//{ |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
615
diff
changeset
|
28 |
//#include "getopt.h" |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
615
diff
changeset
|
29 |
//} |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
615
diff
changeset
|
30 |
//#endif |
329 | 31 |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
32 |
#include "main.h" |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
33 |
#include "TestSlaveGui.h" |
382 | 34 |
extern "C" |
35 |
{ |
|
36 |
#include "canfestival.h" |
|
37 |
#include "ObjDict.h" |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
38 |
} |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
39 |
#include "wx/wxprec.h" |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
40 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
41 |
#ifdef __BORLANDC__ |
382 | 42 |
#pragma hdrstop |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
43 |
#endif |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
44 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
45 |
#ifndef WX_PRECOMP |
382 | 46 |
#include "wx/wx.h" |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
47 |
#endif |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
48 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
49 |
|
382 | 50 |
wxTextCtrl *textLog; |
51 |
int node_id_ext; |
|
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
52 |
int to_start = 0; |
385
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
53 |
int openInput = 0; |
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
54 |
int openOutput = 0; |
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
55 |
|
382 | 56 |
MyFrame *frame; |
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
57 |
#define MAXLENGTH_BUSNAME 32 |
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
58 |
#define MAXLENGTH_BAUDRATE 8 |
382 | 59 |
char _busname[MAXLENGTH_BUSNAME] = "vcan0"; |
60 |
char _baudrate[MAXLENGTH_BAUDRATE] = "500K"; |
|
61 |
s_BOARD SlaveBoard = { _busname, _baudrate }; |
|
62 |
||
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
63 |
#define MAXLENGTH_LIBPATH 1024 |
382 | 64 |
char LibraryPath[MAXLENGTH_LIBPATH] = "libcanfestival_can_virtual.so"; |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
65 |
|
331 | 66 |
#if defined(WIN32) |
67 |
#define LIB_EXTENT wxT("*.dll") |
|
68 |
#else |
|
69 |
#define LIB_EXTENT wxT("*.so") |
|
70 |
#endif |
|
71 |
||
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
72 |
// Declare some IDs. These are arbitrary. |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
73 |
const int BOOKCTRL = 100; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
74 |
const int FILE_QUIT = wxID_EXIT; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
75 |
const int HELP_ABOUT = wxID_ABOUT; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
76 |
const int ADD = 105; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
77 |
const int REMOVE = 108; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
78 |
const int QUIT = 109; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
79 |
const int FREQBOX = 110; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
80 |
const int START = 112; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
81 |
const int TEXTBOX1 = 113; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
82 |
const int STOP = 114; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
83 |
const int LOAD = 115; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
84 |
const int INBT1 = 118; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
85 |
const int INBT2 = 119; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
86 |
const int INBT3 = 120; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
87 |
const int INBT4 = 121; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
88 |
const int INBT5 = 122; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
89 |
const int INBT6 = 123; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
90 |
const int INBT7 = 124; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
91 |
const int INBT8 = 125; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
92 |
const int INS1 = 126; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
93 |
const int INS2 = 127; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
94 |
const int INS3 = 128; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
95 |
const int INS4 = 129; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
96 |
const int INS5 = 135; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
97 |
const int INS6 = 136; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
98 |
const int INS7 = 137; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
99 |
const int INS8 = 138; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
100 |
const int TIMER_ID = 130; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
101 |
const int INST1 = 131; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
102 |
const int INST2 = 132; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
103 |
const int INST3 = 133; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
104 |
const int INST4 = 134; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
105 |
const int INST5 = 135; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
106 |
const int INST6 = 136; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
107 |
const int INST7 = 137; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
108 |
const int INST8 = 138; |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
109 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
110 |
// Attach the event handlers. Put this after MyFrame declaration. |
382 | 111 |
BEGIN_EVENT_TABLE (MyFrame, wxFrame) |
112 |
EVT_BUTTON (STOP, MyFrame::OnStop) |
|
113 |
EVT_BUTTON (LOAD, MyFrame::OnLoad) |
|
114 |
EVT_BUTTON (START, MyFrame::OnStart) |
|
115 |
EVT_TOGGLEBUTTON (INBT1, MyFrame::OnInbt1) |
|
116 |
EVT_TOGGLEBUTTON (INBT2, MyFrame::OnInbt2) |
|
117 |
EVT_TOGGLEBUTTON (INBT3, MyFrame::OnInbt3) |
|
118 |
EVT_TOGGLEBUTTON (INBT4, MyFrame::OnInbt4) |
|
119 |
EVT_TOGGLEBUTTON (INBT5, MyFrame::OnInbt5) |
|
120 |
EVT_TOGGLEBUTTON (INBT6, MyFrame::OnInbt6) |
|
121 |
EVT_TOGGLEBUTTON (INBT7, MyFrame::OnInbt7) |
|
122 |
EVT_TOGGLEBUTTON (INBT8, MyFrame::OnInbt8) |
|
123 |
EVT_COMMAND_SCROLL (INS1, MyFrame::OnIns1) |
|
124 |
EVT_COMMAND_SCROLL (INS2, MyFrame::OnIns2) |
|
125 |
EVT_COMMAND_SCROLL (INS3, MyFrame::OnIns3) |
|
126 |
EVT_COMMAND_SCROLL (INS4, MyFrame::OnIns4) |
|
127 |
EVT_COMMAND_SCROLL (INS5, MyFrame::OnIns5) |
|
128 |
EVT_COMMAND_SCROLL (INS6, MyFrame::OnIns6) |
|
129 |
EVT_COMMAND_SCROLL (INS7, MyFrame::OnIns7) |
|
130 |
EVT_COMMAND_SCROLL (INS8, MyFrame::OnIns8) |
|
131 |
EVT_SPINCTRL (INST1, MyFrame::OnInst1) |
|
132 |
EVT_SPINCTRL (INST2, MyFrame::OnInst2) |
|
133 |
EVT_SPINCTRL (INST3, MyFrame::OnInst3) |
|
134 |
EVT_SPINCTRL (INST4, MyFrame::OnInst4) |
|
135 |
EVT_SPINCTRL (INST5, MyFrame::OnInst5) |
|
136 |
EVT_SPINCTRL (INST6, MyFrame::OnInst6) |
|
137 |
EVT_SPINCTRL (INST7, MyFrame::OnInst7) |
|
138 |
EVT_SPINCTRL (INST8, MyFrame::OnInst8) |
|
139 |
EVT_LISTBOX (FREQBOX, MyFrame::OnFreqBoxClick) |
|
140 |
EVT_MENU (FILE_QUIT, MyFrame::OnQuit) |
|
141 |
EVT_BUTTON (QUIT, MyFrame::OnQuit) EVT_MENU (HELP_ABOUT, MyFrame::OnAbout) |
|
385
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
142 |
EVT_TIMER (TIMER_ID, MyFrame::OnTimer) |
382 | 143 |
END_EVENT_TABLE ()IMPLEMENT_APP_NO_MAIN (MyApp); |
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
144 |
IMPLEMENT_WX_THEME_SUPPORT; |
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
145 |
|
382 | 146 |
void |
147 |
help () |
|
148 |
{ |
|
149 |
printf ("**************************************************************\n"); |
|
150 |
printf ("* DS-401 Slave GUI *\n"); |
|
151 |
printf ("* *\n"); |
|
152 |
printf ("* Usage: *\n"); |
|
153 |
printf ("* ./DS401_Slave_Gui [OPTIONS] *\n"); |
|
154 |
printf ("* *\n"); |
|
155 |
printf ("* OPTIONS: *\n"); |
|
156 |
printf |
|
157 |
("* -l : Can library [\"libcanfestival_can_virtual.so\"] *\n"); |
|
158 |
printf ("* *\n"); |
|
159 |
printf ("* Slave: *\n"); |
|
160 |
printf ("* -i : Node id format [0x01 , 0x7F] *\n"); |
|
161 |
printf ("* *\n"); |
|
162 |
printf ("* CAN bus: *\n"); |
|
163 |
printf |
|
164 |
("* -b : bus name [\"1\"] *\n"); |
|
165 |
printf ("* -B : 1M,500K,250K,125K,100K,50K,20K,10K *\n"); |
|
166 |
printf ("* *\n"); |
|
167 |
printf ("**************************************************************\n"); |
|
168 |
} |
|
169 |
||
170 |
||
171 |
int |
|
172 |
main (int argc, char **argv) |
|
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
173 |
{ |
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
174 |
|
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
175 |
int c; |
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
176 |
extern char *optarg; |
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
177 |
char *snodeid; |
385
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
178 |
while ((c = getopt (argc, argv, "-b:B:l:i:sIO")) != EOF) |
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
179 |
{ |
382 | 180 |
switch (c) |
181 |
{ |
|
182 |
case 'b': |
|
183 |
if (optarg[0] == 0) |
|
184 |
{ |
|
185 |
help (); |
|
186 |
exit (1); |
|
187 |
} |
|
188 |
SlaveBoard.busname = optarg; |
|
189 |
break; |
|
190 |
case 'B': |
|
191 |
if (optarg[0] == 0) |
|
192 |
{ |
|
193 |
help (); |
|
194 |
exit (1); |
|
195 |
} |
|
196 |
SlaveBoard.baudrate = optarg; |
|
197 |
break; |
|
198 |
case 'l': |
|
199 |
if (optarg[0] == 0) |
|
200 |
{ |
|
201 |
help (); |
|
202 |
exit (1); |
|
203 |
} |
|
204 |
strncpy (LibraryPath, optarg, MAXLENGTH_LIBPATH); |
|
205 |
break; |
|
206 |
case 'i': |
|
207 |
if (optarg[0] == 0) |
|
208 |
{ |
|
209 |
help (); |
|
210 |
exit (1); |
|
211 |
} |
|
212 |
snodeid = optarg; |
|
213 |
sscanf (snodeid, "%x", &node_id_ext); |
|
214 |
break; |
|
215 |
case 's': |
|
216 |
to_start = 1; |
|
217 |
break; |
|
385
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
218 |
case 'I': |
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
219 |
openInput = 1; |
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
220 |
break; |
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
221 |
case 'O': |
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
222 |
openOutput = 1; |
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
223 |
break; |
382 | 224 |
default: |
225 |
help (); |
|
226 |
exit (1); |
|
227 |
} |
|
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
228 |
} |
382 | 229 |
wxEntry (argc, argv); |
230 |
} |
|
231 |
||
232 |
||
233 |
bool |
|
234 |
MyApp::OnInit () |
|
235 |
{ |
|
385
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
236 |
frame = new MyFrame (wxString::Format(wxT("CanOpen virtual DS-401 - Id : %d"),node_id_ext)); |
382 | 237 |
frame->Show (true); |
385
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
238 |
if(openInput) frame->book->SetSelection(2); |
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
239 |
else if(openOutput) frame->book->SetSelection(3); |
382 | 240 |
return true; |
241 |
} |
|
242 |
||
243 |
MyFrame::MyFrame (const wxString & title):wxFrame (NULL, wxID_ANY, title, wxDefaultPosition, wxSize (800, 740), |
|
244 |
wxDEFAULT_FRAME_STYLE, wxT ("frame")), m_timer (this, |
|
245 |
TIMER_ID) |
|
246 |
{ |
|
247 |
wxMenu * |
|
248 |
fileMenu = new wxMenu; |
|
249 |
wxMenu * |
|
250 |
helpMenu = new wxMenu; |
|
251 |
wxPanel * |
|
252 |
panel; |
|
253 |
wxButton * |
|
254 |
quit; |
|
255 |
wxButton * |
|
256 |
load; |
|
257 |
wxBoxSizer * |
|
258 |
mysizer; |
|
259 |
wxBoxSizer * |
|
260 |
mysssizer; |
|
261 |
wxBoxSizer * |
|
262 |
myhsizer; |
|
263 |
wxBoxSizer * |
|
264 |
mybsizer; |
|
265 |
wxBoxSizer * |
|
266 |
myentrysizer; |
|
267 |
wxListBox * |
|
268 |
freqlist; |
|
269 |
wxStaticBox * |
|
270 |
namebox; |
|
271 |
wxStaticBox * |
|
272 |
freqbox; |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
273 |
|
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
274 |
// SetIcon(wxICON(monicone)); |
382 | 275 |
SetBackgroundColour (wxSystemSettings::GetColour (wxSYS_COLOUR_BTNFACE)); |
276 |
helpMenu->Append (HELP_ABOUT, _T ("&About...\tF1"), |
|
277 |
_T ("Show about dialog")); |
|
278 |
fileMenu->Append (FILE_QUIT, _T ("E&xit\tAlt-X"), _T ("Quit this program")); |
|
279 |
wxMenuBar * |
|
280 |
menuBar = new wxMenuBar (); |
|
281 |
menuBar->Append (fileMenu, _T ("&File")); |
|
282 |
menuBar->Append (helpMenu, _T ("&Help")); |
|
283 |
SetMenuBar (menuBar); |
|
284 |
CreateStatusBar (2); |
|
615 | 285 |
SetStatusText (_T ("DS-401 GUI."), 0); |
382 | 286 |
SetStatusText (_T ("Welcome."), 1); |
287 |
||
288 |
book = new wxNotebook (this, BOOKCTRL); |
|
289 |
||
290 |
panel = new wxPanel (book); |
|
291 |
book->AddPage (panel, _T ("Configuration"), true); |
|
292 |
mysizer = new wxBoxSizer (wxVERTICAL); |
|
293 |
panel->SetSizer (mysizer); |
|
294 |
wxString |
|
295 |
choices[] = { |
|
296 |
_T ("10K"), _T ("20K"), _T ("50K"), _T ("100K"), |
|
297 |
_T ("125K"), _T ("250K"), _T ("500K"), _T ("1M") |
|
298 |
}; |
|
299 |
||
300 |
myhsizer = |
|
301 |
new wxStaticBoxSizer (new |
|
302 |
wxStaticBox (panel, wxID_ANY, _T ("Bus driver")), |
|
303 |
wxHORIZONTAL); |
|
304 |
mysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 5); |
|
305 |
load = new wxButton (panel, LOAD, _T ("Load can driver")); |
|
306 |
myhsizer->Add (load, 0, wxLEFT, 5); |
|
307 |
drivername = |
|
308 |
new wxTextCtrl (panel, wxID_ANY, |
|
309 |
wxString ((const char *) LibraryPath, wxConvLocal)); |
|
310 |
myhsizer->Add (drivername, 1, wxEXPAND | wxALL, 5); |
|
311 |
myentrysizer = new wxBoxSizer (wxHORIZONTAL); |
|
312 |
mysizer->Add (myentrysizer, 0, wxEXPAND | wxALL, 5); |
|
313 |
myhsizer = |
|
314 |
new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, _T ("Bus name")), |
|
315 |
wxHORIZONTAL); |
|
316 |
myentrysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 5); |
|
317 |
busname = |
|
318 |
new wxTextCtrl (panel, wxID_ANY, |
|
319 |
wxString ((const char *) SlaveBoard.busname, |
|
320 |
wxConvLocal)); |
|
321 |
myhsizer->Add (busname, 0, wxLEFT, 5); |
|
322 |
myhsizer = |
|
323 |
new wxStaticBoxSizer (new |
|
324 |
wxStaticBox (panel, wxID_ANY, |
|
385
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
325 |
_T ("Node ID (Decimal)")), wxHORIZONTAL); |
382 | 326 |
myentrysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 5); |
327 |
node_id = |
|
328 |
new wxSpinCtrl (panel, wxID_ANY, wxEmptyString, wxDefaultPosition, |
|
329 |
wxDefaultSize, wxSP_ARROW_KEYS, 1, 127, node_id_ext, |
|
330 |
_T ("wxSpinCtrl")); |
|
331 |
myhsizer->Add (node_id, 0, wxRIGHT, 5); |
|
332 |
myhsizer = |
|
333 |
new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, _T ("Baudrate")), |
|
334 |
wxHORIZONTAL); |
|
335 |
mysizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
|
336 |
freqlist = |
|
337 |
new wxListBox (panel, FREQBOX, wxDefaultPosition, wxDefaultSize, 8, |
|
338 |
choices, wxLB_SINGLE | wxLB_HSCROLL); |
|
339 |
myhsizer->Add (freqlist, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
|
340 |
quit = new wxButton (panel, QUIT, _T ("QUIT")); |
|
341 |
mysizer->Add (quit, 0, wxALL, 5); |
|
342 |
||
343 |
||
344 |
panel = new wxPanel (book); |
|
345 |
book->AddPage (panel, wxT ("Inputs"), true); |
|
346 |
mysizer = new wxBoxSizer (wxVERTICAL); |
|
347 |
panel->SetSizer (mysizer); |
|
348 |
myhsizer = |
|
349 |
new wxStaticBoxSizer (new |
|
350 |
wxStaticBox (panel, wxID_ANY, |
|
351 |
_T ("Read Inputs UNSIGNED8")), |
|
352 |
wxHORIZONTAL); |
|
353 |
mysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 30); |
|
354 |
inbt1 = new wxToggleButton (panel, INBT1, wxT ("1")); |
|
355 |
inbt2 = new wxToggleButton (panel, INBT2, wxT ("2")); |
|
356 |
inbt3 = new wxToggleButton (panel, INBT3, wxT ("3")); |
|
357 |
inbt4 = new wxToggleButton (panel, INBT4, wxT ("4")); |
|
358 |
inbt5 = new wxToggleButton (panel, INBT5, wxT ("5")); |
|
359 |
inbt6 = new wxToggleButton (panel, INBT6, wxT ("6")); |
|
360 |
inbt7 = new wxToggleButton (panel, INBT7, wxT ("7")); |
|
361 |
inbt8 = new wxToggleButton (panel, INBT8, wxT ("8")); |
|
362 |
myhsizer->Add (inbt1, wxEXPAND | wxALL, 0, 5); |
|
363 |
myhsizer->Add (inbt2, wxEXPAND | wxALL, 0, 5); |
|
364 |
myhsizer->Add (inbt3, wxEXPAND | wxALL, 0, 5); |
|
365 |
myhsizer->Add (inbt4, wxEXPAND | wxALL, 0, 5); |
|
366 |
myhsizer->Add (inbt5, wxEXPAND | wxALL, 0, 5); |
|
367 |
myhsizer->Add (inbt6, wxEXPAND | wxALL, 0, 5); |
|
368 |
myhsizer->Add (inbt7, wxEXPAND | wxALL, 0, 5); |
|
369 |
myhsizer->Add (inbt8, wxEXPAND | wxALL, 0, 5); |
|
370 |
myhsizer = |
|
371 |
new wxStaticBoxSizer (new |
|
372 |
wxStaticBox (panel, wxID_ANY, |
|
373 |
_T ("Analogue Inputs INTEGER16")), |
|
374 |
wxVERTICAL); |
|
375 |
mysizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 30); |
|
376 |
mysssizer = new wxBoxSizer (wxHORIZONTAL); |
|
377 |
myhsizer->Add (mysssizer, 0, wxEXPAND | wxALL, 0); |
|
378 |
inst1 = |
|
379 |
new wxSpinCtrl (panel, INST1, wxEmptyString, wxDefaultPosition, |
|
380 |
wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
|
381 |
_T ("0")); |
|
382 |
inst2 = |
|
383 |
new wxSpinCtrl (panel, INST2, wxEmptyString, wxDefaultPosition, |
|
384 |
wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
|
385 |
_T ("0")); |
|
386 |
inst3 = |
|
387 |
new wxSpinCtrl (panel, INST3, wxEmptyString, wxDefaultPosition, |
|
388 |
wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
|
389 |
_T ("0")); |
|
390 |
inst4 = |
|
391 |
new wxSpinCtrl (panel, INST4, wxEmptyString, wxDefaultPosition, |
|
392 |
wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
|
393 |
_T ("0")); |
|
394 |
inst5 = |
|
395 |
new wxSpinCtrl (panel, INST5, wxEmptyString, wxDefaultPosition, |
|
396 |
wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
|
397 |
_T ("0")); |
|
398 |
inst6 = |
|
399 |
new wxSpinCtrl (panel, INST6, wxEmptyString, wxDefaultPosition, |
|
400 |
wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
|
401 |
_T ("0")); |
|
402 |
inst7 = |
|
403 |
new wxSpinCtrl (panel, INST7, wxEmptyString, wxDefaultPosition, |
|
404 |
wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
|
405 |
_T ("0")); |
|
406 |
inst8 = |
|
407 |
new wxSpinCtrl (panel, INST8, wxEmptyString, wxDefaultPosition, |
|
408 |
wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
|
409 |
_T ("0")); |
|
410 |
mysssizer->Add (inst1, wxALL, 0, 5); |
|
411 |
mysssizer->Add (inst2, wxALL, 0, 5); |
|
412 |
mysssizer->Add (inst3, wxALL, 0, 5); |
|
413 |
mysssizer->Add (inst4, wxALL, 0, 5); |
|
414 |
mysssizer->Add (inst5, wxALL, 0, 5); |
|
415 |
mysssizer->Add (inst6, wxALL, 0, 5); |
|
416 |
mysssizer->Add (inst7, wxALL, 0, 5); |
|
417 |
mysssizer->Add (inst8, wxALL, 0, 5); |
|
418 |
mysssizer = new wxBoxSizer (wxHORIZONTAL); |
|
419 |
myhsizer->Add (mysssizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 0); |
|
420 |
ins1 = |
|
421 |
new wxSlider (panel, INS1, 0, -32768, 32767, wxDefaultPosition, |
|
422 |
wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
|
423 |
wxDefaultValidator, wxT ("slider")); |
|
424 |
ins2 = |
|
425 |
new wxSlider (panel, INS2, 0, -32768, 32767, wxDefaultPosition, |
|
426 |
wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
|
427 |
wxDefaultValidator, wxT ("slider")); |
|
428 |
ins3 = |
|
429 |
new wxSlider (panel, INS3, 0, -32768, 32767, wxDefaultPosition, |
|
430 |
wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
|
431 |
wxDefaultValidator, wxT ("slider")); |
|
432 |
ins4 = |
|
433 |
new wxSlider (panel, INS4, 0, -32768, 32767, wxDefaultPosition, |
|
434 |
wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
|
435 |
wxDefaultValidator, wxT ("slider")); |
|
436 |
ins5 = |
|
437 |
new wxSlider (panel, INS5, 0, -32768, 32767, wxDefaultPosition, |
|
438 |
wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
|
439 |
wxDefaultValidator, wxT ("slider")); |
|
440 |
ins6 = |
|
441 |
new wxSlider (panel, INS6, 0, -32768, 32767, wxDefaultPosition, |
|
442 |
wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
|
443 |
wxDefaultValidator, wxT ("slider")); |
|
444 |
ins7 = |
|
445 |
new wxSlider (panel, INS7, 0, -32768, 32767, wxDefaultPosition, |
|
446 |
wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
|
447 |
wxDefaultValidator, wxT ("slider")); |
|
448 |
ins8 = |
|
449 |
new wxSlider (panel, INS8, 0, -32768, 32767, wxDefaultPosition, |
|
450 |
wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
|
451 |
wxDefaultValidator, wxT ("slider")); |
|
452 |
mysssizer->Add (ins1, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
453 |
mysssizer->Add (ins2, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
454 |
mysssizer->Add (ins3, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
455 |
mysssizer->Add (ins4, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
456 |
mysssizer->Add (ins5, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
457 |
mysssizer->Add (ins6, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
458 |
mysssizer->Add (ins7, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
459 |
mysssizer->Add (ins8, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
460 |
quit = new wxButton (panel, QUIT, _T ("QUIT")); |
|
461 |
mysizer->Add (quit, 0, wxALL, 5); |
|
462 |
||
463 |
panel = new wxPanel (book); |
|
464 |
book->AddPage (panel, wxT ("Outputs"), true); |
|
465 |
mysizer = new wxBoxSizer (wxVERTICAL); |
|
466 |
panel->SetSizer (mysizer); |
|
467 |
myhsizer = |
|
468 |
new wxStaticBoxSizer (new |
|
469 |
wxStaticBox (panel, wxID_ANY, |
|
470 |
_T ("Write Outputs UNSIGNED8")), |
|
471 |
wxHORIZONTAL); |
|
472 |
mysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 30); |
|
473 |
outbt1 = new wxToggleButton (panel, wxID_ANY, wxT ("1")); |
|
474 |
outbt2 = new wxToggleButton (panel, wxID_ANY, wxT ("2")); |
|
475 |
outbt3 = new wxToggleButton (panel, wxID_ANY, wxT ("3")); |
|
476 |
outbt4 = new wxToggleButton (panel, wxID_ANY, wxT ("4")); |
|
477 |
outbt5 = new wxToggleButton (panel, wxID_ANY, wxT ("5")); |
|
478 |
outbt6 = new wxToggleButton (panel, wxID_ANY, wxT ("6")); |
|
479 |
outbt7 = new wxToggleButton (panel, wxID_ANY, wxT ("7")); |
|
480 |
outbt8 = new wxToggleButton (panel, wxID_ANY, wxT ("8")); |
|
481 |
myhsizer->Add (outbt1, wxEXPAND | wxALL, 0, 5); |
|
482 |
myhsizer->Add (outbt2, wxEXPAND | wxALL, 0, 5); |
|
483 |
myhsizer->Add (outbt3, wxEXPAND | wxALL, 0, 5); |
|
484 |
myhsizer->Add (outbt4, wxEXPAND | wxALL, 0, 5); |
|
485 |
myhsizer->Add (outbt5, wxEXPAND | wxALL, 0, 5); |
|
486 |
myhsizer->Add (outbt6, wxEXPAND | wxALL, 0, 5); |
|
487 |
myhsizer->Add (outbt7, wxEXPAND | wxALL, 0, 5); |
|
488 |
myhsizer->Add (outbt8, wxEXPAND | wxALL, 0, 5); |
|
489 |
myhsizer = |
|
490 |
new wxStaticBoxSizer (new |
|
491 |
wxStaticBox (panel, wxID_ANY, |
|
492 |
_T ("Analogue Output INTEGER16")), |
|
493 |
wxVERTICAL); |
|
494 |
mysizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 30); |
|
495 |
mysssizer = new wxBoxSizer (wxHORIZONTAL); |
|
496 |
myhsizer->Add (mysssizer, 0, wxEXPAND | wxALL, 0); |
|
497 |
outst1 = |
|
498 |
new wxStaticText (panel, wxID_ANY, wxT ("label"), wxDefaultPosition, |
|
499 |
wxDefaultSize, 0, wxT ("staticText")); |
|
500 |
outst2 = |
|
501 |
new wxStaticText (panel, wxID_ANY, wxT ("label"), wxDefaultPosition, |
|
502 |
wxDefaultSize, 0, wxT ("staticText")); |
|
503 |
outst3 = |
|
504 |
new wxStaticText (panel, wxID_ANY, wxT ("label"), wxDefaultPosition, |
|
505 |
wxDefaultSize, 0, wxT ("staticText")); |
|
506 |
outst4 = |
|
507 |
new wxStaticText (panel, wxID_ANY, wxT ("label"), wxDefaultPosition, |
|
508 |
wxDefaultSize, 0, wxT ("staticText")); |
|
509 |
mysssizer->Add (outst1, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
|
510 |
mysssizer->Add (outst2, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
|
511 |
mysssizer->Add (outst3, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
|
512 |
mysssizer->Add (outst4, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
|
513 |
mysssizer = new wxBoxSizer (wxHORIZONTAL); |
|
514 |
myhsizer->Add (mysssizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 0); |
|
515 |
outs1 = |
|
516 |
new wxGauge (panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, |
|
517 |
wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, |
|
518 |
wxT ("gauge")); |
|
519 |
outs2 = |
|
520 |
new wxGauge (panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, |
|
521 |
wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, |
|
522 |
wxT ("gauge")); |
|
523 |
outs3 = |
|
524 |
new wxGauge (panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, |
|
525 |
wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, |
|
526 |
wxT ("gauge")); |
|
527 |
outs4 = |
|
528 |
new wxGauge (panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, |
|
529 |
wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, |
|
530 |
wxT ("gauge")); |
|
531 |
mysssizer->Add (outs1, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
532 |
mysssizer->Add (outs2, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
533 |
mysssizer->Add (outs3, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
534 |
mysssizer->Add (outs4, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
535 |
quit = new wxButton (panel, QUIT, _T ("QUIT")); |
|
536 |
mysizer->Add (quit, 0, wxALL, 5); |
|
537 |
||
538 |
wxString |
|
539 |
choice[] = { |
|
540 |
_T ("Analogue Out 1"), _T ("Analogue Out 2"), |
|
541 |
_T ("Analogue Out 3"), _T ("Analogue Out 4"), |
|
542 |
_T ("Bool Out 1"), _T ("Bool Out 2"), |
|
543 |
_T ("Bool Out 3"), _T ("Bool Out 4"), |
|
544 |
_T ("Bool Out 5"), _T ("Bool Out 6"), |
|
545 |
_T ("Bool Out 7"), _T ("Bool Out 8"), |
|
546 |
_T ("Analogue Input 1"), _T ("Analogue Input 2"), |
|
547 |
_T ("Analogue Input 3"), _T ("Analogue Input 4"), |
|
548 |
_T ("Analogue Input 5"), _T ("Analogue Input 6"), |
|
549 |
_T ("Analogue Input 7"), _T ("Analogue Input 8"), |
|
550 |
_T ("Bool Input 1"), _T ("Bool Input 2"), |
|
551 |
_T ("Bool Input 3"), _T ("Bool Input 4"), |
|
552 |
_T ("Bool Input 5"), _T ("Bool Input 6"), |
|
553 |
_T ("Bool Input 7"), _T ("Bool Input 8"), |
|
554 |
}; |
|
555 |
||
556 |
panel = new wxPanel (book); |
|
557 |
book->InsertPage (0, panel, wxT ("Control"), true); |
|
558 |
mysizer = new wxBoxSizer (wxVERTICAL); |
|
559 |
panel->SetSizer (mysizer); |
|
560 |
myhsizer = new wxBoxSizer (wxHORIZONTAL); |
|
561 |
myhsizer = |
|
562 |
new wxStaticBoxSizer (new |
|
563 |
wxStaticBox (panel, wxID_ANY, |
|
564 |
_T ("Control your node")), |
|
565 |
wxHORIZONTAL); |
|
566 |
mysizer->Add (myhsizer, 0, wxALL, 5); |
|
567 |
start = new wxButton (panel, START, _T ("START")); |
|
568 |
stop = new wxButton (panel, STOP, _T ("STOP")); |
|
569 |
stop->Enable (false); |
|
570 |
myhsizer->Add (start, 0, wxRIGHT, 5); |
|
571 |
myhsizer->Add (stop, 0, wxLEFT, 5); |
|
572 |
myhsizer = |
|
573 |
new wxStaticBoxSizer (new |
|
574 |
wxStaticBox (panel, wxID_ANY, _T ("Operation log")), |
|
575 |
wxHORIZONTAL); |
|
576 |
mysizer->Add (myhsizer, wxALL, wxEXPAND | wxALL, 5); |
|
577 |
textLog = |
|
578 |
new wxTextCtrl (panel, TEXTBOX1, _T (""), wxDefaultPosition, |
|
579 |
wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, |
|
580 |
wxTextCtrlNameStr); |
|
581 |
myhsizer->Add (textLog, wxALL, wxEXPAND | wxALL, 5); |
|
582 |
quit = new wxButton (panel, QUIT, _T ("QUIT")); |
|
583 |
mysizer->Add (quit, 0, wxALL, 5); |
|
584 |
||
585 |
m_timer.Start (100); |
|
586 |
if (to_start) |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
587 |
{ |
382 | 588 |
Start (); |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
589 |
} |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
590 |
} |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
591 |
|
382 | 592 |
void |
593 |
MyFrame::OnQuit (wxCommandEvent & WXUNUSED (event)) |
|
594 |
{ |
|
595 |
Close (true); |
|
596 |
} |
|
597 |
||
598 |
void |
|
599 |
MyFrame::Start () |
|
600 |
{ |
|
601 |
if (main_can (SlaveBoard, LibraryPath)) |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
602 |
{ |
382 | 603 |
printf ("[KO]\n"); |
407
384c3cd7afa2
Fixed some win32 stdout related problems. May not worl wit visualstudio debug log anymore.
etisserant
parents:
385
diff
changeset
|
604 |
fflush(stdout); |
382 | 605 |
*textLog << |
606 |
wxT |
|
607 |
("----------------------------------------------------Initialization [KO]\n"); |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
608 |
} |
382 | 609 |
else |
610 |
{ |
|
611 |
printf ("[OK]\n"); |
|
407
384c3cd7afa2
Fixed some win32 stdout related problems. May not worl wit visualstudio debug log anymore.
etisserant
parents:
385
diff
changeset
|
612 |
fflush(stdout); |
382 | 613 |
*textLog << |
614 |
wxT |
|
615 |
("----------------------------------------------------Initialization [OK]\n"); |
|
616 |
stop->Enable (true); |
|
617 |
start->Enable (false); |
|
618 |
} |
|
619 |
} |
|
620 |
||
621 |
void |
|
622 |
MyFrame::OnStart (wxCommandEvent & WXUNUSED (event)) |
|
623 |
{ |
|
624 |
wxString s; |
|
385
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
625 |
|
382 | 626 |
node_id_ext = node_id->GetValue (); |
627 |
s = busname->GetValue (); |
|
628 |
strncpy (SlaveBoard.busname, s.mb_str (), MAXLENGTH_BUSNAME); |
|
629 |
*textLog << wxT ("-- Bus name: ------> ") << s << wxT ("\n"); |
|
630 |
*textLog << wxT ("-- Node ID: -------> ") << node_id-> |
|
631 |
GetValue () << wxT ("\n"); |
|
385
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
632 |
SetTitle(wxString::Format(wxT("CanOpen virtual DS-401 - Id : %d"),node_id-> |
fff25f16c923
Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes.
etisserant
parents:
382
diff
changeset
|
633 |
GetValue ())); |
382 | 634 |
Start (); |
635 |
} |
|
636 |
||
637 |
||
638 |
void |
|
639 |
MyFrame::OnStop (wxCommandEvent & WXUNUSED (event)) |
|
640 |
{ |
|
641 |
||
642 |
*textLog << |
|
643 |
wxT |
|
644 |
("----------------------------------------------------Slave [STOPPED]") << |
|
645 |
wxT ("\n"); |
|
646 |
stop_slave (); |
|
647 |
stop->Enable (false); |
|
648 |
start->Enable (true); |
|
649 |
} |
|
650 |
||
651 |
void |
|
652 |
MyFrame::OnLoad (wxCommandEvent & WXUNUSED (event)) |
|
653 |
{ |
|
654 |
wxFileDialog fd (this, wxT ("Choose a can driver library"), wxT (""), |
|
655 |
wxT (""), LIB_EXTENT); |
|
656 |
||
657 |
if (fd.ShowModal () == wxID_OK) |
|
658 |
{ |
|
659 |
drivername->Clear (); |
|
660 |
drivername->AppendText (fd.GetPath ()); |
|
661 |
*textLog << wxT ("LibraryPath: ") << fd.GetPath () << wxT ("\n"); |
|
662 |
strncpy (LibraryPath, fd.GetPath ().mb_str (), MAXLENGTH_LIBPATH); |
|
663 |
printf ("path=%s", LibraryPath); |
|
664 |
} |
|
665 |
} |
|
666 |
||
667 |
void |
|
668 |
MyFrame::OnInbt1 (wxCommandEvent & WXUNUSED (event)) |
|
669 |
{ |
|
670 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x1; |
|
671 |
} |
|
672 |
||
673 |
void |
|
674 |
MyFrame::OnInbt2 (wxCommandEvent & WXUNUSED (event)) |
|
675 |
{ |
|
676 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x2; |
|
677 |
} |
|
678 |
||
679 |
void |
|
680 |
MyFrame::OnInbt3 (wxCommandEvent & WXUNUSED (event)) |
|
681 |
{ |
|
682 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x4; |
|
683 |
} |
|
684 |
||
685 |
void |
|
686 |
MyFrame::OnInbt4 (wxCommandEvent & WXUNUSED (event)) |
|
687 |
{ |
|
688 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x8; |
|
689 |
} |
|
690 |
||
691 |
void |
|
692 |
MyFrame::OnInbt5 (wxCommandEvent & WXUNUSED (event)) |
|
693 |
{ |
|
694 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x10; |
|
695 |
} |
|
696 |
||
697 |
void |
|
698 |
MyFrame::OnInbt6 (wxCommandEvent & WXUNUSED (event)) |
|
699 |
{ |
|
700 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x20; |
|
701 |
} |
|
702 |
||
703 |
void |
|
704 |
MyFrame::OnInbt7 (wxCommandEvent & WXUNUSED (event)) |
|
705 |
{ |
|
706 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x40; |
|
707 |
} |
|
708 |
||
709 |
void |
|
710 |
MyFrame::OnInbt8 (wxCommandEvent & WXUNUSED (event)) |
|
711 |
{ |
|
712 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x80; |
|
713 |
} |
|
714 |
||
715 |
||
716 |
||
717 |
void |
|
718 |
MyFrame::OnIns1 (wxScrollEvent & event) |
|
719 |
{ |
|
720 |
Read_Analogue_Input_16_Bit[0] = ins1->GetValue (); |
|
721 |
inst1->SetValue (ins1->GetValue ()); |
|
722 |
} |
|
723 |
||
724 |
void |
|
725 |
MyFrame::OnIns2 (wxScrollEvent & event) |
|
726 |
{ |
|
727 |
Read_Analogue_Input_16_Bit[1] = ins2->GetValue (); |
|
728 |
inst2->SetValue (ins2->GetValue ()); |
|
729 |
} |
|
730 |
||
731 |
void |
|
732 |
MyFrame::OnIns3 (wxScrollEvent & event) |
|
733 |
{ |
|
734 |
Read_Analogue_Input_16_Bit[2] = ins3->GetValue (); |
|
735 |
inst3->SetValue (ins3->GetValue ()); |
|
736 |
} |
|
737 |
||
738 |
void |
|
739 |
MyFrame::OnIns4 (wxScrollEvent & event) |
|
740 |
{ |
|
741 |
Read_Analogue_Input_16_Bit[3] = ins4->GetValue (); |
|
742 |
inst4->SetValue (ins4->GetValue ()); |
|
743 |
} |
|
744 |
||
745 |
void |
|
746 |
MyFrame::OnIns5 (wxScrollEvent & event) |
|
747 |
{ |
|
748 |
Read_Analogue_Input_16_Bit[4] = ins5->GetValue (); |
|
749 |
inst5->SetValue (ins5->GetValue ()); |
|
750 |
} |
|
751 |
||
752 |
void |
|
753 |
MyFrame::OnIns6 (wxScrollEvent & event) |
|
754 |
{ |
|
755 |
Read_Analogue_Input_16_Bit[5] = ins6->GetValue (); |
|
756 |
inst6->SetValue (ins6->GetValue ()); |
|
757 |
} |
|
758 |
||
759 |
void |
|
760 |
MyFrame::OnIns7 (wxScrollEvent & event) |
|
761 |
{ |
|
762 |
Read_Analogue_Input_16_Bit[6] = ins7->GetValue (); |
|
763 |
inst7->SetValue (ins7->GetValue ()); |
|
764 |
} |
|
765 |
||
766 |
void |
|
767 |
MyFrame::OnIns8 (wxScrollEvent & event) |
|
768 |
{ |
|
769 |
Read_Analogue_Input_16_Bit[7] = ins8->GetValue (); |
|
770 |
inst8->SetValue (ins8->GetValue ()); |
|
771 |
} |
|
772 |
||
773 |
||
774 |
void |
|
775 |
MyFrame::OnInst1 (wxSpinEvent & ev) |
|
776 |
{ |
|
777 |
Read_Analogue_Input_16_Bit[0] = inst1->GetValue (); |
|
778 |
ins1->SetValue (inst1->GetValue ()); |
|
779 |
} |
|
780 |
||
781 |
void |
|
782 |
MyFrame::OnInst2 (wxSpinEvent & ev) |
|
783 |
{ |
|
784 |
Read_Analogue_Input_16_Bit[1] = inst2->GetValue (); |
|
785 |
ins2->SetValue (inst2->GetValue ()); |
|
786 |
} |
|
787 |
||
788 |
void |
|
789 |
MyFrame::OnInst3 (wxSpinEvent & ev) |
|
790 |
{ |
|
791 |
Read_Analogue_Input_16_Bit[2] = inst3->GetValue (); |
|
792 |
ins3->SetValue (inst3->GetValue ()); |
|
793 |
} |
|
794 |
||
795 |
void |
|
796 |
MyFrame::OnInst4 (wxSpinEvent & ev) |
|
797 |
{ |
|
798 |
Read_Analogue_Input_16_Bit[3] = inst4->GetValue (); |
|
799 |
ins4->SetValue (inst4->GetValue ()); |
|
800 |
} |
|
801 |
||
802 |
void |
|
803 |
MyFrame::OnInst5 (wxSpinEvent & ev) |
|
804 |
{ |
|
805 |
Read_Analogue_Input_16_Bit[4] = inst5->GetValue (); |
|
806 |
ins5->SetValue (inst5->GetValue ()); |
|
807 |
} |
|
808 |
||
809 |
void |
|
810 |
MyFrame::OnInst6 (wxSpinEvent & ev) |
|
811 |
{ |
|
812 |
Read_Analogue_Input_16_Bit[5] = inst6->GetValue (); |
|
813 |
ins6->SetValue (inst6->GetValue ()); |
|
814 |
} |
|
815 |
||
816 |
void |
|
817 |
MyFrame::OnInst7 (wxSpinEvent & ev) |
|
818 |
{ |
|
819 |
Read_Analogue_Input_16_Bit[6] = inst7->GetValue (); |
|
820 |
ins7->SetValue (inst7->GetValue ()); |
|
821 |
} |
|
822 |
||
823 |
void |
|
824 |
MyFrame::OnInst8 (wxSpinEvent & ev) |
|
825 |
{ |
|
826 |
Read_Analogue_Input_16_Bit[7] = inst8->GetValue (); |
|
827 |
ins8->SetValue (inst8->GetValue ()); |
|
828 |
} |
|
829 |
||
830 |
||
831 |
void |
|
832 |
MyFrame::OnAbout (wxCommandEvent & WXUNUSED (event)) |
|
833 |
{ |
|
834 |
wxString msg; |
|
835 |
msg.Printf (_T ("About.\n\n") |
|
836 |
_T |
|
837 |
("Input-Output simulation by GRANDEMANGE Nicolas for CanFestival!!")); |
|
838 |
||
839 |
wxMessageBox (msg, _T ("About !!!"), wxOK | wxICON_INFORMATION, this); |
|
840 |
} |
|
841 |
||
842 |
||
843 |
void |
|
844 |
MyFrame::OnFreqBoxClick (wxCommandEvent & event) |
|
845 |
{ |
|
846 |
wxString wxstr; |
|
847 |
||
848 |
wxstr = event.GetString (); |
|
849 |
strncpy (SlaveBoard.baudrate, wxstr.mb_str (), MAXLENGTH_BAUDRATE); |
|
850 |
*textLog << wxT ("Baudrate:") << event.GetString () << wxT ("\n"); |
|
851 |
} |
|
852 |
||
853 |
static int |
|
854 |
is_set (int i, wxListBox * inlist, wxArrayInt in) |
|
855 |
{ |
|
856 |
inlist->GetSelections (in); |
|
857 |
for (int j = 0; j < in.GetCount (); j++) |
|
858 |
{ |
|
859 |
if (i == (in[j] + 1)) |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
860 |
{ |
382 | 861 |
return (i); |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
862 |
} |
382 | 863 |
} |
864 |
return (0); |
|
865 |
} |
|
866 |
||
867 |
static int |
|
868 |
get_bit (UNS8 input, int bit) |
|
869 |
{ |
|
870 |
return input & (((UNS8) 1) << bit - 1) ? 1 : 0; |
|
871 |
} |
|
872 |
||
873 |
void |
|
874 |
actu_output (void) |
|
875 |
{ |
|
876 |
wxString tmp; |
|
877 |
||
878 |
frame->outbt1->SetValue (get_bit (Write_Outputs_8_Bit[0], 1)); |
|
879 |
frame->outbt2->SetValue (get_bit (Write_Outputs_8_Bit[0], 2)); |
|
880 |
frame->outbt3->SetValue (get_bit (Write_Outputs_8_Bit[0], 3)); |
|
881 |
frame->outbt4->SetValue (get_bit (Write_Outputs_8_Bit[0], 4)); |
|
882 |
frame->outbt5->SetValue (get_bit (Write_Outputs_8_Bit[0], 5)); |
|
883 |
frame->outbt6->SetValue (get_bit (Write_Outputs_8_Bit[0], 6)); |
|
884 |
frame->outbt7->SetValue (get_bit (Write_Outputs_8_Bit[0], 7)); |
|
885 |
frame->outbt8->SetValue (get_bit (Write_Outputs_8_Bit[0], 8)); |
|
886 |
||
887 |
frame->outs1->SetValue (Write_Analogue_Output_16_Bit[0] + 32768); |
|
888 |
frame->outs2->SetValue (Write_Analogue_Output_16_Bit[1] + 32768); |
|
889 |
frame->outs3->SetValue (Write_Analogue_Output_16_Bit[2] + 32768); |
|
890 |
frame->outs4->SetValue (Write_Analogue_Output_16_Bit[3] + 32768); |
|
891 |
tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[0]); |
|
892 |
frame->outst1->SetLabel (tmp); |
|
893 |
tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[1]); |
|
894 |
frame->outst2->SetLabel (tmp); |
|
895 |
tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[2]); |
|
896 |
frame->outst3->SetLabel (tmp); |
|
897 |
tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[3]); |
|
898 |
frame->outst4->SetLabel (tmp); |
|
899 |
} |
|
900 |
||
901 |
void |
|
902 |
actu (void) |
|
903 |
{ |
|
904 |
actu_output (); |
|
905 |
} |
|
906 |
||
907 |
void |
|
908 |
MyFrame::OnTimer (wxTimerEvent & event) |
|
909 |
{ |
|
910 |
actu (); // do whatever you want to do every second here |
|
911 |
} |
|
912 |
||
913 |
void |
|
914 |
MyFrame::OnPaint (wxPaintEvent & event) |
|
915 |
{ |
|
916 |
//Paint(); |
|
917 |
} |