Skip to content
Snippets Groups Projects
Commit 46896090 authored by benjamin.franksen's avatar benjamin.franksen
Browse files

docs: improved documentation of pvAssign

parent 4e0ce795
No related branches found
No related tags found
No related merge requests found
...@@ -1327,39 +1327,53 @@ pvAssign ...@@ -1327,39 +1327,53 @@ pvAssign
.. c:function:: .. c:function::
pvStat pvAssign(assigned_var, process_variable_name) pvStat pvAssign(assigned_var, process_variable_name)
Assigns or re-assigns the SNL variable ``var`` to Assigns or re-assigns the SNL variable ``var`` to ``process_variable_name``.
``process_variable_name``. If ``process_variable_name`` is an empty If ``process_variable_name`` is an empty string then ``assigned_var`` is
string then ``assigned_var`` is de-assigned (not associated with any process de-assigned (not associated with any process variable). In :ref:`safe mode`,
variable). In :ref:`safe mode`, it causes assignment to an anonymous PV. it causes assignment to an anonymous PV.
As usual, ``assigned_var`` can also be an array element. As usual, ``assigned_var`` can also be an array element.
Note that pvAsssign is *asynchronous*: it sends a request to search for and
connect to the given ``process_variable_name``, but it does not wait for a
response, similar to ``pvGet(var,ASYNC)``. Calling pvAssign *does* have one
immediate effect, namely de-assigning the variable from any PV it currently
is assigned to. In order to make sure that it has connected to the new PV,
you can use the :c:func:`pvConnected` built-in function inside a :token:`when`
clause.
.. todo::
Add an optional argument, so users can make pvAssign wait for the
connection to be established (or some timeout).
See also :token:`assign` clause. See also :token:`assign` clause.
A better name for this function would be ``pvReassign``. A better name for this function would be ``pvReassign``.
.. note:: .. note::
:c:func:`pvAssign` can only be called on variables (or array elements) ``pvAssign`` can only be called on variables (or array elements)
that have been statically marked as process variables using the that have been statically marked as process variables using the
:token:`assign` syntax. An empty string may be used for the initial :token:`assign` syntax. An empty string may be used for the initial
assignment, or (from version 2.1. onward) the simplified form assignment, or (from version 2.1. onward) the simplified form
``assign var``. ``assign var``.
.. note:: If a variable gets de-assigned from a non-empty to an empty .. warning::
If a variable gets de-assigned from a non-empty to an empty
name, the corresponding channel is destroyed, which means that name, the corresponding channel is destroyed, which means that
dynamically allocated memory gets freed. If your dynamically allocated memory gets freed. If your
system cannot handle dynamic memory allocation without fragmentation, system cannot handle dynamic memory allocation without fragmentation,
care should be taken that assignment and de-assignment do not care should be taken that assignment and de-assignment do not
alternate too often. alternate too often.
..note:: If you want to assign array elements to separate PVs, you cannot .. note::
If you want to assign array elements to separate PVs, you cannot
currently do this with a single call (in contrast to doing it in an currently do this with a single call (in contrast to doing it in an
:token:`assign` clause. Instead, you must call :c:func:`pvAssign` :token:`assign` clause. Instead, you must call ``pvAssign``
for each array element individually. for each array element individually.
This might change in a future release.
..todo:: Implement multiple assign for arrays.
pvMonitor pvMonitor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment