void R3DSurfaceGenProcess::runSingleCommand()
{
	if(!cmds_.IsEmpty())
	{
		Redirect();	// Redirect I/O, hide console window

		wxString cmdLine = cmds_[0];
		cmds_.RemoveAt(0);
		wxString progressText = progressTexts_[0];
		progressTexts_.RemoveAt(0);
		pMainFrame_->sendUpdateProgressBarEvent(-1.0f, progressText);

		// Cleanup
		if(GetInputStream() != NULL)
			delete GetInputStream();
		if(GetErrorStream() != NULL)
			delete GetErrorStream();
		if(GetOutputStream() != NULL)
			delete GetOutputStream();
		SetPipeStreams(NULL, NULL, NULL);
#if wxCHECK_VERSION(2, 9, 0)
		processId_ = wxExecute(cmdLine, wxEXEC_ASYNC, this, &env_);
#else
		processId_ = wxExecute(cmdLine, wxEXEC_ASYNC, this);
#endif
	}
}
示例#2
0
LineReaderPtr& PopSession::GetLineReader()
{
	if(m_lineReader.get() == NULL)
		m_lineReader.reset(new LineReader(GetInputStream()));

	return m_lineReader;
}
示例#3
0
wxThread::ExitCode wxGISProcess::Entry()
{
    // IMPORTANT:
    // this function gets executed in the secondary thread context!

    // here we do our long task, periodically calling TestDestroy():

    //wxTextInputStream (wxInputStream &stream, const wxString &sep=" \t", const wxMBConv &conv=wxConvAuto())
    wxInputStream &InStream = *GetInputStream();
	wxTextInputStream InputStr(InStream, wxT(" \t"), *wxConvCurrent);
	while(!GetThread()->TestDestroy())
    {
        if(InStream.Eof())
            break;
        if(InStream.IsOk() && InStream.CanRead())
        {
		    wxString line = InputStr.ReadLine();
		    ProcessInput(line);
        }
		wxThread::Sleep(READ_LINE_DELAY);
    }

    // TestDestroy() returned true (which means the main thread asked us
    // to terminate as soon as possible) or we ended the long task...
    return (wxThread::ExitCode)wxTHREAD_NO_ERROR;
}
示例#4
0
XnStatus PrimeClient::OpenFWLogFile(XnUInt8 logID)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	//If no stream started, start it
	if (m_nFWLogStreamID == XN_LINK_STREAM_ID_NONE)
	{
		nRetVal = StartFWLog();
		XN_IS_STATUS_OK_LOG_ERROR("Start FWLog stream", nRetVal);
	}

	//Get FW Log input stream
	LinkInputStream* pFWLogStream = GetInputStream(m_nFWLogStreamID);
	if (pFWLogStream == NULL)
	{
		xnLogError(XN_MASK_PRIME_CLIENT, "FW log input stream is NULL?!");
		XN_ASSERT(FALSE);
		return XN_STATUS_ERROR;
	}
	
	//Open the log file
	nRetVal = m_linkControlEndpoint.OpenFWLogFile(logID, pFWLogStream->GetStreamID());

	return nRetVal;
}
示例#5
0
bool PipedProcess::HasInput()
{
    if (IsErrorAvailable())
    {
        cbTextInputStream serr(*GetErrorStream());

        wxString msg;
        msg << serr.ReadLine();

		CodeBlocksEvent event(cbEVT_PIPEDPROCESS_STDERR, m_Id);
        event.SetString(msg);
		wxPostEvent(m_Parent, event);
// 		m_Parent->ProcessEvent(event);

        return true;
    }

    if (IsInputAvailable())
    {
        cbTextInputStream sout(*GetInputStream());

        wxString msg;
        msg << sout.ReadLine();

		CodeBlocksEvent event(cbEVT_PIPEDPROCESS_STDOUT, m_Id);
        event.SetString(msg);
		wxPostEvent(m_Parent, event);
// 		m_Parent->ProcessEvent(event);

        return true;
    }

    return false;
}
MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode(AudioContext* aContext)
  : AudioNode(aContext,
              2,
              ChannelCountMode::Explicit,
              ChannelInterpretation::Speakers)
  , mDOMStream(
      DOMAudioNodeMediaStream::CreateTrackUnionStreamAsInput(GetOwner(),
                                                             this,
                                                             aContext->Graph()))
{
  // Ensure an audio track with the correct ID is exposed to JS
  nsIDocument* doc = aContext->GetParentObject()->GetExtantDoc();
  RefPtr<MediaStreamTrackSource> source =
    new AudioDestinationTrackSource(this, doc->NodePrincipal());
  RefPtr<MediaStreamTrack> track =
    mDOMStream->CreateDOMTrack(AudioNodeStream::AUDIO_TRACK,
                               MediaSegment::AUDIO, source,
                               MediaTrackConstraints());
  mDOMStream->AddTrackInternal(track);

  ProcessedMediaStream* outputStream = mDOMStream->GetInputStream()->AsProcessedStream();
  MOZ_ASSERT(!!outputStream);
  AudioNodeEngine* engine = new AudioNodeEngine(this);
  mStream = AudioNodeStream::Create(aContext, engine,
                                    AudioNodeStream::EXTERNAL_OUTPUT,
                                    aContext->Graph());
  mPort = outputStream->AllocateInputPort(mStream, AudioNodeStream::AUDIO_TRACK);
}
示例#7
0
bool PipedProcess::ReadAll(wxString &input)
{
	bool hasInput = false;
	bool cont1(true), cont2(true);

	wxTextInputStream tis(*GetInputStream());
	wxTextInputStream tie(*GetErrorStream());
	while(cont1 || cont2){
		cont1 = false;
		cont2 = false;
		while( IsInputAvailable() )
		{
			// this assumes that the output is always line buffered
			wxChar ch = tis.GetChar();
			input << ch;
			hasInput = true;
			cont1 = true;
		}

		while( IsErrorAvailable() )
		{
			// this assumes that the output is always line buffered
			wxChar ch = tie.GetChar();
			input << ch;
			hasInput = true;
			cont2 = true;
		}
	}
	return hasInput;
}
示例#8
0
XnStatus PrimeClient::CloseFWLogFile(XnUInt8 logID)
{
	XnStatus nRetVal = XN_STATUS_OK;

	//If no stream started, something is wrong
	if (m_nFWLogStreamID == XN_LINK_STREAM_ID_NONE)
	{
		xnLogError(XN_MASK_PRIME_CLIENT, "No FW log input stream");
		XN_ASSERT(FALSE);
		return XN_STATUS_ERROR;
	}

	//Get FW Log input stream
	LinkInputStream* pFWLogStream = GetInputStream(m_nFWLogStreamID);
	if (pFWLogStream == NULL)
	{
		xnLogError(XN_MASK_PRIME_CLIENT, "FW log input stream is NULL?!");
		XN_ASSERT(FALSE);
		return XN_STATUS_ERROR;
	}

	//Close the log file
	nRetVal = m_linkControlEndpoint.CloseFWLogFile(logID, pFWLogStream->GetStreamID());

	return nRetVal;
}
示例#9
0
void CPyProcess::HandleInput(void) {
	wxInputStream *m_in, *m_err;

	m_in = GetInputStream();
	m_err = GetErrorStream();

	if (m_in) {
		wxString s;
		while (m_in->CanRead()) {
			char buffer[4096];
			m_in->Read(buffer, sizeof(buffer));
			s += wxString::From8BitData(buffer, m_in->LastRead());
		}
		if (s.Length() > 0) {
			wxLogMessage(_T("> %s"), s.c_str());
		}
	}
	if (m_err) {
		wxString s;
		while (m_err->CanRead()) {
			char buffer[4096];
			m_err->Read(buffer, sizeof(buffer));
			s += wxString::From8BitData(buffer, m_err->LastRead());
		}
		if (s.Length() > 0) {
			wxLogMessage(_T("! %s"), s.c_str());
		}
	}
}
示例#10
0
bool MarkdownProcess::HasInput()
{
    bool hasInput = false;

    if ( IsInputAvailable() )
    {
        wxTextInputStream tis(*GetInputStream());

        // this assumes that the output is always line buffered
		m_file << tis.ReadLine() << wxT("\n");

//        m_parent->GetLogListBox()->Append(msg);

        hasInput = true;
    }

    if ( IsErrorAvailable() )
    {
        wxTextInputStream tis(*GetErrorStream());

        // this assumes that the output is always line buffered
		wxMessageBox(tis.ReadLine());
        hasInput = true;
    }

    return hasInput;
}
示例#11
0
文件: stream.cpp 项目: hgwells/tive
char wxStreamBuffer::GetChar()
{
    wxInputStream *inStream = GetInputStream();

    wxCHECK_MSG( inStream, 0, _T("should have a stream in wxStreamBuffer") );

    char c;
    if ( !HasBuffer() )
    {
        inStream->OnSysRead(&c, sizeof(c));
    }
    else
    {
        if ( !GetDataLeft() )
        {
            SetError(wxSTREAM_READ_ERROR);
            c = 0;
        }
        else
        {
            GetFromBuffer(&c, sizeof(c));
            m_stream->m_lastcount = 1;
        }
    }

    return c;
}
示例#12
0
void R3DSurfaceGenProcess::readConsoleOutput()
{
	wxInputStream *pIn = GetInputStream();
	if(pIn != NULL)
	{
		std::string buf;
		while(pIn->CanRead())
		{
			int curc = pIn->GetC();
			if(curc != wxEOF)
				buf.push_back( static_cast<char>(curc) );
		}

		MLOG << buf.c_str();
	}
	wxInputStream *pErr = GetErrorStream();
	if(pErr != NULL)
	{
		std::string buf;
		while(pErr->CanRead())
		{
			int curc = pErr->GetC();
			if(curc != wxEOF)
				buf.push_back( static_cast<char>(curc) );
		}

		MLOG << buf.c_str();
	}
}
示例#13
0
XnStatus PrimeClient::StopFWLog()
{
    XnStatus nRetVal = XN_STATUS_OK;
    if (m_nFWLogStreamID != XN_LINK_STREAM_ID_NONE)
    {
        //Get FW Log input stream
        LinkInputStream* pFWLogStream = GetInputStream(m_nFWLogStreamID);
        if (pFWLogStream == NULL)
        {
            xnLogError(XN_MASK_PRIME_CLIENT, "FW log input stream is NULL?!");
            XN_ASSERT(FALSE);
            return XN_STATUS_ERROR;
        }

        //Stop stream
        nRetVal = pFWLogStream->Stop();           
        XN_IS_STATUS_OK_LOG_ERROR("Stop FW log stream", nRetVal);

        //Destroy stream
        nRetVal = DestroyInputStream(m_nFWLogStreamID);
        XN_IS_STATUS_OK_LOG_ERROR("Destroy input stream", nRetVal);
        //Mark stream as unused
        m_nFWLogStreamID = XN_LINK_STREAM_ID_NONE;
    }
    return XN_STATUS_OK;
}
示例#14
0
文件: stream.cpp 项目: hgwells/tive
size_t wxStreamBuffer::Read(void *buffer, size_t size)
{
    wxASSERT_MSG( buffer, _T("Warning: Null pointer is about to be used") );

    /* Clear buffer first */
    memset(buffer, 0x00, size);

    // lasterror is reset before all new IO calls
    if ( m_stream )
        m_stream->Reset();

    size_t readBytes;
    if ( !HasBuffer() )
    {
        wxInputStream *inStream = GetInputStream();

        wxCHECK_MSG( inStream, 0, _T("should have a stream in wxStreamBuffer") );

        readBytes = inStream->OnSysRead(buffer, size);
    }
    else // we have a buffer, use it
    {
        size_t orig_size = size;

        while ( size > 0 )
        {
            size_t left = GetDataLeft();

            // if the requested number of bytes if greater than the buffer
            // size, read data in chunks
            if ( size > left )
            {
                GetFromBuffer(buffer, left);
                size -= left;
                buffer = (char *)buffer + left;

                if ( !FillBuffer() )
                {
                    SetError(wxSTREAM_EOF);
                    break;
                }
            }
            else // otherwise just do it in one gulp
            {
                GetFromBuffer(buffer, size);
                size = 0;
            }
        }

        readBytes = orig_size - size;
    }

    if ( m_stream )
        m_stream->m_lastcount = readBytes;

    return readBytes;
}
示例#15
0
    void OnTerminate(int WXUNUSED(pid), int status)
    {
        wxStringOutputStream out, err;
        if (GetInputStream()) out.Write(*GetInputStream());
        if (GetErrorStream()) err.Write(*GetErrorStream());

        //wxPrintf("%s\n", stdout.GetString());
        //wxPrintf("%s\n", stderr.GetString());

        // when wx programs assert on wxGTK/wxMac, they put on stderr a message like:
        //    [Debug] date somefilename.pp(nnnn): assert "xxxxx" failed in yyyy
        // but then the assert dialog pop-ups and thus the app doesn't exit
        // FIXME: make assertion detection work also under other platforms
        //        see http://trac.wxwidgets.org/ticket/10697
        m_crashed = out.GetString().Contains("assert") ||
                    err.GetString().Contains("assert");
        m_exitCode = status;
    }
