6#include <nlohmann/json_fwd.hpp>
82 std::optional<std::vector<DeviceParameter>>
load(uint32_t vendorId, uint32_t productCode,
83 uint32_t revisionNumber)
const;
90 void store(uint32_t vendorId, uint32_t productCode, uint32_t revisionNumber,
91 const std::vector<DeviceParameter>& parameters)
const;
106 static std::string
makeId(uint32_t vendorId, uint32_t productCode, uint32_t revisionNumber);
114 std::vector<CacheEntry>
list()
const;
122 std::expected<std::vector<uint8_t>, std::string>
readRaw(std::string_view
id)
const;
126 std::expected<void, std::string>
remove(std::string_view
id)
const;
132 std::filesystem::path resolveDir()
const;
136 std::filesystem::path pathFor(uint32_t vendorId, uint32_t productCode,
137 uint32_t revisionNumber)
const;
On-disk cache of CoE parameter definitions, keyed by device identity.
Definition parameter_cache.h:55
bool enabledForVendor(uint32_t vendorId) const
Whether the cache is active for vendorId under the current policy.
Definition parameter_cache.cc:137
static constexpr int kFormatVersion
Bumped when the on-disk field set / meaning changes in a way that invalidates older files....
Definition parameter_cache.h:60
void store(uint32_t vendorId, uint32_t productCode, uint32_t revisionNumber, const std::vector< DeviceParameter > ¶meters) const
Persists parameter definitions for an identity (atomic temp-file + rename).
Definition parameter_cache.cc:218
std::expected< void, std::string > remove(std::string_view id) const
Deletes one cache file addressed by its id. Policy-independent.
Definition parameter_cache.cc:305
static std::string makeId(uint32_t vendorId, uint32_t productCode, uint32_t revisionNumber)
Builds the opaque id a client uses to address one cache file, from an identity triple....
Definition parameter_cache.cc:171
std::optional< std::vector< DeviceParameter > > load(uint32_t vendorId, uint32_t productCode, uint32_t revisionNumber) const
Loads the cached parameter definitions for an identity.
Definition parameter_cache.cc:182
std::expected< std::vector< uint8_t >, std::string > readRaw(std::string_view id) const
Reads the raw JSON bytes of one cache file, addressed by its id (for download).
Definition parameter_cache.cc:291
void configure(ParameterCacheConfig config)
Replaces the active policy/location. Called by DeviceManager::init.
Definition parameter_cache.cc:135
std::vector< CacheEntry > list() const
Lists every valid cache file in the cache directory.
Definition parameter_cache.cc:251
Definition http_server.h:16
void to_json(nlohmann::json &j, const Device &d)
Serialises a Device to JSON.
Definition device.cc:915
constexpr uint32_t kSynapticonVendorId
EtherCAT vendor ID of Synapticon (SOMANET drives).
Definition parameter_cache.h:23
Policy and location for the on-disk parameter cache.
Definition parameter_cache.h:28
std::string directory
"" = a standard per-user cache directory (see resolveDir).
Definition parameter_cache.h:31
bool cacheAllVendors
false: cache Synapticon (0x22D2) only; true: cache every vendor.
Definition parameter_cache.h:29
bool enabled
Master switch for the whole cache (false disables it entirely).
Definition parameter_cache.h:32
Summary of one cache file on disk, for the management UI.
Definition parameter_cache.h:94
uint32_t revisionNumber
Revision number from the file header.
Definition parameter_cache.h:98
std::uintmax_t sizeBytes
File size on disk, in bytes.
Definition parameter_cache.h:100
std::string id
Opaque "<vendor>-<product>-<revision>" key (see makeId).
Definition parameter_cache.h:95
uint32_t vendorId
Vendor ID from the file header.
Definition parameter_cache.h:96
uint32_t productCode
Product code from the file header.
Definition parameter_cache.h:97
uint32_t parameterCount
Number of cached parameter definitions in the file.
Definition parameter_cache.h:99