Commit 98614910 authored by kpetersn's avatar kpetersn
Browse files

Added a pollerThread. Moved querying of the temperature, heater power, LN...

Added a pollerThread.  Moved querying of the temperature, heater power, LN pump speed, and vacuum to the poller.  Also made the poller query the status.  Added PVs for relevant status bits.
parent 256b8dab
......@@ -198,4 +198,67 @@ record(longin, "$(P)$(T):stageConfig_RBV")
field(PINI, "YES")
field(EGU, "N/A")
field(SCAN, "Passive")
}
\ No newline at end of file
}
record(bi, "$(P)$(T):statusError_RBV")
{
field(DTYP, "asynInt32")
field(INP, "@asyn($(PORT),$(ADDR))STATUS_CONTROLLER_ERROR")
field(ZNAM, "Ok")
field(ONAM, "Error")
field(SCAN, "I/O Intr")
}
record(bi, "$(P)$(T):rampAtLimit_RBV")
{
field(DTYP, "asynInt32")
field(INP, "@asyn($(PORT),$(ADDR))STATUS_RAMP_SETPOINT")
field(ZNAM, "No")
field(ONAM, "Yes")
field(SCAN, "I/O Intr")
}
record(bi, "$(P)$(T):heating_RBV")
{
field(DTYP, "asynInt32")
field(INP, "@asyn($(PORT),$(ADDR))STATUS_RAMP_STARTED")
field(ZNAM, "Off")
field(ONAM, "On")
field(SCAN, "I/O Intr")
}
record(bi, "$(P)$(T):vacuumAtLimit_RBV")
{
field(DTYP, "asynInt32")
field(INP, "@asyn($(PORT),$(ADDR))STATUS_VACUUM_SETPOINT")
field(ZNAM, "No")
field(ONAM, "Yes")
field(SCAN, "I/O Intr")
}
record(bi, "$(P)$(T):vacuumStatus_RBV")
{
field(DTYP, "asynInt32")
field(INP, "@asyn($(PORT),$(ADDR))STATUS_VACUUM_STARTED")
field(ZNAM, "Off")
field(ONAM, "On")
field(SCAN, "I/O Intr")
}
record(bi, "$(P)$(T):lnpStatus_RBV")
{
field(DTYP, "asynInt32")
field(INP, "@asyn($(PORT),$(ADDR))STATUS_LNP_COOLING_STARTED")
field(ZNAM, "Off")
field(ONAM, "On")
field(SCAN, "I/O Intr")
}
record(bi, "$(P)$(T):lnpMode_RBV")
{
field(DTYP, "asynInt32")
field(INP, "@asyn($(PORT),$(ADDR))STATUS_LNP_COOLING_AUTO")
field(ZNAM, "Manual")
field(ONAM, "Auto")
field(SCAN, "I/O Intr")
}
......@@ -5,8 +5,8 @@ file {
}
display {
object {
x=2300
y=84
x=668
y=129
width=560
height=430
}
......@@ -104,7 +104,7 @@ text {
object {
x=15
y=55
width=200
width=190
height=25
}
"basic attribute" {
......@@ -160,6 +160,7 @@ text {
clr=14
bclr=4
}
align="horiz. centered"
limits {
}
}
......@@ -175,6 +176,7 @@ text {
clr=14
bclr=4
}
align="horiz. centered"
limits {
}
}
......@@ -190,6 +192,7 @@ text {
clr=14
bclr=4
}
align="horiz. centered"
limits {
}
}
......@@ -260,6 +263,7 @@ text {
clr=14
bclr=4
}
align="horiz. centered"
limits {
}
}
......@@ -284,55 +288,15 @@ menu {
height=25
}
monitor {
chan="$(P)$(T):heating"
chan="$(P)$(T):heating_RBV"
clr=14
bclr=4
}
align="horiz. centered"
format="string"
limits {
}
}
composite {
object {
x=220
y=175
width=160
height=25
}
"composite name"=""
children {
"message button" {
object {
x=220
y=175
width=75
height=25
}
control {
chan="$(P)$(T):heating"
clr=0
bclr=63
}
label="On"
release_msg="1"
}
"message button" {
object {
x=305
y=175
width=75
height=25
}
control {
chan="$(P)$(T):heating"
clr=0
bclr=22
}
label="Off"
release_msg="0"
}
}
}
"related display" {
object {
x=445
......@@ -375,7 +339,7 @@ text {
}
menu {
object {
x=385
x=220
y=205
width=160
height=25
......@@ -413,7 +377,7 @@ menu {
clr=14
bclr=4
}
format="string"
align="horiz. centered"
limits {
}
}
......@@ -434,7 +398,7 @@ text {
object {
x=15
y=295
width=200
width=190
height=25
}
"basic attribute" {
......@@ -454,6 +418,7 @@ text {
clr=14
bclr=4
}
align="horiz. centered"
limits {
}
}
......@@ -494,6 +459,7 @@ text {
clr=14
bclr=4
}
align="horiz. centered"
limits {
}
}
......@@ -526,7 +492,7 @@ text {
}
menu {
object {
x=383
x=220
y=355
width=160
height=25
......@@ -537,3 +503,156 @@ menu {
bclr=4
}
}
composite {
object {
x=220
y=175
width=160
height=25
}
"composite name"=""
children {
"message button" {
object {
x=220
y=175
width=75
height=25
}
control {
chan="$(P)$(T):heating"
clr=0
bclr=63
}
label="On"
release_msg="1"
}
"message button" {
object {
x=305
y=175
width=75
height=25
}
control {
chan="$(P)$(T):heating"
clr=0
bclr=22
}
label="Off"
release_msg="0"
}
}
}
"text update" {
object {
x=385
y=205
width=160
height=25
}
monitor {
chan="$(P)$(T):lnpMode_RBV"
clr=14
bclr=4
}
align="horiz. centered"
format="string"
limits {
}
}
rectangle {
object {
x=210
y=55
width=8
height=25
}
"basic attribute" {
clr=17
}
"dynamic attribute" {
vis="if not zero"
calc="A"
chan="$(P)$(T):rampAtLimit_RBV"
}
}
"text update" {
object {
x=385
y=265
width=160
height=25
}
monitor {
chan="$(P)$(T):lnpStatus_RBV"
clr=14
bclr=4
}
align="horiz. centered"
format="string"
limits {
}
}
"text update" {
object {
x=385
y=355
width=160
height=25
}
monitor {
chan="$(P)$(T):vacuumStatus_RBV"
clr=14
bclr=4
}
align="horiz. centered"
format="string"
limits {
}
}
rectangle {
object {
x=210
y=295
width=8
height=25
}
"basic attribute" {
clr=17
}
"dynamic attribute" {
vis="if not zero"
calc="A"
chan="$(P)$(T):vacuumAtLimit_RBV"
}
}
text {
object {
x=15
y=385
width=200
height=25
}
"basic attribute" {
clr=14
}
textix="Controller Error"
}
"text update" {
object {
x=220
y=385
width=160
height=25
}
monitor {
chan="$(P)$(T):statusError_RBV"
clr=14
bclr=4
}
align="horiz. centered"
format="string"
limits {
}
}
This diff is collapsed.
......@@ -14,11 +14,19 @@
// Is this needed?
using namespace std;
// This needs to come before the Linkam constructor to avoid compiler errors
static void pollerThreadC(void * pPvt)
{
Linkam *pLinkam = (Linkam *)pPvt;
pLinkam->pollerThread();
}
Linkam::Linkam(const char *portName, const epicsUInt32 commType, const epicsUInt32 commPort) : asynPortDriver(portName, MAX_CONTROLLERS,
asynInt32Mask | asynFloat64Mask | asynDrvUserMask,
asynInt32Mask | asynFloat64Mask,
ASYN_MULTIDEVICE | ASYN_CANBLOCK, 1, /* ASYN_CANBLOCK=0, ASYN_MULTIDEVICE=1, autoConnect=1 */
0, 0) /* Default priority and stack size */
0, 0), /* Default priority and stack size */
pollTime_(DEFAULT_POLL_TIME)
{
static const char *functionName = "Linkam";
......@@ -26,7 +34,7 @@ Linkam::Linkam(const char *portName, const epicsUInt32 commType, const epicsUInt
commType_ = commType;
commPort_ = commPort;
//
//
createParam(temperatureInValueString, asynParamFloat64, &temperatureInValue_);
createParam(rampLimitOutValueString, asynParamFloat64, &rampLimitOutValue_);
createParam(rampLimitInValueString, asynParamFloat64, &rampLimitInValue_);
......@@ -34,21 +42,29 @@ Linkam::Linkam(const char *portName, const epicsUInt32 commType, const epicsUInt
createParam(rampRateInValueString, asynParamFloat64, &rampRateInValue_);
createParam(heaterPowerInValueString, asynParamFloat64, &heaterPowerInValue_);
createParam(heatingOutValueString, asynParamInt32, &heatingOutValue_);
//
//
createParam(lnpModeOutValueString, asynParamInt32, &lnpModeOutValue_);
createParam(lnpSpeedOutValueString, asynParamInt32, &lnpSpeedOutValue_);
createParam(lnpSpeedInValueString, asynParamFloat64, &lnpSpeedInValue_);
//
//
createParam(vacuumOutValueString, asynParamInt32, &vacuumOutValue_);
createParam(vacuumLimitOutValueString, asynParamFloat64, &vacuumLimitOutValue_);
createParam(vacuumLimitInValueString, asynParamFloat64, &vacuumLimitInValue_);
createParam(pressureInValueString, asynParamFloat64, &pressureInValue_);
//
//
createParam(controllerConfigInValueString, asynParamInt32, &controllerConfigInValue_);
createParam(controllerErrorInValueString, asynParamInt32, &controllerErrorInValue_);
createParam(controllerStatusInValueString, asynParamInt32, &controllerStatusInValue_);
createParam(stageConfigInValueString, asynParamInt32, &stageConfigInValue_);
//
createParam(statusControllerErrorString, asynParamInt32, &statusControllerError_);
createParam(statusRampSetpointString, asynParamInt32, &statusRampSetpoint_);
createParam(statusRampStartedString, asynParamInt32, &statusRampStarted_);
createParam(statusVacuumSetpointString, asynParamInt32, &statusVacuumSetpoint_);
createParam(statusVacuumStartedString, asynParamInt32, &statusVacuumStarted_);
createParam(statusLnpCoolingStartedString, asynParamInt32, &statusLnpCoolingStarted_);
createParam(statusLnpCoolingAutoString, asynParamInt32, &statusLnpCoolingAuto_);
// Must be in the directory with the DLL when this line is executed
//LoadMonoLibrary("LinkamCommsDll.dll");
......@@ -59,8 +75,6 @@ Linkam::Linkam(const char *portName, const epicsUInt32 commType, const epicsUInt
libraryVersion_ = GetDllVersion();
printf("Comms Library Version %s\n", libraryVersion_);
// Start poller? For now just initialize the temperature
// Force the device to connect now
connect(this->pasynUserSelf);
......@@ -70,7 +84,20 @@ Linkam::Linkam(const char *portName, const epicsUInt32 commType, const epicsUInt
//
readStageConfig();
//epicsThreadSleep(5.0);
/*
* Initialize parameters here that need to be set because init record order is
* not predictable or because the corresponding records are PINI=NO
*/
//setIntegerParam(variable_, 1);
// Start the poller
epicsThreadCreate("LinkamPoller",
epicsThreadPriorityLow,
epicsThreadGetStackSize(epicsThreadStackMedium),
(EPICSTHREADFUNC)pollerThreadC,
this);
//epicsThreadSleep(5.0);
}
Linkam::~Linkam()
......@@ -153,6 +180,74 @@ asynStatus Linkam::disconnect(asynUser *pasynUser)
return asynSuccess;
}
/*
*
* poller
*
*/
void Linkam::pollerThread()
{
/* This function runs in a separate thread. It waits for the poll time. */
static const char *functionName = "pollerThread";
// Other variable declarations
epicsInt32 ival;
epicsFloat64 fval;
while (1)
{
lock();
// Get the controller status
this->controllerStatus_ = GetStatus();
/*
* Parse the controller status
*/
ival = ( controllerStatus_ & ((epicsUInt64)1 << (int)u64ControllerError) ) ? 1 : 0;
setIntegerParam(statusControllerError_, ival);
ival = ( controllerStatus_ & ((epicsUInt64)1 << (int)u64Heater1RampSetpoint) ) ? 1 : 0;
setIntegerParam(statusRampSetpoint_, ival);
ival = ( controllerStatus_ & ((epicsUInt64)1 << (int)u64Heater1Started) ) ? 1 : 0;
setIntegerParam(statusRampStarted_, ival);
ival = ( controllerStatus_ & ((epicsUInt64)1 << (int)u64VacuumSetPoint) ) ? 1 : 0;
setIntegerParam(statusVacuumSetpoint_, ival);
ival = ( controllerStatus_ & ((epicsUInt64)1 << (int)u64VacuumControlStarted) ) ? 1 : 0;
setIntegerParam(statusVacuumStarted_, ival);
ival = ( controllerStatus_ & ((epicsUInt64)1 << (int)u64LnpCoolingStarted) ) ? 1 : 0;
setIntegerParam(statusLnpCoolingStarted_, ival);
ival = ( controllerStatus_ & ((epicsUInt64)1 << (int)u64LnpCoolingAuto) ) ? 1 : 0;
setIntegerParam(statusLnpCoolingAuto_, ival);
// Get the temperature
fval = GetValue(u32Heater1TempR);
setDoubleParam(temperatureInValue_, fval);
// Get the heater power
fval = GetValue(u32Heater1PowerR);
setDoubleParam(heaterPowerInValue_, fval);
// Get the LN pump speed
fval = GetValue(u32Heater1LnpSpeedR);
setDoubleParam(lnpSpeedInValue_, fval);
// Get the pressure
fval = GetValue(u32VacuumR);
setDoubleParam(pressureInValue_, fval);
callParamCallbacks();
unlock();
epicsThreadSleep(pollTime_);
}
}
/*
*
* readFloat64
......@@ -168,12 +263,12 @@ asynStatus Linkam::readFloat64(asynUser *pasynUser, epicsFloat64 *value)
"%s:%s, port %s, function = %d\n",
driverName, functionName, this->portName, function);
if (function == temperatureInValue_) {
/* if (function == temperatureInValue_) {
// Read the temperature from the controller (Celsius)
status = readTemperature(value);
} else if (function == rampLimitInValue_) {
} else */ if (function == rampLimitInValue_) {
// Read the ramp limit from the controller (Celsius)
status = readRampLimit(value);
......@@ -183,7 +278,7 @@ asynStatus Linkam::readFloat64(asynUser *pasynUser, epicsFloat64 *value)
// Read the ramp rate from the controller (C/min)
status = readRampRate(value);
} else if (function == heaterPowerInValue_) {
} /* else if (function == heaterPowerInValue_) {
// Read the temperature from the controller (Watts)
status = readHeaterPower(value);
......@@ -193,17 +288,17 @@ asynStatus Linkam::readFloat64(asynUser *pasynUser, epicsFloat64 *value)
// Read the LN Pump speed from the controller (0-100%)
status = readLnpSpeed(value);
} else if (function == vacuumLimitInValue_) {
} */ else if (function == vacuumLimitInValue_) {
// Read the vacuum limit from the controller (mBar)
status = readVacuumLimit(value);
} else if (function == pressureInValue_) {
} /* else if (function == pressureInValue_) {
// Read the vacuum pressure from the controller (mBar)
status = readPressure(value);
} else {
} */ else {
status = asynPortDriver::readFloat64(pasynUser,value);
}
......@@ -215,7 +310,7 @@ asynStatus Linkam::readFloat64(asynUser *pasynUser, epicsFloat64 *value)
return (status==0) ? asynSuccess : asynError;
}
asynStatus Linkam::readTemperature(epicsFloat64 *value)
/*asynStatus Linkam::readTemperature(epicsFloat64 *value)
{
static const char *functionName = "readTemperature";
......@@ -231,7 +326,7 @@ asynStatus Linkam::readTemperature(epicsFloat64 *value)
driverName, functionName, this->portName, *value);
return asynSuccess;
}
}*/
asynStatus Linkam::readRampLimit(epicsFloat64 *value)
{
......@@ -263,7 +358,7 @@ asynStatus Linkam::readRampRate(epicsFloat64 *value)
return asynSuccess;
}
asynStatus Linkam::readHeaterPower(epicsFloat64 *value)
/*asynStatus Linkam::readHeaterPower(epicsFloat64 *value)
{
static const char *functionName = "readHeaterPower";
......@@ -276,9 +371,9 @@ asynStatus Linkam::readHeaterPower(epicsFloat64 *value)
driverName, functionName, this->portName, *value);
return asynSuccess;
}
}*/
asynStatus Linkam::readLnpSpeed(epicsFloat64 *value)
/*asynStatus Linkam::readLnpSpeed(epicsFloat64 *value)
{
static const char *functionName = "readLnpSpeed";
......@@ -291,7 +386,7 @@ asynStatus Linkam::readLnpSpeed(epicsFloat64 *value)
driverName, functionName, this->portName, *value);
return asynSuccess;
}
}*/
asynStatus Linkam::readVacuumLimit(epicsFloat64 *value)
{
......@@ -308,7 +403,7 @@ asynStatus Linkam::readVacuumLimit(epicsFloat64 *value)
return asynSuccess;
}
asynStatus Linkam::readPressure(epicsFloat64 *value)
/*asynStatus Linkam::readPressure(epicsFloat64 *value)
{
static const char *functionName = "readPressure";
......@@ -321,7 +416,7 @@ asynStatus Linkam::readPressure(epicsFloat64 *value)
driverName, functionName, this->portName, *value);