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