Cleaned up ANSTO code to merge with sinqdev.sics
This is our new RELEASE-4_0 branch which was taken from ansto/93d9a7c Conflicts: .gitignore SICSmain.c asynnet.c confvirtualmot.c counter.c devexec.c drive.c event.h exebuf.c exeman.c histmem.c interface.h motor.c motorlist.c motorsec.c multicounter.c napi.c napi.h napi4.c network.c nwatch.c nxscript.c nxxml.c nxxml.h ofac.c reflist.c scan.c sicshipadaba.c sicsobj.c site_ansto/docs/Copyright.txt site_ansto/instrument/lyrebird/config/tasmad/sicscommon/nxsupport.tcl site_ansto/instrument/lyrebird/config/tasmad/taspub_sics/tasscript.tcl statusfile.c tasdrive.c tasub.c tasub.h tasublib.c tasublib.h
This commit is contained in:
83
hipadaba.c
83
hipadaba.c
@@ -10,6 +10,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include "hipadaba.h"
|
||||
|
||||
#define ABS(x) (x < 0 ? -(x) : (x))
|
||||
@@ -21,6 +22,7 @@ static char update[] = { "update" };
|
||||
static char treeChange[] = { "treeChange" };
|
||||
static char dataSearch[] = { "dataSearch" };
|
||||
static char killNode[] = { "killNode" };
|
||||
static char propertyChange[] = { "propertyChange" };
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
pHdbDataMessage GetHdbSetMessage(pHdbMessage toTest)
|
||||
@@ -76,6 +78,15 @@ pHdbMessage GetHdbKillNodeMessage(pHdbMessage toTest)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
pHdbPropertyChange GetPropertyChangeMessage(pHdbMessage toTest)
|
||||
{
|
||||
if (toTest->type == propertyChange) {
|
||||
return (pHdbPropertyChange)toTest;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*================== internal functions ===================================*/
|
||||
void DeleteCallbackChain(pHdb node)
|
||||
{
|
||||
@@ -305,6 +316,10 @@ static pHdb locateChild(pHdb root, char *name)
|
||||
{
|
||||
pHdb current = NULL;
|
||||
|
||||
if(root == NULL){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
current = root->child;
|
||||
while (current != NULL) {
|
||||
if (strcmp(current->name, name) == 0) {
|
||||
@@ -486,8 +501,57 @@ static unsigned short fletcher16( char *data, size_t len)
|
||||
result = result << 8 | checkB;
|
||||
return result ;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
#define MAXLEN 65536
|
||||
/*------------------------------------------------------------------------*/
|
||||
static unsigned short longfletcher16(char *data, size_t len)
|
||||
{
|
||||
char buffer[MAXLEN];
|
||||
int i, j, div, count;
|
||||
char *pPtr;
|
||||
|
||||
if(len < MAXLEN){
|
||||
return fletcher16(data,len);
|
||||
}
|
||||
|
||||
/**
|
||||
* sum together to run the more complex checksum on
|
||||
* more juicy data
|
||||
*/
|
||||
div = (int)trunc((float)len/(float)MAXLEN);
|
||||
for(i = 0; i < MAXLEN; i++){
|
||||
pPtr = data + div*i;
|
||||
for(j = 0; j < div; j++){
|
||||
buffer[i] += *(pPtr + j);
|
||||
}
|
||||
}
|
||||
return fletcher16(buffer,MAXLEN);
|
||||
}
|
||||
#define MAXLEN 65536
|
||||
/*------------------------------------------------------------------------*/
|
||||
static unsigned short longfletcher16(char *data, size_t len)
|
||||
{
|
||||
char buffer[MAXLEN];
|
||||
int i, j, div, count;
|
||||
char *pPtr;
|
||||
|
||||
if(len < MAXLEN){
|
||||
return fletcher16(data,len);
|
||||
}
|
||||
|
||||
/**
|
||||
* sum together to run the more complex checksum on
|
||||
* more juicy data
|
||||
*/
|
||||
div = (int)trunc((float)len/(float)MAXLEN);
|
||||
for(i = 0; i < MAXLEN; i++){
|
||||
pPtr = data + div*i;
|
||||
for(j = 0; j < div; j++){
|
||||
buffer[i] += *(pPtr + j);
|
||||
}
|
||||
}
|
||||
return fletcher16(buffer,MAXLEN);
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
unsigned short getHdbCheckSum(hdbValue *val)
|
||||
{
|
||||
char *data;
|
||||
@@ -740,7 +804,6 @@ void AddHipadabaChild(pHdb parent, pHdb child, void *callData)
|
||||
* step to end of child chain
|
||||
*/
|
||||
while (current != NULL) {
|
||||
assert(strcmp(current->name, child->name) != 0);
|
||||
prev = current;
|
||||
current = current->next;
|
||||
}
|
||||
@@ -933,12 +996,22 @@ static int canCopy(hdbValue * source, hdbValue * target)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if(target->dataType == HIPINTAR &&
|
||||
(source->dataType == HIPINTAR || source->dataType == HIPINTVARAR)
|
||||
&& target->arrayLength == source->arrayLength){
|
||||
return 1;
|
||||
}
|
||||
if (target->dataType == HIPFLOATVARAR) {
|
||||
if (source->dataType == HIPFLOATAR ||
|
||||
source->dataType == HIPFLOATVARAR) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if(target->dataType == HIPFLOATAR &&
|
||||
(source->dataType == HIPFLOATAR || source->dataType == HIPFLOATVARAR)
|
||||
&& target->arrayLength == source->arrayLength){
|
||||
return 1;
|
||||
}
|
||||
if (source->dataType != target->dataType) {
|
||||
return 0;
|
||||
} else {
|
||||
@@ -1106,6 +1179,8 @@ static int calcDataLength(pHdb node, int testLength)
|
||||
/*============================= Property Functions ==========================*/
|
||||
void SetHdbProperty(pHdb node, char *key, char *value)
|
||||
{
|
||||
hdbPropertyChange propMes;
|
||||
|
||||
if (node != NULL && key != NULL && node->properties != NULL) {
|
||||
if (value == NULL) {
|
||||
StringDictDelete(node->properties, key);
|
||||
@@ -1114,6 +1189,10 @@ void SetHdbProperty(pHdb node, char *key, char *value)
|
||||
} else {
|
||||
StringDictAddPair(node->properties, key, value);
|
||||
}
|
||||
propMes.type = propertyChange;
|
||||
propMes.key = key;
|
||||
propMes.value = value;
|
||||
InvokeCallbackChain(node,(pHdbMessage)&propMes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user