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

Add Support for Publishing, More Types, and Basic QoS #30

Draft
wants to merge 63 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
6060c84
Add publisher capability to pyopendds
Sdpierret May 4, 2021
46c2f41
add Sequences support
Sdpierret May 25, 2021
bb07ddc
add Floating type support
Sdpierret May 31, 2021
5b99908
fix after review
Sdpierret Jun 15, 2021
e26b813
Merge branch 'oci-labs:master' into master
Sdpierret Aug 9, 2021
900c777
Add publisher capability to pyopendds
Sdpierret May 4, 2021
da5df2e
add Sequences support
Sdpierret May 25, 2021
5773636
fix after review
Sdpierret Jun 15, 2021
7feb5b2
add Floating type support
Sdpierret May 31, 2021
510b9a4
Add DataReaderListener for callback.
p-e-s Jun 17, 2021
6e5c98a
cleanup and more tests
Sdpierret Jun 24, 2021
8a50cad
add listener and fix publisher
Sdpierret Jun 29, 2021
6c67cb7
add boolean type support
Sdpierret Jul 2, 2021
cdffefa
fix wrong type in itl2py
Sdpierret Jul 2, 2021
27cf722
Add Char type to IntegerType
Sdpierret Jul 5, 2021
c9593f7
Add more supported types
Sdpierret Jul 9, 2021
7046ac4
partial Qos addition to pyOpenDDS
Sdpierret Jul 26, 2021
5bf68dc
Merge branch 'dev_DataListener'
Sdpierret Aug 9, 2021
b5f84f3
Minor bug fix:
herme5 Sep 27, 2021
1244d6a
Implementation improvements:
herme5 Sep 27, 2021
39c7556
Fix setup.cfg warning:
herme5 Sep 27, 2021
ff63d6d
Fix Segmentation fault runtime errors:
herme5 Sep 27, 2021
b712b3e
Fix an error where negative python floats in Samples causes crash:
herme5 Sep 27, 2021
3de4085
Add support for nested IDL modules:
herme5 Sep 27, 2021
573ffb9
Minor code refactoring
herme5 Sep 27, 2021
1613d9f
Fix a bug for IDL nested modules:
herme5 Sep 27, 2021
dccdb0a
Fix segmentation fault at exit:
herme5 Sep 27, 2021
d7ec6e7
Fix exception conditions in cpp bindings.
herme5 Sep 27, 2021
4e3b573
Fix warning and good practises python pep8 linter.
herme5 Sep 27, 2021
a1dbfae
Refactoring:
herme5 Sep 27, 2021
b056165
Fix a few segmentation faults on app terminate:
herme5 Sep 27, 2021
8146316
Fix a bug where python template uses hardcoded module name.
herme5 Sep 27, 2021
5480c0f
Fix a bug where static member value was reset, opting for a singleton…
herme5 Sep 27, 2021
88219c5
Add preprocessor checking if Apple.
herme5 Sep 27, 2021
f0e6224
Fix PyBool_Check returning an exception
herme5 Sep 27, 2021
2f68a41
Forced QoS (for reader and writer) to RELIABLE_RELIABILITY
herme5 Sep 27, 2021
68bf37b
Add support to octet type into IDL.
herme5 Sep 27, 2021
407d5c3
Reformat whitespaces and spacings
herme5 Sep 28, 2021
799393f
Fix a bug where primitives_types contained 'i8' which was declared tw…
herme5 Sep 28, 2021
a29b3b9
Add unsigned integer types
herme5 Oct 6, 2021
f9afdbb
add unsigned 8 and 32 bits integer
Sdpierret Oct 8, 2021
2e84f03
Merge commit 'f9afdbb52bebc574f816b4eb572b07b79454396f' into dev_Type…
herme5 Oct 8, 2021
fe9bf49
Merge commit '5b999086e1431e02ad78efb633bf75b6503744cb' into dev_Type…
herme5 Oct 8, 2021
668c88c
Merge commit 'bb07ddcf31390c8e6fcbafc7e2ddc24dff7105a6' into dev_Type…
herme5 Oct 10, 2021
b2b8971
Revert back merging from sequences branch.
herme5 Oct 11, 2021
6e63ad2
Split long code lines in user.cpp with stringstream insertion.
herme5 Oct 11, 2021
b68fac3
Merge branch 'master' into dev_TypeSupports
andrearuffino Oct 11, 2021
3d35bcd
Merge pull request #1 from Sdpierret/dev_TypeSupports
andrearuffino Oct 13, 2021
c2b76c0
Add pyidl console script:
herme5 Oct 25, 2021
8327eb9
Lower cmake_minimum_required from 3.12 to 3.10
herme5 Oct 25, 2021
4af687d
Run shell script for TypeSupport test
herme5 Oct 25, 2021
496d3f8
Revert to cmake_minimum_required v3.12
herme5 Oct 28, 2021
b6bb16d
Delete tata.idl
Sdpierret Nov 2, 2021
eeb23c1
Delete toto.idl
Sdpierret Nov 2, 2021
3c74b40
qos dev try
swolferDF Nov 3, 2021
79e6342
p-e-s change config QOS
swolferDF Nov 4, 2021
f047637
Merge branch 'dev_PyidlConsoleScript' into support_QOS
swolferDF Nov 4, 2021
58ab265
modified function takenextsample() not blocking when subscribe
swolferDF Nov 5, 2021
79b43cd
dataReader qos Testing
swolferDF Nov 5, 2021
1b0a5d9
dev qos datawriter (publisher)
swolferDF Nov 5, 2021
1c80664
Qos Working !! :tada: :tada:
swolferDF Nov 5, 2021
6578eac
remove print
swolferDF Nov 5, 2021
df314df
add topicname optional arg callaback
swolferDF Nov 9, 2021
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
45 changes: 33 additions & 12 deletions pyopendds/DataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,48 @@
from .Topic import Topic
from .constants import StatusKind
from .util import TimeDurationType, normalize_time_duration
from .Qos import DataReaderQos

