当前位置: 首页>>代码示例>>C++>>正文


C++ CStopWatch::elapsed方法代码示例

本文整理汇总了C++中CStopWatch::elapsed方法的典型用法代码示例。如果您正苦于以下问题:C++ CStopWatch::elapsed方法的具体用法?C++ CStopWatch::elapsed怎么用?C++ CStopWatch::elapsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CStopWatch的用法示例。


在下文中一共展示了CStopWatch::elapsed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run


//.........这里部分代码省略.........
			ret = dstar->hasData();
			if (ret) {
				ret = m_modem->hasDStarSpace();
				if (ret) {
					len = dstar->readData(data);
					if (mode != MODE_DSTAR) {
						LogWarning("D-Star echo data received when in mode %u", mode);
					} else {
						m_modem->writeDStarData(data, len);
						modeTimer.start();
					}
				}
			}
		}

		if (dmr != NULL) {
			ret = m_modem->hasDMRSpace1();
			if (ret) {
				len = dmr->readModemSlot1(data);
				if (len > 0U && mode == MODE_IDLE) {
					m_display->setDMR();
					mode = MODE_DMR;
				}
				if (len > 0U && mode == MODE_DMR) {
					m_modem->writeDMRData1(data, len);
					modeTimer.start();
				}
			}

			ret = m_modem->hasDMRSpace2();
			if (ret) {
				len = dmr->readModemSlot2(data);
				if (len > 0U && mode == MODE_IDLE) {
					m_display->setDMR();
					mode = MODE_DMR;
				}
				if (len > 0U && mode == MODE_DMR) {
					m_modem->writeDMRData2(data, len);
					modeTimer.start();
				}
			}
		}

		if (ysf != NULL) {
			ret = ysf->hasData();
			if (ret) {
				ret = m_modem->hasYSFSpace();
				if (ret) {
					len = ysf->readData(data);
					if (mode != MODE_YSF) {
						LogWarning("System Fusion echo data received when in mode %u", mode);
					} else {
						m_modem->writeYSFData(data, len);
						modeTimer.start();
					}
				}
			}
		}

		unsigned int ms = stopWatch.elapsed();
		m_modem->clock(ms);
		modeTimer.clock(ms);
		if (dstar != NULL)
			dstar->clock(ms);
		if (dmr != NULL)
			dmr->clock(ms);
		if (ysf != NULL)
			ysf->clock(ms);
		stopWatch.start();

		if (ms < 5U) {
#if defined(WIN32)
			::Sleep(5UL);		// 5ms
#else
			::usleep(5000);		// 5ms
#endif
		}
	}

	LogMessage("MMDVMHost is exiting on receipt of SIGHUP1");

	m_display->setIdle();

	m_modem->close();
	delete m_modem;

	m_display->close();
	delete m_display;

	if (m_dmrNetwork != NULL) {
		m_dmrNetwork->close();
		delete m_dmrNetwork;
	}

	delete dstar;
	delete dmr;
	delete ysf;

	return 0;
}
开发者ID:mathisschmieder,项目名称:OpenDV,代码行数:101,代码来源:MMDVMHost.cpp

示例2: run


//.........这里部分代码省略.........
			}

			ret = m_modem->hasDMRSpace2();
			if (ret) {
				len = dmr->readModemSlot2(data);
				if (len > 0U) {
					if (m_mode == MODE_IDLE) {
						setMode(MODE_DMR);
					} else if (m_mode == MODE_DMR) {
						m_modem->writeDMRData2(data, len);
						dmrBeaconTimer.stop();
						m_modeTimer.start();
					} else {
						LogWarning("DMR data received when in mode %u", m_mode);
					}
				}
			}
		}

		if (ysf != NULL) {
			ret = m_modem->hasYSFSpace();
			if (ret) {
				len = ysf->readData(data);
				if (len > 0U) {
					if (m_mode == MODE_IDLE) {
						setMode(MODE_YSF);
					} else if (m_mode == MODE_YSF) {
						m_modem->writeYSFData(data, len);
						m_modeTimer.start();
					} else {
						LogWarning("System Fusion data received when in mode %u", m_mode);
					}
				}
			}
		}

		if (m_dmrNetwork != NULL) {
			bool run = m_dmrNetwork->wantsBeacon();
			if (dmrBeaconsEnabled && run && m_mode == MODE_IDLE) {
				setMode(MODE_DMR, false);
				dmrBeaconTimer.start();
			}
		}

		unsigned int ms = stopWatch.elapsed();
		m_modem->clock(ms);
		m_modeTimer.clock(ms);
		if (dstar != NULL)
			dstar->clock(ms);
		if (dmr != NULL)
			dmr->clock(ms);
		if (ysf != NULL)
			ysf->clock(ms);
		if (m_dstarNetwork != NULL)
			m_dstarNetwork->clock(ms);
		if (m_dmrNetwork != NULL)
			m_dmrNetwork->clock(ms);
		stopWatch.start();

		dmrBeaconTimer.clock(ms);
		if (dmrBeaconTimer.isRunning() && dmrBeaconTimer.hasExpired()) {
			setMode(MODE_IDLE, false);
			dmrBeaconTimer.stop();
		}

		if (ms < 5U) {
#if defined(_WIN32) || defined(_WIN64)
			::Sleep(5UL);		// 5ms
#else
			::usleep(5000);		// 5ms
#endif
		}
	}

	LogMessage("MMDVMHost is exiting on receipt of SIGHUP1");

	setMode(MODE_IDLE);

	m_modem->close();
	delete m_modem;

	m_display->close();
	delete m_display;

	if (m_dstarNetwork != NULL) {
		m_dstarNetwork->close();
		delete m_dstarNetwork;
	}

	if (m_dmrNetwork != NULL) {
		m_dmrNetwork->close();
		delete m_dmrNetwork;
	}

	delete dstar;
	delete dmr;
	delete ysf;

	return 0;
}
开发者ID:zarya,项目名称:MMDVMHost,代码行数:101,代码来源:MMDVMHost.cpp

