Initial debugging

This commit is contained in:
Marty Kraimer
1991-06-27 15:26:54 +00:00
parent 553e949496
commit e3026844af
5 changed files with 88 additions and 43 deletions

View File

@@ -49,6 +49,7 @@
#include <waveformRecord.h>
long init_record();
long get_ioint_info();
long read_wf();
long arm_wf();
@@ -65,7 +66,7 @@ struct {
NULL,
NULL,
init_record,
NULL,
get_ioint_info,
read_wf};
/* control block for callback */
struct callback{
@@ -73,20 +74,11 @@ struct callback{
void (*process)();
};
/*
* Macro to access the Joerger memory using word addressing.
* Returns either byte of a short using only short word addressing
* this is necessary to avoid bus errors
*/
#define get_a_byte(a) (((long)a & 0x01)? \
(*(unsigned short *)(a-1) & 0xff) : (*(unsigned short *)(a) >> 8))
static void myCallback(pcallback,no_read,pdata)
struct callback *pcallback;
int no_read;
unsigned char *pdata;
unsigned short *pdata;
{
struct waveformRecord *pwf=
(struct waveformRecord *)(pcallback->dbAddr.precord);
@@ -96,22 +88,19 @@ static void myCallback(pcallback,no_read,pdata)
if(!pwf->busy) return;
dbScanLock(pwf);
pwf->busy = FALSE;
if(no_read>pwf->nelm)no_read = pwf->nelm;
if(ftvl==DBF_CHAR || ftvl==DBF_UCHAR) {
unsigned char source;
unsigned char *pdest=(unsigned char *)pwf->bptr;
for(i=0; i<no_read; i++) {
source = get_a_byte(pdata);
*pdest++ = source;
*pdest++ = *pdata++;
}
pwf->nord = no_read; /* number of values read */
} else if(ftvl==DBF_SHORT || ftvl==DBF_USHORT) {
unsigned char source;
unsigned short *pdest=(unsigned short *)pwf->bptr;
for(i=0; i<no_read; i++) {
source = get_a_byte(pdata);
*pdest++ = source;
*pdest++ = *pdata++;
}
pwf->nord = no_read; /* number of values read */
} else {
@@ -126,6 +115,20 @@ static void myCallback(pcallback,no_read,pdata)
(pcallback->process)(&pcallback->dbAddr);
dbScanUnlock(pwf);
}
static long get_ioint_info(pwf,io_type,card_type,card_number)
struct waveformRecord *pwf;
short *io_type;
short *card_type;
short *card_number;
{
if(pwf->inp.type != VME_IO) return(S_dev_badInpType);
*io_type = IO_WF;
*card_type = JGVTR1;
*card_number = pwf->inp.value.vmeio.card;
return(0);
}
static long init_record(pwf,process)
struct waveformRecord *pwf;
@@ -182,7 +185,6 @@ struct waveformRecord *pwf;
{
struct vmeio *pvmeio = (struct vmeio *)&(pwf->inp.value);
pwf->busy = TRUE;
if(wf_driver(JGVTR1,pvmeio->card,myCallback,pwf->dpvt)<0){
if(pwf->nsev<VALID_ALARM ) {
pwf->nsta = READ_ALARM;
@@ -192,5 +194,6 @@ struct waveformRecord *pwf;
pwf->busy = FALSE;
return(0);
}
pwf->busy = TRUE;
return(1);
}

View File

@@ -37,5 +37,6 @@ static long init()
{
int status;
time_driver_init();
return(0);
}

View File

@@ -138,6 +138,8 @@ void positional_sm();
void velocity_sm();
void sm_get_position();
static not_init_record=FALSE;
static long init_record(psm)
struct steppermotorRecord *psm;
@@ -155,6 +157,7 @@ static long process(paddr)
/* intialize the stepper motor record when the init bit is 0 */
/* the init is set when the readback returns */
not_init_record=TRUE;
if (psm->init == 0){
init_sm(psm);
tsLocalTime(&psm->time);
@@ -358,13 +361,29 @@ struct steppermotorRecord *psm;
{
short stat,sevr,nsta,nsev;
dbScanLock(psm);
if(psm->pact) {
dbScanUnlock(psm);
return;
}
psm->pact = TRUE;
tsLocalTime(&psm->time);
/*
printf("smcb_callback\n");
printf("%d %d %d %d %d %d %d %d %d\n",
psm_data->cw_limit,
psm_data->ccw_limit,
psm_data->moving,
psm_data->direction,
psm_data->constant_velocity,
psm_data->velocity,
psm_data->encoder_position,
psm_data->motor_position,
psm_data->accel
);
*/
if(not_init_record) {
dbScanLock(psm);
if(psm->pact) {
dbScanUnlock(psm);
return;
}
psm->pact = TRUE;
tsLocalTime(&psm->time);
} else psm->mlis.count=0;
if (psm->cmod == VELOCITY){
/* check velocity */
if (psm->rrbv != psm_data->velocity){
@@ -378,7 +397,7 @@ struct steppermotorRecord *psm;
/* direction */
if (psm->dir != psm_data->direction){
psm->dir == psm_data->direction;
psm->dir = psm_data->direction;
if (psm->mlis.count)
db_post_events(psm,&psm->dir,DBE_VALUE);
}
@@ -399,7 +418,7 @@ struct steppermotorRecord *psm;
/* direction */
if (psm->dir != psm_data->direction){
psm->dir == psm_data->direction;
psm->dir = psm_data->direction;
if (psm->mlis.count)
db_post_events(psm,&psm->dir,DBE_VALUE);
}
@@ -409,7 +428,7 @@ struct steppermotorRecord *psm;
/* use the quardrature encoding technique - if we use an encoder */
/* that does not, then we need to make quadrature encoder a database */
/* field and use the 4 on that condition !!!!! */
if (psm->epos != psm_data->encoder_position){
if (psm->epos){
psm->epos = (psm_data->encoder_position * psm->dist * psm->mres)
/ (psm->eres * 4);
if (psm->mlis.count)
@@ -445,8 +464,6 @@ struct steppermotorRecord *psm;
}
}
/* get the read back value */
sm_get_position(psm,psm_data->moving);
/* get previous stat and sevr and new stat and sevr*/
stat=psm->stat;
@@ -461,14 +478,13 @@ struct steppermotorRecord *psm;
/* anyone waiting for an event on this record */
if (psm->mlis.count!=0 && (stat!=nsta || sevr!=nsev) ){
db_post_events(psm,&psm->ccw,DBE_VALUE);
db_post_events(psm,&psm->cw,DBE_VALUE);
db_post_events(psm,&psm->val,DBE_VALUE|DBE_ALARM);
db_post_events(psm,&psm->rbv,DBE_VALUE|DBE_ALARM);
db_post_events(psm,&psm->stat,DBE_VALUE);
db_post_events(psm,&psm->sevr,DBE_VALUE);
}
/* get the read back value */
sm_get_position(psm,psm_data->moving);
/* needs to follow get position to prevent moves with old readback */
/* moving */
@@ -495,8 +511,10 @@ struct steppermotorRecord *psm;
}
}
}
psm->pact = FALSE;
dbScanUnlock(psm);
if(not_init_record) {
psm->pact = FALSE;
dbScanUnlock(psm);
}
return;
}
@@ -549,7 +567,7 @@ struct steppermotorRecord *psm;
sm_driver(psm->dtyp,card,channel,SM_CALLBACK,smcb_callback,psm);
/* initialize the limit values */
psm->cw = psm->ccw = -1;
psm->mcw = psm->mccw = -1;
/* set initial position */
if (psm->mode == POSITION){
@@ -559,6 +577,7 @@ struct steppermotorRecord *psm;
}else if (psm->ialg == NEGATIVE_LIMIT){
status = sm_driver(psm->dtyp,card,channel,SM_MOVE,-0x0fffffff,0);
}
psm->sthm = 1;
/* force a read of the position and status */
}else{
status = sm_driver(psm->dtyp,card,channel,SM_READ,0,0);
@@ -665,10 +684,11 @@ struct steppermotorRecord *psm;
if (psm->lval != psm->val){
psm->rcnt = 0;
psm->lval = psm->val;
psm->movn = 0; /* start moving to desired location */
psm->dmov = 0; /* start moving to desired location */
if (psm->mlis.count){
db_post_events(psm,&psm->rcnt,DBE_VALUE|DBE_LOG);
db_post_events(psm,&psm->lval,DBE_VALUE|DBE_LOG);
db_post_events(psm,&psm->dmov,DBE_VALUE|DBE_LOG);
}
}
@@ -717,10 +737,10 @@ struct steppermotorRecord *psm;
done_move = 1;
}
/* there was a move in progress and now it is complete */
if (done_move && (psm->movn == 0)){
psm->movn = 1;
if (done_move && (psm->dmov == 0)){
psm->dmov = 1;
if (psm->mlis.count)
db_post_events(psm,&psm->movn,DBE_VALUE|DBE_LOG);
db_post_events(psm,&psm->dmov,DBE_VALUE|DBE_LOG);
/* check for deviation from desired value */
alarm(psm);

View File

@@ -56,6 +56,7 @@
#include <errMdef.h>
#include <link.h>
#include <recSup.h>
#include <module_types.h>
#include <timerRecord.h>
/* Create RSET - Record Support Entry Table*/
@@ -98,9 +99,28 @@ struct rset timerRSET={
get_alarm_double };
/* because the driver does all the work just declare device support here*/
struct dset devTmMizar8310={4,NULL,NULL,NULL,NULL};
struct dset devTmDg535={4,NULL,NULL,NULL,NULL};
struct dset devTmVxiAt5={4,NULL,NULL,NULL,NULL};
long get_ioint_info();
struct dset devTmMizar8310={4,NULL,NULL,NULL,get_ioint_info};
struct dset devTmDg535={4,NULL,NULL,NULL,get_ioint_info};
struct dset devTmVxiAt5={4,NULL,NULL,NULL,get_ioint_info};
static long get_ioint_info(ptimer,io_type,card_type,card_number)
struct timerRecord *ptimer;
short *io_type;
short *card_type;
short *card_number;
{
if(ptimer->out.type != VME_IO) return(S_dev_badInpType);
*io_type = IO_TIMER;
if(ptimer->dtyp==0)
*card_type = MZ8310;
else if(ptimer->dtyp==3)
*card_type = VXI_AT5_TIME;
else
return(1);
*card_number = ptimer->out.value.vmeio.card;
return(0);
}
extern int post_event();

View File

@@ -174,6 +174,7 @@ static long process(paddr)
if (pwf->scan == E_IO_INTERRUPT){
if ((pwf->evnt != 0) && (gts_trigger_counter != 0)){
if ((gts_trigger_counter % pwf->evnt) != 0){
status=(*pdset->read_wf)(pwf);
return(0);
}
}