merge work in progress
This commit is contained in:
25
motor.c
25
motor.c
@ -81,6 +81,7 @@
|
||||
#define IGNOREFAULT 10
|
||||
#define MOVECOUNT 11
|
||||
|
||||
extern double DoubleTime(void);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static void *MotorGetInterface(void *pData, int iID)
|
||||
@ -344,8 +345,9 @@ static int checkPosition(pMotor self, SConnection * pCon)
|
||||
SCWrite(pCon, pBueffel, eWarning);
|
||||
return HWFault;
|
||||
}
|
||||
snprintf(pBueffel, 131, "WARNING: %s off position by %f",
|
||||
self->name, absf(fHard - self->fTarget));
|
||||
snprintf(pBueffel, 131, "WARNING: %s off position by %f%s",
|
||||
self->name, absf(fHard - self->fTarget),
|
||||
self->fTarget > fHard ? "-" : "");
|
||||
SCWrite(pCon, pBueffel, eLog);
|
||||
status = statusRunTo(self, pCon);
|
||||
return status;
|
||||
@ -354,16 +356,19 @@ static int checkPosition(pMotor self, SConnection * pCon)
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
static void finishDriving(pMotor self, SConnection * pCon)
|
||||
void finishDriving(pMotor self, SConnection * pCon)
|
||||
{
|
||||
MotCallback sCall;
|
||||
MotorGetSoftPosition(self, pCon, &sCall.fVal);
|
||||
sCall.pName = self->name;
|
||||
self->fPosition = sCall.fVal;
|
||||
self->fPosition = sCall.fVal;
|
||||
if (self->moving) {
|
||||
InvokeCallBack(self->pCall, MOTDRIVE, &sCall); /* send also very last position */
|
||||
InvokeCallBack(self->pCall, MOTEND, &sCall);
|
||||
tracePar(self->name,"%f",sCall.fVal);
|
||||
}
|
||||
self->moving = 0;
|
||||
self->running = 0;
|
||||
}
|
||||
|
||||
@ -466,13 +471,15 @@ static void handleMoveCallback(pMotor self, SConnection * pCon)
|
||||
{
|
||||
MotCallback sCall;
|
||||
|
||||
self->posCount++;
|
||||
if (self->posCount >= ObVal(self->ParArray, MOVECOUNT)) {
|
||||
double current_time, skip_time;
|
||||
current_time = DoubleTime();
|
||||
skip_time = 0.001 * ObVal(self->ParArray,MOVECOUNT);
|
||||
if(self->last_report_time + skip_time <= current_time) {
|
||||
MotorGetSoftPosition(self, pCon, &sCall.fVal);
|
||||
sCall.pName = self->name;
|
||||
InvokeCallBack(self->pCall, MOTDRIVE, &sCall);
|
||||
tracePar(self->name,"%f",sCall.fVal);
|
||||
self->posCount = 0;
|
||||
self->last_report_time = current_time;
|
||||
}
|
||||
}
|
||||
|
||||
@ -738,8 +745,10 @@ static long MotorRunImpl(void *sulf, SConnection * pCon, float fNew)
|
||||
self->posFaultCount = 0;
|
||||
self->retryCount = 0;
|
||||
self->stopped = 0;
|
||||
self->moving = 1;
|
||||
self->fTarget = fHard;
|
||||
InvokeCallBack(self->pCall, HDBVAL, self);
|
||||
self->last_report_time = 0.0;
|
||||
self->posCount = 0;
|
||||
iRet = self->pDriver->RunTo(self->pDriver, fHard);
|
||||
if (iRet != OKOK) { /* try three times to fix it */
|
||||
@ -1066,6 +1075,9 @@ int MotorCreate(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
}
|
||||
|
||||
/* create the interpreter command */
|
||||
if (pNew->pActionRoutine)
|
||||
iRet = AddCommand(pSics, argv[1], pNew->pActionRoutine, MotorKill, pNew);
|
||||
else
|
||||
iRet = AddCommand(pSics, argv[1], MotorAction, MotorKill, pNew);
|
||||
if (!iRet) {
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: duplicate command %s not created", argv[1]);
|
||||
@ -1287,6 +1299,7 @@ int MotorAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
}
|
||||
pMoti->lastValue = fValue;
|
||||
|
||||
RemoveCallbackCon(self->pCall, pCon);
|
||||
lID = RegisterCallback(self->pCall, MOTDRIVE, InterestCallback,
|
||||
pMoti, KillInfo);
|
||||
DeleteTokenList(pList);
|
||||
|
5
motor.h
5
motor.h
@ -40,6 +40,9 @@ typedef struct __Motor {
|
||||
int stopReported;
|
||||
int errorCount;
|
||||
int running;
|
||||
int moving;
|
||||
double last_report_time;
|
||||
ObjectFunc pActionRoutine;
|
||||
ObPar *ParArray;
|
||||
void *pPrivate;
|
||||
void (*KillPrivate) (void *);
|
||||
@ -78,4 +81,6 @@ int MotorAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
int argc, char *argv[]);
|
||||
pMotor FindMotor(SicsInterp * pSics, char *name);
|
||||
|
||||
/* Made available to oscillate.c to generate MOTEND event. Ferdi */
|
||||
void finishDriving(pMotor self, SConnection *pCon);
|
||||
#endif
|
||||
|
@ -150,7 +150,6 @@ OBJ= site_ansto.o anstoutil.o\
|
||||
fsm.o \
|
||||
counterdriv.o \
|
||||
safetyplc.o \
|
||||
../psi/tcpdornier.o \
|
||||
anstohttp.o \
|
||||
hmcontrol_ansto.o\
|
||||
lssmonitor.o \
|
||||
|
@ -21,7 +21,9 @@ Paul Barron, January 2008
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <rs232controller.h>
|
||||
#include "obdes.h"
|
||||
#include "conman.h"
|
||||
#include "rs232controller.h"
|
||||
#include "modbustcp.h"
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
@ -1,17 +1,17 @@
|
||||
# vim: ft=make ts=4 sw=4 noet ciident
|
||||
# vim: ft=make ts=4 sw=4 noet cindent
|
||||
COBJ = Sclient.o network.o ifile.o intcli.o $(FORTIFYOBJ)
|
||||
SOBJ = access.o alias.o anticollider.o ascon.o asyncprotocol.o asyncqueue.o callback.o \
|
||||
cell.o chadapter.o choco.o circular.o commandlog.o cone.o confvirtualmot.o \
|
||||
conman.o costa.o danu.o definealias.o devexec.o devser.o diffscan.o d_mod.o \
|
||||
drive.o d_sign.o dynstring.o emon.o errormsg.o evcontroller.o evdriver.o \
|
||||
event.o exebuf.o exeman.o fitcenter.o fomerge.o $(FORTIFYOBJ) fourlib.o \
|
||||
fourtable.o fupa.o genericcontroller.o gpibcontroller.o help.o hipadaba.o \
|
||||
histdriv.o histmem.o histregress.o histsim.o hklmot.o hkl.o hklscan.o \
|
||||
fourtable.o fupa.o gpibcontroller.o help.o hipadaba.o \
|
||||
histdriv.o histmem.o histregress.o histsim.o hklmot.o hkl.o \
|
||||
hmcontrol.o hmdata.o hmslave.o ifile.o initializer.o integrate.o interface.o \
|
||||
intserv.o lin2ang.o lld_blob.o lld.o logger.o logreader.o logsetup.o lomax.o \
|
||||
macro.o maximize.o mccontrol.o mcreader.o mcstascounter.o mcstashm.o mesure.o \
|
||||
macro.o maximize.o mccontrol.o mcreader.o mcstascounter.o mcstashm.o \
|
||||
moregress.o motorlist.o motreglist.o motreg.o multicounter.o mumoconf.o mumo.o \
|
||||
napi5.o napi.o network.o $(NIOBJ) nread.o nserver.o nwatch.o nxcopy.o nxdata.o \
|
||||
napi5.o napi.o network.o $(NIOBJ) nread.o nserver.o nwatch.o nxcopy.o \
|
||||
nxdataset.o nxdict.o nxinterhelper.o nxinter_wrap.o nxio.o nxscript.o nxstack.o \
|
||||
nxupdate.o nxutil.o nxxml.o o2t.o obdes.o obpar.o ofac.o optimise.o oscillate.o \
|
||||
passwd.o perfmon.o polldriv.o protocol.o proxy.o regresscter.o remob.o \
|
||||
|
@ -50,11 +50,6 @@
|
||||
|
||||
/*@observer@*//*@null@*/ pCounterDriver CreateMonCounter(/*@observer@*/SConnection *pCon, /*@observer@*/char *name, char *params);
|
||||
|
||||
/*
|
||||
from tcpdornier.c
|
||||
*/
|
||||
extern int VelSelTcpFactory(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]);
|
||||
extern pCodri MakeTcpDoChoDriver(char *tclArray, SConnection *pCon);
|
||||
extern void AddGalilProtocoll();
|
||||
extern void AddModbusProtocoll();
|
||||
extern void AddOxfordProtocoll();
|
||||
@ -139,7 +134,6 @@ static void AddCommands(SicsInterp *pInter)
|
||||
ORHVPSInitProtocol(pInter);
|
||||
LS340InitProtocol(pInter);
|
||||
AddCommand(pInter,"InstallProtocolHandler", InstallProtocol,NULL,NULL);
|
||||
AddCommand(pInter,"MakeTCPSelector",VelSelTcpFactory,NULL,NULL);
|
||||
AddCommand(pInter,"hostnam",hostNamCmd,NULL,NULL);
|
||||
AddCommand(pInter,"portnum",portNumCmd,NULL,NULL);
|
||||
AddCommand(pInter,"abortbatch",AbortBatch,NULL,NULL);
|
||||
@ -237,7 +231,7 @@ static pCodri CreateController(SConnection *pCon,int argc, char *argv[]){
|
||||
eError);
|
||||
return NULL;
|
||||
}
|
||||
return MakeTcpDoChoDriver(argv[1], pCon);
|
||||
return NULL;
|
||||
}
|
||||
return pNew;
|
||||
}
|
||||
|
Reference in New Issue
Block a user