示例#16
0
void processManager::LogOutput(bool &hasOutput, const wxString &label,float *outputProgression)
{
    hasOutput = false;

    if ( IsInputAvailable() )
    {
        wxTextInputStream tis(*GetInputStream());

        // this assumes that the output is always line buffered
        wxString msg;
        wxString output= tis.ReadLine();
        if(!this->outlogs.empty())
        {
            for(std::vector<smart_ptr<InterfLogger> >::iterator itlogs=this->outlogs.begin(); itlogs!=this->outlogs.end(); itlogs++)
            {
                (*(*itlogs)).LogMessage(output);
            }
        }
        if(outputProgression==NULL || output.Left(1)!="#")
        {
            msg << label << output;
            msg.Replace("%","%%"); //si il y a un seul % alors un bug apparait wxString attend un format du type %s ou %i par exemple
            if(output.Left(1)=="!")
            {
                wxLogWarning(msg);
            } else {
                wxLogMessage(msg);
            }
        } else {
            wxString prog=output.Right(output.Len()-1).Strip();
            *outputProgression=Convertor::ToFloat(prog);
        }

        hasOutput = true;
    }

    while ( IsErrorAvailable() )
    {
        wxTextInputStream tis(*GetErrorStream());
        const wxString& errMsg(tis.ReadLine());
        if(!this->outlogs.empty())
        {
            for(std::vector<smart_ptr<InterfLogger> >::iterator itlogs=this->outlogs.begin(); itlogs!=this->outlogs.end(); itlogs++)
            {
                (*(*itlogs)).LogError(errMsg);
            }
        }
        // this assumes that the output is always line buffered
        wxString msg;
        msg << _("Erreur exécutable :") << errMsg;
        msg.Replace("%","%%"); //si il y a un seul % alors un bug apparait wxString attend un format du type %s ou %i par exemple
        wxLogError(msg);

        hasOutput = true;
    }
}
示例#17
0
size_t nwxProcess::ProcessIO(size_t nLimit)
{
  size_t nRtn = 0;
  bool bInputClosed = false;
  if(!m_bPaused)
  {
    if(!IsInputOpened())
    {
      if(m_sBuffer.Len())
      {
        m_sBuffer += "\n";
        ProcessLine(m_sBuffer.utf8_str(),m_sBuffer.Len(),false);
        m_sBuffer.Empty();
      }
      bInputClosed = true;
    }
    else 
    {
      while(IsInputAvailable() && (nRtn < nLimit))
      {
        nRtn += ProcessIO(GetInputStream(),m_sBuffer,false);
      }
    }
    if(!IsErrorOpened())
    {
      if(m_sBufferError.Len())
      {
        m_sBufferError += "\n";
        ProcessLine(m_sBufferError.utf8_str(),m_sBufferError.Len(),true);
        m_sBufferError.Empty();
      }
      if(bInputClosed && m_bRunning)
      {
    	  m_bRunning = false;
    	      // we are sometimes not notified when process ends
#ifndef __WXMSW__
    	  // need to clean up zombie because wx sometimes
    	  // fails to do this on the macintosh
    	  int nStatLoc;
    	  pid_t nPID;
    	  nPID = waitpid((pid_t)m_nPID,&nStatLoc,0);
    	  OnTerminate(m_nPID,nStatLoc);
#endif
      }
    }
    else 
    {
      while(IsErrorAvailable() && (nRtn < nLimit))
      {
        nRtn += ProcessIO(GetErrorStream(),m_sBufferError,true);
      }
    }
  }
  return nRtn;
}
示例#18
0
/*----------------------------------------------------------------------
|   PLT_HttpServerSocketTask::DoRun
+---------------------------------------------------------------------*/
void
PLT_HttpServerSocketTask::DoRun()
{
    NPT_BufferedInputStreamReference buffered_input_stream;
    NPT_HttpRequestContext           context;
    NPT_Result                       res = NPT_SUCCESS;
    bool                             headers_only;
    bool                             keep_alive = false;

    // create a buffered input stream to parse HTTP request
    NPT_InputStreamReference input_stream;
    NPT_CHECK_LABEL_SEVERE(GetInputStream(input_stream), done);
    NPT_CHECK_POINTER_LABEL_FATAL(input_stream.AsPointer(), done);
    buffered_input_stream = new NPT_BufferedInputStream(input_stream);

    while (!IsAborting(0)) {
        NPT_HttpRequest*  request = NULL;
        NPT_HttpResponse* response = NULL;

        // reset keep-alive to exit task on read failure
        keep_alive = false;

        // wait for a request
        res = Read(buffered_input_stream, request, &context);
        if (NPT_FAILED(res) || (request == NULL)) 
            goto cleanup;
        
        // process request and setup response
        res = RespondToClient(*request, context, response);
        if (NPT_FAILED(res) || (response == NULL)) 
            goto cleanup;

        // check if client requested keep-alive
        keep_alive = PLT_HttpHelper::IsConnectionKeepAlive(*request);
        headers_only = request->GetMethod() == NPT_HTTP_METHOD_HEAD;

        // send response, pass keep-alive request from client
        // (it can be overridden if response handler did not allow it)
        res = Write(response, keep_alive, headers_only);

        // on write error, reset keep_alive so we can close this connection
        if (NPT_FAILED(res)) keep_alive = false;

cleanup:
        // cleanup
        delete request;
        delete response;

        if (!keep_alive && !m_StayAliveForever) {
            return;
        }
    }
done:
    return;
}
示例#19
0
/*----------------------------------------------------------------------
|   NPT_File::Load
+---------------------------------------------------------------------*/
NPT_Result
NPT_File::Load(NPT_DataBuffer& buffer)
{
    NPT_InputStreamReference input;

    // get the input stream for the file
    NPT_CHECK_FATAL(GetInputStream(input));

    // read the stream
    return input->Load(buffer);
}
示例#20
0
void CamProcess::OnTerminate(int /*TYPENOTE: Correct*/ pid, int /*TYPENOTE: Correct*/ status)
{
//	TRACEUSER("Gerry", _T("CamProcess::OnTerminate pid = %d  status = %d"), pid, status);
	m_bDead = true;
	m_ReturnCode = status;

	// Process anything remaining on stderr and stdout
	// If we have an output file
	if (m_pOutFile)
	{
		// If there is output from the process
		if (IsInputAvailable())
		{
			// Copy the data to the file
			size_t NumRead = 4096;
			BYTE Buffer[4096];

			while (NumRead > 0)
			{
				// Read a buffer full
				GetInputStream()->Read(Buffer, 4096);

				NumRead = GetInputStream()->LastRead();

				// Write the buffer to the file
				if (NumRead > 0)
				{
					m_pOutFile->write(Buffer, NumRead);
				}
			}
		}
	}
	else
	{
		// Call the virtual function to process the output
		ProcessStdOut();
	}

	ProcessStdErr();
}
示例#21
0
void PipedProcess::ForfeitStreams()
{
    char buf[4096];
    if (IsErrorAvailable())
    {
        wxInputStream *in = GetErrorStream();
        while(in->Read(&buf, sizeof(buf)).LastRead())
            ;
    }
    if (IsInputAvailable())
    {
        wxInputStream *in = GetInputStream();
        while(in->Read(&buf, sizeof(buf)).LastRead())
            ;
    }
}
示例#22
0
void CamProcess::ProcessStdOut()
{
	if (IsInputAvailable())
	{
		wxTextInputStream tis(*GetInputStream());

		// This assumes that the output is always line buffered
		while (IsInputAvailable())
		{
			wxString line;
			line << tis.ReadLine();
//			TRACEUSER("Gerry", _T("(stdout):%s"), line.c_str());
		}
	}

}
ECode CDropBoxManagerEntry::GetText(
    /* [in] */ Int32 maxBytes,
    /* [out] */ String* text)
{
    VALIDATE_NOT_NULL(text);
    if ((mFlags & IDropBoxManager::IS_TEXT) == 0) {
        *text = String(NULL);
        return NOERROR;
    }
    if (mData != NULL) {
        StringBuilder sb("");
        for (Int32 i = 0; i < Elastos::Core::Math::Min(maxBytes, mData->GetLength()); i++) {
            sb += (Char32)((*mData)[i]);
        }
        *text = sb.ToString();
        return NOERROR;
    }

    AutoPtr<IInputStream> is = NULL;
    //try {
    GetInputStream((IInputStream**)&is);
    if (is == NULL) {
        *text = String(NULL);
        return NOERROR;
    }
    AutoPtr<ArrayOf<Byte> > buf = ArrayOf<Byte>::Alloc(maxBytes);
    Int32 readBytes = 0;
    Int32 n = 0;
    while (n >= 0 && (readBytes += n) < maxBytes) {
        is->ReadBytes(buf, readBytes, maxBytes - readBytes, &n);
    }

    StringBuilder sb("");
    for (Int32 i = 0; i < Elastos::Core::Math::Min(readBytes, buf->GetLength()); i++) {
        sb += (Char32)((*buf)[i]);
    }
    *text = sb.ToString();
   //} catch (IOException e) {
   //     return null;
    //} finally {
        //try {
            if (is != NULL)
                is->Close();
        //} catch (IOException e) {}
    //}
    return NOERROR;
}
示例#24
0
void
mux_process::process_input(bool end_of_process) {
  if (!m_dialog)
    return;

  std::string input;
  auto in = GetInputStream();
  if (in)
    while (in->CanRead())
      input += in->GetC();

  if (end_of_process)
    input += "\n";

  if (!input.empty())
    m_dialog->add_input(input);
}
示例#25
0
bool CscopeProcess::ReadProcessOutput()
{

    //wxProcess::GetInputStream() will capture stdout!
    if (IsInputAvailable())
    {
        wxTextInputStream ts(*GetInputStream());
        wxString line = ts.ReadLine();

        if(line.Length())
        {
            m_parent->OnProcessGeneratedOutputLine(line);
        }
        return true;
    }
    return false;
}
示例#26
0
文件: stream.cpp 项目: hgwells/tive
// fill the buffer with as much data as possible (only for read buffers)
bool wxStreamBuffer::FillBuffer()
{
    wxInputStream *inStream = GetInputStream();

    // It's legal to have no stream, so we don't complain about it just return false
    if ( !inStream )
        return false;

    size_t count = inStream->OnSysRead(m_buffer_start, m_buffer_size);
    if ( !count )
        return false;

    m_buffer_end = m_buffer_start + count;
    m_buffer_pos = m_buffer_start;

    return true;
}
示例#27
0
void azSystemProcess::OnTerminate(int pid, int status) {
  wxLogDebug(_T("Process terminated: %d %d"), pid, status);

  if (!luaState) return;
  if (luaCallbackFunction == wxEmptyString) return;

  wxString output;
  wxInputStream* in = GetInputStream();
  
  if (in) {
    // do NOT use in->GetSize() - it always returns 0

    char buffer[256];

    while (true) {
      in->Read((void*)buffer, 255);
      int readCount = in->LastRead();
      buffer[readCount] = '\0';
      if (readCount > 0) {
        wxString conv(buffer, wxConvUTF8);
        output += conv;
      }
      
      if (in->Eof()) break;
    }
  }

  lua_State* L = luaState;
  
  lua_getfield(L, LUA_GLOBALSINDEX, luaCallbackFunction.mb_str());

  LuaHostTable parameters;
  parameters[_T("output")] = new LuaHostTableItem((wxObject*)&output, LHT_string);
  parameters[_T("sender")] = new LuaHostTableItem(&(wxGetApp()), LHT_wxObject);

  LuaUtil::ConvertAndPushLuaHostTable(L, parameters);
    
  int errorCode = lua_pcall(L, 1, 0, 0);

  if (errorCode) {
    const char* errorString = lua_tostring(L, -1);
    luaHost_logError(wxString(errorString, wxConvUTF8));
  }

}
示例#28
0
XnStatus PrimeClient::StartFWLog()
{
    XnStatus nRetVal = XN_STATUS_OK;
    xnl::Array<XnFwStreamInfo> fwLogStreamInfos;
    XnUInt16 nEndpointID = 0;

    //Enumerate log streams (there should be exactly one)
    nRetVal = EnumerateStreams(XN_LINK_STREAM_TYPE_LOG, fwLogStreamInfos);
    XN_IS_STATUS_OK_LOG_ERROR("Enumerate log streams", nRetVal);
    if (fwLogStreamInfos.GetSize() == 0)
    {
        xnLogError(XN_MASK_PRIME_CLIENT, "No FW log stream exists in device");
        XN_ASSERT(FALSE);
        return XN_STATUS_ERROR;
    }

    if (fwLogStreamInfos.GetSize() > 1)
    {
        xnLogError(XN_MASK_PRIME_CLIENT, "Only one FW log stream is supported");
        XN_ASSERT(FALSE);
        return XN_STATUS_ERROR;
    }

    //Create log stream (from first enumeration result)
    nRetVal = CreateInputStreamImpl(XN_LINK_STREAM_TYPE_LOG, fwLogStreamInfos[0].creationInfo, m_nFWLogStreamID, nEndpointID);
    XN_IS_STATUS_OK_LOG_ERROR("Create log input stream", nRetVal);
    LinkInputStream* pFWLogStream = GetInputStream(m_nFWLogStreamID);
    if (pFWLogStream == NULL)
    {
        xnLogError(XN_MASK_PRIME_CLIENT, "FW log input stream is NULL?!");
        XN_ASSERT(FALSE);
        return XN_STATUS_ERROR;
    }

	//Start the log stream
    nRetVal = pFWLogStream->Start();
    XN_IS_STATUS_OK_LOG_ERROR("Start FW Log Stream", nRetVal);
    xnLogInfo(XN_MASK_PRIME_CLIENT, "FW Log started on stream %u, endpoint %u", m_nFWLogStreamID, nEndpointID);
    
    return XN_STATUS_OK;
}
示例#29
0
bool AxProcess::HasEnded( )
{
	wxString msg;

	// redirect in now disabled (see constructor)
	// nothing will happen
	wxTextInputStream tis(*GetInputStream());
	wxTextInputStream tes(*GetErrorStream());
	
	// we don't know where Error is going to be output
    while ( IsInputAvailable() )
	{
		msg = tis.ReadLine();
		if ( msg.StartsWith("$ Success!") )
		{
			return true;
		}
		else if ( msg.StartsWith("$ Error: ") )
		{
			m_status = 255;
			return true;
		}
		if ( !msg.IsEmpty() && m_log )
			m_log->WriteString( msg + "\n" );
	}
    while ( IsErrorAvailable() )
	{
		msg = tes.ReadLine();
		if ( msg.StartsWith("$ Error: ") )
		{
			m_status = 255;
			return true;
		}
		if ( !msg.IsEmpty() && m_log )
			m_log->WriteString( msg + "\n" );
    }


    return false;
}
示例#30
0
文件: gexecute.cpp 项目: eraso/poedit
        bool HasInput()
        {
            bool hasInput = false;

            wxInputStream* is = GetInputStream();
            if (is && is->CanRead() && !is->Eof()) 
            {
                wxTextInputStream tis(*is);
                m_data->Stdout.Add(tis.ReadLine());
                hasInput = true;
            }

            wxInputStream* es = GetErrorStream();
            if (es && es->CanRead() && !es->Eof()) 
            {
                wxTextInputStream tis(*es);
                m_data->Stderr.Add(tis.ReadLine());
                hasInput = true;
            }

            return hasInput;
        }