Property

Stream.get_boolean_property(properties, num_properties, buffer)

Returns the value of the specified boolean properties. This function is optional in a driver. If the driver does not provide it, then this function returns -ErrorCode.NOT_SUPPORTED.

Parameters
  • properties (array_like) – An array containing the properties to query.

  • num_properties (int) – The number of properties in the properties array.

  • buffer (array_like) – An array into which the property values are stored. It must have the same number of elements as the properties array.

Raises

StreamError – On non-zero return code. A suitable error message may be retrieved using get_error_message.

Example

Determine if the given stream is in exclusive write-only mode.

>>> from array import array
>>> from quanser.communications import Stream, BooleanProperty
>>> stream = Stream()
>>> stream.connect("tcpip://localhost:5000", False, 64, 64)
>>> try:
>>>   properties = array('i', [BooleanProperty.IS_EXCLUSIVE, BooleanProperty.IS_WRITE_ONLY])
>>>   num_properties = len(properties)
>>>   buffer = array('b', [0] * num_properties)
>>>   stream.get_boolean_property(properties, num_properties, buffer)
>>>   # ...
...
>>>   stream.shutdown()
>>> finally:
>>>   stream.close()
Stream.set_boolean_property(properties, num_properties, buffer)

Sets the value of the specified boolean properties. This function is optional in a driver. If the driver does not provide it, then this function returns -ErrorCode.NOT_SUPPORTED.

Parameters
  • properties (array_like) – An array containing the properties to query.

  • num_properties (int) – The number of properties in the properties array.

  • buffer (array_like) – An array into which the property values are stored. It must have the same number of elements as the properties array.

Raises

StreamError – On non-zero return code. A suitable error message may be retrieved using get_error_message.

Example

Set the stream to exclusive write-only mode.

>>> from array import array
>>> from quanser.communications import Stream, BooleanProperty
>>> stream = Stream()
>>> stream.connect("tcpip://localhost:5000", False, 64, 64)
>>> try:
>>>   properties = array('i', [BooleanProperty.IS_EXCLUSIVE, BooleanProperty.IS_WRITE_ONLY])
>>>   num_properties = len(properties)
>>>   buffer = array('b', [0] * num_properties)
>>>   stream.set_boolean_property(properties, num_properties, buffer)
>>>   # ...
...
>>>   stream.shutdown()
>>> finally:
>>>   stream.close()