Giter Club home page Giter Club logo

newportxps'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

newportxps's People

Contributors

hududed avatar lincolnuehara avatar lockhart avatar mfilmer avatar newville avatar nico-helmi avatar skordaschristofanis avatar voloved avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

newportxps's Issues

Could not read system.ini!!!

Hello,

I have a XPS-D controller with the following information:
Snapshot version: XPS-D-N13018
QNX kernel version: QNX kernel configuration V3.0.22 (20191107, SYSTEM, apic mode)
Stage database revision: StageDataBase V4.3.6 - XPS Controller

When trying to connect to connect to it:

from newportxps import NewportXPS
xps = NewportXPS('192.168.254.254', username='Administrator', password='Administrator')
I get the following error message:
Could not read system.ini!!!"

I have system.ini file on the controller and when connecting the controller with dedicated software that came with the whole system there is no problem. Also, everything from the web interface of the controller side looks fine.
Also when trying to connect to it, there are no other open connections with the controller.

I am using Python 3.7.4.

Any ideas, suggestions? What did I miss? Please advise.

This is the system.ini file:
`; #########################################################################################
; # Generated from manual configuration by Administrator on Fri, 20 Dec 2019 18:07:40 GMT #
; #########################################################################################

[GENERAL]
BootScriptFileName = SetGPIO3output1.tcl
BootScriptArguments =

[GROUPS]
SingleAxisInUse = Z, P
SpindleInUse =
XYInUse = XY
XYZInUse =
MultipleAxesInUse =

; #############################################
; # Single axis group 'Z' and its positioner: Z

[Z]
PositionerInUse = Z

[Z.Z]
PlugNumber = 5
StageName = IMS@IMS100V@XPS-DRV11
SecondaryPositionerGantry = Disabled

; #############################################
; # Single axis group 'P' and its positioner: P

[P]
PositionerInUse = P

[P.P]
PlugNumber = 4
StageName = AXIS_PZ
SecondaryPositionerGantry = Disabled

; ##############################################
; # XY axes group 'XY' and its positioners: X, Y

[XY]
PositionerInUse = X, Y
InitializationAndHomeSearchSequence = Together
XMappingFileName =
XMappingLineNumber = 0
XMappingColumnNumber = 0
XMappingMaxPositionError = 0
YMappingFileName =
YMappingLineNumber = 0
YMappingColumnNumber = 0
YMappingMaxPositionError = 0

[XY.X]
PlugNumber = 1
StageName = AXIS_X
SecondaryPositionerGantry = Disabled

[XY.Y]
PlugNumber = 2
StageName = AXIS_Y
SecondaryPositionerGantry = Disabled
`

Thank you in advance!

Best regards,
Vedrancek

About this repo

Hello,

Thanks for making the newportxps package available!
Just a few questions:

  • is this the main repo for newportxps or is it a fork of another library? I guess you're the author of this library @newville?
  • Newport Corp. has provided a basic socket and ftp interface to the XPS controller for a long time, this interface is very low-level
    I'm not sure I have this document. Would you have a link to the basic socket and ftp interface documentation ? If you don't have the link, would you have the .PDF filename? (Maybe I can find it)
  • how does newportxps compare to the .net interface (using pythonnet) using the official .DLL coming with Newport.XPS.CommandInterface_x64.msi?
  • I only see in https://github.com/pyepics/newportxps/tree/master/newportxps the model XPS_C8. Does this mean the XPS-D8 and XPS-RLD8 are unsupported by this library?

Thanks again!

system.ini parser problem

Hello,
I found an issue with parsing factory provided system.ini file from XPS-C:

[GENERAL]
BootScriptFileName = 
BootScriptArguments = 

[GROUPS]
SingleAxisInUse =  THETA, X, Y, Z
SpindleInUse = 
XYInUse = 
XYZInUse = 
MultipleAxesInUse = 

 [THETA]
PositionerInUse = RVS80

 [THETA.RVS80]
PlugNumber = 1
StageName = RVS80PPV6
;--- Time flasher
TimeFlasherBaseFrequency = 40e6 ; Hz

 [X]
