コード例 #1
0
ファイル: Sobel.cpp プロジェクト: jrprice/improsa
bool Sobel::runHalideGPU(Image input, Image output, const Params& params)
{
#if ENABLE_HALIDE
    // Create halide buffers
    buffer_t inputBuffer = createHalideBuffer(input);
    buffer_t outputBuffer = createHalideBuffer(output);

    reportStatus("Running Halide GPU filter");

    // Warm-up run
    inputBuffer.host_dirty = true;
    halide_sobel_gpu(&inputBuffer, &outputBuffer);
    halide_dev_sync(NULL);

    // Timed runs
    startTiming();
    for (int i = 0; i < params.iterations; i++)
    {
        halide_sobel_gpu(&inputBuffer, &outputBuffer);
    }
    halide_dev_sync(NULL);
    stopTiming();

    halide_copy_to_host(NULL, &outputBuffer);
    halide_release(NULL);

    return outputResults(input, output, params);
#else
    reportStatus("Halide not enabled during build.");
    return false;
#endif
}
コード例 #2
0
ファイル: Bilateral.cpp プロジェクト: jrprice/improsa
  bool Bilateral::runHalideCPU(Image input, Image output, const Params& params)
  {
#if ENABLE_HALIDE
    // Create halide buffers
    buffer_t inputBuffer = createHalideBuffer(input);
    buffer_t outputBuffer = createHalideBuffer(output);

    reportStatus("Running Halide CPU filter");

    // Warm-up run
    halide_bilateral_cpu(&inputBuffer, &outputBuffer);

    // Timed runs
    startTiming();
    for (int i = 0; i < params.iterations; i++)
    {
      halide_bilateral_cpu(&inputBuffer, &outputBuffer);
    }
    stopTiming();

    halide_release(NULL);

    return outputResults(input, output, params);
#else
    reportStatus("Halide not enabled during build.");
    return false;
#endif
  }
コード例 #3
0
ファイル: workerservice.cpp プロジェクト: jnferguson/winhttpd
void 
workerService_t::onStop(void)
{
	m_log->info("Received stop request, shutting down service.");
	reportStatus(SERVICE_STOP_PENDING);
	emit stopped();
	reportStatus(SERVICE_STOPPED);
	setState(QSERVICE_STOPPED);
	return;
}
コード例 #4
0
void 
controllerService_t::onContinue(void)
{
	m_log->info("Received resume request, resuming service service.");
	reportStatus(SERVICE_START_PENDING);
	setState(QSERVICE_STARTING);
	reportStatus(SERVICE_RUNNING);
	emit resumed();
	return;
}
コード例 #5
0
ファイル: ntservice.cpp プロジェクト: alanw/mongo
    void WINAPI ServiceController::initService( DWORD argc, LPTSTR *argv ) {
		_statusHandle = RegisterServiceCtrlHandler( _serviceName.c_str(), serviceCtrl );
		if ( !_statusHandle )
			return;

		reportStatus( SERVICE_START_PENDING, 1000 );
		
		_serviceCallback();
		
		reportStatus( SERVICE_STOPPED );
	}
コード例 #6
0
void Manager::launchServer()
{
    if (!tcpServer->listen()) {
        Q_EMIT message(tr("Unable to start the server: %1.")
                       .arg(tcpServer->errorString()));
        reportStatus();
        return;
    }
    clientsConnected = 0;
    reportStatus();
    Q_EMIT message(tr("Server started. Run the Client example now."));
}
コード例 #7
0
void ShardingUptimeReporter::startPeriodicThread() {
    invariant(!_thread.joinable());

    _thread = stdx::thread([this] {
        Client::initThread("Uptime reporter");

        const std::string instanceId(constructInstanceIdString());
        const Timer upTimeTimer;

        while (!inShutdown()) {
            {
                auto txn = cc().makeOperationContext();
                reportStatus(txn.get(), instanceId, upTimeTimer);

                auto status =
                    Grid::get(txn.get())->getBalancerConfiguration()->refreshAndCheck(txn.get());
                if (!status.isOK()) {
                    warning() << "failed to refresh mongos settings" << causedBy(status);
                }
            }

            sleepFor(kUptimeReportInterval);
        }
    });
}
コード例 #8
0
ファイル: Filter.cpp プロジェクト: jrprice/improsa
  bool Filter::outputResults(Image input, Image output, const Params& params)
  {
    // Verification
    bool success = true;
    const char *verifyStr = "";
    if (params.verify)
    {
      success = verify(input, output);
      if (success)
      {
        verifyStr = "(verification passed)";
      }
      else
      {
        verifyStr = "(verification failed)";
      }
    }

    // Compute average runtime
    double runtime = ((m_endTime-m_startTime)*1e-3)/params.iterations;

    // Find required DP for 2 significant figures
    int dp = 1 - floor(log10(runtime));

    // Output timing
    char fmt[32];
    sprintf(fmt, "Finished in %%.%dlf ms %%s", dp<0 ? 0 : dp);
    reportStatus(fmt, runtime, verifyStr);

    return success;
  }
