本文整理汇总了C++中CStopWatch::start方法的典型用法代码示例。如果您正苦于以下问题:C++ CStopWatch::start方法的具体用法?C++ CStopWatch::start怎么用?C++ CStopWatch::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStopWatch
的用法示例。
在下文中一共展示了CStopWatch::start方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
CDMRNetwork::CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, bool rssi, HW_TYPE hwType) :
m_address(),
m_port(port),
m_id(NULL),
m_password(password),
m_duplex(duplex),
m_version(version),
m_debug(debug),
m_socket(local),
m_enabled(false),
m_slot1(slot1),
m_slot2(slot2),
m_rssi(rssi),
m_hwType(hwType),
m_status(WAITING_CONNECT),
m_retryTimer(1000U, 10U),
m_timeoutTimer(1000U, 60U),
m_buffer(NULL),
m_salt(NULL),
m_streamId(NULL),
m_rxData(1000U, "DMR Network"),
m_options(),
m_callsign(),
m_rxFrequency(0U),
m_txFrequency(0U),
m_power(0U),
m_colorCode(0U),
m_latitude(0.0F),
m_longitude(0.0F),
m_height(0),
m_location(),
m_description(),
m_url(),
m_beacon(false)
{
assert(!address.empty());
assert(port > 0U);
assert(id > 1000U);
assert(!password.empty());
m_address = CUDPSocket::lookup(address);
m_buffer = new unsigned char[BUFFER_LENGTH];
m_salt = new unsigned char[sizeof(uint32_t)];
m_id = new uint8_t[4U];
m_streamId = new uint32_t[2U];
m_streamId[0U] = 0x00U;
m_streamId[1U] = 0x00U;
m_id[0U] = id >> 24;
m_id[1U] = id >> 16;
m_id[2U] = id >> 8;
m_id[3U] = id >> 0;
CStopWatch stopWatch;
::srand(stopWatch.start());
}
示例2: GeneticProcess
void GeneticProcess(void) {
if (bSimulate && curGeneration < MAXGENERATION ) {
myWatch.start();
solver->nextGeneration();
solver->computeFitness();
curGeneration++;
err[curGeneration] = evalError(solver->getBestFitness());
record[curGeneration] = solver->recordBroken;
myWatch.stop();
totalCompTime += myWatch.getTotalElapsedTime();
}
}
示例3: keyboardFunction
void keyboardFunction(unsigned char key, int x, int y) {
if (key == 27) exit(0);
switch (key) {
case 's':
if(!myWatch.bRunning()) {
Simulator->init();
myWatch.start();
}
else myWatch.stop();
break;
case 'p':
myWatch.pause();
break;
case 'r':
myWatch.resume();
default:
break;
}
}
示例4:
CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, bool duplex, const char* version, bool debug) :
m_socket(localPort),
m_address(),
m_port(gatewayPort),
m_duplex(duplex),
m_version(version),
m_debug(debug),
m_enabled(false),
m_outId(0U),
m_outSeq(0U),
m_inId(0U),
m_buffer(1000U, "D-Star Network"),
m_pollTimer(1000U, 60U),
m_linkStatus(LS_NONE),
m_linkReflector(NULL)
{
m_address = CUDPSocket::lookup(gatewayAddress);
m_linkReflector = new unsigned char[DSTAR_LONG_CALLSIGN_LENGTH];
CStopWatch stopWatch;
::srand(stopWatch.start());
}
示例5: run
int CMMDVMHost::run()
{
bool ret = m_conf.read();
if (!ret) {
::fprintf(stderr, "MMDVMHost: cannot read the .ini file\n");
return 1;
}
ret = ::LogInitialise(m_conf.getLogPath(), m_conf.getLogRoot(), m_conf.getLogDisplay());
if (!ret) {
::fprintf(stderr, "MMDVMHost: unable to open the log file\n");
return 1;
}
::LogSetLevel(m_conf.getLogLevel());
LogInfo(HEADER1);
LogInfo(HEADER2);
LogInfo(HEADER3);
LogInfo(HEADER4);
LogMessage("MMDVMHost-%s is starting", VERSION);
readParams();
ret = createModem();
if (!ret)
return 1;
createDisplay();
if (m_dstarEnabled && m_conf.getDStarNetworkEnabled()) {
ret = createDStarNetwork();
if (!ret)
return 1;
}
if (m_dmrEnabled && m_conf.getDMRNetworkEnabled()) {
ret = createDMRNetwork();
if (!ret)
return 1;
}
CTimer dmrBeaconTimer(1000U, 4U);
bool dmrBeaconsEnabled = m_dmrEnabled && m_conf.getDMRBeacons();
CStopWatch stopWatch;
stopWatch.start();
CDStarControl* dstar = NULL;
if (m_dstarEnabled) {
std::string callsign = m_conf.getCallsign();
std::string module = m_conf.getDStarModule();
unsigned int timeout = m_conf.getTimeout();
bool duplex = m_conf.getDuplex();
LogInfo("D-Star Parameters");
LogInfo(" Callsign: %s", callsign.c_str());
LogInfo(" Module: %s", module.c_str());
LogInfo(" Timeout: %us", timeout);
dstar = new CDStarControl(callsign, module, m_dstarNetwork, m_display, timeout, duplex);
}
CDMRControl* dmr = NULL;
if (m_dmrEnabled) {
unsigned int id = m_conf.getDMRId();
unsigned int colorCode = m_conf.getDMRColorCode();
unsigned int timeout = m_conf.getTimeout();
LogInfo("DMR Parameters");
LogInfo(" Id: %u", id);
LogInfo(" Color Code: %u", colorCode);
LogInfo(" Timeout: %us", timeout);
dmr = new CDMRControl(id, colorCode, timeout, m_modem, m_dmrNetwork, m_display);
}
CYSFEcho* ysf = NULL;
if (m_ysfEnabled)
ysf = new CYSFEcho(2U, 10000U);
m_modeTimer.setTimeout(m_conf.getModeHang());
setMode(MODE_IDLE);
while (!m_killed) {
unsigned char data[200U];
unsigned int len;
bool ret;
len = m_modem->readDStarData(data);
if (dstar != NULL && len > 0U) {
if (m_mode == MODE_IDLE) {
bool ret = dstar->writeModem(data);
if (ret)
setMode(MODE_DSTAR);
} else if (m_mode == MODE_DSTAR) {
dstar->writeModem(data);
m_modeTimer.start();
//.........这里部分代码省略.........
示例6: run
int CMMDVMHost::run()
{
bool ret = m_conf.read();
if (!ret) {
::fprintf(stderr, "MMDVMHost: cannot read the .ini file\n");
return 1;
}
ret = ::LogInitialise(m_conf.getLogPath(), m_conf.getLogRoot(), m_conf.getLogDisplay());
if (!ret) {
::fprintf(stderr, "MMDVMHost: unable to open the log file\n");
return 1;
}
::LogSetLevel(m_conf.getLogLevel());
LogInfo(HEADER1);
LogInfo(HEADER2);
LogInfo(HEADER3);
LogMessage("MMDVMHost-%s is starting", VERSION);
readParams();
ret = createModem();
if (!ret)
return 1;
createDisplay();
if (m_dmrEnabled) {
ret = createDMRNetwork();
if (!ret)
return 1;
}
CStopWatch stopWatch;
stopWatch.start();
CDStarEcho* dstar = NULL;
if (m_dstarEnabled)
dstar = new CDStarEcho(2U, 10000U);
CDMRControl* dmr = NULL;
if (m_dmrEnabled) {
unsigned int id = m_conf.getDMRId();
unsigned int colorCode = m_conf.getDMRColorCode();
unsigned int timeout = m_conf.getTimeout();
LogInfo("DMR Parameters");
LogInfo(" Id: %u", id);
LogInfo(" Color Code: %u", colorCode);
LogInfo(" Timeout: %us", timeout);
dmr = new CDMRControl(id, colorCode, timeout, m_modem, m_dmrNetwork, m_display);
}
CYSFEcho* ysf = NULL;
if (m_ysfEnabled)
ysf = new CYSFEcho(2U, 10000U);
unsigned char mode = MODE_IDLE;
CTimer modeTimer(1000U, m_conf.getModeHang());
m_display->setIdle();
while (!m_killed) {
unsigned char data[200U];
unsigned int len;
bool ret;
len = m_modem->readDStarData(data);
if (dstar != NULL && len > 0U) {
if (mode == MODE_IDLE && (data[0U] == TAG_HEADER || data[0U] == TAG_DATA)) {
LogMessage("Mode set to D-Star");
mode = MODE_DSTAR;
m_display->setDStar();
m_modem->setMode(MODE_DSTAR);
modeTimer.start();
}
if (mode != MODE_DSTAR) {
LogWarning("D-Star data received when in mode %u", mode);
} else {
if (data[0U] == TAG_HEADER || data[0U] == TAG_DATA || data[0U] == TAG_EOT) {
dstar->writeData(data, len);
modeTimer.start();
}
}
}
len = m_modem->readDMRData1(data);
if (dmr != NULL && len > 0U) {
if (mode == MODE_IDLE) {
bool ret = dmr->processWakeup(data);
if (ret) {
LogMessage("Mode set to DMR");
mode = MODE_DMR;
m_display->setDMR();
// This sets the mode to DMR within the modem
m_modem->writeDMRStart(true);
//.........这里部分代码省略.........
示例7: run
void CYSFReflector::run()
{
bool ret = m_conf.read();
if (!ret) {
::fprintf(stderr, "YSFRefector: cannot read the .ini file\n");
return;
}
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel());
if (!ret) {
::fprintf(stderr, "YSFReflector: unable to open the log file\n");
return;
}
#if !defined(_WIN32) && !defined(_WIN64)
bool m_daemon = m_conf.getDaemon();
if (m_daemon) {
// Create new process
pid_t pid = ::fork();
if (pid == -1) {
::LogWarning("Couldn't fork() , exiting");
return;
}
else if (pid != 0)
exit(EXIT_SUCCESS);
// Create new session and process group
if (::setsid() == -1) {
::LogWarning("Couldn't setsid(), exiting");
return;
}
// Set the working directory to the root directory
if (::chdir("/") == -1) {
::LogWarning("Couldn't cd /, exiting");
return;
}
::close(STDIN_FILENO);
::close(STDOUT_FILENO);
::close(STDERR_FILENO);
//If we are currently root...
if (getuid() == 0) {
struct passwd* user = ::getpwnam("mmdvm");
if (user == NULL) {
::LogError("Could not get the mmdvm user, exiting");
return;
}
uid_t mmdvm_uid = user->pw_uid;
gid_t mmdvm_gid = user->pw_gid;
//Set user and group ID's to mmdvm:mmdvm
if (setgid(mmdvm_gid) != 0) {
::LogWarning("Could not set mmdvm GID, exiting");
return;
}
if (setuid(mmdvm_uid) != 0) {
::LogWarning("Could not set mmdvm UID, exiting");
return;
}
//Double check it worked (AKA Paranoia)
if (setuid(0) != -1) {
::LogWarning("It's possible to regain root - something is wrong!, exiting");
return;
}
}
}
#endif
CNetwork network(m_conf.getNetworkPort(), m_conf.getName(), m_conf.getDescription(), m_conf.getNetworkDebug());
ret = network.open();
if (!ret)
return;
CStopWatch stopWatch;
stopWatch.start();
CTimer dumpTimer(1000U, 120U);
dumpTimer.start();
CTimer pollTimer(1000U, 5U);
pollTimer.start();
LogMessage("Starting YSFReflector-%s", VERSION);
CTimer watchdogTimer(1000U, 0U, 1500U);
unsigned char tag[YSF_CALLSIGN_LENGTH];
unsigned char src[YSF_CALLSIGN_LENGTH];
unsigned char dst[YSF_CALLSIGN_LENGTH];
for (;;) {
unsigned char buffer[200U];
unsigned int len = network.readData(buffer);
//.........这里部分代码省略.........