|
| 1 | + |
| 2 | +# senml_pack Module |
| 3 | + |
| 4 | + |
| 5 | +## senml_pack.SenmlPack Objects |
| 6 | + |
| 7 | + |
| 8 | +represents a senml pack object. This can contain multiple records but also other (child) pack objects. |
| 9 | +When the pack object only contains records, it represents the data of a device. |
| 10 | +If the pack object has child pack objects, then it represents a gateway |
| 11 | + |
| 12 | +### __enter__ |
| 13 | + |
| 14 | +```Python |
| 15 | +__enter__(self) |
| 16 | +``` |
| 17 | + |
| 18 | +for supporting the 'with' statement |
| 19 | + |
| 20 | + |
| 21 | +_returns_: self |
| 22 | + |
| 23 | +### __exit__ |
| 24 | + |
| 25 | +```Python |
| 26 | +__exit__(self, exc_type, exc_val, exc_tb) |
| 27 | +``` |
| 28 | + |
| 29 | +when destroyed in a 'with' statement, make certain that the item is removed from the parent list. |
| 30 | + |
| 31 | + |
| 32 | +_returns_: None |
| 33 | + |
| 34 | +### __init__ |
| 35 | + |
| 36 | +```Python |
| 37 | +__init__(self, name, callback=None) |
| 38 | +``` |
| 39 | + |
| 40 | +initialize the object |
| 41 | + |
| 42 | +_parameters:_ |
| 43 | + |
| 44 | +- `name:` {string} the name of the pack |
| 45 | + |
| 46 | +### __iter__ |
| 47 | + |
| 48 | +```Python |
| 49 | +__iter__(self) |
| 50 | +``` |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +### add |
| 55 | + |
| 56 | +```Python |
| 57 | +adds the item to the list of records |
| 58 | +``` |
| 59 | + |
| 60 | + |
| 61 | +_parameters:_ |
| 62 | + |
| 63 | +- `item:` {SenmlRecord} the item that needs to be added to the pack |
| 64 | + |
| 65 | + |
| 66 | +_returns_: None |
| 67 | + |
| 68 | +### base_sum |
| 69 | + |
| 70 | +the base sum of the pack. |
| 71 | + |
| 72 | + |
| 73 | +_returns_: a number |
| 74 | + |
| 75 | +### base_time |
| 76 | + |
| 77 | +Get the base time assigned to this pack object. |
| 78 | +While rendering, this value will be subtracted from the value of the records. |
| 79 | + |
| 80 | + |
| 81 | +_returns_: unix time stamp representing the base time |
| 82 | + |
| 83 | +### base_value |
| 84 | + |
| 85 | +the base value of the pack. The value of the records will be subtracted by this value during rendering. |
| 86 | +While parsing, this value is added to the value of the records. |
| 87 | + |
| 88 | + |
| 89 | +_returns_: a number |
| 90 | + |
| 91 | +### clear |
| 92 | + |
| 93 | +```Python |
| 94 | +clear(self) |
| 95 | +``` |
| 96 | +clear the list of the pack |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | +_returns_: None |
| 101 | + |
| 102 | +### do_actuate |
| 103 | + |
| 104 | +```Python |
| 105 | +do_actuate(self, raw, naming_map, device=None) |
| 106 | +``` |
| 107 | + |
| 108 | +called while parsing incoming data for a record that is not yet part of this pack object. |
| 109 | +adds a new record and raises the actuate callback of the pack with the newly created record as argument |
| 110 | + |
| 111 | +_parameters:_ |
| 112 | + |
| 113 | +- naming_map: |
| 114 | +- `device:` optional: if the device was not found |
| 115 | +- `raw:` the raw record definition, as found in the json structure. this still has invalid labels. |
| 116 | + |
| 117 | + |
| 118 | +_returns_: None |
| 119 | + |
| 120 | +### from_cbor |
| 121 | + |
| 122 | +```Python |
| 123 | +from_cbor(self, data) |
| 124 | +``` |
| 125 | + |
| 126 | +parse a cbor data byte array to a senml pack structure. |
| 127 | + |
| 128 | +_parameters:_ |
| 129 | + |
| 130 | +- `data:` a byte array. |
| 131 | + |
| 132 | + |
| 133 | +_returns_: None |
| 134 | + |
| 135 | +### from_json |
| 136 | + |
| 137 | +```Python |
| 138 | +from_json(self, data) |
| 139 | +``` |
| 140 | + |
| 141 | +parse a json string and convert it to a senml pack structure |
| 142 | + |
| 143 | +_parameters:_ |
| 144 | + |
| 145 | +- `data:` a string containing json data. |
| 146 | + |
| 147 | + |
| 148 | +_returns_: None, will call the appropriate callback functions. |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | +### remove |
| 153 | + |
| 154 | +```Python |
| 155 | +remove(self, item) |
| 156 | +``` |
| 157 | +removes the item from the pack |
| 158 | + |
| 159 | + |
| 160 | +_parameters:_ |
| 161 | + |
| 162 | +- `item:` {SenmlRecord} the item that needs to be removed |
| 163 | + |
| 164 | + |
| 165 | +_returns_: None |
| 166 | + |
| 167 | +### to_cbor |
| 168 | + |
| 169 | +```Python |
| 170 | +to_cbor(self) |
| 171 | +``` |
| 172 | + |
| 173 | +render the content of this object to a cbor byte array |
| 174 | + |
| 175 | + |
| 176 | +_returns_: a byte array |
| 177 | + |
| 178 | +### to_json |
| 179 | + |
| 180 | +```Python |
| 181 | +to_json(self) |
| 182 | +``` |
| 183 | + |
| 184 | +render the content of this object to a string. |
| 185 | + |
| 186 | + |
| 187 | +_returns_: a string representing the senml pack object |
| 188 | + |
| 189 | +## senml_pack.SenmlPackIterator Objects |
| 190 | + |
| 191 | + |
| 192 | +an iterator to walk over all records in a pack |
| 193 | + |
| 194 | +### __init__ |
| 195 | + |
| 196 | +```Python |
| 197 | +__init__(self, list) |
| 198 | +``` |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | +### __iter__ |
| 203 | + |
| 204 | +```Python |
| 205 | +__iter__(self) |
| 206 | +``` |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | +### __next__ |
| 211 | + |
| 212 | +```Python |
| 213 | +__next__(self) |
| 214 | +``` |
| 215 | + |
| 216 | + |
0 commit comments