merge work in progress
This commit is contained in:
33
motor.c
33
motor.c
@ -81,6 +81,7 @@
|
|||||||
#define IGNOREFAULT 10
|
#define IGNOREFAULT 10
|
||||||
#define MOVECOUNT 11
|
#define MOVECOUNT 11
|
||||||
|
|
||||||
|
extern double DoubleTime(void);
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
static void *MotorGetInterface(void *pData, int iID)
|
static void *MotorGetInterface(void *pData, int iID)
|
||||||
@ -344,8 +345,9 @@ static int checkPosition(pMotor self, SConnection * pCon)
|
|||||||
SCWrite(pCon, pBueffel, eWarning);
|
SCWrite(pCon, pBueffel, eWarning);
|
||||||
return HWFault;
|
return HWFault;
|
||||||
}
|
}
|
||||||
snprintf(pBueffel, 131, "WARNING: %s off position by %f",
|
snprintf(pBueffel, 131, "WARNING: %s off position by %f%s",
|
||||||
self->name, absf(fHard - self->fTarget));
|
self->name, absf(fHard - self->fTarget),
|
||||||
|
self->fTarget > fHard ? "-" : "");
|
||||||
SCWrite(pCon, pBueffel, eLog);
|
SCWrite(pCon, pBueffel, eLog);
|
||||||
status = statusRunTo(self, pCon);
|
status = statusRunTo(self, pCon);
|
||||||
return status;
|
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;
|
MotCallback sCall;
|
||||||
MotorGetSoftPosition(self, pCon, &sCall.fVal);
|
MotorGetSoftPosition(self, pCon, &sCall.fVal);
|
||||||
sCall.pName = self->name;
|
sCall.pName = self->name;
|
||||||
self->fPosition = sCall.fVal;
|
self->fPosition = sCall.fVal;
|
||||||
self->fPosition = sCall.fVal;
|
self->fPosition = sCall.fVal;
|
||||||
InvokeCallBack(self->pCall, MOTDRIVE, &sCall); /* send also very last position */
|
if (self->moving) {
|
||||||
InvokeCallBack(self->pCall, MOTEND, &sCall);
|
InvokeCallBack(self->pCall, MOTDRIVE, &sCall); /* send also very last position */
|
||||||
tracePar(self->name,"%f",sCall.fVal);
|
InvokeCallBack(self->pCall, MOTEND, &sCall);
|
||||||
|
tracePar(self->name,"%f",sCall.fVal);
|
||||||
|
}
|
||||||
|
self->moving = 0;
|
||||||
self->running = 0;
|
self->running = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,13 +471,15 @@ static void handleMoveCallback(pMotor self, SConnection * pCon)
|
|||||||
{
|
{
|
||||||
MotCallback sCall;
|
MotCallback sCall;
|
||||||
|
|
||||||
self->posCount++;
|
double current_time, skip_time;
|
||||||
if (self->posCount >= ObVal(self->ParArray, MOVECOUNT)) {
|
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);
|
MotorGetSoftPosition(self, pCon, &sCall.fVal);
|
||||||
sCall.pName = self->name;
|
sCall.pName = self->name;
|
||||||
InvokeCallBack(self->pCall, MOTDRIVE, &sCall);
|
InvokeCallBack(self->pCall, MOTDRIVE, &sCall);
|
||||||
tracePar(self->name,"%f",sCall.fVal);
|
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->posFaultCount = 0;
|
||||||
self->retryCount = 0;
|
self->retryCount = 0;
|
||||||
self->stopped = 0;
|
self->stopped = 0;
|
||||||
|
self->moving = 1;
|
||||||
self->fTarget = fHard;
|
self->fTarget = fHard;
|
||||||
InvokeCallBack(self->pCall, HDBVAL, self);
|
InvokeCallBack(self->pCall, HDBVAL, self);
|
||||||
|
self->last_report_time = 0.0;
|
||||||
self->posCount = 0;
|
self->posCount = 0;
|
||||||
iRet = self->pDriver->RunTo(self->pDriver, fHard);
|
iRet = self->pDriver->RunTo(self->pDriver, fHard);
|
||||||
if (iRet != OKOK) { /* try three times to fix it */
|
if (iRet != OKOK) { /* try three times to fix it */
|
||||||
@ -1066,7 +1075,10 @@ int MotorCreate(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* create the interpreter command */
|
/* create the interpreter command */
|
||||||
iRet = AddCommand(pSics, argv[1], MotorAction, MotorKill, pNew);
|
if (pNew->pActionRoutine)
|
||||||
|
iRet = AddCommand(pSics, argv[1], pNew->pActionRoutine, MotorKill, pNew);
|
||||||
|
else
|
||||||
|
iRet = AddCommand(pSics, argv[1], MotorAction, MotorKill, pNew);
|
||||||
if (!iRet) {
|
if (!iRet) {
|
||||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: duplicate command %s not created", argv[1]);
|
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: duplicate command %s not created", argv[1]);
|
||||||
SCWrite(pCon, pBueffel, eError);
|
SCWrite(pCon, pBueffel, eError);
|
||||||
@ -1287,6 +1299,7 @@ int MotorAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
}
|
}
|
||||||
pMoti->lastValue = fValue;
|
pMoti->lastValue = fValue;
|
||||||
|
|
||||||
|
RemoveCallbackCon(self->pCall, pCon);
|
||||||
lID = RegisterCallback(self->pCall, MOTDRIVE, InterestCallback,
|
lID = RegisterCallback(self->pCall, MOTDRIVE, InterestCallback,
|
||||||
pMoti, KillInfo);
|
pMoti, KillInfo);
|
||||||
DeleteTokenList(pList);
|
DeleteTokenList(pList);
|
||||||
|
5
motor.h
5
motor.h
@ -40,6 +40,9 @@ typedef struct __Motor {
|
|||||||
int stopReported;
|
int stopReported;
|
||||||
int errorCount;
|
int errorCount;
|
||||||
int running;
|
int running;
|
||||||
|
int moving;
|
||||||
|
double last_report_time;
|
||||||
|
ObjectFunc pActionRoutine;
|
||||||
ObPar *ParArray;
|
ObPar *ParArray;
|
||||||
void *pPrivate;
|
void *pPrivate;
|
||||||
void (*KillPrivate) (void *);
|
void (*KillPrivate) (void *);
|
||||||
@ -78,4 +81,6 @@ int MotorAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
int argc, char *argv[]);
|
int argc, char *argv[]);
|
||||||
pMotor FindMotor(SicsInterp * pSics, char *name);
|
pMotor FindMotor(SicsInterp * pSics, char *name);
|
||||||
|
|
||||||
|
/* Made available to oscillate.c to generate MOTEND event. Ferdi */
|
||||||
|
void finishDriving(pMotor self, SConnection *pCon);
|
||||||
#endif
|
#endif
|
||||||
|
@ -150,7 +150,6 @@ OBJ= site_ansto.o anstoutil.o\
|
|||||||
fsm.o \
|
fsm.o \
|
||||||
counterdriv.o \
|
counterdriv.o \
|
||||||
safetyplc.o \
|
safetyplc.o \
|
||||||
../psi/tcpdornier.o \
|
|
||||||
anstohttp.o \
|
anstohttp.o \
|
||||||
hmcontrol_ansto.o\
|
hmcontrol_ansto.o\
|
||||||
lssmonitor.o \
|
lssmonitor.o \
|
||||||
|
@ -21,7 +21,9 @@ Paul Barron, January 2008
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <rs232controller.h>
|
#include "obdes.h"
|
||||||
|
#include "conman.h"
|
||||||
|
#include "rs232controller.h"
|
||||||
#include "modbustcp.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)
|
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 \
|
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 \
|
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 \
|
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 \
|
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 \
|
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 \
|
fourtable.o fupa.o gpibcontroller.o help.o hipadaba.o \
|
||||||
histdriv.o histmem.o histregress.o histsim.o hklmot.o hkl.o hklscan.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 \
|
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 \
|
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 \
|
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 \
|
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 \
|
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 \
|
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);
|
/*@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 AddGalilProtocoll();
|
||||||
extern void AddModbusProtocoll();
|
extern void AddModbusProtocoll();
|
||||||
extern void AddOxfordProtocoll();
|
extern void AddOxfordProtocoll();
|
||||||
@ -139,7 +134,6 @@ static void AddCommands(SicsInterp *pInter)
|
|||||||
ORHVPSInitProtocol(pInter);
|
ORHVPSInitProtocol(pInter);
|
||||||
LS340InitProtocol(pInter);
|
LS340InitProtocol(pInter);
|
||||||
AddCommand(pInter,"InstallProtocolHandler", InstallProtocol,NULL,NULL);
|
AddCommand(pInter,"InstallProtocolHandler", InstallProtocol,NULL,NULL);
|
||||||
AddCommand(pInter,"MakeTCPSelector",VelSelTcpFactory,NULL,NULL);
|
|
||||||
AddCommand(pInter,"hostnam",hostNamCmd,NULL,NULL);
|
AddCommand(pInter,"hostnam",hostNamCmd,NULL,NULL);
|
||||||
AddCommand(pInter,"portnum",portNumCmd,NULL,NULL);
|
AddCommand(pInter,"portnum",portNumCmd,NULL,NULL);
|
||||||
AddCommand(pInter,"abortbatch",AbortBatch,NULL,NULL);
|
AddCommand(pInter,"abortbatch",AbortBatch,NULL,NULL);
|
||||||
@ -237,7 +231,7 @@ static pCodri CreateController(SConnection *pCon,int argc, char *argv[]){
|
|||||||
eError);
|
eError);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return MakeTcpDoChoDriver(argv[1], pCon);
|
return NULL;
|
||||||
}
|
}
|
||||||
return pNew;
|
return pNew;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user