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

113
drive.c
View File

@ -169,7 +169,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
/* first try to find the thing to drive */
pObject = FindCommand(pInter, name);
if (!pObject) {
snprintf(pBueffel,511, "Cannot find %s to drive ", name);
snprintf(pBueffel,511, "ERROR: Cannot find %s to drive ", name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -180,7 +180,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
pDum = (Dummy *) pObject->pData;
pDes = pDum->pDescriptor;
if (!pDes) {
snprintf(pBueffel,511, "%s is NOT drivable!", pDes->name);
snprintf(pBueffel,511, "ERROR: %s is NOT drivable!", pDes->name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -190,14 +190,14 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
*/
pInt = pDes->GetInterface(pDum, DRIVEID);
if (!pInt) {
snprintf(pBueffel,511, "%s is NOT drivable!", pDes->name);
snprintf(pBueffel,511, "ERROR: %s is NOT drivable!", pDes->name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
if (pInt) {
iRet = pInt->CheckLimits(pDum, fNew, pBueffel, 511);
if (!iRet) {
SCWrite(pCon, pBueffel, eError);
SCPrintf(pCon, eError, "ERROR: %s", pBueffel);
SCSetInterrupt(pCon, eAbortOperation);
return 0;
}
@ -208,7 +208,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
return 1;
}
} else {
snprintf(pBueffel,511, "%s is NOT drivable", pDes->name);
snprintf(pBueffel,511, "ERROR: %s is NOT drivable", pDes->name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -302,18 +302,21 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
return 0;
}
<<<<<<< HEAD
/* interpret arguments as pairs (name, value) and check */
SetStatus(eDriving);
=======
/* interprete arguments as pairs name value and try to start */
>>>>>>> master
for (i = 1; i < argc; i += 2) {
if (argv[i + 1] == NULL) {
snprintf(pBueffel, 511, "ERROR: no value found for driving %s", argv[i]);
SCWrite(pCon, pBueffel, eError);
SetStatus(eOld);
return 0;
}
iRet = Tcl_GetDouble(tcl_interp, argv[i + 1], &dTarget);
if (iRet == TCL_ERROR) {
SCWrite(pCon, Tcl_GetStringResult(tcl_interp), eError);
<<<<<<< HEAD
SetStatus(eOld);
return 0;
} else if (!isfinite(dTarget)) {
@ -321,7 +324,6 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
"ERROR: target %s value for %s is not a finite number",
argv[i + 1], argv[i]);
SCWrite(pCon, pBueffel, eError);
SetStatus(eOld);
return 0;
}
}
@ -330,7 +332,9 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
iRet = Tcl_GetDouble(tcl_interp, argv[i + 1], &dTarget);
if (iRet == TCL_ERROR) {
SCWrite(pCon, Tcl_GetStringResult(tcl_interp), eError);
SetStatus(eOld);
=======
StopExe(GetExecutor(), "ALL");
>>>>>>> master
return 0;
}
iRet = Start2Run(pCon, pSics, argv[i], RUNDRIVE, dTarget);
@ -344,7 +348,6 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
}
SCWrite(pCon, pBueffel, eError);
StopExe(GetExecutor(), "ALL");
SetStatus(eOld);
return 0;
}
}
@ -367,17 +370,18 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
sprintf(pBueffel, "Driving finished with problem");
SCWrite(pCon, pBueffel, eError);
ClearExecutor(GetExecutor());
SetStatus(eOld);
return 0;
} else if (iRet == DEVINT) {
sprintf(pBueffel, "ERROR: Driving Interrupted!");
SCWrite(pCon, pBueffel, eError);
ClearExecutor(GetExecutor());
SetStatus(eOld);
return 0;
}
<<<<<<< HEAD
SCWrite(pCon, "Driving finished successfully", eValue);
SetStatus(eOld);
=======
SCWrite(pCon, "Driving finished sucessfully", eValue);
>>>>>>> master
return 1;
}
@ -414,20 +418,21 @@ int RunWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
return 0;
}
<<<<<<< HEAD
/* interpret arguments as pairs name value and try to start */
SetStatus(eDriving);
=======
/* interprete arguments as pairs name value and try to start */
>>>>>>> master
for (i = 1; i < argc; i += 2) {
if (argv[i + 1] == NULL) {
snprintf(pBueffel,511, "ERROR: no value found for driving %s", argv[i]);
SCWrite(pCon, pBueffel, eError);
SetStatus(eOld);
return 0;
}
iRet = Tcl_GetDouble(tcl_interp, argv[i + 1], &dTarget);
if (iRet == TCL_ERROR) {
SCWrite(pCon, Tcl_GetStringResult(tcl_interp), eError);
StopExe(GetExecutor(), "ALL");
SetStatus(eOld);
return 0;
}
iRet = Start2Run(pCon, pSics, argv[i], RUNRUN, dTarget);
@ -436,13 +441,75 @@ int RunWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
argv[i + 1]);
SCWrite(pCon, pBueffel, eError);
StopExe(GetExecutor(), "ALL");
SetStatus(eOld);
return 0;
}
}
return 1;
}
/*---------------------------------------------------------------------------*/
int MoveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[])
{
Tcl_Interp *tcl_interp;
int iRet, i;
double dTarget;
float curPos;
char pBueffel[512];
Status eOld;
long groupID, taskID;
void *obj;
assert(pCon);
assert(pSics);
tcl_interp = InterpGetTcl(pSics);
/* check Status */
eOld = GetStatus();
/* check no of args */
if (argc < 3) {
snprintf(pBueffel,511, "Insufficient number of args. Usage %s name val",
argv[0]);
SCWrite(pCon, pBueffel, eError);
return 0;
}
/* check authorisation */
if (!SCMatchRights(pCon, usUser)) {
SCWrite(pCon,
"ERROR: You are not authorized to use the mv command",
eError);
return 0;
}
groupID = GetTaskGroupID(pServ->pTasker);
for (i = 1; i < argc; i += 2) {
if (argv[i + 1] == NULL) {
snprintf(pBueffel,511, "ERROR: no value found for driving %s", argv[i]);
SCWrite(pCon, pBueffel, eError);
return 0;
}
iRet = Tcl_GetDouble(tcl_interp, argv[i + 1], &dTarget);
if (iRet == TCL_ERROR) {
SCWrite(pCon, Tcl_GetStringResult(tcl_interp), eError);
StopExe(GetExecutor(), "ALL");
return 0;
}
obj = FindCommandData(pSics,argv[i],NULL);
if(obj == NULL || GetDrivableInterface(obj) == NULL){
SCPrintf(pCon,eError, "ERROR: %s not found, not started",argv[i]);
break;
}
GetDrivablePosition(obj,pCon,&curPos);
dTarget = curPos + dTarget;
taskID = StartDriveTask(obj, pCon, argv[i], (float)dTarget);
AddTaskToGroup(pServ->pTasker,taskID,groupID);
}
while(isTaskGroupRunning(pServ->pTasker,groupID)){
TaskYield(pServ->pTasker);
}
SCSendOK(pCon);
return 0;
}
/*---------------------------------------------------------------------------*/
int MakeDrive(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[])
@ -473,5 +540,17 @@ int MakeDrive(SConnection * pCon, SicsInterp * pSics, void *pData,
SCWrite(pCon, pBueffel, eError);
return 0;
}
if (argc > 3) {
iRet = AddCommand(pSics, argv[2], MoveWrapper, NULL, NULL);
} else {
iRet = AddCommand(pSics, "mv", MoveWrapper, NULL, NULL);
}
if (!iRet) {
sprintf(pBueffel, "ERROR: duplicate command mv not created");
SCWrite(pCon, pBueffel, eError);
return 0;
}
return 1;
}