- various small bugfixes
- added driver for the lock-in amplifier
This commit is contained in:
140
linadriv.c
Normal file
140
linadriv.c
Normal file
@@ -0,0 +1,140 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
linadriv.c
|
||||
|
||||
Driver for the Lock IN Amplifier SIGNAL RECOVERY Model 7265
|
||||
|
||||
Markus Zolliker, Oct 2006
|
||||
----------------------------------------------------------------------------*/
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <sys/time.h>
|
||||
#include <math.h>
|
||||
#include <tcl.h>
|
||||
#include <fortify.h>
|
||||
#include <sics.h>
|
||||
#include <splitter.h>
|
||||
#include <obpar.h>
|
||||
#include <devexec.h>
|
||||
#include <nserver.h>
|
||||
#include <interrupt.h>
|
||||
#include <emon.h>
|
||||
#include <evcontroller.h>
|
||||
#include <evcontroller.i>
|
||||
#include <servlog.h>
|
||||
#include <sicsvar.h>
|
||||
#include <evdriver.i>
|
||||
#include <rs232controller.h>
|
||||
#include "linahdl.h"
|
||||
#include "fsm.h"
|
||||
#include "initializer.h"
|
||||
|
||||
typedef struct {
|
||||
EaseDriv d;
|
||||
float x, y;
|
||||
} Lina;
|
||||
|
||||
static ParClass linaClass = { "LINA", sizeof(Lina) };
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static void LinaParDef(void *object) {
|
||||
Lina *drv = ParCast(&linaClass, object);
|
||||
EaseBase *eab = object;
|
||||
|
||||
ParName(""); ParTail("units");
|
||||
ParFloat(&drv->x, PAR_NAN);
|
||||
|
||||
ParName("x"); ParTail("");
|
||||
ParFloat(&drv->x, PAR_NAN);
|
||||
|
||||
ParName("y"); ParTail("");
|
||||
ParFloat(&drv->y, PAR_NAN);
|
||||
|
||||
EaseBasePar(drv);
|
||||
EaseSendPar(drv);
|
||||
/*
|
||||
EaseDrivPar(drv, "%.5g", "K");
|
||||
*/
|
||||
ParStdDef();
|
||||
EaseMsgPar(drv);
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static long LinaRead(long pc, void *object) {
|
||||
Lina *drv = ParCast(&linaClass, object);
|
||||
EaseBase *eab = object;
|
||||
char *p;
|
||||
|
||||
switch (pc) { default: /* FSM BEGIN *******************************/
|
||||
EaseWrite(eab, "XY.");
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
p = strchr(eab->ans, ',');
|
||||
if (p) {
|
||||
*p='\0';
|
||||
p++;
|
||||
drv->x = atof(eab->ans);
|
||||
drv->y = atof(p);
|
||||
}
|
||||
ParLog(drv);
|
||||
fsm_quit: return 0; } /* FSM END *********************************/
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static long LinaStart(long pc, void *object) {
|
||||
Lina *drv = ParCast(&linaClass, object);
|
||||
EaseBase *eab = object;
|
||||
|
||||
switch (pc) { default: /* FSM BEGIN *******************************/
|
||||
EaseWrite(eab, "ID");
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
if (0 != strncmp(eab->version, "7265", 4)) {
|
||||
snprintf(eab->msg, sizeof eab->msg, "unknown lock in amplifier version: %s",
|
||||
eab->version);
|
||||
ParPrintf(drv, eError, "ERROR: %s", eab->msg);
|
||||
EaseStop(eab);
|
||||
goto quit;
|
||||
}
|
||||
ParPrintf(drv, eStatus, "connected to %s", eab->version);
|
||||
FsmCall(LinaRead);
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
|
||||
quit:
|
||||
return 0; } /* FSM END ********************************************/
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static long LinaSet(long pc, void *object) {
|
||||
Lina *drv = ParCast(&linaClass, object);
|
||||
EaseBase *eab = object;
|
||||
char cmd[32];
|
||||
int upd;
|
||||
|
||||
switch (pc) { default: /* FSM BEGIN *******************************/
|
||||
/*
|
||||
snprintf(cmd, sizeof cmd, "SETP %.5g;SETP?", drv->d.targetValue);
|
||||
EaseWrite(eab, cmd);
|
||||
*/
|
||||
quit:
|
||||
return 0; } /* FSM END ********************************************/
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int LinaInit(SConnection *con, int argc, char *argv[], int dynamic) {
|
||||
/* args:
|
||||
MakeObject objectname lina <rs232>
|
||||
MakeObject objectname lina <host> <port>
|
||||
*/
|
||||
Lina *drv;
|
||||
|
||||
drv = EaseMakeDriv(con, &linaClass, argc, argv, dynamic, 7,
|
||||
LinaParDef, LinaHandler, LinaStart, NULL, LinaRead,
|
||||
LinaSet);
|
||||
if (drv == NULL) return 0;
|
||||
/*
|
||||
setRS232ReplyTerminator(drv->d.b.ser,"\n");
|
||||
setRS232SendTerminator(drv->d.b.ser,"\n");
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void LinaStartup(void) {
|
||||
ParMakeClass(&linaClass, EaseDrivClass());
|
||||
MakeDriver("LINA", LinaInit, 0, "Lock in amplifier SIGNAL RECOVERY Model 7265");
|
||||
}
|
||||
Reference in New Issue
Block a user