Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <2017 Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <2017
<== Date ==> <== Thread ==>

Subject: RE: Is there any support for EPICS for IronPython (or anyone working on it)?
From: <freddie.akeroyd@stfc.ac.uk>
To: <newville@cars.uchicago.edu>, <hartmansm@ornl.gov>
Cc: skorpenskehd@ornl.gov, tech-talk@aps.anl.gov
Date: Sat, 13 May 2017 18:40:50 +0000

Hi,

 

I’ve had a brief look at this – there doesn’t seem to be an  in_dll()  method on Arrays in IronPython, but I was able to work around it using:

 

    c_short_p = ctypes.POINTER(ctypes.c_short)

    value_offset0 = ctypes.c_short.in_dll(libca,'dbr_value_offset')

    dbr.value_offset = ctypes.cast(ctypes.addressof(value_offset0), (39*ctypes.c_short))

 

IronPython also looks to be a little more fussy about having types specified in function calls – so in the PyEpics call to   libca.ca_create_channel    I had to change    pvn    to    ctypes.c_char_p(pvn)     as otherwise only the first character of the PV name seemed to get passed into ca.dll   I suspect there may be a few other places where similar changes might be needed too as it’s not quite working yet. I’ve some time later next week when I could take a more detailed look with a debugger if that’s not too late for you.

 

Regards,


Freddie

  

 

From: tech-talk-bounces@aps.anl.gov [mailto:tech-talk-bounces@aps.anl.gov] On Behalf Of Matt Newville
Sent: 12 May 2017 21:25
To: Hartman, Steven M.
Cc: Skorpenske, Harley David; EPICS Tech Talk
Subject: Re: Is there any support for EPICS for IronPython (or anyone working on it)?

 

Hi Steven,

 

On Fri, May 12, 2017 at 1:44 PM, Hartman, Steven M. <hartmansm@ornl.gov> wrote:

In follow up to http://www.aps.anl.gov/epics/tech-talk/2016/msg01425.php from last August . . .

The MTS customer referenced was one of the beam lines here at SNS. They are interested in using the IronPython interface included with the new MTS load-frame software to pass parameters to our EPICS beam line control system using PyEpics.

Harley (cc’d here but not on tech-talk) gave it a try . . .

>>> from epics import caget
>>> beampower = caget('RTBT_Diag:BCM25I:Power60')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\Lib\site-packages\epics\__init__.py", line 81, in caget
  File "C:\Python27\Lib\site-packages\epics\pv.py", line 39, in get_pv
  File "C:\Python27\Lib\site-packages\epics\ca.py", line 359, in wrapper
  File "C:\Python27\Lib\site-packages\epics\ca.py", line 239, in initialize_libca
AttributeError: 'ArrayType' object has no attribute 'in_dll'

>>> beampower = caget('RTBT_Diag:BCM25I:Power60')
cannot connect to RTBT_Diag:BCM25I:Power60
>>>


The first call to pyepics from IronPython always gives the AttributeError; all subsequent calls give “cannot connect”.

Regular C Python 2.7 was used to install PyEpics using the installer exe. On the same host, it can successfully connect and read the same PV so not likely to be a network or access permission issue.

Tested with . . .
IronPython 2.7.7 (2.7.7.0) on .NET 4.0.30319.42000
32-bit and 64-bit


Any suggestions?

Thanks,
--
Steven Hartman
hartmansm@ornl.gov




 

I think the answer to the question in the subject line is: no one is working on this. But that's not a deliberate lack of support, and it doesn't mean it can't be done.   I think it's just that no one has needed to do this, yet.

 

PyEpics needs to load the CA library (ca.dll)  for all CA communication.  It does this using the ctypes library, which is (mostly) cross-platform.   My understanding is that it is available for IronPython, and the message implies it is partially working.

The error message from the function `initialize_libca` in ca.py means that this initial connection to ca.dll is where the problem is.  It looks like the DLL is found and loaded, and that at least some interaction with the DLL works, but that it fails doing:
 

     dbr.value_offset = (39*ctypes.c_short).in_dll(libca, 'dbr_value_offset')

which is a ctypes Array trying to look inside the DLL (held in `libca`) for a particular value that's needed to unpack some of the CA data structures. The message looks like it's saying that ctypes Arrays don't have an `in_dll` method.   I don't know why *that* is. 

From the perspective of  "could pyepics ever work in IronPython", I'd say this is a pretty encouraging report -- it definitely didn't fail loading ca.dll!   If the error with `in_dll` is the only problem, the solution is probably pretty easy. But, there might be other challenges with ctypes too, and it might take some work to get it to work fully.
 

--Matt Newville


Replies:
Re: Is there any support for EPICS for IronPython (or anyone working on it)? Matt Newville
References:
Re: Is there any support for EPICS for IronPython (or anyone working on it)? Hartman, Steven M.
Re: Is there any support for EPICS for IronPython (or anyone working on it)? Matt Newville

Navigate by Date:
Prev: Re: Is there any support for EPICS for IronPython (or anyone working on it)? Matt Newville
Next: Re: Is there any support for EPICS for IronPython (or anyone working on it)? Matt Newville
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <2017
Navigate by Thread:
Prev: Re: Is there any support for EPICS for IronPython (or anyone working on it)? Matt Newville
Next: Re: Is there any support for EPICS for IronPython (or anyone working on it)? Matt Newville
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <2017
ANJ, 14 May 2017 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·