FACT++  1.0
void add_int_item_node ( unsigned int  _id,
IntItem *  _int_item 
)

Definition at line 3317 of file feeserver.c.

References cleanUp(), intNodesAmount, lastIntNode, and Memory::malloc().

Referenced by publishInt().

3317  {
3318  //create new node with enough memory
3319  IntItemNode* newNode = 0;
3320 
3321  newNode = (IntItemNode*) malloc(sizeof(IntItemNode));
3322  if (newNode == 0) {
3323  //no memory available!
3324 # ifdef __DEBUG
3325  printf("no memory available while adding IntItemNode!\n");
3326  fflush(stdout);
3327 # endif
3328  cleanUp();
3329  exit(201);
3330  }
3331  //initialize "members" of node
3332  newNode->prev = 0;
3333  newNode->next = 0;
3334  newNode->id = _id;
3335  newNode->intItem = _int_item;
3336  newNode->lastTransmittedIntValue = *(_int_item->location);
3337  //if default deadband is negative -> set threshold 0, otherwise set half of defaultDeadband
3338  newNode->threshold = (_int_item->defaultDeadband < 0) ? 0.0 : (_int_item->defaultDeadband / 2);
3339 
3340  newNode->locBackup = _int_item->location;
3341 
3342  // Check if these feature have to be ported as well ??? !!!
3343 // newNode->checksum = calculateChecksum((unsigned char*) &(_item->location),
3344 // sizeof(volatile float*));
3345 // newNode->checksumBackup = newNode->checksum;
3346 
3347 #ifdef __DEBUG
3348  // complete debug display of added IntItem
3349 /*
3350  printf("IntItem: %d\n", _id);
3351  printf("location: %f, locBackup %f\n", *(_int_item->location), *(newNode->locBackup));
3352  printf("location addr: %p, locBackup addr %p\n", _int_item->location, newNode->locBackup);
3353  printf("checksum1: %d, checksum2: %d\n\n", newNode->checksum,
3354  newNode->checksumBackup);
3355 */
3356 #endif
3357 
3358 # ifdef __DEBUG
3359  // short debug display of added Item
3360  printf("init of %s (int) with ID %d: %d\n", newNode->intItem->name,
3361  newNode->id, newNode->lastTransmittedIntValue);
3362  fflush(stdout);
3363 # endif
3364 
3365  ++intNodesAmount;
3366  //redirect pointers of doubly linked list (int)
3367  if (firstIntNode != 0) {
3368  lastIntNode->next = newNode;
3369  newNode->prev = lastIntNode;
3370  lastIntNode = newNode;
3371  } else {
3372  firstIntNode = newNode;
3373  lastIntNode = newNode;
3374  }
3375 }
static IntItemNode * firstIntNode
Definition: feeserver.c:281
void cleanUp()
Definition: feeserver.c:3159
void * malloc()
Definition: EventBuilder.cc:99
static unsigned int intNodesAmount
Definition: feeserver.c:293
static IntItemNode * lastIntNode
Definition: feeserver.c:287

+ Here is the call graph for this function:

+ Here is the caller graph for this function: