22 #include "hardware/Buzzer_odb.h" 23 #include "hardware/GPIO_odb.h" 25 #include "hardware/LED_odb.h" 42 "Base GPIO serialization did something unexpected.");
44 serialized[
"type"] =
"wiegand-reader";
45 serialized[
"attributes"][
"mode"] = in.
mode;
47 serialized[
"relationships"] =
json{};
51 ASSERT_LOG(hwd_service,
"No hardware service.");
53 serialized[
"relationships"][
"gpio-high"] =
54 hwd_service->serialize_device_metadata(in.
gpio_high_);
55 serialized[
"relationships"][
"gpio-low"] =
56 hwd_service->serialize_device_metadata(in.
gpio_low_);
57 serialized[
"relationships"][
"buzzer"] =
58 hwd_service->serialize_device_metadata(in.
buzzer_);
59 serialized[
"relationships"][
"green-led"] =
60 hwd_service->serialize_device_metadata(in.
green_led_);
69 using namespace JSONUtil;
77 if (!device_id.is_nil())
80 odb::lazy_shared_ptr<Hardware::GPIO>(*db->db(), device_id).load();
85 if (!device_id.is_nil())
88 odb::lazy_shared_ptr<Hardware::GPIO>(*db->db(), device_id).load();
93 if (!device_id.is_nil())
96 odb::lazy_shared_ptr<Hardware::Buzzer>(*db->db(), device_id).load();
101 if (!device_id.is_nil())
104 odb::lazy_shared_ptr<Hardware::LED>(*db->db(), device_id).load();
std::chrono::system_clock::time_point extract_with_default(const nlohmann::json &obj, const std::string &key, const std::chrono::system_clock::time_point &tp)
Extract an ISO 8601 datetime string from a json object.
static void unserialize(Hardware::RFIDReader &out, const json &in, const SecurityContext &sc)
An instance of this class represents the configuration of one Wiegand reader.
static void unserialize(WiegandReaderConfig &out, const json &in, const SecurityContext &sc)
This is the header file for a generated source file, GitSHA1.cpp.
ServiceRegistry & get_service_registry()
A function to retrieve the ServiceRegistry from pretty much anywhere.
Thin wrapper around boost::uuids::uuid.
Hardware::GPIOPtr gpio_high_
Database aware Hardware Service.
Hardware::GPIOPtr gpio_low_
A SecurityContext is used to query permission while doing an operation.
static json serialize(const Hardware::RFIDReader &in, const SecurityContext &sc)
Provides various database-related services to consumer.
#define ASSERT_LOG(cond, msg)
std::shared_ptr< ServiceInterface > get_service() const
Retrieve the service instance implementing the ServiceInterface, or nullptr if no such service was re...
Hardware::LEDPtr green_led_
static json serialize(const WiegandReaderConfig &in, const SecurityContext &sc)
Hardware::BuzzerPtr buzzer_