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  <20132014  2015  2016  2017  2018  2019  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019 
<== Date ==> <== Thread ==>

Subject: Re: pilatus detecotr modify FileName problem
From: Bruce Hill <bhill@slac.stanford.edu>
To: "tech-talk@aps.anl.gov >> \"tech-talk@aps.anl.gov\"" <tech-talk@aps.anl.gov>
Date: Thu, 12 Dec 2013 00:06:08 -0800
Hi Hongchunxia,
If Nick is right about Filename_RBV being a waveform record, you
may need something like the python function below.     With our python
channel access implementation, we needed to convert the python string
into a tuple of bytes whose length is the same as the Filename_RBV.NELM,
the number of elements in the waveform.

def stringToTuple( strValue, length ):
    if not isinstance( strValue, str ):
        raise TypeError, "stringToTuple value is not a string"
    # Convert the string to a bytearray
    newByteArray = bytearray( strValue.ljust(length,chr(0)), 'ascii', 'ignore' )
    return tuple(newByteArray)

You may also need the inverse to convert the waveform tuple to a string.

def tupleToString( tupleValue ):
    if isinstance( tupleValue, str ):
        return tupleValue
    # Remove any invalid characters
    for item in tupleValue:
        if item > 255:
            tupleValue.remove(item)

    # Isolate the null terminated string, if any
    if tupleValue.count(0) == 0:
        end = len(tupleValue)
    else:
        end = tupleValue.index(0)

    # Convert remaining bytes to a string
    stringRet = ''.join( map( chr, tupleValue[0:end] ) )
    return stringRet

Hope this helps,
- Bruce

--
Bruce Hill
Member Technical Staff
SLAC National Accelerator Lab
2575 Sand Hill Road M/S 10
Menlo Park, CA  94025

On 12/11/2013 12:59 AM, nick.rees@diamond.ac.uk wrote:

Hi hongchunxia,

 

I suspect it is getting confused between byte arrays of waveform records and strings. I suspect the X16B:EH:13PIL1:cam1:FileName PV is a waveform record, and the EPICS Python library you are using doesn’t realise you are actually putting a string to it and so isn’t terminating the data with a null character. I am not familiar with the python library you are using, but you need the equivalent of the –S option to the command line version of caput.

 

Cheers,

 

Nick Rees

Principal Software Engineer           Phone: +44 (0)1235-778430

Diamond Light Source                  Fax:   +44 (0)1235-446713

 

From: tech-talk-bounces@aps.anl.gov [mailto:tech-talk-bounces@aps.anl.gov] On Behalf Of ???
Sent: 11 December 2013 03:33
To: tech-talk@aps.anl.gov
Subject: pilatus detecotr modify FileName problem

 

Hello everyone,

 

Now we use CSS(Control System Studio) to control a Pilatus Detector. The platform is base-3.14.12.3, synApps_5_6 and CSS_3.1.6, the driver of Pilatus Detector is from synApps_5_6.

When I use the softioc and the CSS opi to control the Detector, it works well and no problem, but now I have a python script to modify the detector’s Filename and Filename readback for exposing some different samples. That is, when I execute the python script it can modify the record X16B:EH:13PIL1:cam1:Filename and X16B:EH:13PIL1:cam1:Filename_RBV automaticly, the python is as followssample.py:

 

#!/usr/bin/env python

from epics import caget,caput

caput(' X16B:EH:13PIL1:cam1:FileName',sample_name)

caput(' X16B:EH:13PIL1:cam1:FileName_RBV',sample_name)

……

 

The sample_name is from the css opi for different sample’s name, for example,in a experiment you can do six samples, that is, the sample.py will be run for six times.

The problem is, if the first sample name is sample1, the python can modify the two record, and the detector file name will be sample1_0001.tif, it works well. But when I set the second sample’s name is s2, the detector file name will be s2mple1_0002.tif, which is not I wanted. That is , the first two letter is replaced by s2, but the sample’s name is not replaced all. I don’t know why.

When I open a terminal in linux, and input python, and then run statement of the sample.py line by line, the problems is the same. That is to say, if the next sample’s name is shorter than former, the question is exist, on the contrary, it’s ok.

 

I don't know how to solve the problem. Thank you.

 

---------------------------------------------

hongchunxia

Shanghai Synchrotron Radiation Facility

Shanghai Institute of Applied Physics

Chinese Academy of Sciences


 

-- 

This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
 




Replies:
Re: pilatus detecotr modify FileName problem Matt Newville
References:
pilatus detecotr modify FileName problem 洪春霞
RE: pilatus detecotr modify FileName problem nick.rees

Navigate by Date:
Prev: RE: Mclennan PM600 motor controller Mark Rivers
Next: RE: Mclennan PM600 motor controller nick.rees
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019 
Navigate by Thread:
Prev: RE: pilatus detecotr modify FileName problem nick.rees
Next: Re: pilatus detecotr modify FileName problem Matt Newville
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·