Example #1
0
void SessionsBox::Inner::listUpdated() {
	if (_list->isEmpty()) {
		_terminateAll->hide();
	} else {
		_terminateAll->show();
	}
	for (TerminateButtons::iterator i = _terminateButtons.begin(), e = _terminateButtons.end(); i != e; ++i) {
		i.value()->move(0, -1);
	}
	for (int32 i = 0, l = _list->size(); i < l; ++i) {
		TerminateButtons::iterator j = _terminateButtons.find(_list->at(i).hash);
		if (j == _terminateButtons.cend()) {
			j = _terminateButtons.insert(_list->at(i).hash, new Ui::IconButton(this, st::sessionTerminate));
			connect(j.value(), SIGNAL(clicked()), this, SLOT(onTerminate()));
		}
		j.value()->moveToRight(st::sessionTerminateSkip, st::sessionCurrentHeight + i * st::sessionHeight + st::sessionTerminateTop, width());
		j.value()->show();
	}
	for (TerminateButtons::iterator i = _terminateButtons.begin(); i != _terminateButtons.cend();) {
		if (i.value()->y() >= 0) {
			++i;
		} else {
			delete i.value();
			i = _terminateButtons.erase(i);
		}
	}
	resize(width(), _list->isEmpty() ? (st::sessionCurrentHeight + st::noContactsHeight) : (st::sessionCurrentHeight + _list->size() * st::sessionHeight));
	update();
}
Example #2
0
    Status tick()
    {
        if (m_eStatus != BH_RUNNING)
        {
            onInitialize();
        }

        m_eStatus = update();

        if (m_eStatus != BH_RUNNING)
        {
            onTerminate(m_eStatus);
        }
        return m_eStatus;
    }
Example #3
0
void HllAggregateFunctionBase::terminate(
    ServerInterface &srvInterface, 
    BlockWriter &resWriter, 
    IntermediateAggs &aggs) {
    try {
        VString& agg = aggs.getStringRef(0);

        printBinaryHll(srvInterface, "terminate", agg);

        onTerminate(agg, resWriter);
    } catch(exception& e) {
        // Standard exception. Quit.
        vt_report_error(0, "Exception while computing aggregate output: [%s]", e.what());
    }
}
		Status tick()
		{
			if (status != RUNNING)
			{
				onInitialize();
			}

			status = update();

			if (status != RUNNING)
			{
				onTerminate(status);
			}
			return status;
		}
ErrorCode DummySessionDelegateImpl::onTerminate(Session &session,
                                                ProcessId pid) {
  StopCode stop;
  return onTerminate(session, pid, stop);
}
Example #6
0
void Recorder::messagePump()
{
	XnStatus nRetVal = XN_STATUS_OK;
    Message msg = { Message::MESSAGE_NO_OPERATION, 0, NULL, {NULL}, 0, 0 };

	{
		xnl::LockGuard<MessageQueue> guard(m_queue);
		nRetVal = m_queue.Pop(msg);
	}

    if (XN_STATUS_OK == nRetVal)
    {
        switch (msg.type)
        {
            case Message::MESSAGE_INITIALIZE:
                {
                    onInitialize();
                }
                break;
            case Message::MESSAGE_TERMINATE:
                {
                    onTerminate();
                    m_running = FALSE;
                }
                break;
            case Message::MESSAGE_ATTACH:
                {
                    xnl::LockGuard<AttachedStreams> streamsGuard(m_streams);
                    AttachedStreams::Iterator i = m_streams.Find(msg.pStream);
                    if (i != m_streams.End())
                    {
                        onAttach(i->Value().nodeId, msg.pStream);
                    }
                }
                break;
            case Message::MESSAGE_DETACH:
                {
                    xnl::LockGuard<AttachedStreams> streamsGuard(m_streams);
                    AttachedStreams::Iterator i = m_streams.Find(msg.pStream);
                    if (i != m_streams.End())
                    {
                        onDetach(i->Value().nodeId);
                        XN_DELETE(m_streams[msg.pStream].pCodec);
                        m_streams.Remove(msg.pStream);
                    }
                }
                break;
            case Message::MESSAGE_START:
                {
                    xnl::LockGuard<AttachedStreams> streamsGuard(m_streams);
                    for (AttachedStreams::Iterator 
                            i = m_streams.Begin(),
                            e = m_streams.End();
                        i != e; ++i)
                    {
                        onStart(i->Value().nodeId);
                    }
                    m_started = true;
                }
                break;
            case Message::MESSAGE_RECORD:
                {
                    xnl::LockGuard<AttachedStreams> streamsGuard(m_streams);
                    AttachedStreams::Iterator i = m_streams.Find(msg.pStream);
                    if (i != m_streams.End())
                    {
                        XnCodecBase* pCodec = m_streams[msg.pStream].pCodec;
                        XnUInt32 frameId    = ++m_streams[msg.pStream].frameId;
                        XnUInt64 timestamp  = 0;
                        if (frameId > 1)
                        {
                            timestamp = m_streams[msg.pStream].lastOutputTimestamp + (msg.pFrame->timestamp - m_streams[msg.pStream].lastInputTimestamp);
                        }
                        m_streams[msg.pStream].lastInputTimestamp = msg.pFrame->timestamp;
                        m_streams[msg.pStream].lastOutputTimestamp = timestamp;
                        onRecord(i->Value().nodeId, pCodec, msg.pFrame, frameId, timestamp);
                        msg.pStream->frameRelease(msg.pFrame);
                    }
                }
                break;
            case Message::MESSAGE_RECORDPROPERTY:
                {
                    xnl::LockGuard<AttachedStreams> streamsGuard(m_streams);
                    AttachedStreams::Iterator i = m_streams.Find(msg.pStream);
                    if (i != m_streams.End())
                    {
                        onRecordProperty(
                            i->Value().nodeId,
                            msg.propertyId,
                            msg.pData,
                            msg.dataSize);
                    }
                    // free the temporary buffer allocated earlier
                    xnOSFree((void*)msg.pData);
                }
                break;
            default:
                ;
        }
    }
}
Example #7
0
 void abort()
 {
     onTerminate(BH_ABORTED);
     m_eStatus = BH_ABORTED;
 }
		void abort()
		{
			onTerminate(ABORTED);
			status = ABORTED;
		}
