etisserant@246: #include etisserant@246: #include etisserant@246: #include etisserant@246: #include etisserant@246: #include etisserant@246: #include etisserant@246: #include etisserant@246: #include etisserant@246: #include etisserant@295: #include etisserant@246: #include etisserant@246: #include etisserant@246: #include etisserant@246: #include etisserant@246: #include etisserant@246: etisserant@295: //#include "monicone.xpm" etisserant@246: greg@329: #if defined(WIN32) && !defined(__CYGWIN__) greg@329: #include greg@329: extern "C" { greg@329: #include "getopt.h" greg@329: } greg@329: #endif greg@329: etisserant@246: #include "main.h" etisserant@246: #include "TestSlaveGui.h" etisserant@246: extern "C" { etisserant@246: #include "canfestival.h" etisserant@246: #include "ObjDict.h" etisserant@246: } etisserant@246: #include "wx/wxprec.h" etisserant@246: etisserant@246: #ifdef __BORLANDC__ etisserant@246: #pragma hdrstop etisserant@246: #endif etisserant@246: etisserant@246: #ifndef WX_PRECOMP etisserant@246: #include "wx/wx.h" etisserant@246: #endif etisserant@246: etisserant@246: etisserant@246: wxTextCtrl *textLog; etisserant@246: int node_id_ext; etisserant@295: int to_start = 0; etisserant@246: MyFrame *frame; etisserant@295: #define MAXLENGTH_BUSNAME 32 etisserant@295: #define MAXLENGTH_BAUDRATE 8 etisserant@295: char _busname[MAXLENGTH_BUSNAME] = "vcan0"; etisserant@295: char _baudrate[MAXLENGTH_BAUDRATE] = "500K"; etisserant@295: s_BOARD SlaveBoard = {_busname, _baudrate}; etisserant@295: #define MAXLENGTH_LIBPATH 1024 etisserant@295: char LibraryPath[MAXLENGTH_LIBPATH] = "libcanfestival_can_virtual.so"; etisserant@246: double Gtime = 0; etisserant@246: double y[28][45]; etisserant@246: double hdelta = 0; etisserant@246: double old_max = 5; etisserant@246: double old_min = -5; etisserant@246: etisserant@331: #if defined(WIN32) etisserant@331: #define LIB_EXTENT wxT("*.dll") etisserant@331: #else etisserant@331: #define LIB_EXTENT wxT("*.so") etisserant@331: #endif etisserant@331: etisserant@246: // Declare some IDs. These are arbitrary. etisserant@246: const int BOOKCTRL = 100; etisserant@246: const int FILE_QUIT = wxID_EXIT; etisserant@246: const int HELP_ABOUT = wxID_ABOUT; etisserant@246: const int ADD = 105; etisserant@246: const int REMOVE = 108; etisserant@246: const int QUIT = 109; etisserant@246: const int FREQBOX = 110; etisserant@246: const int START = 112; etisserant@246: const int TEXTBOX1 = 113; etisserant@246: const int STOP = 114; etisserant@246: const int LOAD = 115; etisserant@246: const int INBT1 = 118; etisserant@246: const int INBT2 = 119; etisserant@246: const int INBT3 = 120; etisserant@246: const int INBT4 = 121; etisserant@246: const int INBT5 = 122; etisserant@246: const int INBT6 = 123; etisserant@246: const int INBT7 = 124; etisserant@246: const int INBT8 = 125; etisserant@246: const int INS1 = 126; etisserant@246: const int INS2 = 127; etisserant@246: const int INS3 = 128; etisserant@246: const int INS4 = 129; etisserant@246: const int INS5 = 135; etisserant@246: const int INS6 = 136; etisserant@246: const int INS7 = 137; etisserant@246: const int INS8 = 138; etisserant@246: const int TIMER_ID = 130; etisserant@246: const int INST1 = 131; etisserant@246: const int INST2 = 132; etisserant@246: const int INST3 = 133; etisserant@246: const int INST4 = 134; etisserant@246: const int INST5 = 135; etisserant@246: const int INST6 = 136; etisserant@246: const int INST7 = 137; etisserant@246: const int INST8 = 138; etisserant@246: etisserant@246: // Attach the event handlers. Put this after MyFrame declaration. etisserant@246: BEGIN_EVENT_TABLE(MyFrame, wxFrame) etisserant@246: EVT_BUTTON(STOP, MyFrame::OnStop) etisserant@246: EVT_BUTTON(LOAD, MyFrame::OnLoad) etisserant@246: EVT_BUTTON(START, MyFrame::OnStart) etisserant@246: EVT_TOGGLEBUTTON(INBT1, MyFrame::OnInbt1) etisserant@246: EVT_TOGGLEBUTTON(INBT2, MyFrame::OnInbt2) etisserant@246: EVT_TOGGLEBUTTON(INBT3, MyFrame::OnInbt3) etisserant@246: EVT_TOGGLEBUTTON(INBT4, MyFrame::OnInbt4) etisserant@246: EVT_TOGGLEBUTTON(INBT5, MyFrame::OnInbt5) etisserant@246: EVT_TOGGLEBUTTON(INBT6, MyFrame::OnInbt6) etisserant@246: EVT_TOGGLEBUTTON(INBT7, MyFrame::OnInbt7) etisserant@246: EVT_TOGGLEBUTTON(INBT8, MyFrame::OnInbt8) etisserant@246: EVT_COMMAND_SCROLL(INS1, MyFrame::OnIns1) etisserant@246: EVT_COMMAND_SCROLL(INS2, MyFrame::OnIns2) etisserant@246: EVT_COMMAND_SCROLL(INS3, MyFrame::OnIns3) etisserant@246: EVT_COMMAND_SCROLL(INS4, MyFrame::OnIns4) etisserant@246: EVT_COMMAND_SCROLL(INS5, MyFrame::OnIns5) etisserant@246: EVT_COMMAND_SCROLL(INS6, MyFrame::OnIns6) etisserant@246: EVT_COMMAND_SCROLL(INS7, MyFrame::OnIns7) etisserant@246: EVT_COMMAND_SCROLL(INS8, MyFrame::OnIns8) etisserant@246: EVT_SPINCTRL(INST1, MyFrame::OnInst1) etisserant@246: EVT_SPINCTRL(INST2, MyFrame::OnInst2) etisserant@246: EVT_SPINCTRL(INST3, MyFrame::OnInst3) etisserant@246: EVT_SPINCTRL(INST4, MyFrame::OnInst4) etisserant@246: EVT_SPINCTRL(INST5, MyFrame::OnInst5) etisserant@246: EVT_SPINCTRL(INST6, MyFrame::OnInst6) etisserant@246: EVT_SPINCTRL(INST7, MyFrame::OnInst7) etisserant@246: EVT_SPINCTRL(INST8, MyFrame::OnInst8) etisserant@246: etisserant@246: EVT_LISTBOX(FREQBOX, MyFrame::OnFreqBoxClick) etisserant@246: EVT_MENU(FILE_QUIT, MyFrame::OnQuit) etisserant@246: EVT_BUTTON(QUIT, MyFrame::OnQuit) etisserant@246: EVT_MENU(HELP_ABOUT, MyFrame::OnAbout) etisserant@331: //EVT_PAINT(MyFrame::OnPaint) etisserant@246: etisserant@246: EVT_TIMER(TIMER_ID, MyFrame::OnTimer) etisserant@246: END_EVENT_TABLE() etisserant@246: etisserant@295: IMPLEMENT_APP_NO_MAIN(MyApp); etisserant@295: IMPLEMENT_WX_THEME_SUPPORT; etisserant@295: etisserant@295: void help() etisserant@295: { etisserant@295: printf("**************************************************************\n"); etisserant@295: printf("* DS-401 Slave GUI *\n"); etisserant@295: printf("* *\n"); etisserant@295: printf("* Usage: *\n"); etisserant@295: printf("* ./DS401_Slave_Gui [OPTIONS] *\n"); etisserant@295: printf("* *\n"); etisserant@295: printf("* OPTIONS: *\n"); etisserant@295: printf("* -l : Can library [\"libcanfestival_can_virtual.so\"] *\n"); etisserant@295: printf("* *\n"); etisserant@295: printf("* Slave: *\n"); etisserant@295: printf("* -i : Node id format [0x01 , 0x7F] *\n"); etisserant@295: printf("* *\n"); etisserant@295: printf("* CAN bus: *\n"); etisserant@295: printf("* -b : bus name [\"1\"] *\n"); etisserant@295: printf("* -B : 1M,500K,250K,125K,100K,50K,20K,10K *\n"); etisserant@295: printf("* *\n"); etisserant@295: printf("**************************************************************\n"); etisserant@295: } etisserant@295: etisserant@295: etisserant@295: int main(int argc,char **argv) etisserant@295: { etisserant@295: etisserant@295: int c; etisserant@295: extern char *optarg; etisserant@295: char *snodeid; etisserant@295: while ((c = getopt(argc, argv, "-b:B:l:i:s")) != EOF) etisserant@295: { etisserant@295: switch(c) etisserant@295: { etisserant@295: case 'b' : etisserant@295: if (optarg[0] == 0) etisserant@295: { etisserant@295: help(); etisserant@295: exit(1); etisserant@295: } etisserant@295: SlaveBoard.busname = optarg; etisserant@295: break; etisserant@295: case 'B' : etisserant@295: if (optarg[0] == 0) etisserant@295: { etisserant@295: help(); etisserant@295: exit(1); etisserant@295: } etisserant@295: SlaveBoard.baudrate = optarg; etisserant@295: break; etisserant@295: case 'l' : etisserant@295: if (optarg[0] == 0) etisserant@295: { etisserant@295: help(); etisserant@295: exit(1); etisserant@295: } etisserant@295: strncpy(LibraryPath, optarg, MAXLENGTH_LIBPATH); etisserant@295: break; etisserant@295: case 'i' : etisserant@295: if (optarg[0] == 0) etisserant@295: { etisserant@295: help(); etisserant@295: exit(1); etisserant@295: } etisserant@295: snodeid = optarg; etisserant@295: sscanf(snodeid,"%x",&node_id_ext); etisserant@295: break; etisserant@295: case 's' : etisserant@295: to_start = 1; etisserant@295: break; etisserant@295: default: etisserant@295: help(); etisserant@295: exit(1); etisserant@295: } etisserant@295: } etisserant@295: wxEntry(argc,argv); etisserant@295: } etisserant@295: etisserant@246: etisserant@246: bool MyApp::OnInit() etisserant@246: { etisserant@246: frame = new MyFrame( _T("I-O simulator")); etisserant@246: frame->Show(true); etisserant@246: return true; etisserant@246: } etisserant@246: etisserant@246: MyFrame::MyFrame(const wxString& title) etisserant@246: : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 740), wxDEFAULT_FRAME_STYLE, wxT("frame")) etisserant@246: ,m_timer(this, TIMER_ID) etisserant@246: { etisserant@246: wxMenu *fileMenu = new wxMenu; etisserant@246: wxMenu *helpMenu = new wxMenu; etisserant@246: wxPanel *panel; etisserant@246: wxButton *quit; etisserant@246: wxButton *load; etisserant@246: wxBoxSizer *mysizer; etisserant@246: wxBoxSizer *mysssizer; etisserant@246: wxBoxSizer *myhsizer; etisserant@246: wxBoxSizer *mybsizer; etisserant@246: wxBoxSizer *myentrysizer; etisserant@246: wxListBox *freqlist; etisserant@246: wxStaticBox *namebox; etisserant@246: wxStaticBox *freqbox; etisserant@246: etisserant@295: // SetIcon(wxICON(monicone)); etisserant@246: SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); etisserant@246: helpMenu->Append(HELP_ABOUT, _T("&About...\tF1"), etisserant@246: _T("Show about dialog")); etisserant@246: fileMenu->Append(FILE_QUIT, _T("E&xit\tAlt-X"), etisserant@246: _T("Quit this program")); etisserant@246: wxMenuBar *menuBar = new wxMenuBar(); etisserant@246: menuBar->Append(fileMenu, _T("&File")); etisserant@246: menuBar->Append(helpMenu, _T("&Help")); etisserant@246: SetMenuBar(menuBar); etisserant@246: CreateStatusBar(2); etisserant@246: SetStatusText(_T("Lolitech."), 0); etisserant@246: SetStatusText(_T("Welcome."), 1); etisserant@246: etisserant@246: book = new wxNotebook(this, BOOKCTRL); etisserant@246: etisserant@246: panel = new wxPanel(book); etisserant@246: book->AddPage(panel, _T("Configuration"), true); etisserant@246: mysizer = new wxBoxSizer( wxVERTICAL ); etisserant@246: panel->SetSizer(mysizer); etisserant@246: wxString choices[] = etisserant@246: { etisserant@246: _T("10K"), _T("20K"), _T("50K"), _T("100K"), etisserant@246: _T("125K"), _T("250K"), _T("500K"), _T("1M") etisserant@246: }; etisserant@246: etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Bus driver")), wxHORIZONTAL ); etisserant@246: mysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 5); etisserant@246: load = new wxButton( panel, LOAD, _T("Load can driver")); etisserant@246: myhsizer->Add(load, 0, wxLEFT, 5); etisserant@295: drivername = new wxTextCtrl(panel, wxID_ANY, wxString((const char*)LibraryPath,wxConvLocal)); etisserant@246: myhsizer->Add(drivername, 1, wxEXPAND | wxALL, 5); etisserant@246: myentrysizer = new wxBoxSizer( wxHORIZONTAL ); etisserant@246: mysizer->Add(myentrysizer, 0, wxEXPAND | wxALL, 5); etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Bus name")), wxHORIZONTAL ); etisserant@246: myentrysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 5); etisserant@295: busname = new wxTextCtrl(panel, wxID_ANY, wxString((const char*)SlaveBoard.busname, wxConvLocal)); etisserant@246: myhsizer->Add(busname, 0, wxLEFT, 5); etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Node ID (Hexa)")), wxHORIZONTAL ); etisserant@246: myentrysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 5); etisserant@295: node_id = new wxSpinCtrl(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 127, node_id_ext, _T("wxSpinCtrl")); etisserant@246: myhsizer->Add(node_id, 0, wxRIGHT, 5); etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Baudrate")), wxHORIZONTAL ); etisserant@246: mysizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); etisserant@246: freqlist = new wxListBox( panel, FREQBOX, wxDefaultPosition, wxDefaultSize, 8, choices, wxLB_SINGLE | wxLB_HSCROLL); etisserant@246: myhsizer->Add(freqlist, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); etisserant@246: quit = new wxButton( panel, QUIT, _T("QUIT")); etisserant@246: mysizer->Add(quit, 0, wxALL, 5); etisserant@246: etisserant@246: etisserant@246: panel = new wxPanel(book); etisserant@246: book->AddPage(panel, wxT("Inputs"), true); etisserant@246: mysizer = new wxBoxSizer( wxVERTICAL ); etisserant@246: panel->SetSizer(mysizer); etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Read Inputs UNSIGNED8")), wxHORIZONTAL ); etisserant@246: mysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 30); etisserant@246: inbt1 = new wxToggleButton(panel, INBT1, wxT("1")); etisserant@246: inbt2 = new wxToggleButton(panel, INBT2, wxT("2")); etisserant@246: inbt3 = new wxToggleButton(panel, INBT3, wxT("3")); etisserant@246: inbt4 = new wxToggleButton(panel, INBT4, wxT("4")); etisserant@246: inbt5 = new wxToggleButton(panel, INBT5, wxT("5")); etisserant@246: inbt6 = new wxToggleButton(panel, INBT6, wxT("6")); etisserant@246: inbt7 = new wxToggleButton(panel, INBT7, wxT("7")); etisserant@246: inbt8 = new wxToggleButton(panel, INBT8, wxT("8")); etisserant@246: myhsizer->Add(inbt1, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(inbt2, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(inbt3, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(inbt4, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(inbt5, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(inbt6, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(inbt7, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(inbt8, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Analogue Inputs INTEGER16")), wxVERTICAL ); etisserant@246: mysizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 30); etisserant@246: mysssizer = new wxBoxSizer( wxHORIZONTAL ); etisserant@246: myhsizer->Add(mysssizer, 0, wxEXPAND | wxALL, 0); etisserant@246: inst1 = new wxSpinCtrl(panel, INST1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); etisserant@246: inst2 = new wxSpinCtrl(panel, INST2, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); etisserant@246: inst3 = new wxSpinCtrl(panel, INST3, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); etisserant@246: inst4 = new wxSpinCtrl(panel, INST4, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); etisserant@246: inst5 = new wxSpinCtrl(panel, INST5, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); etisserant@246: inst6 = new wxSpinCtrl(panel, INST6, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); etisserant@246: inst7 = new wxSpinCtrl(panel, INST7, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); etisserant@246: inst8 = new wxSpinCtrl(panel, INST8, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -32768, 32767, 0, _T("0")); etisserant@246: mysssizer->Add(inst1, wxALL, 0, 5); etisserant@246: mysssizer->Add(inst2, wxALL, 0, 5); etisserant@246: mysssizer->Add(inst3, wxALL, 0, 5); etisserant@246: mysssizer->Add(inst4, wxALL, 0, 5); etisserant@246: mysssizer->Add(inst5, wxALL, 0, 5); etisserant@246: mysssizer->Add(inst6, wxALL, 0, 5); etisserant@246: mysssizer->Add(inst7, wxALL, 0, 5); etisserant@246: mysssizer->Add(inst8, wxALL, 0, 5); etisserant@246: mysssizer = new wxBoxSizer( wxHORIZONTAL ); etisserant@246: myhsizer->Add(mysssizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 0); etisserant@246: ins1 = new wxSlider(panel, INS1, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); etisserant@246: ins2 = new wxSlider(panel, INS2, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); etisserant@246: ins3 = new wxSlider(panel, INS3, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); etisserant@246: ins4 = new wxSlider(panel, INS4, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); etisserant@246: ins5 = new wxSlider(panel, INS5, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); etisserant@246: ins6 = new wxSlider(panel, INS6, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); etisserant@246: ins7 = new wxSlider(panel, INS7, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); etisserant@246: ins8 = new wxSlider(panel, INS8, 0, -32768, 32767, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("slider")); etisserant@246: mysssizer->Add(ins1, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: mysssizer->Add(ins2, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: mysssizer->Add(ins3, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: mysssizer->Add(ins4, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: mysssizer->Add(ins5, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: mysssizer->Add(ins6, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: mysssizer->Add(ins7, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: mysssizer->Add(ins8, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: quit = new wxButton( panel, QUIT, _T("QUIT")); etisserant@246: mysizer->Add(quit, 0, wxALL, 5); etisserant@246: etisserant@246: panel = new wxPanel(book); etisserant@246: book->AddPage(panel, wxT("Outputs"), true); etisserant@246: mysizer = new wxBoxSizer( wxVERTICAL ); etisserant@246: panel->SetSizer(mysizer); etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Write Outputs UNSIGNED8")), wxHORIZONTAL ); etisserant@246: mysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 30); etisserant@246: outbt1 = new wxToggleButton(panel, wxID_ANY, wxT("1")); etisserant@246: outbt2 = new wxToggleButton(panel, wxID_ANY, wxT("2")); etisserant@246: outbt3 = new wxToggleButton(panel, wxID_ANY, wxT("3")); etisserant@246: outbt4 = new wxToggleButton(panel, wxID_ANY, wxT("4")); etisserant@246: outbt5 = new wxToggleButton(panel, wxID_ANY, wxT("5")); etisserant@246: outbt6 = new wxToggleButton(panel, wxID_ANY, wxT("6")); etisserant@246: outbt7 = new wxToggleButton(panel, wxID_ANY, wxT("7")); etisserant@246: outbt8 = new wxToggleButton(panel, wxID_ANY, wxT("8")); etisserant@246: myhsizer->Add(outbt1, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(outbt2, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(outbt3, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(outbt4, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(outbt5, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(outbt6, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(outbt7, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer->Add(outbt8, wxEXPAND | wxALL, 0, 5); etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Analogue Output INTEGER16")), wxVERTICAL ); etisserant@246: mysizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 30); etisserant@246: mysssizer = new wxBoxSizer( wxHORIZONTAL ); etisserant@246: myhsizer->Add(mysssizer, 0, wxEXPAND | wxALL, 0); etisserant@246: outst1 = new wxStaticText(panel, wxID_ANY, wxT("label"), wxDefaultPosition, wxDefaultSize, 0, wxT("staticText")); etisserant@246: outst2 = new wxStaticText(panel, wxID_ANY, wxT("label"), wxDefaultPosition, wxDefaultSize, 0, wxT("staticText")); etisserant@246: outst3 = new wxStaticText(panel, wxID_ANY, wxT("label"), wxDefaultPosition, wxDefaultSize, 0, wxT("staticText")); etisserant@246: outst4 = new wxStaticText(panel, wxID_ANY, wxT("label"), wxDefaultPosition, wxDefaultSize, 0, wxT("staticText")); etisserant@246: mysssizer->Add(outst1, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); etisserant@246: mysssizer->Add(outst2, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); etisserant@246: mysssizer->Add(outst3, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); etisserant@246: mysssizer->Add(outst4, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); etisserant@246: mysssizer = new wxBoxSizer( wxHORIZONTAL ); etisserant@246: myhsizer->Add(mysssizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 0); etisserant@246: outs1 = new wxGauge(panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("gauge")); etisserant@246: outs2 = new wxGauge(panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("gauge")); etisserant@246: outs3 = new wxGauge(panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("gauge")); etisserant@246: outs4 = new wxGauge(panel, wxID_ANY, 65535, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE, wxDefaultValidator, wxT("gauge")); etisserant@246: mysssizer->Add(outs1, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: mysssizer->Add(outs2, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: mysssizer->Add(outs3, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: mysssizer->Add(outs4, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: quit = new wxButton( panel, QUIT, _T("QUIT")); etisserant@246: mysizer->Add(quit, 0, wxALL, 5); etisserant@246: etisserant@246: wxString choice[] = etisserant@246: { etisserant@246: _T("Analogue Out 1"), _T("Analogue Out 2"), etisserant@246: _T("Analogue Out 3"), _T("Analogue Out 4"), etisserant@246: _T("Bool Out 1"), _T("Bool Out 2"), etisserant@246: _T("Bool Out 3"), _T("Bool Out 4"), etisserant@246: _T("Bool Out 5"), _T("Bool Out 6"), etisserant@246: _T("Bool Out 7"), _T("Bool Out 8"), etisserant@246: _T("Analogue Input 1"), _T("Analogue Input 2"), etisserant@246: _T("Analogue Input 3"), _T("Analogue Input 4"), etisserant@246: _T("Analogue Input 5"), _T("Analogue Input 6"), etisserant@246: _T("Analogue Input 7"), _T("Analogue Input 8"), etisserant@246: _T("Bool Input 1"), _T("Bool Input 2"), etisserant@246: _T("Bool Input 3"), _T("Bool Input 4"), etisserant@246: _T("Bool Input 5"), _T("Bool Input 6"), etisserant@246: _T("Bool Input 7"), _T("Bool Input 8"), }; etisserant@246: panel = new wxPanel(book); etisserant@331: //book->AddPage(panel, wxT("Graphic"), true); etisserant@246: mysizer = new wxBoxSizer( wxVERTICAL ); etisserant@331: panel->SetSizer(mysizer); etisserant@331: panel->Hide(); etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Graphic")), wxVERTICAL ); etisserant@246: mysizer->Add(myhsizer, 0, wxEXPAND | wxALL, 10); etisserant@246: mygraphpan = new wxPanel(panel, wxID_ANY, wxDefaultPosition, wxSize(0, 350), wxTAB_TRAVERSAL, wxT("Graphic")); etisserant@246: myhsizer->Add(mygraphpan, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: echelle = new wxSlider(panel, wxID_ANY, 44, 44, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL , wxDefaultValidator, wxT("slider")); etisserant@246: myhsizer->Add(echelle, 0, wxEXPAND | wxALL, 0); etisserant@246: mybsizer = new wxBoxSizer( wxHORIZONTAL ); etisserant@246: mysizer->Add(mybsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Select viewable Inputs")), wxHORIZONTAL ); etisserant@246: mybsizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 10); etisserant@246: inlist = new wxListBox( panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 28, choice, wxLB_EXTENDED | wxLB_HSCROLL); etisserant@246: myhsizer->Add(inlist, wxEXPAND | wxALL, wxEXPAND | wxALL, 5); etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Legende")), wxHORIZONTAL ); etisserant@246: mybsizer->Add(myhsizer, wxEXPAND | wxALL, wxEXPAND | wxALL, 10); etisserant@246: mylegpan = new wxPanel(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxT("Legende")); etisserant@246: myhsizer->Add(mylegpan, wxEXPAND | wxALL, wxEXPAND | wxALL, 15); etisserant@246: quit = new wxButton( panel, QUIT, _T("QUIT")); etisserant@246: mysizer->Add(quit, 0, wxALL, 5); etisserant@246: etisserant@246: panel = new wxPanel(book); etisserant@246: book->InsertPage(0, panel, wxT("Control"), true); etisserant@246: mysizer = new wxBoxSizer( wxVERTICAL ); etisserant@246: panel->SetSizer(mysizer); etisserant@246: myhsizer = new wxBoxSizer( wxHORIZONTAL ); etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Control your node")), wxHORIZONTAL ); etisserant@246: mysizer->Add(myhsizer, 0, wxALL, 5); etisserant@246: start = new wxButton( panel, START, _T("START")); etisserant@246: stop = new wxButton( panel, STOP, _T("STOP")); etisserant@246: stop->Enable(false); etisserant@246: myhsizer->Add(start, 0, wxRIGHT, 5); etisserant@246: myhsizer->Add(stop, 0, wxLEFT, 5); etisserant@246: myhsizer = new wxStaticBoxSizer( new wxStaticBox(panel, wxID_ANY, _T("Operation log")), wxHORIZONTAL ); etisserant@246: mysizer->Add(myhsizer, wxALL, wxEXPAND | wxALL, 5); etisserant@246: textLog = new wxTextCtrl( panel, TEXTBOX1, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, wxTextCtrlNameStr); etisserant@246: myhsizer->Add(textLog, wxALL, wxEXPAND | wxALL, 5); etisserant@246: quit = new wxButton( panel, QUIT, _T("QUIT")); etisserant@246: mysizer->Add(quit, 0, wxALL, 5); etisserant@246: etisserant@246: for (int i= 0; i < 28; i++) etisserant@246: for (int j = 0; j < 44; j++) etisserant@246: y[i][j] = 0; etisserant@246: m_timer.Start(100); etisserant@295: if(to_start) etisserant@295: { etisserant@295: Start(); etisserant@295: } etisserant@246: } etisserant@246: etisserant@246: void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@246: Close(true); etisserant@246: } etisserant@246: etisserant@295: void MyFrame::Start() etisserant@295: { etisserant@295: if (main_can(SlaveBoard, LibraryPath)) etisserant@295: { etisserant@295: printf("[KO]\n"); etisserant@295: *textLog << wxT("----------------------------------------------------Initialization [KO]\n"); etisserant@295: } etisserant@295: else etisserant@295: { etisserant@295: printf("[OK]\n"); etisserant@295: *textLog << wxT("----------------------------------------------------Initialization [OK]\n"); etisserant@295: stop->Enable(true); etisserant@295: start->Enable(false); etisserant@295: } etisserant@295: } etisserant@295: etisserant@246: void MyFrame::OnStart(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@246: wxString s; etisserant@246: etisserant@246: node_id_ext = node_id->GetValue(); etisserant@246: s = busname->GetValue(); etisserant@295: strncpy(SlaveBoard.busname, s.mb_str(), MAXLENGTH_BUSNAME); etisserant@246: *textLog << wxT("-- Bus name: ------> ") << s << wxT("\n"); etisserant@246: *textLog << wxT("-- Node ID: -------> ") << node_id->GetValue() << wxT("\n"); etisserant@295: Start(); etisserant@295: } etisserant@295: etisserant@246: etisserant@246: void MyFrame::OnStop(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@246: etisserant@246: *textLog << wxT("----------------------------------------------------Slave [STOPPED]") << wxT("\n"); etisserant@246: stop_slave(); etisserant@246: stop->Enable(false); etisserant@246: start->Enable(true); etisserant@246: } etisserant@246: etisserant@246: void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@331: wxFileDialog fd(this, wxT("Choose a can driver library"), wxT(""), wxT(""), LIB_EXTENT); etisserant@246: etisserant@246: if(fd.ShowModal() == wxID_OK) etisserant@246: { etisserant@246: drivername->Clear(); etisserant@246: drivername->AppendText(fd.GetPath()); etisserant@246: *textLog << wxT("LibraryPath: ") << fd.GetPath() << wxT("\n"); etisserant@295: strncpy(LibraryPath, fd.GetPath().mb_str(), MAXLENGTH_LIBPATH); etisserant@246: printf("path=%s",LibraryPath); etisserant@246: } etisserant@246: } etisserant@246: etisserant@246: void MyFrame::OnInbt1(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@246: Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x1; etisserant@246: } etisserant@246: void MyFrame::OnInbt2(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@246: Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x2; etisserant@246: } etisserant@246: void MyFrame::OnInbt3(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@246: Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x4; etisserant@246: } etisserant@246: void MyFrame::OnInbt4(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@246: Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x8; etisserant@246: } etisserant@246: void MyFrame::OnInbt5(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@246: Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x10; etisserant@246: } etisserant@246: void MyFrame::OnInbt6(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@246: Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x20; etisserant@246: } etisserant@246: void MyFrame::OnInbt7(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@246: Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x40; etisserant@246: } etisserant@246: void MyFrame::OnInbt8(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@246: Read_Inputs_8_Bit[0] = Read_Inputs_8_Bit[0] ^ 0x80; etisserant@246: } etisserant@246: etisserant@246: etisserant@246: etisserant@246: void MyFrame::OnIns1(wxScrollEvent &event) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[0] = ins1->GetValue(); etisserant@246: inst1->SetValue(ins1->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnIns2(wxScrollEvent &event) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[1] = ins2->GetValue(); etisserant@246: inst2->SetValue(ins2->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnIns3(wxScrollEvent &event) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[2] = ins3->GetValue(); etisserant@246: inst3->SetValue(ins3->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnIns4(wxScrollEvent &event) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[3] = ins4->GetValue(); etisserant@246: inst4->SetValue(ins4->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnIns5(wxScrollEvent &event) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[4] = ins5->GetValue(); etisserant@246: inst5->SetValue(ins5->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnIns6(wxScrollEvent &event) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[5] = ins6->GetValue(); etisserant@246: inst6->SetValue(ins6->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnIns7(wxScrollEvent &event) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[6] = ins7->GetValue(); etisserant@246: inst7->SetValue(ins7->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnIns8(wxScrollEvent &event) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[7] = ins8->GetValue(); etisserant@246: inst8->SetValue(ins8->GetValue()); etisserant@246: } etisserant@246: etisserant@246: etisserant@246: void MyFrame::OnInst1 ( wxSpinEvent &ev ) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[0] = inst1->GetValue(); etisserant@246: ins1->SetValue(inst1->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnInst2 ( wxSpinEvent &ev ) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[1] = inst2->GetValue(); etisserant@246: ins2->SetValue(inst2->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnInst3 ( wxSpinEvent &ev ) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[2] = inst3->GetValue(); etisserant@246: ins3->SetValue(inst3->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnInst4 ( wxSpinEvent &ev ) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[3] = inst4->GetValue(); etisserant@246: ins4->SetValue(inst4->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnInst5 ( wxSpinEvent &ev ) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[4] = inst5->GetValue(); etisserant@246: ins5->SetValue(inst5->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnInst6 ( wxSpinEvent &ev ) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[5] = inst6->GetValue(); etisserant@246: ins6->SetValue(inst6->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnInst7 ( wxSpinEvent &ev ) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[6] = inst7->GetValue(); etisserant@246: ins7->SetValue(inst7->GetValue()); etisserant@246: } etisserant@246: void MyFrame::OnInst8 ( wxSpinEvent &ev ) etisserant@246: { etisserant@246: Read_Analogue_Input_16_Bit[7] = inst8->GetValue(); etisserant@246: ins8->SetValue(inst8->GetValue()); etisserant@246: } etisserant@246: etisserant@246: etisserant@246: void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) etisserant@246: { etisserant@246: wxString msg; etisserant@246: msg.Printf( _T("About.\n\n") etisserant@246: _T("Input-Output simulation by GRANDEMANGE Nicolas for CanFestival!!")); etisserant@246: etisserant@246: wxMessageBox(msg, _T("About !!!"), wxOK | wxICON_INFORMATION, this); etisserant@246: } etisserant@246: etisserant@246: etisserant@246: void MyFrame::OnFreqBoxClick( wxCommandEvent &event ) etisserant@246: { etisserant@246: wxString wxstr; etisserant@246: etisserant@246: wxstr = event.GetString(); etisserant@295: strncpy(SlaveBoard.baudrate, wxstr.mb_str(),MAXLENGTH_BAUDRATE); etisserant@246: *textLog << wxT("Baudrate:") << event.GetString() << wxT("\n"); etisserant@246: } etisserant@246: etisserant@246: static int is_set(int i, etisserant@246: wxListBox *inlist, etisserant@246: wxArrayInt in) etisserant@246: { etisserant@246: inlist->GetSelections(in); etisserant@246: for (int j = 0; j < in.GetCount(); j++) etisserant@246: { etisserant@246: if (i == (in[j] + 1)) etisserant@246: { etisserant@246: return (i); etisserant@246: } etisserant@246: } etisserant@246: return (0); etisserant@246: } etisserant@246: etisserant@246: static int get_bit(UNS8 input, int bit) etisserant@246: { etisserant@302: return input & (((UNS8)1) << bit-1) ? 1 : 0; etisserant@246: } etisserant@246: etisserant@246: void MyFrame::Paint() etisserant@246: { etisserant@246: double vmax = old_max; etisserant@246: double vmin = old_min; etisserant@246: double vdelta = vmax - vmin; etisserant@246: double vech = ((float)vdelta) / 10.0; etisserant@246: etisserant@246: double hmax = frame->echelle->GetValue(); etisserant@246: double hech = hdelta / 11; etisserant@246: etisserant@246: double d = 300 / vdelta; etisserant@246: double g = 0; etisserant@246: double top = 5; etisserant@246: double left = 50; etisserant@246: etisserant@246: double tmpi = 0; etisserant@246: wxString tmps; etisserant@246: double p = 0; etisserant@246: double q = 0; etisserant@246: int i = 0; etisserant@246: int j = 0; lbessard@316: wxColor col[8] = {wxColor(wxT("BLUE")), wxColor(wxT("RED")), wxColor(wxT("GREEN")), wxColor(wxT("GREY")), lbessard@316: wxColor(wxT("ORANGE")), wxColor(wxT("YELLOW")), wxColor(wxT("PINK")), wxColor(wxT("BLACK"))}; etisserant@246: hdelta = hmax - 0; etisserant@246: g = (Gtime / hdelta) * 44.00; etisserant@246: etisserant@246: wxClientDC MonDc(mygraphpan); etisserant@246: MonDc.Clear(); etisserant@246: etisserant@246: MonDc.SetPen(wxPen(wxColour(200,200,200), 5, wxSOLID)); etisserant@246: MonDc.DrawRectangle((int) left, (int)top, 660, 300); etisserant@246: etisserant@246: MonDc.SetPen(wxPen(wxColor(150,200,150), 2, wxSOLID)); etisserant@246: MonDc.SetFont(wxFont(9, wxSWISS , wxNORMAL, wxNORMAL, false, wxT("Arial Black"))); etisserant@246: for (i=0; i < 11; i++) etisserant@246: { etisserant@246: tmpi = (vmin + (vech * i)); etisserant@246: tmps.Printf(wxT("%d"), (int)tmpi); etisserant@246: MonDc.DrawRotatedText(tmps, 0, (int)(293 - (30 * i) + top), 0); etisserant@246: } etisserant@246: for (i=0; i < 12; i++) etisserant@246: { etisserant@246: tmpi = (hech * i * 100); etisserant@246: if (tmpi < 1000) etisserant@246: tmps.Printf(wxT("%ims"), (int)tmpi); etisserant@246: if (tmpi > 1000) etisserant@246: tmps.Printf(wxT("%is"), (int)(tmpi / 1000)); etisserant@246: MonDc.DrawRotatedText(tmps, (int)((60 * i) + left) - 10, (int)(317 + top), 0); etisserant@246: } etisserant@246: for (j=1; j < 10; j++) etisserant@246: MonDc.DrawLine((int)left, (int)(300 - (30 * j) + top), (int)(left + 660), (int)(300 - (30 * j) + top)); etisserant@246: MonDc.SetPen(wxPen(wxColor(150,200,150), 2, wxSOLID)); etisserant@246: for (j=1; j < 22; j++) etisserant@246: MonDc.DrawLine((int)(30 * j + left), (int)(300 + top), (int)(30 * j + left), (int)(top)); etisserant@246: MonDc.SetPen(wxPen(wxColor(150,170,150), 1, wxSOLID)); etisserant@246: for (j=1; j < 22; j++) etisserant@246: MonDc.DrawLine((int)(30 * j + left - 15), (int)(300 + top), (int)(30 * j + left - 15), (int)(top)); etisserant@246: MonDc.DrawLine((int)(30 * 22 + left - 15), (int)(300 + top), (int)(30 * 22 + left - 15), (int)(top)); etisserant@246: etisserant@246: double m = (- vmin) * d; etisserant@246: MonDc.SetPen(wxPen(wxColor(170,170,150), 3, wxSOLID)); etisserant@246: MonDc.DrawLine((int)(left), (int)(300 + top - m), (int)(left + 660), (int)(300 + top - m)); etisserant@246: etisserant@246: wxClientDC MaLeg(mylegpan); etisserant@246: MaLeg.Clear(); etisserant@246: etisserant@246: MaLeg.SetPen(wxPen(wxColour(150,200,100), 2, wxSOLID)); etisserant@246: MaLeg.SetFont(wxFont(7, wxSWISS , wxNORMAL, wxNORMAL, false, wxT("Arial Black"))); etisserant@246: for (int k=1, tmpi = 0; k < 30; k++) etisserant@246: { etisserant@246: if ((tmpi < 8) && is_set(k, inlist, in)) etisserant@246: { etisserant@246: if (k <= 4) etisserant@246: tmps.Printf(wxT("Analogue Output %d"), k); etisserant@246: if ((k > 4) && (k <= 12)) etisserant@246: tmps.Printf(wxT("Bool Output %d"), k - 4); etisserant@246: if ((k > 12) && (k <= 20)) etisserant@246: tmps.Printf(wxT("Analogue Input %d"), k - 12); etisserant@246: if ((k > 20) && (k <= 28)) etisserant@246: tmps.Printf(wxT("Bool Input %d"), k - 20); etisserant@246: etisserant@246: MaLeg.DrawRotatedText(tmps, 0, 10 * tmpi , 0); etisserant@246: MaLeg.SetPen(wxPen(col[tmpi], 4, wxSOLID)); etisserant@246: MaLeg.DrawLine(100, 10 * tmpi + 6, 115, 10 * tmpi + 6); etisserant@246: //////////////////////////////////////////DAW//////////////////////////////////////// etisserant@246: MonDc.SetPen(wxPen(col[tmpi], 4, wxSOLID)); etisserant@246: if (k <= 4) etisserant@246: y[k - 1][(int)g] = Write_Analogue_Output_16_Bit[k - 1]; etisserant@246: if ((k > 4) && (k <= 12)) etisserant@246: y[k - 1][(int)g] = get_bit(Write_Outputs_8_Bit[0] ,k - 4); etisserant@246: if ((k > 12) && (k <= 20)) etisserant@246: y[k - 1][(int)g] = Read_Analogue_Input_16_Bit[k - 1 -12]; etisserant@246: if ((k > 20) && (k <= 28)) etisserant@246: y[k - 1][(int)g] = get_bit(Read_Inputs_8_Bit[0] ,k - 20); etisserant@246: etisserant@246: if (y[k - 1][(int)g] > old_max) etisserant@246: old_max = y[k - 1][(int)g]; etisserant@246: if (y[k - 1][(int)g] < old_min) etisserant@246: old_min = y[k - 1][(int)g]; etisserant@246: for (j=1; j < (g + 1) ; j++) etisserant@246: { etisserant@246: p = (y[k - 1][j - 1] - vmin) * d; etisserant@246: q = (y[k - 1][j ] - vmin) * d; etisserant@246: MonDc.DrawLine((int)(15 * (j - 1) + left), (int)(300 + top - p), (int)(15 * j + left), (int)(300 + top - q)); etisserant@246: } etisserant@246: ///////////////////////////////////////////////////////////////////////////////////// etisserant@246: tmpi++; etisserant@246: } etisserant@246: } etisserant@246: } etisserant@246: etisserant@246: void actu_output(void) etisserant@246: { etisserant@246: wxString tmp; etisserant@246: etisserant@246: frame->outbt1->SetValue(get_bit(Write_Outputs_8_Bit[0], 1)); etisserant@246: frame->outbt2->SetValue(get_bit(Write_Outputs_8_Bit[0], 2)); etisserant@246: frame->outbt3->SetValue(get_bit(Write_Outputs_8_Bit[0], 3)); etisserant@246: frame->outbt4->SetValue(get_bit(Write_Outputs_8_Bit[0], 4)); etisserant@246: frame->outbt5->SetValue(get_bit(Write_Outputs_8_Bit[0], 5)); etisserant@246: frame->outbt6->SetValue(get_bit(Write_Outputs_8_Bit[0], 6)); etisserant@246: frame->outbt7->SetValue(get_bit(Write_Outputs_8_Bit[0], 7)); etisserant@246: frame->outbt8->SetValue(get_bit(Write_Outputs_8_Bit[0], 8)); etisserant@246: etisserant@246: frame->outs1->SetValue(Write_Analogue_Output_16_Bit[0] + 32768); etisserant@246: frame->outs2->SetValue(Write_Analogue_Output_16_Bit[1] + 32768); etisserant@246: frame->outs3->SetValue(Write_Analogue_Output_16_Bit[2] + 32768); etisserant@246: frame->outs4->SetValue(Write_Analogue_Output_16_Bit[3] + 32768); etisserant@246: tmp.Printf(wxT(" %i"), Write_Analogue_Output_16_Bit[0]); etisserant@246: frame->outst1->SetLabel(tmp); etisserant@246: tmp.Printf(wxT(" %i"), Write_Analogue_Output_16_Bit[1]); etisserant@246: frame->outst2->SetLabel(tmp); etisserant@246: tmp.Printf(wxT(" %i"), Write_Analogue_Output_16_Bit[2]); etisserant@246: frame->outst3->SetLabel(tmp); etisserant@246: tmp.Printf(wxT(" %i"), Write_Analogue_Output_16_Bit[3]); etisserant@246: frame->outst4->SetLabel(tmp); etisserant@246: } etisserant@246: etisserant@246: void actu(void) etisserant@246: { etisserant@246: actu_output(); etisserant@246: etisserant@246: Gtime++; etisserant@246: if (Gtime > hdelta) etisserant@246: { etisserant@246: old_max = 5; etisserant@246: old_min = -5; etisserant@246: Gtime = 0; etisserant@246: } etisserant@246: frame->Paint(); etisserant@246: } etisserant@246: etisserant@246: void MyFrame::OnTimer(wxTimerEvent& event) etisserant@246: { etisserant@246: actu();// do whatever you want to do every second here etisserant@246: } etisserant@246: etisserant@246: void MyFrame::OnPaint( wxPaintEvent &event ) etisserant@246: { etisserant@246: //Paint(); etisserant@246: }