Clean up the space/tab mess and trailing whitespace

This commit is contained in:
Douglas Clowes
2014-03-03 17:00:14 +11:00
parent bcefc2db60
commit 579b78e30b

View File

@ -24,11 +24,11 @@
#include "scriptcontext.h"
/*---------------------------------------------------------------*/
typedef struct {
pObjectDescriptor pDes;
pIDrivable pDriv;
pHdb write_node;
pHdb read_node;
SctController *c;
pObjectDescriptor pDes;
pIDrivable pDriv;
pHdb write_node;
pHdb read_node;
SctController *c;
}SctDrive, *pSctDrive;
/*---------------------------------------------------------------*/
static void *SCTDRIVGetInterface(void *data, int iD){
@ -77,16 +77,16 @@ static int SCTDRIVCheckLimits(void *data, float val,
snprintf(script,1024,"%f", val);
SetHdbProperty(self->write_node,"target", script);
if(GetHdbProperty(self->write_node,"checklimits",script,1024)){
status = SctCallInContext(pServ->dummyCon, script,
self->write_node, self->c, &result);
if(SctVerbose(self->c)){
SCPrintf(pServ->dummyCon, eWarning, "script %s called with result %s\n ",
script, result);
}
if(status == 0){
strncpy(error,result,errlen);
return 0;
}
status = SctCallInContext(pServ->dummyCon, script,
self->write_node, self->c, &result);
if(SctVerbose(self->c)){
SCPrintf(pServ->dummyCon, eWarning, "script %s called with result %s\n ",
script, result);
}
if(status == 0){
strncpy(error,result,errlen);
return 0;
}
}
return 1;
}
@ -110,9 +110,9 @@ static long SCTDRIVSetValue(void *data, SConnection *pCon, float val){
SetHdbProperty(self->write_node,"writestatus", "start");
status = SetHipadabaPar(self->write_node, v, pCon);
if(status == 1){
return OKOK;
return OKOK;
} else {
return HWFault;
return HWFault;
}
}
/*----------------------------------------------------------------
@ -139,9 +139,9 @@ static int SCTDRIVCheckStatus(void *data, SConnection *pCon){
* check if the write command has gone through
*/
if(GetHdbProperty(self->write_node,"writestatus", script,1024)){
if(strcmp(script,"start") == 0){
return HWBusy;
}
if(strcmp(script,"start") == 0){
return HWBusy;
}
}
/*
@ -159,12 +159,12 @@ static int SCTDRIVCheckStatus(void *data, SConnection *pCon){
self->c, &result);
if (status == 0) {
SCPrintf(pCon,eError," script %s returned %s",
script, result);
script, result);
return HWFault;
}
if(SctVerbose(self->c)){
SCPrintf(pCon,eError," script %s returned %s",
script, result);
script, result);
}
}
if(strstr(result,"busy") != NULL){
@ -196,8 +196,8 @@ static float SCTDRIVGetValue(void *data, SConnection *pCon){
self = (pSctDrive)data;
if(GetHdbProperty(self->read_node,"geterror", error, 256)){
SCWrite(pCon,error, eError);
return val;
SCWrite(pCon,error, eError);
return val;
}
return (float)self->read_node->value.v.doubleValue;
}
@ -209,13 +209,13 @@ static pSctDrive SCTDRIVMakeObject(){
self = calloc(sizeof(SctDrive),1);
if(self == NULL){
return NULL;
return NULL;
}
self->pDes = CreateDescriptor("SctDriveAdapter");
self->pDriv = CreateDrivableInterface();
if(self->pDes == NULL || self->pDriv == NULL){
free(self);
return NULL;
free(self);
return NULL;
}
self->pDes->GetInterface = SCTDRIVGetInterface;
@ -230,36 +230,36 @@ static pSctDrive SCTDRIVMakeObject(){
/*-----------------------------------------------------------------*/
static int SctDriveCommand(SConnection *pCon, SicsInterp *sics, void *object,
int argc, char *argv[]) {
pSctDrive self = (pSctDrive)object;
float val;
pSctDrive self = (pSctDrive)object;
float val;
assert(self != NULL);
assert(self != NULL);
if (self->write_node == NULL) {
SCWrite(pCon, "ERROR: defunct object", eError);
return 0;
}
/*
* only action: print value
*/
val = self->pDriv->GetValue(self,pCon);
SCPrintf(pCon,eValue,"%s = %f", argv[0], val);
return 1;
if (self->write_node == NULL) {
SCWrite(pCon, "ERROR: defunct object", eError);
return 0;
}
/*
* only action: print value
*/
val = self->pDriv->GetValue(self,pCon);
SCPrintf(pCon,eValue,"%s = %f", argv[0], val);
return 1;
}
/*----------------------------------------------------------------*/
static void SctDriveKill(void *data){
pSctDrive self = (pSctDrive)data;
pSctDrive self = (pSctDrive)data;
if(self == NULL){
return;
}
if(self->pDriv != NULL){
free(self->pDriv);
}
if(self->pDes != NULL){
DeleteDescriptor(self->pDes);
}
free(self);
if(self == NULL){
return;
}
if(self->pDriv != NULL){
free(self->pDriv);
}
if(self->pDes != NULL){
DeleteDescriptor(self->pDes);
}
free(self);
}
/*----------------------------------------------------------------*/
static hdbCallbackReturn SctDummyCallback(Hdb *node, void *userData,
@ -274,44 +274,44 @@ static void SctDriveDeleteNode(void *data) {
/*---------------------------------------------------------------*/
int ANSTO_SctMakeDriveAdapter(SConnection *pCon, SicsInterp *pSics, void *object,
int argc, char *argv[]) {
pSctDrive pNew = NULL;
pSICSOBJ obj = NULL;
pSctDrive pNew = NULL;
pSICSOBJ obj = NULL;
hdbCallback *cb;
pNew = SCTDRIVMakeObject();
if(pNew == NULL){
SCWrite(pCon,"ERROR: out of memory in ANSTO_SctMakeDriveAdapter",
eError);
return 0;
}
pNew = SCTDRIVMakeObject();
if(pNew == NULL){
SCWrite(pCon,"ERROR: out of memory in ANSTO_SctMakeDriveAdapter",
eError);
return 0;
}
if(argc < 4){
SCWrite(pCon,"ERROR: not enough arguments for ANSTO_SctMakeDriveAdapter", eError);
return 0;
}
if(argc < 4){
SCWrite(pCon,"ERROR: not enough arguments for ANSTO_SctMakeDriveAdapter", eError);
return 0;
}
pNew->write_node = FindHdbNode(NULL,argv[2], pCon);
pNew->read_node = FindHdbNode(NULL,argv[3], pCon);
obj = FindCommandData(pSics,argv[4], "SctController");
if(pNew->write_node == NULL || obj == NULL){
SCWrite(pCon,"ERROR: node or controller not found", eError);
SctDriveKill(pNew);
return 0;
}
pNew->c =(SctController *)obj->pPrivate;
pNew->write_node = FindHdbNode(NULL,argv[2], pCon);
pNew->read_node = FindHdbNode(NULL,argv[3], pCon);
obj = FindCommandData(pSics,argv[4], "SctController");
if(pNew->write_node == NULL || obj == NULL){
SCWrite(pCon,"ERROR: node or controller not found", eError);
SctDriveKill(pNew);
return 0;
}
pNew->c =(SctController *)obj->pPrivate;
if (strcasecmp(argv[0],"dynsctdrive") == 0) {
/* make object dynamic by defining a descriptor command */
SetDescriptorKey(pNew->pDes, "creationCommand", "0");
}
AddCommand(pSics, argv[1], SctDriveCommand, SctDriveKill, pNew);
SetHdbProperty(pNew->write_node,"sicsdev",argv[1]);
AddCommand(pSics, argv[1], SctDriveCommand, SctDriveKill, pNew);
SetHdbProperty(pNew->write_node,"sicsdev",argv[1]);
cb = MakeHipadabaCallback(SctDummyCallback, pNew, SctDriveDeleteNode);
assert(cb);
AppendHipadabaCallback(pNew->write_node, cb);
return 1;
return 1;
}
/*---------------------------------------------------------------*/