-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Device interface dev #118
Draft
vasilisniaouris
wants to merge
22
commits into
qt3uw:main
Choose a base branch
from
vasilisniaouris:device-interface-dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Device interface dev #118
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… as a subclass with the Device interface class to provide data acquisition support for sensor/reader-type devices.
…. Specifically, two methods were added to ease automated resource detection with pyvisa.
…and force-stop functionality in time series acquisition.
… the `logger_config.yaml` file.
In `utils.py`, updated methods resource finder methods to bypass `resource.clear()` errors, and set the write and (automatically) read termination. Also created a force clear method for problematic read buffers. In `devices.py`, created a `MessageBasedDevice` class, updated AcquisitionMixin with data streaming thread and other optimizations.
… with device communication delays and crashes.
…uistionThread and StreamingThread
…Mixin classes. Thoroughly documented everything.
…dually defined log methods.
…xin usage in `random.py`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the beginning of a new interface class that will be used throughout the project. The goal of creating such an interface is to automate the introduction of new devices to already existing experiments and applications.
Throughout the following I will inadvertently mention problems that may related to different qt3-utils issues. I will do my best to edit this intro message to mention each of the issues at a later time. For now, I want this pull request to serve as a discussion space of how to implement such a big project that is device interfacing (if that is the appropriate way to do it). Happy to move the discussion elsewhere if it is dimmed necessary.
The structure I chose is the following:
Device(abc.ABC)
is a class that holds all device information, allows the device to connect, disconnect, clear and actuate basic communication with the physical instrument. All devices will use athreading.Lock
to safely communicate with the device. The use of the lock is not necessary but strongly recommended. The most important attribute of this class is themediator
, which will hold the object that performs the communication between software and hardware.Device
, to provide acquisition capabilities such as single acquisition, timed single acquisition (single acquisition with time stamps), and time series acquistion (multiple timed single acquisitions).AcquisitionThread
, which will use a pipeline (queue.Queue
) to pass the acquired data from the acquisition thread to the device data storage variable. The acquisition thread will be controlled (start, pause, resume, stop) bythreading.Event
s, which will be passed down from the experiment control thread to the acquisition thread through the device object.StreamingThread
will 'collect' the data to either store, display on a GUI or both. This is best used when we want to observe the time series collection as it takes place.AcquisitionThread
, and release them at the end of the acquisition through the pipeline. In that case, theStreamingThread
is not necessary. This is best used when time overhead must be avoided as much as possible, and observation of the time series during collection is not important.The main device subclasses that can be helpful are:
PyVisaMessagingBasedDevice(abc.ABC, Device)
: Devices that use thepyvisa
library, and specificallyMessageBasedInstrument
s, such as USB, Serial and GPIB, which are very common in our labs. This subclass defines the base methods connect, disconnect and clear. Additionally, it implementsclassmethod
s that allow the use to easily connect with the device without necessarily knowing the port, but rather the device IDN, or the manufacttorer device name attribute. This will allow users to be able to use already known devices without needing to change the code every time they change the connections or the computer system.NIDAQDevice(abc.ABC, Device)
: Not sure if needed or how I would implemented yet, the goal is similar to the above subclass. For example, we can define a device that takes the already definedRateCounter
and uses it as a mediator, or a slight variation thereof.DLLbasedDevice(abc.ABC, Device)
: A device whosemediator
is a dll-based library. I have created a universal dll-loading class and methods based onctypesgen
that searches multiple locations in the computer to find the desired dll file. This class is not implemented in this branch but in the hyperspectral-dev brach in my personal github account. I am planning on transfering it soon.Other useful classes and methods I have developed:
get_configured_logger
: a method that returns a logger with a given name that is configured based on thelogger_config.yaml
file settings.LoggerMixin
: a mixin class that creates a log method for a given class, that allows tracking of information from specific devices. I believe this will help the user better understand how their experiment is run, as long as we consistently log what our code does! Great for troubleshooting multiple threads and devices.Future implementations:
AcquisitionMixin-based
object (much like the oscilloscope application, but generalized).Device
class.Other features that probably refer to existing or should refer to new issues, but would be good to start implementing now:
Issues I am running into:
StreamingThread
necessary?