23 #ifndef C_PNP_ADAPTER_HPP 24 #define C_PNP_ADAPTER_HPP 29 #include <boost/asio.hpp> 30 #include <boost/thread.hpp> 31 #include <boost/shared_ptr.hpp> 32 #include <boost/property_tree/ptree_fwd.hpp> 52 ,
public boost::enable_shared_from_this<CPnpAdapter>
56 typedef boost::shared_ptr<CPnpAdapter>
Pointer;
79 void Timeout(
const boost::system::error_code & e);
88 void HandleRead(
const boost::system::error_code & e);
91 void AfterWrite(
const boost::system::error_code & e);
125 #endif // C_PNP_ADAPTER_HPP PNP adapter that maintains a TCP server for a set of plug-and-play devices.
Definition: CPnpAdapter.hpp:50
void ReadStatePacket(const std::string packet)
Parses a state packet received from the client.
Definition: CPnpAdapter.cpp:394
void Heartbeat()
Refreshes the internal countdown timer.
Definition: CPnpAdapter.cpp:149
void HandleRead(const boost::system::error_code &e)
Handles a packet received from the device.
Definition: CPnpAdapter.cpp:278
void AfterWrite(const boost::system::error_code &e)
Handles when a packet has been sent to the device.
Definition: CPnpAdapter.cpp:366
std::string m_identifier
Unique identifier of this adapter.
Definition: CPnpAdapter.hpp:106
~CPnpAdapter()
Destructs the object.
Definition: CPnpAdapter.cpp:114
void Stop()
Stops the adapter.
Definition: CPnpAdapter.cpp:179
void Start()
Starts the internal countdown timer.
Definition: CPnpAdapter.cpp:127
boost::shared_ptr< CPnpAdapter > Pointer
Convenience type for a shared pointer to self.
Definition: CPnpAdapter.hpp:56
CPnpAdapter(boost::asio::io_service &service, boost::property_tree::ptree &p, CTcpServer::Connection client)
Initializes the TCP server and internal storage.
Definition: CPnpAdapter.cpp:94
boost::shared_ptr< boost::asio::deadline_timer > m_countdown
Countdown until the object destroys itself.
Definition: CPnpAdapter.hpp:100
Buffer adapter device interface.
Definition: IBufferAdapter.hpp:47
boost::asio::io_service & m_ios
The ioservice running this adapter.
Definition: CPnpAdapter.hpp:103
boost::asio::streambuf m_buffer
Stream used to send and receive data.
Definition: CPnpAdapter.hpp:112
CTcpServer::Connection m_client
TCP server for the PNP client.
Definition: CPnpAdapter.hpp:109
void Timeout(const boost::system::error_code &e)
Tells the adapter factory to remove its reference to this object.
Definition: CPnpAdapter.cpp:203
bool m_stopping
Signifies that the adapter is to stop.
Definition: CPnpAdapter.hpp:115
void StartRead()
Schedules the next read operation.
Definition: CPnpAdapter.cpp:237
boost::mutex m_stoppingMutex
Protects access to m_stopping.
Definition: CPnpAdapter.hpp:118
void StartWrite()
Schedules the next write operation.
Definition: CPnpAdapter.cpp:257
General FREEDM Namespace.
Definition: CBroker.cpp:53
boost::shared_ptr< IAdapter > Pointer
Pointer to a physical adapter.
Definition: IAdapter.hpp:72
boost::shared_ptr< boost::asio::ip::tcp::socket > Connection
Convenient type for the client socket.
Definition: CTcpServer.hpp:49
std::string GetCommandPacket()
Sends device commands to the current client.
Definition: CPnpAdapter.cpp:460
static IAdapter::Pointer Create(boost::asio::io_service &service, boost::property_tree::ptree &p, CTcpServer::Connection client)
Creates a shared instance of the PNP adapter.
Definition: CPnpAdapter.cpp:75