コード例 #1
0
    def get_channel_data_count(self, device_id, channel):
        """ Get number of data entries in a channel for the recording.

        Args:
            device_id (str): ID of device to get data from.
            channel (str): Name of the channel to get data from.

        Returns:
            int: Number of data entries in the channel.

        """
        data = {
            "recording_id": self.id,
            "device_id": device_id,
            "channel": channel
        }
        request = {
            "type": "request",
            "cmd": "recording_get_channel_data_count",
            "data": data
        }
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        return response["data"]["count"]
コード例 #2
0
    def get_channel_data_index(self, device_id, channel, timestamp):
        """ Get the index of a data entry in a channel for a specific recording for a given timestamp.

        Args:
            device_id (str): ID of device to get data from.
            channel (str): Name of the channel to get data from.
            timestamp (float): Timestamp to get index of in seconds (s).

        Returns:
            int: Index of data entry at the timestamp.

        """
        data = {
            "device_id": device_id,
            "recording_id": self.id,
            "channel": channel,
            "timestamp": timestamp
        }
        request = {
            "type": "request",
            "cmd": "recording_get_channel_data_index",
            "data": data
        }
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        return response["data"]["index"]
コード例 #3
0
    def import_log(self, filename, converter):
        """ Import log into recording.

        Args:
            filename (str): Path to log to import.
            converter (str): Name of the llog converter to use.

        Returns:
            log_id (str): Id of the log.

        """
        data = {
            "recording_id": self.id,
            "filename": filename,
            "converter": converter
        }
        request = {
            "type": "request",
            "cmd": "recording_import_log",
            "data": data
        }
        # Set timeout to None (blocking) as command can operate over large quantities of data to avoid timeout
        response = self.connection.send_and_receive(request, None)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        return response["data"]["log_id"]
コード例 #4
0
    def save_as(self, filename, force=False, progress=False):
        """ Save the project as.

        Args:
            filename (str): Name of project file.
            force (bool, optional): True to overwrite existing file, False to not overwrite.
            progress (bool, optional): True to receive notifications about save progress, False to not receive any notifications.

        Returns:
            str: Name of saved file.

        """
        data = {
            "project_id": self.id,
            "filename": filename,
            "force": force,
            "progress": progress
        }
        request = {"type": "request", "cmd": "project_save", "data": data}
        # Set timeout to None (blocking) as command can operate over large quantities of data to avoid timeout
        response = self.connection.send_and_receive(request, None)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        self.filename = response["data"]["filename"]
        return response["data"]["filename"]
コード例 #5
0
    def calibrate(self):
        """ Perform internal calibration of an Arc device.

        """
        data = {"device_id": self.id}
        request = {"type": "request", "cmd": "arc_calibrate", "data": data}
        response = self.connection.send_and_receive(request, 10)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #6
