本文整理汇总了C++中DateAndTime::toISO8601String方法的典型用法代码示例。如果您正苦于以下问题:C++ DateAndTime::toISO8601String方法的具体用法?C++ DateAndTime::toISO8601String怎么用?C++ DateAndTime::toISO8601String使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateAndTime
的用法示例。
在下文中一共展示了DateAndTime::toISO8601String方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: accept
void StartLiveDataDialog::accept()
{
// Now manually set the StartTime property as there's a computation needed
DateAndTime startTime = DateAndTime::getCurrentTime() - ui.dateTimeEdit->value()*60.0;
m_algorithm->setPropertyValue("StartTime",startTime.toISO8601String());
AlgorithmDialog::accept(); // accept executes the algorithm
}
示例2: shiftTimeOfLogForStringProperty
/**
* Shift the times in a log of a string property
* @param logEntry :: the string property
* @param timeShift :: the time shift.
*/
void ChangeTimeZero::shiftTimeOfLogForStringProperty(
PropertyWithValue<std::string> *logEntry, double timeShift) const {
// Parse the log entry and replace all ISO8601 strings with an adjusted value
auto value = logEntry->value();
if (checkForDateTime(value)) {
DateAndTime dateTime(value);
DateAndTime shiftedTime = dateTime + timeShift;
logEntry->setValue(shiftedTime.toISO8601String());
}
}
示例3: saveTimeVector
void saveTimeVector(::NeXus::File * file, TimeSeriesProperty<NumT> * prop)
{
std::vector<DateAndTime> times = prop->timesAsVector();
DateAndTime start = times[0];
std::vector<double> timeSec(times.size());
for (size_t i=0; i<times.size(); i++)
timeSec[i] = double(times[i].totalNanoseconds() - start.totalNanoseconds()) * 1e-9;
file->writeData("time", timeSec);
file->openData("time");
file->putAttr("start", start.toISO8601String() );
file->closeData();
}
示例4: exec
/** Execute the algorithm.
*/
void LoadLiveData::exec() {
// The full, post-processed output workspace
m_outputWS = this->getProperty("OutputWorkspace");
// Validate inputs
if (this->hasPostProcessing()) {
if (this->getPropertyValue("AccumulationWorkspace").empty())
throw std::invalid_argument("Must specify the AccumulationWorkspace "
"parameter if using PostProcessing.");
// The accumulated but not post-processed output workspace
m_accumWS = this->getProperty("AccumulationWorkspace");
} else {
// No post-processing, so the accumulation and output are the same
m_accumWS = m_outputWS;
}
// Get or create the live listener
ILiveListener_sptr listener = this->getLiveListener();
// Do we need to reset the data?
bool dataReset = listener->dataReset();
// The listener returns a MatrixWorkspace containing the chunk of live data.
Workspace_sptr chunkWS;
bool dataNotYetGiven = true;
while (dataNotYetGiven) {
try {
chunkWS = listener->extractData();
dataNotYetGiven = false;
} catch (Exception::NotYet &ex) {
g_log.warning() << "The " << listener->name()
<< " is not ready to return data: " << ex.what() << "\n";
g_log.warning()
<< "Trying again in 10 seconds - cancel the algorithm to stop.\n";
const int tenSeconds = 40;
for (int i = 0; i < tenSeconds; ++i) {
Poco::Thread::sleep(10000 / tenSeconds); // 250 ms
this->interruption_point();
}
}
}
// TODO: Have the ILiveListener tell me exactly the time stamp
DateAndTime lastTimeStamp = DateAndTime::getCurrentTime();
this->setPropertyValue("LastTimeStamp", lastTimeStamp.toISO8601String());
// Now we process the chunk
Workspace_sptr processed = this->processChunk(chunkWS);
bool PreserveEvents = this->getProperty("PreserveEvents");
EventWorkspace_sptr processedEvent =
boost::dynamic_pointer_cast<EventWorkspace>(processed);
if (!PreserveEvents && processedEvent) {
// Convert the monitor workspace, if there is one and it's necessary
MatrixWorkspace_sptr monitorWS = processedEvent->monitorWorkspace();
auto monitorEventWS =
boost::dynamic_pointer_cast<EventWorkspace>(monitorWS);
if (monitorEventWS) {
auto monAlg = this->createChildAlgorithm("ConvertToMatrixWorkspace");
monAlg->setProperty("InputWorkspace", monitorEventWS);
monAlg->executeAsChildAlg();
if (!monAlg->isExecuted())
g_log.error(
"Failed to convert monitors from events to histogram form.");
monitorWS = monAlg->getProperty("OutputWorkspace");
}
// Now do the main workspace
Algorithm_sptr alg = this->createChildAlgorithm("ConvertToMatrixWorkspace");
alg->setProperty("InputWorkspace", processedEvent);
std::string outputName = "__anonymous_livedata_convert_" +
this->getPropertyValue("OutputWorkspace");
alg->setPropertyValue("OutputWorkspace", outputName);
alg->execute();
if (!alg->isExecuted())
throw std::runtime_error("Error when calling ConvertToMatrixWorkspace "
"(since PreserveEvents=False). See log.");
// Replace the "processed" workspace with the converted one.
MatrixWorkspace_sptr temp = alg->getProperty("OutputWorkspace");
if (monitorWS)
temp->setMonitorWorkspace(monitorWS); // Set back the monitor workspace
processed = temp;
}
// How do we accumulate the data?
std::string accum = this->getPropertyValue("AccumulationMethod");
// If the AccumulationWorkspace does not exist, we always replace the
// AccumulationWorkspace.
// Also, if the listener said we are resetting the data, then we clear out the
// old.
if (!m_accumWS || dataReset)
accum = "Replace";
g_log.notice() << "Performing the " << accum << " operation.\n";
// Perform the accumulation and set the AccumulationWorkspace workspace
//.........这里部分代码省略.........
示例5:
/** Circumvent a bug in IPython 1.1, which chokes on nanosecond precision
* datetimes.
* Adding a space to the string returned by the C++ method avoids it being
* given
* the special treatment that leads to the problem.
*/
std::string ISO8601StringPlusSpace(DateAndTime &self) {
return self.toISO8601String() + " ";
}