Property

HIL.get_double_property(properties, num_properties, buffer)

Gets the value of double properties of the board. There are currently no standard double properties defined, but the board may support product-specific double properties. This function can retrieve the value of more than one double property at the same time.

Parameters
  • properties (array_like) – An array containing the property numbers of the properties to be retrieved. There are no standard double properties currently defined.

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

  • buffer (array_like) – An array for receiving the property values retrieved from the board. The array must contain num_properties elements. Each element in the returned buffer array will correspond to the same element in the properties array.

Raises

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

Examples

Fetch the second product-specific double property of the board.

Using array:

>>> from array import array
>>> from quanser.hardware import HIL, DoubleProperty
>>> card = HIL("q8_usb", "0")
>>> try:
>>>   properties = array('i', [DoubleProperty.PRODUCT_SPECIFIC + 1])
>>>   num_properties = len(properties)
>>>   buffer = array('i', [0] * num_properties)
>>>   card.get_double_property(properties, num_properties, buffer)
>>>   # ...
...
>>> finally:
>>>   card.close()

Using numpy:

>>> import numpy as np
>>> from quanser.hardware import HIL, DoubleProperty
>>> card = HIL("q8_usb", "0")
>>> try:
>>>   properties = np.array([DoubleProperty.PRODUCT_SPECIFIC + 1], dtype=np.int32)
>>>   num_properties = len(properties)
>>>   buffer = np.zeros(num_properties, dtype=np.float64)
>>>   card.get_double_property(properties, num_properties, buffer)
>>>   # ...
...
>>> finally:
>>>   card.close()
HIL.get_integer_property(properties, num_properties, buffer)

Gets the value of integer properties of the board. This function can retrieve the value of more than one integer property at the same time. Standard integer properties are listed in the table below. The board may also support product-specific integer properties.

Parameters
  • properties (array_like) – An array containing the property numbers of the properties to be retrieved.

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

  • buffer (array_like) – An array for receiving the property values retrieved from the board. The array must contain num_properties elements. Each element in the returned buffer array will correspond to the same element in the properties array.

Raises

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

Examples

Fetch the major and minor version numbers of the board.

Using array:

>>> from array import array
>>> from quanser.hardware import HIL, IntegerProperty
>>> card = HIL("q8_usb", "0")
>>> try:
>>>   properties = array('i', [IntegerProperty.MAJOR_VERSION, IntegerProperty.MINOR_VERSION])
>>>   num_properties = len(properties)
>>>   buffer = array('i', [0] * num_properties)
>>>   card.get_integer_property(properties, num_properties, buffer)
>>>   # ...
...
>>> finally:
>>>   card.close()

Using numpy:

>>> import numpy as np
>>> from quanser.hardware import HIL, IntegerProperty
>>> card = HIL("q8_usb", "0")
>>> try:
>>>   properties = np.array([IntegerProperty.MAJOR_VERSION, IntegerProperty.MINOR_VERSION], dtype=np.int32)
>>>   num_properties = len(properties)
>>>   buffer = np.zeros(num_properties, dtype=np.int32)
>>>   card.get_integer_property(properties, num_properties, buffer)
>>>   # ...
...
>>> finally:
>>>   card.close()
HIL.get_string_property(property_code, buffer_size)

Gets the value of a string property of the board. This function can only retrieve the value of one string property at a time. Standard string properties are listed in the table below. The board may also support product-specific string properties.

Parameters
  • property_code (int) – The number of the property to be retrieved.

  • buffer_size (int) – The maximum size of the string in code units (bytes).

Raises

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

Example

Fetch the manufacturer of the board.

>>> from quanser.hardware import HIL, StringProperty
>>> import array as arr
>>> card = HIL("q8_usb", "0")
>>> try:
>>>   manufacturer = card.get_string_property(StringProperty.MANUFACTURER, 64) # up to 64 bytes allowed in returned string
>>>   # ...
...
>>> finally:
>>>   card.close()
HIL.set_double_property(properties, num_properties, buffer)

