Metadata-Version: 2.1
Name: epmux
Version: 1.0.0
Summary: epmux protocol python binding.
Author-email: EPC MSU <info@physlab.ru>
License: Copyright (c) 2024 EPC MSU
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
Classifier: Operating System :: Microsoft :: Windows :: Windows 7
Classifier: Operating System :: Microsoft :: Windows :: Windows 8
Classifier: Operating System :: Microsoft :: Windows :: Windows 8.1
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.6
Description-Content-Type: text/markdown

## epmux
This is a python binding for epmux cross-platform library for Multiplexer EyePoint MUX.

![MUX](https://raw.githubusercontent.com/EPC-MSU/EPLab/851dc110dd48f778766e33a604f93fdae4b685a9/media/ep_mux.jpg)

### Installation
```
pip install epmux
```

### Minimal example

For more information on API functions please consult documentation (see section "More information").

```python
from epmux import EpmuxDeviceHandle

module_type = {
    0: "placeholder",  # No module present
    1: "A",            # Module of type A (connects to line A only)
    2: "AB"            # Module of type AB (connects to both line A and B)
}

# Set correct device URI here
# Format for Windows: com:\\.\COM1
# Format for Linux: /dev/ttyACM1
# Format for MacOS: com:///dev/tty.usbmodem000001721
device_uri = r'com:\\.\COM433'

# Open device
try:
    device = EpmuxDeviceHandle(device_uri)
    print("Device opened")
    print("Read device information... ", end="")
    device_info = device.get_identity_information()
    print("Done")
    print("  -- Device information --")
    print("  Product: {} {}".format(bytes(device_info.manufacturer).decode("utf-8"),
                                    bytes(device_info.product_name).decode("utf-8")))
    print("  Hardware version: {}.{}.{}".format(device_info.hardware_major,
                                                device_info.hardware_minor,
                                                device_info.hardware_bugfix))
    print("  Serial number: {}".format(device_info.serial_number))
    print("  Firmware version: {}.{}.{}".format(device_info.firmware_major,
                                                device_info.firmware_minor,
                                                device_info.firmware_bugfix))
except RuntimeError:
    print("Cannot open device {}.".format(device_uri))
    print("Please check URI and try again.")
    exit()

# Get module chain structure (number of modules and their types)
chain = device.get_chain_structure()
print("Device chain length: {}".format(chain.chain_length))
print("Device chain structure: ", end="")
print(*("{}".format(module_type[chain.chain_structure[k]])
        for k in range(chain.chain_length)), sep=", ")

# Set active output channel
print("Set active output channel to: module 1, line A, channel 1")
active_channel_a = device.get_channel_for_line_a()
active_channel_a.module_number = 1   # Module chain position
active_channel_a.channel_number = 1  # Channel number within the module
device.set_channel_for_line_a(active_channel_a)

print("Turn off all channels of all modules")
device.all_channels_off()

# Close device
device.close_device()
print("Device closed")
```

### More information
For documentation, software, examples of using the API and bindings for Python and C#, you can visit our website:
* English version: https://eyepoint.physlab.ru/en/product/EyePoint_MUX_M/
* Russian version: https://eyepoint.physlab.ru/ru/product/EyePoint_MUX_M/. 