23 #include <ArmarXCore/interface/core/Log.h>
31 std::cout <<
"onInitComponent" << std::endl;
54 std::cout <<
"onConnectComponent" << std::endl;
58 dataBasePrx = getProxy<CommonStorageInterfacePrx>(
"CommonStorage");
60 CollectionInterfacePrx actionCollectionPrx = dataBasePrx->requestCollection(
"workmem.actions");
63 DBStorableData action1;
64 action1.JSON =
"{\"name\":\"put\", params: ['what', 'where'], prereq: [{pred: 'isIn', params: ['what', 'hand'] }], \
65 effects: [{pred: 'isOn', params: ['what', 'where'] }] }";
66 const std::string action1ID = actionCollectionPrx->insert(action1);
68 ARMARX_INFO <<
"Inserted action1 with ID = " << action1ID;
70 DBStorableData action2;
71 action2.JSON =
"{name: 'take', params: ['what'], prereq: [], effects: [{pred: 'isIn', params: ['what', 'hand'] }] }";
72 actionCollectionPrx->save(action2);
75 action2.JSON =
"{\"name\": \"take\", params: [], prereq: [], effects: [] }";
76 actionCollectionPrx->saveWithUserKey(action2,
"name");
84 catch (InvalidMongoIdException& e)
86 ARMARX_ERROR <<
"Failed to fetch action by id: " << e.reason;
89 const std::string findQuery =
"{name: 'take'}";
90 DBStorableDataList actions = actionCollectionPrx->findByQuery(findQuery);
92 for (DBStorableDataList::const_iterator it = actions.begin(); it != actions.end(); ++it)
94 ARMARX_INFO <<
"Found action by name: " << it->JSON;
101 const std::string remQuery =
"{name: 'put'}";
102 ARMARX_INFO <<
"Removing action by query: " << remQuery;
103 actionCollectionPrx->removeByQuery(remQuery);
105 dataBasePrx->releaseCollection(actionCollectionPrx);
107 GridFileInterfacePrx filePrx = dataBasePrx->getFileProxyByName(
"workmem",
"Cup.iv");
111 ARMARX_INFO <<
"Got file of size: " << filePrx->getFileSize();
112 dataBasePrx->releaseFileProxy(filePrx);