コード例 #9
0
void ShardingUptimeReporter::startPeriodicThread() {
    invariant(!_thread.joinable());

    _thread = stdx::thread([] {
        Client::initThread("Uptime reporter");

        const std::string hostName(getHostNameCached());
        const std::string instanceId(constructInstanceIdString(hostName));
        const Timer upTimeTimer;

        while (!globalInShutdownDeprecated()) {
            {
                auto opCtx = cc().makeOperationContext();
                reportStatus(opCtx.get(), instanceId, hostName, upTimeTimer);

                auto status = Grid::get(opCtx.get())
                                  ->getBalancerConfiguration()
                                  ->refreshAndCheck(opCtx.get());
                if (!status.isOK()) {
                    warning() << "failed to refresh mongos settings" << causedBy(status);
                }
            }

            MONGO_IDLE_THREAD_BLOCK;
            sleepFor(kUptimeReportInterval);
        }
    });
}
コード例 #10
0
Socket* RemoteSessionHandle::ConnectSocket(std::string const& host, std::string const& port)
{
    if (!reportStatus.empty())
    {
        reportStatus("Connecting to host " + host + " on port " + port);
    }

    try
    {
    tcp::resolver rsv(*ios);
    tcp::resolver::query query(host, port);

    tcp::resolver::iterator iter = rsv.resolve(query);

    tcp::socket* s = new tcp::socket(*ios);

    // TODO: Change this to connect async?
    boost::asio::connect(*s, iter);

    socket_base::keep_alive ka_option(true);
    s->set_option(ka_option);

    return s;
    }
    catch (boost::system::system_error& ex)
    {
        BOOST_THROW_EXCEPTION(SSHConnectionError() <<
            ssh_error_string("SessionConnection: Error connecting to host " + host + " on port " + port + ". " +
            ex.what()) << ssh_error_id(ex.code().value()));
    }
}
コード例 #11
0
ファイル: Sobel.cpp プロジェクト: jrprice/improsa
bool Sobel::runOpenCL(Image input, Image output, const Params& params)
{
    if (!initCL(params, sobel_kernel, "-cl-fast-relaxed-math"))
    {
        return false;
    }

    cl_int err;
    cl_kernel kernel;
    cl_mem d_input, d_output;
    cl_image_format format = {CL_RGBA, CL_UNORM_INT8};

    kernel = clCreateKernel(m_program, "sobel", &err);
    CHECK_ERROR_OCL(err, "creating kernel", return false);

    d_input = clCreateImage2D(
                  m_context, CL_MEM_READ_ONLY, &format,
                  input.width, input.height, 0, NULL, &err);
    CHECK_ERROR_OCL(err, "creating input image", return false);

    d_output = clCreateImage2D(
                   m_context, CL_MEM_WRITE_ONLY, &format,
                   input.width, input.height, 0, NULL, &err);
    CHECK_ERROR_OCL(err, "creating output image", return false);

    size_t origin[3] = {0, 0, 0};
    size_t region[3] = {input.width, input.height, 1};
    err = clEnqueueWriteImage(
              m_queue, d_input, CL_TRUE,
              origin, region, 0, 0, input.data, 0, NULL, NULL);
    CHECK_ERROR_OCL(err, "writing image data", return false);

    err  = clSetKernelArg(kernel, 0, sizeof(cl_mem), &d_input);
    err |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &d_output);
    CHECK_ERROR_OCL(err, "setting kernel arguments", return false);

    reportStatus("Running OpenCL kernel");

    const size_t global[2] = {output.width, output.height};
    const size_t *local = NULL;
    if (params.wgsize[0] && params.wgsize[1])
    {
        local = params.wgsize;
    }

    // Timed runs
    for (int i = 0; i < params.iterations + 1; i++)
    {
        err = clEnqueueNDRangeKernel(
                  m_queue, kernel, 2, NULL, global, local, 0, NULL, NULL);
        CHECK_ERROR_OCL(err, "enqueuing kernel", return false);

        // Start timing after warm-up run
        if (i == 0)
        {
            err = clFinish(m_queue);
            CHECK_ERROR_OCL(err, "running kernel", return false);
            startTiming();
        }
    }
