| 302 | } |
| 303 | |
| 304 | void InsertAttribute(CipInstance *const instance, |
| 305 | const EipUint16 attribute_number, |
| 306 | const EipUint8 cip_type, |
| 307 | void *const data, |
| 308 | const EipByte cip_flags) { |
| 309 | |
| 310 | CipAttributeStruct *attribute = instance->attributes; |
| 311 | CipClass *class = instance->cip_class; |
| 312 | |
| 313 | OPENER_ASSERT(NULL != attribute) |
| 314 | /* adding a attribute to a class that was not declared to have any attributes is not allowed */ |
| 315 | for (int i = 0; i < instance->cip_class->number_of_attributes; i++) { |
| 316 | if (attribute->data == NULL) { /* found non set attribute */ |
| 317 | attribute->attribute_number = attribute_number; |
| 318 | attribute->type = cip_type; |
| 319 | attribute->attribute_flags = cip_flags; |
| 320 | attribute->data = data; |
| 321 | |
| 322 | OPENER_ASSERT(attribute_number <= class->highest_attribute_number) |
| 323 | |
| 324 | size_t index = CalculateIndex(attribute_number); |
| 325 | |
| 326 | class->get_single_bit_mask[index] |= |
| 327 | (cip_flags & kGetableSingle) ? |
| 328 | 1 << (attribute_number) % 8 : 0; |
| 329 | class->get_all_bit_mask[index] |= |
| 330 | (cip_flags & kGetableAll) ? 1 << (attribute_number) % 8 : 0; |
| 331 | class->set_bit_mask[index] |= ( (cip_flags & kSetable) ? 1 : 0 ) |
| 332 | << ( (attribute_number) % 8 ); |
| 333 | |
| 334 | return; |
| 335 | } |
| 336 | attribute++; |
| 337 | } |
| 338 | OPENER_TRACE_ERR( |
| 339 | "Tried to insert to many attributes into class: %" PRIu32 ", instance %" PRIu32 "\n", |
| 340 | instance->cip_class->class_instance.instance_number, |
| 341 | instance->instance_number); |
| 342 | OPENER_ASSERT(0) |
| 343 | /* trying to insert too many attributes*/ |
| 344 | } |
| 345 | |
| 346 | void InsertService(const CipClass *const class, |
| 347 | const EipUint8 service_number, |
no test coverage detected