YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
LLM_nws_yarp.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <LLM_nws_yarp.h>
7
9#include <yarp/os/LogStream.h>
10
11namespace
12{
13YARP_LOG_COMPONENT(LLM_NWS_YARP, "yarp.device.LLM_nws_yarp")
14}
15
17{
18 if (driver->isValid())
19 {
20 driver->view(m_iLlm);
21 }
22
23 if (m_iLlm == nullptr)
24 {
25 yCError(LLM_NWS_YARP, "Subdevice passed to attach method is invalid (it does not implement all the required interfaces)");
26 return false;
27 }
28
29 std::string streaming_name = m_name + "/conv:o";
30 m_RPC.setInterface(m_iLlm, streaming_name);
31
32 yCDebug(LLM_NWS_YARP) << "Attachment successful";
33
34 return true;
35}
36
38{
39 if (!parseParams(config)) { return false; }
40
41 std::string rpc_name = m_name + "/rpc:i";
42 if (!m_RpcPort.open(rpc_name))
43 {
44 yCError(LLM_NWS_YARP) << "Unable to open port:" << m_name;
45 return false;
46 }
47
48 m_RpcPort.setReader(*this);
49
50 yCDebug(LLM_NWS_YARP) << "Waiting to be attached";
51
52 return true;
53}
54
56{
57 m_iLlm = nullptr;
58 return true;
59}
60
62{
66 return true;
67}
68
70{
71 bool b = m_RPC.read(connection);
72 if (b)
73 {
74 return true;
75 }
76
77 yCDebug(LLM_NWS_YARP) << "read() Command failed";
78
79 return false;
80}
void setInterface(yarp::dev::ILLM *_iLlm, const std::string &streaming_port_name)
void unsetInterface()
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
yarp::dev::ILLM * m_iLlm
yarp::os::RpcServer m_RpcPort
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual bool attach(yarp::dev::PolyDriver *drv) override
Attach to another object.
virtual bool open(yarp::os::Searchable &prop) override
Open the DeviceDriver.
ILLMRPCd m_RPC
virtual bool close() override
Close the DeviceDriver.
virtual bool detach() override
Detach the object (you must have first called attach).
bool view(T *&x)
Get an interface to the device driver.
A container for a device driver.
Definition PolyDriver.h:23
bool isValid() const
Check if device is valid.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void setReader(PortReader &reader) override
Set an external reader for port data.
void close() override
Stop port activity.
void interrupt() override
Interrupt any current reads or writes attached to the port.
An interface for reading from a network connection.
A base class for nested structures that can be searched.
Definition Searchable.h:31
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)