from . import acquisition_api as _acquisition
from . import channel_api as _channel
from . import connection_api as _connection
+from . import fieldbus_api as _fieldbus
from . import mainframe_api as _mainframe
from . import manage_mainframe_settings as _manage_mainframe_settings
from . import manage_recordings_api as _manage_recordings
from . import recorder_api as _recorder
from .connection import ConnectionHandler
-from .ghsapi_states import (
- RETURN_KEY,
- GHSChannelType,
- GHSDigitalOutMode,
- GHSDirection,
- GHSEnableDisable,
- GHSReturnValue,
- GHSSyncStatus,
- GHSTriggerMode,
- GHSUserMode,
-)
+from .fieldbus_ringbuffer import FieldBus
+from .ghsapi_states import RETURN_KEY, GHSReturnValue
CLIENT_API_VERSION = 4
class GHS:
- """GEN DAQ API object.
+ """GEN DAQ API object.
Attributes:
_con_handle: An unique identifier per mainframe connection.
@@ -132,10 +129,11 @@ Source code for ghsapi.ghsapi
def __init__(self):
self._con_handle = ConnectionHandler()
+ self.fieldbus_handle = FieldBus(0, 0)
# Connection related API functions.
[docs] def ghs_connect(self, ip_address: int, port_num: int) -> str:
-
"""Establishes a connection to the mainframe.
+
"""Establishes a connection to the mainframe.
Args:
ip_address: IP address needs to be an IPV4 address.
@@ -145,12 +143,22 @@
Source code for ghsapi.ghsapi
* GHSReturnValue - Connect return status.
"""
- return _connection.connect(
+ returnVal = _connection.connect(
self._con_handle, ip_address, port_num, CLIENT_API_VERSION
- )
+
)
+
if returnVal != "OK":
+
self._con_handle = None
+
+
self.fieldbus_handle.dataHandle = None
+
self.fieldbus_handle.conHandle = ConnectionHandler()
+
self.fieldbus_handle.lastPacket.timeStamp = 0
+
self.fieldbus_handle.lastPacket.fValues = None
+
self.fieldbus_handle.ipAddress = ip_address
+
+
return returnVal
[docs] def ghs_disconnect(self) -> str:
-
"""Disconnects from a connected mainframe.
+
"""Disconnects from a connected mainframe.
*Results in error when the handle is not valid and / or
mainframe is not connected.*
@@ -162,7 +170,7 @@
Source code for ghsapi.ghsapi
return _connection.disconnect(self._con_handle)
[docs] def ghs_get_client_api_version(self) -> int:
-
"""Client's API version.
+
"""Client's API version.
*This function can be useful when ghs_connect() returns
GHSReturnValue_APIMismatch.*
@@ -174,7 +182,7 @@
Source code for ghsapi.ghsapi
return CLIENT_API_VERSION
[docs] def ghs_get_current_access(self) -> str:
-
"""Current access permission to the mainframe.
+
"""Current access permission to the mainframe.
*The current access permissions might change at any time.
For example, when Perception connects concurrently to the same
@@ -193,7 +201,7 @@
Source code for ghsapi.ghsapi
# Acquisition control related API functions.
[docs] def ghs_start_preview(self) -> str:
-
"""Starts preview mode.
+
"""Starts preview mode.
*The system needs to be idle before calling this function.*
@@ -204,7 +212,7 @@
Source code for ghsapi.ghsapi
return _acquisition.start_preview(self._con_handle)
[docs] def ghs_stop_preview(self) -> str:
-
"""Stops preview mode.
+
"""Stops preview mode.
*The system needs to be in preview mode before calling this
function.*
@@ -216,7 +224,7 @@
Source code for ghsapi.ghsapi
return _acquisition.stop_preview(self._con_handle)
[docs] def ghs_start_recording(self) -> str:
-
"""Start recording on local storage.
+
"""Start recording on local storage.
*The system needs to be idle before calling this function. Note
that the connected mainframe will generate a recording name.
@@ -230,7 +238,7 @@
Source code for ghsapi.ghsapi
return _acquisition.start_recording(self._con_handle)
[docs] def ghs_pause_recording(self) -> str:
-
"""Pauses a started recording.
+
"""Pauses a started recording.
*The system needs to be recording before calling this function.*
@@ -241,7 +249,7 @@
Source code for ghsapi.ghsapi
return _acquisition.pause_recording(self._con_handle)
[docs] def ghs_resume_recording(self) -> str:
-
"""Resumes a paused recording.
+
"""Resumes a paused recording.
*The system needs to be paused before calling this function.*
@@ -252,7 +260,7 @@
Source code for ghsapi.ghsapi
return _acquisition.resume_recording(self._con_handle)
[docs] def ghs_stop_recording(self) -> str:
-
"""Stops a started recording.
+
"""Stops a started recording.
*The system needs to be recording before calling this function.*
@@ -263,7 +271,7 @@
Source code for ghsapi.ghsapi
return _acquisition.stop_recording(self._con_handle)
[docs] def ghs_trigger(self) -> str:
-
"""Issues a trigger.
+
"""Issues a trigger.
Results in error when the trigger cannot be issued.
@@ -274,7 +282,7 @@
Source code for ghsapi.ghsapi
return _acquisition.trigger(self._con_handle)
[docs] def ghs_get_acquisition_state(self) -> tuple[str, str | None]:
-
"""Returns the Acquisition State of the Mainframe.
+
"""Returns the Acquisition State of the Mainframe.
Returns:
* GHSReturnValue - API return status
@@ -286,7 +294,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_get_acquisition_start_time(
self,
) -> tuple[str, int | None, int | None, float | None]:
-
"""Retrieves the absolute time of the start of acquisition.
+
"""Retrieves the absolute time of the start of acquisition.
Returns:
* GHSReturnValue - API return status
@@ -298,7 +306,7 @@
Source code for ghsapi.ghsapi
return _acquisition.get_acquisition_start_time(self._con_handle)
[docs] def ghs_get_acquisition_time(self) -> tuple[str, float | None]:
-
"""Retrieves the current acquisition time relative to the start
+
"""Retrieves the current acquisition time relative to the start
of acquistion.
Returns:
@@ -311,7 +319,7 @@
Source code for ghsapi.ghsapi
# Mainframe APIs
[docs] def ghs_identify(self, identity_flag: bool) -> str:
-
"""Enable or disable the identification sound of the connected
+
"""Enable or disable the identification sound of the connected
mainframe.
Args:
@@ -324,7 +332,7 @@
Source code for ghsapi.ghsapi
return _mainframe.identity(self._con_handle, identity_flag)
[docs] def ghs_get_disk_space(self) -> tuple[str, float | None, float | None]:
-
"""Get total and available mainframe internal disk space.
+
"""Get total and available mainframe internal disk space.
Returns:
* GHSReturnValue - API return status
@@ -335,7 +343,7 @@
Source code for ghsapi.ghsapi
return _mainframe.get_disk_space(self._con_handle)
[docs] def ghs_get_sync_status(self) -> tuple[str, str | None]:
-
"""Determine the mainframe sync status.
+
"""Determine the mainframe sync status.
Returns:
* GHSReturnValue - API return status
@@ -345,7 +353,7 @@
Source code for ghsapi.ghsapi
return _mainframe.get_sync_status(self._con_handle)
[docs] def ghs_get_slot_count(self) -> tuple[str, int | None]:
-
"""Retrieve the number of slots in the mainframe.
+
"""Retrieve the number of slots in the mainframe.
Returns:
* GHSReturnValue - API return status
@@ -355,7 +363,7 @@
Source code for ghsapi.ghsapi
return _mainframe.get_slot_count(self._con_handle)
[docs] def ghs_get_user_mode(self) -> tuple[str, str | None]:
-
"""Retrieve the user mode.
+
"""Retrieve the user mode.
Returns:
* GHSReturnValue - API return status
@@ -365,7 +373,7 @@
Source code for ghsapi.ghsapi
return _mainframe.get_user_mode(self._con_handle)
[docs] def ghs_set_user_mode(self, user_mode: str | int) -> str:
-
"""Set the user mode.
+
"""Set the user mode.
*The system needs to be idle before calling this function.*
@@ -381,7 +389,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_get_mainframe_info(
self,
) -> tuple[str, str | None, str | None, str | None, str | None]:
-
"""Determine type, name, serial number and firmware version
+
"""Determine type, name, serial number and firmware version
information for the connected mainframe.
*The mainframeType, mainframeName, serialNumber and
@@ -400,7 +408,7 @@
Source code for ghsapi.ghsapi
# Manage recordings APIs
[docs] def ghs_delete_all_recordings(self) -> str:
-
"""Deletes all recordings from local mainframe storage.
+
"""Deletes all recordings from local mainframe storage.
*Recordings are deleted asynchronously.*
@@ -411,7 +419,7 @@
Source code for ghsapi.ghsapi
return _manage_recordings.delete_all_recordings(self._con_handle)
[docs] def ghs_delete_last_recording(self) -> str:
-
"""Deletes the most recent recording from local mainframe
+
"""Deletes the most recent recording from local mainframe
storage.
*Recordings are deleted asynchronously.*
@@ -423,7 +431,7 @@
Source code for ghsapi.ghsapi
return _manage_recordings.delete_last_recording(self._con_handle)
[docs] def ghs_get_recording_name(self) -> tuple[str, str | None, int | None]:
-
"""Retrieve the recording base name and recording index of the
+
"""Retrieve the recording base name and recording index of the
last recording file.
*The recording base name parameter is UTF-8 encoded.*
@@ -437,7 +445,7 @@
Source code for ghsapi.ghsapi
return _manage_recordings.get_recording_name(self._con_handle)
[docs] def ghs_get_storage_location(self) -> tuple[str, str | None]:
-
"""Retrieve the storage location.
+
"""Retrieve the storage location.
Returns:
* GHSReturnValue - API return status
@@ -449,7 +457,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_get_high_low_rate_storage_enabled(
self, source: str | int, slot_id: str
) -> tuple[str, str | None, str | None]:
-
"""Retrieve storage enabled status of high and low rate data
+
"""Retrieve storage enabled status of high and low rate data
for the specified recording data source.
Args:
@@ -473,7 +481,7 @@
Source code for ghsapi.ghsapi
high_rate_enabled: str | int,
low_rate_enabled: str | int,
) -> str:
- """Enable/disable storage of high and low rate data for the
+ """Enable/disable storage of high and low rate data for the
specified recording data source.
Args:
@@ -497,7 +505,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_set_recording_name(
self, recording_name: str, recording_index: int
) -> str:
-
"""Set the recording base name and recording index for the next
+
"""Set the recording base name and recording index for the next
recording file.
*The system needs to be idle before calling this function.
@@ -516,7 +524,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_set_storage_location(self, storage_location: str | int) -> str:
-
"""Set the storage location.
+
"""Set the storage location.
*The system needs to be idle before calling this function.*
@@ -534,7 +542,7 @@
Source code for ghsapi.ghsapi
# Manage recordings APIs
[docs] def ghs_apply_persisted_settings(self) -> str:
-
"""A mainframe might contain persisted settings (being applied upon
+
"""A mainframe might contain persisted settings (being applied upon
boot). This method re-applies these settings. In Perception this
maps on the 'Configured boot' feature.
@@ -551,7 +559,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_persist_current_settings(self) -> str:
-
"""Persists the current mainframe settings.
+
"""Persists the current mainframe settings.
*The persisted mainframe settings are applied upon a mainframe
boot.*
@@ -565,7 +573,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_get_current_settings(self) -> tuple[str, bytes | None, int | None]:
-
"""Retrieves the current mainframe settings as a blob.
+
"""Retrieves the current mainframe settings as a blob.
*As this blob can be of variable size, it is upon the caller to
ensure reading the correct amount of memory.
@@ -582,7 +590,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_set_current_settings(self, blob: bytes, blob_size: int) -> str:
-
"""Persists the current mainframe settings.
+
"""Persists the current mainframe settings.
*The persisted mainframe settings are applied upon a mainframe
boot.*
@@ -602,7 +610,7 @@
Source code for ghsapi.ghsapi
# Recorder APIs
[docs] def ghs_get_channel_count(self, slot_id: str) -> tuple[str, int | None]:
-
"""Retrieve the number of channels for a recorder.
+
"""Retrieve the number of channels for a recorder.
*This method can be called by multiple connected clients at same
time.*
@@ -620,7 +628,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_get_digital_output(
self, slot_id: str, digital_output: str | int
) -> tuple[str, str | None]:
-
"""Retrieve the Digital Output Mode for a specified Output ID in a
+
"""Retrieve the Digital Output Mode for a specified Output ID in a
recorder.
*This method can be called by multiple connected clients at same
@@ -640,7 +648,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_get_recorder_enabled(self, slot_id: str) -> tuple[str, str | None]:
-
"""Determine if recorder is enabled or disabled.
+
"""Determine if recorder is enabled or disabled.
*This method can be called by multiple connected clients at same
time.*
@@ -658,7 +666,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_get_recorder_info(
self, slot_id: str
) -> tuple[str, str | None, str | None, str | None, str | None]:
-
"""Determine type, name, serial number and firmware version
+
"""Determine type, name, serial number and firmware version
information for a recorder.
*The recorderType, recorderName, serialNumber and firmwareVersion
@@ -681,7 +689,7 @@
Source code for ghsapi.ghsapi
return _recorder.get_recorder_info(self._con_handle, slot_id)
[docs] def ghs_get_sample_rate(self, slot_id: str) -> tuple[str, float | None]:
-
"""Determine the sample rate for a recorder.
+
"""Determine the sample rate for a recorder.
*This method can be called by multiple connected clients at same
time.*
@@ -702,7 +710,7 @@
Source code for ghsapi.ghsapi
digital_output: str | int,
digital_output_mode: str | int,
) -> str:
- """Set the Digital Output Mode for a specified Output ID in a
+ """Set the Digital Output Mode for a specified Output ID in a
recorder.
*This method will only process requests from the connected client
@@ -727,7 +735,7 @@ Source code for ghsapi.ghsapi
slot_id: str,
enabled: str | int,
) -> str:
- """Enable or disable a recorder.
+ """Enable or disable a recorder.
*The system needs to be idle before calling this function.*
@@ -752,7 +760,7 @@ Source code for ghsapi.ghsapi
slot_id: str,
sample_rate: float,
) -> str:
- """Set the sample rate for a recorder.
+ """Set the sample rate for a recorder.
*The system needs to be idle before calling this function.
This function overwrites any previously set sample rate setting for
@@ -782,7 +790,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_get_channel_type(
self, slot_id: str, channel_index: int
) -> tuple[str, int | None]:
-
"""Determine the type of a channel.
+
"""Determine the type of a channel.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -803,7 +811,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_get_channel_name(
self, slot_id: str, channel_index: int
) -> tuple[str, int | None]:
-
"""Determine the name of a channel.
+
"""Determine the name of a channel.
*The channel name is UTF-8 encoded*
@@ -826,7 +834,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_set_channel_name(
self, slot_id: str, channel_index: int, channel_name: str
) -> str:
-
"""Set the name for a channel.
+
"""Set the name for a channel.
*The channel name is UTF-8 encoded*
@@ -850,7 +858,7 @@
Source code for ghsapi.ghsapi
[docs] def ghs_get_channel_storage_enabled(
self, slot_id: str, channel_index: int
) -> tuple[str, str | None]:
-
"""Determine if storage is enabled or disabled for a channel.
+
"""Determine if storage is enabled or disabled for a channel.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -874,7 +882,7 @@
Source code for ghsapi.ghsapi
channel_index: int,
enabled: str | int,
) -> str:
- """Enable or disable storage for a channel.
+ """Enable or disable storage for a channel.
*The system needs to be idle before calling this function.*
@@ -898,7 +906,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_cmd_zeroing(
self, slot_id: str, channel_index: int, ezeroing: str | int
) -> str:
-
"""Perform zeroing in a channel.
+
"""Perform zeroing in a channel.
*The system needs to be idle before calling this function.*
@@ -925,7 +933,7 @@
Source code for ghsapi.ghsapi
) -> tuple[
str, str | None, float | None, float | None, float | None, str | None
]:
- """Determine the trigger settings for an analog channel.
+ """Determine the trigger settings for an analog channel.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -957,7 +965,7 @@ Source code for ghsapi.ghsapi
hysteresis: float,
direction: str | int,
) -> str:
- """Set the trigger settings for an analog channel.
+ """Set the trigger settings for an analog channel.
*The system needs to be idle before calling this function.*
@@ -999,7 +1007,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_get_signal_coupling(
self, slot_id: str, channel_index: int
) -> tuple[str, str | None]:
-
"""Determine the signal coupling for an analog channel.
+
"""Determine the signal coupling for an analog channel.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -1023,7 +1031,7 @@
Source code for ghsapi.ghsapi
channel_index: int,
signal_coupling: str | int,
) -> str:
- """Set the signal coupling for an analog channel.
+ """Set the signal coupling for an analog channel.
*If the specified signal coupling mode is not supported by the
recorder, the signal coupling mode remains unchanged.*
@@ -1051,7 +1059,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_get_input_coupling(
self, slot_id: str, channel_index: int
) -> tuple[str, str | None]:
-
"""Determine the input coupling for an analog channel.
+
"""Determine the input coupling for an analog channel.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -1075,7 +1083,7 @@
Source code for ghsapi.ghsapi
channel_index: int,
input_coupling: str | int,
) -> str:
- """Set the input coupling for an analog channel.
+ """Set the input coupling for an analog channel.
*If the specified input coupling mode is not supported by the
recorder, the input coupling mode remains unchanged.*
@@ -1103,7 +1111,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_get_span_and_offset(
self, slot_id: str, channel_index: int
) -> tuple[str, float | None, float | None]:
-
"""Determine the span and offset for an analog channel.
+
"""Determine the span and offset for an analog channel.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -1129,7 +1137,7 @@
Source code for ghsapi.ghsapi
span: float,
offset: float,
) -> str:
- """Set Span and offset for analog channels.
+ """Set Span and offset for analog channels.
*ReadWrite - This method will only process requests from the
connected client with the most privileges order (Privileges
@@ -1156,7 +1164,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_get_filter_type_and_frequency(
self, slot_id: str, channel_index: int
) -> tuple[str, str | None, float | None]:
-
"""Determine the filter type and frequency for an analog channel.
+
"""Determine the filter type and frequency for an analog channel.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -1182,7 +1190,7 @@
Source code for ghsapi.ghsapi
filter_type: str | int,
frequency: float,
) -> str:
- """Set the filter type and frequency for an analog channel.
+ """Set the filter type and frequency for an analog channel.
*This function overwrites any previously set filter settings
for the specified recorder.*
@@ -1216,7 +1224,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_get_excitation(
self, slot_id: str, channel_index: int
) -> tuple[str, str | None, float | None]:
-
"""Determine the excitation type and value for an analog channel.
+
"""Determine the excitation type and value for an analog channel.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -1242,7 +1250,7 @@
Source code for ghsapi.ghsapi
excitation_type: str | int,
excitation_value: float,
) -> str:
- """Set the excitation type and value for an analog channel.
+ """Set the excitation type and value for an analog channel.
*The system needs to be idle before calling this function.*
@@ -1275,7 +1283,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_get_amplifier_mode(
self, slot_id: str, channel_index: int
) -> tuple[str, str | None]:
-
"""Determine the amplifier mode for an analog channel.
+
"""Determine the amplifier mode for an analog channel.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -1299,7 +1307,7 @@
Source code for ghsapi.ghsapi
channel_index: int,
amplifier_mode: str | int,
) -> str:
- """Set the amplifier mode for an analog channel.
+ """Set the amplifier mode for an analog channel.
*The system needs to be idle before calling this function.*
@@ -1329,7 +1337,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_get_technical_units(
self, slot_id: str, channel_index: int
) -> tuple[str, str | None, float | None, float | None]:
-
"""Determine the technical units, unit multiplier and unit offset for
+
"""Determine the technical units, unit multiplier and unit offset for
an analog channel.
*The units parameter is UTF-8 encoded.*
@@ -1360,7 +1368,7 @@
Source code for ghsapi.ghsapi
multiplier: float,
offset: float,
) -> str:
- """Set the technical units, unit multiplier and unit offset for an
+ """Set the technical units, unit multiplier and unit offset for an
analog channel.
*The units parameter must be UTF-8 encoded.*
@@ -1392,7 +1400,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_get_auto_range(
self, slot_id: str, channel_index: int
) -> tuple[str, str | None, float | None]:
-
"""Determine the auto range enable and time settings.
+
"""Determine the auto range enable and time settings.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -1418,7 +1426,7 @@
Source code for ghsapi.ghsapi
auto_range_enabled: str | int,
auto_range_time: float,
) -> str:
- """Set Auto range settings for analog channels.
+ """Set Auto range settings for analog channels.
*ReadWrite - This method will only process requests from the
connected client with the most privileges order (Privileges
@@ -1448,7 +1456,7 @@ Source code for ghsapi.ghsapi
channel_index: int,
auto_range_time: float,
) -> str:
- """Command a single shot for auto range.
+ """Command a single shot for auto range.
*The system needs to be acquiring for this function to have any
effect.*
@@ -1484,7 +1492,7 @@ Source code for ghsapi.ghsapi
str | None,
str | None,
]:
- """Retrieve calibration information for an analog channel.
+ """Retrieve calibration information for an analog channel.
*The calibrationDateTime, verificationDateTime,
powerVerificationDateTime, calibrationLab, verificationLab and
@@ -1516,7 +1524,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_get_timer_counter_gate_time(
self, slot_id: str, channel_index: int
) -> tuple[str, float | None]:
-
"""Determine the gate time for a timer/counter channel.
+
"""Determine the gate time for a timer/counter channel.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -1540,7 +1548,7 @@
Source code for ghsapi.ghsapi
channel_index: int,
gate_time: float,
) -> str:
- """Determine the gate time for a timer/counter channel.
+ """Determine the gate time for a timer/counter channel.
The system needs to be idle before calling this function.
@@ -1571,7 +1579,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_get_timer_counter_mode(
self, slot_id: str, channel_index: int
) -> tuple[str, str | None]:
-
"""Determine the mode for a timer/counter channel.
+
"""Determine the mode for a timer/counter channel.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -1595,7 +1603,7 @@
Source code for ghsapi.ghsapi
channel_index: int,
mode: str | int,
) -> str:
- """Set the mode for a timer/counter channel.
+ """Set the mode for a timer/counter channel.
*The system needs to be idle before calling this function.*
@@ -1625,7 +1633,7 @@ Source code for ghsapi.ghsapi
[docs] def ghs_get_timer_counter_range(
self, slot_id: str, channel_index: int
) -> tuple[str, float | None, float | None]:
-
"""Determine the range for a timer/counter channel.
+
"""Determine the range for a timer/counter channel.
*Read - This method can be called by multiple connected clients at same
time.*
@@ -1651,7 +1659,7 @@
Source code for ghsapi.ghsapi
lower_value: float,
upper_value: float,
) -> str:
- """Set the range for a timer/counter channel.
+ """Set the range for a timer/counter channel.
*The system needs to be idle before calling this function.*
@@ -1680,6 +1688,166 @@ Source code for ghsapi.ghsapi
lower_value,
upper_value,
)
+
+ # FieldBus API
+
+[docs] def ghs_initiate_fieldbus_data_transfer(
+
self,
+
update_rate: int,
+
) -> tuple[str, int | None, int | None]:
+
"""*Opens a new connection for the field bus data, and waits for client
+
to connect. Once the client connects, if the acquisition state is
+
active, data is sent to the client. Otherwise nothing is sent.*
+
+
*If no formulas are present then you get error code back:GHSReturnValue_FieldBusError_NotConfigured*
+
+
*If the field bus is already initiated then an error code is returned:
+
GHSReturnValue_FieldBusError_FieldBusEnabled.*
+
+
*To change the update rate the field bus needs to be stoped and inititated again with a new update rate.*
+
+
Args:
+
update_rate: (in Hz) The update rate should be a part of the list
+
containing the supported update rates
+
+
Returns:
+
* GHSReturnValue - API return values
+
* update_rate - If the update rate selected by the user is not supported, the mainframe will adjust the update rate based on a minimum distance from the supported rates and returns back to the client.
+
* data_count - The number of published data on the setup. Timestamp is not included in this count.
+
"""
+
+
return _fieldbus.initiate_fieldbus_data_transfer(
+
self._con_handle,
+
update_rate,
+
self.fieldbus_handle
+
)
+
+[docs] def ghs_stop_fieldbus_data_transfer(
+
self,
+
) -> str:
+
"""*Closes the socket dedicated for the field bus data and stops transfering data.
+
The ring buffer allocated for the transfer data is deleted.*
+
+
*Field bus data transfer must have been initiated before calling this function*
+
+
Returns:
+
* GHSReturnValue - API return values
+
"""
+
+
return _fieldbus.stop_fieldbus_data_transfer(
+
self._con_handle,
+
)
+
+[docs] def ghs_get_fieldbus_data_count(
+
self,
+
) -> tuple[str, int | None]:
+
"""Gets the number of data that are configured to be sent through the field bus, excluding the timestamp.
+
+
Returns:
+
* GHSReturnValue - API return values
+
* data_count - The number of data that are selected to be published, excluding timestamp.
+
"""
+
+
return _fieldbus.get_fieldbus_data_count(
+
self._con_handle,
+
)
+
+[docs] def ghs_get_fieldbus_data_name_and_unit(
+
self,
+
data_index: int,
+
) -> tuple[str, str | None, str | None]:
+
"""*Gets the name of specific field bus data value, by giving the index of the data value.
+
The number of data values can be retrieved by GHSGetFieldBusDataCount().*
+
+
*In case of no formulas (or reserved values acquisition state and latency) published,
+
an error code is returned: GHSReturnValue_FieldBusError_NoFormulasDeployed.*
+
+
Args:
+
data_index: Zero-based index of the data value.
+
+
Returns:
+
* GHSReturnValue - API return values
+
* data_name - Name of the data value.
+
* data_unit - Unit of the data value.
+
"""
+
+
return _fieldbus.get_fieldbus_data_name_and_unit(
+
self._con_handle,
+
data_index,
+
)
+
+[docs] def ghs_request_fieldbus_snapshot(
+
self,
+
dataCount: int
+
) -> tuple[str, float | None, int | None, tuple[float] | None]:
+
"""*Request a single snapshot of the field bus data.
+
In this case the timestamp received is not grid aligned.*
+
+
*If the system is not acquiring the method returns an error code:GHSReturnValue_SystemNotRecording*
+
+
*In case of no formulas you get the error return code back:GHSReturnValue_FieldBusError_NotConfigured*
+
+
*If the field bus is already enabled then this method is not allowed.
+
An error return code is returned:FieldBusError_UnavailableFunctionality.*
+
+
Returns:
+
* GHSReturnValue - API return values
+
* timestamp - Timestamp of the FieldBus data relative to start of acquisition (not grid aligned) GHSGetAcquisitionStartTime
+
* data_count - Actual number of elements(formulas) in the data parameter. If number of elements allocated by the customer are less than the actual formulas number, then we return an error code.
+
* data - Array of floats that contains the data
+
"""
+
+
return _fieldbus.request_fieldbus_snapshot(
+
self._con_handle,
+
dataCount
+
)
+
+[docs] def ghs_receive_fieldbus_data(
+
self,
+
) -> str:
+
"""Used to retrieve the FieldBus data from the new socket connection and write on the buffer.
+
+
*Can be used in a thread and if so, mutual exclusion should be used with GHSStopFieldBusDataTransfer.*
+
+
*This function should be used in a loop if continuous delivery of Async Data is desired.*
+
+
*Field bus data transfer must have been initiated before calling this function.*
+
+
Returns:
+
* GHSReturnValue - API return values
+
"""
+
+
return _fieldbus.receive_fieldbus_data(
+
self.fieldbus_handle
+
)
+
+[docs] def ghs_read_next_snapshot(
+
self,
+
call_type: str | int
+
) -> tuple[str, float | None, float | None, int | None]:
+
"""Retrieves the next snapshot in the buffer.
+
+
*The timestamp is grid aligned - as specified by the 'updateRate' argument
+
of the GHSInitiateFieldBusDataTransfer() method.*
+
+
Args:
+
call_type: flag to control the receiving of FieldBus data:
+
*If set to GHS_BlockingCall it blocks while waiting for new FieldBus data.
+
*If set to GHS_NonBlockingCall then returns last FieldBus data when no new data available.
+
*GHS_BlockingCall is the preferred value as this results in the lowest CPU load
+
and highest data troughput.*
+
+
Returns:
+
* GHSReturnValue - API return values
+
* Timestamp - timestamp of the FieldBus data relative to start of acquisition GHSGetAcquisitionStartTime()
+
* Values - the values published on the FieldBus.
+
* Overrun - is one if overrun happened in the buffer, zero if not.
+
"""
+
+
return _fieldbus.read_next_snapshot(
+
self.fieldbus_handle,
+
call_type
+
)
diff --git a/docs/html/_modules/index.html b/docs/html/_modules/index.html
index 1f49491..5977efd 100644
--- a/docs/html/_modules/index.html
+++ b/docs/html/_modules/index.html
@@ -10,10 +10,11 @@
-
-
+
+
+
@@ -24,11 +25,15 @@