19 #ifndef __ICUBCLIENT_OPCC_H__ 20 #define __ICUBCLIENT_OPCC_H__ 48 bool write(yarp::os::Bottle &cmd, yarp::os::Bottle &reply,
bool Verbose=
false);
62 Entity* complement_place =
nullptr,
63 Entity* complement_time =
nullptr,
64 Entity* complement_manner =
nullptr);
93 std::string name_appended = name;
99 name_appended = name +
"_" + std::to_string(appendix);
105 o->m_name = name_appended;
125 yError() <<
"Trying to add an already existing entity (" << name <<
")";
126 return dynamic_cast<T*
>(e);
145 if(yarp::os::Network::isConnected(opc.getName().c_str(), (
"/" + opcName +
"/rpc").c_str())) {
160 return yarp::os::Network::connect(opc.getName().c_str(), (
"/" + opcName +
"/rpc").c_str());
184 bool setEntityProperty(std::string sourceEntityName, std::string propertyName, std::string targetEntityName);
205 double lifeTime = -1,
206 Entity* complement_place =
nullptr,
207 Entity* complement_time =
nullptr,
208 Entity* complement_manner =
nullptr 228 Entity* complement_place =
nullptr,
229 Entity* complement_time =
nullptr,
230 Entity* complement_manner =
nullptr 241 Entity* complement_place =
nullptr,
242 Entity* complement_time =
nullptr,
243 Entity* complement_manner =
nullptr 272 std::list<Relation>
getRelationsMatching(std::string subject =
"any",std::string verb =
"any", std::string
object =
"any", std::string c_place =
"any", std::string c_time =
"any", std::string c_manner =
"any" );
279 std::list<Relation>
getRelationsMatchingLoosly(std::string subject =
"any", std::string verb =
"any", std::string
object =
"any", std::string c_place =
"any", std::string c_time =
"any", std::string c_manner =
"any");
321 void checkout(
bool updateCache=
true);
348 std::list<Entity*>
Entities(
const yarp::os::Bottle &condition);
353 std::list<Entity*>
Entities(
const std::string &prop,
const std::string &op,
const std::string &value);
std::list< Relation > getRelationsMatching(std::string subject="any", std::string verb="any", std::string object="any", std::string c_place="any", std::string c_time="any", std::string c_manner="any")
Returns a list of all existing relations between entities.
Represent any entity that can be stored within the OPC.
bool containsRelation(Entity *subject, Entity *verb, Entity *object=nullptr, Entity *complement_place=nullptr, Entity *complement_time=nullptr, Entity *complement_manner=nullptr)
Check if a relation exists.
void close()
Close the client ports.
Grants access to high level motor commands (grasp, touch, look, goto, etc) of the robot as well as it...
std::list< Relation > getRelationsMatchingLoosly(std::string subject="any", std::string verb="any", std::string object="any", std::string c_place="any", std::string c_time="any", std::string c_manner="any")
Returns a list of all existing relations between entities.
void commit()
Commit all the entities & relations stored locally, erasing the server copies.
T * addOrRetrieveEntity(const std::string &name)
Obtains an entity with the given name.
bool connect(const std::string &opcName)
Try to connect the client to an OPC server.
bool changeName(Entity *e, const std::string &newName)
Change the name of an entity and send messages to relevant subsystems.
bool removeRelation(const Relation &r)
Try to remove a relation between two entities.
T * addEntity(const std::string &name)
Creates a new entity.
OPCClient(const std::string &moduleName)
Create an OPC client.
std::list< Entity * > EntitiesCache() const
Getter of the list of entities stored locally.
bool write(yarp::os::Bottle &cmd, yarp::os::Bottle &reply, bool Verbose=false)
Send a command to the OPC and return the reply.
std::list< std::shared_ptr< Entity > > EntitiesCacheCopy() const
Getter of the list of the copies of the entities stored locally.
Entity * getEntity(const std::string &name, bool forceUpdate=false)
Gets an entity based on its name, but do no create it if it doesn't exist yet.
std::string toString()
Returns a human readable description of the client content (Entities & Relations) ...
std::list< Relation > getRelations()
Returns a list of all existing relations between entities.
bool setEntityProperty(std::string sourceEntityName, std::string propertyName, std::string targetEntityName)
Try to assign a property from an entity to another entity, using a specific property name...
An OPC client using the datastructures defined within the icub-client library.
void clear()
Clear the OPC content.
yarp::os::Port opc
Port which connects to /OPC/rpc.
void interrupt()
Interrupt communications of the client ports.
bool isConnected()
Check if the client is already connected to the OPC server.
std::list< Entity * > Entities(const yarp::os::Bottle &condition)
Getter of the list of entities of matching a complex condition (e.g "(entity "==" agent) "&&" (isPres...
Represent a relation between two entities.
void checkout(bool updateCache=true)
Poll the OPC for all entities and relations and store them locally.
void addEntity(Entity *e)
Send a the request to add a new entity to the OPC.
std::map< int, Entity * > entitiesByID
bool addRelation(const Relation &r, double lifeTime=-1)
Obtains a relation between two entities.
bool setLifeTime(int id, double lifeTime)
Set the lifetime property of a relation in the OPC.
void update()
Update the properties of all locally stored entities & relations.
bool removeEntity(const std::string &name)
Removes an entity based on its name.
int getRelationID(Entity *subject, Entity *verb, Entity *object=nullptr, Entity *complement_place=nullptr, Entity *complement_time=nullptr, Entity *complement_manner=nullptr)