Skip to content
Snippets Groups Projects
Commit af7efbc3 authored by Sonia Minolli's avatar Sonia Minolli
Browse files

Add mutex for communication data protection (TANGODEVIC-1965)

parent a6b4cd2e
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@
<dependency>
<groupId>fr.soleil.lib</groupId>
<artifactId>PLCServerProxy-${aol}-${library}-${mode}</artifactId>
<version>3.1.1-SNAPSHOT</version>
</dependency>
</dependencies>
<scm>
......
......@@ -209,17 +209,7 @@ namespace CryoCooler_ns
{
//DEBUG_STREAM << "CryoCoolerInterface::process_message handling TASK_PERIODIC msg" << std::endl;
//- code relative to the task's periodic job goes here
this->com_error = hwp->get_com_error();
this->com_success = hwp->get_com_success();
this->com_error += hwp_wr->get_com_error();
this->com_success += hwp_wr->get_com_success();
//- comm state/status
this->com_status = hwp_wr->get_com_status();
this->com_state = hwp_wr->get_com_state();
//- last error
this->last_error = hwp_wr->get_last_error();
this->periodic_job_i();
}
break;
......@@ -270,6 +260,7 @@ namespace CryoCooler_ns
}
catch (...)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_status = hwp_wr->get_com_status();
this->com_state = hwp_wr->get_com_state();
this->last_error = hwp_wr->get_last_error();
......@@ -314,6 +305,7 @@ namespace CryoCooler_ns
}
catch (...)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_status = hwp_wr->get_com_status();
this->com_state = hwp_wr->get_com_state();
this->last_error = hwp_wr->get_last_error();
......@@ -349,6 +341,7 @@ namespace CryoCooler_ns
}
catch (...)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_status = hwp_wr->get_com_status();
this->com_state = hwp_wr->get_com_state();
this->last_error = hwp_wr->get_last_error();
......@@ -381,6 +374,7 @@ namespace CryoCooler_ns
}
catch (...)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_status = hwp_wr->get_com_status();
this->com_state = hwp_wr->get_com_state();
this->last_error = hwp_wr->get_last_error();
......@@ -412,6 +406,7 @@ namespace CryoCooler_ns
}
catch (...)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_status = hwp_wr->get_com_status();
this->com_state = hwp_wr->get_com_state();
this->last_error = hwp_wr->get_last_error();
......@@ -443,19 +438,21 @@ namespace CryoCooler_ns
if (byte_offset > max_offset)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_state = HWProxy_ns::HWP_SOFTWARE_ERROR;
this->com_status = "HWP_SOFTWARE_ERROR";
std::stringstream s;
s << "CryoCoolerInterface::get_real Offset out of range trying to read a REAL " << " at offset " << byte_offset << std::endl;
this->last_error = s.str ();
Tango::Except::throw_exception(
static_cast<const char *>("OUT_OF_RANGE"),
static_cast<const char *>(s.str().c_str()),
static_cast<const char *>("CryoCoolerInterface::get_real"));
_CPTC ("OUT_OF_RANGE"),
_CPTC (s.str().c_str()),
_CPTC ("CryoCoolerInterface::get_real"));
}
if (!hwp)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_state = HWProxy_ns::HWP_SOFTWARE_ERROR;
this->com_status = "HWP_SOFTWARE_ERROR";
std::stringstream s;
......@@ -473,6 +470,7 @@ namespace CryoCooler_ns
}
catch(...)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_state = HWProxy_ns::HWP_SOFTWARE_ERROR;
this->com_status = "HWP_SOFTWARE_ERROR";
std::stringstream s;
......@@ -503,19 +501,21 @@ namespace CryoCooler_ns
if (byte_offset > max_offset)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_state = HWProxy_ns::HWP_SOFTWARE_ERROR;
this->com_status = "HWP_SOFTWARE_ERROR";
std::stringstream s;
s << "CryoCoolerInterface::get_int Offset out of range trying to read an INT " << " at offset " << byte_offset << std::endl;
this->last_error = s.str ();
Tango::Except::throw_exception(
static_cast<const char *>("OUT_OF_RANGE"),
static_cast<const char *>(s.str().c_str()),
static_cast<const char *>("CryoCoolerInterface::get_int "));
_CPTC ("OUT_OF_RANGE"),
_CPTC (s.str().c_str()),
_CPTC ("CryoCoolerInterface::get_int "));
}
if (!hwp)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_state = HWProxy_ns::HWP_SOFTWARE_ERROR;
this->com_status = "HWP_SOFTWARE_ERROR";
std::stringstream s;
......@@ -534,6 +534,7 @@ namespace CryoCooler_ns
}
catch(...)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_state = HWProxy_ns::HWP_SOFTWARE_ERROR;
this->com_status = "HWP_SOFTWARE_ERROR";
std::stringstream s;
......@@ -565,19 +566,21 @@ namespace CryoCooler_ns
if (byte_offset > max_offset)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_state = HWProxy_ns::HWP_SOFTWARE_ERROR;
this->com_status = "HWP_SOFTWARE_ERROR";
std::stringstream s;
s << "CryoCoolerInterface::get_bool Offset out of range trying to read a BOOL " << " at offset " << byte_offset << "." << bit_offset << std::endl;
this->last_error = s.str ();
Tango::Except::throw_exception(
static_cast<const char *>("OUT_OF_RANGE"),
static_cast<const char *>(s.str().c_str()),
static_cast<const char *>("CryoCoolerInterface::get_bool"));
_CPTC ("OUT_OF_RANGE"),
_CPTC (s.str().c_str()),
_CPTC ("CryoCoolerInterface::get_bool"));
}
if (!hwp)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_state = HWProxy_ns::HWP_SOFTWARE_ERROR;
this->com_status = "HWP_SOFTWARE_ERROR";
std::stringstream s;
......@@ -596,6 +599,7 @@ namespace CryoCooler_ns
}
catch(...)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
this->com_state = HWProxy_ns::HWP_SOFTWARE_ERROR;
this->com_status = "HWP_SOFTWARE_ERROR";
std::stringstream s;
......@@ -613,11 +617,16 @@ namespace CryoCooler_ns
//-----------------------------------------------
void CryoCoolerInterface::periodic_job_i (void)
{
yat::AutoMutex<yat::Mutex> guard (this->m_com_lock);
long l_com_error = 0;
long l_com_success = 0;
if (hwp)
{
l_com_success += hwp->get_com_success();
l_com_error += hwp->get_com_error();
this->com_state = hwp->get_com_state();
if (com_state == HWProxy_ns::HWP_COMMUNICATION_ERROR)
{
this->com_status = hwp->get_com_status();
......@@ -629,8 +638,10 @@ namespace CryoCooler_ns
//- hwp_wr is alive
if (hwp_wr)
{
l_com_success += hwp_wr->get_com_success();
l_com_error += hwp_wr->get_com_error();
this->com_state = hwp_wr->get_com_state();
if (com_state == HWProxy_ns::HWP_COMMUNICATION_ERROR)
{
this->com_status = hwp_wr->get_com_status();
......@@ -638,6 +649,7 @@ namespace CryoCooler_ns
return;
}
}
this->com_success = l_com_success;
this->com_error = l_com_error;
}
......
......@@ -105,6 +105,8 @@ namespace CryoCooler_ns
//- periodic job
void periodic_job_i (void);
//- mutex for communication data protection
yat::Mutex m_com_lock;
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment