genie-python 15.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. genie_python/.pylintrc +539 -0
  2. genie_python/__init__.py +1 -0
  3. genie_python/_version.py +16 -0
  4. genie_python/block_names.py +123 -0
  5. genie_python/channel_access_exceptions.py +45 -0
  6. genie_python/genie.py +2462 -0
  7. genie_python/genie_advanced.py +418 -0
  8. genie_python/genie_alerts.py +195 -0
  9. genie_python/genie_api_setup.py +451 -0
  10. genie_python/genie_blockserver.py +64 -0
  11. genie_python/genie_cachannel_wrapper.py +551 -0
  12. genie_python/genie_change_cache.py +151 -0
  13. genie_python/genie_dae.py +2219 -0
  14. genie_python/genie_epics_api.py +906 -0
  15. genie_python/genie_experimental_data.py +186 -0
  16. genie_python/genie_logging.py +200 -0
  17. genie_python/genie_p4p_wrapper.py +203 -0
  18. genie_python/genie_plot.py +77 -0
  19. genie_python/genie_pre_post_cmd_manager.py +21 -0
  20. genie_python/genie_pv_connection_protocol.py +36 -0
  21. genie_python/genie_script_checker.py +507 -0
  22. genie_python/genie_script_generator.py +212 -0
  23. genie_python/genie_simulate.py +69 -0
  24. genie_python/genie_simulate_impl.py +1265 -0
  25. genie_python/genie_startup.py +29 -0
  26. genie_python/genie_toggle_settings.py +58 -0
  27. genie_python/genie_wait_for_move.py +154 -0
  28. genie_python/genie_waitfor.py +576 -0
  29. genie_python/matplotlib_backend/__init__.py +0 -0
  30. genie_python/matplotlib_backend/ibex_websocket_backend.py +366 -0
  31. genie_python/mysql_abstraction_layer.py +272 -0
  32. genie_python/scanning_instrument_pylint_plugin.py +31 -0
  33. genie_python/testing_utils/__init__.py +4 -0
  34. genie_python/testing_utils/script_checker.py +63 -0
  35. genie_python/typings/CaChannel/CaChannel.pyi +893 -0
  36. genie_python/typings/CaChannel/__init__.pyi +9 -0
  37. genie_python/typings/CaChannel/_version.pyi +6 -0
  38. genie_python/typings/CaChannel/ca.pyi +31 -0
  39. genie_python/utilities.py +406 -0
  40. genie_python/version.py +6 -0
  41. genie_python-15.1.0.dist-info/LICENSE +28 -0
  42. genie_python-15.1.0.dist-info/METADATA +84 -0
  43. genie_python-15.1.0.dist-info/RECORD +45 -0
  44. genie_python-15.1.0.dist-info/WHEEL +5 -0
  45. genie_python-15.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,893 @@
1
+ """
2
+ This type stub file was generated by pyright.
3
+ """
4
+
5
+ from typing import Any, Callable, Tuple, TypeAlias, TypeVar
6
+
7
+ from numpy import NDArray
8
+
9
+ __all__ = ["CaChannelException", "CaChannel"]
10
+ T = TypeVar("T")
11
+
12
+ class CaChannelException(Exception):
13
+ def __init__(self, status) -> None: ...
14
+ def __int__(self) -> int: ...
15
+ def __str__(self) -> str: ...
16
+
17
+ PVBaseValue: TypeAlias = bool | int | float | str
18
+ PVValue: TypeAlias = PVBaseValue | list[PVBaseValue] | NDArray | None
19
+
20
+ class CaChannel:
21
+ """CaChannel: A Python class with identical API as of caPython/CaChannel.
22
+
23
+ This class implements the methods to operate on channel access so that you can find
24
+ their C library counterparts ,
25
+ http://www.aps.anl.gov/epics/base/R3-14/12-docs/CAref.html#Function.
26
+ Therefore an understanding of C API helps much.
27
+
28
+ To get started easily, convenient methods are created for often used operations,
29
+
30
+ ========== ======
31
+ Operation Method
32
+ ========== ======
33
+ connect :meth:`searchw`
34
+ read :meth:`getw`
35
+ write :meth:`putw`
36
+ ========== ======
37
+
38
+ They have shorter names and default arguments. It is recommended to start with these methods.
39
+ Study the other C alike methods when necessary.
40
+
41
+ >>> chan = CaChannel('catest')
42
+ >>> chan.searchw()
43
+ >>> chan.putw(12.5)
44
+ >>> chan.getw()
45
+ 12.5
46
+ >>> chan.searchw('cabo')
47
+ >>> chan.putw('Done')
48
+ >>> chan.getw(ca.DBR_STRING)
49
+ 'Done'
50
+ """
51
+
52
+ __context = ...
53
+ __callbacks = ...
54
+ __context_lock = ...
55
+ __context_dict = ...
56
+ ca_timeout = ...
57
+ last_value: PVValue = ...
58
+ @staticmethod
59
+ def get_thread_id(thread) -> str: # -> str:
60
+ ...
61
+ @staticmethod
62
+ def create_context(): ...
63
+ def attach_ca_context(func): # -> _Wrapped[Callable[..., Any], Any, Callable[..., Any], Any]:
64
+ ...
65
+ def __init__(self, pvName=...) -> None: ...
66
+ def __del__(self) -> None: ...
67
+ @staticmethod
68
+ def version(): ...
69
+ def setTimeout(self, timeout: float) -> None:
70
+ """Set the timeout for this channel object. It overrides the class timeout.
71
+
72
+ :param float timeout: timeout in seconds
73
+
74
+ >>> chan = CaChannel()
75
+ >>> chan.setTimeout(10.)
76
+ >>> chan.getTimeout()
77
+ 10.0
78
+ """
79
+ ...
80
+
81
+ def getTimeout(self) -> float:
82
+ """Retrieve the timeout set for this channel object.
83
+
84
+ :return: timeout in seconds for this channel instance
85
+ :rtype: float
86
+
87
+ >>> chan = CaChannel()
88
+ >>> chan.getTimeout() == CaChannel.ca_timeout
89
+ True
90
+ """
91
+ ...
92
+
93
+ @classmethod
94
+ @attach_ca_context
95
+ def replace_printf_handler(
96
+ cls,
97
+ callback: Callable[[str, Tuple[T, ...]], None] = ...,
98
+ user_args: Tuple[T, ...] | None = ...,
99
+ ) -> None:
100
+ """
101
+ Install or replace the callback used for formatted CA diagnostic message output.
102
+ The default is to send to stderr.
103
+
104
+ :param callable callback: function called.
105
+ :param user_args: user provided arguments that are passed to callback when it is invoked.
106
+
107
+ >>> chan = CaChannel('catest')
108
+ >>> chan.searchw()
109
+ >>> def printfCB(message, _):
110
+ ... print('CA message:', message)
111
+ >>> chan.replace_printf_handler(printfCB) # add callback # doctest: +SKIP
112
+ >>> chan.replace_printf_handler() # clear the callback # doctest: +SKIP
113
+
114
+ .. versionadded:: 3.1
115
+ """
116
+ ...
117
+
118
+ @classmethod
119
+ @attach_ca_context
120
+ def add_exception_event(cls, callback=..., user_args=...): # -> None:
121
+ """
122
+ Install or replace the currently installed CA context global exception handler callback.
123
+
124
+ When an error occurs in the server asynchronous to the clients thread then information
125
+ about this type of error is passed from the server to the client in an exception message.
126
+ When the client receives this exception message an exception handler callback is called.
127
+ The default exception handler prints a diagnostic message on the client's standard out and
128
+ terminates execution if the error condition is severe.
129
+
130
+ Note that certain fields returned in the callback args are not applicable in the context of
131
+ some error messages. For instance, a failed get will supply the address in the client task
132
+ where the returned value was requested to be written. For other failed operations the value
133
+ of the addr field should not be used.
134
+
135
+ :param callable callback: function called.
136
+ :param user_args: user provided arguments that are passed to callback when it is invoked.
137
+
138
+ The possible fields available are as defined in the C "struct exception_handler_args"
139
+ and are: chid, type, count, state, op, ctx, file, lineNo
140
+
141
+ >>> chan = CaChannel('catest')
142
+ >>> chan.searchw()
143
+ >>> def exceptionCB(epicsArgs, _):
144
+ ... print('op:', epicsArgs['op'], 'file:', epicsArgs['file'], 'line:', epicsArgs['lineNo'])
145
+ >>> chan.add_exception_event(exceptionCB) # add callback # doctest: +SKIP
146
+ >>> chan.add_exception_event() # clear the callback # doctest: +SKIP
147
+
148
+ .. versionadded:: 3.1
149
+ """
150
+ ...
151
+
152
+ def replace_access_rights_event(self, callback=..., user_args=...): # -> None:
153
+ """
154
+ Install or replace the access rights state change callback handler for the specified channel.
155
+
156
+ The callback handler is called in the following situations.
157
+
158
+ - whenever CA connects the channel immediately before the channel's connection handler is called
159
+ - whenever CA disconnects the channel immediately after the channel's disconnect callback is called
160
+ - once immediately after installation if the channel is connected
161
+ - whenever the access rights state of a connected channel changes
162
+
163
+ When a channel is created no access rights handler is installed.
164
+
165
+ :param callable callback: function called when access rights change. If None is given,
166
+ remove the access rights event callback.
167
+ :param user_args: user provided arguments that are passed to callback when it is invoked.
168
+
169
+ >>> chan = CaChannel('catest')
170
+ >>> chan.searchw()
171
+ >>> def accessCB(epicsArgs, _):
172
+ ... print('read:', epicsArgs['read_access'], 'write:', epicsArgs['write_access'])
173
+ >>> chan.replace_access_rights_event(accessCB)
174
+ read: True write: True
175
+ >>> chan.replace_access_rights_event() # clear the callback
176
+
177
+ .. versionadded:: 3.0
178
+ """
179
+ ...
180
+
181
+ @attach_ca_context
182
+ def search_and_connect(self, pvName, callback, *user_args): # -> None:
183
+ """Attempt to establish a connection to a process variable.
184
+
185
+ :param pvName: process variable name
186
+ :param callback: function called when connection completes and connection status changes later on.
187
+ :param user_args: user provided arguments that are passed to callback when it is invoked.
188
+ :type pvName: bytes, str
189
+ :type callback: callable
190
+ :raises CaChannelException: if error happens
191
+
192
+ The user arguments are returned to the user in a tuple in the callback function.
193
+ The order of the arguments is preserved.
194
+
195
+ Each Python callback function is required to have two arguments.
196
+ The first argument is a tuple containing the results of the action.
197
+ The second argument is a tuple containing any user arguments specified by *user_args*.
198
+ If no arguments were specified then the tuple is empty.
199
+
200
+
201
+ .. note:: All remote operation requests such as the above are accumulated (buffered) and not forwarded to
202
+ the IOC until one of execution methods (:meth:`pend_io`, :meth:`poll`, :meth:`pend_event`, :meth:`flush_io`)
203
+ is called. This allows several requests to be efficiently sent over the network in one message.
204
+
205
+ >>> chan = CaChannel('catest')
206
+ >>> def connCB(epicsArgs, _):
207
+ ... chid = epicsArgs[0]
208
+ ... connection_state = epicsArgs[1]
209
+ ... if connection_state == ca.CA_OP_CONN_UP:
210
+ ... print(ca.name(chid), "is connected")
211
+ >>> chan.search_and_connect(None, connCB, chan)
212
+ >>> status = chan.pend_event(3) # doctest: +SKIP
213
+ catest is connected
214
+ >>> chan.search_and_connect('cabo', connCB, chan)
215
+ >>> status = chan.pend_event(3) # doctest: +SKIP
216
+ cabo is connected
217
+ >>> chan.clear_channel()
218
+ """
219
+ ...
220
+
221
+ @attach_ca_context
222
+ def search(self, pvName=...): # -> None:
223
+ """Attempt to establish a connection to a process variable.
224
+
225
+ :param pvName: process variable name
226
+ :type pvName: bytes, str
227
+ :raises CaChannelException: if error happens
228
+
229
+ .. note:: All remote operation requests such as the above are accumulated (buffered) and not forwarded to
230
+ the IOC until one of execution methods (:meth:`pend_io`, :meth:`poll`, :meth:`pend_event`, :meth:`flush_io`)
231
+ is called. This allows several requests to be efficiently sent over the network in one message.
232
+
233
+ >>> chan = CaChannel()
234
+ >>> chan.search('catest')
235
+ >>> status = chan.pend_io()
236
+ >>> chan.state()
237
+ <ChannelState.CONN: 2>
238
+ """
239
+ ...
240
+
241
+ def clear_channel(self): # -> None:
242
+ """Close a channel created by one of the search functions.
243
+
244
+ Clearing a channel does not cause its connection handler to be called.
245
+ Clearing a channel does remove any monitors registered for that channel.
246
+ If the channel is currently connected then resources are freed only some
247
+ time after this request is flushed out to the server.
248
+
249
+ .. note:: All remote operation requests such as the above are accumulated (buffered) and not forwarded to
250
+ the IOC until one of execution methods (:meth:`pend_io`, :meth:`poll`, :meth:`pend_event`, :meth:`flush_io`)
251
+ is called. This allows several requests to be efficiently sent over the network in one message.
252
+
253
+ """
254
+ ...
255
+
256
+ def change_connection_event(self, callback, *user_args): # -> None:
257
+ """Change the connection callback function
258
+
259
+ :param callback: function called when connection completes and connection status changes later on.
260
+ The previous connection callback will be replaced. If an invalid callback is given,
261
+ no connection callback will be used.
262
+ :param user_args: user provided arguments that are passed to callback when it is invoked.
263
+ :type callback: callable
264
+
265
+ >>> chan = CaChannel('catest')
266
+ >>> chan.search() # connect without callback
267
+ >>> def connCB(epicsArgs, _):
268
+ ... chid = epicsArgs[0]
269
+ ... connection_state = epicsArgs[1]
270
+ ... if connection_state == ca.CA_OP_CONN_UP:
271
+ ... print(ca.name(chid), "is connected")
272
+ >>> chan.change_connection_event(connCB) # install connection callback
273
+ >>> status = chan.pend_event(3) # doctest: +SKIP
274
+ catest is connected
275
+ >>> chan.change_connection_event(None) # remove connection callback
276
+
277
+ """
278
+ ...
279
+
280
+ def array_put(self, value, req_type=..., count=...): # -> None:
281
+ """Write a value or array of values to a channel
282
+
283
+ :param value: data to be written. For multiple values use a list or tuple
284
+ :param req_type: database request type (``ca.DBR_XXXX``). Defaults to be the native data type.
285
+ :param count: number of data values to write. Defaults to be the native count.
286
+ :type value: int, float, bytes, str, list, tuple, array
287
+ :type req_type: int, None
288
+ :type count: int, None
289
+
290
+ .. note:: All remote operation requests such as the above are accumulated (buffered) and not forwarded to
291
+ the IOC until one of execution methods (:meth:`pend_io`, :meth:`poll`, :meth:`pend_event`, :meth:`flush_io`)
292
+ is called. This allows several requests to be efficiently sent over the network in one message.
293
+
294
+ >>> chan = CaChannel('catest')
295
+ >>> chan.searchw()
296
+ >>> chan.array_put(123)
297
+ >>> chan.flush_io()
298
+ >>> chan.getw()
299
+ 123.0
300
+ >>> chan = CaChannel('cabo')
301
+ >>> chan.searchw()
302
+ >>> chan.array_put('Busy', ca.DBR_STRING)
303
+ >>> chan.flush_io()
304
+ >>> chan.getw()
305
+ 1
306
+ >>> chan = CaChannel('cawavec')
307
+ >>> chan.searchw()
308
+ >>> chan.array_put([1,2,3])
309
+ >>> chan.flush_io()
310
+ >>> chan.getw()
311
+ [1, 2, 3, 0, 0]
312
+ >>> chan.getw(count=3, use_numpy=True)
313
+ array([1, 2, 3], dtype=uint8)
314
+ >>> chan = CaChannel('cawavec')
315
+ >>> chan.searchw()
316
+ >>> chan.array_put('1234',count=3)
317
+ >>> chan.flush_io()
318
+ >>> chan.getw(count=4)
319
+ [49, 50, 51, 0]
320
+ """
321
+ ...
322
+
323
+ def array_put_callback(self, value, req_type, count, callback, *user_args): # -> None:
324
+ """Write a value or array of values to a channel and execute the user
325
+ supplied callback after the put has completed.
326
+
327
+ :param value: data to be written. For multiple values use a list or tuple.
328
+ :param req_type: database request type (``ca.DBR_XXXX``). Defaults to be the native data type.
329
+ :param count: number of data values to write, Defaults to be the native count.
330
+ :param callback: function called when the write is completed.
331
+ :param user_args: user provided arguments that are passed to callback when it is invoked.
332
+ :type value: int, float, bytes, str, list, tuple, array
333
+ :type req_type: int, None
334
+ :type count: int, None
335
+ :type callback: callable
336
+ :raises CaChannelException: if error happens
337
+
338
+ Each Python callback function is required to have two arguments.
339
+ The first argument is a dictionary containing the results of the action.
340
+
341
+ ======= ======= =======
342
+ field type comment
343
+ ======= ======= =======
344
+ chid capsule channels id structure
345
+ type int database request type (ca.DBR_XXXX)
346
+ count int number of values to transfered
347
+ status int CA status return code (ca.ECA_XXXX)
348
+ ======= ======= =======
349
+
350
+ The second argument is a tuple containing any user arguments specified by *user_args*.
351
+ If no arguments were specified then the tuple is empty.
352
+
353
+ .. note:: All remote operation requests such as the above are accumulated (buffered) and not forwarded to
354
+ the IOC until one of execution methods (:meth:`pend_io`, :meth:`poll`, :meth:`pend_event`, :meth:`flush_io`)
355
+ is called. This allows several requests to be efficiently sent over the network in one message.
356
+
357
+ >>> def putCB(epicsArgs, _):
358
+ ... print(ca.name(epicsArgs['chid']), 'put completed')
359
+ >>> chan = CaChannel('catest')
360
+ >>> chan.searchw()
361
+ >>> chan.array_put_callback(145, None, None, putCB)
362
+ >>> status = chan.pend_event(1)
363
+ catest put completed
364
+ >>> chan = CaChannel('cabo')
365
+ >>> chan.searchw()
366
+ >>> chan.array_put_callback('Busy', ca.DBR_STRING, None, putCB)
367
+ >>> status = chan.pend_event(1)
368
+ cabo put completed
369
+ >>> chan = CaChannel('cawave')
370
+ >>> chan.searchw()
371
+ >>> chan.array_put_callback([1,2,3], None, None, putCB)
372
+ >>> status = chan.pend_event(1)
373
+ cawave put completed
374
+ >>> chan = CaChannel('cawavec')
375
+ >>> chan.searchw()
376
+ >>> chan.array_put_callback('123', None, None, putCB)
377
+ >>> status = chan.pend_event(1)
378
+ cawavec put completed
379
+ """
380
+ ...
381
+
382
+ def getValue(self): # -> dict[Any, Any] | None:
383
+ """
384
+ Return the value(s) after :meth:`array_get` has completed.
385
+
386
+ :return: the value returned from the last array_get
387
+ :rtype: int, float, str, list, array, dict
388
+
389
+ If the *req_type* was not a plain type, the returned value is of dict type. It contains the same keys as in :meth:`array_get_callback`.
390
+
391
+ .. seealso:: :meth:`array_get`
392
+
393
+ >>> chan = CaChannel('cabo')
394
+ >>> chan.searchw()
395
+ >>> chan.putw(1)
396
+ >>> chan.array_get(req_type=ca.DBR_CTRL_ENUM)
397
+ >>> chan.pend_io()
398
+ >>> for k,v in sorted(chan.getValue().items()):
399
+ ... if k in ['pv_severity', 'pv_status']:
400
+ ... print(k, v.name)
401
+ ... else:
402
+ ... print(k, v)
403
+ pv_nostrings 2
404
+ pv_severity Minor
405
+ pv_statestrings ('Done', 'Busy')
406
+ pv_status State
407
+ pv_value 1
408
+ """
409
+ ...
410
+
411
+ def array_get(self, req_type=..., count=..., **keywords): # -> None:
412
+ """Read a value or array of values from a channel.
413
+
414
+ The new value is not available until a subsequent :meth:`pend_io` returns :data:`ca.ECA_NORMAL`.
415
+ Then it can be retrieved by a call to :meth:`getValue`.
416
+
417
+ :param req_type: database request type (:data:`ca.DBR_XXXX`). Defaults to be the native data type.
418
+ :param count: number of data values to read, Defaults to be the native count.
419
+ :param keywords: optional arguments assigned by keywords
420
+
421
+ =========== ===================================================
422
+ keyword value
423
+ =========== ===================================================
424
+ use_numpy True if waveform should be returned as numpy array.
425
+ Default :data:`CaChannel.USE_NUMPY`.
426
+ =========== ===================================================
427
+ :type req_type: int, None
428
+ :type count: int, None
429
+ :raises CaChannelException: if error happens
430
+
431
+ .. note:: All remote operation requests such as the above are accumulated (buffered) and not forwarded to
432
+ the IOC until one of execution methods (:meth:`pend_io`, :meth:`poll`, :meth:`pend_event`, :meth:`flush_io`)
433
+ is called. This allows several requests to be efficiently sent over the network in one message.
434
+
435
+ .. seealso:: :meth:`getValue`
436
+
437
+ >>> chan = CaChannel('catest')
438
+ >>> chan.searchw()
439
+ >>> chan.putw(123)
440
+ >>> chan.array_get()
441
+ >>> chan.pend_io()
442
+ >>> chan.getValue()
443
+ 123.0
444
+ """
445
+ ...
446
+
447
+ def array_get_callback(self, req_type, count, callback, *user_args, **keywords): # -> None:
448
+ """Read a value or array of values from a channel and execute the user
449
+ supplied callback after the get has completed.
450
+
451
+ :param req_type: database request type (``ca.DBR_XXXX``). Defaults to be the native data type.
452
+ :param count: number of data values to read, Defaults to be the native count.
453
+ :param callback: function called when the get is completed.
454
+ :param user_args: user provided arguments that are passed to callback when it is invoked.
455
+ :param keywords: optional arguments assigned by keywords
456
+
457
+ =========== ===================================================
458
+ keyword value
459
+ =========== ===================================================
460
+ use_numpy True if waveform should be returned as numpy array.
461
+ Default :data:`CaChannel.USE_NUMPY`.
462
+ =========== ===================================================
463
+ :type req_type: int, None
464
+ :type count: int, None
465
+ :type callback: callable
466
+
467
+ :raises CaChannelException: if error happens
468
+
469
+ Each Python callback function is required to have two arguments.
470
+ The first argument is a dictionary containing the results of the action.
471
+
472
+ +-----------------+---------------+------------------------------------+-------------------------+---------------+-------------+---------------+
473
+ | field | type | comment | request type |
474
+ | | | +----------+--------------+---------------+-------------+---------------+
475
+ | | | | DBR_XXXX | DBR_STS_XXXX | DBR_TIME_XXXX | DBR_GR_XXXX | DBR_CTRL_XXXX |
476
+ +=================+===============+====================================+==========+==============+===============+=============+===============+
477
+ | chid | int | channels id number | X | X | X | X | X |
478
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
479
+ | type | int | database request type | X | X | X | X | X |
480
+ | | | (ca.DBR_XXXX) | | | | | |
481
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
482
+ | count | int | number of values to transfered | X | X | X | X | X |
483
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
484
+ | status | int | CA status return code | X | X | X | X | X |
485
+ | | | (ca.ECA_XXXX) | | | | | |
486
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
487
+ | pv_value | | PV value | X | X | X | X | X |
488
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
489
+ | pv_status | int | PV alarm status | | X | X | X | X |
490
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
491
+ | pv_severity | int | PV alarm severity | | X | X | X | X |
492
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
493
+ | pv_seconds | int | seconds part of timestamp | | | X | | |
494
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
495
+ | pv_nseconds | int | nanoseconds part of timestamp | | | X | | |
496
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
497
+ | pv_nostrings | int | ENUM PV's number of states | | | | X | X |
498
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
499
+ | pv_statestrings | string list | ENUM PV's states string | | | | X | X |
500
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
501
+ | pv_units | string | units | | | | X | X |
502
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
503
+ | pv_precision | int | precision | | | | X | X |
504
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
505
+ | pv_updislim | float | upper display limit | | | | X | X |
506
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
507
+ | pv_lodislim | float | lower display limit | | | | X | X |
508
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
509
+ | pv_upalarmlim | float | upper alarm limit | | | | X | X |
510
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
511
+ | pv_upwarnlim | float | upper warning limit | | | | X | X |
512
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
513
+ | pv_loalarmlim | float | lower alarm limit | | | | X | X |
514
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
515
+ | pv_lowarnlim | float | lower warning limit | | | | X | X |
516
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
517
+ | pv_upctrllim | float | upper control limit | | | | | X |
518
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
519
+ | pv_loctrllim | float | lower control limit | | | | | X |
520
+ +-----------------+---------------+------------------------------------+----------+--------------+---------------+-------------+---------------+
521
+
522
+ The second argument is a tuple containing any user arguments specified by *user_args*.
523
+ If no arguments were specified then the tuple is empty.
524
+
525
+ .. note:: All remote operation requests such as the above are accumulated (buffered)
526
+ and not forwarded to the IOC until one of execution methods (:meth:`pend_io`, :meth:`poll`, :meth:`pend_event`, :meth:`flush_io`)
527
+ is called. This allows several requests to be efficiently sent over the network in one message.
528
+
529
+ >>> def getCB(epicsArgs, _):
530
+ ... for item in sorted(epicsArgs.keys()):
531
+ ... if item in ['pv_severity', 'pv_status']:
532
+ ... print(item,epicsArgs[item].name)
533
+ ... elif item.startswith('pv_'):
534
+ ... print(item,epicsArgs[item])
535
+ >>> chan = CaChannel('catest')
536
+ >>> chan.searchw()
537
+ >>> chan.putw(145)
538
+ >>> chan.array_get_callback(ca.DBR_CTRL_DOUBLE, 1, getCB)
539
+ >>> status = chan.pend_event(1)
540
+ pv_loalarmlim -20.0
541
+ pv_loctrllim 0.0
542
+ pv_lodislim -20.0
543
+ pv_lowarnlim -10.0
544
+ pv_precision 4
545
+ pv_severity Major
546
+ pv_status HiHi
547
+ pv_units mm
548
+ pv_upalarmlim 20.0
549
+ pv_upctrllim 0.0
550
+ pv_updislim 20.0
551
+ pv_upwarnlim 10.0
552
+ pv_value 145.0
553
+ >>> chan = CaChannel('cabo')
554
+ >>> chan.searchw()
555
+ >>> chan.putw(0)
556
+ >>> chan.array_get_callback(ca.DBR_CTRL_ENUM, 1, getCB)
557
+ >>> status = chan.pend_event(1)
558
+ pv_nostrings 2
559
+ pv_severity No
560
+ pv_statestrings ('Done', 'Busy')
561
+ pv_status No
562
+ pv_value 0
563
+ """
564
+ ...
565
+
566
+ def add_masked_array_event(
567
+ self, req_type, count, mask, callback, *user_args, **keywords
568
+ ): # -> None:
569
+ """Specify a callback function to be executed whenever changes occur to a PV.
570
+
571
+ Creates a new event id and stores it on self.__evid. Only one event registered per CaChannel object.
572
+ If an event is already registered the event is cleared before registering a new event.
573
+
574
+ :param req_type: database request type (``ca.DBR_XXXX``). Defaults to be the native data type.
575
+ :param count: number of data values to read, Defaults to be the native count.
576
+ :param mask: logical or of ``ca.DBE_VALUE``, ``ca.DBE_LOG``, ``ca.DBE_ALARM``.
577
+ Defaults to be ``ca.DBE_VALUE|ca.DBE_ALARM``.
578
+ :param callback: function called when the get is completed.
579
+ :param user_args: user provided arguments that are passed to callback when it is invoked.
580
+ :param keywords: optional arguments assigned by keywords
581
+
582
+ =========== ===================================================
583
+ keyword value
584
+ =========== ===================================================
585
+ use_numpy True if waveform should be returned as numpy array.
586
+ Default :data:`CaChannel.USE_NUMPY`.
587
+ =========== ===================================================
588
+ :type req_type: int, None
589
+ :type count: int, None
590
+ :type mask: int, None
591
+ :type callback: callable
592
+
593
+ :raises CaChannelException: if error happens
594
+
595
+ .. note:: All remote operation requests such as the above are accumulated (buffered) and not forwarded to
596
+ the IOC until one of execution methods (:meth:`pend_io`, :meth:`poll`, :meth:`pend_event`, :meth:`flush_io`)
597
+ is called. This allows several requests to be efficiently sent over the network in one message.
598
+
599
+ >>> def eventCB(epicsArgs, _):
600
+ ... print('pv_value', epicsArgs['pv_value'])
601
+ ... print('pv_status', epicsArgs['pv_status'].name)
602
+ ... print('pv_severity', epicsArgs['pv_severity'].name)
603
+ >>> chan = CaChannel('cabo')
604
+ >>> chan.searchw()
605
+ >>> chan.putw(1)
606
+ >>> chan.add_masked_array_event(ca.DBR_STS_ENUM, None, None, eventCB)
607
+ >>> status = chan.pend_event(1)
608
+ pv_value 1
609
+ pv_status State
610
+ pv_severity Minor
611
+ >>> chan.add_masked_array_event(ca.DBR_STS_STRING, None, None, eventCB)
612
+ >>> status = chan.pend_event(1)
613
+ pv_value Busy
614
+ pv_status State
615
+ pv_severity Minor
616
+ >>> chan.clear_event()
617
+ """
618
+ ...
619
+
620
+ def clear_event(self): # -> None:
621
+ """Remove previously installed callback function.
622
+
623
+ .. note:: All remote operation requests such as the above are accumulated (buffered) and not forwarded to
624
+ the IOC until one of execution methods (:meth:`pend_io`, :meth:`poll`, :meth:`pend_event`, :meth:`flush_io`)
625
+ is called. This allows several requests to be efficiently sent over the network in one message.
626
+ """
627
+ ...
628
+
629
+ @attach_ca_context
630
+ def pend_io(self, timeout=...): # -> None:
631
+ """
632
+ Flush the send buffer and wait until outstanding queries (:meth:`search`, :meth:`array_get`) complete
633
+ or the specified timeout expires.
634
+
635
+ :param float timeout: seconds to wait
636
+ :raises CaChannelException: if timeout or other error happens
637
+
638
+ """
639
+ ...
640
+
641
+ @attach_ca_context
642
+ def pend_event(self, timeout=...):
643
+ """Flush the send buffer and process background activity (connect/get/put/monitor callbacks) for ``timeout`` seconds.
644
+
645
+ It will not return before the specified timeout expires and all unfinished channel access labor has been processed.
646
+
647
+ :param float timeout: seconds to wait
648
+ :return: :data:`ca.ECA_TIMEOUT`
649
+ """
650
+ ...
651
+
652
+ @attach_ca_context
653
+ def poll(self):
654
+ """Flush the send buffer and execute any outstanding background activity.
655
+
656
+ :return: :data:`ca.ECA_TIMEOUT`
657
+
658
+ .. note:: It is an alias to ``pend_event(1e-12)``.
659
+ """
660
+ ...
661
+
662
+ @attach_ca_context
663
+ def flush_io(self): # -> None:
664
+ """
665
+ Flush the send buffer and does not execute outstanding background activity.
666
+
667
+ :raises CaChannelException: if error happens
668
+ """
669
+ ...
670
+
671
+ def field_type(self):
672
+ """
673
+ Native type of the PV in the server, :data:`ca.DBF_XXXX`.
674
+
675
+ >>> chan = CaChannel('catest')
676
+ >>> chan.searchw()
677
+ >>> ftype = chan.field_type()
678
+ >>> ftype
679
+ <DBF.DOUBLE: 6>
680
+ >>> ca.dbf_text(ftype)
681
+ 'DBF_DOUBLE'
682
+ >>> ca.DBF_DOUBLE == ftype
683
+ True
684
+ """
685
+ ...
686
+
687
+ def element_count(self):
688
+ """
689
+ Maximum array element count of the PV in the server.
690
+
691
+ >>> chan = CaChannel('catest')
692
+ >>> chan.searchw()
693
+ >>> chan.element_count()
694
+ 1
695
+ """
696
+ ...
697
+
698
+ def name(self):
699
+ """
700
+ Channel name specified when the channel was created.
701
+
702
+ >>> chan = CaChannel('catest')
703
+ >>> chan.searchw()
704
+ >>> chan.name()
705
+ 'catest'
706
+ """
707
+ ...
708
+
709
+ def state(self):
710
+ """
711
+ Current state of the CA connection.
712
+
713
+ ================== ===== =============
714
+ States Value Meaning
715
+ ================== ===== =============
716
+ ca.cs_never_conn 0 PV not found
717
+ ca.cs_prev_conn 1 PV was found but unavailable
718
+ ca.cs_conn 2 PV was found and available
719
+ ca.cs_closed 3 PV not closed
720
+ ca.cs_never_search 4 PV not searched yet
721
+ ================== ===== =============
722
+
723
+ >>> chan = CaChannel('catest')
724
+ >>> chan.state()
725
+ <ChannelState.NEVER_SEARCH: 4>
726
+ >>> chan.searchw()
727
+ >>> chan.state()
728
+ <ChannelState.CONN: 2>
729
+ """
730
+ ...
731
+
732
+ def host_name(self):
733
+ """
734
+ Host name that hosts the process variable.
735
+
736
+ >>> chan = CaChannel('catest')
737
+ >>> chan.searchw()
738
+ >>> host_name = chan.host_name()
739
+
740
+ """
741
+ ...
742
+
743
+ def read_access(self):
744
+ """Access right to read the channel.
745
+
746
+ :return: True if the channel can be read, False otherwise.
747
+
748
+ >>> chan = CaChannel('catest')
749
+ >>> chan.searchw()
750
+ >>> chan.read_access()
751
+ True
752
+ """
753
+ ...
754
+
755
+ def write_access(self):
756
+ """Access right to write the channel.
757
+
758
+ :return: True if the channel can be written, False otherwise.
759
+
760
+ >>> chan = CaChannel('catest')
761
+ >>> chan.searchw()
762
+ >>> chan.write_access()
763
+ True
764
+ """
765
+ ...
766
+
767
+ def searchw(self, pvName=...): # -> None:
768
+ """
769
+ Attempt to establish a connection to a process variable.
770
+
771
+ :param pvName: process variable name
772
+ :type pvName: str, None
773
+ :raises CaChannelException: if timeout or error happens
774
+
775
+ .. note:: This method waits for connection to be established or fail with exception.
776
+
777
+ >>> chan = CaChannel('non-exist-channel')
778
+ >>> chan.searchw() # doctest: +IGNORE_EXCEPTION_DETAIL
779
+ Traceback (most recent call last):
780
+ ...
781
+ CaChannelException: User specified timeout on IO operation expired
782
+ """
783
+ ...
784
+
785
+ def putw(self, value, req_type=...): # -> None:
786
+ """
787
+ Write a value or array of values to a channel.
788
+
789
+ If the request type is omitted the data is written as the Python type corresponding to the native format.
790
+ Multi-element data is specified as a tuple or a list.
791
+ Internally the sequence is converted to a list before inserting the values into a C array.
792
+ Access using non-numerical types is restricted to the first element in the data field.
793
+ Mixing character types with numerical types writes bogus results but is not prohibited at this time.
794
+ :data:`ca.DBF_ENUM` fields can be written using :data:`ca.DBR_ENUM` and :data:`ca.DBR_STRING` types.
795
+ :data:`ca.DBR_STRING` writes of a field of type :data:`ca.DBF_ENUM` must be accompanied by a valid string
796
+ out of the possible enumerated values.
797
+
798
+ :param value: data to be written. For multiple values use a list or tuple
799
+ :param req_type: database request type (:data:`ca.DBR_XXXX`). Defaults to be the native data type.
800
+ :type value: int, float, bytes, str, tuple, list, array
801
+ :type req_type: int, None
802
+ :raises CaChannelException: if timeout or error happens
803
+
804
+ .. note:: This method does flush the request to the channel access server.
805
+
806
+ >>> chan = CaChannel('catest')
807
+ >>> chan.searchw()
808
+ >>> chan.putw(145)
809
+ >>> chan.getw()
810
+ 145.0
811
+ >>> chan = CaChannel('cabo')
812
+ >>> chan.searchw()
813
+ >>> chan.putw('Busy', ca.DBR_STRING)
814
+ >>> chan.getw()
815
+ 1
816
+ >>> chan.getw(ca.DBR_STRING)
817
+ 'Busy'
818
+ >>> chan = CaChannel('cawave')
819
+ >>> chan.searchw()
820
+ >>> chan.putw([1,2,3])
821
+ >>> chan.getw(req_type=ca.DBR_LONG,count=4)
822
+ [1, 2, 3, 0]
823
+ >>> chan = CaChannel('cawavec')
824
+ >>> chan.searchw()
825
+ >>> chan.putw('123')
826
+ >>> chan.getw(count=4)
827
+ [49, 50, 51, 0]
828
+ >>> chan.getw(req_type=ca.DBR_STRING)
829
+ '123'
830
+ >>> chan = CaChannel('cawaves')
831
+ >>> chan.searchw()
832
+ >>> chan.putw(['string 1','string 2'])
833
+ >>> chan.getw()
834
+ ['string 1', 'string 2', '']
835
+ """
836
+ ...
837
+
838
+ def getw(self, req_type=..., count=..., **keywords) -> dict[Any, Any] | PVValue:
839
+ """Read the value from a channel.
840
+
841
+ If the request type is omitted the data is returned to the user as the Python type corresponding to the native format.
842
+ Multi-element data has all the elements returned as items in a list and must be accessed using a numerical type.
843
+ Access using non-numerical types is restricted to the first element in the data field.
844
+
845
+ :data:`ca.DBF_ENUM` fields can be read using :data:`ca.DBR_ENUM` and :data:`ca.DBR_STRING` types.
846
+ :data:`ca.DBR_STRING` reads of a field of type :data:`ca.DBF_ENUM` returns the string corresponding
847
+ to the current enumerated value.
848
+
849
+ :data:`ca.DBF_CHAR` fields can be read using :data:`ca.DBR_CHAR` and :data:`ca.DBR_STRING` types.
850
+ :data:`ca.DBR_CHAR` returns a scalar or a sequnece of integers. :data:`ca.DBR_STRING` assumes each integer as a
851
+ character and assemble a string.
852
+
853
+ :param req_type: database request type. Defaults to be the native data type.
854
+ :param count: number of data values to read, Defaults to be the native count.
855
+ :param keywords: optional arguments assigned by keywords
856
+
857
+ =========== ===================================================
858
+ keyword value
859
+ =========== ===================================================
860
+ use_numpy True if waveform should be returned as numpy array.
861
+ Default :data:`CaChannel.USE_NUMPY`.
862
+ =========== ===================================================
863
+ :type req_type: int, None
864
+ :type count: int, None
865
+ :return: If *req_type* is plain request type, only the value is returned.
866
+ Otherwise a dict returns with information depending on the request type,
867
+ same as the first argument passed to user's callback by :meth:`array_get_callback`.
868
+
869
+ :raises CaChannelException: if timeout error happens
870
+
871
+ >>> chan = CaChannel('catest')
872
+ >>> chan.searchw()
873
+ >>> chan.putw(0)
874
+ >>> value = chan.getw(ca.DBR_TIME_DOUBLE)
875
+ >>> for k,v in sorted(value.items()): # doctest: +ELLIPSIS
876
+ ... if k in ['pv_severity', 'pv_status']:
877
+ ... print(k, v.name)
878
+ ... else:
879
+ ... print(k, v)
880
+ pv_nseconds ...
881
+ pv_seconds ...
882
+ pv_severity No
883
+ pv_status No
884
+ pv_value 0.0
885
+
886
+ .. versionchanged:: 3.0
887
+ If *req_type* is DBR_XXX_STRING for a char type PV, a string will be returned from composing
888
+ each element as a character.
889
+
890
+ """
891
+ ...
892
+
893
+ if __name__ == "__main__": ...