0
    def delete(self):
        """ Delete the recording.

        """
        data = {"recording_id": self.id}
        request = {"type": "request", "cmd": "recording_delete", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        self.id = -1
コード例 #7
0
    def shutdown(self):
        """ Shutdown Otii

        """
        request = {"type": "request", "cmd": "otii_shutdown"}
        try:
            response = self.connection.send_and_receive(request)
            if response["type"] == "error":
                raise otii_exception.Otii_Exception(response)
        except otii_connection.DisconnectedException:
            pass
コード例 #8
0
    def create_project(self):
        """ Create a new project.

        Returns:
            int: ID of created project.

        """
        request = {"type": "request", "cmd": "otii_create_project"}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        return project.Project(response["data"]["project_id"], self.connection)
コード例 #9
0
    def set_uart_baudrate(self, value):
        """ Set UART baud rate.

        Args:
            value (int): Value to set UART baud rate to.

        """
        data = {"device_id": self.id, "value": value}
        request = {"type": "request", "cmd": "arc_set_uart_baudrate", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #10
0
    def set_supply_used_capacity(self, value):
        """ Set power supply used capacity.

        Args:
            value (float): Capacity used in coulombs (C), multiply mAh by 3.6 to get C.

        """
        data = {"device_id": self.id, "value": value}
        request = {"type": "request", "cmd": "arc_set_supply_used_capacity", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #11
0
    def set_supply_soc_tracking(self, enable):
        """ Set power supply State of Charge tracking.

        Args:
            enable (bool): True to enable State of Charge tracking, False to disable.

        """
        data = {"device_id": self.id, "enable": enable}
        request = {"type": "request", "cmd": "arc_set_supply_soc_tracking", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #12
0
    def set_max_current(self, value):
        """ When the current exceeds this value, the main power will cut off.

        Args:
            value (float): Value to set max current to, value should be between 0.001-5 (A).

        """
        data = {"device_id": self.id, "value": value}
        request = {"type": "request", "cmd": "arc_set_max_current", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #13
0
    def set_main_voltage(self, value):
        """ Get data entries from a specified channel of a specific recording.

        Args:
            value (float): Value to set main voltage to (V).

        """
        data = {"device_id": self.id, "value": value}
        request = {"type": "request", "cmd": "arc_set_main_voltage", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #14
0
    def set_exp_voltage(self, value):
        """ Set the voltage of the expansion port.

        Args:
            value (float): Value to set expansion port voltage to, value should be between 1.2-5 (V).

        """
        data = {"device_id": self.id, "value": value}
        request = {"type": "request", "cmd": "arc_set_exp_voltage", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #15
0
    def set_adc_resistor(self, value):
        """ Set the value of the shunt resistor for the ADC.

        Args:
            value (float): Value to set ADC resistor to, value should be between 0.001-22 (Ohm).

        """
        data = {"device_id": self.id, "value": value}
        request = {"type": "request", "cmd": "arc_set_adc_resistor", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #16
0
ファイル: arc.py プロジェクト: qoitech/otii-tcp-client-python
    def set_4wire(self, enable):
        """ Enable/disable 4-wire measurements using Sense+/-.

        Args:
            enable (bool): True to enable 4-wire, false to disable

        """
        data = {"device_id": self.id, "enable": enable}
        request = {"type": "request", "cmd": "arc_set_4wire", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #17
0
    def enable_uart(self, enable):
        """ Enable UART.

        Args:
            enable (bool): True to enable UART, False to disable.

        """
        data = {"device_id": self.id, "enable": enable}
        request = {"type": "request", "cmd": "arc_enable_uart", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #18
0
    def write_tx(self, value):
        """ Write data to TX.

        Args:
            value (str): Data to write to TX.

        """
        data = {"device_id": self.id, "value": value}
        request = {"type": "request", "cmd": "arc_write_tx", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #19
0
    def set_range(self, range):
        """ Set the main outputs measurement range.

        Args:
            range (str): Current measurement range mode to set on main. "low" enables auto-range, "high" force high-range.

        """
        data = {"device_id": self.id, "range": range}
        request = {"type": "request", "cmd": "arc_set_range", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #20
0
    def set_tx(self, value):
        """ The TX pin can be used as a GPO when the UART is disabled.

        Args:
            value (bool): True to enable TX output, False to disable.

        """
        data = {"device_id": self.id, "value": value}
        request = {"type": "request", "cmd": "arc_set_tx", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #21
0
    def set_main(self, enable):
        """ Turn on or off main power on a devices.

        Args:
            enable (bool): True to turn on main power, False to turn off.

        """
        data = {"device_id": self.id, "enable": enable}
        request = {"type": "request", "cmd": "arc_set_main", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #22
0
ファイル: arc.py プロジェクト: qoitech/otii-tcp-client-python
    def get_4wire(self):
        """ Get the 4-wire measurement state.

        Returns:
            str: The current state, "cal_invalid", "disabled", "inactive" or "active".

        """
        data = {"device_id": self.id}
        request = {"type": "request", "cmd": "arc_get_4wire", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        return response["data"]["value"]
コード例 #23
0
    def set_gpo(self, pin, value):
        """ Set the state of one of the GPO pins.

        Args:
            pin (int): ID of the GPO pin to set state of, 1 or 2.
            value (bool): True to enable GPO output, False to disable.

        """
        data = {"device_id": self.id, "pin": pin, "value": value}
        request = {"type": "request", "cmd": "arc_set_gpo", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
コード例 #24
0
    def get_version(self):
        """ Get hardware and firmware versions of device.

        Returns:
            dict: Dictionary including keys hw_version (str) and fw_version (str).

        """
        data = {"device_id": self.id}
        request = {"type": "request", "cmd": "arc_get_version", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        return response["data"]
コード例 #25
0
    def is_connected(self):
        """ Check if a device is connected.

        Returns:
            bool: True if device is connected, False otherwise.

        """
        data = {"device_id": self.id}
        request = {"type": "request", "cmd": "arc_is_connected", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        return response["data"]["connected"]
コード例 #26
0
    def get_adc_resistor(self):
        """ Get adc resistor value.

        Returns:
            float: ADC resistor value (Ohm).

        """
        data = {"device_id": self.id}
        request = {"type": "request", "cmd": "arc_get_adc_resistor", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        return response["data"]["value"]
コード例 #27
0
    def get_supply(self):
        """ Get current power supply ID.

        Returns:
            int: ID of current supply.

        """
        data = {"device_id": self.id}
        request = {"type": "request", "cmd": "arc_get_supply", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        return response["data"]["supply_id"]
コード例 #28
0
    def get_supplies(self):
        """ Get a list of all available supplies. Supply ID 0 allways refers to the power box.

        Returns:
            list: List of supply objects.

        """
        data = {"device_id": self.id}
        request = {"type": "request", "cmd": "arc_get_supplies", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        return response["data"]["supplies"]
コード例 #29
0
    def get_rx(self):
        """ The RX pin can be used as a GPI when the UART is disabled.

        Returns:
            bool: State of the RX pin.

        """
        data = {"device_id": self.id}
        request = {"type": "request", "cmd": "arc_get_rx", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        return response["data"]["value"]
コード例 #30
0
    def get_range(self):
        """ Get the current measurement range on the main output.

        Returns:
            str: Current measurement range mode on main, "low" or "high".

        """
        data = {"device_id": self.id}
        request = {"type": "request", "cmd": "arc_get_range", "data": data}
        response = self.connection.send_and_receive(request)
        if response["type"] == "error":
            raise otii_exception.Otii_Exception(response)
        return response["data"]["range"]