def _parse_notification_header(self, ntf_handle, ntf_header): """ Parse the notification header in the received notification to retrieve information Args: ntf_handle (SaNtfNotificationHandleT): A handle to the internal notification structure ntf_header (SaNtfNotificationHeaderT): Notification header structure in the received notification Returns: NotificationInfo: A NotificationInfo structure containing information from the notification header """ ntf_info = ntf.NotificationInfo() ntf_info.event_type = ntf_header.eventType.contents.value ntf_info.notification_object = \ str(ntf_header.notificationObject.contents) ntf_info.notifying_object = str(ntf_header.notifyingObject.contents) ntf_info.ntf_class_id = \ ntf_header.notificationClassId.contents ntf_info.event_time = ntf_header.eventTime.contents.value ntf_info.notification_id = \ ntf_header.notificationId.contents.value additional_text_str = \ ctypes.create_string_buffer(ntf_header.lengthAdditionalText) ctypes.memmove(additional_text_str, ntf_header.additionalText, ntf_header.lengthAdditionalText) ntf_info.additional_text = additional_text_str.value.decode( 'utf-8') if PY3 else additional_text_str.value for i in range(ntf_header.numAdditionalInfo): c_add_info = ntf_header.additionalInfo[i] add_info = ntf.AdditionalInfo() add_info.info_id = c_add_info.infoId add_info.info_type = c_add_info.infoType add_info.info_value = self._get_ntf_value(ntf_handle, c_add_info.infoValue, c_add_info.infoType) ntf_info.additional_info.append(add_info) return ntf_info
def clear_info(self): """ Reset the NotificationInfo field values """ self.ntf_info = ntf.NotificationInfo()
def __init__(self, version=None): """ Constructor for NtfProducer class """ super(NtfProducer, self).__init__(version) self.ntf_info = ntf.NotificationInfo()