- Modified collective drive operations to run motors in individual tasks
- Added a processnode methos to scriptcontext. processnode waits for the scriptchain of a node to finish. - Fixed a bug in sicsget - Made histmemsec dim and rank manager privilege. To allow chnage at runtime. Is required for SANS - Fixed some issues with multicountersec, mostly relating to passing things through in a sensible way. - Updated motorsec.c to work with a client based driver SKIPPED: psi/polterwrite.c psi/tabledrive.c psi/tabledrive.h
This commit is contained in:
157
tasdrive.c
157
tasdrive.c
@ -5,12 +5,14 @@
|
||||
|
||||
Mark Koennecke, May 2005
|
||||
|
||||
In the long run it might be useful to switch all this to the more
|
||||
general motor list driving code.
|
||||
|
||||
Modified to rather use drivables then motors
|
||||
|
||||
Mark Koennecke, September 2011
|
||||
|
||||
Modified to use drive tasks
|
||||
|
||||
Mark Koennecke, January 2014
|
||||
--------------------------------------------------------------------*/
|
||||
#include <assert.h>
|
||||
#include "sics.h"
|
||||
@ -72,7 +74,12 @@ int readTASMotAngles(ptasUB self, SConnection * pCon,
|
||||
if (status == 0) {
|
||||
return status;
|
||||
}
|
||||
theta = val;
|
||||
theta = val;/* $Id: tasdrive.c,v 1.39 2014/02/18 13:25:32 koennecke Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
static char vcid[] = "$Id: tasdrive.c,v 1.39 2014/02/18 13:25:32 koennecke Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
status = GetDrivablePosition(self->motors[A2], pCon, &val);
|
||||
if (status == 0) {
|
||||
return status;
|
||||
@ -274,7 +281,7 @@ static float getMotorValue(pMotor mot, SConnection * pCon)
|
||||
void InvokeNewTarget(pExeList self, char *name, float target);
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int startTASMotor(pMotor mot, SConnection * pCon, char *name,
|
||||
double target, int silent, int stopFixed)
|
||||
double target, int silent, int stopFixed, long groupID)
|
||||
{
|
||||
float val, fixed, precision = MOTPREC;
|
||||
int status = OKOK;
|
||||
@ -282,6 +289,7 @@ static int startTASMotor(pMotor mot, SConnection * pCon, char *name,
|
||||
pIDrivable pDriv = NULL;
|
||||
pDummy dum = NULL;
|
||||
pDynString mes = NULL;
|
||||
long taskID;
|
||||
|
||||
dum = (pDummy)mot;
|
||||
val = getMotorValue(mot, pCon);
|
||||
@ -298,10 +306,11 @@ static int startTASMotor(pMotor mot, SConnection * pCon, char *name,
|
||||
}
|
||||
mot->stopped = 0;
|
||||
if (ABS(val - target) > precision) {
|
||||
pDriv = GetDrivableInterface(mot);
|
||||
status = pDriv->SetValue(mot, pCon, (float) target);
|
||||
if(status != OKOK){
|
||||
taskID = StartDriveTask(mot,pCon,name,target);
|
||||
if(taskID < 0){
|
||||
SCPrintf(pCon,eLog,"ERROR: failed to drive %s to %f", name, target);
|
||||
} else {
|
||||
AddTaskToGroup(pServ->pTasker,taskID, groupID);
|
||||
}
|
||||
/*
|
||||
to force updates on targets
|
||||
@ -313,7 +322,8 @@ static int startTASMotor(pMotor mot, SConnection * pCon, char *name,
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int StartTASA3(pMotor mot, SConnection *pCon, char *name,
|
||||
double target, int silent, int stopFixed)
|
||||
double target, int silent, int stopFixed,
|
||||
long groupID)
|
||||
{
|
||||
float val;
|
||||
int status;
|
||||
@ -326,14 +336,14 @@ static int StartTASA3(pMotor mot, SConnection *pCon, char *name,
|
||||
status = SCPromptTMO(pCon,NULL,buffer,sizeof(buffer),120);
|
||||
if(status == 1){
|
||||
if(buffer[0] == 'y'){
|
||||
return startTASMotor(mot,pCon,name,target,silent,stopFixed);
|
||||
return startTASMotor(mot,pCon,name,target,silent,stopFixed,groupID);
|
||||
}
|
||||
}
|
||||
SCWrite(pCon,"ERROR: no or wrong reply, aborting scan",eLogError);
|
||||
SCSetInterrupt(pCon,eAbortScan);
|
||||
return HWFault;
|
||||
} else {
|
||||
return startTASMotor(mot,pCon,name,target,silent,stopFixed);
|
||||
return startTASMotor(mot,pCon,name,target,silent,stopFixed,groupID);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -346,6 +356,9 @@ static int startMotors(ptasMot self, tasAngles angles,
|
||||
silent = self->math->silent;
|
||||
stopFixed = self->math->stopFixed;
|
||||
self->math->mustRecalculate = 1;
|
||||
|
||||
self->math->groupID = GetTaskGroupID(pServ->pTasker);
|
||||
|
||||
/*
|
||||
monochromator
|
||||
*/
|
||||
@ -353,6 +366,8 @@ static int startMotors(ptasMot self, tasAngles angles,
|
||||
pCon,angles.monochromator_two_theta);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
} else {
|
||||
AddTaskToGroup(pServ->pTasker, self->math->monoTaskID, self->math->groupID);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -360,12 +375,12 @@ static int startMotors(ptasMot self, tasAngles angles,
|
||||
*/
|
||||
if (self->math->tasMode != ELASTIC) {
|
||||
status = startTASMotor(self->math->motors[A5], pCon, "a5",
|
||||
angles.analyzer_two_theta / 2.0, silent,stopFixed);
|
||||
angles.analyzer_two_theta / 2.0, silent,stopFixed,self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
return status;
|
||||
}
|
||||
status = startTASMotor(self->math->motors[A6], pCon, "a6",
|
||||
angles.analyzer_two_theta, silent,stopFixed);
|
||||
angles.analyzer_two_theta, silent,stopFixed,self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
return status;
|
||||
}
|
||||
@ -374,7 +389,7 @@ static int startMotors(ptasMot self, tasAngles angles,
|
||||
curve = maCalcVerticalCurvature(self->math->machine.analyzer,
|
||||
angles.analyzer_two_theta);
|
||||
status = startTASMotor(self->math->motors[ACV], pCon, "acv",
|
||||
curve, silent,stopFixed);
|
||||
curve, silent,stopFixed,self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
SCWrite(pCon,"WARNING: analyzer vertical curvature motor failed to start", eLog);
|
||||
SCSetInterrupt(pCon,eContinue);
|
||||
@ -384,7 +399,7 @@ static int startMotors(ptasMot self, tasAngles angles,
|
||||
curve = maCalcHorizontalCurvature(self->math->machine.analyzer,
|
||||
angles.analyzer_two_theta);
|
||||
status = startTASMotor(self->math->motors[ACH], pCon, "ach",
|
||||
curve, silent,stopFixed);
|
||||
curve, silent,stopFixed,self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
SCWrite(pCon,"WARNING: analyzer horizontal curvature motor failed to start", eLog);
|
||||
SCSetInterrupt(pCon,eContinue);
|
||||
@ -400,24 +415,24 @@ static int startMotors(ptasMot self, tasAngles angles,
|
||||
crystal
|
||||
*/
|
||||
status = StartTASA3(self->math->motors[A3], pCon, "a3",
|
||||
angles.a3, silent,stopFixed);
|
||||
angles.a3, silent,stopFixed,self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
return status;
|
||||
}
|
||||
status = startTASMotor(self->math->motors[A4], pCon, "a4",
|
||||
angles.sample_two_theta, silent,stopFixed);
|
||||
angles.sample_two_theta, silent,stopFixed,self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (driveTilt == 1) {
|
||||
status = startTASMotor(self->math->motors[SGL], pCon, "sgl",
|
||||
angles.sgl, silent,stopFixed);
|
||||
angles.sgl, silent,stopFixed, self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
return status;
|
||||
}
|
||||
status = startTASMotor(self->math->motors[SGU], pCon, "sgu",
|
||||
angles.sgu, silent,stopFixed);
|
||||
angles.sgu, silent,stopFixed,self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
return status;
|
||||
}
|
||||
@ -566,60 +581,12 @@ static int calculateAndDrive(ptasMot self, SConnection * pCon)
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
static int checkMotors(ptasMot self, SConnection * pCon)
|
||||
{
|
||||
int i, status, length = 12, count;
|
||||
int mask[12], busy[12];
|
||||
pIDrivable pDrivInt = NULL;
|
||||
|
||||
self->math->mustRecalculate = 1;
|
||||
if (self->math->tasMode == ELASTIC) {
|
||||
length = 8;
|
||||
}
|
||||
memset(mask, 0, 12 * sizeof(int));
|
||||
memset(busy, 0, 12 * sizeof(int));
|
||||
for (i = 0; i < length; i++) {
|
||||
mask[i] = 1;
|
||||
busy[i] = 1;
|
||||
}
|
||||
if (self->math->outOfPlaneAllowed == 0) {
|
||||
mask[SGU] = 0;
|
||||
mask[SGL] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
check monochromator
|
||||
*/
|
||||
status = self->math->mono->CheckStatus(self->math->monoData,pCon);
|
||||
if(status == HWIdle){
|
||||
for(i = 0; i < 4; i++){
|
||||
busy[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
check the rest
|
||||
*/
|
||||
for (i = 4; i < 12; i++) {
|
||||
if(self->math->motors[i] == NULL){
|
||||
busy[i] = 0;
|
||||
} else {
|
||||
if(mask[i] != 0) {
|
||||
pDrivInt = GetDrivableInterface(self->math->motors[i]);
|
||||
status = pDrivInt->CheckStatus(self->math->motors[i], pCon);
|
||||
if(status == HWIdle || status == OKOK || status == HWFault || status == HWPosFault){
|
||||
busy[i] = 0;
|
||||
}
|
||||
} else {
|
||||
busy[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(i = 0, count = 0; i < 12; i++){
|
||||
count += busy[i];
|
||||
}
|
||||
if(count == 0) {
|
||||
return HWIdle;
|
||||
} else {
|
||||
if(isTaskGroupRunning(pServ->pTasker,self->math->groupID)){
|
||||
return HWBusy;
|
||||
} else {
|
||||
return HWIdle;
|
||||
}
|
||||
}
|
||||
|
||||
@ -653,42 +620,18 @@ static int startQMMotors(ptasMot self, tasAngles angles,
|
||||
|
||||
silent = self->math->silent;
|
||||
stopFixed = self->math->stopFixed;
|
||||
|
||||
self->math->groupID = GetTaskGroupID(pServ->pTasker);
|
||||
|
||||
/*
|
||||
monochromator
|
||||
*/
|
||||
/* status = startTASMotor(self->math->motors[A1], pCon, "a1", */
|
||||
/* angles.monochromator_two_theta / 2., silent,stopFixed); */
|
||||
/* if (status != OKOK) { */
|
||||
/* return status; */
|
||||
/* } */
|
||||
/* status = startTASMotor(self->math->motors[A2], pCon, "a2", */
|
||||
/* angles.monochromator_two_theta, silent,stopFixed); */
|
||||
/* if (status != OKOK) { */
|
||||
/* return status; */
|
||||
/* } */
|
||||
|
||||
/* if (self->math->motors[MCV] != NULL) { */
|
||||
/* curve = maCalcVerticalCurvature(self->math->machine.monochromator, */
|
||||
/* angles.monochromator_two_theta); */
|
||||
/* status = startTASMotor(self->math->motors[MCV], pCon, "mcv", */
|
||||
/* curve, silent,stopFixed); */
|
||||
/* if (status != OKOK) { */
|
||||
/* return status; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* if (self->math->motors[MCH] != NULL) { */
|
||||
/* curve = maCalcHorizontalCurvature(self->math->machine.monochromator, */
|
||||
/* angles.monochromator_two_theta); */
|
||||
/* status = startTASMotor(self->math->motors[MCH], pCon, "mch", */
|
||||
/* curve, silent,stopFixed); */
|
||||
/* if (status != OKOK) { */
|
||||
/* return status; */
|
||||
/* } */
|
||||
/* } */
|
||||
status = self->math->mono->SetValue(self->math->monoData,pCon,angles.analyzer_two_theta);
|
||||
monochromator
|
||||
*/
|
||||
status = self->math->mono->SetValue(self->math->monoData,
|
||||
pCon,angles.monochromator_two_theta);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
} else {
|
||||
AddTaskToGroup(pServ->pTasker, self->math->monoTaskID, self->math->groupID);
|
||||
}
|
||||
|
||||
|
||||
@ -696,12 +639,12 @@ static int startQMMotors(ptasMot self, tasAngles angles,
|
||||
analyzer
|
||||
*/
|
||||
status = startTASMotor(self->math->motors[A5], pCon, "a5",
|
||||
angles.analyzer_two_theta / 2.0, silent,stopFixed);
|
||||
angles.analyzer_two_theta / 2.0, silent,stopFixed,self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
return status;
|
||||
}
|
||||
status = startTASMotor(self->math->motors[A6], pCon, "a6",
|
||||
angles.analyzer_two_theta, silent,stopFixed);
|
||||
angles.analyzer_two_theta, silent,stopFixed,self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
return status;
|
||||
}
|
||||
@ -710,7 +653,7 @@ static int startQMMotors(ptasMot self, tasAngles angles,
|
||||
curve = maCalcVerticalCurvature(self->math->machine.analyzer,
|
||||
angles.analyzer_two_theta);
|
||||
status = startTASMotor(self->math->motors[ACV], pCon, "acv",
|
||||
curve, silent,stopFixed);
|
||||
curve, silent,stopFixed,self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
return status;
|
||||
}
|
||||
@ -719,7 +662,7 @@ static int startQMMotors(ptasMot self, tasAngles angles,
|
||||
curve = maCalcHorizontalCurvature(self->math->machine.analyzer,
|
||||
angles.analyzer_two_theta);
|
||||
status = startTASMotor(self->math->motors[ACH], pCon, "ach",
|
||||
curve, silent,stopFixed);
|
||||
curve, silent,stopFixed,self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
return status;
|
||||
}
|
||||
@ -729,7 +672,7 @@ static int startQMMotors(ptasMot self, tasAngles angles,
|
||||
crystal
|
||||
*/
|
||||
status = startTASMotor(self->math->motors[A4], pCon, "a4",
|
||||
angles.sample_two_theta, silent,stopFixed);
|
||||
angles.sample_two_theta, silent,stopFixed,self->math->groupID);
|
||||
if (status != OKOK) {
|
||||
return status;
|
||||
}
|
||||
|
Reference in New Issue
Block a user