1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 <2015> 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 | 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 2018 2019 2020 2021 2022 2023 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | RE: how to write array data to waveform record in cothread? |
From: | <[email protected]> |
To: | <[email protected]>, <[email protected]> |
Date: | Thu, 9 Jul 2015 06:24:58 +0000 |
Hy Geyang, I think I may have made the description here too confusing. Certainly caput can write arrays, but the description here is confusing because it can also write
arrays of arrays – there is some overloading, depending on whether pvs is a string or a list of strings. Let me try and be clearer. caput has two variants: 1.
caput(pv, value, …) Here pv must be a string (naming the PV to be written) and value can be pretty well anything that can be written over epics and that numpy understands. In
particular you can write the following to write 5 elements to an array: caput(pv, [1,2,3,4,5]) This is the basic form of caput. In this variant repeat_value argument has no meaning and will raise an error. 2.1
caput(pvs, values, repeat_value=False, …) This is almost certainly the case which was confusing you. Here pvs is a list of PV names, in which case values must be an array of the same length as pvs.
Now, it can be an array of arrays (or a numpy 2-d array) if you want to write to a list of array PVs, for example: caput([pv1, pv2], [1, 2]) # Writes 1 to pv1, 2 to pv2 caput([pv1, pv2], [[1, 2], [3, 4]]) # Writes [1,2] to pv1, [3,4] to pv2 2.2
caput(pvs, value, repeat_value=True, …) This is the most obsure variant. Again pvs is a list of PV names, and now value is a single value (or a possibly an array) which is written to all pvs. For
example: caput([pv1, pv2], ‘a string’, repeat_value=True) # Writes ‘a string’ to pv1 and pv2 You might well ask why I have implemented variants 2.1 and 2.2 above when all they do is call caput on each pv. The reason is, it’s much more efficient to
write multiple pvs in parallel. You might also ask why I didn’t give the two variants different names. Um. I was trying to make the API simple. Huh. In fact there are two functions, caput_one and caput_array inside catools.py, and caput figures out which one to call. Let me know if this works for you or if you have any further problems. From: [email protected] [mailto:[email protected]]
On Behalf Of Silver hi, all: I want to use cothread to write array data to a waveform record, but can't find how to do this. In the manual of cothread as following: cothread.catools.caput(pvs, values, repeat_value=False, datatype=None, wait=False, timeout=5, callback=None, throw=True)[source] Writes values to one or more PVs. If pvs is a single string then values is
treated as a single value to be written to the named process variable, otherwise pvs must be iterable, and unless repeat_value=True is
set, values must also be an iterable of the same length in which case values[i]is written to pvs[i].
Otherwise, if a single value is given or if repeat_value=True is specified, values is
written to all PVs. seems can only get array data, can't write array data? thanks a lot in advance. Best wishes Geyang 2015-07-09
-- 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. |