Build Packages / Build documentation (push) Successful in 48s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 15m47s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 23m19s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 18m47s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 5m54s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 11m27s
Build Packages / Unit tests (push) Successful in 1h50m25s
Build Packages / Validation Battery (push) Successful in 46m38s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 32m52s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 32m32s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 28m34s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 29m19s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 30m11s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 33m58s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 31m26s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 34m4s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 26m59s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 31m50s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 32m17s
Build Packages / Generate python client (push) Successful in 32s
Build Packages / Create release (push) Successful in 9s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 19m38s
* jfjoch_broker (experimental): Live Rugnux covers serial collections from DECTRIS detectors; a rotation collection too large for the image buffer falls back to standard per-image processing with a warning, and a stream that ends without its end message finishes the collection instead of hanging it. * jfjoch_broker (experimental): Live Rugnux settings to build the solvent during refinement and to process a rotation collection as stills, a Clear action for the last result, a `_report.txt` for live rotation runs, R-free reported for the refined model, and ice-ring detection on by default for rotation as in the command line. * jfjoch_broker (experimental): More complete and reproducible live serial merges, analysed for twinning, pseudo-translation and anisotropy, with merging statistics by resolution shell in the live status. * jfjoch_writer: Live results with large models are written reliably; update jfjoch_writer together with jfjoch_broker. * Rugnux: Several masters can be processed together with `--force-still`, including grid scans; more robust and faster merging of several sweeps; improved twinning, pseudo-translation, anisotropy, anomalous-signal and space-group decisions. * Rugnux: Molecular replacement places the copies of a multi-copy solution together; the pseudo-translation warning quotes the Patterson peak and is not raised once a model is placed; the report advises on extending the rotation or reorienting the crystal where the coverage would gain from it. * Web frontend: Light and dark modes, a phone layout, a hideable page list, a redesigned Rugnux live page with step-through of the Fo-Fc peaks in the structure view. * jfjoch_viewer: A broker URL given on the command line follows the running collection. Reviewed-on: #97 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
110 lines
3.2 KiB
C++
110 lines
3.2 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <chrono>
|
|
#include <regex>
|
|
#include <iomanip>
|
|
#include <sstream>
|
|
#include <stdexcept>
|
|
#include <ctime>
|
|
#include <cstdio>
|
|
|
|
inline double SecondsSince(std::chrono::steady_clock::time_point t0) {
|
|
return std::chrono::duration<double>(std::chrono::steady_clock::now() - t0).count();
|
|
}
|
|
|
|
inline std::string time_UTC(const std::chrono::time_point<std::chrono::system_clock> &input) {
|
|
auto time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(input.time_since_epoch()).count();
|
|
|
|
char buf1[255], buf2[255];
|
|
time_t time = time_ms / (1000);
|
|
|
|
std::tm tm_utc{};
|
|
#ifdef _WIN32
|
|
if (gmtime_s(&tm_utc, &time) != 0)
|
|
#else
|
|
if (gmtime_r(&time, &tm_utc) == nullptr)
|
|
#endif
|
|
throw std::runtime_error("gmtime failed");
|
|
|
|
strftime(buf1, sizeof(buf1), "%FT%T", &tm_utc);
|
|
snprintf(buf2, sizeof(buf2), ".%03d", static_cast<int>(time_ms % 1000));
|
|
return std::string(buf1) + std::string(buf2) + "Z";
|
|
}
|
|
|
|
inline uint64_t parse_UTC_to_ms(const std::string& utc_string) {
|
|
static const std::regex re(
|
|
R"(^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,6}))?Z$)",
|
|
std::regex::ECMAScript);
|
|
|
|
std::smatch match;
|
|
if (!std::regex_match(utc_string, match, re)) {
|
|
throw std::runtime_error("Invalid UTC timestamp format: " + utc_string);
|
|
}
|
|
|
|
std::tm tm = {};
|
|
tm.tm_year = std::stoi(match[1]) - 1900;
|
|
tm.tm_mon = std::stoi(match[2]) - 1;
|
|
tm.tm_mday = std::stoi(match[3]);
|
|
tm.tm_hour = std::stoi(match[4]);
|
|
tm.tm_min = std::stoi(match[5]);
|
|
tm.tm_sec = std::stoi(match[6]);
|
|
|
|
int milliseconds = 0;
|
|
if (match[7].matched) {
|
|
std::string frac = match[7].str();
|
|
|
|
if (frac.size() > 3) {
|
|
frac = frac.substr(0, 3);
|
|
} else if (frac.size() < 3) {
|
|
while (frac.size() < 3) frac.push_back('0');
|
|
}
|
|
|
|
milliseconds = std::stoi(frac);
|
|
}
|
|
|
|
#ifdef _WIN32
|
|
time_t t = _mkgmtime(&tm);
|
|
#else
|
|
time_t t = timegm(&tm);
|
|
#endif
|
|
return static_cast<uint64_t>(t) * 1000ULL + milliseconds;
|
|
}
|
|
|
|
inline std::string utc_to_local_human_readable(const std::string& utc_string) {
|
|
using namespace std::chrono;
|
|
|
|
try {
|
|
uint64_t ms_since_epoch = parse_UTC_to_ms(utc_string);
|
|
auto tp = system_clock::time_point(milliseconds(ms_since_epoch));
|
|
time_t t = system_clock::to_time_t(tp);
|
|
|
|
std::tm tm_local{};
|
|
#ifdef _WIN32
|
|
if (localtime_s(&tm_local, &t) != 0)
|
|
#else
|
|
if (localtime_r(&t, &tm_local) == nullptr)
|
|
#endif
|
|
return "";
|
|
|
|
static const char* months[] = {
|
|
"January", "February", "March", "April", "May", "June",
|
|
"July", "August", "September", "October", "November", "December"
|
|
};
|
|
|
|
std::ostringstream out;
|
|
out << months[tm_local.tm_mon] << " "
|
|
<< std::setw(2) << std::setfill('0') << tm_local.tm_mday << ", "
|
|
<< (tm_local.tm_year + 1900) << " "
|
|
<< std::setw(2) << std::setfill('0') << tm_local.tm_hour << ":"
|
|
<< std::setw(2) << std::setfill('0') << tm_local.tm_min;
|
|
|
|
return out.str();
|
|
} catch (...) {
|
|
return "";
|
|
}
|
|
}
|