Commit 2a5cd5dc authored by Pavel Vainerman's avatar Pavel Vainerman

(IOController): исправил ошибку в загрузке "порогов" из секции <thresholds>

и провёл небольшую чистку кода.
parent eb618109
...@@ -49,7 +49,8 @@ Debug: ...@@ -49,7 +49,8 @@ Debug:
HTTP API: HTTP API:
- запрос списка заказчиков по конкретным датчикам - запрос списка заказчиков по конкретным датчикам
- запрос о том, кто последний сохранил указанный датчик - запрос о том, кто последний сохранил указанный датчик
- список объектов возвращать с их типом (чтобы можно было SM вычислять)
= Сделать возможность настраивать параметры httpserver-а из командной строки (количество потоков и т.п.)
Version 2.5 Version 2.5
============ ============
......
...@@ -30309,7 +30309,7 @@ ...@@ -30309,7 +30309,7 @@
</sensors> </sensors>
<thresholds name="thresholds"> <thresholds name="thresholds">
<sensor iotype="AI" name="AI_AS"> <sensor iotype="AI" name="AI_AS">
<threshold hilimit="376" id="1" lowlimit="374" name="t1" sensibility="0" sid="Threshold1_S"> <threshold hilimit="376" id="1" lowlimit="374" name="t1" sid="Threshold1_S">
<consumers> <consumers>
<consumer name="TestProc" type="objects"/> <consumer name="TestProc" type="objects"/>
</consumers> </consumers>
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
<item id="7" iotype="DO" name="DO_C" priority="Medium" textname="Digital output"/> <item id="7" iotype="DO" name="DO_C" priority="Medium" textname="Digital output"/>
<item id="8" iotype="DO" name="DO1_C" priority="Medium" textname="Digital output"/> <item id="8" iotype="DO" name="DO1_C" priority="Medium" textname="Digital output"/>
<item default="1000" id="9" iotype="AO" name="AO_AS" precision="2" priority="Medium" unet_sendfactor="2" rs="2" rs_channel="1" rs_jack="j1" rs_mbaddr="0x01" rs_mbfunc="0x06" rs_mbreg="0x02" rs_mbtype="rtu188" textname="Analog output"/> <item default="1000" id="9" iotype="AO" name="AO_AS" precision="2" priority="Medium" unet_sendfactor="2" rs="2" rs_channel="1" rs_jack="j1" rs_mbaddr="0x01" rs_mbfunc="0x06" rs_mbreg="0x02" rs_mbtype="rtu188" textname="Analog output"/>
<item default="378" id="10" iotype="AI" mbaddr="0x01" mbfunc="0x04" mbreg="0x01" mbtype="rtu" name="AI_AS" precision="45" priority="Medium" rs="1" textname="Analog input" vtype="F2"> <item default="378" id="10" iotype="AI" mbaddr="0x01" mbfunc="0x04" mbreg="0x01" mbtype="rtu" name="AI_AS" precision="3" priority="Medium" rs="1" textname="Analog input" vtype="F2">
<consumers> <consumers>
<consumer cfilter="test1" name="TestProc" type="objects"/> <consumer cfilter="test1" name="TestProc" type="objects"/>
<consumer name="PLCProcessor" type="objects"/> <consumer name="PLCProcessor" type="objects"/>
...@@ -5310,8 +5310,8 @@ ...@@ -5310,8 +5310,8 @@
<item id="15099" losttest="3" mbperf="100" iotype="AI" mbaddr="0x01" mbfunc="0x03" mbreg="101" mbtype="rtu" name="Sensor15099_S" textname="test sensor 15099"/> <item id="15099" losttest="3" mbperf="100" iotype="AI" mbaddr="0x01" mbfunc="0x03" mbreg="101" mbtype="rtu" name="Sensor15099_S" textname="test sensor 15099"/>
</sensors> </sensors>
<thresholds name="thresholds"> <thresholds name="thresholds">
<sensor iotype="AI" name="AI_AS"> <sensor name="AI_AS">
<threshold hilimit="376" id="1" lowlimit="374" name="t1" sensibility="0" sid="Threshold1_S"> <threshold hilimit="376" id="1" lowlimit="374" name="t1" sid="Threshold1_S">
<consumers> <consumers>
<consumer name="TestProc" type="objects"/> <consumer name="TestProc" type="objects"/>
</consumers> </consumers>
......
...@@ -36,7 +36,9 @@ void SharedMemory::help_print( int argc, const char* const* argv ) ...@@ -36,7 +36,9 @@ void SharedMemory::help_print( int argc, const char* const* argv )
cout << "--s-filter-field - Фильтр для загрузки списка датчиков." << endl; cout << "--s-filter-field - Фильтр для загрузки списка датчиков." << endl;
cout << "--s-filter-value - Значение фильтра для загрузки списка датчиков." << endl; cout << "--s-filter-value - Значение фильтра для загрузки списка датчиков." << endl;
cout << "--c-filter-field - Фильтр для загрузки списка заказчиков." << endl; cout << "--c-filter-field - Фильтр для загрузки списка заказчиков." << endl;
cout << "--c-filter-value - Значение фильтр для загрузки списка заказчиков." << endl; cout << "--c-filter-value - Значение фильтра для загрузки списка заказчиков." << endl;
cout << "--t-filter-field - Фильтр для загрузки списка порогов из секции <thresholds>." << endl;
cout << "--t-filter-value - Значение фильтра для загрузки списка порогов из секции <thresholds>." << endl;
cout << "--wdt-device - Использовать в качестве WDT указанный файл." << endl; cout << "--wdt-device - Использовать в качестве WDT указанный файл." << endl;
cout << "--heartbeat-node - Загружать heartbeat датчики для указанного узла." << endl; cout << "--heartbeat-node - Загружать heartbeat датчики для указанного узла." << endl;
cout << "--heartbeat-check-time - период проверки 'счётчиков'. По умолчанию 1000 мсек" << endl; cout << "--heartbeat-check-time - период проверки 'счётчиков'. По умолчанию 1000 мсек" << endl;
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
</sensors> </sensors>
<thresholds name="thresholds"> <thresholds name="thresholds">
<sensor iotype="AI" name="AI1_AS"> <sensor name="AI1_AS">
<threshold hilimit="376" id="1" lowlimit="374" name="t1" sensibility="0" sid="Threshold1_S"/> <threshold hilimit="376" id="1" lowlimit="374" name="t1" sid="Threshold1_S"/>
</sensor> </sensor>
</thresholds> </thresholds>
<controllers name="Controllers"> <controllers name="Controllers">
......
...@@ -54,10 +54,12 @@ ...@@ -54,10 +54,12 @@
<item id="512" iotype="AI" name="DependAI_S" depend="Depend_BlockSensor_S" depend_value="1" depend_off_value="1000" priority="Medium" textname="Depend AI sesnor"/> <item id="512" iotype="AI" name="DependAI_S" depend="Depend_BlockSensor_S" depend_value="1" depend_off_value="1000" priority="Medium" textname="Depend AI sesnor"/>
<item id="513" iotype="DI" name="DependDI_S" depend="Depend_BlockSensor_S" depend_value="0" depend_off_value="0" priority="Medium" textname="Depend DI sesnor"/> <item id="513" iotype="DI" name="DependDI_S" depend="Depend_BlockSensor_S" depend_value="0" depend_off_value="0" priority="Medium" textname="Depend DI sesnor"/>
<item id="514" iotype="DI" name="Depend_BlockSensor_S" priority="Medium" textname="Block Sensor for depend"/> <item id="514" iotype="DI" name="Depend_BlockSensor_S" priority="Medium" textname="Block Sensor for depend"/>
<item id="515" iotype="DI" name="Threshold2_S" priority="Medium" textname="Threshold 2"/>
</sensors> </sensors>
<thresholds name="thresholds"> <thresholds name="thresholds">
<sensor iotype="AI" name="AI1_AS"> <sensor name="AI1_AS">
<threshold hilimit="376" id="1" lowlimit="374" name="t1" sensibility="0" sid="Threshold1_S"/> <threshold hilimit="376" id="1" lowlimit="374" name="t1" sid="Threshold1_S"/>
<threshold hilimit="30" id="1" lowlimit="25" name="t1" invert="1" sid="Threshold2_S"/>
</sensor> </sensor>
</thresholds> </thresholds>
<controllers name="Controllers"> <controllers name="Controllers">
......
...@@ -65,6 +65,20 @@ TEST_CASE("[SM]: threshold", "[sm][threshold]") ...@@ -65,6 +65,20 @@ TEST_CASE("[SM]: threshold", "[sm][threshold]")
CHECK( ui->getValue(504) == 0 ); CHECK( ui->getValue(504) == 0 );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_CASE("[SM]: threshold (invert)", "[sm][threshold]")
{
InitTest();
ui->setValue(503, 20);
CHECK( ui->getValue(515) == 1 );
ui->setValue(503, 25);
CHECK( ui->getValue(515) == 1 );
ui->setValue(503, 35);
CHECK( ui->getValue(515) == 0 );
}
// -----------------------------------------------------------------------------
TEST_CASE("[SM]: pulsar", "[sm][pulsar]") TEST_CASE("[SM]: pulsar", "[sm][pulsar]")
{ {
InitTest(); InitTest();
......
...@@ -275,8 +275,8 @@ ...@@ -275,8 +275,8 @@
</sensors> </sensors>
<thresholds name="thresholds"> <thresholds name="thresholds">
<sensor iotype="AI" name="AI_AS"> <sensor name="AI_AS">
<threshold hilimit="376" id="1" lowlimit="374" name="t1" sensibility="0" sid="Threshold1_S"> <threshold hilimit="376" id="1" lowlimit="374" name="t1" sid="Threshold1_S">
<consumers> <consumers>
<consumer name="TestProc" type="objects"/> <consumer name="TestProc" type="objects"/>
</consumers> </consumers>
......
...@@ -216,11 +216,10 @@ void NCRestorer_XML::read( IONotifyController* ic, const std::shared_ptr<UniXML> ...@@ -216,11 +216,10 @@ void NCRestorer_XML::read( IONotifyController* ic, const std::shared_ptr<UniXML>
init_depends_signals(ic); init_depends_signals(ic);
} }
xmlNode* tnode( xml->findNode(xml->getFirstNode(), "thresholds") ); xmlNode* tnode = xml->findNode(xml->getFirstNode(), "thresholds");
if( tnode ) if( tnode )
read_thresholds(xml, tnode, ic); read_thresholds(xml, tnode, ic);
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool NCRestorer_XML::getBaseInfo( const std::shared_ptr<UniXML>& xml, xmlNode* it, IOController_i::SensorInfo& si ) bool NCRestorer_XML::getBaseInfo( const std::shared_ptr<UniXML>& xml, xmlNode* it, IOController_i::SensorInfo& si )
...@@ -359,16 +358,30 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod ...@@ -359,16 +358,30 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod
if( !check_thresholds_item(it) ) if( !check_thresholds_item(it) )
continue; continue;
std::shared_ptr<NCRestorer_XML::SInfo> inf = make_shared<NCRestorer_XML::SInfo>(); IOController_i::SensorInfo si;
if( !getBaseInfo(xml,it.getCurrent(),si) )
{
ostringstream err;
err << ic->getName()
<< "(read_thresholds): не смог получить информацию о пороге"
<< " для датчика " << it.getProp("name");
ucrit << err.str() << endl;
throw uniset::SystemError(err.str());
}
auto inf = ic->find(si.id);
if( !getSensorInfo(xml, it.getCurrent(), inf) ) if( inf == ic->ioEnd() )
{ {
uwarn << ic->getName() ostringstream err;
<< "(read_thresholds): не смог получить информацию по датчику" << endl; err << ic->getName()
continue; << "(read_thresholds): датчик " << it.getProp("name")
<< " НЕ НАЙДЕН В СПИСКЕ датчиков";
ucrit << err.str() << endl;
throw uniset::SystemError(err.str());
} }
uinfo << ic->getName() << "(read_thresholds): " << it.getProp("name") << endl; ulog3 << ic->getName() << "(read_thresholds): " << it.getProp("name") << endl;
UniXML::iterator tit(it); UniXML::iterator tit(it);
...@@ -383,14 +396,17 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod ...@@ -383,14 +396,17 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod
if( !getThresholdInfo(xml, tit, ti) ) if( !getThresholdInfo(xml, tit, ti) )
{ {
uwarn << ic->getName() ostringstream err;
err << ic->getName()
<< "(read_thresholds): не смог получить информацию о пороге" << "(read_thresholds): не смог получить информацию о пороге"
<< " для датчика " << " для датчика "
<< uniset_conf()->oind->getNameById(inf->si.id) << endl; << uniset_conf()->oind->getNameById(si.id);
continue;
ucrit << err.str() << endl;
throw uniset::SystemError(err.str());
} }
uinfo << "(read_thresholds): \tthreshold low=" ulog3 << "(read_thresholds): \tthreshold low="
<< ti.lowlimit << " \thi=" << ti.hilimit << ti.lowlimit << " \thi=" << ti.hilimit
<< " \t sid=" << ti.sid << " \t sid=" << ti.sid
<< " \t invert=" << ti.invert << " \t invert=" << ti.invert
...@@ -409,7 +425,7 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod ...@@ -409,7 +425,7 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod
uwarn << ic->getName() uwarn << ic->getName()
<< "(read_thresholds): не смог получить список заказчиков" << "(read_thresholds): не смог получить список заказчиков"
<< " для порога " << ti.id << " для порога " << ti.id
<< " датчика " << uniset_conf()->oind->getNameById(inf->si.id) << endl; << " датчика " << uniset_conf()->oind->getNameById(si.id) << endl;
} }
} }
} }
...@@ -419,7 +435,7 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod ...@@ -419,7 +435,7 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod
rtslot(xml, tit, it); rtslot(xml, tit, it);
} }
std::shared_ptr<IOController::USensorInfo> uinf = std::static_pointer_cast<IOController::USensorInfo>(inf); std::shared_ptr<IOController::USensorInfo> uinf = std::static_pointer_cast<IOController::USensorInfo>(inf->second);
addthresholdlist(ic, uinf, std::move(tlst) ); addthresholdlist(ic, uinf, std::move(tlst) );
} }
} }
......
...@@ -251,8 +251,8 @@ ...@@ -251,8 +251,8 @@
<item id="65" iotype="DI" name="D65_S" textname="D65" threshold_aid="AI64_AS" lowlimit="3" hilimit="5" threshold_invert="1" rs="5" /> <item id="65" iotype="DI" name="D65_S" textname="D65" threshold_aid="AI64_AS" lowlimit="3" hilimit="5" threshold_invert="1" rs="5" />
</sensors> </sensors>
<thresholds name="thresholds"> <thresholds name="thresholds">
<sensor iotype="AI" name="AI_AS"> <sensor name="AI_AS">
<threshold hilimit="376" id="1" lowlimit="374" name="t1" sensibility="0" sid="Threshold1_S"> <threshold hilimit="376" id="1" lowlimit="374" name="t1" sid="Threshold1_S">
<consumers> <consumers>
<consumer name="TestProc" type="objects"/> <consumer name="TestProc" type="objects"/>
</consumers> </consumers>
......
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