Example #9
0
int
main(int argc, char** argv)
{
  OptionParser options;
  options.executable("dune-test-tail")
  .program(DUNE_SHORT_NAME)
  .copyright(DUNE_COPYRIGHT)
  .email(DUNE_CONTACT)
  .version(getFullVersion())
  .date(getCompileDate())
  .arch(DUNE_SYSTEM_NAME)
  .add("-i", "--address",
       "Vehicle's IP address", "ADDRESS")
  .add("-w", "--wait",
       "Wait DELAY seconds before starting test", "DELAY")
  .add("-d", "--duration",
       "Test duration in seconds", "DURATION")
  .add("-s", "--speed",
       "Speed in percentage", "SPEED")
  .add("-t", "--angle",
       "Angle in degrees", "ANGLE");

  // Parse command line arguments.
  if (!options.parse(argc, argv))
  {
    if (options.bad())
      std::cerr << "ERROR: " << options.error() << std::endl;
    options.usage();
    return 1;
  }

  // Set destination address.
  if (options.value("--address") == "")
    g_addr = "127.0.0.1";
  else
    g_addr = options.value("--address").c_str();

  // Set start delay.
  double sdelay = 0;
  if (options.value("--wait") == "")
    sdelay = 0;
  else
    sdelay = castLexical<double>(options.value("--wait"));

  // Set duration.
  double duration = 0;
  if (options.value("--duration") == "")
    duration = 0;
  else
    duration = castLexical<double>(options.value("--duration"));

  // Set speed.
  double speed = 0;
  if (options.value("--speed") == "")
    speed = 0;
  else
  {
    speed = castLexical<double>(options.value("--speed"));
    speed /= 100.0;
  }

  // Set Angle
  double angle = 0;
  if (options.value("--angle") == "")
    angle = 0;
  else
    angle = castLexical<double>(options.value("--angle"));

  // POSIX implementation.
#if defined(DUNE_SYS_HAS_SIGACTION)
  struct sigaction actions;
  std::memset(&actions, 0, sizeof(actions));
  sigemptyset(&actions.sa_mask);
  actions.sa_flags = 0;
  actions.sa_handler = handleTerminate;
  sigaction(SIGALRM, &actions, 0);
  sigaction(SIGHUP, &actions, 0);
  sigaction(SIGINT, &actions, 0);
  sigaction(SIGQUIT, &actions, 0);
  sigaction(SIGTERM, &actions, 0);
  sigaction(SIGCHLD, &actions, 0);
  sigaction(SIGCONT, &actions, 0);
#endif

  setThrust(0);
  Delay::wait(sdelay);

  setLog("mcrt_endurance");
  Delay::wait(2.0);

  double deadline = Clock::get() + duration;
  setThrust(speed);

  while ((Clock::get() < deadline) && !g_stop)
  {
    setFin(0, -angle);
    setFin(1, -angle);
    setFin(2, -angle);
    setFin(3, -angle);

    if (!g_stop)
      Delay::wait(1.0);

    if (!g_stop)
      Delay::wait(1.0);

    if (!g_stop)
      Delay::wait(1.0);

    if (!g_stop)
      Delay::wait(1.0);

    setFin(0, angle);
    setFin(1, angle);
    setFin(2, angle);
    setFin(3, angle);

    if (!g_stop)
      Delay::wait(1.0);

    if (!g_stop)
      Delay::wait(1.0);

    if (!g_stop)
      Delay::wait(1.0);

    if (!g_stop)
      Delay::wait(1.0);
  }

  // Change log.
  Delay::wait(2.0);
  setLog("idle");

  onTerminate();

  return 0;
}