Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ファクトリ追加時に生成するオブジェクトの設定に必要なパラメータの情報を設定できるようにする #259

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions OpenRTM_aist/GlobalFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def addFactory(self, id, creator, prop=None):
if id in self._creators:
return self.ALREADY_EXISTS

self._creators[id] = creator
self._creators[id] = FactoryEntry(id, creator, prop)
return self.FACTORY_OK

# ReturnCode removeFactory(const Identifier& id)
Expand All @@ -76,9 +76,34 @@ def createObject(self, id):
if id not in self._creators:
print("Factory.createObject return None id: ", id)
return None
obj_ = self._creators[id]()
obj_ = self._creators[id].creator()
return obj_

def getProperties(self, id):
if not id in self._creators:
print("Factory.getProperties return None id: ", id)
return None
return self._creators[id].prop


class FactoryEntry:
def __init__(self, id, creator, prop=None):
self._id = id
self._creator = creator
self._prop = prop

@property
def id(self):
return self._id

@property
def creator(self):
return self._creator

@property
def prop(self):
return self._prop


gfactory = None

Expand Down
30 changes: 30 additions & 0 deletions OpenRTM_aist/InPortBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,10 +1175,25 @@ def initProviders(self):

# InPortProvider supports "push" dataflow type
if provider_types:
prop_options = OpenRTM_aist.Properties()
self._rtcout.RTC_DEBUG("dataflow_type push is supported")
self.appendProperty("dataport.dataflow_type", "push")
for provider_type in provider_types:
self.appendProperty("dataport.interface_type", provider_type)
prop_if = factory.getProperties(provider_type)
if prop_if is None:
prop_if = OpenRTM_aist.Properties()

prop_node = prop_options.getNode(provider_type)
prop_node.mergeProperties(prop_if)

prop = OpenRTM_aist.Properties()
OpenRTM_aist.NVUtil.copyToProperties(
prop, self._profile.properties)
prop_dataport = prop.getNode("dataport.interface_option")
prop_dataport.mergeProperties(prop_options)
OpenRTM_aist.NVUtil.copyFromProperties(
self._profile.properties, prop)

self._providerTypes = provider_types
return
Expand Down Expand Up @@ -1219,10 +1234,25 @@ def initConsumers(self):

# OutPortConsumer supports "pull" dataflow type
if consumer_types:
prop_options = OpenRTM_aist.Properties()
self._rtcout.RTC_PARANOID("dataflow_type pull is supported")
self.appendProperty("dataport.dataflow_type", "pull")
for consumer_type in consumer_types:
self.appendProperty("dataport.interface_type", consumer_type)
prop_if = factory.getProperties(consumer_type)
if prop_if is None:
prop_if = OpenRTM_aist.Properties()

prop_node = prop_options.getNode(consumer_type)
prop_node.mergeProperties(prop_if)

prop = OpenRTM_aist.Properties()
OpenRTM_aist.NVUtil.copyToProperties(
prop, self._profile.properties)
prop_dataport = prop.getNode("dataport.interface_option")
prop_dataport.mergeProperties(prop_options)
OpenRTM_aist.NVUtil.copyFromProperties(
self._profile.properties, prop)

self._consumerTypes = consumer_types
return
Expand Down
31 changes: 31 additions & 0 deletions OpenRTM_aist/OutPortBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,11 +1185,27 @@ def initProviders(self):
provider_types = provider_types + list(set_ptypes)

# OutPortProvider supports "pull" dataflow type

if provider_types:
prop_options = OpenRTM_aist.Properties()
self._rtcout.RTC_DEBUG("dataflow_type pull is supported")
self.appendProperty("dataport.dataflow_type", "pull")
for provider_type in provider_types:
self.appendProperty("dataport.interface_type", provider_type)
prop_if = factory.getProperties(provider_type)
if prop_if is None:
prop_if = OpenRTM_aist.Properties()

prop_node = prop_options.getNode(provider_type)
prop_node.mergeProperties(prop_if)

prop = OpenRTM_aist.Properties()
OpenRTM_aist.NVUtil.copyToProperties(
prop, self._profile.properties)
prop_dataport = prop.getNode("dataport.interface_option")
prop_dataport.mergeProperties(prop_options)
OpenRTM_aist.NVUtil.copyFromProperties(
self._profile.properties, prop)

self._providerTypes = provider_types

Expand Down Expand Up @@ -1229,10 +1245,25 @@ def initConsumers(self):

# InPortConsumer supports "push" dataflow type
if consumer_types:
prop_options = OpenRTM_aist.Properties()
self._rtcout.RTC_PARANOID("dataflow_type push is supported")
self.appendProperty("dataport.dataflow_type", "push")
for consumer_type in consumer_types:
self.appendProperty("dataport.interface_type", consumer_type)
prop_if = factory.getProperties(consumer_type)
if prop_if is None:
prop_if = OpenRTM_aist.Properties()

prop_node = prop_options.getNode(consumer_type)
prop_node.mergeProperties(prop_if)

prop = OpenRTM_aist.Properties()
OpenRTM_aist.NVUtil.copyToProperties(
prop, self._profile.properties)
prop_dataport = prop.getNode("dataport.interface_option")
prop_dataport.mergeProperties(prop_options)
OpenRTM_aist.NVUtil.copyFromProperties(
self._profile.properties, prop)

self._consumerTypes = consumer_types

Expand Down
Loading