| |
- __builtin__.object
-
- DataField
- pcisim.lib.MyException(exceptions.Exception)
-
- DataFieldOverflow
class DataField(__builtin__.object) |
|
A bitfield container with name, bits, value and description.
@ATTRIBS
(str) name : symbolic name for the field
(int) bits : number of bits of the field
(int) value : internal value of the field
(str) hint : field description or None
In order to handle field value, the following interfaces are available:
- self.value : retrieve the current field value
- self.set : set field value making size checks and notify
changed value to callbacks.
- self.value = x : set field value directly (*not recommended*)
It is possible to add callbacks to be executed on value change. This
remarks provider-subscriber programming pattern.
Field values can be limited using *slots*. Slots can be classified in
category groups and, optionally, a *filter* field can be used to query
current category.
See 'add_slot*' and 'set_filter' methods for more details.
@NOTES
- A readonly field cannot be modified
- Value is actually changed only if different from current one |
|
Methods defined here:
- __init__(self, bits, name='', value=0, hint=None, ro=False)
- __str__(self)
- Shows field name, bits and hex value.
- add_callback(self, callback)
- Add a function listener for field value change.
@PARAMS
callback : callback to call on change.
- add_slot(self, slotlb, slotval, cat=0)
- Adds a slot to the field slots.
@PARAMS
(str) slotlb : label associated the slot
(int) slotval : value associated to the slot
cat : optional slot category
@NOTES
Default category code is 0x0
- add_slots(self, slots_l, cat=0)
- Adds multiple slots at once, using same category.
@PARAMS
(list)(list[2]) : slots list of slot_label, slot_value
cat : optional slots category
@NOTES
Default category code is 0x0
- can_hold(self, value)
- Performs checks on value to ensure it fits field bit size.
@PARAMS
(uint) value to check
@RETURN
| FITS OK : True
| DON'T FIT : False
- clean_slots(self)
- Removes all slots and filter from the field
- get_bin(self)
- Get binary representation as a string.
- get_hex(self)
- Get hexadecimal representation as a string.
- get_slot_name(self, slotval)
- Find a slot in current category by value.
@PARAMS
(int) slotval : slot value to search
@RETURN
| SUCCESS : (str) slot name
| FAILURE : (None)
- get_slots(self)
- Get the field slots. If a filter is being set, use it to extract
only the slots having the filtered category.
@RETURN
(list)(list[2]) : slots list of slot_label, slot_value
- has_category(self, cat)
- Query field slots and look for specified category.
@PARAMS
cat : slots category group name.
@RETURN
| HAS CATEGORY : True
| HAS NOT CATEGORY : False
- has_highlight(self)
- Get field selection state.
@RETURN
| HAS HIGHLIGHT : True
| HAS NOT HIGHLIGHT : False
- has_slots(self)
- Query about field slots.
@RETURN
| HAS SLOTS : True
| HAS NOT SLOTS : False
- highlight(self, highlight=True)
- Sets field selection state.
@PARAMS
(bool) highlight : higlight state, True if active.
@NOTES
This function sends callbacks notification.
- is_readonly(self)
- Returns readonly boolean state
- notify(self, exclude=[])
- This function is called to notify to the callbacks that field
value id changed.
@PARAMS
| (list) exclude : optional list of callbacks to exclude
| (func) exclude : single callback to exclude
- rand(self)
- Fills field with a random value, in respect to field bit size and
optional slots.
- rem_callback(self, callback)
- Removes the function from internal callbacks or does nothing.
@PARAMS
callback : function to remove
@NOTES
It is safe to call this function for an unsubscribed callback.
- set(self, value, notify=True)
- Set field value after performing size checks.
@PARAMS
(int | long) value : value to set
notify : if True, send value changes notifications to callbacks
@NOTES
This function sends callbacks notification.
@RAISES
DataFieldOverflow on field value overflow.
- set_filter(self, field)
- Adds a filter field for category filtering.
@PARAMS
(DataField) field : field used as a filter
- set_readonly(self, readonly)
- Set readonly status.
@PARAMS
(bool) readonly : if True, field modifications are locked
- set_slot(self, sloti)
- Sets the active slot for the current category.
@PARAMS
(int) sloti : index in slot category of the setting slot.
@NOTES
Internal value is changed and changes are notified.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
|