EPICS Controls 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  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Write to waveform record using PVUtil.writePV
From: "Kasemir, Kay" <[email protected]>
To: Abdalla Ahmad <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Mon, 11 Jul 2016 14:09:23 +0000
Hi:

Sorry, before answering you specific value type issue: Using PVUtil.writePV(name, value) is a bad idea because this will
1) Create the PV
2) write the value
3) close the PV
.. and all that’s done on the user interface thread.

If you do need to write to a PV from a script, just make the target PV one of the script “inputs”.
Maybe de-select the “trigger” option because changes of the PV should not trigger execution of the script.
So somewhat like this:

Input PV 0:  some_PV_that_triggers_the_script_execution  [x] trigger
Input PV 1:  some_PV_that_you_want_to_write                   [  ] don’t trigger


Inside the script you can then write to the PV via

pvs[1].setValue(the_value_you_want_to_write)




Now to the data types that you can write:

If you use the vtype.pv connection layer, you should be able to write byte[], short[], int[], long[], float[], double[] arrays.

If you use the pvmanager connection layer because you also need to use formulas,
then your supported types indeed appear limited to byte[], short[], int[], float[], double[], no long.

In neither case do you get “unsigned int”, because Java does not use any unsigned data types.
With the vtype.pv layer, you could write a long[] array, because a long holds the complete value range of an unsigned int.

But I assume you really want to preserve the 4 byte alignment of the values, so then with either connection layer you can write an int[] array, but you may have to adjust your data.
To write an “unsigned” 0 ..  0x7FFFFFFF, you can just keep that value.
But “unsigned” data from 0x80000000 to 0xFFFFFFFF must be mapped
to the corresponding negative value.
For example, 0xFFFFFFFF is written as Integer.valueOf(-1).
In Java, that looks like a negative value.
It’s written as 0xFFFFFFFF, and in the IOC, if your driver accesses it as
an unsigned number, you get 0xFFFFFFFF.

Thanks,
Kay



On Jul 11, 2016, at 7:10 AM, Abdalla Ahmad <[email protected]> wrote:

Hello all,
 
Recently we created a waveform record that holds a firmware for a device. We read the firmware from a binary file and put every 4 bytes as unsigned integer into an array of integers. We found out that in order for arrays to be passed to the writePV API using a Python script, it must be a float array (either array or jarray). Can be done something like this:
 
Data = "" [], 'f' )
 
Now since we need to send unsigned integers, something like this won't work:
 
Data = "" [], 'l' )
 
Or anything other than 'f' or 'd' will give error:
 
java.lang.RuntimeException: Unsupported type for CA: class [J
 
Why does the writePV API does not accept any array other than float or double array array? The bytes to be sent are unpacked from the bin file with a specific bit pattern that should not be changed or the device is rendered unusable and needs restart.
 
Best Regards,
 
Abdalla Ahmad
Control Engineer
SESAME
Allan, Jordan.
Tel: (+962-5) 3511348 , ext. 265
Fax: (+962-5) 3511423
Mob: (+962-7)88183296


References:
Write to waveform record using PVUtil.writePV Abdalla Ahmad

Navigate by Date:
Prev: Write to waveform record using PVUtil.writePV Abdalla Ahmad
Next: AndorCCD binning Hinxx
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Write to waveform record using PVUtil.writePV Abdalla Ahmad
Next: AndorCCD binning Hinxx
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 15 Jul 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·