Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def connected_cb(self, isconnected):
"""
Callback to run whenever the connection state of our pv changes.
:param isconnected: True if we are connected, False otherwise.
:type isconnected: bool
"""
self.connected = isconnected
self.send_connection_state(isconnected)
if isconnected:
self.epics_type = self.pv.type()
self.count = self.pv.count or 1
# Get the control info for the PV.
self.pv.get_data(True, -1.0, self.count)
pyca.flush_io()
if self.epics_type == "DBF_ENUM":
self.pv.get_enum_strings(-1.0)
if not self.pv.ismonitored:
self.pv.monitor()
self.python_type = type_map.get(self.epics_type)
if self.python_type is None:
raise Exception("Unsupported EPICS type {0} for pv {1}".format(
self.epics_type, self.pv.name))
def put_value(self, value):
"""
Set our PV's value in EPICS.
:param value: The value we'd like to put to our PV.
:type value: int or float or str or np.ndarray, depending on our
record type.
"""
if self.count == 1:
value = self.python_type(value)
try:
self.pv.put(value)
except pyca.caexc as e:
print("pyca error: {}".format(e))