Skip to content
Snippets Groups Projects
Commit 9f8931dc authored by Alain BUTEAU's avatar Alain BUTEAU
Browse files

TANGODEVIC-1750

parent da963c44
Branches
Tags
No related merge requests found
.project 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CryoCooler</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
......@@ -26,12 +26,8 @@ namespace CryoCooler_ns
{
DEBUG_STREAM << "CryoCoolerInterface::CryoCoolerInterface <- " << std::endl;
#ifdef _DB_SEGMENTATION_BY_104_
hwp_rd_start = NULL;
hwp_rd_end = NULL;
#else
hwp = NULL;
#endif
hwp_wr = NULL;
//- yat::Task configure optional msg handling
......@@ -52,26 +48,11 @@ namespace CryoCooler_ns
{
DEBUG_STREAM << "CryoCoolerInterface::~CryoCoolerInterface <- " << std::endl;
#ifdef _DB_SEGMENTATION_BY_104_
if (hwp_rd_start)
{
this->hwp_rd_start->exit();
hwp_rd_start = NULL;
}
if (hwp_rd_end)
{
this->hwp_rd_end->exit();
hwp_rd_end = NULL;
}
#else
if (hwp)
{
this->hwp->exit();
hwp = NULL;
}
#endif
if (hwp_wr)
{
......@@ -91,91 +72,7 @@ namespace CryoCooler_ns
DEBUG_STREAM << " CryoCoolerInterface::initialize_DB try to get device proxy on " << plc_name << std::endl;
#ifdef _DB_SEGMENTATION_BY_104_
if (hwp_rd_start)
return;
try
{
DEBUG_STREAM << "CryoCoolerInterface::initialize trying to create hwp_rd_start" << std::endl;
HWProxy_ns:: HWProxy::Config conf;
//- this one gets the 50 first WORDS
conf.url = plc_name;
//- Give a specific name to plc client on the same DB number
conf.device_name = host_dev->get_name() + "_start";
conf.db_number = db_read_number;
conf.input_offset = DB_START_INPUT_OFFSET;
conf.input_length = DB_START_INPUT_LEN;
conf.output_offset = DB_START_OUTPUT_OFFSET;
conf.output_length = DB_START_OUTPUT_LEN;
// conf.periodic_timeout_ms = periodic_timeout_ms;
hwp_rd_start = new HWProxy_ns::HWProxy (host_dev, conf);
if (!hwp_rd_start)
{
ERROR_STREAM << "CryoCoolerInterface::initialize could not instanciate hwp_rd_start ..." << std::endl;
throw std::bad_alloc();
}
hwp_rd_start->go ();
}
catch (std::bad_alloc)
{
FATAL_STREAM << "CryoCoolerInterface::initialize () catched bad_alloc" << std::endl;
this->com_state = HWProxy_ns::HWP_INITIALIZATION_ERROR;
this->last_error = "could not instanciate hwp_rd_start class catched bad_alloc";
return;
}
catch (...)
{
FATAL_STREAM << "CryoCoolerInterface::initialize () catched ..." << std::endl;
this->com_state = HWProxy_ns::HWP_INITIALIZATION_ERROR;
this->last_error = "could not instanciate hwp_rd_start class catched (...)";
return;
}
if (hwp_rd_end)
return;
try
{
DEBUG_STREAM << "CryoCoolerInterface::initialize trying to create hwp_rd_end" << std::endl;
HWProxy_ns:: HWProxy::Config conf;
//- this one gets the 50 last WORDS (from 100 to 200)
conf.url = plc_name;
//- Give a specific name to plc client on the same DB number
conf.device_name = host_dev->get_name() + "_end";
conf.db_number = db_read_number;
conf.input_offset = DB_END_INPUT_OFFSET;
conf.input_length = DB_END_INPUT_LEN;
conf.output_offset = DB_END_OUTPUT_OFFSET;
conf.output_length = DB_END_OUTPUT_LEN;
// conf.periodic_timeout_ms = periodic_timeout_ms;
hwp_rd_end = new HWProxy_ns::HWProxy (host_dev, conf);
if (!hwp_rd_end)
{
ERROR_STREAM << "CryoCoolerInterface::initialize could not instanciate hwp_rd_end ..." << std::endl;
throw std::bad_alloc();
}
hwp_rd_end->go ();
}
catch (std::bad_alloc)
{
FATAL_STREAM << "CryoCoolerInterface::initialize () catched bad_alloc" << std::endl;
this->com_state = HWProxy_ns::HWP_INITIALIZATION_ERROR;
this->last_error = "could not instanciate hwp_rd_end class catched bad_alloc";
return;
}
catch (...)
{
FATAL_STREAM << "CryoCoolerInterface::initialize () catched ..." << std::endl;
this->com_state = HWProxy_ns::HWP_INITIALIZATION_ERROR;
this->last_error = "could not instanciate hwp_rd_end class catched (...)";
return;
}
#else
if (hwp)
return;
......@@ -186,7 +83,7 @@ namespace CryoCooler_ns
HWProxy_ns:: HWProxy::Config conf;
//- this one gets the 100 last WORDS (from 0 to 200)
conf.url = plc_name;
conf.device_name = host_dev->get_name ();
conf.device_name = host_dev->get_name () +"_R";
conf.db_number = db_read_number;
conf.input_offset = DB_START_INPUT_OFFSET;
conf.input_length = (DB_START_INPUT_LEN + DB_END_INPUT_LEN);
......@@ -216,7 +113,6 @@ namespace CryoCooler_ns
this->last_error = "could not instanciate hwp_rd_end class catched (...)";
return;
}
#endif
if (hwp_wr)
return;
......@@ -227,7 +123,7 @@ namespace CryoCooler_ns
HWProxy_ns:: HWProxy::Config conf;
//- Write DB Data the 100 WORDS (from 0 to 100)
conf.url = plc_name;
conf.device_name = host_dev->get_name ();
conf.device_name = host_dev->get_name () +"_W";
conf.db_number = db_write_number;
conf.input_offset = DB_WRITE_INPUT_OFFSET;
conf.input_length = DB_WRITE_INPUT_LEN;
......@@ -261,20 +157,7 @@ namespace CryoCooler_ns
//------------------------------------------------------
//------------------------------------------------------
#ifdef _DB_SEGMENTATION_BY_104_
HWProxy_ns::HWProxy * CryoCoolerInterface::get_hw_proxy_instance(unsigned int byte_offset)
{
//- evaluate the offset range
if ((byte_offset >= DB_START_INPUT_OFFSET) &&
(byte_offset < DB_END_INPUT_OFFSET) )
return hwp_rd_start;
else if ((byte_offset >= DB_END_INPUT_OFFSET) &&
(byte_offset < (DB_END_INPUT_OFFSET + DB_END_INPUT_LEN)))
return hwp_rd_end;
else
return NULL;
}
#endif
//-----------------------------------------------
//- the user core of the Task -------------------
......@@ -308,16 +191,9 @@ namespace CryoCooler_ns
DEBUG_STREAM << "CryoCoolerInterface::process_message handling TASK_PERIODIC msg" << std::endl;
//- code relative to the task's periodic job goes here
#ifdef _DB_SEGMENTATION_BY_104_
this->com_error = hwp_rd_start->get_com_error();
this->com_error += hwp_rd_end->get_com_error();
this->com_success = hwp_rd_start->get_com_success();
this->com_success += hwp_rd_end->get_com_success();
#else
this->com_error = hwp->get_com_error();
this->com_success = hwp->get_com_success();
#endif
this->com_error += hwp_wr->get_com_error();
this->com_success += hwp_wr->get_com_success();
//- comm state/status
......@@ -454,11 +330,8 @@ namespace CryoCooler_ns
static_cast<const char *>(s.str().c_str()),
static_cast<const char *>("CryoCoolerInterface::get_real"));
}
#ifdef _DB_SEGMENTATION_BY_104_
if (!(this->get_hw_proxy_instance(byte_offset)))
#else
if (!hwp)
#endif
{
this->com_state = HWProxy_ns::HWP_SOFTWARE_ERROR;
this->com_status = "HWP_SOFTWARE_ERROR";
......@@ -473,13 +346,8 @@ namespace CryoCooler_ns
try
{
#ifdef _DB_SEGMENTATION_BY_104_
if(this->get_hw_proxy_instance(byte_offset))
fval = (this->get_hw_proxy_instance(byte_offset))->get_real(byte_offset);
#else
if(hwp)
fval = hwp->get_real(byte_offset);
#endif
}
catch(...)
{
......@@ -515,11 +383,7 @@ namespace CryoCooler_ns
static_cast<const char *>(s.str().c_str()),
static_cast<const char *>("CryoCoolerInterface::get_int "));
}
#ifdef _DB_SEGMENTATION_BY_104_
if (!(this->get_hw_proxy_instance(byte_offset)))
#else
if (!hwp)
#endif
{
this->com_state = HWProxy_ns::HWP_SOFTWARE_ERROR;
this->com_status = "HWP_SOFTWARE_ERROR";
......@@ -535,13 +399,10 @@ namespace CryoCooler_ns
try
{
#ifdef _DB_SEGMENTATION_BY_104_
if (this->get_hw_proxy_instance(byte_offset))
shval = (this->get_hw_proxy_instance(byte_offset))->get_word(byte_offset);
#else
if (hwp)
shval = hwp->get_word(byte_offset);
#endif
}
catch(...)
......@@ -580,11 +441,9 @@ namespace CryoCooler_ns
static_cast<const char *>(s.str().c_str()),
static_cast<const char *>("CryoCoolerInterface::get_bool"));
}
#ifdef _DB_SEGMENTATION_BY_104_
if (!(this->get_hw_proxy_instance(byte_offset)))
#else
if (!hwp)
#endif
{
this->com_state = HWProxy_ns::HWP_SOFTWARE_ERROR;
this->com_status = "HWP_SOFTWARE_ERROR";
......@@ -599,12 +458,10 @@ namespace CryoCooler_ns
//- processing
try
{
#ifdef _DB_SEGMENTATION_BY_104_
bval = (this->get_hw_proxy_instance(byte_offset))->get_bool(byte_offset, bit_offset);
#else
if(hwp)
bval = hwp->get_bool(byte_offset, bit_offset);
#endif
}
catch(...)
......@@ -627,32 +484,6 @@ namespace CryoCooler_ns
{
long l_com_error = 0;
#ifdef _DB_SEGMENTATION_BY_104_
//- hwp_rd_start is alive
if (hwp_rd_start)
{
l_com_error += hwp_rd_start->get_com_error();
this->com_state = hwp_rd_start->get_com_state();
if (com_state == HWProxy_ns::HWP_COMMUNICATION_ERROR)
{
this->com_status = hwp_rd_start->get_com_status();
this->last_error = hwp_rd_start->get_last_error();
return;
}
}
//- hwp_rd_end is alive
if (hwp_rd_end)
{
l_com_error += hwp_rd_end->get_com_error();
this->com_state = hwp_rd_end->get_com_state();
if (com_state == HWProxy_ns::HWP_COMMUNICATION_ERROR)
{
this->com_status = hwp_rd_end->get_com_status();
this->last_error = hwp_rd_end->get_last_error();
return;
}
}
#else
if (hwp)
{
l_com_error += hwp->get_com_error();
......@@ -664,7 +495,6 @@ namespace CryoCooler_ns
return;
}
}
#endif
//- hwp_wr is alive
if (hwp_wr)
{
......
......@@ -76,18 +76,7 @@ namespace CryoCooler_ns
short db_write_number;
size_t periodic_timeout_ms;
#ifdef _DB_SEGMENTATION_BY_104_
//- Due to the 104 words limit max, the DB is too large to get it in one plc buffer
HWProxy_ns::HWProxy * hwp_rd_start;
HWProxy_ns::HWProxy * hwp_rd_end;
//- get the hwp proxy associated with the specific DB_start, DB_end, DB_write
HWProxy_ns::HWProxy * get_hw_proxy_instance(unsigned int byte_offset);
#else
HWProxy_ns::HWProxy * hwp;
#endif
//- DB write hwp proxy
HWProxy_ns::HWProxy * hwp_wr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment