Skip to content

Initial commit for OmniControl 200 - #3

Open
LNicolasOnera wants to merge 6 commits into
PyMoDAQ:mainfrom
LNicolasOnera:main
Open

LNicolasOnera wants to merge 6 commits into
PyMoDAQ:mainfrom
LNicolasOnera:main

Conversation

@LNicolasOnera

Copy link
Copy Markdown

No description provided.

@LNicolasOnera

Copy link
Copy Markdown
Author

Previous plugin included the following folder only: pymodaq_plugins_pfeiffer\src\pymodaq_plugins_alcatel
I added the folder pymodaq_plugins_pfeiffer\src\pymodaq_plugins_pfeiffer containing all the code for the OmniControl 200.

from serial.tools import list_ports

def get_com_ports() -> list[str]:
"""Détecte les ports COM connectés et les renvoie sous forme de liste de strings."""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use only english to make it usable by everyone


def _active_channels(self):
"""Names of the currently checked channel booleans, in tree order."""
return [ch.name()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should group your channels in a dedicated group in the settings


def ini_attributes(self):
self.controller: Omnicontrol = None
self.port=None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't nee an extra variable to store the COM port, it is already stored in the settings!

self.settings.child('com_port').setLimits(get_com_ports())
if self.is_master:
self.port=self.settings.child('com_port').value()
self.port="COM9"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardcoded here?????????????, use the config if you want to store a default value

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and place the default value in the "value" key of the com_port parameter

labels=label)]))
# labels = ['Channel 1', 'Channel 2'])]))

info = self.controller.read_name() # lève PfeifferError si pas de réponse

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments in english

self.controller = controller
initialized = True

self.pressure_data=[np.array([0]) for ch in self._active_channels()]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use np.atleast_1d to make sure you always have at least a numpy array

try:
for ch in self._active_channels():
if ch == 'ch_1':
pressure_data.append(np.array([self.controller.read_pressure(122)]))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

122 and 132 ?? You should assign a variable name to store those at the top of your script:

CHANNEL1 = 122
CHANNEL2 = 132

A given parameter (within detector_settings) whose value has been changed by the user
"""
## TODO for your custom plugin
if param.name() == "com_port":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could remove this if you just use the com port value stored in the settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants