Commit 61dfd1da authored by kpetersn's avatar kpetersn
Browse files

Try to be smarter about connecting and disconnecting

parent 95ba7505
......@@ -4,6 +4,7 @@
#include <iocsh.h>
#include <epicsExport.h>
#include <epicsString.h>
#include <epicsThread.h>
#include "Linkam_T96.h"
......@@ -31,7 +32,38 @@ Linkam::Linkam(const char *portName, const char *serialPort) : asynPortDriver(po
libraryVersion_ = GetDllVersion();
printf("Comms Library Version %s\n", libraryVersion_);
// TODO: should this be moved to an init or connect method?
// Start poller? For now just initialize the temperature
// Wrapped call to LinkamCommDll.Comms.GetValue(). Index 0 is temperature.
// See Linkam.SharedEnums.eVALUETYPE page for full listing.
//temperatureRbv_ = GetValue(0);
//printf("Stage temperature:%f °C\n", temperatureRbv_);
// Initialize the temperature param to something other than the default (25.0)
//setDoubleParam(temperatureInValue_, 21.3);
//callParamCallbacks();
// Force the device to connect now
connect(this->pasynUserSelf);
//epicsThreadSleep(5.0);
}
Linkam::~Linkam()
{
// Force the controller to disconnect
disconnect(this->pasynUserSelf);
}
asynStatus Linkam::connect(asynUser *pasynUser)
{
asynStatus status;
static const char *functionName = "connect";
// Disconnect first?
//disconnect(pasynUser);
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s: Connecting...\n", driverName, functionName);
/*
* Wrapped call to LinkamCommsDll.Comms.OpenComms()
*
......@@ -44,19 +76,40 @@ Linkam::Linkam(const char *portName, const char *serialPort) : asynPortDriver(po
//commStatus_ = OpenComms(true, 1, 0);
commStatus_ = OpenCommsFromDevice(true, serialPort_);
// Start poller? For now just initialize the temperature
// Wrapped call to LinkamCommDll.Comms.GetValue(). Index 0 is temperature.
// See Linkam.SharedEnums.eVALUETYPE page for full listing.
//temperatureRbv_ = GetValue(0);
//printf("Stage temperature:%f °C\n", temperatureRbv_);
// Initialize the temperature param to something other than the default (25.0)
setDoubleParam(temperatureInValue_, 21.3);
callParamCallbacks();
// Disconnect
/* We found the controller and everything is OK. Signal to asynManager that we are connected. */
status = pasynManager->exceptionConnect(this->pasynUserSelf);
if (status) {
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s: error calling pasynManager->exceptionConnect, error=%s\n",
driverName, functionName, pasynUserSelf->errorMessage);
return asynError;
}
return asynSuccess;
}
asynStatus Linkam::disconnect(asynUser *pasynUser)
{
asynStatus status;
static const char *functionName = "disconnect";
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s: Disconnecting...\n", driverName, functionName);
// OpenComms only works for Windows-style numbering of COM ports
//commStatus_ = OpenComms(false, 1, 0);
//commStatus_ = OpenCommsFromDevice(false, "");
commStatus_ = OpenCommsFromDevice(false, serialPort_);
/* We found the controller and everything is OK. Signal to asynManager that we are connected. */
status = pasynManager->exceptionDisconnect(this->pasynUserSelf);
if (status) {
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s: error calling pasynManager->exceptionDisonnect, error=%s\n",
driverName, functionName, pasynUserSelf->errorMessage);
return asynError;
}
return asynSuccess;
}
asynStatus Linkam::readFloat64(asynUser *pasynUser, epicsFloat64 *value)
......
......@@ -23,6 +23,9 @@ public:
/* These are the methods that we override from asynPortDriver */
virtual asynStatus readFloat64(asynUser *pasynUser, epicsFloat64 *value);
virtual asynStatus disconnect(asynUser *pasynUser);
virtual asynStatus connect(asynUser *pasynUser);
virtual ~Linkam();
protected:
int temperatureInValue_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment