hephy-dd / comet Goto Github PK
View Code? Open in Web Editor NEWCOMET - Control and Measurement Toolkit
License: GNU General Public License v3.0
COMET - Control and Measurement Toolkit
License: GNU General Public License v3.0
Migrate comet.ui
, comet.application
and comet.process
to qutie.
Note: this will introduce breaking changes.
In Driver.__setattr__
every property is accessed for a type check, resulting in unwanted queries. Driver attributes can be found in Driver.__dict__
(but properties not).
An optimized approach for custom process/thread callback registration and calls.
class Process(comet.Process):
def run(self):
while self.running:
self.push("temp", 22.5)
self.push("humid", 50.0)
self.push("status", 42)
process = Process(
fail=ctrl.handle_error, # built in callback
temp=ctrl.handle_temp,
humid=ctrl.handle_humid
)
process.callbacks["status"] = ctrl.handle_status
...
Optional move built in callbacks begin
, finish
and fail
also to property callbacks
to avoid accidental assignment in process run()
.
Provide a custom generic plot widget to re-sample data series from numpy
arrays and plot using QChart.
Linear range class functions.LinearRange
does return an empty sequence if step exceeds the absolute ramp distance.
>>> list(LinearRange(0, 1, 5))
[]
It should return
>>> list(LinearRange(0, 1, 5))
[0.0, 1.0]
FutureWarning: The visa module provided by PyVISA is being deprecated. You can replace
import visa
byimport pyvisa as visa
to achieve the same effect.The reason for the deprecation is the possible conflict with the visa package provided by the https://github.com/visa-sdk/visa-python which can result in hard to debug situations.
Corvus Venus-1 driver fixes after hardware testing.
Provide an convenient way of using class comet.Process
with functions (like class threading.Thread
). Attribute target
is called if no custom implementaion of run()
is provided.
>>> def run(p):
... while p.running:
... pass
...
>>> p = comet.Process(id="proc", target=run)
>>> p.start()
Migrate to Qutie 1.7.x, list-like widget property items
was replaced by __iter__
.
Add driver for Corvus TT/eco instruments (Venus-1 language)
from comet.driver.corvus import Venus1
Add a simple to use tree widget.
tree = comet.Tree(header=["Key", "Value"])
spam = tree.append(["spam", 1000])
spam.append(["ham", 2000])
spam.append(["eggs", 3000])
for item in tree:
item[0].checked = True # set checkd state
for child in item.children:
child[0].checked = False
child[1].color = "green"
Broken method remove()
of class ui.BoxLayout
.
In class comet.devices.cts.ITC
method setAnalogChannel
does switch wraong channels, eg. a1
instead of a0
See https://github.com/hephy-dd/comet/blob/master/comet/devices/cts/itc.py#L106
Create a generic instrument emulation socket server for testing and development.
from comet.emulator import RequestHandler, TCPServer
class K2700Handler(RequestHandler):
read_terminaton = "\r"
write_terminaton = "\r"
@message(r'\*IDN\?')
def idn(self, message):
return "Keithley Model 2700 Emulator"
server = TCPServer(K2700Handler)
server.run("localhost", 10001)
It turned out to be quite tedious/impractical to forward attributes using property classes, implementing Driver
sub modules. Possible solution: stick back to classic attribute instances, prevent attribute assignments for Driver
instances.
class Axis(Driver):
def __init__(self, resource, index):
super().__init__(resource)
self._index = index
class Venus1(Driver):
def __init__(self, resource):
super().__init__(resource)
self.x = Axis(resource, 1)
self.y = Axis(resource, 2)
self.z = Axis(resource, 3)
# Prevent accidental assignments
>>> device = Venus1(...)
>>> device.x = 4
...
AttributeError: can't set attribute
Add method decorator classes for actions and properties like Lantz or Slave do provide for convenient value mapping and list like item access.
class MyDriver(Driver):
@Action()
def init(self): ...
@Property(values={False: 0, True: 1})
def output(self):
...
@output.setter
def output(self, value: int):
...
@Property(keys=(0, 1, 2, 3), minimum=-1000.0, maximum=1000.0)
def channel(self, key):
...
@channel.setter
def channel(self, key, value):
...
>>> with MyDriver(...) as device:
... device.output = True
... device.channel[0] = 10.0
An easy approach to load/overwrite settings for registered devices using method load_settings()
.
...
>>> app.devices.add("smu", K2140(Resource("GBIP::1::INSTR")))
>>> app.devices.get("smu").resource.resource_name
'GBIP::1::INSTR'
...
>>> app.devices.load_settings() # overwrite resource values by settings
>>> app.devices.get("smu").resource.resource_name
'ASRL1::INSTR'
Add VISA specific instrument options (eg. read_termination
, write_termination
) to the resources preferences dialog.
It is required to update these options depending on the physical device settings without updating the application code.
*.spec
file template*.ico
iconCreate simple custom UI classes to wrap PyQt5 widgets to provide an easy way to create COMET dashboards.
A bit like a simplified version of Plotly's Dash Python framework.
import comet
app = comet.Application(name='sample')
app.layout = comet.Row(
comet.Plot(id='plot'),
comet.Column(
comet.Button(id='reset', text='Reset'),
comet.Button(id='clear', text='Clear')
)
)
@comet.event('refresh', 'clicked')
def refresh(event):
app.get('plot').reset()
@comet.event('clear', 'clicked')
def clear(event):
app.get('plot').clear()
app.run()
Add functions to create file/directory open/save dialogs.
>>> comet.file_open(...)
'/home/user/sample.txt'
>>> comet.files_open(...)
['/home/user/foo.txt', '/home/user/bar.txt']
>>> comet.directory_open(...)
'/home/user'
>>> comet.file_save(...)
'/home/user/sample.txt'
>>> comet.directory_save(...)
'/home/user'
Migrate to recent setuptools and add pyproject.toml
and setup.cfg
files.
Migrate Qt5 widgets MainWindow
, PreferencesDialog
and AboutDialog
to qutie.
Provide access to main window and preferences dialog to enable customization.
Adding a device driver for HEPHY ShuntBox.
from comet.devices.hephy import ShuntBox
Some individual instruments (observed with a Keithley 2700) might occasionally require an additional delay between consecutive write()
commands.
write_delay
write_delay
to device write()
methodwrite_delay
using preferences dialogAdd unit tests for driver classes.
Creating a minimal basic documentation using GitHub pages and Jekyll.
Special case
for value in comet.Range(0, 0, 1):
print(value)
will count up infinite.
Providing a simple UI widget stack using QStackedWidget
.
stack = comet.Stack(id="stack", [
comet.Label(id="p1", "Page 1"),
comet.Label(id="p2", "Page 2"),
comet.Label(id="p3", "Page 3")
])
stack.current = 1 # shows page 1
stack.current = stack.get('p3') # shows page 3
Migrate to Qutie 1.6.x, module qutie.qt
was replaced by qutie.qutie
.
Add functions to create modal message dialogs.
>>> comet.show_info(title="Hey!", text="This is informative.")
>>> comet.show_warning(title="Ho!", text="Hold your horses.")
>>> comet.show_error(title="An error occurred", text="This is a fatal error.")
>>> comet.show_critical(title="A critical error occurred", text="This is really critical.")
>>> try:
... no_such_func()
... except NameError as e:
... comet.show_exception(e)
In class comet.devices.hephy.ShuntBox
methods enable()
and enableAll()
raise assertion errors for query results. This is due to trailing blank characters in the result (despite the read termination).
Add rule for *.ico
assets in setup.py
as Pyinstaller fails on Windows (missing icon file).
Introducing an event handler for convenient use of callbacks from within processes (threads).
Depending on the thread context an event callback is either called in the same thread the process was created in (usually the main thread) or a PyQt5 signal is emitted from within a worker thread.
Callbacks should be accessible as dictionary and also as attribute for convenience.
def on_reading(data):
print(data)
def on_finished():
print("finished.")
def run(p):
while p.running:
p.events.reading([42]) # access as attribute
p.events["finished"]() # access as dict item
app = comet.Application()
p = comet.Process(target=run, events=dict(reading=print)) # initial assign as dict
p.events["reading"] = on_reading # (re-)assign as dict item
p.events.finished = on_finished # assign as attribute
p.start()
app.run() # events require event loop to work!
Introduce thread save immutable data exchange mechanism (exchanging only deep copies) using methods get(key, default=None)
and set(key, value)
>>> def run(p):
... for i in range(42):
... value = p.get('count', default=0)
... value += 1
... p.set('count', value)
>>> p = comet.Process(target=run)
>>> p.set('count', 0)
>>> p.start()
>>> p.join()
>>> p.get('count')
42
Create a cascading instrument driver class (like Slave).
Should be
self.voltage = self.Voltage(resource)
comet/comet/driver/keithley/k2400.py
Line 322 in 4979a02
Infinitive default minimum/maximum limits for UI class Number
to prevent accidental value mangling (Qt default is 0.0-99.99 see https://doc.qt.io/qt-5/qdoublespinbox.html#maximum-prop).
w.setMinimum(-float('inf'))
w.setMaximum(float('inf'))
Setting application properties width
and height
result in fixed sized window, should use function resize
instead to adjust window size.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.