qoitech/otii-tcp-client-python

Names of channels in otii-tcp-client-python?

Opened this issue · 1 comments

I would like to use the OTII Automation toolbox with Python (otii-tcp-client-python).
Furthermore, I would like to configure the device to record the channels "Main current", "Main voltage", and "Main power".
In the GUI, these are called as above, see the following screenshot:

Screenshot from 2024-02-19 15-47-18

Unfortunately, I do not know how these channels have to be called when calling the method enable_channel of the Arc device class.

"Main current" and "Main voltage" seem to be referred to by the strings "mc" and "mv" respectively.
These strings are used in some of the examples, e.g., basic measurement example or the documentation page example.

What are the string names for the other channels? I can neither find them in the examples nor in the documentation.

In particular, what is the string referring to "Main power"? Is it "mp"?

Thank you for your help in advance.


I would suggest to modify the method enable_channel method of the Arc class so that it does not receive a string as channel parameter.
Instead, it could receive instances of a Channel Enum, see below.
Then the code would be more self-documenting.

from enum import Enum


class Channel(Enum):
    MAIN_CURRENT = "mc"
    MAIN_VOLTAGE = "mv"
    MAIN_POWER = "mp"
    ADC_CURRENT = "adcc"
    ADC_VOLTAGE = "adcv"
    ADC_POWER = "adcp"
    SENSE_MINUS_VOLTAGE = "smv"
    SENSE_PLUS_VOLTAGE = "spv"
    GPI_1 = "gpi1"
    GPI_2 = "gpi2"

A call to the method would then look like the following

device.enable_channel(Channel.MAIN_CURRENT, True)

I believe such a change could help others than me :)
In case you like it, I will implement it and send a respective pull request.

Hej again,

in an otti 2 example, I found the following list of channel identifier strings:

"""
    Channel Description	    Unit
    mc      Main Current    A
    mv      Main Voltage    V
    me      Main Energy     J
    ac      ADC Current     A
    av      ADC Voltage     V
    ae      ADC Energy      J
    sp      Sense+ Voltage  V
    sn      Sense- Voltage  V
    vb      VBUS            V
    vj      DC Jack         V
    tp      Temperature     °C
    rx      UART logs       text
"""

That is, I believe the channel string for "Main power" that I was searching for is "me". Consequently, I am suggesting an enumeration type as in the following:

class Channel(Enum):
    """ All channels of an ARC device and their mapping to strings that are
    understood by the TCP server.

    Use these values as input to the Arc.enable_channel method.
    """
    # Identifier   String value   Unit
    MAIN_CURRENT = "mc"         # A
    MAIN_VOLTAGE = "mv"         # V
    MAIN_POWER = "mp"          # J
    ADC_CURRENT = "ac"          # A
    ADC_VOLTAGE = "av"          # V
    ADC_POWER = "ap"           # J
    SENSE_MINUS_VOLTAGE = "sn"  # V
    SENSE_PLUS_VOLTAGE = "sp"   # V
    VBUS = "vb"                 # V
    TEMPERATURE = "tp"          # °C
    UART_LOGS = "rx"            # text
    GPI_1 = "i1"
    GPI_2 = "i2"

However, this raises two questions:
1. What is the reason for that "Main power" and "ADC Power" are labelled with Power in the GUI but as Energy in code, should not they be called the same?
2. What are the correct strings for the GPI channels? In the example above, I just guessed them.

I found an answer to my second question in the recording module. Based on that line, I believe the strings for these two channels are "i1" and "i2" respectively. I changed my example above accordingly.

I also found an answer to my first question. It seems that in Otii 2, the two channels were called something with Energy and now they are called something with Power. I adapted my suggestion above accordingly. That is, to answer my original question: the "Main power" channel string identifier is just "mp".

In case you are interested in a pull-request with a respective enumeration type, I implemented it here. In case you are not interested, this issue can be closed.