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

(ModbusMultiSlave): мелкие правки

parent 3e8ed111
......@@ -29,7 +29,7 @@ MBSlave::MBSlave( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, cons
prop_prefix("")
{
if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(MBSlave): objId=-1?!! Use --mbs-name" );
throw UniSetTypes::SystemError("(MBSlave): objId=-1?!! Use --" + prefix + "-name" );
auto conf = uniset_conf();
mutex_start.setName(myname + "_mutex_start");
......@@ -148,7 +148,7 @@ MBSlave::MBSlave( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, cons
mbtcp->setAfterSendPause(aftersend_pause);
mbtcp->setReplyTimeout(reply_tout);
mbslot = mbslot = std::static_pointer_cast<ModbusServerSlot>(mbtcp);
mbslot = std::static_pointer_cast<ModbusServerSlot>(mbtcp);
thr = make_shared< ThreadCreator<MBSlave> >(this, &MBSlave::execute_tcp);
thr->setFinalAction(this, &MBSlave::finalThread);
dinfo << myname << "(init): init TCP connection ok. " << " inet=" << iaddr << " port=" << port << endl;
......@@ -157,7 +157,7 @@ MBSlave::MBSlave( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, cons
mbtcp->setLog(dlog());
}
else
throw UniSetTypes::SystemError(myname + "(MBSlave): Unknown slave type. Use: --mbs-type [RTU|TCP]");
throw UniSetTypes::SystemError(myname + "(MBSlave): Unknown slave type. Use: --" + prefix + "-type [RTU|TCP]");
mbslot->connectReadCoil( sigc::mem_fun(this, &MBSlave::readCoilStatus) );
mbslot->connectReadInputStatus( sigc::mem_fun(this, &MBSlave::readInputStatus) );
......
......@@ -158,7 +158,7 @@ void MBTCPMultiSlave::execute_tcp()
if( dlog()->is_level9() )
sslot->setLog(dlog());
for( auto && i : cmap )
for( auto&& i : cmap )
i.second.ptTimeout.reset();
sslot->setMaxSessions( sessMaxNum );
......@@ -175,7 +175,7 @@ void MBTCPMultiSlave::execute_tcp()
sess.clear();
sslot->getSessions(sess);
for( auto && s : sess )
for( auto&& s : sess )
{
auto i = cmap.find( s.iaddr );
......@@ -318,7 +318,7 @@ void MBTCPMultiSlave::initIterators()
shm->initIterator(sesscount_it);
for( auto& i : cmap )
for( auto&& i : cmap )
i.second.initIterators(shm);
}
// -----------------------------------------------------------------------------
......
......@@ -9,6 +9,7 @@
#include "Extensions.h"
#include "RTUExchange.h"
#include "MBSlave.h"
#include "MBTCPMultiSlave.h"
#include "MBTCPMaster.h"
#include "SharedMemory.h"
//#include "UniExchange.h"
......@@ -200,6 +201,35 @@ int main( int argc, const char** argv )
act->add(unet);
}
// ------------- MBTCPMultiSlave --------------
for( unsigned int i = 0; i < MaxAddNum; i++ )
{
stringstream s;
s << "--add-mbmultislave";
if( i > 0 ) s << i;
bool add_mbslave = findArgParam(s.str(), argc, argv) != -1;
if( add_mbslave )
{
stringstream p;
p << "mbms";
if( i > 0 ) p << i;
dinfo << "(smemory-plus): add MBTCPMultiSlave(" << p.str() << ")" << endl;
auto mbs = MBTCPMultiSlave::init_mbslave(argc, argv, shm->getId(), shm, p.str());
if( !mbs )
return 1;
act->add(mbs);
}
}
// ---------------------------------------
// попытка решить вопрос с "зомби" процессами
signal( SIGCHLD, on_sigchild );
......
......@@ -3,6 +3,18 @@
ulimit -Sc 10000000
START=uniset2-start.sh
MBMS=""
for n in `seq 1 10`; do
p=`echo "2050+$n" | bc`
MBMS="$MBMS --add-mbmultislave$n --mbms$n-name MBMultiSlave$n --mbms$n-confnode MBMultiSlave1 --mbms$n-type TCP --mbms$n-inet-addr 127.0.0.1 --mbms$n-inet-port $p --mbms$n-reg-from-id 1 --mbms$n-my-addr 0x01"
done
MBS=""
for n in `seq 1 5`; do
p=`echo "2090+$n" | bc`
MBS="$MBS --add-mbslave$n --mbs$n-name MBSlave$n --mbs$n-confnode MBMultiSlave1 --mbs$n-type TCP --mbs$n-inet-addr 127.0.0.1 --mbs$n-inet-port $p --mbs$n-reg-from-id 1 --mbs$n-my-addr 0x01"
done
${START} -f ./uniset2-smemory-plus --smemory-id SharedMemory --confile test.xml \
--io-name IOControl \
--io-polltime 100 \
......@@ -30,6 +42,8 @@ ${START} -f ./uniset2-smemory-plus --smemory-id SharedMemory --confile test.xml
--mbtcp2-gateway-port 2049 \
--mbtcp2-recv-timeout 200 \
--mbtcp2-force-out 1 \
$MBMS \
$MBS \
--ulog-add-levels system \
$*
# --add-rtu \
......
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