def _apply_point_update(point_def, point_index, value): """ Set an input point in the outstation database. This may send its PointValue to the Master. :param point_def: A PointDefinition. :param point_index: A numeric index for the point. :param value: A value to send (unwrapped, simple data type). """ data_type = point_def.data_type if data_type == DATA_TYPE_ANALOG_INPUT: wrapped_val = opendnp3.Analog(float(value)) if isinstance(value, bool) or not isinstance(value, numbers.Number): # Invalid data type raise DNP3Exception('Received {} value for {}.'.format( type(value), point_def)) elif data_type == DATA_TYPE_BINARY_INPUT: wrapped_val = opendnp3.Binary(value) if not isinstance(value, bool): # Invalid data type raise DNP3Exception('Received {} value for {}.'.format( type(value), point_def)) else: # The agent supports only DNP3's Analog and Binary point types at this time. raise DNP3Exception('Unsupported point type {}'.format(data_type)) if wrapped_val is not None: DNP3Outstation.apply_update(wrapped_val, point_index) _log.debug('Sent DNP3 point {}, value={}'.format( point_def, wrapped_val.value))
def _apply_point_update(point_def, point_index, value): """ Set an input point in the outstation database. This may send its PointValue to the Master. :param point_def: A PointDefinition. :param point_index: A numeric index for the point. :param value: A value to send (unwrapped, simple data type). """ data_type = point_def.data_type if data_type == DATA_TYPE_ANALOG_INPUT: wrapped_val = opendnp3.Analog(float(value)) if isinstance(value, bool) or not isinstance(value, numbers.Number): # Invalid data type raise DNP3Exception('Received {} value for {}.'.format(type(value), point_def)) elif data_type == DATA_TYPE_BINARY_INPUT: wrapped_val = opendnp3.Binary(value) if not isinstance(value, bool): # Invalid data type raise DNP3Exception('Received {} value for {}.'.format(type(value), point_def)) else: # The agent supports only DNP3's Analog and Binary point types at this time. raise DNP3Exception('Unsupported point type {}'.format(data_type)) if wrapped_val is not None: DNP3Outstation.apply_update(wrapped_val, point_index) _log.debug('Sent DNP3 point {}, value={}'.format(point_def, wrapped_val.value))
def _set_point(self, point_name, value): """ (Internal) Set the value of a given input point (no debug trace). @param point_name: The VOLTTRON point name of a DNP3 PointDefinition. @param value: The value to set. The value's data type must match the one in the DNP3 PointDefinition. """ point_properties = self.volttron_points.get(point_name, {}) data_type = point_properties.get('data_type', None) index = point_properties.get('index', None) try: if data_type == DATA_TYPE_ANALOG_INPUT: wrapped_value = opendnp3.Analog(value) elif data_type == DATA_TYPE_BINARY_INPUT: wrapped_value = opendnp3.Binary(value) else: raise Exception('Unexpected data type for DNP3 point named {0}'.format(point_name)) DNP3Outstation.apply_update(wrapped_value, index) except Exception as e: raise DNP3Exception(e.message)
def _set_point(self, point_name, value): """ (Internal) Set the value of a given input point (no debug trace). @param point_name: The VOLTTRON point name of a DNP3 PointDefinition. @param value: The value to set. The value's data type must match the one in the DNP3 PointDefinition. """ point_properties = self.volttron_points.get(point_name, {}) group = point_properties.get('group', None) index = point_properties.get('index', None) point_type = PointDefinition.point_type_for_group(group) try: if point_type == POINT_TYPE_ANALOG_INPUT: wrapped_value = opendnp3.Analog(value) elif point_type == POINT_TYPE_BINARY_INPUT: wrapped_value = opendnp3.Binary(value) else: raise Exception('Unexpected data type for DNP3 point named {0}'.format(point_name)) DNP3Outstation.apply_update(wrapped_value, index) except Exception as e: raise DNP3Exception(e.message)