9 #ifndef FCF_DEVMGR_COMMON_DEVICE_FACADE_HPP_
10 #define FCF_DEVMGR_COMMON_DEVICE_FACADE_HPP_
16 #include <rad/smAdapter.hpp>
17 #include <rad/topicPub.hpp>
18 #include <rad/anyEvent.hpp>
19 #include <rad/activity.hpp>
21 #include <fcf/common/dispatcher.hpp>
23 #include <fcf/devmgr/common/events.rad.hpp>
51 fcf::common::Dispatcher<>& failure,
52 fcf::common::Dispatcher<>& normal);
63 virtual bool Init(rad::SMAdapter& sm, rad::ThreadActivity* activity);
72 virtual bool Enable(rad::SMAdapter& sm, rad::ThreadActivity* activity);
81 virtual bool Recover(rad::SMAdapter& sm, rad::ThreadActivity* activity);
109 virtual bool Setup(
const std::any& payload, rad::ThreadActivity* activity);
120 virtual void Reset();
128 virtual void Status(
const std::any& payload, std::string& buffer);
135 virtual void Simulate(rad::AnyEvent
const& last_event);
141 virtual void StopSim(rad::AnyEvent
const& last_event);
147 virtual void Ignore(rad::AnyEvent
const& last_event);
153 virtual void StopIgn(rad::AnyEvent
const& last_event);
159 virtual void HwReset(rad::AnyEvent
const& last_event);
165 virtual void HwInit(rad::AnyEvent
const& last_event);
171 virtual void HwEnable(rad::AnyEvent
const& last_event);
177 virtual void HwDisable(rad::AnyEvent
const& last_event);
195 virtual void BeginAcq(rad::AnyEvent
const& last_event);
212 virtual void EndAcq(rad::AnyEvent
const& last_event);
230 void AddDevice(std::shared_ptr<IDevice> device);
268 void InitSync(rad::ThreadActivity* activity,
269 std::chrono::system_clock::time_point start_time,
281 void EnableSync(rad::ThreadActivity* activity,
282 std::chrono::system_clock::time_point start_time,
291 void DeviceFailureCB();
299 void DeviceNormalCB();
301 void CheckDeviceName(
const std::vector<std::string>& devices)
const;
303 std::vector<std::shared_ptr<IDevice> > m_devices;
304 std::vector<std::string> m_device_names;
305 boost::asio::io_service m_ios;
306 rad::SMAdapter& m_sm;
308 std::string m_dp_filename;
313 fcf::common::Dispatcher<> m_failure;
318 fcf::common::Dispatcher<> m_normal;
324 #endif // FCF_DEVMGR_COMMON_DEVICE_FACADE_HPP_
Device class header file.
virtual ~DeviceFacade()
~DeviceFacade
Definition: deviceFacade.cpp:62
virtual void HwDisable(rad::AnyEvent const &last_event)
Disable hardware.
Definition: deviceFacade.cpp:599
virtual void Reset()
Reset devices.
Definition: deviceFacade.cpp:470
virtual void Simulate(rad::AnyEvent const &last_event)
Simulate devices managed by the server.
Definition: deviceFacade.cpp:497
virtual void Stop()
Abort all devices managed by the devmgr.
Definition: deviceFacade.cpp:460
void ClearDevices()
Empty internal device map.
Definition: deviceFacade.cpp:684
virtual bool Recover(rad::SMAdapter &sm, rad::ThreadActivity *activity)
Recover all devices managed by the devmgr.
Definition: deviceFacade.cpp:242
Definition: deviceFacade.hpp:39
void AddDevice(std::shared_ptr< IDevice > device)
Add a device instance to be managed by the facade.
Definition: deviceFacade.cpp:678
virtual bool Enable(rad::SMAdapter &sm, rad::ThreadActivity *activity)
Enable all devices managed by the devmgr.
Definition: deviceFacade.cpp:113
virtual void StopIgn(rad::AnyEvent const &last_event)
Stop ignoring devices managed by the server.
Definition: deviceFacade.cpp:542
virtual bool Disable()
Disable all devices managed by the devmgr.
Definition: deviceFacade.cpp:346
virtual void HwInit(rad::AnyEvent const &last_event)
Init hardware.
Definition: deviceFacade.cpp:571
const int GetNumDevices()
Get the number of devices.
Definition: deviceFacade.cpp:729
virtual void StopSim(rad::AnyEvent const &last_event)
Stop simulating devices managed by the server.
Definition: deviceFacade.cpp:512
void TriggerInternalEvent(rad::SMAdapter &sm, rad::UniqueEvent &&e)
Trigger an internal event.
Definition: deviceFacade.cpp:672
virtual void Ignore(rad::AnyEvent const &last_event)
Ignore devices managed by the server.
Definition: deviceFacade.cpp:527
virtual void BeginAcq(rad::AnyEvent const &last_event)
Begin Acquisition.
Definition: deviceFacade.cpp:613
fcf::common::Dispatcher & GetFailureCB()
Get reference to failure CB.
Definition: deviceFacade.cpp:691
virtual bool Init(rad::SMAdapter &sm, rad::ThreadActivity *activity)
Init all devices managed by the devmgr.
Definition: deviceFacade.cpp:66
Definition: iConfig.hpp:22
fcf::common::Dispatcher & GetNormalCB()
Get reference to normal CB.
Definition: deviceFacade.cpp:696
virtual void EndAcq(rad::AnyEvent const &last_event)
End Acquisition.
Definition: deviceFacade.cpp:650
virtual bool Setup(const std::any &payload, rad::ThreadActivity *activity)
Executes a setup message.
Definition: deviceFacade.cpp:374
virtual void Status(const std::any &payload, std::string &buffer)
Get status from devices.
Definition: deviceFacade.cpp:482
virtual void HwEnable(rad::AnyEvent const &last_event)
Enable hardware.
Definition: deviceFacade.cpp:585
virtual void HwReset(rad::AnyEvent const &last_event)
Reset hardware.
Definition: deviceFacade.cpp:557
virtual std::string DevNames()
Get list of managed devices.
Definition: deviceFacade.cpp:924
DeviceFacade(rad::SMAdapter &sm, IConfig &config, fcf::common::Dispatcher<> &failure, fcf::common::Dispatcher<> &normal)
Definition: deviceFacade.cpp:43