コード例 #12
0
ファイル: status.cpp プロジェクト: cawka/NFD
/** \brief single-section status command
 */
static void
reportStatusSingleSection(ExecuteContext& ctx, bool StatusReportOptions::*wantSection)
{
  StatusReportOptions options;
  options.*wantSection = true;
  reportStatus(ctx, options);
}
コード例 #13
0
ファイル: workerservice.cpp プロジェクト: jnferguson/winhttpd
void 
workerService_t::onContinue(void)
{
	m_log->info("Received resume request, resuming service service.");
	setState(QSERVICE_RESUME);
	reportStatus(SERVICE_RUNNING);
	emit resumed();
	return;
}
コード例 #14
0
ファイル: workerservice.cpp プロジェクト: jnferguson/winhttpd
void 
workerService_t::onPause(void)
{
	m_log->info("Received pause request, pausing service.");
	setState(QSERVICE_PAUSED);
	reportStatus(SERVICE_PAUSED);
	emit paused();
	return;
}
コード例 #15
0
ファイル: workerservice.cpp プロジェクト: jnferguson/winhttpd
void 
workerService_t::onStart(DWORD, LPTSTR*)
{
	m_log->info("Service started");
	setState(QSERVICE_STARTING);
	reportStatus(SERVICE_RUNNING);
	emit started();
	return;
}
コード例 #16
0
ファイル: status.cpp プロジェクト: cawka/NFD
/** \brief the 'status report' command
 */
static void
reportStatusComprehensive(ExecuteContext& ctx)
{
  StatusReportOptions options;
  options.output = ctx.args.get<ReportFormat>("format", ReportFormat::TEXT);
  options.wantForwarderGeneral = options.wantChannels = options.wantFaces = options.wantFib =
    options.wantRib = options.wantCs = options.wantStrategyChoice = true;
  reportStatus(ctx, options);
}
コード例 #17
0
ファイル: ntservice.cpp プロジェクト: BendustiK/mongo
 void WINAPI ServiceController::serviceCtrl( DWORD ctrlCode ) {
     switch ( ctrlCode ) {
     case SERVICE_CONTROL_STOP:
     case SERVICE_CONTROL_SHUTDOWN:
         shutdownServer();
         reportStatus( SERVICE_STOPPED );
         return;
     }
 }
コード例 #18
0
ファイル: daemon.c プロジェクト: jaseg/transmission
static void
periodicUpdate (evutil_socket_t fd UNUSED, short what UNUSED, void *watchdir)
{
    dtr_watchdir_update (watchdir);

    pumpLogMessages (logfile);

    reportStatus ();
}
コード例 #19
0
ファイル: Platforms.cpp プロジェクト: konkath/pociagi
//add people to given platform
void Platforms::addPeople(int idx){
	int platform = getPlatform(idx), id = getId(idx);

	peopleMutex->lock();
	people[platform].push_back(id);
	peopleMutex->unlock();

	reportStatus(idx);
}
コード例 #20
0
void Manager::clearSocket()
{
    QTcpSocket *clientConnection = qobject_cast<QTcpSocket *>(sender());
    if(!clientConnection)
        return;
    --clientsConnected;
    reportStatus();
    Q_EMIT message(tr("Client disconnected."));
    clientConnection->deleteLater();
}
コード例 #21
0
ファイル: Filter.cpp プロジェクト: jrprice/improsa
  bool Filter::verify(Image input, Image output, int tolerance)
  {
    // Compute reference image
    Image ref =
    {
      (unsigned char*)malloc(output.width*output.height*4),
      output.width,
      output.height
    };
    runReference(input, ref);

    // Compare pixels
    int errors = 0;
    const int maxErrors = 16;
    for (int y = 0; y < output.height; y++)
    {
      for (int x = 0; x < output.width; x++)
      {
        for (int c = 0; c < 4; c++)
        {
          int r = getPixel(ref, x, y, c)*255;
          int o = getPixel(output, x, y, c)*255;
          int diff = abs(r - o);
          if (diff > tolerance)
          {
            // Only report first few errors
            if (errors < maxErrors)
            {
              reportStatus("Mismatch at (%d,%d,%d): %d vs %d", x, y, c, r, o);
            }
            if (++errors == maxErrors)
            {
              reportStatus("Supressing further errors");
            }
          }
        }
      }
    }

    free(ref.data);

    return errors == 0;
  }
