24#include <RobotRaconteur/RobotRaconteurNode.h>
25#include <RobotRaconteur/Subscription.h>
26#include "com__robotraconteur__identifier.h"
27#include <yaml-cpp/yaml.h>
29#include "UtilMacros.h"
33namespace RobotRaconteur
59 com::robotraconteur::identifier::IdentifierPtr
Device;
63 std::vector<com::robotraconteur::identifier::IdentifierPtr>
Tags;
65 std::vector<RobotRaconteur::ServiceSubscriptionFilterNodePtr>
ServiceNodes;
67 std::vector<std::string>
Urls;
75 RobotRaconteur::ServiceSubscriptionFilterNodePtr
UrlAuth;
80 RobotRaconteur::ServiceSubscriptionFilterAttributeGroupOperation_AND;
104 const com::robotraconteur::identifier::IdentifierPtr& device,
105 const std::vector<std::string>& root_object_type,
106 const std::vector<com::robotraconteur::identifier::IdentifierPtr>& tags = {},
107 const std::vector<RobotRaconteur::ServiceSubscriptionFilterNodePtr>& service_nodes = {});
116 const RobotRaconteur::ServiceSubscriptionFilterNodePtr& url_auth =
nullptr);
125 const RobotRaconteur::ServiceSubscriptionFilterPtr& subscription_filter);
220 DeviceConnector(RobotRaconteur::RobotRaconteurNodePtr node =
nullptr,
bool autoconnect =
true);
233 void Init(
const std::vector<DeviceConnectorDetails>& devices);
276 void RemoveDevice(
const std::string& device_nickname,
bool close =
true);
302 RobotRaconteur::ServiceSubscriptionPtr
GetDevice(
const std::string& device_nickname,
bool force_create =
false);
312 bool TryGetDevice(
const std::string& device_nickname, RobotRaconteur::ServiceSubscriptionPtr& device);
339 RobotRaconteur::RobotRaconteurNodePtr node;
340 bool autoconnect =
true;
341 RR_SHARED_PTR<RobotRaconteur::ServiceSubscriptionManager> subscription_manager;
353 const boost::filesystem::path& filename);
364 const std::string& yaml_str);
387 const YAML::Node& node);
std::vector< DeviceConnectorDetails > LoadDeviceDetailsFromFile(const boost::filesystem::path &filename)
Load DeviceDetails list from a YAML file.
std::vector< DeviceConnectorDetails > LoadDeviceDetailsFromYAMLNode(const YAML::Node &node)
Load DeviceDetails list from a YAML node.
std::vector< DeviceConnectorDetails > LoadDeviceDetailsFromStream(std::istream &stream)
Load DeviceDetails list from a YAML stream.
std::vector< DeviceConnectorDetails > LoadDeviceDetailsFromString(const std::string &yaml_str)
Load DeviceDetails list from a YAML string.
std::vector< std::string > GetDeviceNicknames()
Get all nicknames of the devices.
void AddDevice(const DeviceConnectorDetails &device_details, bool force_connect=false)
Add a device to the DeviceConnector.
void DisconnectDevice(const std::string &device_nickname, bool close=true)
Disconnect a device.
void InitFromYamlFile(const boost::filesystem::path &filename)
Initialize the DeviceConnector from a YAML file.
void InitFromYamlFile(std::istream &file)
Initialize the DeviceConnector from a YAML stream.
void InitFromYamlStr(const std::string &yaml)
Initialize the DeviceConnector from a YAML string.
boost::shared_ptr< RobotRaconteur::ServiceSubscriptionManager > GetServiceSubscriptionManager()
Get the underlying ServiceSubscriptionManager used by the DeviceConnector.
void Init()
Initialize the DeviceConnector.
DeviceConnector(RobotRaconteur::RobotRaconteurNodePtr node=nullptr, bool autoconnect=true)
Construct a new DeviceConnector.
void RemoveDevice(const std::string &device_nickname, bool close=true)
Remove a device from the DeviceConnector.
void Init(const std::vector< DeviceConnectorDetails > &devices)
Initialize the DeviceConnector with a list of devices.
RobotRaconteur::ServiceSubscriptionPtr GetDevice(const std::string &device_nickname, bool force_create=false)
Get the Device object.
void Close()
Close the DeviceConnector.
bool TryGetDevice(const std::string &device_nickname, RobotRaconteur::ServiceSubscriptionPtr &device)
Try to get the Device object. Returns false if the device does not exist instead of throwing an excep...
void ConnectDevice(const std::string &device_nickname)
Connect to a device if not already connected.
Device connection information for use with DeviceConnector class.
Definition DeviceConnector.h:55
RobotRaconteur::ServiceSubscriptionFilterNodePtr UrlAuth
The URL auth to use when connecting to the device. Not used with Filter or "device".
Definition DeviceConnector.h:75
std::vector< std::string > RootObjectType
The root object type of the device. Empty if not used. May be necessary when "device" is used.
Definition DeviceConnector.h:69
DeviceConnectorDetails()=default
Construct an empty DeviceConnectorDetails.
std::string DeviceNickname
The nickname of the device.
Definition DeviceConnector.h:57
std::vector< com::robotraconteur::identifier::IdentifierPtr > Tags
The tags of the device. Empty if not used.
Definition DeviceConnector.h:63
std::string SerialNumber
The serial number of the device. Empty if not used.
Definition DeviceConnector.h:61
RobotRaconteur::ServiceSubscriptionFilterAttributeGroupOperation TagMatchOperation
The tag match operation to use with Tags. Defaults to "AND".
Definition DeviceConnector.h:79
RobotRaconteur::ServiceSubscriptionFilterPtr SubscriptionFilter
The subscription filter to use when connecting to the device. Not used with Url or "device".
Definition DeviceConnector.h:71
std::vector< std::string > Urls
A list of URLs to use for direct connection to the device. Empty if not used.
Definition DeviceConnector.h:67
com::robotraconteur::identifier::IdentifierPtr Device
The device identifier (name, uuid) of the device. null if not used.
Definition DeviceConnector.h:59
std::vector< RobotRaconteur::ServiceSubscriptionFilterNodePtr > ServiceNodes
The service nodes of the device. Empty if not used.
Definition DeviceConnector.h:65
DeviceConnectorDetails(const std::string &device_nickname, const std::string &url, const RobotRaconteur::ServiceSubscriptionFilterNodePtr &url_auth=nullptr)
Construct a new DeviceConnectorDetails for use with URL connection.
DeviceConnectorDetails(const std::string &device_nickname)
Construct a new DeviceConnectorDetails with nickname.
DeviceConnectorDetails(const std::string &device_nickname, const std::vector< std::string > &root_object_type, const RobotRaconteur::ServiceSubscriptionFilterPtr &subscription_filter)
Construct a new DeviceConnectorDetails for use with Robot Raconteur subscription filter.
int32_t MaxConnections
The maximum number of connections to the device. 0 for unlimited. Defaults to 10.
Definition DeviceConnector.h:77
DeviceConnectorDetails(const std::string &device_nickname, const com::robotraconteur::identifier::IdentifierPtr &device, const std::vector< std::string > &root_object_type, const std::vector< com::robotraconteur::identifier::IdentifierPtr > &tags={}, const std::vector< RobotRaconteur::ServiceSubscriptionFilterNodePtr > &service_nodes={})
Construct a new DeviceConnectorDetails for use with "device" identifier.
std::vector< std::string > TransportSchemes
The transport schemes to use when connecting to the device. Not used with Url or Filter.
Definition DeviceConnector.h:73