- Fixed bugs in sinqhttp.c, most notatbly the unknown error on hm init
- Added first slit to amorset - Added untested code for the POLDI strees machine
This commit is contained in:
66
tabledrive.c
66
tabledrive.c
@@ -10,11 +10,13 @@
|
||||
#include "../lld.h"
|
||||
#include "tabledrive.h"
|
||||
/*--------------------------------------------------------------------------*/
|
||||
#define OUTOFSYNC 100
|
||||
#define STARTING 101
|
||||
#define STEPPING 102
|
||||
#define WAITING 103
|
||||
#define OUTOFSYNC 100
|
||||
#define STARTING 101
|
||||
#define STEPPING 102
|
||||
#define WAITING 103
|
||||
#define WAITFINISH 104
|
||||
#define IDLE 105
|
||||
|
||||
#define ABS(x) (x < 0 ? -(x) : (x))
|
||||
#define SIGN(x) (x < .0 ? (-1) : (1))
|
||||
extern char *trim(char *txt);
|
||||
@@ -182,6 +184,10 @@ static void checkSync(pTableDrive self, SConnection *pCon, float value){
|
||||
float motorPosition, targetPosition, tolerance, diff;
|
||||
tdMotor moti;
|
||||
char pBueffel[256];
|
||||
|
||||
if(self->state != IDLE){
|
||||
return;
|
||||
}
|
||||
|
||||
status = LLDnodePtr2First(self->motorTable);
|
||||
while(status != 0){
|
||||
@@ -224,6 +230,36 @@ static float TableDriveGetValue(void *pData, SConnection *pCon){
|
||||
self->currentPosition = value;
|
||||
return value;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static void tableInfo(pTableDrive self, SConnection *pCon){
|
||||
int status, test;
|
||||
float motorPosition, targetPosition, tolerance, diff, value;
|
||||
tdMotor moti;
|
||||
char pBueffel[256];
|
||||
|
||||
value = TableDriveGetValue(self,pCon);
|
||||
snprintf(pBueffel,255," Triffid Position: %8.2f", value);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
|
||||
status = LLDnodePtr2First(self->motorTable);
|
||||
while(status != 0){
|
||||
LLDnodeDataTo(self->motorTable,&moti);
|
||||
test = MotorGetSoftPosition(moti.pMot,pCon,&motorPosition);
|
||||
if(!test){
|
||||
snprintf(pBueffel,255,"ERROR: failed to read motor %s",
|
||||
moti.motorName);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
} else {
|
||||
MotorGetPar(moti.pMot,"precision",&tolerance);
|
||||
targetPosition = findTarget(moti,value);
|
||||
snprintf(pBueffel,256,"Motor %10s, should: %8.2f, is %8.2f, diff = %8.2f",
|
||||
moti.motorName, motorPosition, targetPosition,
|
||||
ABS(targetPosition - motorPosition));
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
}
|
||||
status = LLDnodePtr2Next(self->motorTable);
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static void tableSetPar(pMotor pMot, char *name, float value){
|
||||
ObPar *ob = NULL;
|
||||
@@ -401,6 +437,7 @@ static int TableDriveCheckStatus(void *pData, SConnection *pCon){
|
||||
if(status != HWBusy){
|
||||
TableDriveGetValue(self,pCon);
|
||||
closeMotors(self,pCon);
|
||||
self->state = IDLE;
|
||||
return status;
|
||||
} else {
|
||||
return HWBusy;
|
||||
@@ -408,6 +445,7 @@ static int TableDriveCheckStatus(void *pData, SConnection *pCon){
|
||||
break;
|
||||
case OUTOFSYNC:
|
||||
SCWrite(pCon,"WARNING: tabledrive out of sync",eWarning);
|
||||
self->state = IDLE;
|
||||
return HWFault;
|
||||
break;
|
||||
default:
|
||||
@@ -579,6 +617,7 @@ int TableDriveFactory(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
killTableDrive(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->state = IDLE;
|
||||
|
||||
status = AddCommand(pSics,argv[1],
|
||||
TableDriveAction,
|
||||
@@ -599,7 +638,8 @@ int TableDriveAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
pTableDrive self = (pTableDrive)pData;
|
||||
int status;
|
||||
char pBueffel[1024];
|
||||
float value;
|
||||
float value;
|
||||
pDynString print = NULL;
|
||||
|
||||
if(argc < 2){
|
||||
value = TableDriveGetValue(self,pCon);
|
||||
@@ -626,10 +666,18 @@ int TableDriveAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
return status;
|
||||
}else if(strcmp(argv[1],"show") == 0){
|
||||
showPositions(self,pCon,pBueffel,1023);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}else if(strcmp(argv[1],"show") == 0){
|
||||
showPositions(self,pCon,pBueffel,1023);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}else if(strcmp(argv[1],"info") == 0){
|
||||
SCStartBuffering(pCon);
|
||||
tableInfo(self,pCon);
|
||||
print = SCEndBuffering(pCon);
|
||||
if(print != NULL){
|
||||
SCWrite(pCon,GetCharArray(print), eValue);
|
||||
}
|
||||
return 1;
|
||||
}else if(strcmp(argv[1],"orient") == 0){
|
||||
if(argc > 2){
|
||||
if(!SCMatchRights(pCon,usMugger)){
|
||||
|
||||
Reference in New Issue
Block a user