From 02fab0d388e4488edd27b6823cb301c6392df167 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Fri, 21 Nov 2014 21:59:26 +0100 Subject: [PATCH] =?UTF-8?q?term=20hal=20kompatibilit=C3=A4t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- term/mainframe.cpp | 43 ++++++++++++++++++------------------------- term/mainframe.hpp | 2 +- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/term/mainframe.cpp b/term/mainframe.cpp index a0637af2..d706286f 100644 --- a/term/mainframe.cpp +++ b/term/mainframe.cpp @@ -51,20 +51,10 @@ MainFrame::MainFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title){ topsizer->Add(drawpanel, 1,wxEXPAND,0); wxArrayString waves; waves.push_back("-"); - waves.push_back("error"); - waves.push_back("error_d"); - waves.push_back("error_dd"); - waves.push_back("soll_pos"); - waves.push_back("pid.cmd_d"); - waves.push_back("pid.cmd_dd"); - waves.push_back("ist"); - waves.push_back("feedbackv"); - waves.push_back("voltage_scale"); - waves.push_back("saturated_count"); - waves.push_back("mag_pos"); - waves.push_back("startpos"); - waves.push_back("res_offset"); - waves.push_back("time"); + waves.push_back("net0.cmd"); + waves.push_back("net0.fb"); + waves.push_back("pid0.pwm_cmd"); + waves.push_back("pos_minus0.out"); //channels channelstartID = currentID-1;//next ID @@ -142,16 +132,16 @@ void MainFrame::OnKeyDown(wxKeyEvent& event){ void MainFrame::OnChannelChange(wxCommandEvent& event){ int param = (event.GetId()-channelstartID-2)%3; - int channel = (int)((event.GetId()-channelstartID-2)/3)+1; - string params[] = {"wave","offset","gain"}; - float value = 0; + int channel = (int)((event.GetId()-channelstartID-2)/3); + string params[] = {"term0.wave","term0.offset","term0.gain"}; + wxString value; switch (param) { case 0://wave - value = event.GetSelection(); + value = event.GetSelection()==0?"0":event.GetString(); break; case 1://offset case 2://gain - value = (float)event.GetSelection()/10.0f; + value = to_string(event.GetSelection()/10.0f); break; default: break; @@ -161,16 +151,19 @@ void MainFrame::OnChannelChange(wxCommandEvent& event){ string df = params[param]; df += to_string(channel); df += " = "; - df += to_string(value); + df += value; send(df); } -void MainFrame::send(string& s){ +void MainFrame::send(string& s,bool h){ + cout << s << endl; if(connected){ - if((history.size()==0 || history.back() != s) && !s.empty()){ - history.push_back(s); + if(h){//history + if((history.size()==0 || history.back() != s) && !s.empty()){ + history.push_back(s); + } + histpos = history.size(); } - histpos = history.size(); int ret1 = sp_nonblocking_write(port, s.c_str(), s.length()); int ret2 = sp_nonblocking_write(port, "\r", 1); if(ret1 != s.length() || ret2!=1){ @@ -292,6 +285,6 @@ void MainFrame::disconnect(){ void MainFrame::OnInput(wxCommandEvent& event){ string s =string(textinput->GetValue().mb_str()); - send(s); + send(s,true); textinput->Clear(); } diff --git a/term/mainframe.hpp b/term/mainframe.hpp index fd606bed..2c03c4c3 100644 --- a/term/mainframe.hpp +++ b/term/mainframe.hpp @@ -44,7 +44,7 @@ private: void OnGainChange(wxCommandEvent& event); void OnKeyDown(wxKeyEvent& event); void OnIdle(wxIdleEvent& evt); - void send(std::string& s); + void send(std::string& s,bool h = false); void connect(); void disconnect(); void listports();