| 866 | } |
| 867 | |
| 868 | std::string AgentSML::ExecuteCommandLine(std::string const& commandLine) |
| 869 | { |
| 870 | KernelSML* pKernel = m_pKernelSML ; |
| 871 | |
| 872 | // We'll pretend this came from the local (embedded) connection. |
| 873 | Connection* pConnection = pKernel->GetEmbeddedConnection() ; |
| 874 | |
| 875 | // Build up a message to execute the command line |
| 876 | bool rawOutput = true ; |
| 877 | soarxml::ElementXML* pMsg = pConnection->CreateSMLCommand(sml_Names::kCommand_CommandLine, rawOutput) ; |
| 878 | pConnection->AddParameterToSMLCommand(pMsg, sml_Names::kParamAgent, this->GetName()); |
| 879 | pConnection->AddParameterToSMLCommand(pMsg, sml_Names::kParamLine, commandLine.c_str()) ; |
| 880 | |
| 881 | AnalyzeXML incoming ; |
| 882 | incoming.Analyze(pMsg) ; |
| 883 | |
| 884 | // Create a response object which the command line can fill in |
| 885 | soarxml::ElementXML* pResponse = pConnection->CreateSMLResponse(pMsg) ; |
| 886 | |
| 887 | // Execute the command line |
| 888 | bool ok = pKernel->ProcessCommand(sml_Names::kCommand_CommandLine, pConnection, &incoming, pResponse) ; |
| 889 | |
| 890 | std::string result ; |
| 891 | |
| 892 | if (ok) |
| 893 | { |
| 894 | // Take the result from executing the command line and fill it in to our "pReturnValue" array. |
| 895 | AnalyzeXML response ; |
| 896 | response.Analyze(pResponse) ; |
| 897 | |
| 898 | char const* pRes = response.GetResultString() ; |
| 899 | |
| 900 | if (pRes) |
| 901 | { |
| 902 | result = pRes ; |
| 903 | } |
| 904 | } |
| 905 | else |
| 906 | { |
| 907 | result = std::string("Error executing command ") + commandLine ; |
| 908 | } |
| 909 | |
| 910 | // Clean up |
| 911 | delete pMsg ; |
| 912 | delete pResponse ; |
| 913 | |
| 914 | return result ; |
| 915 | } |
| 916 | |
| 917 | bool AgentSML::AddInputWME(char const* pID, char const* pAttribute, Symbol* pValueSymbol, int64_t clientTimeTag) |
| 918 | { |