Exemplo n.º 1
0
/**
 * 更新共享内存线程函数
 *
 * @return void
 */
void *updateQqwry(void *pPtr)
{
    printf("thread(%d) start\n", pthread_self());
    char* cPath = (char*)pPtr;
    while(1)
    {
        char* pName = getQqwryFile(cPath);
        if (pName)
        {
            if (strncmp(pName, cFileName, strlen(pName)) != 0)
            {
                strncpy(cFileName, pName, sizeof(cFileName));
                char cQqwryFile[256];
                memset(cQqwryFile, 0x00, sizeof(cQqwryFile));
                sprintf(cQqwryFile, "%s/%s", cPath, cFileName);
                pthread_rwlock_wrlock(&rwlock);
                closeshare(); // 释放内存
                if (openshare(cQqwryFile))// 打开内存
                    p_share = NULL;
                pthread_rwlock_unlock(&rwlock);
                printf("cQqwryFile = %s\n", cQqwryFile);
            }
            free(pName);
            pName = NULL;
        }
        char cDate1[40] = {"\0"}, cDate2[40] = {"\0"};
        time_t t1, t2;
        unsigned int interval = ONEDAY_SECONF;
        char *tCur = getTimeFormat("%Y-%m-%d");
        if (tCur == NULL)
            goto NEXT;
        sprintf(cDate1, "%s %s", tCur, update_time);
        free(tCur);
        tCur = NULL;
        t1 = getTTime(cDate1, "%Y-%m-%d %H:%M:%S");
        if (t1 > time(NULL))
        {// 今天执行
            interval = t1 - time(NULL);
            goto NEXT;
        }
        // 明天执行
        t2 = t1 + ONEDAY_SECONF;
        interval = t2 - time(NULL);
NEXT:
        printf("interval = %u\n", interval);
        sleep(interval);
    }
    printf("thread(%d) end\n", pthread_self());
}
Exemplo n.º 2
0
	/**@brief Log the lap times to out in two columns separated by tab
	 * @param out The std::ostream object to log the times to
	 * @param formatted A bool whether the time should be
	 * @param decPlaces The number of decimal places to print if formatted
	 *
	 */
	void logLapTimes(std::ostream & out,
			bool formatted, int32_t decPlaces,
			bool endLastLap){
		if(endLastLap){
			startNewLap();
		}
		if(formatted){
			std::vector<VecStr> content;
			VecStr header {"lap", "time"};
			for(const auto & lt : lapTimes_){
				content.emplace_back(VecStr{lt.first,
					getTimeFormat(lt.second, true, decPlaces)});
			}
			printTableOrganized(content, header, out);
		}else{
			for(const auto & lt : lapTimes_){
				out << lt.first << "\t" << lt.second << "\n";
			}
		}
	}
Exemplo n.º 3
0
void LocalePreferences::saveValues() {
    int date = getDateFormat();
    int time = getTimeFormat();

    global.settings->beginGroup("Locale");
    global.settings->setValue("dateFormat", date);
    global.settings->setValue("timeFormat", time);
    global.settings->endGroup();

    datefmt = "MM/dd/yy";
    switch (date) {
    case MMddyy:
        datefmt = "MM/dd/yy";
        break;
    case MMddyyyy:
        datefmt = "MM/dd/yyyy";
        break;
    case Mddyyyy:
        datefmt = "M/dd/yyyy";
        break;
    case Mdyyyy:
        datefmt = "M/d/yyyy";
        break;
    case ddMMyy:
        datefmt = "dd/MM/yy";
        break;
    case dMyy:
        datefmt = "d/M/yy";
        break;
    case ddMMyyyy:
        datefmt = "dd/MM/yyyy";
        break;
    case dMyyyy:
        datefmt = "d/M/yyyy";
        break;
    case yyyyMMdd:
        datefmt = "yyyy-MM-dd";
        break;
    case yyMMdd:
        datefmt = "yy-MM-dd";
        break;
    }

    timefmt = "HH:mm:ss";
    switch (time) {
    case HHmmss:
        timefmt = "HH:mm:ss";
        break;
    case HHmmssa:
        timefmt = "HH:MM:SS a";
        break;
    case HHmm:
        timefmt = "HH:mm";
        break;
    case HHmma:
        timefmt = "HH:mm a";
        break;
    case hhmmss:
        timefmt = "hh:mm:ss";
        break;
    case hhmmssa:
        timefmt = "hh:mm:ss a";
        break;
    case hhmm:
        timefmt = "hh:mm";
        break;
    case hhmma:
        timefmt = "hh:mm a";
        break;
    case hmma:
        timefmt = "h:mm a";
        break;
    case hmmssa:
        timefmt = "h:mm:ss a";
        break;
    }
    global.dateFormat = datefmt;
    global.timeFormat = timefmt;
}
Exemplo n.º 4
0
	/**@brief Get formatted time since last point formatted
	 *
	 * @param decPlaces How many decimal places to round to
	 * @return A string with the time formatted for hrs, min, secs etc.
	 */
	std::string timeLapFormatted(int32_t decPlaces = 6){
		return getTimeFormat(getTimeDiff(currentLap_),true, decPlaces);
	}
Exemplo n.º 5
0
	/**@brief Get formatted time since start formatted
	 *
	 * @param decPlaces How many decimal places to round to
	 * @return A string with the time formatted for hrs, min, secs etc.
	 */
	std::string totalTimeFormatted(int32_t decPlaces = 6){
		return getTimeFormat(getTimeDiff(start_),true, decPlaces);
	}