Sets the value of double properties of the board. There are currently no standard double properties defined. Typically, only board-specific properties may actually be reconfigured. This function can set the value of more than one double property at the same time.

Parameters
  • properties (array_like) – An array containing the property numbers of the properties to be set. There are currently no standard double properties defined.

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

  • buffer (array_like) – An array of the property values to be set for the board. The array must contain num_properties elements. Each element in the buffer array corresponds to the same element in the properties array.

Raises

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

Examples

Set the second product-specific double property of the board.

Using array:

>>> from array import array
>>> from quanser.hardware import HIL, DoubleProperty
>>> card = HIL("q8_usb", "0")
>>> try:
>>>   properties = array('i', [DoubleProperty.PRODUCT_SPECIFIC + 1])
>>>   num_properties = len(properties)
>>>   buffer = array('i', [0] * num_properties)
>>>   card.set_double_property(properties, num_properties, buffer)
>>>   # ...
...
>>> finally:
>>>   card.close()

Using numpy:

>>> import numpy as np
>>> from quanser.hardware import HIL, DoubleProperty
>>> card = HIL("q8_usb", "0")
>>> try:
>>>   properties = np.array([DoubleProperty.PRODUCT_SPECIFIC + 1], dtype=np.int32)
>>>   num_properties = len(properties)
>>>   buffer = np.zeros(num_properties, dtype=np.float64)
>>>   card.set_double_property(properties, num_properties, buffer)
>>>   # ...
...
>>> finally:
>>>   card.close()
HIL.set_integer_property(properties, num_properties, buffer)

Sets the value of integer properties of the board. There are currently no standard integer properties defined. Typically, only board-specific properties may actually be reconfigured. This function can set the value of more than one integer property at the same time.

Parameters
  • properties (array_like) – An array containing the property numbers of the properties to be set. There are currently no standard integer properties defined.

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

  • buffer (array_like) – An array of the property values to be set for the board. The array must contain num_properties elements. Each element in the buffer array corresponds to the same element in the properties array.

Raises

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

Examples

Set the second product-specific integer property of the board.

Using array:

>>> from array import array
>>> from quanser.hardware import HIL, IntegerProperty
>>> card = HIL("q8_usb", "0")
>>> try:
>>>   properties = array('i', [IntegerProperty.PRODUCT_SPECIFIC + 1])
>>>   num_properties = len(properties)
>>>   buffer = array('i', [0] * num_properties)
>>>   card.set_integer_property(properties, num_properties, buffer)
>>>   # ...
...
>>> finally:
>>>   card.close()

Using numpy:

>>> import numpy as np
>>> from quanser.hardware import HIL, IntegerProperty
>>> card = HIL("q8_usb", "0")
>>> try:
>>>   properties = np.array([IntegerProperty.PRODUCT_SPECIFIC + 1], dtype=np.int32)
>>>   num_properties = len(properties)
>>>   buffer = np.zeros(num_properties, dtype=np.int32)
>>>   card.set_integer_property(properties, num_properties, buffer)
>>>   # ...
...
>>> finally:
>>>   card.close()
HIL.set_string_property(property_code, buffer, buffer_size)

Sets the value of a string property of the board. There are currently no standard string properties defined that can be set. Typically only board-specific properties may actually be reconfigured.

Parameters
  • property_code (int) – The number of the property to be set. There are currently no standard string properties defined that may be set.

  • buffer (string) – A string containing the property value to be set for the board. The function will not copy more than buffer_size code units (bytes) from the buffer.

  • buffer_size (int) – The maximum number of code units (bytes) to copy from buffer.

Raises

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

Example

Set the second product-specific string property of the board.

>>> from quanser.hardware import HIL, StringProperty
>>> card = HIL("q8_usb", "0")
>>> try:
>>>   buffer = "My String Value"
>>>   buffer_size = len(buffer)
>>>   card.set_string_property(StringProperty.PRODUCT_SPECIFIC + 1, buffer, buffer_size)
>>>   # ...
...
>>> finally:
>>>   card.close()