Commit 470b69a3 authored by elaazzouzi's avatar elaazzouzi

Test CAENels FastPs device

parent 8f597f8e
......@@ -710,6 +710,10 @@ void CurrentController::startCurrent() {
break;
}
}
if (m_ReadDriver->commandStatus.isError()) {
error = true;
break;
}
}
else {
checkStatus();
......
......@@ -25,7 +25,7 @@ namespace caen_fastps {
* Commands
*/
static const char VERSION_COMMAND[] = "VER";
static const char ON_COMMAND[] = "MOD";
static const char ON_COMMAND[] = "MON";
static const char OFF_COMMAND[] = "MOFF";
static const char READ_CURRENT_COMMAND[] = "MRI";
static const char READ_VOLTAGE_COMMAND[] = "MRV";
......
......@@ -94,23 +94,20 @@ void CaenFastpsDriver::execute(const std::string& aCommand) {
* computeCurrentStatus
*/
void CaenFastpsDriver::computeCurrentStatus(int32 value) {
switch(value) {
case caen_fastps::OVP_STATUS:
case caen_fastps::INTERLOCK2_STATUS:
case caen_fastps::INTERLOCK1_STATUS:
case caen_fastps::REG_FAULT_STATUS:
case caen_fastps::FUSE_STATUS:
case caen_fastps::LEAKAGE_STATUS:
case caen_fastps::DCLINK_STATUS:
case caen_fastps::OVT_STATUS:
if ((value & caen_fastps::CONTROL_STATUS)
|| (value & caen_fastps::OVP_STATUS)
|| (value & caen_fastps::INTERLOCK2_STATUS)
|| (value & caen_fastps::INTERLOCK1_STATUS)
|| (value & caen_fastps::REG_FAULT_STATUS)
|| (value & caen_fastps::FUSE_STATUS)
|| (value & caen_fastps::LEAKAGE_STATUS)
|| (value & caen_fastps::DCLINK_STATUS)
|| (value & caen_fastps::OVT_STATUS)) {
commandStatus.setError();
break;
case caen_fastps::CHANGING:
} else if (value & caen_fastps::CHANGING) {
commandStatus.setRunning();
break;
case caen_fastps::IN_TOLERANCE:
} else if (value & caen_fastps::IN_TOLERANCE) {
commandStatus.setIdle();
break;
}
status = value;
}
......
......@@ -230,7 +230,7 @@ void RealCaenFastpsDriver::stop() {
/*
* writeCaenFastps
*/
vector<string> RealCaenFastpsDriver::writeCaenFastps(const string& aCommand) throw (CaenError) {
vector<string> RealCaenFastpsDriver::writeCaenFastps(const string& aCommand) throw (CaenError, DeviceDriver::TimeOut) {
string buf_in;
ostringstream scom;
scom << aCommand << "\r";
......
......@@ -92,7 +92,7 @@ private:
int32 code;
};
std::vector<std::string> writeCaenFastps(const std::string& aCommand) throw (CaenError);
std::vector<std::string> writeCaenFastps(const std::string& aCommand) throw (CaenError, DeviceDriver::TimeOut);
std::string getStringError(int32 code);
std::map<int32, std::string> m_Errors;
......
......@@ -67,7 +67,7 @@ CaenFastps.waveformImage=
CaenFastps.rampingImage=
CaenFastps.analogImage=
CaenFastps.cvImage=
CaenFastps.controlImage=
CaenFastps.controlImage=ALARM_STATUS
CaenFastps.conditionImage=
CaenFastps.onoffImage=
......
......@@ -84,22 +84,22 @@ void SocketTcp::write(const std::string& command) throw (DeviceDriver::TimeOut)
/*
* read
*/
std::string SocketTcp::read(const std::string& terminator) {
return m_socketproto->read(terminator);
std::string SocketTcp::read(const std::string& terminator) throw (DeviceDriver::TimeOut) {
return m_socketproto->read(this, terminator);
}
/*
* read
*/
std::string SocketTcp::read(uint32 nb) {
return m_socketproto->read(nb);
std::string SocketTcp::read(uint32 nb) throw (DeviceDriver::TimeOut) {
return m_socketproto->read(this, nb);
}
/*
* read
*/
std::string SocketTcp::read() {
return m_socketproto->read();
std::string SocketTcp::read() throw (DeviceDriver::TimeOut) {
return m_socketproto->read(this);
}
/*
......
......@@ -62,9 +62,9 @@ public:
void write(const std::string& command, const std::string& terminator) throw (DeviceDriver::TimeOut);
void write(const std::string& command) throw (DeviceDriver::TimeOut);
std::string read(const std::string& terminator);
std::string read(uint32 nb);
std::string read();
std::string read(const std::string& terminator) throw (DeviceDriver::TimeOut);
std::string read(uint32 nb) throw (DeviceDriver::TimeOut);
std::string read() throw (DeviceDriver::TimeOut);
void setTimeoutValue(int32 value);
......
......@@ -105,7 +105,7 @@ void SocketTcpProtocol::connect(DeviceDriver* device) throw (DeviceDriver::TimeO
/*
* read_line
*/
std::string SocketTcpProtocol::read_line(uint32 nb) {
std::string SocketTcpProtocol::read_line(uint32 nb) throw(boost::system::system_error) {
// Set a deadline for the asynchronous operation. Since this function uses
// a composed operation (async_read_until), the deadline applies to the
// entire operation, rather than individual reads from the socket.
......@@ -143,7 +143,7 @@ std::string SocketTcpProtocol::read_line(uint32 nb) {
/*
* read_line
*/
std::string SocketTcpProtocol::read_line(const std::string& terminator) {
std::string SocketTcpProtocol::read_line(const std::string& terminator) throw(boost::system::system_error) {
// Set a deadline for the asynchronous operation. Since this function uses
// a composed operation (async_read_until), the deadline applies to the
// entire operation, rather than individual reads from the socket.
......@@ -181,7 +181,7 @@ std::string SocketTcpProtocol::read_line(const std::string& terminator) {
/*
* read_line
*/
std::string SocketTcpProtocol::read_line() {
std::string SocketTcpProtocol::read_line() throw(boost::system::system_error) {
// Set a deadline for the asynchronous operation. Since this function uses
// a composed operation (async_read_until), the deadline applies to the
// entire operation, rather than individual reads from the socket.
......@@ -221,7 +221,7 @@ std::string SocketTcpProtocol::read_line() {
/*
* write_line
*/
void SocketTcpProtocol::write_line(const std::string& line) {
void SocketTcpProtocol::write_line(const std::string& line) throw(boost::system::system_error) {
std::string data = line;
// Set a deadline for the asynchronous operation. Since this function uses
......@@ -314,22 +314,40 @@ void SocketTcpProtocol::write(DeviceDriver* device, const std::string& command)
/*
* read
*/
std::string SocketTcpProtocol::read(const std::string& terminator) {
return read_line(terminator);
std::string SocketTcpProtocol::read(DeviceDriver* device, const std::string& terminator) throw (DeviceDriver::TimeOut) {
try {
return read_line(terminator);
} catch (...) {
m_connected = false;
throw DeviceDriver::TimeOut(device->getType(), device->getName(), device, "Read");
}
return string();
}
/*
* read
*/
std::string SocketTcpProtocol::read(uint32 nb) {
return read_line(nb);
std::string SocketTcpProtocol::read(DeviceDriver* device, uint32 nb) throw (DeviceDriver::TimeOut) {
try {
return read_line(nb);
} catch (...) {
m_connected = false;
throw DeviceDriver::TimeOut(device->getType(), device->getName(), device, "Read");
}
return string();
}
/*
* read
*/
std::string SocketTcpProtocol::read() {
return read_line();
std::string SocketTcpProtocol::read(DeviceDriver* device) throw (DeviceDriver::TimeOut) {
try {
return read_line();
} catch (...) {
m_connected = false;
throw DeviceDriver::TimeOut(device->getType(), device->getName(), device, "Read");
}
return string();
}
void SocketTcpProtocol::setTimeoutValue(int32 value) {
......
......@@ -68,18 +68,18 @@ public:
void write(DeviceDriver* device, const std::string& command, const std::string& terminator) throw (DeviceDriver::TimeOut);
void write(DeviceDriver* device, const std::string& command) throw (DeviceDriver::TimeOut);
std::string read(const std::string& terminator);
std::string read(uint32 nb);
std::string read();
std::string read(DeviceDriver* device, const std::string& terminator) throw (DeviceDriver::TimeOut);
std::string read(DeviceDriver* device, uint32 nb) throw (DeviceDriver::TimeOut);
std::string read(DeviceDriver* device) throw (DeviceDriver::TimeOut);
void setTimeoutValue(int32 value);
private:
std::string read_line(const std::string& terminator);
std::string read_line(uint32 nb);
std::string read_line();
void write_line(const std::string& line);
std::string read_line(const std::string& terminator) throw(boost::system::system_error);
std::string read_line(uint32 nb) throw(boost::system::system_error);
std::string read_line() throw(boost::system::system_error);
void write_line(const std::string& line) throw(boost::system::system_error);
void check_deadline();
std::string m_address;
......
......@@ -62,8 +62,8 @@ driver::SocketTcpProtocol* RealGpibEnetDriver::getSocket(const DeviceDriver* aDe
scom1 << (char) 0x07 << (char) 1 << (char) 0 << (char) (0x40 | eot) << (char) pad << (char) sad << (char) eos
<< (char) 0 << (char) tmo << (char) 0 << (char) 0 << (char) 0;
socket->write(owner(), scom1.str());
string answer = socket->read(4);
answer = socket->read(12);
string answer = socket->read(owner(), 4);
answer = socket->read(owner(), 12);
// ostringstream scom2;
// scom2 << (char) 0x07 << (char) 0 << (char) 0x5c << (char) 0x41 << (char) 0 << (char) 0 << (char) 0 << (char) 0 << (char) 13 << (char) 0 << (char) 0 << (char) 0;
// socket->write(scom2.str());
......@@ -93,15 +93,15 @@ void RealGpibEnetDriver::write(const DeviceDriver* aDeviceDriver, const std::str
// cout << "write 12" << endl;
socket->write(owner(), scom.str());
// cout << "read 4" << endl;
string answer = socket->read(4);
string answer = socket->read(owner(), 4);
// cout << "read 12" << endl;
answer = socket->read(12);
answer = socket->read(owner(), 12);
// cout << "write data" << endl;
socket->write(owner(), aData);
// cout << "read 4" << endl;
answer = socket->read(4);
answer = socket->read(owner(), 4);
// cout << "read 12" << endl;
answer = socket->read(12);
answer = socket->read(owner(), 12);
// Check size
uint32 size = static_cast<uint32>(answer[11]);
if (size != aData.size()) {
......@@ -118,19 +118,19 @@ void RealGpibEnetDriver::read(const DeviceDriver* aDeviceDriver, std::string& aD
scom << (char) 0x16 << (char) 0 << (char) 0 << (char) 0 << (char) 0 << (char) 0 << (char) 0 << (char) 40 << (char) 0
<< (char) 0 << (char) 0 << (char) 0;
socket->write(owner(), scom.str());
string buf = socket->read(4);
string buf = socket->read(owner(), 4);
// cout << read 0: " <<buf<< endl;
buf = socket->read(12);
buf = socket->read(owner(), 12);
// cout << read 1: " <<buf<< endl;
buf = socket->read(4);
buf = socket->read(owner(), 4);
// cout << "read 2: " << buf<<endl;
uint32 size = static_cast<uint32>(buf[3]);
string answer = socket->read(size);
buf = socket->read(4);
string answer = socket->read(owner(), size);
buf = socket->read(owner(), 4);
// cout << "read 3: " <<buf<< endl;
buf = socket->read(4);
buf = socket->read(owner(), 4);
// cout << "read 4: " <<buf<< endl;
buf = socket->read(12);
buf = socket->read(owner(), 12);
// cout << "read 5: " << buf<<endl;
uint32 sizeret = static_cast<uint32>(buf[11]);
if (sizeret != size) {
......
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