# HG changeset patch # User etisserant # Date 1202478768 -3600 # Node ID fff25f16c923762a99f484df2d6c7e00d2637ada # Parent 83793fc7ce48f27106c52cd2bf3e1e67edfa0379 Cleaned DS-401GUI (definitively removed graph) added options to open directly on the right Input or Output page. Little fixes. diff -r 83793fc7ce48 -r fff25f16c923 examples/DS401_Slave_Gui/CallBack.h --- a/examples/DS401_Slave_Gui/CallBack.h Thu Feb 07 10:25:15 2008 +0100 +++ b/examples/DS401_Slave_Gui/CallBack.h Fri Feb 08 14:52:48 2008 +0100 @@ -1,22 +1,22 @@ #ifndef CALLBACK_H_ #define CALLBACK_H_ -extern "C" - { - #include "ObjDict.h" - } +extern "C" +{ +#include "ObjDict.h" +} -void Call_heartbeatError(CO_Data* d, UNS8); +void Call_heartbeatError (CO_Data * d, UNS8); -UNS8 Call_canSend(Message *); +UNS8 Call_canSend (Message *); -void Call_initialisation(CO_Data* d); -void Call_preOperational(CO_Data* d); -void Call_operational(CO_Data* d); -void Call_stopped(CO_Data* d); +void Call_initialisation (CO_Data * d); +void Call_preOperational (CO_Data * d); +void Call_operational (CO_Data * d); +void Call_stopped (CO_Data * d); -void Call_post_sync(CO_Data* d); -void Call_post_TPDO(CO_Data* d); -void Call_storeODSubIndex(CO_Data* d, UNS16 wIndex, UNS8 bSubindex); +void Call_post_sync (CO_Data * d); +void Call_post_TPDO (CO_Data * d); +void Call_storeODSubIndex (CO_Data * d, UNS16 wIndex, UNS8 bSubindex); -#endif /*CALLBACK_H_*/ +#endif /*CALLBACK_H_ */ diff -r 83793fc7ce48 -r fff25f16c923 examples/DS401_Slave_Gui/TestSlaveGui.h --- a/examples/DS401_Slave_Gui/TestSlaveGui.h Thu Feb 07 10:25:15 2008 +0100 +++ b/examples/DS401_Slave_Gui/TestSlaveGui.h Fri Feb 08 14:52:48 2008 +0100 @@ -1,12 +1,12 @@ #ifndef TESTSLAVEGUI_H_ #define TESTSLAVEGUI_H_ -extern "C" - { - #include "canfestival.h" - } +extern "C" +{ +#include "canfestival.h" +} -int main_can(s_BOARD SlaveBoard, char* LibraryPath); -void stop_slave(); +int main_can (s_BOARD SlaveBoard, char *LibraryPath); +void stop_slave (); -#endif /*TESTSLAVEGUI_H_*/ +#endif /*TESTSLAVEGUI_H_ */ diff -r 83793fc7ce48 -r fff25f16c923 examples/DS401_Slave_Gui/main.cpp --- a/examples/DS401_Slave_Gui/main.cpp Thu Feb 07 10:25:15 2008 +0100 +++ b/examples/DS401_Slave_Gui/main.cpp Fri Feb 08 14:52:48 2008 +0100 @@ -45,6 +45,9 @@ wxTextCtrl *textLog; int node_id_ext; int to_start = 0; +int openInput = 0; +int openOutput = 0; + MyFrame *frame; #define MAXLENGTH_BUSNAME 32 #define MAXLENGTH_BAUDRATE 8 @@ -54,11 +57,6 @@ #define MAXLENGTH_LIBPATH 1024 char LibraryPath[MAXLENGTH_LIBPATH] = "libcanfestival_can_virtual.so"; -double Gtime = 0; -double y[28][45]; -double hdelta = 0; -double old_max = 5; -double old_min = -5; #if defined(WIN32) #define LIB_EXTENT wxT("*.dll") @@ -136,8 +134,7 @@ EVT_LISTBOX (FREQBOX, MyFrame::OnFreqBoxClick) EVT_MENU (FILE_QUIT, MyFrame::OnQuit) EVT_BUTTON (QUIT, MyFrame::OnQuit) EVT_MENU (HELP_ABOUT, MyFrame::OnAbout) - //EVT_PAINT(MyFrame::OnPaint) - EVT_TIMER (TIMER_ID, MyFrame::OnTimer) +EVT_TIMER (TIMER_ID, MyFrame::OnTimer) END_EVENT_TABLE ()IMPLEMENT_APP_NO_MAIN (MyApp); IMPLEMENT_WX_THEME_SUPPORT; @@ -173,7 +170,7 @@ int c; extern char *optarg; char *snodeid; - while ((c = getopt (argc, argv, "-b:B:l:i:s")) != EOF) + while ((c = getopt (argc, argv, "-b:B:l:i:sIO")) != EOF) { switch (c) { @@ -213,6 +210,12 @@ case 's': to_start = 1; break; + case 'I': + openInput = 1; + break; + case 'O': + openOutput = 1; + break; default: help (); exit (1); @@ -225,8 +228,10 @@ bool MyApp::OnInit () { - frame = new MyFrame (_T ("I-O simulator")); + frame = new MyFrame (wxString::Format(wxT("CanOpen virtual DS-401 - Id : %d"),node_id_ext)); frame->Show (true); + if(openInput) frame->book->SetSelection(2); + else if(openOutput) frame->book->SetSelection(3); return true; } @@ -312,7 +317,7 @@ myhsizer = new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, - _T ("Node ID (Hexa)")), wxHORIZONTAL); + _T ("Node ID (Decimal)")), wxHORIZONTAL); myentrysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 5); node_id = new wxSpinCtrl (panel, wxID_ANY, wxEmptyString, wxDefaultPosition, @@ -542,46 +547,6 @@ _T ("Bool Input 5"), _T ("Bool Input 6"), _T ("Bool Input 7"), _T ("Bool Input 8"), }; - panel = new wxPanel (book); - book->AddPage(panel, wxT("Graphic"), true); - mysizer = new wxBoxSizer (wxVERTICAL); - panel->SetSizer (mysizer); - //panel->Hide (); - myhsizer = - new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, _T ("Graphic")), - wxVERTICAL); - mysizer->Add (myhsizer, 0, wxEXPAND | wxALL, 10); - mygraphpan = - new wxPanel (panel, wxID_ANY, wxDefaultPosition, wxSize (0, 350), - wxTAB_TRAVERSAL, wxT ("Graphic")); - myhsizer->Add (mygraphpan, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); - echelle = - new wxSlider (panel, wxID_ANY, 44, 44, 1000, wxDefaultPosition, - wxDefaultSize, wxSL_HORIZONTAL, wxDefaultValidator, - wxT ("slider")); - myhsizer->Add (echelle, 0, wxEXPAND | wxALL, 0); - mybsizer = new wxBoxSizer (wxHORIZONTAL); - mysizer->Add (mybsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); - myhsizer = - new wxStaticBoxSizer (new - wxStaticBox (panel, wxID_ANY, - _T ("Select viewable Inputs")), - wxHORIZONTAL); - mybsizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 10); - inlist = - new wxListBox (panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 28, - choice, wxLB_EXTENDED | wxLB_HSCROLL); - myhsizer->Add (inlist, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); - myhsizer = - new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, _T ("Legende")), - wxHORIZONTAL); - mybsizer->Add (myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 10); - mylegpan = - new wxPanel (panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxTAB_TRAVERSAL, wxT ("Legende")); - myhsizer->Add (mylegpan, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); - quit = new wxButton (panel, QUIT, _T ("QUIT")); - mysizer->Add (quit, 0, wxALL, 5); panel = new wxPanel (book); book->InsertPage (0, panel, wxT ("Control"), true); @@ -612,9 +577,6 @@ quit = new wxButton (panel, QUIT, _T ("QUIT")); mysizer->Add (quit, 0, wxALL, 5); - for (int i = 0; i < 28; i++) - for (int j = 0; j < 44; j++) - y[i][j] = 0; m_timer.Start (100); if (to_start) { @@ -653,13 +615,15 @@ MyFrame::OnStart (wxCommandEvent & WXUNUSED (event)) { wxString s; - + node_id_ext = node_id->GetValue (); s = busname->GetValue (); strncpy (SlaveBoard.busname, s.mb_str (), MAXLENGTH_BUSNAME); *textLog << wxT ("-- Bus name: ------> ") << s << wxT ("\n"); *textLog << wxT ("-- Node ID: -------> ") << node_id-> GetValue () << wxT ("\n"); + SetTitle(wxString::Format(wxT("CanOpen virtual DS-401 - Id : %d"),node_id-> + GetValue ())); Start (); } @@ -900,134 +864,6 @@ } void -MyFrame::Paint () -{ - double vmax = old_max; - double vmin = old_min; - double vdelta = vmax - vmin; - double vech = ((float) vdelta) / 10.0; - - double hmax = frame->echelle->GetValue (); - double hech = hdelta / 11; - - double d = 300 / vdelta; - double g = 0; - double top = 5; - double left = 50; - - double tmpi = 0; - wxString tmps; - double p = 0; - double q = 0; - int i = 0; - int j = 0; - wxColor col[8] = - { wxColor (wxT ("BLUE")), wxColor (wxT ("RED")), wxColor (wxT ("GREEN")), -wxColor (wxT ("GREY")), - wxColor (wxT ("ORANGE")), wxColor (wxT ("YELLOW")), - wxColor (wxT ("PINK")), wxColor (wxT ("BLACK")) - }; - hdelta = hmax - 0; - g = (Gtime / hdelta) * 44.00; - - wxClientDC MonDc (mygraphpan); - MonDc.Clear (); - - MonDc.SetPen (wxPen (wxColour (200, 200, 200), 5, wxSOLID)); - MonDc.DrawRectangle ((int) left, (int) top, 660, 300); - - MonDc.SetPen (wxPen (wxColor (150, 200, 150), 2, wxSOLID)); - MonDc. - SetFont (wxFont - (9, wxSWISS, wxNORMAL, wxNORMAL, false, wxT ("Arial Black"))); - for (i = 0; i < 11; i++) - { - tmpi = (vmin + (vech * i)); - tmps.Printf (wxT ("%d"), (int) tmpi); - MonDc.DrawRotatedText (tmps, 0, (int) (293 - (30 * i) + top), 0); - } - for (i = 0; i < 12; i++) - { - tmpi = (hech * i * 100); - if (tmpi < 1000) - tmps.Printf (wxT ("%ims"), (int) tmpi); - if (tmpi > 1000) - tmps.Printf (wxT ("%is"), (int) (tmpi / 1000)); - MonDc.DrawRotatedText (tmps, (int) ((60 * i) + left) - 10, - (int) (317 + top), 0); - } - for (j = 1; j < 10; j++) - MonDc.DrawLine ((int) left, (int) (300 - (30 * j) + top), - (int) (left + 660), (int) (300 - (30 * j) + top)); - MonDc.SetPen (wxPen (wxColor (150, 200, 150), 2, wxSOLID)); - for (j = 1; j < 22; j++) - MonDc.DrawLine ((int) (30 * j + left), (int) (300 + top), - (int) (30 * j + left), (int) (top)); - MonDc.SetPen (wxPen (wxColor (150, 170, 150), 1, wxSOLID)); - for (j = 1; j < 22; j++) - MonDc.DrawLine ((int) (30 * j + left - 15), (int) (300 + top), - (int) (30 * j + left - 15), (int) (top)); - MonDc.DrawLine ((int) (30 * 22 + left - 15), (int) (300 + top), - (int) (30 * 22 + left - 15), (int) (top)); - - double m = (-vmin) * d; - MonDc.SetPen (wxPen (wxColor (170, 170, 150), 3, wxSOLID)); - MonDc.DrawLine ((int) (left), (int) (300 + top - m), (int) (left + 660), - (int) (300 + top - m)); - - wxClientDC MaLeg (mylegpan); - MaLeg.Clear (); - - MaLeg.SetPen (wxPen (wxColour (150, 200, 100), 2, wxSOLID)); - MaLeg. - SetFont (wxFont - (7, wxSWISS, wxNORMAL, wxNORMAL, false, wxT ("Arial Black"))); - for (int k = 1, tmpi = 0; k < 30; k++) - { - if ((tmpi < 8) && is_set (k, inlist, in)) - { - if (k <= 4) - tmps.Printf (wxT ("Analogue Output %d"), k); - if ((k > 4) && (k <= 12)) - tmps.Printf (wxT ("Bool Output %d"), k - 4); - if ((k > 12) && (k <= 20)) - tmps.Printf (wxT ("Analogue Input %d"), k - 12); - if ((k > 20) && (k <= 28)) - tmps.Printf (wxT ("Bool Input %d"), k - 20); - - MaLeg.DrawRotatedText (tmps, 0, 10 * tmpi, 0); - MaLeg.SetPen (wxPen (col[tmpi], 4, wxSOLID)); - MaLeg.DrawLine (100, 10 * tmpi + 6, 115, 10 * tmpi + 6); - //////////////////////////////////////////DAW//////////////////////////////////////// - MonDc.SetPen (wxPen (col[tmpi], 4, wxSOLID)); - if (k <= 4) - y[k - 1][(int) g] = Write_Analogue_Output_16_Bit[k - 1]; - if ((k > 4) && (k <= 12)) - y[k - 1][(int) g] = get_bit (Write_Outputs_8_Bit[0], k - 4); - if ((k > 12) && (k <= 20)) - y[k - 1][(int) g] = Read_Analogue_Input_16_Bit[k - 1 - 12]; - if ((k > 20) && (k <= 28)) - y[k - 1][(int) g] = get_bit (Read_Inputs_8_Bit[0], k - 20); - - if (y[k - 1][(int) g] > old_max) - old_max = y[k - 1][(int) g]; - if (y[k - 1][(int) g] < old_min) - old_min = y[k - 1][(int) g]; - for (j = 1; j < (g + 1); j++) - { - p = (y[k - 1][j - 1] - vmin) * d; - q = (y[k - 1][j] - vmin) * d; - MonDc.DrawLine ((int) (15 * (j - 1) + left), - (int) (300 + top - p), (int) (15 * j + left), - (int) (300 + top - q)); - } - ///////////////////////////////////////////////////////////////////////////////////// - tmpi++; - } - } -} - -void actu_output (void) { wxString tmp; @@ -1059,15 +895,6 @@ actu (void) { actu_output (); - - Gtime++; - if (Gtime > hdelta) - { - old_max = 5; - old_min = -5; - Gtime = 0; - } - frame->Paint (); } void diff -r 83793fc7ce48 -r fff25f16c923 examples/DS401_Slave_Gui/main.h --- a/examples/DS401_Slave_Gui/main.h Thu Feb 07 10:25:15 2008 +0100 +++ b/examples/DS401_Slave_Gui/main.h Fri Feb 08 14:52:48 2008 +0100 @@ -10,112 +10,113 @@ #include #include -class MyApp : public wxApp { +class MyApp:public wxApp +{ public: - virtual bool OnInit(); + virtual bool OnInit (); }; -class MyFrame : public wxFrame { +class MyFrame:public wxFrame +{ public: - wxNotebook *book; - wxButton *stop; - wxButton *start; - wxTextCtrl *busname; - wxSpinCtrl *inst1; - wxSpinCtrl *inst2; - wxSpinCtrl *inst3; - wxSpinCtrl *inst4; - wxSpinCtrl *inst5; - wxSpinCtrl *inst6; - wxSpinCtrl *inst7; - wxSpinCtrl *inst8; - wxTextCtrl *drivername; - wxSpinCtrl *node_id; - wxToggleButton *inbt1; - wxToggleButton *inbt2; - wxToggleButton *inbt3; - wxToggleButton *inbt4; - wxToggleButton *inbt5; - wxToggleButton *inbt6; - wxToggleButton *inbt7; - wxToggleButton *inbt8; - wxSlider *ins1; - wxSlider *ins2; - wxSlider *ins3; - wxSlider *ins4; - wxSlider *ins5; - wxSlider *ins6; - wxSlider *ins7; - wxSlider *ins8; - wxToggleButton *outbt1; - wxToggleButton *outbt2; - wxToggleButton *outbt3; - wxToggleButton *outbt4; - wxToggleButton *outbt5; - wxToggleButton *outbt6; - wxToggleButton *outbt7; - wxToggleButton *outbt8; - wxGauge *outs1; - wxGauge *outs2; - wxGauge *outs3; - wxGauge *outs4; - wxStaticText *outst1; - wxStaticText *outst2; - wxStaticText *outst3; - wxStaticText *outst4; - wxSlider *echelle; - wxPanel *mygraphpan; - wxPanel *mylegpan; - wxListBox *inlist; - wxArrayInt in; - wxTimer m_timer; - - MyFrame(const wxString& title); - - void OnListBoxDoubleClick( wxCommandEvent &event ); - void OnInbt1(wxCommandEvent& event); - void OnInbt2(wxCommandEvent& event); - void OnInbt3(wxCommandEvent& event); - void OnInbt4(wxCommandEvent& event); - void OnInbt5(wxCommandEvent& event); - void OnInbt6(wxCommandEvent& event); - void OnInbt7(wxCommandEvent& event); - void OnInbt8(wxCommandEvent& event); - void OnQuit(wxCommandEvent& event); - void OnAdd(wxCommandEvent& event); - void OnRemove(wxCommandEvent& event); - void OnAbout(wxCommandEvent& event); - void OnStart(wxCommandEvent& WXUNUSED(event)); - void Start(); - void OnStop(wxCommandEvent& WXUNUSED(event)); - void OnFreqBoxClick(wxCommandEvent& WXUNUSED(event)); - void OnLoad(wxCommandEvent& WXUNUSED(event)); - void OnPaint(wxPaintEvent& WXUNUSED(event)); - void OnIns1(wxScrollEvent &event); - void OnIns2(wxScrollEvent &event); - void OnIns3(wxScrollEvent &event); - void OnIns4(wxScrollEvent &event); - void OnIns5(wxScrollEvent &event); - void OnIns6(wxScrollEvent &event); - void OnIns7(wxScrollEvent &event); - void OnIns8(wxScrollEvent &event); - void OnInst1( wxSpinEvent &ev ); - void OnInst2( wxSpinEvent &ev ); - void OnInst3( wxSpinEvent &ev ); - void OnInst4( wxSpinEvent &ev ); - void OnInst5( wxSpinEvent &ev ); - void OnInst6( wxSpinEvent &ev ); - void OnInst7( wxSpinEvent &ev ); - void OnInst8( wxSpinEvent &ev ); - void Paint(); - void OnTimer(wxTimerEvent& event); + wxNotebook * book; + wxButton *stop; + wxButton *start; + wxTextCtrl *busname; + wxSpinCtrl *inst1; + wxSpinCtrl *inst2; + wxSpinCtrl *inst3; + wxSpinCtrl *inst4; + wxSpinCtrl *inst5; + wxSpinCtrl *inst6; + wxSpinCtrl *inst7; + wxSpinCtrl *inst8; + wxTextCtrl *drivername; + wxSpinCtrl *node_id; + wxToggleButton *inbt1; + wxToggleButton *inbt2; + wxToggleButton *inbt3; + wxToggleButton *inbt4; + wxToggleButton *inbt5; + wxToggleButton *inbt6; + wxToggleButton *inbt7; + wxToggleButton *inbt8; + wxSlider *ins1; + wxSlider *ins2; + wxSlider *ins3; + wxSlider *ins4; + wxSlider *ins5; + wxSlider *ins6; + wxSlider *ins7; + wxSlider *ins8; + wxToggleButton *outbt1; + wxToggleButton *outbt2; + wxToggleButton *outbt3; + wxToggleButton *outbt4; + wxToggleButton *outbt5; + wxToggleButton *outbt6; + wxToggleButton *outbt7; + wxToggleButton *outbt8; + wxGauge *outs1; + wxGauge *outs2; + wxGauge *outs3; + wxGauge *outs4; + wxStaticText *outst1; + wxStaticText *outst2; + wxStaticText *outst3; + wxStaticText *outst4; + wxSlider *echelle; + wxPanel *mygraphpan; + wxPanel *mylegpan; + wxListBox *inlist; + wxArrayInt in; + wxTimer m_timer; + + MyFrame (const wxString & title); + + void OnListBoxDoubleClick (wxCommandEvent & event); + void OnInbt1 (wxCommandEvent & event); + void OnInbt2 (wxCommandEvent & event); + void OnInbt3 (wxCommandEvent & event); + void OnInbt4 (wxCommandEvent & event); + void OnInbt5 (wxCommandEvent & event); + void OnInbt6 (wxCommandEvent & event); + void OnInbt7 (wxCommandEvent & event); + void OnInbt8 (wxCommandEvent & event); + void OnQuit (wxCommandEvent & event); + void OnAdd (wxCommandEvent & event); + void OnRemove (wxCommandEvent & event); + void OnAbout (wxCommandEvent & event); + void OnStart (wxCommandEvent & WXUNUSED (event)); + void Start (); + void OnStop (wxCommandEvent & WXUNUSED (event)); + void OnFreqBoxClick (wxCommandEvent & WXUNUSED (event)); + void OnLoad (wxCommandEvent & WXUNUSED (event)); + void OnPaint (wxPaintEvent & WXUNUSED (event)); + void OnIns1 (wxScrollEvent & event); + void OnIns2 (wxScrollEvent & event); + void OnIns3 (wxScrollEvent & event); + void OnIns4 (wxScrollEvent & event); + void OnIns5 (wxScrollEvent & event); + void OnIns6 (wxScrollEvent & event); + void OnIns7 (wxScrollEvent & event); + void OnIns8 (wxScrollEvent & event); + void OnInst1 (wxSpinEvent & ev); + void OnInst2 (wxSpinEvent & ev); + void OnInst3 (wxSpinEvent & ev); + void OnInst4 (wxSpinEvent & ev); + void OnInst5 (wxSpinEvent & ev); + void OnInst6 (wxSpinEvent & ev); + void OnInst7 (wxSpinEvent & ev); + void OnInst8 (wxSpinEvent & ev); + void Paint (); + void OnTimer (wxTimerEvent & event); private: - DECLARE_EVENT_TABLE() -}; + DECLARE_EVENT_TABLE ()}; -void actu(void); -void actu_output(void); +void actu (void); +void actu_output (void); -#endif /*MAIN_H_*/ +#endif /*MAIN_H_ */