100 const int INST6 = 136; |
103 const int INST6 = 136; |
101 const int INST7 = 137; |
104 const int INST7 = 137; |
102 const int INST8 = 138; |
105 const int INST8 = 138; |
103 |
106 |
104 // Attach the event handlers. Put this after MyFrame declaration. |
107 // Attach the event handlers. Put this after MyFrame declaration. |
105 BEGIN_EVENT_TABLE(MyFrame, wxFrame) |
108 BEGIN_EVENT_TABLE (MyFrame, wxFrame) |
106 EVT_BUTTON(STOP, MyFrame::OnStop) |
109 EVT_BUTTON (STOP, MyFrame::OnStop) |
107 EVT_BUTTON(LOAD, MyFrame::OnLoad) |
110 EVT_BUTTON (LOAD, MyFrame::OnLoad) |
108 EVT_BUTTON(START, MyFrame::OnStart) |
111 EVT_BUTTON (START, MyFrame::OnStart) |
109 EVT_TOGGLEBUTTON(INBT1, MyFrame::OnInbt1) |
112 EVT_TOGGLEBUTTON (INBT1, MyFrame::OnInbt1) |
110 EVT_TOGGLEBUTTON(INBT2, MyFrame::OnInbt2) |
113 EVT_TOGGLEBUTTON (INBT2, MyFrame::OnInbt2) |
111 EVT_TOGGLEBUTTON(INBT3, MyFrame::OnInbt3) |
114 EVT_TOGGLEBUTTON (INBT3, MyFrame::OnInbt3) |
112 EVT_TOGGLEBUTTON(INBT4, MyFrame::OnInbt4) |
115 EVT_TOGGLEBUTTON (INBT4, MyFrame::OnInbt4) |
113 EVT_TOGGLEBUTTON(INBT5, MyFrame::OnInbt5) |
116 EVT_TOGGLEBUTTON (INBT5, MyFrame::OnInbt5) |
114 EVT_TOGGLEBUTTON(INBT6, MyFrame::OnInbt6) |
117 EVT_TOGGLEBUTTON (INBT6, MyFrame::OnInbt6) |
115 EVT_TOGGLEBUTTON(INBT7, MyFrame::OnInbt7) |
118 EVT_TOGGLEBUTTON (INBT7, MyFrame::OnInbt7) |
116 EVT_TOGGLEBUTTON(INBT8, MyFrame::OnInbt8) |
119 EVT_TOGGLEBUTTON (INBT8, MyFrame::OnInbt8) |
117 EVT_COMMAND_SCROLL(INS1, MyFrame::OnIns1) |
120 EVT_COMMAND_SCROLL (INS1, MyFrame::OnIns1) |
118 EVT_COMMAND_SCROLL(INS2, MyFrame::OnIns2) |
121 EVT_COMMAND_SCROLL (INS2, MyFrame::OnIns2) |
119 EVT_COMMAND_SCROLL(INS3, MyFrame::OnIns3) |
122 EVT_COMMAND_SCROLL (INS3, MyFrame::OnIns3) |
120 EVT_COMMAND_SCROLL(INS4, MyFrame::OnIns4) |
123 EVT_COMMAND_SCROLL (INS4, MyFrame::OnIns4) |
121 EVT_COMMAND_SCROLL(INS5, MyFrame::OnIns5) |
124 EVT_COMMAND_SCROLL (INS5, MyFrame::OnIns5) |
122 EVT_COMMAND_SCROLL(INS6, MyFrame::OnIns6) |
125 EVT_COMMAND_SCROLL (INS6, MyFrame::OnIns6) |
123 EVT_COMMAND_SCROLL(INS7, MyFrame::OnIns7) |
126 EVT_COMMAND_SCROLL (INS7, MyFrame::OnIns7) |
124 EVT_COMMAND_SCROLL(INS8, MyFrame::OnIns8) |
127 EVT_COMMAND_SCROLL (INS8, MyFrame::OnIns8) |
125 EVT_SPINCTRL(INST1, MyFrame::OnInst1) |
128 EVT_SPINCTRL (INST1, MyFrame::OnInst1) |
126 EVT_SPINCTRL(INST2, MyFrame::OnInst2) |
129 EVT_SPINCTRL (INST2, MyFrame::OnInst2) |
127 EVT_SPINCTRL(INST3, MyFrame::OnInst3) |
130 EVT_SPINCTRL (INST3, MyFrame::OnInst3) |
128 EVT_SPINCTRL(INST4, MyFrame::OnInst4) |
131 EVT_SPINCTRL (INST4, MyFrame::OnInst4) |
129 EVT_SPINCTRL(INST5, MyFrame::OnInst5) |
132 EVT_SPINCTRL (INST5, MyFrame::OnInst5) |
130 EVT_SPINCTRL(INST6, MyFrame::OnInst6) |
133 EVT_SPINCTRL (INST6, MyFrame::OnInst6) |
131 EVT_SPINCTRL(INST7, MyFrame::OnInst7) |
134 EVT_SPINCTRL (INST7, MyFrame::OnInst7) |
132 EVT_SPINCTRL(INST8, MyFrame::OnInst8) |
135 EVT_SPINCTRL (INST8, MyFrame::OnInst8) |
133 |
136 EVT_LISTBOX (FREQBOX, MyFrame::OnFreqBoxClick) |
134 EVT_LISTBOX(FREQBOX, MyFrame::OnFreqBoxClick) |
137 EVT_MENU (FILE_QUIT, MyFrame::OnQuit) |
135 EVT_MENU(FILE_QUIT, MyFrame::OnQuit) |
138 EVT_BUTTON (QUIT, MyFrame::OnQuit) EVT_MENU (HELP_ABOUT, MyFrame::OnAbout) |
136 EVT_BUTTON(QUIT, MyFrame::OnQuit) |
139 //EVT_PAINT(MyFrame::OnPaint) |
137 EVT_MENU(HELP_ABOUT, MyFrame::OnAbout) |
140 EVT_TIMER (TIMER_ID, MyFrame::OnTimer) |
138 //EVT_PAINT(MyFrame::OnPaint) |
141 END_EVENT_TABLE ()IMPLEMENT_APP_NO_MAIN (MyApp); |
139 |
|
140 EVT_TIMER(TIMER_ID, MyFrame::OnTimer) |
|
141 END_EVENT_TABLE() |
|
142 |
|
143 IMPLEMENT_APP_NO_MAIN(MyApp); |
|
144 IMPLEMENT_WX_THEME_SUPPORT; |
142 IMPLEMENT_WX_THEME_SUPPORT; |
145 |
143 |
146 void help() |
144 void |
147 { |
145 help () |
148 printf("**************************************************************\n"); |
146 { |
149 printf("* DS-401 Slave GUI *\n"); |
147 printf ("**************************************************************\n"); |
150 printf("* *\n"); |
148 printf ("* DS-401 Slave GUI *\n"); |
151 printf("* Usage: *\n"); |
149 printf ("* *\n"); |
152 printf("* ./DS401_Slave_Gui [OPTIONS] *\n"); |
150 printf ("* Usage: *\n"); |
153 printf("* *\n"); |
151 printf ("* ./DS401_Slave_Gui [OPTIONS] *\n"); |
154 printf("* OPTIONS: *\n"); |
152 printf ("* *\n"); |
155 printf("* -l : Can library [\"libcanfestival_can_virtual.so\"] *\n"); |
153 printf ("* OPTIONS: *\n"); |
156 printf("* *\n"); |
154 printf |
157 printf("* Slave: *\n"); |
155 ("* -l : Can library [\"libcanfestival_can_virtual.so\"] *\n"); |
158 printf("* -i : Node id format [0x01 , 0x7F] *\n"); |
156 printf ("* *\n"); |
159 printf("* *\n"); |
157 printf ("* Slave: *\n"); |
160 printf("* CAN bus: *\n"); |
158 printf ("* -i : Node id format [0x01 , 0x7F] *\n"); |
161 printf("* -b : bus name [\"1\"] *\n"); |
159 printf ("* *\n"); |
162 printf("* -B : 1M,500K,250K,125K,100K,50K,20K,10K *\n"); |
160 printf ("* CAN bus: *\n"); |
163 printf("* *\n"); |
161 printf |
164 printf("**************************************************************\n"); |
162 ("* -b : bus name [\"1\"] *\n"); |
165 } |
163 printf ("* -B : 1M,500K,250K,125K,100K,50K,20K,10K *\n"); |
166 |
164 printf ("* *\n"); |
167 |
165 printf ("**************************************************************\n"); |
168 int main(int argc,char **argv) |
166 } |
|
167 |
|
168 |
|
169 int |
|
170 main (int argc, char **argv) |
169 { |
171 { |
170 |
172 |
171 int c; |
173 int c; |
172 extern char *optarg; |
174 extern char *optarg; |
173 char *snodeid; |
175 char *snodeid; |
174 while ((c = getopt(argc, argv, "-b:B:l:i:s")) != EOF) |
176 while ((c = getopt (argc, argv, "-b:B:l:i:s")) != EOF) |
175 { |
|
176 switch(c) |
|
177 { |
177 { |
178 case 'b' : |
178 switch (c) |
179 if (optarg[0] == 0) |
179 { |
180 { |
180 case 'b': |
181 help(); |
181 if (optarg[0] == 0) |
182 exit(1); |
182 { |
183 } |
183 help (); |
184 SlaveBoard.busname = optarg; |
184 exit (1); |
185 break; |
185 } |
186 case 'B' : |
186 SlaveBoard.busname = optarg; |
187 if (optarg[0] == 0) |
187 break; |
188 { |
188 case 'B': |
189 help(); |
189 if (optarg[0] == 0) |
190 exit(1); |
190 { |
191 } |
191 help (); |
192 SlaveBoard.baudrate = optarg; |
192 exit (1); |
193 break; |
193 } |
194 case 'l' : |
194 SlaveBoard.baudrate = optarg; |
195 if (optarg[0] == 0) |
195 break; |
196 { |
196 case 'l': |
197 help(); |
197 if (optarg[0] == 0) |
198 exit(1); |
198 { |
199 } |
199 help (); |
200 strncpy(LibraryPath, optarg, MAXLENGTH_LIBPATH); |
200 exit (1); |
201 break; |
201 } |
202 case 'i' : |
202 strncpy (LibraryPath, optarg, MAXLENGTH_LIBPATH); |
203 if (optarg[0] == 0) |
203 break; |
204 { |
204 case 'i': |
205 help(); |
205 if (optarg[0] == 0) |
206 exit(1); |
206 { |
207 } |
207 help (); |
208 snodeid = optarg; |
208 exit (1); |
209 sscanf(snodeid,"%x",&node_id_ext); |
209 } |
210 break; |
210 snodeid = optarg; |
211 case 's' : |
211 sscanf (snodeid, "%x", &node_id_ext); |
212 to_start = 1; |
212 break; |
213 break; |
213 case 's': |
214 default: |
214 to_start = 1; |
215 help(); |
215 break; |
216 exit(1); |
216 default: |
|
217 help (); |
|
218 exit (1); |
|
219 } |
217 } |
220 } |
218 } |
221 wxEntry (argc, argv); |
219 wxEntry(argc,argv); |
222 } |
220 } |
223 |
221 |
224 |
222 |
225 bool |
223 bool MyApp::OnInit() |
226 MyApp::OnInit () |
224 { |
227 { |
225 frame = new MyFrame( _T("I-O simulator")); |
228 frame = new MyFrame (_T ("I-O simulator")); |
226 frame->Show(true); |
229 frame->Show (true); |
227 return true; |
230 return true; |
228 } |
231 } |
229 |
232 |
230 MyFrame::MyFrame(const wxString& title) |
233 MyFrame::MyFrame (const wxString & title):wxFrame (NULL, wxID_ANY, title, wxDefaultPosition, wxSize (800, 740), |
231 : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 740), wxDEFAULT_FRAME_STYLE, wxT("frame")) |
234 wxDEFAULT_FRAME_STYLE, wxT ("frame")), m_timer (this, |
232 ,m_timer(this, TIMER_ID) |
235 TIMER_ID) |
233 { |
236 { |
234 wxMenu *fileMenu = new wxMenu; |
237 wxMenu * |
235 wxMenu *helpMenu = new wxMenu; |
238 fileMenu = new wxMenu; |
236 wxPanel *panel; |
239 wxMenu * |
237 wxButton *quit; |
240 helpMenu = new wxMenu; |
238 wxButton *load; |
241 wxPanel * |
239 wxBoxSizer *mysizer; |
242 panel; |
240 wxBoxSizer *mysssizer; |
243 wxButton * |
241 wxBoxSizer *myhsizer; |
244 quit; |
242 wxBoxSizer *mybsizer; |
245 wxButton * |
243 wxBoxSizer *myentrysizer; |
246 load; |
244 wxListBox *freqlist; |
247 wxBoxSizer * |
245 wxStaticBox *namebox; |
248 mysizer; |
246 wxStaticBox *freqbox; |
249 wxBoxSizer * |
|
250 mysssizer; |
|
251 wxBoxSizer * |
|
252 myhsizer; |
|
253 wxBoxSizer * |
|
254 mybsizer; |
|
255 wxBoxSizer * |
|
256 myentrysizer; |
|
257 wxListBox * |
|
258 freqlist; |
|
259 wxStaticBox * |
|
260 namebox; |
|
261 wxStaticBox * |
|
262 freqbox; |
247 |
263 |
248 // SetIcon(wxICON(monicone)); |
264 // SetIcon(wxICON(monicone)); |
249 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); |
265 SetBackgroundColour (wxSystemSettings::GetColour (wxSYS_COLOUR_BTNFACE)); |
250 helpMenu->Append(HELP_ABOUT, _T("&About...\tF1"), |
266 helpMenu->Append (HELP_ABOUT, _T ("&About...\tF1"), |
251 _T("Show about dialog")); |
267 _T ("Show about dialog")); |
252 fileMenu->Append(FILE_QUIT, _T("E&xit\tAlt-X"), |
268 fileMenu->Append (FILE_QUIT, _T ("E&xit\tAlt-X"), _T ("Quit this program")); |
253 _T("Quit this program")); |
269 wxMenuBar * |
254 wxMenuBar *menuBar = new wxMenuBar(); |
270 menuBar = new wxMenuBar (); |
255 menuBar->Append(fileMenu, _T("&File")); |
271 menuBar->Append (fileMenu, _T ("&File")); |
256 menuBar->Append(helpMenu, _T("&Help")); |
272 menuBar->Append (helpMenu, _T ("&Help")); |
257 SetMenuBar(menuBar); |
273 SetMenuBar (menuBar); |
258 CreateStatusBar(2); |
274 CreateStatusBar (2); |
259 SetStatusText(_T("Lolitech."), 0); |
275 SetStatusText (_T ("Lolitech."), 0); |
260 SetStatusText(_T("Welcome."), 1); |
276 SetStatusText (_T ("Welcome."), 1); |
261 |
277 |
262 book = new wxNotebook(this, BOOKCTRL); |
278 book = new wxNotebook (this, BOOKCTRL); |
263 |
279 |
264 panel = new wxPanel(book); |
280 panel = new wxPanel (book); |
265 book->AddPage(panel, _T("Configuration"), true); |
281 book->AddPage (panel, _T ("Configuration"), true); |
266 mysizer = new wxBoxSizer( wxVERTICAL ); |
282 mysizer = new wxBoxSizer (wxVERTICAL); |
267 panel->SetSizer(mysizer); |
283 panel->SetSizer (mysizer); |
268 wxString choices[] = |
284 wxString |
269 { |
285 choices[] = { |
270 _T("10K"), _T("20K"), _T("50K"), _T("100K"), |
286 _T ("10K"), _T ("20K"), _T ("50K"), _T ("100K"), |
271 _T("125K"), _T("250K"), _T("500K"), _T("1M") |
287 _T ("125K"), _T ("250K"), _T ("500K"), _T ("1M") |
272 }; |
288 }; |
273 |
289 |
274 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Bus driver")), wxHORIZONTAL ); |
290 myhsizer = |
275 mysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 5); |
291 new wxStaticBoxSizer (new |
276 load = new wxButton( panel, LOAD, _T("Load can driver")); |
292 wxStaticBox (panel, wxID_ANY, _T ("Bus driver")), |
277 myhsizer->Add(load, 0, wxLEFT, 5); |
293 wxHORIZONTAL); |
278 drivername = new wxTextCtrl(panel, wxID_ANY, wxString((const char*)LibraryPath,wxConvLocal)); |
294 mysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 5); |
279 myhsizer->Add(drivername, 1, wxEXPAND | wxALL, 5); |
295 load = new wxButton (panel, LOAD, _T ("Load can driver")); |
280 myentrysizer = new wxBoxSizer( wxHORIZONTAL ); |
296 myhsizer->Add (load, 0, wxLEFT, 5); |
281 mysizer->Add(myentrysizer, 0, wxEXPAND | wxALL, 5); |
297 drivername = |
282 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Bus name")), wxHORIZONTAL ); |
298 new wxTextCtrl (panel, wxID_ANY, |
283 myentrysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 5); |
299 wxString ((const char *) LibraryPath, wxConvLocal)); |
284 busname = new wxTextCtrl(panel, wxID_ANY, wxString((const char*)SlaveBoard.busname, wxConvLocal)); |
300 myhsizer->Add (drivername, 1, wxEXPAND | wxALL, 5); |
285 myhsizer->Add(busname, 0, wxLEFT, 5); |
301 myentrysizer = new wxBoxSizer (wxHORIZONTAL); |
286 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Node ID (Hexa)")), wxHORIZONTAL ); |
302 mysizer->Add (myentrysizer, 0, wxEXPAND | wxALL, 5); |
287 myentrysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 5); |
303 myhsizer = |
288 node_id = new wxSpinCtrl(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 127, node_id_ext, _T("wxSpinCtrl")); |
304 new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, _T ("Bus name")), |
289 myhsizer->Add(node_id, 0, wxRIGHT, 5); |
305 wxHORIZONTAL); |
290 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Baudrate")), wxHORIZONTAL ); |
306 myentrysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 5); |
291 mysizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
307 busname = |
292 freqlist = new wxListBox( panel, FREQBOX, wxDefaultPosition, wxDefaultSize, 8, choices, wxLB_SINGLE | wxLB_HSCROLL); |
308 new wxTextCtrl (panel, wxID_ANY, |
293 myhsizer->Add(freqlist, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
309 wxString ((const char *) SlaveBoard.busname, |
294 quit = new wxButton( panel, QUIT, _T("QUIT")); |
310 wxConvLocal)); |
295 mysizer->Add(quit, 0, wxALL, 5); |
311 myhsizer->Add (busname, 0, wxLEFT, 5); |
296 |
312 myhsizer = |
297 |
313 new wxStaticBoxSizer (new |
298 panel = new wxPanel(book); |
314 wxStaticBox (panel, wxID_ANY, |
299 book->AddPage(panel, wxT("Inputs"), true); |
315 _T ("Node ID (Hexa)")), wxHORIZONTAL); |
300 mysizer = new wxBoxSizer( wxVERTICAL ); |
316 myentrysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 5); |
301 panel->SetSizer(mysizer); |
317 node_id = |
302 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Read Inputs UNSIGNED8")), wxHORIZONTAL ); |
318 new wxSpinCtrl (panel, wxID_ANY, wxEmptyString, wxDefaultPosition, |
303 mysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 30); |
319 wxDefaultSize, wxSP_ARROW_KEYS, 1, 127, node_id_ext, |
304 inbt1 = new wxToggleButton(panel, INBT1, wxT("1")); |
320 _T ("wxSpinCtrl")); |
305 inbt2 = new wxToggleButton(panel, INBT2, wxT("2")); |
321 myhsizer->Add (node_id, 0, wxRIGHT, 5); |
306 inbt3 = new wxToggleButton(panel, INBT3, wxT("3")); |
322 myhsizer = |
307 inbt4 = new wxToggleButton(panel, INBT4, wxT("4")); |
323 new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, _T ("Baudrate")), |
308 inbt5 = new wxToggleButton(panel, INBT5, wxT("5")); |
324 wxHORIZONTAL); |
309 inbt6 = new wxToggleButton(panel, INBT6, wxT("6")); |
325 mysizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
310 inbt7 = new wxToggleButton(panel, INBT7, wxT("7")); |
326 freqlist = |
311 inbt8 = new wxToggleButton(panel, INBT8, wxT("8")); |
327 new wxListBox (panel, FREQBOX, wxDefaultPosition, wxDefaultSize, 8, |
312 myhsizer->Add(inbt1, wxEXPAND | wxALL, 0, 5); |
328 choices, wxLB_SINGLE | wxLB_HSCROLL); |
313 myhsizer->Add(inbt2, wxEXPAND | wxALL, 0, 5); |
329 myhsizer->Add (freqlist, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
314 myhsizer->Add(inbt3, wxEXPAND | wxALL, 0, 5); |
330 quit = new wxButton (panel, QUIT, _T ("QUIT")); |
315 myhsizer->Add(inbt4, wxEXPAND | wxALL, 0, 5); |
331 mysizer->Add (quit, 0, wxALL, 5); |
316 myhsizer->Add(inbt5, wxEXPAND | wxALL, 0, 5); |
332 |
317 myhsizer->Add(inbt6, wxEXPAND | wxALL, 0, 5); |
333 |
318 myhsizer->Add(inbt7, wxEXPAND | wxALL, 0, 5); |
334 panel = new wxPanel (book); |
319 myhsizer->Add(inbt8, wxEXPAND | wxALL, 0, 5); |
335 book->AddPage (panel, wxT ("Inputs"), true); |
320 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Analogue Inputs INTEGER16")), wxVERTICAL ); |
336 mysizer = new wxBoxSizer (wxVERTICAL); |
321 mysizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 30); |
337 panel->SetSizer (mysizer); |
322 mysssizer = new wxBoxSizer( wxHORIZONTAL ); |
338 myhsizer = |
323 myhsizer->Add(mysssizer, 0, wxEXPAND | wxALL, 0); |
339 new wxStaticBoxSizer (new |
324 inst1 = new wxSpinCtrl(panel, INST1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); |
340 wxStaticBox (panel, wxID_ANY, |
325 inst2 = new wxSpinCtrl(panel, INST2, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); |
341 _T ("Read Inputs UNSIGNED8")), |
326 inst3 = new wxSpinCtrl(panel, INST3, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); |
342 wxHORIZONTAL); |
327 inst4 = new wxSpinCtrl(panel, INST4, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); |
343 mysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 30); |
328 inst5 = new wxSpinCtrl(panel, INST5, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); |
344 inbt1 = new wxToggleButton (panel, INBT1, wxT ("1")); |
329 inst6 = new wxSpinCtrl(panel, INST6, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); |
345 inbt2 = new wxToggleButton (panel, INBT2, wxT ("2")); |
330 inst7 = new wxSpinCtrl(panel, INST7, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); |
346 inbt3 = new wxToggleButton (panel, INBT3, wxT ("3")); |
331 inst8 = new wxSpinCtrl(panel, INST8, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); |
347 inbt4 = new wxToggleButton (panel, INBT4, wxT ("4")); |
332 mysssizer->Add(inst1, wxALL, 0, 5); |
348 inbt5 = new wxToggleButton (panel, INBT5, wxT ("5")); |
333 mysssizer->Add(inst2, wxALL, 0, 5); |
349 inbt6 = new wxToggleButton (panel, INBT6, wxT ("6")); |
334 mysssizer->Add(inst3, wxALL, 0, 5); |
350 inbt7 = new wxToggleButton (panel, INBT7, wxT ("7")); |
335 mysssizer->Add(inst4, wxALL, 0, 5); |
351 inbt8 = new wxToggleButton (panel, INBT8, wxT ("8")); |
336 mysssizer->Add(inst5, wxALL, 0, 5); |
352 myhsizer->Add (inbt1, wxEXPAND | wxALL, 0, 5); |
337 mysssizer->Add(inst6, wxALL, 0, 5); |
353 myhsizer->Add (inbt2, wxEXPAND | wxALL, 0, 5); |
338 mysssizer->Add(inst7, wxALL, 0, 5); |
354 myhsizer->Add (inbt3, wxEXPAND | wxALL, 0, 5); |
339 mysssizer->Add(inst8, wxALL, 0, 5); |
355 myhsizer->Add (inbt4, wxEXPAND | wxALL, 0, 5); |
340 mysssizer = new wxBoxSizer( wxHORIZONTAL ); |
356 myhsizer->Add (inbt5, wxEXPAND | wxALL, 0, 5); |
341 myhsizer->Add(mysssizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 0); |
357 myhsizer->Add (inbt6, wxEXPAND | wxALL, 0, 5); |
342 ins1 = new wxSlider(panel, INS1, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); |
358 myhsizer->Add (inbt7, wxEXPAND | wxALL, 0, 5); |
343 ins2 = new wxSlider(panel, INS2, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); |
359 myhsizer->Add (inbt8, wxEXPAND | wxALL, 0, 5); |
344 ins3 = new wxSlider(panel, INS3, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); |
360 myhsizer = |
345 ins4 = new wxSlider(panel, INS4, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); |
361 new wxStaticBoxSizer (new |
346 ins5 = new wxSlider(panel, INS5, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); |
362 wxStaticBox (panel, wxID_ANY, |
347 ins6 = new wxSlider(panel, INS6, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); |
363 _T ("Analogue Inputs INTEGER16")), |
348 ins7 = new wxSlider(panel, INS7, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); |
364 wxVERTICAL); |
349 ins8 = new wxSlider(panel, INS8, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); |
365 mysizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 30); |
350 mysssizer->Add(ins1, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
366 mysssizer = new wxBoxSizer (wxHORIZONTAL); |
351 mysssizer->Add(ins2, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
367 myhsizer->Add (mysssizer, 0, wxEXPAND | wxALL, 0); |
352 mysssizer->Add(ins3, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
368 inst1 = |
353 mysssizer->Add(ins4, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
369 new wxSpinCtrl (panel, INST1, wxEmptyString, wxDefaultPosition, |
354 mysssizer->Add(ins5, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
370 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
355 mysssizer->Add(ins6, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
371 _T ("0")); |
356 mysssizer->Add(ins7, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
372 inst2 = |
357 mysssizer->Add(ins8, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
373 new wxSpinCtrl (panel, INST2, wxEmptyString, wxDefaultPosition, |
358 quit = new wxButton( panel, QUIT, _T("QUIT")); |
374 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
359 mysizer->Add(quit, 0, wxALL, 5); |
375 _T ("0")); |
360 |
376 inst3 = |
361 panel = new wxPanel(book); |
377 new wxSpinCtrl (panel, INST3, wxEmptyString, wxDefaultPosition, |
362 book->AddPage(panel, wxT("Outputs"), true); |
378 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
363 mysizer = new wxBoxSizer( wxVERTICAL ); |
379 _T ("0")); |
364 panel->SetSizer(mysizer); |
380 inst4 = |
365 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Write Outputs UNSIGNED8")), wxHORIZONTAL ); |
381 new wxSpinCtrl (panel, INST4, wxEmptyString, wxDefaultPosition, |
366 mysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 30); |
382 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
367 outbt1 = new wxToggleButton(panel, wxID_ANY, wxT("1")); |
383 _T ("0")); |
368 outbt2 = new wxToggleButton(panel, wxID_ANY, wxT("2")); |
384 inst5 = |
369 outbt3 = new wxToggleButton(panel, wxID_ANY, wxT("3")); |
385 new wxSpinCtrl (panel, INST5, wxEmptyString, wxDefaultPosition, |
370 outbt4 = new wxToggleButton(panel, wxID_ANY, wxT("4")); |
386 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
371 outbt5 = new wxToggleButton(panel, wxID_ANY, wxT("5")); |
387 _T ("0")); |
372 outbt6 = new wxToggleButton(panel, wxID_ANY, wxT("6")); |
388 inst6 = |
373 outbt7 = new wxToggleButton(panel, wxID_ANY, wxT("7")); |
389 new wxSpinCtrl (panel, INST6, wxEmptyString, wxDefaultPosition, |
374 outbt8 = new wxToggleButton(panel, wxID_ANY, wxT("8")); |
390 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
375 myhsizer->Add(outbt1, wxEXPAND | wxALL, 0, 5); |
391 _T ("0")); |
376 myhsizer->Add(outbt2, wxEXPAND | wxALL, 0, 5); |
392 inst7 = |
377 myhsizer->Add(outbt3, wxEXPAND | wxALL, 0, 5); |
393 new wxSpinCtrl (panel, INST7, wxEmptyString, wxDefaultPosition, |
378 myhsizer->Add(outbt4, wxEXPAND | wxALL, 0, 5); |
394 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
379 myhsizer->Add(outbt5, wxEXPAND | wxALL, 0, 5); |
395 _T ("0")); |
380 myhsizer->Add(outbt6, wxEXPAND | wxALL, 0, 5); |
396 inst8 = |
381 myhsizer->Add(outbt7, wxEXPAND | wxALL, 0, 5); |
397 new wxSpinCtrl (panel, INST8, wxEmptyString, wxDefaultPosition, |
382 myhsizer->Add(outbt8, wxEXPAND | wxALL, 0, 5); |
398 wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, |
383 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Analogue Output INTEGER16")), wxVERTICAL ); |
399 _T ("0")); |
384 mysizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 30); |
400 mysssizer->Add (inst1, wxALL, 0, 5); |
385 mysssizer = new wxBoxSizer( wxHORIZONTAL ); |
401 mysssizer->Add (inst2, wxALL, 0, 5); |
386 myhsizer->Add(mysssizer, 0, wxEXPAND | wxALL, 0); |
402 mysssizer->Add (inst3, wxALL, 0, 5); |
387 outst1 = new wxStaticText(panel, wxID_ANY, wxT("label"), wxDefaultPosition, wxDefaultSize, 0, wxT("staticText")); |
403 mysssizer->Add (inst4, wxALL, 0, 5); |
388 outst2 = new wxStaticText(panel, wxID_ANY, wxT("label"), wxDefaultPosition, wxDefaultSize, 0, wxT("staticText")); |
404 mysssizer->Add (inst5, wxALL, 0, 5); |
389 outst3 = new wxStaticText(panel, wxID_ANY, wxT("label"), wxDefaultPosition, wxDefaultSize, 0, wxT("staticText")); |
405 mysssizer->Add (inst6, wxALL, 0, 5); |
390 outst4 = new wxStaticText(panel, wxID_ANY, wxT("label"), wxDefaultPosition, wxDefaultSize, 0, wxT("staticText")); |
406 mysssizer->Add (inst7, wxALL, 0, 5); |
391 mysssizer->Add(outst1, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
407 mysssizer->Add (inst8, wxALL, 0, 5); |
392 mysssizer->Add(outst2, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
408 mysssizer = new wxBoxSizer (wxHORIZONTAL); |
393 mysssizer->Add(outst3, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
409 myhsizer->Add (mysssizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 0); |
394 mysssizer->Add(outst4, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
410 ins1 = |
395 mysssizer = new wxBoxSizer( wxHORIZONTAL ); |
411 new wxSlider (panel, INS1, 0, -32768, 32767, wxDefaultPosition, |
396 myhsizer->Add(mysssizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 0); |
412 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
397 outs1 = new wxGauge(panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("gauge")); |
413 wxDefaultValidator, wxT ("slider")); |
398 outs2 = new wxGauge(panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("gauge")); |
414 ins2 = |
399 outs3 = new wxGauge(panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("gauge")); |
415 new wxSlider (panel, INS2, 0, -32768, 32767, wxDefaultPosition, |
400 outs4 = new wxGauge(panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("gauge")); |
416 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
401 mysssizer->Add(outs1, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
417 wxDefaultValidator, wxT ("slider")); |
402 mysssizer->Add(outs2, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
418 ins3 = |
403 mysssizer->Add(outs3, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
419 new wxSlider (panel, INS3, 0, -32768, 32767, wxDefaultPosition, |
404 mysssizer->Add(outs4, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
420 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
405 quit = new wxButton( panel, QUIT, _T("QUIT")); |
421 wxDefaultValidator, wxT ("slider")); |
406 mysizer->Add(quit, 0, wxALL, 5); |
422 ins4 = |
407 |
423 new wxSlider (panel, INS4, 0, -32768, 32767, wxDefaultPosition, |
408 wxString choice[] = |
424 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
409 { |
425 wxDefaultValidator, wxT ("slider")); |
410 _T("Analogue Out 1"), _T("Analogue Out 2"), |
426 ins5 = |
411 _T("Analogue Out 3"), _T("Analogue Out 4"), |
427 new wxSlider (panel, INS5, 0, -32768, 32767, wxDefaultPosition, |
412 _T("Bool Out 1"), _T("Bool Out 2"), |
428 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
413 _T("Bool Out 3"), _T("Bool Out 4"), |
429 wxDefaultValidator, wxT ("slider")); |
414 _T("Bool Out 5"), _T("Bool Out 6"), |
430 ins6 = |
415 _T("Bool Out 7"), _T("Bool Out 8"), |
431 new wxSlider (panel, INS6, 0, -32768, 32767, wxDefaultPosition, |
416 _T("Analogue Input 1"), _T("Analogue Input 2"), |
432 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
417 _T("Analogue Input 3"), _T("Analogue Input 4"), |
433 wxDefaultValidator, wxT ("slider")); |
418 _T("Analogue Input 5"), _T("Analogue Input 6"), |
434 ins7 = |
419 _T("Analogue Input 7"), _T("Analogue Input 8"), |
435 new wxSlider (panel, INS7, 0, -32768, 32767, wxDefaultPosition, |
420 _T("Bool Input 1"), _T("Bool Input 2"), |
436 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
421 _T("Bool Input 3"), _T("Bool Input 4"), |
437 wxDefaultValidator, wxT ("slider")); |
422 _T("Bool Input 5"), _T("Bool Input 6"), |
438 ins8 = |
423 _T("Bool Input 7"), _T("Bool Input 8"), }; |
439 new wxSlider (panel, INS8, 0, -32768, 32767, wxDefaultPosition, |
424 panel = new wxPanel(book); |
440 wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, |
425 //book->AddPage(panel, wxT("Graphic"), true); |
441 wxDefaultValidator, wxT ("slider")); |
426 mysizer = new wxBoxSizer( wxVERTICAL ); |
442 mysssizer->Add (ins1, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
427 panel->SetSizer(mysizer); |
443 mysssizer->Add (ins2, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
428 panel->Hide(); |
444 mysssizer->Add (ins3, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
429 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Graphic")), wxVERTICAL ); |
445 mysssizer->Add (ins4, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
430 mysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 10); |
446 mysssizer->Add (ins5, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
431 mygraphpan = new wxPanel(panel, wxID_ANY, wxDefaultPosition, wxSize(0, 350), wxTAB_TRAVERSAL, wxT("Graphic")); |
447 mysssizer->Add (ins6, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
432 myhsizer->Add(mygraphpan, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
448 mysssizer->Add (ins7, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
433 echelle = new wxSlider(panel, wxID_ANY, 44, 44, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL , wxDefaultValidator, wxT("slider")); |
449 mysssizer->Add (ins8, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
434 myhsizer->Add(echelle, 0, wxEXPAND | wxALL, 0); |
450 quit = new wxButton (panel, QUIT, _T ("QUIT")); |
435 mybsizer = new wxBoxSizer( wxHORIZONTAL ); |
451 mysizer->Add (quit, 0, wxALL, 5); |
436 mysizer->Add(mybsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
452 |
437 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Select viewable Inputs")), wxHORIZONTAL ); |
453 panel = new wxPanel (book); |
438 mybsizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 10); |
454 book->AddPage (panel, wxT ("Outputs"), true); |
439 inlist = new wxListBox( panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 28, choice, wxLB_EXTENDED | wxLB_HSCROLL); |
455 mysizer = new wxBoxSizer (wxVERTICAL); |
440 myhsizer->Add(inlist, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
456 panel->SetSizer (mysizer); |
441 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Legende")), wxHORIZONTAL ); |
457 myhsizer = |
442 mybsizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 10); |
458 new wxStaticBoxSizer (new |
443 mylegpan = new wxPanel(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxT("Legende")); |
459 wxStaticBox (panel, wxID_ANY, |
444 myhsizer->Add(mylegpan, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
460 _T ("Write Outputs UNSIGNED8")), |
445 quit = new wxButton( panel, QUIT, _T("QUIT")); |
461 wxHORIZONTAL); |
446 mysizer->Add(quit, 0, wxALL, 5); |
462 mysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 30); |
447 |
463 outbt1 = new wxToggleButton (panel, wxID_ANY, wxT ("1")); |
448 panel = new wxPanel(book); |
464 outbt2 = new wxToggleButton (panel, wxID_ANY, wxT ("2")); |
449 book->InsertPage(0, panel, wxT("Control"), true); |
465 outbt3 = new wxToggleButton (panel, wxID_ANY, wxT ("3")); |
450 mysizer = new wxBoxSizer( wxVERTICAL ); |
466 outbt4 = new wxToggleButton (panel, wxID_ANY, wxT ("4")); |
451 panel->SetSizer(mysizer); |
467 outbt5 = new wxToggleButton (panel, wxID_ANY, wxT ("5")); |
452 myhsizer = new wxBoxSizer( wxHORIZONTAL ); |
468 outbt6 = new wxToggleButton (panel, wxID_ANY, wxT ("6")); |
453 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Control your node")), wxHORIZONTAL ); |
469 outbt7 = new wxToggleButton (panel, wxID_ANY, wxT ("7")); |
454 mysizer->Add(myhsizer, 0, wxALL, 5); |
470 outbt8 = new wxToggleButton (panel, wxID_ANY, wxT ("8")); |
455 start = new wxButton( panel, START, _T("START")); |
471 myhsizer->Add (outbt1, wxEXPAND | wxALL, 0, 5); |
456 stop = new wxButton( panel, STOP, _T("STOP")); |
472 myhsizer->Add (outbt2, wxEXPAND | wxALL, 0, 5); |
457 stop->Enable(false); |
473 myhsizer->Add (outbt3, wxEXPAND | wxALL, 0, 5); |
458 myhsizer->Add(start, 0, wxRIGHT, 5); |
474 myhsizer->Add (outbt4, wxEXPAND | wxALL, 0, 5); |
459 myhsizer->Add(stop, 0, wxLEFT, 5); |
475 myhsizer->Add (outbt5, wxEXPAND | wxALL, 0, 5); |
460 myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Operation log")), wxHORIZONTAL ); |
476 myhsizer->Add (outbt6, wxEXPAND | wxALL, 0, 5); |
461 mysizer->Add(myhsizer, wxALL, wxEXPAND | wxALL, 5); |
477 myhsizer->Add (outbt7, wxEXPAND | wxALL, 0, 5); |
462 textLog = new wxTextCtrl( panel, TEXTBOX1, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, wxTextCtrlNameStr); |
478 myhsizer->Add (outbt8, wxEXPAND | wxALL, 0, 5); |
463 myhsizer->Add(textLog, wxALL, wxEXPAND | wxALL, 5); |
479 myhsizer = |
464 quit = new wxButton( panel, QUIT, _T("QUIT")); |
480 new wxStaticBoxSizer (new |
465 mysizer->Add(quit, 0, wxALL, 5); |
481 wxStaticBox (panel, wxID_ANY, |
466 |
482 _T ("Analogue Output INTEGER16")), |
467 for (int i= 0; i < 28; i++) |
483 wxVERTICAL); |
468 for (int j = 0; j < 44; j++) |
484 mysizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 30); |
469 y[i][j] = 0; |
485 mysssizer = new wxBoxSizer (wxHORIZONTAL); |
470 m_timer.Start(100); |
486 myhsizer->Add (mysssizer, 0, wxEXPAND | wxALL, 0); |
471 if(to_start) |
487 outst1 = |
472 { |
488 new wxStaticText (panel, wxID_ANY, wxT ("label"), wxDefaultPosition, |
473 Start(); |
489 wxDefaultSize, 0, wxT ("staticText")); |
474 } |
490 outst2 = |
475 } |
491 new wxStaticText (panel, wxID_ANY, wxT ("label"), wxDefaultPosition, |
476 |
492 wxDefaultSize, 0, wxT ("staticText")); |
477 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) |
493 outst3 = |
478 { |
494 new wxStaticText (panel, wxID_ANY, wxT ("label"), wxDefaultPosition, |
479 Close(true); |
495 wxDefaultSize, 0, wxT ("staticText")); |
480 } |
496 outst4 = |
481 |
497 new wxStaticText (panel, wxID_ANY, wxT ("label"), wxDefaultPosition, |
482 void MyFrame::Start() |
498 wxDefaultSize, 0, wxT ("staticText")); |
483 { |
499 mysssizer->Add (outst1, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
484 if (main_can(SlaveBoard, LibraryPath)) |
500 mysssizer->Add (outst2, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
485 { |
501 mysssizer->Add (outst3, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
486 printf("[KO]\n"); |
502 mysssizer->Add (outst4, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
487 *textLog << wxT("----------------------------------------------------Initialization [KO]\n"); |
503 mysssizer = new wxBoxSizer (wxHORIZONTAL); |
488 } |
504 myhsizer->Add (mysssizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 0); |
489 else |
505 outs1 = |
490 { |
506 new wxGauge (panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, |
491 printf("[OK]\n"); |
507 wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, |
492 *textLog << wxT("----------------------------------------------------Initialization [OK]\n"); |
508 wxT ("gauge")); |
493 stop->Enable(true); |
509 outs2 = |
494 start->Enable(false); |
510 new wxGauge (panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, |
495 } |
511 wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, |
496 } |
512 wxT ("gauge")); |
497 |
513 outs3 = |
498 void MyFrame::OnStart(wxCommandEvent& WXUNUSED(event)) |
514 new wxGauge (panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, |
499 { |
515 wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, |
500 wxString s; |
516 wxT ("gauge")); |
501 |
517 outs4 = |
502 node_id_ext = node_id->GetValue(); |
518 new wxGauge (panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, |
503 s = busname->GetValue(); |
519 wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, |
504 strncpy(SlaveBoard.busname, s.mb_str(), MAXLENGTH_BUSNAME); |
520 wxT ("gauge")); |
505 *textLog << wxT("-- Bus name: ------> ") << s << wxT("\n"); |
521 mysssizer->Add (outs1, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
506 *textLog << wxT("-- Node ID: -------> ") << node_id->GetValue() << wxT("\n"); |
522 mysssizer->Add (outs2, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
507 Start(); |
523 mysssizer->Add (outs3, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
508 } |
524 mysssizer->Add (outs4, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
509 |
525 quit = new wxButton (panel, QUIT, _T ("QUIT")); |
510 |
526 mysizer->Add (quit, 0, wxALL, 5); |
511 void MyFrame::OnStop(wxCommandEvent& WXUNUSED(event)) |
527 |
512 { |
528 wxString |
513 |
529 choice[] = { |
514 *textLog << wxT("----------------------------------------------------Slave [STOPPED]") << wxT("\n"); |
530 _T ("Analogue Out 1"), _T ("Analogue Out 2"), |
515 stop_slave(); |
531 _T ("Analogue Out 3"), _T ("Analogue Out 4"), |
516 stop->Enable(false); |
532 _T ("Bool Out 1"), _T ("Bool Out 2"), |
517 start->Enable(true); |
533 _T ("Bool Out 3"), _T ("Bool Out 4"), |
518 } |
534 _T ("Bool Out 5"), _T ("Bool Out 6"), |
519 |
535 _T ("Bool Out 7"), _T ("Bool Out 8"), |
520 void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event)) |
536 _T ("Analogue Input 1"), _T ("Analogue Input 2"), |
521 { |
537 _T ("Analogue Input 3"), _T ("Analogue Input 4"), |
522 wxFileDialog fd(this, wxT("Choose a can driver library"), wxT(""), wxT(""), LIB_EXTENT); |
538 _T ("Analogue Input 5"), _T ("Analogue Input 6"), |
523 |
539 _T ("Analogue Input 7"), _T ("Analogue Input 8"), |
524 if(fd.ShowModal() == wxID_OK) |
540 _T ("Bool Input 1"), _T ("Bool Input 2"), |
|
541 _T ("Bool Input 3"), _T ("Bool Input 4"), |
|
542 _T ("Bool Input 5"), _T ("Bool Input 6"), |
|
543 _T ("Bool Input 7"), _T ("Bool Input 8"), |
|
544 }; |
|
545 panel = new wxPanel (book); |
|
546 book->AddPage(panel, wxT("Graphic"), true); |
|
547 mysizer = new wxBoxSizer (wxVERTICAL); |
|
548 panel->SetSizer (mysizer); |
|
549 //panel->Hide (); |
|
550 myhsizer = |
|
551 new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, _T ("Graphic")), |
|
552 wxVERTICAL); |
|
553 mysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 10); |
|
554 mygraphpan = |
|
555 new wxPanel (panel, wxID_ANY, wxDefaultPosition, wxSize (0, 350), |
|
556 wxTAB_TRAVERSAL, wxT ("Graphic")); |
|
557 myhsizer->Add (mygraphpan, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
558 echelle = |
|
559 new wxSlider (panel, wxID_ANY, 44, 44, 1000, wxDefaultPosition, |
|
560 wxDefaultSize, wxSL_HORIZONTAL, wxDefaultValidator, |
|
561 wxT ("slider")); |
|
562 myhsizer->Add (echelle, 0, wxEXPAND | wxALL, 0); |
|
563 mybsizer = new wxBoxSizer (wxHORIZONTAL); |
|
564 mysizer->Add (mybsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
|
565 myhsizer = |
|
566 new wxStaticBoxSizer (new |
|
567 wxStaticBox (panel, wxID_ANY, |
|
568 _T ("Select viewable Inputs")), |
|
569 wxHORIZONTAL); |
|
570 mybsizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 10); |
|
571 inlist = |
|
572 new wxListBox (panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 28, |
|
573 choice, wxLB_EXTENDED | wxLB_HSCROLL); |
|
574 myhsizer->Add (inlist, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); |
|
575 myhsizer = |
|
576 new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, _T ("Legende")), |
|
577 wxHORIZONTAL); |
|
578 mybsizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 10); |
|
579 mylegpan = |
|
580 new wxPanel (panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, |
|
581 wxTAB_TRAVERSAL, wxT ("Legende")); |
|
582 myhsizer->Add (mylegpan, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); |
|
583 quit = new wxButton (panel, QUIT, _T ("QUIT")); |
|
584 mysizer->Add (quit, 0, wxALL, 5); |
|
585 |
|
586 panel = new wxPanel (book); |
|
587 book->InsertPage (0, panel, wxT ("Control"), true); |
|
588 mysizer = new wxBoxSizer (wxVERTICAL); |
|
589 panel->SetSizer (mysizer); |
|
590 myhsizer = new wxBoxSizer (wxHORIZONTAL); |
|
591 myhsizer = |
|
592 new wxStaticBoxSizer (new |
|
593 wxStaticBox (panel, wxID_ANY, |
|
594 _T ("Control your node")), |
|
595 wxHORIZONTAL); |
|
596 mysizer->Add (myhsizer, 0, wxALL, 5); |
|
597 start = new wxButton (panel, START, _T ("START")); |
|
598 stop = new wxButton (panel, STOP, _T ("STOP")); |
|
599 stop->Enable (false); |
|
600 myhsizer->Add (start, 0, wxRIGHT, 5); |
|
601 myhsizer->Add (stop, 0, wxLEFT, 5); |
|
602 myhsizer = |
|
603 new wxStaticBoxSizer (new |
|
604 wxStaticBox (panel, wxID_ANY, _T ("Operation log")), |
|
605 wxHORIZONTAL); |
|
606 mysizer->Add (myhsizer, wxALL, wxEXPAND | wxALL, 5); |
|
607 textLog = |
|
608 new wxTextCtrl (panel, TEXTBOX1, _T (""), wxDefaultPosition, |
|
609 wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, |
|
610 wxTextCtrlNameStr); |
|
611 myhsizer->Add (textLog, wxALL, wxEXPAND | wxALL, 5); |
|
612 quit = new wxButton (panel, QUIT, _T ("QUIT")); |
|
613 mysizer->Add (quit, 0, wxALL, 5); |
|
614 |
|
615 for (int i = 0; i < 28; i++) |
|
616 for (int j = 0; j < 44; j++) |
|
617 y[i][j] = 0; |
|
618 m_timer.Start (100); |
|
619 if (to_start) |
525 { |
620 { |
526 drivername->Clear(); |
621 Start (); |
527 drivername->AppendText(fd.GetPath()); |
|
528 *textLog << wxT("LibraryPath: ") << fd.GetPath() << wxT("\n"); |
|
529 strncpy(LibraryPath, fd.GetPath().mb_str(), MAXLENGTH_LIBPATH); |
|
530 printf("path=%s",LibraryPath); |
|
531 } |
622 } |
532 } |
623 } |
533 |
624 |
534 void MyFrame::OnInbt1(wxCommandEvent& WXUNUSED(event)) |
625 void |
535 { |
626 MyFrame::OnQuit (wxCommandEvent & WXUNUSED (event)) |
536 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x1; |
627 { |
537 } |
628 Close (true); |
538 void MyFrame::OnInbt2(wxCommandEvent& WXUNUSED(event)) |
629 } |
539 { |
630 |
540 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x2; |
631 void |
541 } |
632 MyFrame::Start () |
542 void MyFrame::OnInbt3(wxCommandEvent& WXUNUSED(event)) |
633 { |
543 { |
634 if (main_can (SlaveBoard, LibraryPath)) |
544 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x4; |
|
545 } |
|
546 void MyFrame::OnInbt4(wxCommandEvent& WXUNUSED(event)) |
|
547 { |
|
548 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x8; |
|
549 } |
|
550 void MyFrame::OnInbt5(wxCommandEvent& WXUNUSED(event)) |
|
551 { |
|
552 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x10; |
|
553 } |
|
554 void MyFrame::OnInbt6(wxCommandEvent& WXUNUSED(event)) |
|
555 { |
|
556 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x20; |
|
557 } |
|
558 void MyFrame::OnInbt7(wxCommandEvent& WXUNUSED(event)) |
|
559 { |
|
560 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x40; |
|
561 } |
|
562 void MyFrame::OnInbt8(wxCommandEvent& WXUNUSED(event)) |
|
563 { |
|
564 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x80; |
|
565 } |
|
566 |
|
567 |
|
568 |
|
569 void MyFrame::OnIns1(wxScrollEvent &event) |
|
570 { |
|
571 Read_Analogue_Input_16_Bit[0] = ins1->GetValue(); |
|
572 inst1->SetValue(ins1->GetValue()); |
|
573 } |
|
574 void MyFrame::OnIns2(wxScrollEvent &event) |
|
575 { |
|
576 Read_Analogue_Input_16_Bit[1] = ins2->GetValue(); |
|
577 inst2->SetValue(ins2->GetValue()); |
|
578 } |
|
579 void MyFrame::OnIns3(wxScrollEvent &event) |
|
580 { |
|
581 Read_Analogue_Input_16_Bit[2] = ins3->GetValue(); |
|
582 inst3->SetValue(ins3->GetValue()); |
|
583 } |
|
584 void MyFrame::OnIns4(wxScrollEvent &event) |
|
585 { |
|
586 Read_Analogue_Input_16_Bit[3] = ins4->GetValue(); |
|
587 inst4->SetValue(ins4->GetValue()); |
|
588 } |
|
589 void MyFrame::OnIns5(wxScrollEvent &event) |
|
590 { |
|
591 Read_Analogue_Input_16_Bit[4] = ins5->GetValue(); |
|
592 inst5->SetValue(ins5->GetValue()); |
|
593 } |
|
594 void MyFrame::OnIns6(wxScrollEvent &event) |
|
595 { |
|
596 Read_Analogue_Input_16_Bit[5] = ins6->GetValue(); |
|
597 inst6->SetValue(ins6->GetValue()); |
|
598 } |
|
599 void MyFrame::OnIns7(wxScrollEvent &event) |
|
600 { |
|
601 Read_Analogue_Input_16_Bit[6] = ins7->GetValue(); |
|
602 inst7->SetValue(ins7->GetValue()); |
|
603 } |
|
604 void MyFrame::OnIns8(wxScrollEvent &event) |
|
605 { |
|
606 Read_Analogue_Input_16_Bit[7] = ins8->GetValue(); |
|
607 inst8->SetValue(ins8->GetValue()); |
|
608 } |
|
609 |
|
610 |
|
611 void MyFrame::OnInst1 ( wxSpinEvent &ev ) |
|
612 { |
|
613 Read_Analogue_Input_16_Bit[0] = inst1->GetValue(); |
|
614 ins1->SetValue(inst1->GetValue()); |
|
615 } |
|
616 void MyFrame::OnInst2 ( wxSpinEvent &ev ) |
|
617 { |
|
618 Read_Analogue_Input_16_Bit[1] = inst2->GetValue(); |
|
619 ins2->SetValue(inst2->GetValue()); |
|
620 } |
|
621 void MyFrame::OnInst3 ( wxSpinEvent &ev ) |
|
622 { |
|
623 Read_Analogue_Input_16_Bit[2] = inst3->GetValue(); |
|
624 ins3->SetValue(inst3->GetValue()); |
|
625 } |
|
626 void MyFrame::OnInst4 ( wxSpinEvent &ev ) |
|
627 { |
|
628 Read_Analogue_Input_16_Bit[3] = inst4->GetValue(); |
|
629 ins4->SetValue(inst4->GetValue()); |
|
630 } |
|
631 void MyFrame::OnInst5 ( wxSpinEvent &ev ) |
|
632 { |
|
633 Read_Analogue_Input_16_Bit[4] = inst5->GetValue(); |
|
634 ins5->SetValue(inst5->GetValue()); |
|
635 } |
|
636 void MyFrame::OnInst6 ( wxSpinEvent &ev ) |
|
637 { |
|
638 Read_Analogue_Input_16_Bit[5] = inst6->GetValue(); |
|
639 ins6->SetValue(inst6->GetValue()); |
|
640 } |
|
641 void MyFrame::OnInst7 ( wxSpinEvent &ev ) |
|
642 { |
|
643 Read_Analogue_Input_16_Bit[6] = inst7->GetValue(); |
|
644 ins7->SetValue(inst7->GetValue()); |
|
645 } |
|
646 void MyFrame::OnInst8 ( wxSpinEvent &ev ) |
|
647 { |
|
648 Read_Analogue_Input_16_Bit[7] = inst8->GetValue(); |
|
649 ins8->SetValue(inst8->GetValue()); |
|
650 } |
|
651 |
|
652 |
|
653 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) |
|
654 { |
|
655 wxString msg; |
|
656 msg.Printf( _T("About.\n\n") |
|
657 _T("Input-Output simulation by GRANDEMANGE Nicolas for CanFestival!!")); |
|
658 |
|
659 wxMessageBox(msg, _T("About !!!"), wxOK | wxICON_INFORMATION, this); |
|
660 } |
|
661 |
|
662 |
|
663 void MyFrame::OnFreqBoxClick( wxCommandEvent &event ) |
|
664 { |
|
665 wxString wxstr; |
|
666 |
|
667 wxstr = event.GetString(); |
|
668 strncpy(SlaveBoard.baudrate, wxstr.mb_str(),MAXLENGTH_BAUDRATE); |
|
669 *textLog << wxT("Baudrate:") << event.GetString() << wxT("\n"); |
|
670 } |
|
671 |
|
672 static int is_set(int i, |
|
673 wxListBox *inlist, |
|
674 wxArrayInt in) |
|
675 { |
|
676 inlist->GetSelections(in); |
|
677 for (int j = 0; j < in.GetCount(); j++) |
|
678 { |
|
679 if (i == (in[j] + 1)) |
|
680 { |
|
681 return (i); |
|
682 } |
|
683 } |
|
684 return (0); |
|
685 } |
|
686 |
|
687 static int get_bit(UNS8 input, int bit) |
|
688 { |
|
689 return input & (((UNS8)1) << bit-1) ? 1 : 0; |
|
690 } |
|
691 |
|
692 void MyFrame::Paint() |
|
693 { |
|
694 double vmax = old_max; |
|
695 double vmin = old_min; |
|
696 double vdelta = vmax - vmin; |
|
697 double vech = ((float)vdelta) / 10.0; |
|
698 |
|
699 double hmax = frame->echelle->GetValue(); |
|
700 double hech = hdelta / 11; |
|
701 |
|
702 double d = 300 / vdelta; |
|
703 double g = 0; |
|
704 double top = 5; |
|
705 double left = 50; |
|
706 |
|
707 double tmpi = 0; |
|
708 wxString tmps; |
|
709 double p = 0; |
|
710 double q = 0; |
|
711 int i = 0; |
|
712 int j = 0; |
|
713 wxColor col[8] = {wxColor(wxT("BLUE")), wxColor(wxT("RED")), wxColor(wxT("GREEN")), wxColor(wxT("GREY")), |
|
714 wxColor(wxT("ORANGE")), wxColor(wxT("YELLOW")), wxColor(wxT("PINK")), wxColor(wxT("BLACK"))}; |
|
715 hdelta = hmax - 0; |
|
716 g = (Gtime / hdelta) * 44.00; |
|
717 |
|
718 wxClientDC MonDc(mygraphpan); |
|
719 MonDc.Clear(); |
|
720 |
|
721 MonDc.SetPen(wxPen(wxColour(200,200,200), 5, wxSOLID)); |
|
722 MonDc.DrawRectangle((int) left, (int)top, 660, 300); |
|
723 |
|
724 MonDc.SetPen(wxPen(wxColor(150,200,150), 2, wxSOLID)); |
|
725 MonDc.SetFont(wxFont(9, wxSWISS , wxNORMAL, wxNORMAL, false, wxT("Arial Black"))); |
|
726 for (i=0; i < 11; i++) |
|
727 { |
|
728 tmpi = (vmin + (vech * i)); |
|
729 tmps.Printf(wxT("%d"), (int)tmpi); |
|
730 MonDc.DrawRotatedText(tmps, 0, (int)(293 - (30 * i) + top), 0); |
|
731 } |
|
732 for (i=0; i < 12; i++) |
|
733 { |
|
734 tmpi = (hech * i * 100); |
|
735 if (tmpi < 1000) |
|
736 tmps.Printf(wxT("%ims"), (int)tmpi); |
|
737 if (tmpi > 1000) |
|
738 tmps.Printf(wxT("%is"), (int)(tmpi / 1000)); |
|
739 MonDc.DrawRotatedText(tmps, (int)((60 * i) + left) - 10, (int)(317 + top), 0); |
|
740 } |
|
741 for (j=1; j < 10; j++) |
|
742 MonDc.DrawLine((int)left, (int)(300 - (30 * j) + top), (int)(left + 660), (int)(300 - (30 * j) + top)); |
|
743 MonDc.SetPen(wxPen(wxColor(150,200,150), 2, wxSOLID)); |
|
744 for (j=1; j < 22; j++) |
|
745 MonDc.DrawLine((int)(30 * j + left), (int)(300 + top), (int)(30 * j + left), (int)(top)); |
|
746 MonDc.SetPen(wxPen(wxColor(150,170,150), 1, wxSOLID)); |
|
747 for (j=1; j < 22; j++) |
|
748 MonDc.DrawLine((int)(30 * j + left - 15), (int)(300 + top), (int)(30 * j + left - 15), (int)(top)); |
|
749 MonDc.DrawLine((int)(30 * 22 + left - 15), (int)(300 + top), (int)(30 * 22 + left - 15), (int)(top)); |
|
750 |
|
751 double m = (- vmin) * d; |
|
752 MonDc.SetPen(wxPen(wxColor(170,170,150), 3, wxSOLID)); |
|
753 MonDc.DrawLine((int)(left), (int)(300 + top - m), (int)(left + 660), (int)(300 + top - m)); |
|
754 |
|
755 wxClientDC MaLeg(mylegpan); |
|
756 MaLeg.Clear(); |
|
757 |
|
758 MaLeg.SetPen(wxPen(wxColour(150,200,100), 2, wxSOLID)); |
|
759 MaLeg.SetFont(wxFont(7, wxSWISS , wxNORMAL, wxNORMAL, false, wxT("Arial Black"))); |
|
760 for (int k=1, tmpi = 0; k < 30; k++) |
|
761 { |
635 { |
762 if ((tmpi < 8) && is_set(k, inlist, in)) |
636 printf ("[KO]\n"); |
763 { |
637 *textLog << |
764 if (k <= 4) |
638 wxT |
765 tmps.Printf(wxT("Analogue Output %d"), k); |
639 ("----------------------------------------------------Initialization [KO]\n"); |
766 if ((k > 4) && (k <= 12)) |
|
767 tmps.Printf(wxT("Bool Output %d"), k - 4); |
|
768 if ((k > 12) && (k <= 20)) |
|
769 tmps.Printf(wxT("Analogue Input %d"), k - 12); |
|
770 if ((k > 20) && (k <= 28)) |
|
771 tmps.Printf(wxT("Bool Input %d"), k - 20); |
|
772 |
|
773 MaLeg.DrawRotatedText(tmps, 0, 10 * tmpi , 0); |
|
774 MaLeg.SetPen(wxPen(col[tmpi], 4, wxSOLID)); |
|
775 MaLeg.DrawLine(100, 10 * tmpi + 6, 115, 10 * tmpi + 6); |
|
776 //////////////////////////////////////////DAW//////////////////////////////////////// |
|
777 MonDc.SetPen(wxPen(col[tmpi], 4, wxSOLID)); |
|
778 if (k <= 4) |
|
779 y[k - 1][(int)g] = Write_Analogue_Output_16_Bit[k - 1]; |
|
780 if ((k > 4) && (k <= 12)) |
|
781 y[k - 1][(int)g] = get_bit(Write_Outputs_8_Bit[0] ,k - 4); |
|
782 if ((k > 12) && (k <= 20)) |
|
783 y[k - 1][(int)g] = Read_Analogue_Input_16_Bit[k - 1 -12]; |
|
784 if ((k > 20) && (k <= 28)) |
|
785 y[k - 1][(int)g] = get_bit(Read_Inputs_8_Bit[0] ,k - 20); |
|
786 |
|
787 if (y[k - 1][(int)g] > old_max) |
|
788 old_max = y[k - 1][(int)g]; |
|
789 if (y[k - 1][(int)g] < old_min) |
|
790 old_min = y[k - 1][(int)g]; |
|
791 for (j=1; j < (g + 1) ; j++) |
|
792 { |
|
793 p = (y[k - 1][j - 1] - vmin) * d; |
|
794 q = (y[k - 1][j ] - vmin) * d; |
|
795 MonDc.DrawLine((int)(15 * (j - 1) + left), (int)(300 + top - p), (int)(15 * j + left), (int)(300 + top - q)); |
|
796 } |
|
797 ///////////////////////////////////////////////////////////////////////////////////// |
|
798 tmpi++; |
|
799 } |
|
800 } |
640 } |
801 } |
641 else |
802 |
642 { |
803 void actu_output(void) |
643 printf ("[OK]\n"); |
804 { |
644 *textLog << |
805 wxString tmp; |
645 wxT |
806 |
646 ("----------------------------------------------------Initialization [OK]\n"); |
807 frame->outbt1->SetValue(get_bit(Write_Outputs_8_Bit[0], 1)); |
647 stop->Enable (true); |
808 frame->outbt2->SetValue(get_bit(Write_Outputs_8_Bit[0], 2)); |
648 start->Enable (false); |
809 frame->outbt3->SetValue(get_bit(Write_Outputs_8_Bit[0], 3)); |
649 } |
810 frame->outbt4->SetValue(get_bit(Write_Outputs_8_Bit[0], 4)); |
650 } |
811 frame->outbt5->SetValue(get_bit(Write_Outputs_8_Bit[0], 5)); |
651 |
812 frame->outbt6->SetValue(get_bit(Write_Outputs_8_Bit[0], 6)); |
652 void |
813 frame->outbt7->SetValue(get_bit(Write_Outputs_8_Bit[0], 7)); |
653 MyFrame::OnStart (wxCommandEvent & WXUNUSED (event)) |
814 frame->outbt8->SetValue(get_bit(Write_Outputs_8_Bit[0], 8)); |
654 { |
815 |
655 wxString s; |
816 frame->outs1->SetValue(Write_Analogue_Output_16_Bit[0] + 32768); |
656 |
817 frame->outs2->SetValue(Write_Analogue_Output_16_Bit[1] + 32768); |
657 node_id_ext = node_id->GetValue (); |
818 frame->outs3->SetValue(Write_Analogue_Output_16_Bit[2] + 32768); |
658 s = busname->GetValue (); |
819 frame->outs4->SetValue(Write_Analogue_Output_16_Bit[3] + 32768); |
659 strncpy (SlaveBoard.busname, s.mb_str (), MAXLENGTH_BUSNAME); |
820 tmp.Printf(wxT(" %i"), Write_Analogue_Output_16_Bit[0]); |
660 *textLog << wxT ("-- Bus name: ------> ") << s << wxT ("\n"); |
821 frame->outst1->SetLabel(tmp); |
661 *textLog << wxT ("-- Node ID: -------> ") << node_id-> |
822 tmp.Printf(wxT(" %i"), Write_Analogue_Output_16_Bit[1]); |
662 GetValue () << wxT ("\n"); |
823 frame->outst2->SetLabel(tmp); |
663 Start (); |
824 tmp.Printf(wxT(" %i"), Write_Analogue_Output_16_Bit[2]); |
664 } |
825 frame->outst3->SetLabel(tmp); |
665 |
826 tmp.Printf(wxT(" %i"), Write_Analogue_Output_16_Bit[3]); |
666 |
827 frame->outst4->SetLabel(tmp); |
667 void |
828 } |
668 MyFrame::OnStop (wxCommandEvent & WXUNUSED (event)) |
829 |
669 { |
830 void actu(void) |
670 |
831 { |
671 *textLog << |
832 actu_output(); |
672 wxT |
833 |
673 ("----------------------------------------------------Slave [STOPPED]") << |
834 Gtime++; |
674 wxT ("\n"); |
835 if (Gtime > hdelta) |
675 stop_slave (); |
|
676 stop->Enable (false); |
|
677 start->Enable (true); |
|
678 } |
|
679 |
|
680 void |
|
681 MyFrame::OnLoad (wxCommandEvent & WXUNUSED (event)) |
|
682 { |
|
683 wxFileDialog fd (this, wxT ("Choose a can driver library"), wxT (""), |
|
684 wxT (""), LIB_EXTENT); |
|
685 |
|
686 if (fd.ShowModal () == wxID_OK) |
|
687 { |
|
688 drivername->Clear (); |
|
689 drivername->AppendText (fd.GetPath ()); |
|
690 *textLog << wxT ("LibraryPath: ") << fd.GetPath () << wxT ("\n"); |
|
691 strncpy (LibraryPath, fd.GetPath ().mb_str (), MAXLENGTH_LIBPATH); |
|
692 printf ("path=%s", LibraryPath); |
|
693 } |
|
694 } |
|
695 |
|
696 void |
|
697 MyFrame::OnInbt1 (wxCommandEvent & WXUNUSED (event)) |
|
698 { |
|
699 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x1; |
|
700 } |
|
701 |
|
702 void |
|
703 MyFrame::OnInbt2 (wxCommandEvent & WXUNUSED (event)) |
|
704 { |
|
705 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x2; |
|
706 } |
|
707 |
|
708 void |
|
709 MyFrame::OnInbt3 (wxCommandEvent & WXUNUSED (event)) |
|
710 { |
|
711 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x4; |
|
712 } |
|
713 |
|
714 void |
|
715 MyFrame::OnInbt4 (wxCommandEvent & WXUNUSED (event)) |
|
716 { |
|
717 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x8; |
|
718 } |
|
719 |
|
720 void |
|
721 MyFrame::OnInbt5 (wxCommandEvent & WXUNUSED (event)) |
|
722 { |
|
723 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x10; |
|
724 } |
|
725 |
|
726 void |
|
727 MyFrame::OnInbt6 (wxCommandEvent & WXUNUSED (event)) |
|
728 { |
|
729 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x20; |
|
730 } |
|
731 |
|
732 void |
|
733 MyFrame::OnInbt7 (wxCommandEvent & WXUNUSED (event)) |
|
734 { |
|
735 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x40; |
|
736 } |
|
737 |
|
738 void |
|
739 MyFrame::OnInbt8 (wxCommandEvent & WXUNUSED (event)) |
|
740 { |
|
741 Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x80; |
|
742 } |
|
743 |
|
744 |
|
745 |
|
746 void |
|
747 MyFrame::OnIns1 (wxScrollEvent & event) |
|
748 { |
|
749 Read_Analogue_Input_16_Bit[0] = ins1->GetValue (); |
|
750 inst1->SetValue (ins1->GetValue ()); |
|
751 } |
|
752 |
|
753 void |
|
754 MyFrame::OnIns2 (wxScrollEvent & event) |
|
755 { |
|
756 Read_Analogue_Input_16_Bit[1] = ins2->GetValue (); |
|
757 inst2->SetValue (ins2->GetValue ()); |
|
758 } |
|
759 |
|
760 void |
|
761 MyFrame::OnIns3 (wxScrollEvent & event) |
|
762 { |
|
763 Read_Analogue_Input_16_Bit[2] = ins3->GetValue (); |
|
764 inst3->SetValue (ins3->GetValue ()); |
|
765 } |
|
766 |
|
767 void |
|
768 MyFrame::OnIns4 (wxScrollEvent & event) |
|
769 { |
|
770 Read_Analogue_Input_16_Bit[3] = ins4->GetValue (); |
|
771 inst4->SetValue (ins4->GetValue ()); |
|
772 } |
|
773 |
|
774 void |
|
775 MyFrame::OnIns5 (wxScrollEvent & event) |
|
776 { |
|
777 Read_Analogue_Input_16_Bit[4] = ins5->GetValue (); |
|
778 inst5->SetValue (ins5->GetValue ()); |
|
779 } |
|
780 |
|
781 void |
|
782 MyFrame::OnIns6 (wxScrollEvent & event) |
|
783 { |
|
784 Read_Analogue_Input_16_Bit[5] = ins6->GetValue (); |
|
785 inst6->SetValue (ins6->GetValue ()); |
|
786 } |
|
787 |
|
788 void |
|
789 MyFrame::OnIns7 (wxScrollEvent & event) |
|
790 { |
|
791 Read_Analogue_Input_16_Bit[6] = ins7->GetValue (); |
|
792 inst7->SetValue (ins7->GetValue ()); |
|
793 } |
|
794 |
|
795 void |
|
796 MyFrame::OnIns8 (wxScrollEvent & event) |
|
797 { |
|
798 Read_Analogue_Input_16_Bit[7] = ins8->GetValue (); |
|
799 inst8->SetValue (ins8->GetValue ()); |
|
800 } |
|
801 |
|
802 |
|
803 void |
|
804 MyFrame::OnInst1 (wxSpinEvent & ev) |
|
805 { |
|
806 Read_Analogue_Input_16_Bit[0] = inst1->GetValue (); |
|
807 ins1->SetValue (inst1->GetValue ()); |
|
808 } |
|
809 |
|
810 void |
|
811 MyFrame::OnInst2 (wxSpinEvent & ev) |
|
812 { |
|
813 Read_Analogue_Input_16_Bit[1] = inst2->GetValue (); |
|
814 ins2->SetValue (inst2->GetValue ()); |
|
815 } |
|
816 |
|
817 void |
|
818 MyFrame::OnInst3 (wxSpinEvent & ev) |
|
819 { |
|
820 Read_Analogue_Input_16_Bit[2] = inst3->GetValue (); |
|
821 ins3->SetValue (inst3->GetValue ()); |
|
822 } |
|
823 |
|
824 void |
|
825 MyFrame::OnInst4 (wxSpinEvent & ev) |
|
826 { |
|
827 Read_Analogue_Input_16_Bit[3] = inst4->GetValue (); |
|
828 ins4->SetValue (inst4->GetValue ()); |
|
829 } |
|
830 |
|
831 void |
|
832 MyFrame::OnInst5 (wxSpinEvent & ev) |
|
833 { |
|
834 Read_Analogue_Input_16_Bit[4] = inst5->GetValue (); |
|
835 ins5->SetValue (inst5->GetValue ()); |
|
836 } |
|
837 |
|
838 void |
|
839 MyFrame::OnInst6 (wxSpinEvent & ev) |
|
840 { |
|
841 Read_Analogue_Input_16_Bit[5] = inst6->GetValue (); |
|
842 ins6->SetValue (inst6->GetValue ()); |
|
843 } |
|
844 |
|
845 void |
|
846 MyFrame::OnInst7 (wxSpinEvent & ev) |
|
847 { |
|
848 Read_Analogue_Input_16_Bit[6] = inst7->GetValue (); |
|
849 ins7->SetValue (inst7->GetValue ()); |
|
850 } |
|
851 |
|
852 void |
|
853 MyFrame::OnInst8 (wxSpinEvent & ev) |
|
854 { |
|
855 Read_Analogue_Input_16_Bit[7] = inst8->GetValue (); |
|
856 ins8->SetValue (inst8->GetValue ()); |
|
857 } |
|
858 |
|
859 |
|
860 void |
|
861 MyFrame::OnAbout (wxCommandEvent & WXUNUSED (event)) |
|
862 { |
|
863 wxString msg; |
|
864 msg.Printf (_T ("About.\n\n") |
|
865 _T |
|
866 ("Input-Output simulation by GRANDEMANGE Nicolas for CanFestival!!")); |
|
867 |
|
868 wxMessageBox (msg, _T ("About !!!"), wxOK | wxICON_INFORMATION, this); |
|
869 } |
|
870 |
|
871 |
|
872 void |
|
873 MyFrame::OnFreqBoxClick (wxCommandEvent & event) |
|
874 { |
|
875 wxString wxstr; |
|
876 |
|
877 wxstr = event.GetString (); |
|
878 strncpy (SlaveBoard.baudrate, wxstr.mb_str (), MAXLENGTH_BAUDRATE); |
|
879 *textLog << wxT ("Baudrate:") << event.GetString () << wxT ("\n"); |
|
880 } |
|
881 |
|
882 static int |
|
883 is_set (int i, wxListBox * inlist, wxArrayInt in) |
|
884 { |
|
885 inlist->GetSelections (in); |
|
886 for (int j = 0; j < in.GetCount (); j++) |
|
887 { |
|
888 if (i == (in[j] + 1)) |
836 { |
889 { |
837 old_max = 5; |
890 return (i); |
838 old_min = -5; |
|
839 Gtime = 0; |
|
840 } |
891 } |
841 frame->Paint(); |
892 } |
842 } |
893 return (0); |
843 |
894 } |
844 void MyFrame::OnTimer(wxTimerEvent& event) |
895 |
845 { |
896 static int |
846 actu();// do whatever you want to do every second here |
897 get_bit (UNS8 input, int bit) |
847 } |
898 { |
848 |
899 return input & (((UNS8) 1) << bit - 1) ? 1 : 0; |
849 void MyFrame::OnPaint( wxPaintEvent &event ) |
900 } |
850 { |
901 |
851 //Paint(); |
902 void |
852 } |
903 MyFrame::Paint () |
|
904 { |
|
905 double vmax = old_max; |
|
906 double vmin = old_min; |
|
907 double vdelta = vmax - vmin; |
|
908 double vech = ((float) vdelta) / 10.0; |
|
909 |
|
910 double hmax = frame->echelle->GetValue (); |
|
911 double hech = hdelta / 11; |
|
912 |
|
913 double d = 300 / vdelta; |
|
914 double g = 0; |
|
915 double top = 5; |
|
916 double left = 50; |
|
917 |
|
918 double tmpi = 0; |
|
919 wxString tmps; |
|
920 double p = 0; |
|
921 double q = 0; |
|
922 int i = 0; |
|
923 int j = 0; |
|
924 wxColor col[8] = |
|
925 { wxColor (wxT ("BLUE")), wxColor (wxT ("RED")), wxColor (wxT ("GREEN")), |
|
926 wxColor (wxT ("GREY")), |
|
927 wxColor (wxT ("ORANGE")), wxColor (wxT ("YELLOW")), |
|
928 wxColor (wxT ("PINK")), wxColor (wxT ("BLACK")) |
|
929 }; |
|
930 hdelta = hmax - 0; |
|
931 g = (Gtime / hdelta) * 44.00; |
|
932 |
|
933 wxClientDC MonDc (mygraphpan); |
|
934 MonDc.Clear (); |
|
935 |
|
936 MonDc.SetPen (wxPen (wxColour (200, 200, 200), 5, wxSOLID)); |
|
937 MonDc.DrawRectangle ((int) left, (int) top, 660, 300); |
|
938 |
|
939 MonDc.SetPen (wxPen (wxColor (150, 200, 150), 2, wxSOLID)); |
|
940 MonDc. |
|
941 SetFont (wxFont |
|
942 (9, wxSWISS, wxNORMAL, wxNORMAL, false, wxT ("Arial Black"))); |
|
943 for (i = 0; i < 11; i++) |
|
944 { |
|
945 tmpi = (vmin + (vech * i)); |
|
946 tmps.Printf (wxT ("%d"), (int) tmpi); |
|
947 MonDc.DrawRotatedText (tmps, 0, (int) (293 - (30 * i) + top), 0); |
|
948 } |
|
949 for (i = 0; i < 12; i++) |
|
950 { |
|
951 tmpi = (hech * i * 100); |
|
952 if (tmpi < 1000) |
|
953 tmps.Printf (wxT ("%ims"), (int) tmpi); |
|
954 if (tmpi > 1000) |
|
955 tmps.Printf (wxT ("%is"), (int) (tmpi / 1000)); |
|
956 MonDc.DrawRotatedText (tmps, (int) ((60 * i) + left) - 10, |
|
957 (int) (317 + top), 0); |
|
958 } |
|
959 for (j = 1; j < 10; j++) |
|
960 MonDc.DrawLine ((int) left, (int) (300 - (30 * j) + top), |
|
961 (int) (left + 660), (int) (300 - (30 * j) + top)); |
|
962 MonDc.SetPen (wxPen (wxColor (150, 200, 150), 2, wxSOLID)); |
|
963 for (j = 1; j < 22; j++) |
|
964 MonDc.DrawLine ((int) (30 * j + left), (int) (300 + top), |
|
965 (int) (30 * j + left), (int) (top)); |
|
966 MonDc.SetPen (wxPen (wxColor (150, 170, 150), 1, wxSOLID)); |
|
967 for (j = 1; j < 22; j++) |
|
968 MonDc.DrawLine ((int) (30 * j + left - 15), (int) (300 + top), |
|
969 (int) (30 * j + left - 15), (int) (top)); |
|
970 MonDc.DrawLine ((int) (30 * 22 + left - 15), (int) (300 + top), |
|
971 (int) (30 * 22 + left - 15), (int) (top)); |
|
972 |
|
973 double m = (-vmin) * d; |
|
974 MonDc.SetPen (wxPen (wxColor (170, 170, 150), 3, wxSOLID)); |
|
975 MonDc.DrawLine ((int) (left), (int) (300 + top - m), (int) (left + 660), |
|
976 (int) (300 + top - m)); |
|
977 |
|
978 wxClientDC MaLeg (mylegpan); |
|
979 MaLeg.Clear (); |
|
980 |
|
981 MaLeg.SetPen (wxPen (wxColour (150, 200, 100), 2, wxSOLID)); |
|
982 MaLeg. |
|
983 SetFont (wxFont |
|
984 (7, wxSWISS, wxNORMAL, wxNORMAL, false, wxT ("Arial Black"))); |
|
985 for (int k = 1, tmpi = 0; k < 30; k++) |
|
986 { |
|
987 if ((tmpi < 8) && is_set (k, inlist, in)) |
|
988 { |
|
989 if (k <= 4) |
|
990 tmps.Printf (wxT ("Analogue Output %d"), k); |
|
991 if ((k > 4) && (k <= 12)) |
|
992 tmps.Printf (wxT ("Bool Output %d"), k - 4); |
|
993 if ((k > 12) && (k <= 20)) |
|
994 tmps.Printf (wxT ("Analogue Input %d"), k - 12); |
|
995 if ((k > 20) && (k <= 28)) |
|
996 tmps.Printf (wxT ("Bool Input %d"), k - 20); |
|
997 |
|
998 MaLeg.DrawRotatedText (tmps, 0, 10 * tmpi, 0); |
|
999 MaLeg.SetPen (wxPen (col[tmpi], 4, wxSOLID)); |
|
1000 MaLeg.DrawLine (100, 10 * tmpi + 6, 115, 10 * tmpi + 6); |
|
1001 //////////////////////////////////////////DAW//////////////////////////////////////// |
|
1002 MonDc.SetPen (wxPen (col[tmpi], 4, wxSOLID)); |
|
1003 if (k <= 4) |
|
1004 y[k - 1][(int) g] = Write_Analogue_Output_16_Bit[k - 1]; |
|
1005 if ((k > 4) && (k <= 12)) |
|
1006 y[k - 1][(int) g] = get_bit (Write_Outputs_8_Bit[0], k - 4); |
|
1007 if ((k > 12) && (k <= 20)) |
|
1008 y[k - 1][(int) g] = Read_Analogue_Input_16_Bit[k - 1 - 12]; |
|
1009 if ((k > 20) && (k <= 28)) |
|
1010 y[k - 1][(int) g] = get_bit (Read_Inputs_8_Bit[0], k - 20); |
|
1011 |
|
1012 if (y[k - 1][(int) g] > old_max) |
|
1013 old_max = y[k - 1][(int) g]; |
|
1014 if (y[k - 1][(int) g] < old_min) |
|
1015 old_min = y[k - 1][(int) g]; |
|
1016 for (j = 1; j < (g + 1); j++) |
|
1017 { |
|
1018 p = (y[k - 1][j - 1] - vmin) * d; |
|
1019 q = (y[k - 1][j] - vmin) * d; |
|
1020 MonDc.DrawLine ((int) (15 * (j - 1) + left), |
|
1021 (int) (300 + top - p), (int) (15 * j + left), |
|
1022 (int) (300 + top - q)); |
|
1023 } |
|
1024 ///////////////////////////////////////////////////////////////////////////////////// |
|
1025 tmpi++; |
|
1026 } |
|
1027 } |
|
1028 } |
|
1029 |
|
1030 void |
|
1031 actu_output (void) |
|
1032 { |
|
1033 wxString tmp; |
|
1034 |
|
1035 frame->outbt1->SetValue (get_bit (Write_Outputs_8_Bit[0], 1)); |
|
1036 frame->outbt2->SetValue (get_bit (Write_Outputs_8_Bit[0], 2)); |
|
1037 frame->outbt3->SetValue (get_bit (Write_Outputs_8_Bit[0], 3)); |
|
1038 frame->outbt4->SetValue (get_bit (Write_Outputs_8_Bit[0], 4)); |
|
1039 frame->outbt5->SetValue (get_bit (Write_Outputs_8_Bit[0], 5)); |
|
1040 frame->outbt6->SetValue (get_bit (Write_Outputs_8_Bit[0], 6)); |
|
1041 frame->outbt7->SetValue (get_bit (Write_Outputs_8_Bit[0], 7)); |
|
1042 frame->outbt8->SetValue (get_bit (Write_Outputs_8_Bit[0], 8)); |
|
1043 |
|
1044 frame->outs1->SetValue (Write_Analogue_Output_16_Bit[0] + 32768); |
|
1045 frame->outs2->SetValue (Write_Analogue_Output_16_Bit[1] + 32768); |
|
1046 frame->outs3->SetValue (Write_Analogue_Output_16_Bit[2] + 32768); |
|
1047 frame->outs4->SetValue (Write_Analogue_Output_16_Bit[3] + 32768); |
|
1048 tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[0]); |
|
1049 frame->outst1->SetLabel (tmp); |
|
1050 tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[1]); |
|
1051 frame->outst2->SetLabel (tmp); |
|
1052 tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[2]); |
|
1053 frame->outst3->SetLabel (tmp); |
|
1054 tmp.Printf (wxT (" %i"), Write_Analogue_Output_16_Bit[3]); |
|
1055 frame->outst4->SetLabel (tmp); |
|
1056 } |
|
1057 |
|
1058 void |
|
1059 actu (void) |
|
1060 { |
|
1061 actu_output (); |
|
1062 |
|
1063 Gtime++; |
|
1064 if (Gtime > hdelta) |
|
1065 { |
|
1066 old_max = 5; |
|
1067 old_min = -5; |
|
1068 Gtime = 0; |
|
1069 } |
|
1070 frame->Paint (); |
|
1071 } |
|
1072 |
|
1073 void |
|
1074 MyFrame::OnTimer (wxTimerEvent & event) |
|
1075 { |
|
1076 actu (); // do whatever you want to do every second here |
|
1077 } |
|
1078 |
|
1079 void |
|
1080 MyFrame::OnPaint (wxPaintEvent & event) |
|
1081 { |
|
1082 //Paint(); |
|
1083 } |