PositionerInUse = LTA-X

 [X.LTA-X]
PlugNumber = 2
StageName = LTAHLPPV6-X
;--- Time flasher
TimeFlasherBaseFrequency = 40e6 ; Hz

 [Y]
PositionerInUse = LTA-Y

 [Y.LTA-Y]
PlugNumber = 3
StageName = LTAHLPPV6-Y
;--- Time flasher
TimeFlasherBaseFrequency = 40e6 ; Hz

 [Z]
PositionerInUse = LTA-Z

 [Z.LTA-Z]
PlugNumber = 4
StageName = LTAHLPPV6-Z
;--- Time flasher
TimeFlasherBaseFrequency = 40e6 ; Hz

After debugging, I found that problem is in leading white character in [section] header line. Such line is not processed correctly with ConfigParser.
To be honest, I am not sure if white characters before section are allowed in standart .ini files but possible workaround is to remove white characters from lines before parsing using strip() function. Thus replace code:

sconf.readfp(StringIO('\n'.join(lines)))

with:

sconf.readfp(StringIO('\n'.join([line.strip() for line in lines])))

Best,
Juraj

Bug in ftp_wrapper

Hello,

I wanted to use your module to control a Newport XPS-D. After having problems establishing the sftp connection I finally found the reason: In the ftp_wrapper.py file, the "connect" function trys to establish a connection to the XPS using "username=self.username" and "password=self.username" (Line 75). The latter should be changed to "password=self.password".

Kind regards,
Nico

Abort movement but busy socket (XPS_D8)

Hi, first of all thank you for you're package, that is super useful
All i want is to press a button on my interface that's stop the axis to create like an software emergency button and also to avoid crash (with telemeter laser measurement).
But I have an issue with the fact the Abort function does anything.
During an axis movement the socket is busy so the function Abort can't send the message to the XPS.
Is that possible to open several sockets ?

typo in package description

Hi,
just the package I was looking for, but just noticed that line three of the example code should read:

print(xps.status_report()) not print(xps.status_report)

Tim

`xps.run_trajectory` hangs

Hello

I ran in both jupyter notebook and python shell in windows powershell:

from newportxps import NewportXPS
IPADDR = '192.168.254.100' # Update remote/host address here

xps = NewportXPS(IPADDR)
xps.initialize_allgroups()
xps.home_allgroups()
xps.define_line_trajectories(start=0,
                             stop=5,
                             step=0.01,
                             scantime=2.667,
                             axis='Y')
xps.trajectories
xps.run_trajectory('foreward')

but the code gets stuck after the motors have moved. Any thoughts?

Setting trajectory group

Hi @newville

I am trying to set a simple line trajectory.

I have the axes set as such:

xps = NewportXPS(hostname)
# XPS host:         192.168.254.254 (XPS-1B81)
# Firmware:         XPS-D-N13019
# Current Time:     Wed Aug  5 14:52:22 2020
# Last Reboot:      Sun Aug  2 17:27:49 2020
# Trajectory Group: None
# Groups and Stages
Z (singleaxisinuse), Status: Not referenced state
   Z.Z-MFA (MFA@MFA-CC@XPS-DRV11)
      Hardware Status: First driver powered on - ZM low level
      Positioner Errors: OK
XY (xyinuse), Status: Not referenced state
   XY.X-MFA (MFA@MFA-CC@XPS-DRV11)
      Hardware Status: First driver powered on - ZM low level
      Positioner Errors: OK
   XY.Y-MFA (MFA@MFA-CC@XPS-DRV11)
      Hardware Status: First driver powered on - ZM low level
      Positioner Errors: OK

If I try to define the line trajectory for group Z:

>>>xps.define_line_trajectories("Z")
Must define a trajectory group first!

If I set the trajectory group I get the error:

>>>xps.set_trajectory_group("Z")
XPSException: 'OrderedDict([('category', 'xyinuse'), ('positioners', ['X-MFA', 'Y-MFA'])])' cannot be a trajectory group, must be one of 

How do I properly set the trajectory group?

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.