Ejemplo n.º 1
0
 /**
  * Checks whether the specified duration has passed since the last
  * update.  If yes, it updates the time stamp.
  *
  * @param duration the duration in milliseconds
  */
 bool CheckUpdate(unsigned duration) {
   Stamp now = GetNow();
   if (Check(now, duration)) {
     Update(now);
     return true;
   } else
     return false;
 }
void TelescopeClientDirectNexStar::step(long long int timeout_micros)
{
	long long int now = GetNow();
	if (queue_get_position && now >= next_pos_time)
	{
		nexstar->sendCommand(new NexStarCommandGetRaDec(*this));
		queue_get_position = false;
		next_pos_time = now + 500000;
	}
	Server::step(timeout_micros);
}
void TelescopeClientDirectLx200::step(long long int timeout_micros)
{
	long long int now = GetNow();
	if (queue_get_position && now >= next_pos_time)
	{
		lx200->sendCommand(new Lx200CommandGetRa(*this));
		lx200->sendCommand(new Lx200CommandGetDec(*this));
		queue_get_position = false;
		next_pos_time = now + 500000;// 500000;
	}
	Server::step(timeout_micros);
}
//Merged from Connection::sendPosition() and TelescopeTCP::performReading()
void TelescopeClientDirectNexStar::sendPosition(unsigned int ra_int, int dec_int, int status)
{
	//Server time is "now", because this class is the server
	const qint64 server_micros = (qint64) GetNow();
	const double ra  =  ra_int * (M_PI/(unsigned int)0x80000000);
	const double dec = dec_int * (M_PI/(unsigned int)0x80000000);
	const double cdec = cos(dec);
	Vec3d position(cos(ra)*cdec, sin(ra)*cdec, sin(dec));
	Vec3d j2000Position = position;
	if (equinox == EquinoxJNow)
	{
		const StelCore* core = StelApp::getInstance().getCore();
		j2000Position = core->equinoxEquToJ2000(position);
	}
	interpolatedPosition.add(j2000Position, getNow(), server_micros, status);
}
Ejemplo n.º 5
0
	  static void StartTiming() {  // Start the timed portion of the code.
	       // This is called automatically from
	       // Init(), but if there is a portion of
	       // the code you don't want to count in
	       // the timed portion, you could call
	       // SuspendTiming() and then call
	       // StartTiming() explicitly when the
	       // timed portion begins.
	       _startTime = GetNow();
	       std::cerr << "Timing started\n";
	       struct sigaction act;
	       bzero(&act, sizeof(act));
	       act.sa_handler = StopSignal;
	       act.sa_flags = SA_RESETHAND;
	       sigaction(SIGALRM, &act, NULL);
	       _timingIsSuspended = false;
	       alarm(static_cast<unsigned int>(_runTimeSeconds));
	       volatile int temp = 1;
	       if (_hang) {
		    while(temp) {}
	       }
	  }
Ejemplo n.º 6
0
 /**
  * Combines a call to Elapsed() and Update().
  */
 int ElapsedUpdate() {
   const auto now = GetNow();
   int result = Elapsed(now);
   Update(now);
   return result;
 }
Ejemplo n.º 7
0
 /**
  * Returns the number of milliseconds elapsed since the last
  * update().  Returns -1 if update() was never called.
  */
 int Elapsed() const {
   return Elapsed(GetNow());
 }
Ejemplo n.º 8
0
 /**
  * Checks whether the specified duration has passed since the last
  * update.  After that, it updates the time stamp.
  *
  * @param duration the duration in milliseconds
  */
 bool CheckAlwaysUpdate(unsigned duration) {
   Stamp now = GetNow();
   bool ret = Check(now, duration);
   Update(now);
   return ret;
 }
Ejemplo n.º 9
0
 /**
  * Updates the time stamp, setting it to the current clock plus the
  * specified offset.
  */
 void UpdateWithOffset(int offset) {
   Update(GetNow() + offset);
 }
Ejemplo n.º 10
0
 /**
  * Updates the time stamp, setting it to the current clock.
  */
 void Update() {
   Update(GetNow());
 }
