Commit 090cfb83 authored by Pavel Vainerman's avatar Pavel Vainerman

(IONotifyController): подправил вылавливание исключений в getThresholdsList,

а также инициализацию списка порогов.
parent a42601bb
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
Name: libuniset2 Name: libuniset2
Version: 2.2 Version: 2.2
Release: alt22 Release: alt23
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
...@@ -451,6 +451,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -451,6 +451,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# .. # ..
%changelog %changelog
* Wed Feb 17 2016 Pavel Vainerman <pv@altlinux.ru> 2.2-alt23
- IONotifyController: fixed buf for init thresholdslist
* Tue Feb 09 2016 Pavel Vainerman <pv@altlinux.ru> 2.2-alt22 * Tue Feb 09 2016 Pavel Vainerman <pv@altlinux.ru> 2.2-alt22
- ModbusSlave(TCP): add show ip:port to vmonit setbug #9012 - ModbusSlave(TCP): add show ip:port to vmonit setbug #9012
......
...@@ -190,6 +190,12 @@ TEST_CASE("UInterface", "[UInterface]") ...@@ -190,6 +190,12 @@ TEST_CASE("UInterface", "[UInterface]")
REQUIRE( ti3.hilimit == 40 ); REQUIRE( ti3.hilimit == 40 );
REQUIRE_THROWS_AS( ui.getThresholdInfo(sid, 10), UniSetTypes::NameNotFound ); REQUIRE_THROWS_AS( ui.getThresholdInfo(sid, 10), UniSetTypes::NameNotFound );
// проверяем thresholds который был сформирован из секции <thresholds>
ui.setValue(10, 378);
REQUIRE( ui.getValue(13) == 1 );
ui.setValue(10, 0);
REQUIRE( ui.getValue(13) == 0 );
} }
SECTION( "calibration" ) SECTION( "calibration" )
......
...@@ -90,6 +90,7 @@ namespace UniSetTypes ...@@ -90,6 +90,7 @@ namespace UniSetTypes
std::ostream& operator<<( std::ostream& os, const UniversalIO::IOType t ); std::ostream& operator<<( std::ostream& os, const UniversalIO::IOType t );
std::ostream& operator<<( std::ostream& os, const IONotifyController_i::ThresholdInfo& ti ); std::ostream& operator<<( std::ostream& os, const IONotifyController_i::ThresholdInfo& ti );
std::ostream& operator<<( std::ostream& os, const IOController_i::ShortIOInfo& s ); std::ostream& operator<<( std::ostream& os, const IOController_i::ShortIOInfo& s );
std::ostream& operator<<( std::ostream& os, const IONotifyController_i::ThresholdState& s);
/*! Команды для управления лампочками */ /*! Команды для управления лампочками */
enum LampCommand enum LampCommand
......
...@@ -557,3 +557,18 @@ std::ostream& UniSetTypes::operator<<( std::ostream& os, const IOController_i::S ...@@ -557,3 +557,18 @@ std::ostream& UniSetTypes::operator<<( std::ostream& os, const IOController_i::S
return os; return os;
} }
// -------------------------------------------------------------------------
std::ostream& UniSetTypes::operator<<( std::ostream& os, const IONotifyController_i::ThresholdState& s )
{
if( s == IONotifyController_i::LowThreshold )
return os << "low";
if( s == IONotifyController_i::HiThreshold )
return os << "hi";
if( s == IONotifyController_i::NormalThreshold )
return os << "norm";
return os << "Unknown";
}
// -------------------------------------------------------------------------
...@@ -528,6 +528,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp ...@@ -528,6 +528,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
tli.si.node = uniset_conf()->getLocalNode(); tli.si.node = uniset_conf()->getLocalNode();
tli.list = std::move(lst); tli.list = std::move(lst);
tli.type = li->second->type; tli.type = li->second->type;
tli.ait = li->second;
// после этого вызова ti использовать нельзя // после этого вызова ti использовать нельзя
addThreshold(tli.list, std::move(ti), ci); addThreshold(tli.list, std::move(ti), ci);
...@@ -863,11 +864,18 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy ...@@ -863,11 +864,18 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
} }
catch( const Exception& ex ) catch( const Exception& ex )
{ {
uwarn << myname << "(getThresholdsList): для датчика " uwarn << myname << "(getThresholds): для датчика "
<< uniset_conf()->oind->getNameById(it->second.si.id) << uniset_conf()->oind->getNameById(it->second.si.id)
<< " " << ex << endl; << " " << ex << endl;
} }
/*
catch( const IOController_i::NameNotFound& ex )
{
uwarn << myname << "(getThresholds): IOController_i::NameNotFound.. for sid"
<< uniset_conf()->oind->getNameById(it->second.si.id)
<< endl;
}
*/
res->tlist.length( it->second.list.size() ); res->tlist.length( it->second.list.size() );
unsigned int k = 0; unsigned int k = 0;
...@@ -903,16 +911,24 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList() ...@@ -903,16 +911,24 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
try try
{ {
(*res)[i].si = it->second.si; (*res)[i].si = it->second.si;
(*res)[i].value = IOController::localGetValue(it->second.ait, it->second.si.id); (*res)[i].value = IOController::localGetValue(it->second.ait,it->second.si.id);
(*res)[i].type = it->second.type; (*res)[i].type = it->second.type;
} }
catch( const std::exception& ex ) catch( const std::exception& ex )
{ {
uwarn << myname << "(getThresholdsList): для датчика " uwarn << myname << "(getThresholdsList): for sid="
<< uniset_conf()->oind->getNameById(it->second.si.id) << uniset_conf()->oind->getNameById(it->second.si.id)
<< " " << ex.what() << endl; << " " << ex.what() << endl;
continue; continue;
} }
catch( const IOController_i::NameNotFound& ex )
{
uwarn << myname << "(getThresholdsList): IOController_i::NameNotFound.. for sid="
<< uniset_conf()->oind->getNameById(it->second.si.id)
<< endl;
continue;
}
(*res)[i].tlist.length( it->second.list.size() ); (*res)[i].tlist.length( it->second.list.size() );
......
...@@ -120,6 +120,13 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, std::shared_ptr<IOCon ...@@ -120,6 +120,13 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, std::shared_ptr<IOCon
for( auto& it : lst ) for( auto& it : lst )
it.sit = ic->myioEnd(); it.sit = ic->myioEnd();
try
{
auto i = ic->find(inf->si.id);
ic->askTMap[inf->si.id].ait = i->second;
}
catch(...){}
ic->askTMap[inf->si.id].si = inf->si; ic->askTMap[inf->si.id].si = inf->si;
ic->askTMap[inf->si.id].type = inf->type; ic->askTMap[inf->si.id].type = inf->type;
ic->askTMap[inf->si.id].list = std::move(lst); ic->askTMap[inf->si.id].list = std::move(lst);
......
...@@ -156,8 +156,6 @@ void NCRestorer_XML::read_list( const std::shared_ptr<UniXML>& xml, xmlNode* nod ...@@ -156,8 +156,6 @@ void NCRestorer_XML::read_list( const std::shared_ptr<UniXML>& xml, xmlNode* nod
{ {
try try
{ {
ioRegistration(ic, uinf, true); ioRegistration(ic, uinf, true);
} }
catch( const Exception& ex ) catch( const Exception& ex )
...@@ -509,11 +507,11 @@ bool NCRestorer_XML::getThresholdInfo( const std::shared_ptr<UniXML>& xml, xmlNo ...@@ -509,11 +507,11 @@ bool NCRestorer_XML::getThresholdInfo( const std::shared_ptr<UniXML>& xml, xmlNo
} }
} }
ti.id = uit.getIntProp("id"); ti.id = uit.getIntProp("id");
ti.lowlimit = uit.getIntProp("lowlimit"); ti.lowlimit = uit.getIntProp("lowlimit");
ti.hilimit = uit.getIntProp("hilimit"); ti.hilimit = uit.getIntProp("hilimit");
ti.invert = uit.getIntProp("invert"); ti.invert = uit.getIntProp("invert");
ti.state = IONotifyController_i::NormalThreshold; ti.state = IONotifyController_i::NormalThreshold;
return true; return true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
......
...@@ -304,7 +304,7 @@ void SViewer::updateThresholds( IONotifyController_i::ThresholdsListSeq_var& tls ...@@ -304,7 +304,7 @@ void SViewer::updateThresholds( IONotifyController_i::ThresholdsListSeq_var& tls
for( auto k = 0; k < m; k++ ) for( auto k = 0; k < m; k++ )
{ {
IONotifyController_i::ThresholdInfo* ti = &tlst[i].tlist[k]; IONotifyController_i::ThresholdInfo* ti = &tlst[i].tlist[k];
cout << "\t(" << setw(3) << ti->id << ") | " << ti->state << " | hi: " << setw(5) << ti->hilimit; cout << "\t(" << setw(3) << ti->id << ") | " << setw(5) << ti->state << " | hi: " << setw(5) << ti->hilimit;
cout << " | low: " << setw(5) << ti->lowlimit; cout << " | low: " << setw(5) << ti->lowlimit;
cout << endl; cout << endl;
} }
......
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