Commit b245e46f authored by Pavel Vainerman's avatar Pavel Vainerman

(tests): добавил тесты для UIInterface совместно с SharedMemory

(проверка удалённых вызовов). Исправил некоторые части кода.
parent 5a26585e
......@@ -10,7 +10,7 @@ tests_with_conf_SOURCES = tests_with_conf.cc
tests_with_conf_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la
tests_with_conf_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include -I$(includedir)/Catch
tests_with_sm_SOURCES = tests_with_sm.cc
tests_with_sm_SOURCES = tests_with_sm.cc ui.cc
tests_with_sm_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la \
$(top_builddir)/extensions/SharedMemory/libUniSet2SharedMemory.la $(SIGC_LIBS) $(COMCPP_LIBS)
tests_with_sm_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include -I$(includedir)/Catch \
......
......@@ -4,6 +4,7 @@
#include <string>
#include "Debug.h"
#include "UniSetActivator.h"
#include "PassiveTimer.h"
#include "SharedMemory.h"
#include "Extensions.h"
// --------------------------------------------------------------------------
......@@ -47,6 +48,17 @@ int main(int argc, char* argv[] )
SystemMessage sm(SystemMessage::StartUp);
act->broadcast( sm.transport_msg() );
act->run(true);
int tout = 6000;
PassiveTimer pt(tout);
while( !pt.checkTime() && !act->exist() )
msleep(100);
if( !act->exist() )
{
cerr << "(tests_with_sm): SharedMemory not exist! (timeout=" << tout << ")" << endl;
return 1;
}
int ret = session.run();
......
#!/bin/sh
# '--' - нужен для отделения аоргументов catch, от наших..
uniset-start.sh -f ./tests_with_sm $* -- --confile tests_with_sm.xml
uniset-start.sh -f ./tests_with_sm $* -- --confile tests_with_sm.xml --e-startup-pause 10 --ulog-levels warn,crit --dlog-levels warn,crit
......@@ -4,7 +4,7 @@
<!-- Общие(стартовые) параметры по UniSet -->
<UniSet>
<NameService host="localhost" port="2809"/>
<LocalNode name="LocalhostNode"/>
<LocalNode name="localhost"/>
<RootSection name="UNISET_PLC"/>
<CountOfNet name="1"/>
<RepeatCount name="3"/>
......@@ -171,7 +171,7 @@
textname - текстовое имя датчика
-->
<nodes port="2809" unet_broadcast_ip="192.168.1.255" unet_broadcast_ip2="192.168.122.255">
<item id="3000" dbserver="DBServer1" infserver="InfoServer" ip="127.0.0.1" name="LocalhostNode" textname="Локальный узел" unet_ignore="0" unet_port="2048">
<item id="3000" dbserver="DBServer1" infserver="InfoServer" ip="127.0.0.1" name="localhost" textname="Локальный узел" unet_ignore="0" unet_port="2048">
<iocards>
<item card="1" name="DI32"/>
<item card="2" name="DO32"/>
......@@ -179,8 +179,8 @@
</iocards>
</item>
<item id="3001" infserver="InfoServer" ip="127.0.0.1" name="LocalhostNode1" textname="Локальный узел" unet_ignore="0" unet_port="2049"/>
<item id="3002" ip="192.168.56.10" name="Node1" textname="Node1" unet_ignore="0" unet_ip="192.168.56.255" unet_port="3001" unet_respond_id="Input1_S" unet_respond_invert="1"/>
<item id="3003" ip="192.168.56.11" name="Node2" textname="Node2" unet_ignore="0" unet_ip="192.168.56.255" unet_port="3002"/>
<item id="3002" ip="192.168.56.10" name="node1" textname="Node1" unet_ignore="0" unet_ip="192.168.56.255" unet_port="3001" unet_respond_id="Input1_S" unet_respond_invert="1"/>
<item id="3003" ip="192.168.56.11" name="node2" textname="Node2" unet_ignore="0" unet_ip="192.168.56.255" unet_port="3002"/>
</nodes>
<!-- ************************ Датчики ********************** -->
<sensors name="Sensors">
......
......@@ -255,7 +255,7 @@ class IONotifyController:
struct ThresholdsListInfo
{
ThresholdsListInfo(){}
ThresholdsListInfo( IOController_i::SensorInfo& si, ThresholdExtList&& list,
ThresholdsListInfo( const IOController_i::SensorInfo& si, ThresholdExtList&& list,
UniversalIO::IOType t=UniversalIO::AI ):
si(si),type(t),list( std::move(list) ){}
......
......@@ -71,7 +71,7 @@
UniSetTypes::ObjectPtr resolve(const std::string& name, const std::string& NSName="NameService")const throw(UniSetTypes::ORepFailed, UniSetTypes::NameNotFound);
/*! Проверка существования и доступности объекта */
bool isExist( const UniSetTypes::ObjectPtr oref ) const;
bool isExist( const UniSetTypes::ObjectPtr& oref ) const;
/*! Проверка существования и доступности объекта */
bool isExist( const std::string& fullName ) const;
......
......@@ -86,7 +86,7 @@ class UInterface
void fastSetValue( const IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId supplier );
//! Получение состояния для списка указанных датчиков
IOController_i::SensorInfoSeq_var getSensorSeq( UniSetTypes::IDList& lst );
IOController_i::SensorInfoSeq_var getSensorSeq( const UniSetTypes::IDList& lst );
/*! Изменения состояния списка входов/выходов
\return Возвращает список не найденных идентификаторов */
......@@ -103,7 +103,7 @@ class UInterface
UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId ) const throw(UI_THROW_EXCEPTIONS);
//! Заказ по списку
UniSetTypes::IDSeq_var askSensorsSeq( UniSetTypes::IDList& lst, UniversalIO::UIOCommand cmd,
UniSetTypes::IDSeq_var askSensorsSeq( const UniSetTypes::IDList& lst, UniversalIO::UIOCommand cmd,
UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId );
// ------------------------------------------------------
......
......@@ -105,17 +105,17 @@ namespace UniSetTypes
void add( ObjectId id );
void del( ObjectId id );
inline int size(){ return lst.size(); }
inline bool empty(){ return lst.empty(); }
inline int size() const { return lst.size(); }
inline bool empty() const { return lst.empty(); }
std::list<ObjectId> getList();
// за освобождение выделеной памяти
// отвечает вызывающий!
IDSeq* getIDSeq();
IDSeq* getIDSeq() const;
//
ObjectId getFirst();
ObjectId getFirst() const;
ObjectId node; // узел, на котором находятся датчики
private:
......
......@@ -1141,7 +1141,7 @@ bool UInterface::isExist( const UniSetTypes::ObjectId id ) const
}
catch( UniSetTypes::Exception& ex )
{
// uwarn << "UI(isExist): " << ex << endl;
// uwarn << "UI(isExist): " << ex << endl;
}
catch(...){}
return false;
......@@ -1594,7 +1594,7 @@ IOController_i::CalibrateInfo UInterface::getCalibrateInfo( const IOController_i
throw UniSetTypes::TimeOut(set_err("UI(getCalibrateInfo): Timeout",si.id,si.node));
}
// --------------------------------------------------------------------------------------------
IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( UniSetTypes::IDList& lst )
IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::IDList& lst )
{
if( lst.empty() )
return IOController_i::SensorInfoSeq_var();
......@@ -1622,7 +1622,7 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( UniSetTypes::IDList&
IOController_i_var iom = IOController_i::_narrow(oref);
UniSetTypes::IDSeq_var seq = lst.getIDSeq();
UniSetTypes::IDSeq_var seq(lst.getIDSeq());
return iom->getSensorSeq(seq);
}
catch(CORBA::TRANSIENT){}
......@@ -1748,7 +1748,7 @@ IDSeq_var UInterface::setOutputSeq( const IOController_i::OutSeq& lst, UniSetTyp
throw UniSetTypes::TimeOut(set_err("UI(setOutputSeq): Timeout",lst[0].si.id,lst[0].si.node));
}
// --------------------------------------------------------------------------------------------
UniSetTypes::IDSeq_var UInterface::askSensorsSeq( UniSetTypes::IDList& lst,
UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst,
UniversalIO::UIOCommand cmd, UniSetTypes::ObjectId backid )
{
if( lst.empty() )
......
......@@ -398,7 +398,7 @@ bool ObjectRepository::isExist( const string& fullName ) const
// --------------------------------------------------------------------------
bool ObjectRepository::isExist( const ObjectPtr oref ) const
bool ObjectRepository::isExist( const ObjectPtr& oref ) const
{
try
{
......
......@@ -141,7 +141,7 @@ std::list<UniSetTypes::ObjectId> UniSetTypes::IDList::getList()
return lst;
}
UniSetTypes::ObjectId UniSetTypes::IDList::getFirst()
UniSetTypes::ObjectId UniSetTypes::IDList::getFirst() const
{
if( lst.empty() )
return UniSetTypes::DefaultObjectId;
......@@ -151,7 +151,7 @@ UniSetTypes::ObjectId UniSetTypes::IDList::getFirst()
// за освобождение выделеной памяти
// отвечает вызывающий!
IDSeq* UniSetTypes::IDList::getIDSeq()
IDSeq* UniSetTypes::IDList::getIDSeq() const
{
IDSeq* seq = new IDSeq();
seq->length(lst.size());
......
......@@ -861,6 +861,9 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet
for( auto it2= it->second.list.begin(); it2!=it->second.list.end(); ++it2 )
{
/*! \warning На самом деле список разрешает иметь много порогов с одинаковым ID, для разных "заказчиков".
Но здесь мы возвращаем первый встретившийся..
*/
if( it2->id == tid )
return IONotifyController_i::ThresholdInfo( *it2 );
}
......
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