bool SetupAppEnvironment() { std::string user = getenv("USER"); std::string shostname = ExecuteShellCommand("echo `hostname`"); shostname = Globals.Trim(shostname); // Save properties in setup Globals._appproperties["user"]= user; Globals._appproperties["hostname"]= shostname; return true; }
std::string ReadRosParams(ros::NodeHandle &nh) { std::stringstream result; std::string cmd = "/opt/ros/indigo/bin/rosparam list "; std::string params = ExecuteShellCommand(cmd); // std::string rvizid = RvizId(params, Globals._appproperties["hostname"]); // Globals._appproperties["rvizid"]= rvizid; std::vector<std::string> lines = Split(params, '\n'); for (size_t i = 0; i < lines.size(); i++) { lines[i] = Globals.Trim(lines[i]); if (lines[i].empty()) continue; std::string param = ReadRosParam(nh, lines[i]); if (!param.empty()) { result << lines[i] << "=" << param.c_str() << std::endl; } } return result.str(); }
bool SetupRosEnvironment(std::string pkgpath) { #if 1 //std::string rosdistro = getenv ("ROS_DISTRO"); // suppose we could just copy all the environment variables //std::string user = Globals._appproperties["user"]; //std::cout << "user="******"/bin/bash -i /usr/local/michalos/nistfanuc_ws/devel/lib/nist_fanuc/rossetup.bash "); std::cout << "cmd=" << cmd.c_str() << std::endl; #else // pkgpath=pkgpath+"/scripts/rossetup.bash" pkgpath = pkgpath + "/../../devel/setup.bash"; std::cout << "pkgpath=" << pkgpath.c_str() << std::endl; std::string cmd = Globals.StrFormat("/bin/bash -i %s && env\n", pkgpath.c_str()); std::cout << "cmd=" << cmd.c_str() << std::endl; #endif std::string envs = ExecuteShellCommand(cmd); std::cout << "envs=" << envs.c_str() << std::endl; std::map<std::string, std::string> envvars = ParseIniString(envs); for (std::map<std::string, std::string>::iterator it = envvars.begin(); it != envvars.end(); it++) { // std::cout << (*it).first.c_str() << "=" <<(*it).second.c_str()<< std::endl; SetupRosEnv((*it).first, (*it).second); } return true; }
BOOL CCmdDlg::PreTranslateMessage(MSG* pMsg) { CString strCmd; if (pMsg->message == WM_KEYDOWN) { // 屏蔽VK_ESCAPE、VK_DELETE if (pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_DELETE) return true; if (pMsg->wParam == VK_RETURN && pMsg->hwnd == m_editResult.m_hWnd) { int len = m_editResult.GetWindowTextLength(); CString strText; m_editResult.GetWindowText(strText); strCmd = strText.GetBuffer() + m_strResult.GetLength(); strCmd.TrimLeft(); strCmd.TrimRight(); strText += _T("\r\n"); if (0 == strCmd.CompareNoCase(_T("exit"))) { OnBnClickedButtonClose(); return true; } else if (0 == strCmd.CompareNoCase(_T("cls"))) { m_strResult = _T("\r\n")+m_strResult.Right(m_strResult.GetLength()-m_strResult.ReverseFind('\n')-1); SetDlgItemText(IDC_EDIT_RESULT,m_strResult); return true; } else { if (IsDisable(strCmd)) { AfxMessageBox(_T("Don't use the string!")); } else { ExecuteShellCommand(m_clientid, strCmd); m_editResult.SetSel(-1); } } m_nCurSel = m_editResult.GetWindowTextLength(); } // 限制VK_BACK if (pMsg->wParam == VK_BACK && pMsg->hwnd == m_editResult.m_hWnd) { if (m_editResult.GetWindowTextLength() <= m_strResult.GetLength()) return true; else { CString strText; GetDlgItemText(IDC_EDIT_RESULT,strText); strText.Left(strText.GetLength()-1); SetDlgItemText(IDC_EDIT_RESULT,strText); UpdateData(TRUE); } } } // Ctrl没按下 if (pMsg->message == WM_CHAR && GetKeyState(VK_CONTROL) >= 0) { int nSize = m_editResult.GetWindowTextLength(); m_editResult.SetSel(nSize, nSize); // 用户删除了部分内容,改变m_nCurSel if (nSize < m_nCurSel) m_nCurSel = nSize; } return __super::PreTranslateMessage(pMsg); }