fwt_software/include/fgc/CameraSettingsXml.h

56 lines
2.2 KiB
C++

#pragma once
#include <cstdint>
#include <string>
#include <utility>
#include <vector>
namespace fgc {
// One camera setting as the VimbaX Viewer exported it.
struct SettingEntry {
std::string name;
std::string value;
std::string selector; // "" unless the Viewer nested it in a <SelectorGroup>
};
// The settings a Viewer XML holds, in file order.
//
// These are NEVER applied: the program hands the XML itself to the Vimba X SDK,
// which is what guarantees the camera gets exactly the combination the GUI
// validated. This parse exists only to render a human-readable record and to
// diff one export against the previous one.
struct CameraSettings {
std::string model; // <CameraInfo Model="...">
std::string device_id;
std::vector<SettingEntry> entries; // <RemoteDevice> features, in order
};
// Parse a VimbaX Viewer settings export. Only the <RemoteDevice> block is read:
// the <LocalDevice>/stream sections describe the host's transport layer, not the
// sensor. Throws std::runtime_error naming the problem if the file is missing or
// does not look like a Viewer export.
CameraSettings parseCameraSettingsXml(const std::string& path);
// Render the human-readable record written beside the XML. `xml_name` and
// `hash_label` go in the header so the file says what it came from.
std::string renderSettingsRecord(const CameraSettings& s, const std::string& xml_name,
const std::string& hash_label);
// Read back a record written by renderSettingsRecord. Returns the recorded hash
// label (empty if the file is absent or has none) and the settings it listed, so
// a regeneration can report what actually changed.
struct SettingsRecord {
std::string hash_label;
std::vector<SettingEntry> entries;
};
SettingsRecord readSettingsRecord(const std::string& path);
// Human-readable difference between two settings lists, one line per change:
// "AcquisitionFrameRate 10 -> 8", "+ Gamma 1.2 (new)", "- Sharpness (removed)".
// Empty when they match.
std::vector<std::string> diffSettings(const std::vector<SettingEntry>& before,
const std::vector<SettingEntry>& after);
} // namespace fgc