コード例 #22
0
void Manager::registerSocket()
{
    ++clientsConnected;
    QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
    reportStatus();
    Q_EMIT message(tr("Client %1(%2) connected.")
                   .arg(clientConnection->peerAddress().toString())
                   .arg(clientConnection->peerPort()));
    connect(clientConnection, SIGNAL(disconnected()),
            this, SLOT(clearSocket()));
    connect(clientConnection, SIGNAL(readyRead()), this, SLOT(readRequest()));
    connect(clientConnection, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(displayError(QAbstractSocket::SocketError)));
}
コード例 #23
0
/** \brief the 'legacy-nfd-status' command
 */
static int
legacyNfdStatus(ExecuteContext& ctx)
{
  auto args = ctx.args.get<std::vector<std::string>>("args");

  int exitCode = -1;
  StatusReportOptions options;
  std::tie(exitCode, options) = parseCommandLine(args);
  if (exitCode >= 0) {
    return exitCode;
  }

  return reportStatus(ctx, options);
}
コード例 #24
0
ファイル: main.cpp プロジェクト: dmerejkowsky/nao-gm
int main(int argc, char** argv)
{
    std::string ip = "192.168.11.9";
    std::string port = "9559";

    if (argc > 1) ip = argv[1];
    if (argc > 2) port = argv[2];

    int portn = std::atoi(port.c_str());

    AL::ALBrokerManager::getInstance()->killAllBroker();
    AL::ALBroker::Ptr broker = AL::ALBroker::createBroker("main", "0.0.0.0", 54000, ip, portn);

    try
    {
        auto hvc = AL::ALModule::createModule<HandVoiceControl>(broker, "HandVoiceControl");
        hvc->startRecognition();

        AL::ALMotionProxy motion(broker);

        auto d = AL::ALModule::createModule<Diagnostics>(broker, "Diagnostics");
        d->reportStatus();

        static bool finish = false;
        while (!finish)
        {
            motion.openHand("RHand");
            motion.setStiffnesses("HeadYaw", 0.1f);
            motion.angleInterpolation("HeadYaw", 0.2f, 1.0f, true);
            qi::os::msleep(1000);
            motion.closeHand("RHand");
            motion.angleInterpolation("HeadYaw", 0.0f, 1.0f, true);
            qi::os::msleep(1000);
        }

        hvc->stopRecognition();
    }
    catch (const AL::ALError& e)
    {
        qiLogError("error") << e.what() << std::endl;
    }

    //AL::ALMotionProxy motion(ip, portn);
    //int a = motion.post.openHand("RHand");
    //tts.callVoid("say", std::string("opening"));
    //int b = motion.post.closeHand("RHand");
    //tts.callVoid("say", std::string("closing"));

    return 0;
}
コード例 #25
0
ファイル: Platforms.cpp プロジェクト: konkath/pociagi
//remove people from given platform
bool Platforms::removePeople(int idx){
	int platformId = getPlatform(idx), id = getId(idx);
	bool result = false;

	peopleMutex->lock();
	if (!people[platformId].empty()){
		for(unsigned int i = 0; i < people[platformId].size(); ++i){
			//look for people with correct ticket
			if (people[platformId][i] == id){
				//delete that person
				people[platformId].erase(people[platformId].begin() + i);
				result = true;
				break;
			}
		}
	}//exit locked
	peopleMutex->unlock();

	reportStatus(idx);
	return result;
}
コード例 #26
0
RemoteSessionHandle::RemoteSessionHandle(ReportFunctionRef pReportStatus, std::string const& host,
    std::string const& port) :
    reportStatus{pReportStatus}, ios{new io_service()}, sock{ConnectSocket(host, port)},
    sessionHandle{pReportStatus}, cleanupState{utils::CleanupState::NoCleanup}
{
    if (!reportStatus.empty())
    {
        reportStatus("Performing SSH handshake");
    }

    io_service& ios = sock->get_io_service();
    ios.reset();

    sock->async_read_some
    (
        boost::asio::null_buffers{},
        bind(AsyncLoopSocket, protect(bind(&RemoteSessionHandle::DoHandshake, this)),
            boost::ref(*sock), true)
    );

    ios.run();
}
コード例 #27
0
ファイル: son.cpp プロジェクト: gagara/homekeeper
void loop() {
    tsCurr = getTimestamp();
    if (diffTimestamps(tsCurr, tsLastSensorRead) >= SENSORS_READ_INTERVAL_SEC) {
        readSensors();
        tsLastSensorRead = tsCurr;

        digitalWrite(HEARTBEAT_LED, digitalRead(HEARTBEAT_LED) ^ 1);
    }
    if (serial->available() > 0) {
        processSerialMsg();
    }
    if (wifi->available() > 0) {
        processWifiMsg();
    }

    if (diffTimestamps(tsCurr, tsLastStatusReport) >= STATUS_REPORTING_PERIOD_SEC) {
        reportStatus();
        tsLastStatusReport = tsCurr;
    }

    tsPrev = tsCurr;
}
コード例 #28
0
void StepperControl::checkAxisSubStatus(StepperControlAxis *axis, int *axisSubStatus)
{
  int newStatus = 0;
  bool statusChanged = false;

  if (axis->isAccelerating())
  {
    newStatus = COMM_REPORT_MOVE_STATUS_ACCELERATING;
  }

  if (axis->isCruising())
  {
    newStatus = COMM_REPORT_MOVE_STATUS_CRUISING;
  }

  if (axis->isDecelerating())
  {
    newStatus = COMM_REPORT_MOVE_STATUS_DECELERATING;
  }

  if (axis->isCrawling())
  {
    newStatus = COMM_REPORT_MOVE_STATUS_CRAWLING;
  }

  // if the status changes, send out a status report
  if (*axisSubStatus != newStatus && newStatus > 0)
  {
    statusChanged = true;
  }
  *axisSubStatus = newStatus;

  if (statusChanged)
  {
    reportStatus(axis, *axisSubStatus);
  }
}
コード例 #29
0
int main(void) 
{
    // intro text
    printf("* * * DUNGEON QUEST * * *\n\n");
    printf("You find yourself in a dungeon ruled by dark magic\n");
    printf("Try to escape and reach %s without dying!\n", DESTINATION);
    printf("But before you arrive, you must boost your %s to at least level %i,\n", SKILL, SKILL_GOAL);
    printf("...or else the Dieties of %s will not accept you!\n\n", DESTINATION);
    
    // provide a seed to the random number generator (don't worry about understanding this)
    srand(time(NULL));
    
    // initialize the player
    player p = { 100, 3, 1 };

    // continue looping forever until Game Over
    while (true)
    {
        if (checkGameOver(p))
        {
            // stop if we hit Game Over
            return 0;
        }
        
        reportStatus(p);
        
        printf("You continue walking through dark corridors...\n");
        p.distance -= 1;
        GetString();
        
        printf("You health is slowly waning...\n");
        p.health -= 10;
        GetString();
        
        discoverPotion(&p);
    }
}
コード例 #30
0
void RemoteSessionHandle::CloseSession()
{
    if (cleanupState != utils::CleanupState::NoCleanup)
    {
        return;
    }

    if (!reportStatus.empty())
    {
        reportStatus("Disconnecting SSH remote session.");
    }

    io_service ios{};
    deadline_timer dt{ios};

    dt.expires_from_now(milliseconds{10});
    dt.async_wait(bind(AsyncLoopTimer, protect(bind(&RemoteSessionHandle::DoCloseSession, this)),
        boost::ref(dt), 10));

    cleanupState = utils::CleanupState::CleanupInProgress;
    ios.run();

    cleanupState = utils::CleanupState::CleanupDone;
}