Coder Social home page Coder Social logo

alba-synchrotron / pyicepap Goto Github PK

View Code? Open in Web Editor NEW
2.0 13.0 12.0 1.17 MB

Python IcePAP Extension for Win32, Linux, BSD, Jython This is the python library to access IcePAP systems for generic purpose. It provides Socket objects to interact with the IcePAP System.

License: GNU General Public License v3.0

Python 100.00%

pyicepap's Introduction

icepap

Pypi version

Python module to configure, control and monitor IcePAP based systems.

Installation

From within your favourite python environment:

pip install icepap

Additionally, if you want to use icepapctl (the icepap CLI), you need some extra dependencies which can be installed with:

pip install icepap[cli]

Note: The CLI requires a python >= 3.6 environment.

icepap is also available on conda-forge. You can install it using conda:

conda install -c conda-forge icepap

Usage

The icepap python library in action:

spec in action

The icepapctl command line tool in action:

spec in action

Documentation

The project documentation can be found here or you can build it by executing:

python setup.py build_sphinx

This documentation has been created by sphinx.

Tests

You can run tests simply with:

python setup.py test

Contribute

You can find how to contribute to this project on CONTRIBUTING.md file.

pyicepap's People

Contributors

aureocarneiro avatar beenje avatar guifrecuni avatar henquist avatar inki2 avatar jordiandreu avatar marceloalcocer avatar ovallcorba avatar psperceval avatar reszelaz avatar rhomspuron avatar tiagocoutinho avatar

Stargazers

 avatar  avatar

Watchers

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

pyicepap's Issues

dependencies

Hello there,
doing some tests for icepapcms, I noticed that pyIcePAP needs at least numpy installed (perhaps other dependencies exists but are already installed).

Is there a list of these dependencies somewhere?
Thank you.

Asynchronous command

Implement the asynchronous communication, it allows to send commands without delays.

The default configuration will be synchronous, but will be possible to change it in runtime.

Implement the list API

Allow to iterate on the Ethernet controller:

import pyIcePAP
ipap = pyIcePAP.EthIcePAPController('icepap12')
for m in ipap:
     print m.power

Function srch() fails

I get the following output using Python 2.7:
/home/jarink/github/pyIcePAP/pyIcePAP/axis.py:1648: PendingDeprecationWarning: object.format with a non-empty format string is deprecated
Traceback (most recent call last):
File "/home/jarink/github/fork_inki2/IcepapCMS/icepapCMS/ui_icepapcms/dialoghomesrch.py", line 63, in _btn_go_stop_clicked
self._start_motor()
File "/home/jarink/github/fork_inki2/IcepapCMS/icepapCMS/ui_icepapcms/dialoghomesrch.py", line 76, in _start_motor
self.axis.srch(opt, edge, direction)
File "/home/jarink/github/pyIcePAP/pyIcePAP/axis.py", line 1648, in srch
cmd = 'SRCH {0} {1} {2:+}'.format(signal, edge_type, direction)
ValueError: Sign not allowed in string format specifier

@rhomspuron Please take a look at the first and the last line in the above output.

icepapctl <subcommand> --help does not work

Expected behaviour:

$ icepapctl status --help
Usage: icepapctl status [OPTIONS]

  Prints a summary of each axis status (position velotiy, acc. time, etc) in
  form of table

Options:
  --axes AXES                     comma separated list of axes. Also supports
                                  'all' and 'alive'  [default: all]

  --table-style [default|none|dotted|mysql|parated|compact|markdown|rst|box|box_doubled|box_rounded|grid]
                                  table style  [default: box_rounded]
  --help                          Show this message and exit.

What I get:

$ icepapctl status --help
Usage: icepapctl [OPTIONS] COMMAND [ARGS]...
Try 'icepapctl --help' for help.

Error: Missing option '-u' / '--url'.

Problems with icepap communication

Hi,
I found several issues with the icepap communication.
I will put them all here.

handle asynchronous exception (ex: Keyboard Interrupt)

during a call for the icepap it is not possible to do ctrl+c and have a recover.
example:

m3 = ice[3]
try:
    m3.move(target)
    while m3.ge_tstate().is_moving():
        time.sleep(0.1)
except KeyboardInterrupt:
    m3.stop()

If the ctrl+c happens during the call to get_state() the icepap tries to start reconnection thread but when the m3.stop() line is executed, the connection is not ready so the call to stop() fails.

masked errors

Some OSError and even a BaseException is being masked to RuntimeError.
This makes it harder to handle errors since I cannot easily understand on my application what real error happened.
IMHO the library should just handle the error and re-raise or simply don't do anything

separate application protocol and connection

Not an error, just a suggestion:
The low level SocketCon class is handling both TCP connection and half of the icepap protocol. The other half seems to be managed by the IcePAPCommunication.
It would be create if the concerns are separated. This way you could eventually use another connection class (like serial line for example... not that anyone wants that :-)

ctl status issue when board not installed

WSD2023. cms 3.7.0, osc 0.10.3, ctl 3.9.0 and library 3.9.0

mv Move specified axes in pairs <axis, position> to the...
mvr Move specified axes in pairs <axis, position> relative to...
rackinfo Prints a summary of each rack information in form of table
reboot Reboots the icepap
reset Resets the given rack.
send Send raw command to the icepap
sendall Send raw command to selected axes with option --axes
state Prints a summary of each axis state in form of table
status Prints a summary of each axis status (position velotiy, acc.
version Prints a summary of icepap version
wa Prints a summary of each axis detailed position in form of table

state
Axis Name Pos. Ready Vel. Acc. T.


1                      0.0      NO                    
2           rls   -35996.0      NO   1000.0       1.0 
3         resol        0.0      NO    200.0       1.0 
4      maralc00    52001.0      NO    400.0       0.3 
5      maralc01        0.0      NO    400.0       0.3 
6      maralc02    52001.0      NO    400.0       0.3 
7   axelsmotor2        0.0      NO    400.0       0.3 
8    axelsmotor     2390.0      NO    400.0       0.3 

status
Unexpected error: RuntimeError('Error sending command, IcePAP answered 1:?MODE ERROR Board is not alive\n')
status
Unexpected error: RuntimeError('Error sending command, IcePAP answered 1:?MODE ERROR Board is not alive\n')
:reset
Done
status
Unexpected error: RuntimeError('Error sending command, IcePAP answered 1:?MODE ERROR Board is not alive\n')

How/Where to publish pyIcePAP library documentation?

We need to decide which is the most convenient option to publish the documentation for the new pyIcePAP library.

We would like to use gh-pages, but different approaches are available. Taurus-org has already integrated the automatic generation of the taurus's documentation following a custom approach in which a secondary repository (taurus-doc) is used for pushing the html files (gh-pages branch).

The inconvenient here for pyIcePAP project is that the access to the html documentation will always be through this secondary repository (i.e. https://ALBA-Synchrotron.github.io/pyIcePAP-doc) instead of using the original repository code name (i.e. https://ALBA-Synchrotron.github.io/pyIcePAP) or using a secondary domain name as taurus does (taurus-scada.org).

We still have the options proposed by default by gh-pages: docs folder or gh-pages branch in the same repository.

Which do you think is the most convenient approach?

Probles on firmware updating

We found some problems on the update from 1.22 to 3.15 version to do the autofix. The firmware update change the register parameters but the autofix script can not fix them:

2020-07-27 11:04:49,705 - icepap.backups.IcePAPBackup - WARNING - Skip axis 3 pos_inpos: bkp(0L) icepap(0)
2020-07-27 11:04:49,706 - icepap.backups.IcePAPBackup - ERROR - Cannot fix axis 3 enc_motor: bkp(118050L) icepap(0). Error unexpected EOF while parsing (<string>, line 1))
2020-07-27 11:04:49,707 - icepap.backups.IcePAPBackup - WARNING - Skip axis 3 pos_absenc: bkp(-8192L) icepap(0)
2020-07-27 11:04:49,708 - icepap.backups.IcePAPBackup - WARNING - Skip axis 3 pos_tgtenc: bkp(-74521L) icepap(0)
2020-07-27 11:04:49,709 - icepap.backups.IcePAPBackup - ERROR - Cannot fix axis 3 enc: bkp(118050L) icepap(0). Error unexpected EOF while parsing (<string>, line 1))
2020-07-27 11:04:49,710 - icepap.backups.IcePAPBackup - ERROR - Cannot fix axis 3 enc_encin: bkp(-745214L) icepap(0). Error unexpected EOF while parsing (<string>, line 1))
2020-07-27 11:04:49,710 - icepap.backups.IcePAPBackup - ERROR - Cannot fix axis 3 enc_absenc: bkp(-8192L) icepap(0). Error unexpected EOF while parsing (<string>, line 1))
2020-07-27 11:04:49,711 - icepap.backups.IcePAPBackup - ERROR - Cannot fix axis 3 enc_inpos: bkp(0L) icepap(0). Error unexpected EOF while parsing (<string>, line 1))
2020-07-27 11:04:49,712 - icepap.backups.IcePAPBackup - WARNING - Skip axis 3 pos: bkp(118050L) icepap(0)
2020-07-27 11:04:49,713 - icepap.backups.IcePAPBackup - WARNING - Skip axis 4 pos_encin: bkp(0L) icepap(0)

Config conflict gives NoneType exception

Use case:
We have a configuration conflict situation (DB - driver board) for some driver in a system.

Symptom:
When starting up IcePAPcms and selecting the system in the selection tree, IcePAPcms will call function getDriverConfiguration() for all drivers. This function calls pyIcePAP property IcePAPAxis.config() which throws an exception "'NoneType' object has no attribute 'getitem'".

@rhomspuron This is a problem to me since I deliberately have a conflict situation for some drivers in my test system in Lund. In every branch I need to comment out some code to be able to run IcePAPcms. I sent you an e-mail 2018-10-24, 15:20 with title "pyIcePAP axis config exeption".

EthIcePAPController interface

The current EthIcePAPController object acts in an intelligent way which introspect the hardware to find version and present racks and axes.

  • asking for the version is problematic is the hardware is under heavy stress (ex: another connection that asked to move a motor and is querying the motor state frequently to know when it stops)
  • the amount of discovery slows down the object creation and consequently the applications that use them

The current behaviour is still very useful for creating a very verbose object which takes care of many things underneath. But it would be nice to have an alternative mode that solves the above problems.

We propose that EthIcePAPController API work in two modes:

  • intelligent (default in 2.8.x): in the constructor we introspect the hardware to see what
    axes are present and we initialize the internal state with these axes. This is the current behaviour in 2.8.x.
  • advanced (would be default in 3.x): the constructor is lazy and it is up to the user of the object to request specific axes and manage their destruction

Here is an excerpt of how the advanced mode could look like:

ice = EthIcePAPController('icepap12', auto_axes=False)
5 in ice                # False
ice.keys()              # = []
# return True
a5 = ice[5]             # a5 instance IcePAPAxis
ice.keys()              # = [5]
ice.values()            # = [IcePAPAxis(5)]
p = ice[5].pos          # p is int
p = ice[55].pos        # raise IcePAPError('unknown axis') if axis does not exist
p = ice['th'].pos        # raise IcePAPError('unknown axis') if axis does not exist
p = ice[12700].pos      # raise IcePAPError('unknown axis')
ice.add_alias('th', 5)
th = ice['th']          # th instance IcePAPAxis
th is a5                # return True
th in ice               # raise False
5 in ice                # return True
ice.get_pos(5)          # int with steps
ice.get_pos('th')       # int with steps

ice.find_axes() # list all existing axis numbers
ice.find_axes(filter=lambda axis: axis.alive) # list all alive axis numbers
ice.update_axes() # fills dict with existing axis by asking hardware which are the existing axes
ice[5] is th          # this invariant should remain true

del ice[5]        # == ice.pop(5) removes axis 5 from known axes

Inconsistent return types from `get_pos` and `get_fpos`

Description

The ?POS and ?FPOS system queries return the value of the requested position registers from the IcePAP. These registers contain integer values only;

  • AXIS
  • MEASURE
  • SHFTENC (?POS only)
  • TGTENC (?POS only)
  • CTRLENC (?POS only)
  • ENCIN (?POS only)
  • INPOS (?POS only)
  • ABSENC (?POS only)
  • MOTOR (?POS only)
  • SYNC (?POS only)

The return values from the two corresponding IcePAPController methods however differ in type;

This inconsistency is confusing. One return type should be chosen for both methods.

Suggested action

Update get_fpos to return int

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.