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:
Ferdi Franceschini
2015-04-23 20:49:26 +10:00
parent c650788a2c
commit 10d29d597c
1336 changed files with 9430 additions and 226646 deletions

72
scan.c
View File

@@ -241,31 +241,6 @@ int AddScanVar(pScanData self, SicsInterp * pSics, SConnection * pCon,
return 1;
}
/*-------------------------------------------------------------------------*/
int ReplaceScanVar(pScanData self, SicsInterp * pSics, SConnection * pCon,
int index, float fStart, float fStep)
{
pVarEntry pVar = NULL;
void *pPtr = NULL;
if (self->iActive) {
SCWrite(pCon, "ERROR: cannot change parameters while scan is running",
eError);
return 0;
}
DynarGet(self->pScanVar, index, &pPtr);
pVar = (pVarEntry) pPtr;
if (pVar == NULL) {
return 0;
}
pVar->fStart = fStart;
pVar->fStep = fStep;
/* put it away */
DynarReplace(self->pScanVar, index, pVar, sizeof(VarEntry));
return 1;
}
/*-------------------------------------------------------------------------*/
int AddLogVar(pScanData self, SicsInterp * pSics, SConnection * pCon,
char *name)
@@ -669,6 +644,7 @@ int DoScan(pScanData self, int iNP, int iMode, float fPreset,
return 0;
}
self->iActive = 1;
self->iNP = iNP;
self->iMode = iMode;
self->fPreset = fPreset;
@@ -682,13 +658,15 @@ int DoScan(pScanData self, int iNP, int iMode, float fPreset,
if (!iRet) {
self->pCon = NULL;
self->pSics = NULL;
self->iActive = 0;
return 0;
}
self->iActive = 1;
iRet = ScanLoop(self);
ScriptScanFinish(self);
if(self->pCon != NULL && self->pSics != NULL){
ScriptScanFinish(self);
}
InvokeCallBack(self->pCall, SCANEND, self);
SendQuieck(QUIECK, self->pFile);
self->iActive = 0;
@@ -1021,7 +999,11 @@ int GetScanVarName(pScanData self, int iWhich, char *pName, int iLength)
return 0;
}
}
/*---------------------------------------------------------------------*/
int isScanRunning(pScanData self)
{
return self->iActive;
}
/*---------------------------------------------------------------------*/
int GetScanVarStep(pScanData self, int iWhich, float *fStep)
{
@@ -1641,12 +1623,12 @@ int ScanWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[])
{
pScanData self = NULL;
char pBueffel[512], varname[512];
char pBueffel[512];
double fStep, fStart, fPreset;
float *fData = NULL;
int lNP, foundMatch=0;
int lNP;
int iChannel;
int iRet, iMode, i, varnum;
int iRet, iMode, i;
char *pPtr = NULL, pItem[20];
long *lData = NULL, lID;
int *iData;
@@ -1742,6 +1724,12 @@ int ScanWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
SCWrite(pCon, pBueffel, eValue);
return 1;
}
/*-------- isactive */
else if (strcmp(argv[1], "isactive") == 0) {
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.active = %d", argv[0], self->iActive);
SCWrite(pCon, pBueffel, eValue);
return 1;
}
/*--------- getvardata */
else if (strcmp(argv[1], "getvardata") == 0) {
/* we need an integer parameter saying which */
@@ -1898,26 +1886,8 @@ int ScanWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
SCWrite(pCon, pBueffel, eError);
return 0;
}
if (self->iScanVar == 0) {
iRet = AddScanVar(self, pSics, pCon, argv[2], (float) fStart,
(float) fStep);
} else {
foundMatch = 0;
for (varnum = 0; varnum < self->iScanVar; varnum++) {
GetScanVarName(self, varnum, varname, 512);
if (strcmp(argv[2], varname) == 0) {
foundMatch = 1;
break;
}
}
if (foundMatch) {
iRet = ReplaceScanVar(self, pSics, pCon, varnum, (float) fStart,
(float) fStep);
} else {
iRet = AddScanVar(self, pSics, pCon, argv[2], (float) fStart,
(float) fStep);
}
}
iRet = AddScanVar(self, pSics, pCon, argv[2],
(float) fStart, (float) fStep);
if (iRet) {
SCSendOK(pCon);
}