from typing import TYPE_CHECKING, Callable, Optional, Any

from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .Subscriber import Subscriber


class DataReader:

def __init__(self, subscriber: Subscriber, topic: Topic, qos=None, listener=None):
def __init__(self, subscriber: Subscriber, topic: Topic, qos=DataReaderQos(), listener: Optional[Callable[..., None]] = None):
self.topic = topic
self.qos = qos
self.listener = listener
self.subscriber = subscriber
self.qos = qos
subscriber.readers.append(self)

from _pyopendds import create_datareader
create_datareader(self, subscriber, topic)

def wait_for(self, status: StatusKind, timeout: TimeDurationType):
from _pyopendds import datareader_wait_for
return datareader_wait_for(self, status, *normalize_time_duration(timeout))

def take_next_sample(self):
return self.topic._ts_package.take_next_sample(self)
from _pyopendds import create_datareader # noqa
#verify if callback is None
if self.listener == None :
create_datareader(self, subscriber, topic, None, self.qos)
else :
create_datareader(self, subscriber, topic, self.on_data_available_callback, self.qos)


def wait_for(self, timeout: TimeDurationType, status: StatusKind = StatusKind.SUBSCRIPTION_MATCHED):
from _pyopendds import datareader_wait_for # noqa
datareader_wait_for(self, status, *normalize_time_duration(timeout))

def take_next_sample(self) -> Any:
return self.topic.ts_package.take_next_sample(self)

def on_data_available_callback(self):
sample = self.take_next_sample()
topicname = self.topic.name
print("on data available callback")

if sample is None:
# print("on_data_available_callback error: sample is None")
pass
elif self.listener is not None:
try: # if callback have 2 arguments
self.listener(sample,topicname)
except : # if callback have 1 arguments
self.listener(sample)
32 changes: 31 additions & 1 deletion pyopendds/DataWriter.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
from __future__ import annotations

from .Topic import Topic
from .constants import StatusKind
from .util import TimeDurationType, normalize_time_duration
from .Qos import DataWriterQos

from typing import TYPE_CHECKING


if TYPE_CHECKING:
from .Publisher import Publisher


class DataWriter:
pass

def __init__(self, publisher: Publisher, topic: Topic, qos=DataWriterQos()):
self.topic = topic
self.publisher = publisher
self.qos = qos
publisher.writers.append(self)

from _pyopendds import create_datawriter # noqa
create_datawriter(self, publisher, topic,self.qos)


def wait_for(self, timeout: TimeDurationType, status: StatusKind = StatusKind.PUBLICATION_MATCHED):
from _pyopendds import datawriter_wait_for # noqa
datawriter_wait_for(self, status, *normalize_time_duration(timeout))

def write(self, sample) -> int:
return self.topic.ts_package.write(self, sample)
19 changes: 12 additions & 7 deletions pyopendds/DomainParticipant.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
from .Subscriber import Subscriber
from .Publisher import Publisher

try:
from _pyopendds import participant_cleanup # noqa
except ImportError as e:
def participant_cleanup(*args):
pass
pass

class DomainParticipant:

class DomainParticipant(object):

def __init__(self, domain: int, qos=None, listener=None):
self.domain = int(domain)
Expand All @@ -14,19 +21,17 @@ def __init__(self, domain: int, qos=None, listener=None):
self.publishers = []
self._registered_typesupport = []

from _pyopendds import create_participant
from _pyopendds import create_participant # noqa
create_participant(self, domain)

def __del__(self):
from _pyopendds import participant_cleanup
participant_cleanup(self)

def create_topic(self,
name: str, topic_type: type, qos=None, listener=None) -> Topic:
def create_topic(self, name: str, topic_type: type, qos=None, listener=None) -> Topic:
return Topic(self, name, topic_type, qos, listener)

def create_subscriber(self, qos=None, listener=None) -> Subscriber:
return Subscriber(self, qos, listener)

def create_publisher(self, qos=None, listener=None) -> Publisher:
return Publisher(self, qos, listener)
def create_publisher(self, qos=None) -> Publisher:
return Publisher(self, qos)
15 changes: 8 additions & 7 deletions pyopendds/Publisher.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
from __future__ import annotations

from .DataWriter import DataWriter
from .Topic import Topic

from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .DomainParticipant import DomainParticipant


class Publisher:
class Publisher(object):

def __init__(self, participant: DomainParticipant, qos=None, listener=None):
def __init__(self, participant: DomainParticipant, qos=None):
participant.publishers.append(self)
self.qos = qos
self.listener = listener
self.writers = []

from _pyopendds import create_publisher
from _pyopendds import create_publisher # noqa
create_publisher(self, participant)

def create_datawriter(self, topic: Topic, qos=None, listener=None):
pass
def create_datawriter(self, topic: Topic, qos=None) -> DataWriter:
writer = DataWriter(self, topic, qos)
self.writers.append(writer)
return writer
49 changes: 49 additions & 0 deletions pyopendds/Qos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from enum import IntEnum


class DurabilityQosPolicyKind(IntEnum):
VOLATILE_DURABILITY_QOS = 0,
TRANSIENT_LOCAL_DURABILITY_QOS = 1,
TRANSIENT_DURABILITY_QOS = 2,
PERSISTENT_DURABILITY_QOS = 3


class ReliabilityQosPolicyKind(IntEnum):
BEST_EFFORT_RELIABILITY_QOS = 0,
RELIABLE_RELIABILITY_QOS = 1


class HistoryQosPolicyKind(IntEnum):
KEEP_LAST_HISTORY_QOS = 0,
KEEP_ALL_HISTORY_QOS = 1


class DurabilityQosPolicy:
def __init__(self):
self.kind = DurabilityQosPolicyKind.VOLATILE_DURABILITY_QOS


class ReliabilityQosPolicy:
def __init__(self):
self.kind = ReliabilityQosPolicyKind.BEST_EFFORT_RELIABILITY_QOS
self.max_blocking_time = 0


class HistoryQosPolicy:
def __init__(self):
self.kind = HistoryQosPolicyKind.KEEP_LAST_HISTORY_QOS
self.depth = 1


class DataWriterQos:
def __init__(self):
self.durability = DurabilityQosPolicy()
self.reliability = ReliabilityQosPolicy()
self.history = HistoryQosPolicy()


class DataReaderQos:
def __init__(self):
self.durability = DurabilityQosPolicy()
self.reliability = ReliabilityQosPolicy()
self.history = HistoryQosPolicy()
9 changes: 5 additions & 4 deletions pyopendds/Subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ def __init__(self, participant: DomainParticipant, qos=None, listener=None):
self.qos = qos
self.listener = listener
self.readers = []

from _pyopendds import create_subscriber
from _pyopendds import create_subscriber # noqa
create_subscriber(self, participant)

def create_datareader(self, topic: Topic, qos=None, listener=None):
return DataReader(self, topic, qos, listener)
def create_datareader(self, topic: Topic, qos=None, listener=None) -> DataReader:
reader = DataReader(self, topic, qos, listener)
self.readers.append(reader)
return reader
20 changes: 10 additions & 10 deletions pyopendds/Topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

class Topic:

def __init__(self,
participant: DomainParticipant, name: str, topic_type: type,
qos=None, listener=None):
def __init__(self, participant: DomainParticipant, name: str, topic_type: type, qos=None, listener=None):
participant.topics[name] = self
self.name = name
self.type = topic_type
Expand All @@ -18,12 +16,14 @@ def __init__(self,

# Get OpenDDS Topic Type Name
import importlib
self._ts_package = \
importlib.import_module(
topic_type._pyopendds_typesupport_packge_name)
if topic_type not in participant._registered_typesupport:
self._ts_package.register_type(participant, topic_type)
self.type_name = self._ts_package.type_name(topic_type)
self._ts_package = importlib.import_module(topic_type._pyopendds_typesupport_packge_name) # noqa
if topic_type not in participant._registered_typesupport: # noqa
self._ts_package.register_type(participant, topic_type) # noqa

from _pyopendds import create_topic
self.type_name = self._ts_package.type_name(topic_type) # noqa
from _pyopendds import create_topic # noqa
create_topic(self, participant, name, self.type_name)

@property
def ts_package(self):
return self._ts_package
Loading