Giter Club home page Giter Club logo

epicsapps's Introduction

PyEpics: Epics Channel Access for Python

https://img.shields.io/badge/docs-read-brightgreen

PyEpics is a Python interface to the EPICS Channel Access (CA) library for the EPICS control system.

The PyEpics module includes both low-level (C-like) and higher-level access (with Python objects) to the EPICS Channnel Access (CA) protocol. Python's ctypes library is used to wrap the basic CA functionality, with higher level objects on top of that basic interface. This approach has several advantages including no need for extension code written in C, better thread-safety, and easier installation on multiple platforms.

Installation

This package is supported and tested with Python 3.8 through 3.12. Shared libraries needed for Epics Channel Access are provided for Windows, MacOS, and Linux, and used by default. If you wish to use your own versions of the CA shared libraries, that can be controlled with an environmental variable.

To install the package, use:

pip install pyepics

To install from source, download the source kit for the latest release from PyPI (https://pypi.org/project/pyepics/) or Github (https://github.com/pyepics/pyepics/releases), unpack that and use:

pip install .

For additional installation details, see the INSTALL file. Binary installers for Windows are available.

License

This code is distributed under the Epics Open License

Overview

Pyepics provides two principle modules: ca, and pv, and functions caget(), caput(), and cainfo() for the simplest of interaction with EPICS. In addition, there are modules for Epics Motors and Alarms, autosave support via CA, and special widget classes for using EPICS PVs with wxPython.

caget(), caput() and cainfo()

The simplest interface to EPICS Channel Access provides functions caget(), caput(), and cainfo(), similar to the EZCA interface and to the EPICS-supplied command line utilities. These all take the name of an Epics Process Variable as the first argument:

 ~> python
 >>> from epics import caget, caput, cainfo
 >>> print(caget('XXX:m1.VAL'))
1.200
>>> caput('XXX:m1.VAL',2.30)
1
>>> cainfo('XXX.m1.VAL')
== XXX:m1.VAL  (double) ==
   value      = 2.3
   char_value = 2.3000
   count      = 1
   units      = mm
   precision  = 4
   host       = xxx.aps.anl.gov:5064
   access     = read/write
   status     = 1
   severity   = 0
   timestamp  = 1265996455.417 (2010-Feb-12 11:40:55.417)
   upper_ctrl_limit    = 200.0
   lower_ctrl_limit    = -200.0
   upper_disp_limit    = 200.0
   lower_disp_limit    = -200.0
   upper_alarm_limit   = 0.0
   lower_alarm_limit   = 0.0
   upper_warning_limit = 0.0
   lower_warning       = 0.0
   PV is monitored internally
   no user callbacks defined.
=============================

PV: Object Oriented CA interface

The general concept is that an Epics Process Variable is implemented as a Python PV object, which provides a natural way to interact with EPICS.

>>> import epics
>>> pv = epics.PV('PVName')
>>> pv.connected
True
>>> pv.get()
3.14
>>> pv.put(2.71)

Channel Access features that are included here:

  • user callbacks - user-supplied Python function(s) that are run when a PV's value, access rights, or connection status changes
  • control values - a full Control DBR record can be requested
  • enumeration strings - enum PV types have integer or string representation, and you get access to both
  • put with wait - The PV.put() method can optionally wait until the record is done processing (with timeout)

Features that you won't have to worry about:

  • connection management (unless you choose to worry about this)
  • PV record types - this is handled automatically.

Matt Newville <[email protected]> Last Update: 2024-June-20

epicsapps's People

Contributors

newville avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

epicsapps's Issues

step scan needs

-- user comments to file
-- spec_emulator needs to read and use .INI file
-- stepscan and spec_emulator need to use "auto_increment" or "append" mode for outputfile.

AreaDetector_Display not showing image (16bit data)

Dear Matt,

I would like to customise the AreaDetector application to do some image processing "on the fly."
At the moment the application connects to the camera and the "acquisition start/stop" works properly.
Unfortunately the image is not show in the frame (just black).
I looked to the code and I think that this is due to the fact that my raw data is of type uint16 and mono.
In this case ad_display.py lines 866--876, sets im_mode to 'I' and convert to uint32.
But in the DataToImage method I couldn't find the code lines that convert the data to an image.
As far as I understand from the documentation neither the python Image library 'image.frombuffernor 'wx.ImageFromData support this kind of data. Am I correct?
Does this mean that the only way to go is to scale down the rawdata to uint8? or is there other ways to plot the uint16 data?

Thanks

ps. I used some print statement, so the line numbers above may be a bit shifted.

on using the epics.wx widgets

Just trying it out with a very simple:

import wx
import epics.wx

app = wx.App()

frame = wx.Frame(None, -1, 'simple.py')
panel = wx.Panel(frame, -1)
epics.wx.PVText(panel, pv="MY:PV")
frame.Show()

app.MainLoop()

But nothing is displayed... probably missing something trivial here, but what?

Creating PV on uninitialized waveform record fails in ca.py

Set-up:

  • IOC with a waveform record (name WF_SP) in the db:
    record(waveform, "WF_SP") {
    field(DESC, "Sequence")
    field(FTVL, "LONG")
    field(NELM, "10")
    }
  • no operation is done on the waveform after the IOC starts so it is totally uninitialized

Issue description:

When creating a PV as the following:
pv1= PV(pvname = 'WF_SP', callback = onChanges, auto_monitor=True, form='ctrl');

The following error is reported and callback is not called:

Traceback (most recent call last):
File "_ctypes/callbacks.c", line 314, in 'calling callback function'
File "/usr/local/lib/python2.7/dist-packages/pyepics-3.2.1-py2.7.egg/epics/ca.py", line 436, in _onMonitorEvent
tmpv = value[0]
IndexError: invalid index

This means that callback should be called with no value(?) and count set to 0(?), but one could still use other information from other callback arguments and kwargs.

The same issue does not happen when this is done on an uninitialized longout record (I guess this is true also for other types)

Best Regards,
Rok

instruments requests

  1. highlighting motor value then typing should wipe old value
  2. double-click pos name should be same as GoTo
  3. selecting position should put that name in the edit field
  4. should be able to Edit Position or Specify a Position without being at that Position

Also: Menu->Options->Settings appeared to not work...
Also: Moving items up/down position list seemed to hang process and NOT save settings....

AreaDetector_Display: Draw lines on top of camera image

My aim is to draw some lines on top of the image. As far as I understood how imageview works,
it should be done directly on the DrawImage method using de dc instance (unless we do it a instance attribute). I plugged the following line in the code:

dc.DrawLine(512*xscale,0*yscale, 512*xscale, 1024*yscale)

But it doesn't seem to be a line on the center in my 1024x1024 image.
The image it also not shown completely on the frame even if the application is maximaized.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.