author | greg |
Tue, 19 Feb 2008 14:53:59 +0100 | |
changeset 403 | 57d5da3b6228 |
parent 385 | fff25f16c923 |
child 407 | 384c3cd7afa2 |
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"); |
599 |
*textLog << |
|
600 |
wxT |
|
601 |
("----------------------------------------------------Initialization [KO]\n"); |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
602 |
} |
382 | 603 |
else |
604 |
{ |
|
605 |
printf ("[OK]\n"); |
|
606 |
*textLog << |
|
607 |
wxT |
|
608 |
("----------------------------------------------------Initialization [OK]\n"); |
|
609 |
stop->Enable (true); |
|
610 |
start->Enable (false); |
|
611 |
} |
|
612 |
} |
|
613 |
||
614 |
void |
|
615 |
MyFrame::OnStart (wxCommandEvent & WXUNUSED (event)) |
|
616 |
{ |
|
617 |
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
|
618 |
|
382 | 619 |
node_id_ext = node_id->GetValue (); |
620 |
s = busname->GetValue (); |
|
621 |
strncpy (SlaveBoard.busname, s.mb_str (), MAXLENGTH_BUSNAME); |
|
622 |
*textLog << wxT ("-- Bus name: ------> ") << s << wxT ("\n"); |
|
623 |
*textLog << wxT ("-- Node ID: -------> ") << node_id-> |
|
624 |
GetValue () << wxT ("\n"); |
|
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 |
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
|
626 |
GetValue ())); |
382 | 627 |
Start (); |
628 |
} |
|
629 |
||
630 |
||
631 |
void |
|
632 |
MyFrame::OnStop (wxCommandEvent & WXUNUSED (event)) |
|
633 |
{ |
|
634 |
||
635 |
*textLog << |
|
636 |
wxT |
|
637 |
("----------------------------------------------------Slave [STOPPED]") << |
|
638 |
wxT ("\n"); |
|
639 |
stop_slave (); |
|
640 |
stop->Enable (false); |
|
641 |
start->Enable (true); |
|
642 |
} |
|
643 |
||
644 |
void |
|
645 |
MyFrame::OnLoad (wxCommandEvent & WXUNUSED (event)) |
|
646 |
{ |
|
647 |
wxFileDialog fd (this, wxT ("Choose a can driver library"), wxT (""), |
|
648 |
wxT (""), LIB_EXTENT); |
|
649 |
||
650 |
if (fd.ShowModal () == wxID_OK) |
|
651 |
{ |
|
652 |
drivername->Clear (); |
|
653 |
drivername->AppendText (fd.GetPath ()); |
|
654 |
*textLog << wxT ("LibraryPath: ") << fd.GetPath () << wxT ("\n"); |
|
655 |
strncpy (LibraryPath, fd.GetPath ().mb_str (), MAXLENGTH_LIBPATH); |
|
656 |
printf ("path=%s", LibraryPath); |
|
657 |
} |
|
658 |
} |
|
659 |
||
660 |
void |
|
661 |
MyFrame::OnInbt1 (wxCommandEvent & WXUNUSED (event)) |
|
662 |
{ |
|
663 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x1; |
|
664 |
} |
|
665 |
||
666 |
void |
|
667 |
MyFrame::OnInbt2 (wxCommandEvent & WXUNUSED (event)) |
|
668 |
{ |
|
669 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x2; |
|
670 |
} |
|
671 |
||
672 |
void |
|
673 |
MyFrame::OnInbt3 (wxCommandEvent & WXUNUSED (event)) |
|
674 |
{ |
|
675 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x4; |
|
676 |
} |
|
677 |
||
678 |
void |
|
679 |
MyFrame::OnInbt4 (wxCommandEvent & WXUNUSED (event)) |
|
680 |
{ |
|
681 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x8; |
|
682 |
} |
|
683 |
||
684 |
void |
|
685 |
MyFrame::OnInbt5 (wxCommandEvent & WXUNUSED (event)) |
|
686 |
{ |
|
687 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x10; |
|
688 |
} |
|
689 |
||
690 |
void |
|
691 |
MyFrame::OnInbt6 (wxCommandEvent & WXUNUSED (event)) |
|
692 |
{ |
|
693 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x20; |
|
694 |
} |
|
695 |
||
696 |
void |
|
697 |
MyFrame::OnInbt7 (wxCommandEvent & WXUNUSED (event)) |
|
698 |
{ |
|
699 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x40; |
|
700 |
} |
|
701 |
||
702 |
void |
|
703 |
MyFrame::OnInbt8 (wxCommandEvent & WXUNUSED (event)) |
|
704 |
{ |
|
705 |
Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x80; |
|
706 |
} |
|
707 |
||
708 |
||
709 |
||
710 |
void |
|
711 |
MyFrame::OnIns1 (wxScrollEvent & event) |
|
712 |
{ |
|
713 |
Read_Analogue_Input_16_Bit[0] = ins1->GetValue (); |
|
714 |
inst1->SetValue (ins1->GetValue ()); |
|
715 |
} |
|
716 |
||
717 |
void |
|
718 |
MyFrame::OnIns2 (wxScrollEvent & event) |
|
719 |
{ |
|
720 |
Read_Analogue_Input_16_Bit[1] = ins2->GetValue (); |
|
721 |
inst2->SetValue (ins2->GetValue ()); |
|
722 |
} |
|
723 |
||
724 |
void |
|
725 |
MyFrame::OnIns3 (wxScrollEvent & event) |
|
726 |
{ |
|
727 |
Read_Analogue_Input_16_Bit[2] = ins3->GetValue (); |
|
728 |
inst3->SetValue (ins3->GetValue ()); |
|
729 |
} |
|
730 |
||
731 |
void |
|
732 |
MyFrame::OnIns4 (wxScrollEvent & event) |
|
733 |
{ |
|
734 |
Read_Analogue_Input_16_Bit[3] = ins4->GetValue (); |
|
735 |
inst4->SetValue (ins4->GetValue ()); |
|
736 |
} |
|
737 |
||
738 |
void |
|
739 |
MyFrame::OnIns5 (wxScrollEvent & event) |
|
740 |
{ |
|
741 |
Read_Analogue_Input_16_Bit[4] = ins5->GetValue (); |
|
742 |
inst5->SetValue (ins5->GetValue ()); |
|
743 |
} |
|
744 |
||
745 |
void |
|
746 |
MyFrame::OnIns6 (wxScrollEvent & event) |
|
747 |
{ |
|
748 |
Read_Analogue_Input_16_Bit[5] = ins6->GetValue (); |
|
749 |
inst6->SetValue (ins6->GetValue ()); |
|
750 |
} |
|
751 |
||
752 |
void |
|
753 |
MyFrame::OnIns7 (wxScrollEvent & event) |
|
754 |
{ |
|
755 |
Read_Analogue_Input_16_Bit[6] = ins7->GetValue (); |
|
756 |
inst7->SetValue (ins7->GetValue ()); |
|
757 |
} |
|
758 |
||
759 |
void |
|
760 |
MyFrame::OnIns8 (wxScrollEvent & event) |
|
761 |
{ |
|
762 |
Read_Analogue_Input_16_Bit[7] = ins8->GetValue (); |
|
763 |
inst8->SetValue (ins8->GetValue ()); |
|
764 |
} |
|
765 |
||
766 |
||
767 |
void |
|
768 |
MyFrame::OnInst1 (wxSpinEvent & ev) |
|
769 |
{ |
|
770 |
Read_Analogue_Input_16_Bit[0] = inst1->GetValue (); |
|
771 |
ins1->SetValue (inst1->GetValue ()); |
|
772 |
} |
|
773 |
||
774 |
void |
|
775 |
MyFrame::OnInst2 (wxSpinEvent & ev) |
|
776 |
{ |
|
777 |
Read_Analogue_Input_16_Bit[1] = inst2->GetValue (); |
|
778 |
ins2->SetValue (inst2->GetValue ()); |
|
779 |
} |
|
780 |
||
781 |
void |
|
782 |
MyFrame::OnInst3 (wxSpinEvent & ev) |
|
783 |
{ |
|
784 |
Read_Analogue_Input_16_Bit[2] = inst3->GetValue (); |
|
785 |
ins3->SetValue (inst3->GetValue ()); |
|
786 |
} |
|
787 |
||
788 |
void |
|
789 |
MyFrame::OnInst4 (wxSpinEvent & ev) |
|
790 |
{ |
|
791 |
Read_Analogue_Input_16_Bit[3] = inst4->GetValue (); |
|
792 |
ins4->SetValue (inst4->GetValue ()); |
|
793 |
} |
|
794 |
||
795 |
void |
|
796 |
MyFrame::OnInst5 (wxSpinEvent & ev) |
|
797 |
{ |
|
798 |
Read_Analogue_Input_16_Bit[4] = inst5->GetValue (); |
|
799 |
ins5->SetValue (inst5->GetValue ()); |
|
800 |
} |
|
801 |
||
802 |
void |
|
803 |
MyFrame::OnInst6 (wxSpinEvent & ev) |
|
804 |
{ |
|
805 |
Read_Analogue_Input_16_Bit[5] = inst6->GetValue (); |
|
806 |
ins6->SetValue (inst6->GetValue ()); |
|
807 |
} |
|
808 |
||
809 |
void |
|
810 |
MyFrame::OnInst7 (wxSpinEvent & ev) |
|
811 |
{ |
|
812 |
Read_Analogue_Input_16_Bit[6] = inst7->GetValue (); |
|
813 |
ins7->SetValue (inst7->GetValue ()); |
|
814 |
} |
|
815 |
||
816 |
void |
|
817 |
MyFrame::OnInst8 (wxSpinEvent & ev) |
|
818 |
{ |
|
819 |
Read_Analogue_Input_16_Bit[7] = inst8->GetValue (); |
|
820 |
ins8->SetValue (inst8->GetValue ()); |
|
821 |
} |
|
822 |
||
823 |
||
824 |
void |
|
825 |
MyFrame::OnAbout (wxCommandEvent & WXUNUSED (event)) |
|
826 |
{ |
|
827 |
wxString msg; |
|
828 |
msg.Printf (_T ("About.\n\n") |
|
829 |
_T |
|
830 |
("Input-Output simulation by GRANDEMANGE Nicolas for CanFestival!!")); |
|
831 |
||
832 |
wxMessageBox (msg, _T ("About !!!"), wxOK | wxICON_INFORMATION, this); |
|
833 |
} |
|
834 |
||
835 |
||
836 |
void |
|
837 |
MyFrame::OnFreqBoxClick (wxCommandEvent & event) |
|
838 |
{ |
|
839 |
wxString wxstr; |
|
840 |
||
841 |
wxstr = event.GetString (); |
|
842 |
strncpy (SlaveBoard.baudrate, wxstr.mb_str (), MAXLENGTH_BAUDRATE); |
|
843 |
*textLog << wxT ("Baudrate:") << event.GetString () << wxT ("\n"); |
|
844 |
} |
|
845 |
||
846 |
static int |
|
847 |
is_set (int i, wxListBox * inlist, wxArrayInt in) |
|
848 |
{ |
|
849 |
inlist->GetSelections (in); |
|
850 |
for (int j = 0; j < in.GetCount (); j++) |
|
851 |
{ |
|
852 |
if (i == (in[j] + 1)) |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
853 |
{ |
382 | 854 |
return (i); |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
855 |
} |
382 | 856 |
} |
857 |
return (0); |
|
858 |
} |
|
859 |
||
860 |
static int |
|
861 |
get_bit (UNS8 input, int bit) |
|
862 |
{ |
|
863 |
return input & (((UNS8) 1) << bit - 1) ? 1 : 0; |
|
864 |
} |
|
865 |
||
866 |
void |
|
867 |
actu_output (void) |
|
868 |
{ |
|
869 |
wxString tmp; |
|
870 |
||
871 |
frame->outbt1->SetValue (get_bit (Write_Outputs_8_Bit[0], 1)); |
|
872 |
frame->outbt2->SetValue (get_bit (Write_Outputs_8_Bit[0], 2)); |
|
873 |
frame->outbt3->SetValue (get_bit (Write_Outputs_8_Bit[0], 3)); |
|
874 |
frame->outbt4->SetValue (get_bit (Write_Outputs_8_Bit[0], 4)); |
|
875 |
frame->outbt5->SetValue (get_bit (Write_Outputs_8_Bit[0], 5)); |
|
876 |
frame->outbt6->SetValue (get_bit (Write_Outputs_8_Bit[0], 6)); |
|
877 |
frame->outbt7->SetValue (get_bit (Write_Outputs_8_Bit[0], 7)); |
|
878 |
frame->outbt8->SetValue (get_bit (Write_Outputs_8_Bit[0], 8)); |
|
879 |
||
880 |
frame->outs1->SetValue (Write_Analogue_Output_16_Bit[0] + 32768); |
|
881 |
frame->outs2->SetValue (Write_Analogue_Output_16_Bit[1] + 32768); |
|
882 |
frame->outs3->SetValue (Write_Analogue_Output_16_Bit[2] + 32768); |
|
883 |
frame->outs4->SetValue (Write_Analogue_Output_16_Bit[3] + 32768); |
|
884 |
tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[0]); |
|
885 |
frame->outst1->SetLabel (tmp); |
|
886 |
tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[1]); |
|
887 |
frame->outst2->SetLabel (tmp); |
|
888 |
tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[2]); |
|
889 |
frame->outst3->SetLabel (tmp); |
|
890 |
tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[3]); |
|
891 |
frame->outst4->SetLabel (tmp); |
|
892 |
} |
|
893 |
||
894 |
void |
|
895 |
actu (void) |
|
896 |
{ |
|
897 |
actu_output (); |
|
898 |
} |
|
899 |
||
900 |
void |
|
901 |
MyFrame::OnTimer (wxTimerEvent & event) |
|
902 |
{ |
|
903 |
actu (); // do whatever you want to do every second here |
|
904 |
} |
|
905 |
||
906 |
void |
|
907 |
MyFrame::OnPaint (wxPaintEvent & event) |
|
908 |
{ |
|
909 |
//Paint(); |
|
910 |
} |