// Convert epicsTime into "mm/dd/yyyy 00:00:00.000000000" bool epicsTime2string (const epicsTime &time, stdString &txt) { char buffer[50]; epicsTimeStamp stamp = time; if (stamp.nsec == 0 && stamp.secPastEpoch <= 1000) { sprintf(buffer, "%d", stamp.secPastEpoch); txt = buffer; return true; } if (! isValidTime(time)) { txt = "00:00:00"; return false; } struct local_tm_nano_sec tm = (local_tm_nano_sec) time; sprintf(buffer, "%02d/%02d/%04d %02d:%02d:%02d.%09ld", tm.ansi_tm.tm_mon + 1, tm.ansi_tm.tm_mday, tm.ansi_tm.tm_year + 1900, tm.ansi_tm.tm_hour, tm.ansi_tm.tm_min, tm.ansi_tm.tm_sec, tm.nSec); txt = buffer; return true; }
void TimeEntry::on_change ( ) { Glib::ustring str = get_text(); if ( isValidTime(str) ) { previousTime = str; } else { set_text(previousTime); } }
void output_ascii(const stdString &archive_name, const stdString &channel_name, const epicsTime &start, const epicsTime &end) { Archive archive(new ARCHIVE_TYPE(archive_name)); ChannelIterator channel(archive); ValueIterator value(archive); if (! archive.findChannelByName(channel_name, channel)) { printf("# Channel not found: %s\n", channel_name.c_str()); return; } printf("channel=%s\n", channel_name.c_str()); if (! channel->getValueAfterTime (start, value)) { printf("# no values\n"); return; } CtrlInfo info; double period=-1; epicsTime last_time = nullTime; while (value && (!isValidTime(end) || value->getTime() < end)) { if (period != value.getPeriod()) { period = value.getPeriod(); output_header(value); } if (info != *value->getCtrlInfo()) { info = *value->getCtrlInfo(); output_info(&info); } if (isValidTime(last_time) && value->getTime() < last_time) printf("Error: back in time:\n"); value->show(stdout); fputs("\n", stdout); last_time = value->getTime(); ++value; } }
void CircularBuffer::addRawValue(const RawValue::Data *value) { #ifdef DEBUG_CIRCBUF printf("CircularBuffer(0x%lX)::add: ", (unsigned long)this); RawValue::show(stdout, type, count, value); #endif if (!isValidTime(RawValue::getTime(value))) { LOG_MSG("CircularBuffer added bad time stamp!\n"); } memcpy(getNextElement(), value, element_size); }
void epicsTime2vals(const epicsTime &time, int &year, int &month, int &day, int &hour, int &min, int &sec, unsigned long &nano) { if (isValidTime(time)) { struct local_tm_nano_sec tm = (local_tm_nano_sec) time; year = tm.ansi_tm.tm_year + 1900; month = tm.ansi_tm.tm_mon + 1; day = tm.ansi_tm.tm_mday; hour = tm.ansi_tm.tm_hour; min = tm.ansi_tm.tm_min; sec = tm.ansi_tm.tm_sec; nano = tm.nSec; } else { year = month = day = hour = min = sec = 0; nano = 0; } }
const RawValue::Data *CircularBuffer::removeRawValue() { RawValue::Data *val; if (tail == head) val = 0; else { if (++tail >= max_index) tail = 0; val = getElement(tail); } if (val && !isValidTime(RawValue::getTime(val))) { LOG_MSG("CircularBuffer returns bad time stamp!\n"); } #ifdef DEBUG_CIRCBUF printf("CircularBuffer(0x%lX)::remove: ", (unsigned long)this); RawValue::show(stdout, type, count, val); #endif return val; }
bool ArchiveParser::handleValue(ChannelIterator &channel) { if (!_value) { printf("Line %zd: no header, yet\n", getLineNo()); return false; } // Format of line: time\tvalue\tstatus const stdString &line = getLine(); size_t valtab = line.find('\t'); if (valtab == stdString::npos) { printf("Line %zd: expected time stamp of value\n%s\n", getLineNo(), line.c_str()); return false; } // Time: stdString text = line.substr(0, valtab); epicsTime time; if (! string2epicsTime(text, time)) { printf("Line %zd: invalid time '%s'\n", getLineNo(), text.c_str()); return false; } _value->setTime(time); stdString status; stdString value = line.substr(valtab+1); size_t stattab = value.find('\t'); if (stattab != stdString::npos) { status = value.substr(stattab+1); value = value.substr(0, stattab); } // Value: if (! _value->parseValue(value)) { printf("Line %zd: invalid value '%s'\n%s\n", getLineNo(), value.c_str(), line.c_str()); return false; } // Status: if (status.empty()) _value->setStatus(0, 0); else { if (!_value->parseStatus(status)) { printf("Line %zd: invalid status '%s'\n%s\n", getLineNo(), status.c_str(), line.c_str()); return false; } } if (isValidTime(_last_time) && _value->getTime() < _last_time) { printf("Line %zd: back in time\n", getLineNo()); return false; } size_t avail = channel->lockBuffer(*_value, _period); if (avail <= 0 || _new_ctrl_info) { channel->addBuffer(*_value, _period, _buffer_alloc); if (_buffer_alloc < MAX_VALS_PER_BUF) _buffer_alloc *= BUF_GROWTH_RATE; _new_ctrl_info = false; } channel->addValue(*_value); channel->releaseBuffer(); _last_time = _value->getTime(); return true; }
bool TimeLimit::SlashCommand ( int playerID, bz_ApiString cmd, bz_ApiString, bz_APIStringList* cmdParams ) { if (strcasecmp (cmd.c_str(), "timelimit")) { return false; } // Check permissions if (! bz_hasPerm(playerID,"TIMELIMIT")) { bz_sendTextMessagef (BZ_SERVER, playerID, "You do not have permission to run the timelimit command"); return true; } // If the server is not configured for manual countdown the timelimit // command can't be used if (! bz_isTimeManualStart()) { bz_sendTextMessagef (BZ_SERVER, playerID, "This server was not configured for manual clock countdowns"); return true; } if (cmdParams->get(0).c_str()[0] == '\0') { bz_sendTextMessagef (BZ_SERVER, playerID, "Usage : /timelimit <minutes>|show|reset"); return true; } // displaying the current timelimit if (strcasecmp(cmdParams->get(0).c_str(),"show") == 0 ) { bz_sendTextMessagef (BZ_SERVER, playerID,"Match duration is set to %.0f minute(s)",(bz_getTimeLimit() / 60)); return true; } // check if there is already a countdown in progress or if a match is // already in progress if ( bz_isCountDownInProgress() ) { bz_sendTextMessagef (BZ_SERVER, playerID, "There is a countdown already in progress, match duration can't be changed now"); return true; } else if ( bz_isCountDownActive() ) { bz_sendTextMessagef (BZ_SERVER, playerID, "A game is already in progress, match duration can't be changed now"); return true; } bz_BasePlayerRecord *playerRecord; playerRecord = bz_getPlayerByIndex(playerID); // resets the timer to the default if (strcasecmp(cmdParams->get(0).c_str(),"reset") == 0 ) { bz_setTimeLimit(saveTimeLimit); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Match duration reset to %.0f minute(s) by %s",(bz_getTimeLimit() / 60),playerRecord->callsign.c_str()); return true; } unsigned i, nonumber=0; for (i=0; i < strlen(cmdParams->get(0).c_str()); i++) { if (isdigit(cmdParams->get(0).c_str()[i]) == 0) nonumber=1; } if (nonumber == 0 ) { float limit = (float)atof(cmdParams->get(0).c_str()); // Don't allow timelimit being equal or lower then 0 if (limit > 0 ) { if (! isValidTime(limit)) { showMatchDurations(playerID); return true; } bz_setTimeLimit(limit * 60); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Match duration set to %.0f minute(s) by %s",(bz_getTimeLimit() / 60),playerRecord->callsign.c_str()); } else { bz_sendTextMessagef (BZ_SERVER, playerID, "Match duration can't be equal or lower then 0"); return true; } } else { bz_sendTextMessagef (BZ_SERVER, playerID, "Not a correct value"); return true; } return true; }
void ColorTimeCache::addSample(double t, Color col) { if (isValidTime(t)) { samples[offset(t)].color += col; } }