#include "SystemClock.h" #include "ClockClient.h" #include "Timestamp.h" #include "bridge.h" #include "clockkit/src/lib.rs.h" #include "PhaseLockedClock.h" #include "kissnet.hpp" #include #include #include namespace bridge { std::pair buildClock(ConfigReader config) { auto cli = new dex::ClockClient(kissnet::endpoint(std::string(config.server), config.port)); cli->setTimeout(config.timeout); cli->setAcknowledge(true); auto plc = new dex::PhaseLockedClock(dex::SystemClock::instance(), *cli); plc->setPhasePanic(dex::DurFromUsec(config.phasePanic)); plc->setUpdatePanic(dex::DurFromUsec(config.updatePanic)); return std::make_pair(plc, cli); } std::shared_ptr buildPLC(ConfigReader config) { auto [plc, cli] = buildClock(config); return std::shared_ptr(plc); } int64_t getValue(std::shared_ptr clock) { auto val = clock->getValue(); return dex::UsecFromTp(val); } void setPhasePanic(std::shared_ptr clock, int64_t micros) { auto val = dex::DurFromUsec(micros); clock->setPhasePanic(val); } void setUpdatePanic(std::shared_ptr clock, int64_t micros) { auto val = dex::DurFromUsec(micros); clock->setUpdatePanic(val); } } // ns bridge