Ejemplo n.º 11
0
 /**
  * Checks whether the specified duration has passed since the last
  * update.
  *
  * @param duration the duration in milliseconds
  */
 bool Check(unsigned duration) const {
   return Check(GetNow(), duration);
 }
Ejemplo n.º 12
0
int CLobbyApp::Run()
{
  const DWORD c_dwUpdateInterval = 200; // milliseconds
  DWORD dwSleep = c_dwUpdateInterval;
  DWORD dwWait = WAIT_TIMEOUT;
  InitializeCriticalSectionAndSpinCount(&HttpCriticalSection, 0x00000400);
  InitializeCriticalSectionAndSpinCount(GetLogonCS(), 0x00000400);
  m_plas->LogEvent(EVENTLOG_INFORMATION_TYPE, LE_Running);
  puts("---------Press Q to exit---------");
   printf("Ready for clients/servers.\n");
  CTempTimer timerIterations("between iterations", .25f);
  timerIterations.Start();
  CTempTimer timerReceiveClientsMessages("in clients ReceiveMessages()", .05f);
  CTempTimer timerReceiveServersMessages("in servers ReceiveMessages()", .05f);
  Time timeLastQueueCheck = Time::Now();
  Time timeLastGameInfo = Time::Now();

  while (true)
  {
    timerIterations.Stop();
    timerIterations.Start();

    if (ProcessMsgPump() || (_kbhit() && toupper(_getch()) == 'Q')) {
		//Imago #111 7/10
		if(g_pAutoUpdate)
		{ 
			char szFileName[MAX_PATH+16];
			strcpy(szFileName, _Module.GetModulePath());
			Strcat(szFileName, "FileList.txt");
			g_pAutoUpdate->LoadCRC(szFileName);
			FedMessaging * pfm = &g_pLobbyApp->GetFMClients();
			int count = pfm->GetConnectionCount();
			ListConnections::Iterator iterCnxn(*pfm->GetConnections());
			while (!iterCnxn.End()) {
				BEGIN_PFM_CREATE(*pfm, pfmAutoUpdate, L, AUTO_UPDATE_INFO)
				  FM_VAR_PARM(g_pAutoUpdate->GetFTPServer(), CB_ZTS)
				  FM_VAR_PARM(g_pAutoUpdate->GetFTPInitialDir(), CB_ZTS)
				  FM_VAR_PARM(g_pAutoUpdate->GetFTPAccount(), CB_ZTS)
				  FM_VAR_PARM(g_pAutoUpdate->GetFTPPassword(), CB_ZTS)
				END_PFM_CREATE
				pfmAutoUpdate->crcFileList = g_pAutoUpdate->GetFileListCRC();
				pfmAutoUpdate->nFileListSize = g_pAutoUpdate->GetFileListSize();
				pfm->SendMessages(iterCnxn.Value(), FM_GUARANTEED, FM_FLUSH);
				iterCnxn.Next();
			}
		}
      return 0;
	}

    SetNow();

    m_pCounters->timeInnerLoop = timerIterations.LastInterval();

    // receive any messages in the queue
    timerReceiveClientsMessages.Start();
    m_fmClients.ReceiveMessages();
    timerReceiveClientsMessages.Stop();

    timerReceiveServersMessages.Start();
    m_fmServers.ReceiveMessages();
    timerReceiveServersMessages.Stop();

    if (GetNow() - timeLastQueueCheck >= 1.0f)
    {
      // count the fairly expensive stuff no more than once a second
      UpdatePerfCounters();
      timeLastQueueCheck = GetNow();
      if (GetNow() - timeLastGameInfo >= (float) m_sGameInfoInterval)
      {
        SendGameInfo();
        timeLastGameInfo = GetNow();
      }

      // Do a periodic roll call. If we haven't heard from anyone for two roll calls in a row, waste 'em
      static Time timeRollCall = Time::Now();
      if (GetNow() - timeRollCall >= 5.0f)
      {
        RollCall();
        timeRollCall = GetNow();
      }
    }
    Sleep(1);
  }
  DeleteCriticalSection(GetLogonCS());
  DeleteCriticalSection(&HttpCriticalSection);
  return 0;
}
Ejemplo n.º 13
0
 /**
  * This method schedules the timer to fire a @p dt milliseconds from now.
  *
  * @param[in]  aDt  The expire time in milliseconds from now.
  */
 void Start(uint32_t aDt) { StartAt(GetNow(), aDt); }