示例3: run


//.........这里部分代码省略.........
					}

					if (changed)
						LogMessage("Received data from %10.10s to %10.10s at %10.10s", src, dst, buffer + 4U);
				}
			}

			// Only accept transmission from an already accepted repeater
			if (::memcmp(tag, buffer + 4U, YSF_CALLSIGN_LENGTH) == 0) {
				watchdogTimer.start();

				std::string callsign = std::string((char*)(buffer + 4U), YSF_CALLSIGN_LENGTH);
				CYSFRepeater* rpt = findRepeater(callsign);
				if (rpt != NULL) {
					for (std::vector<CYSFRepeater*>::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
						if ((*it)->m_callsign != callsign)
							network.writeData(buffer, (*it)->m_address, (*it)->m_port);
					}
				}

				if ((buffer[34U] & 0x01U) == 0x01U) {
					LogMessage("Received end of transmission");
					watchdogTimer.stop();
				}
			}
		}

		// Refresh/add repeaters based on their polls
		std::string callsign;
		in_addr address;
		unsigned int port;
		bool ret = network.readPoll(callsign, address, port);
		if (ret) {
			CYSFRepeater* rpt = findRepeater(callsign);
			if (rpt == NULL) {
				LogMessage("Adding %s", callsign.c_str());
				rpt = new CYSFRepeater;
				rpt->m_timer.start();
				rpt->m_callsign = callsign;
				rpt->m_address  = address;
				rpt->m_port     = port;
				m_repeaters.push_back(rpt);
				network.setCount(m_repeaters.size());
			} else {
				rpt->m_timer.start();
				rpt->m_address = address;
				rpt->m_port    = port;
			}
		}

		unsigned int ms = stopWatch.elapsed();
		stopWatch.start();

		network.clock(ms);

		pollTimer.clock(ms);
		if (pollTimer.hasExpired()) {
			for (std::vector<CYSFRepeater*>::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it)
				network.writePoll((*it)->m_address, (*it)->m_port);
			pollTimer.start();
		}

		// Remove any repeaters that haven't reported for a while
		for (std::vector<CYSFRepeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it)
			(*it)->m_timer.clock(ms);

		for (std::vector<CYSFRepeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
			if ((*it)->m_timer.hasExpired()) {
				LogMessage("Removing %s", (*it)->m_callsign.c_str());
				m_repeaters.erase(it);
				network.setCount(m_repeaters.size());
				break;
			}
		}

		watchdogTimer.clock(ms);
		if (watchdogTimer.isRunning() && watchdogTimer.hasExpired()) {
			LogMessage("Network watchdog has expired");
			watchdogTimer.stop();
		}

		dumpTimer.clock(ms);
		if (dumpTimer.hasExpired()) {
			dumpRepeaters();
			dumpTimer.start();
		}

		if (ms < 5U) {
#if defined(_WIN32) || defined(_WIN64)
			::Sleep(5UL);		// 5ms
#else
			::usleep(5000);		// 5ms
#endif
		}
	}

	network.close();

	::LogFinalise();
}
开发者ID:kc2vrj,项目名称:YSFClients,代码行数:101,代码来源:YSFReflector.cpp


注:本文中的CStopWatch::elapsed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。