Ejemplo n.º 14
0
	  static void Init(const std::string & system, int & argc, char ** &argv) 
	  // Call this first thing in your program.  It will parse the standard
	  // commandline options and remove them from the argv.
	  {

	       assert(argc >= 1);
	       std::vector<char*> leftOvers;
	       leftOvers.push_back(argv[0]);

	       if (argc < 2) {
		    std::cerr << "Standard harness options : " << argv[0] << " " << _usage << "\n";
		    exit(1);
	       }

	       _name = argv[1];
	       _system = system;
	       bool durationSet = false;
	       int i=2;
	       while(i < argc) {
		    if (!strcmp(argv[i], "-tc"))
			 _threadCount = atoi(argv[++i]);
		    else if (!strcmp(argv[i], "-foot"))
			 _footPrintB = atoll(argv[++i])*1024*1024;
		    else if (!strcmp(argv[i], "-footMB"))
			 _footPrintB = atoll(argv[++i])*1024*1024;
		    else if (!strcmp(argv[i], "-footKB"))
			 _footPrintB = atoll(argv[++i])*1024;
		    else if (!strcmp(argv[i], "-footB"))
			 _footPrintB = atoll(argv[++i]);
		    else if (!strcmp(argv[i], "-rt")) {
			 durationSet = true;
			 _runTimeSeconds = atoi(argv[++i]);
		    } else if (!strcmp(argv[i], "-max")) {
			 durationSet = true;
			 _opCountSet = true;
			 _operationCount = atoi(argv[++i]);
			 
		    } else if (!strcmp(argv[i], "-file"))
			 _file = argv[++i];
		    else if (!strcmp(argv[i], "-reload"))
			 _reload = true;
		    else if (!strcmp(argv[i], "-create"))
			 _create = true;
		    else if (!strcmp(argv[i], "-hang"))
		         _hang = true;
		    else if (!strcmp(argv[i], "-nondet"))
			 srand(time(NULL));
		    else {
			 leftOvers.push_back(argv[i]);
		    }
		    i++;
	       }
	       

	       if (_footPrintB == 0) {
		    std::cerr << "Footprint must be specified\n";
		    std::cerr << argv[0] << _usage << "\n";
		    exit(-1);
	       }

	       if (!durationSet) {
		    std::cerr << "-rt or -max must be specified\n";
		    std::cerr << argv[0] << _usage << "\n";
		    exit(-1);
	       }

	       if (_runTimeSeconds > 0 && _operationCount > 0) {
		    std::cerr << "only one of -rt or -max\n";
		    std::cerr << argv[0] << _usage << "\n";
		    exit(-1);
	       }

	       if (_create && _reload) {
		    std::cerr << "Either -create or -reload may be specified, but not both\n";
		    std::cerr << argv[0] << _usage << "\n";
		    exit(-1);
	       }

	       _operationsPerThread  = _operationCount/_threadCount;
	       _startTime = GetNow();

	       argc = leftOvers.size();
	       for(unsigned int i = 0; i< leftOvers.size(); i++) {
		    argv[i] = leftOvers[i];
	       }
	       argv[leftOvers.size()] = NULL;
	       

	       struct sigaction act;
	       bzero(&act, sizeof(act));
	       act.sa_handler = GracefulExit;
	       sigaction(SIGINT, &act, NULL);

	       StartTiming();
	  }
Ejemplo n.º 15
0
	  static void StopTiming() {  // Call this when the timed portion of
	       // the program has ended.
	       _stopTime = GetNow();
	       std::cerr << "Timing stopped\n";
	  }
Ejemplo n.º 16
0
	  static void StopSignal(int i) { // don't call this.
	       if (!_timingIsSuspended) {
		    _stopTime = GetNow();
		    _finished = true;	      
	       }
	  }