Commit 148f9e26 authored by Pavel Vainerman's avatar Pavel Vainerman

Исправил ошибку с вылетом в uniset2-smonit, а так же небольшие правки.

parent cff1c7df
......@@ -71,9 +71,9 @@ int main(int argc, char** argv)
// надо ли писать изменения в БД
bool dbDumping = conf->getArgInt("--dbDumping");
NullController nc(ID,askfile,s_field,s_fvalue,c_field,c_fvalue,dbDumping);
UniSetActivatorPtr act = UniSetActivator::Instance();
act->add( nc.get_ptr() );
auto nc = make_shared<NullController>(ID,askfile,s_field,s_fvalue,c_field,c_fvalue,dbDumping);
auto act = UniSetActivator::Instance();
act->add(nc);
act->run(false);
return 0;
}
......
......@@ -34,22 +34,26 @@ int main( int argc, const char **argv )
return 0;
}
UniSetActivatorPtr act = UniSetActivator::Instance();
SMonitor tp(ID);
act->add(tp.get_ptr());
auto act = UniSetActivator::Instance();
auto smon = make_shared<SMonitor>(ID);
act->add(smon);
SystemMessage sm(SystemMessage::StartUp);
act->broadcast( sm.transport_msg() );
act->run(false);
return 0;
}
catch( Exception& ex )
catch( const Exception& ex )
{
cout << "(main):" << ex << endl;
}
catch( const std::exception& ex )
{
cout << "(main): exception: " << ex.what() << endl;
}
catch(...)
{
cout << "(main): Неизвестное исключение!!!!"<< endl;
cout << "(main): Unknown exception!!"<< endl;
}
return 1;
......
#!/bin/sh
uniset2-start.sh -f ./uniset2-smonit --name TestProc --confile test.xml --sid $*
uniset2-start.sh -g ./uniset2-smonit --name TestProc --confile test.xml --sid $*
#--ulog-add-levels system,info,level9 $*
......@@ -12,7 +12,7 @@
Name: libuniset2
Version: 2.0
Release: alt14
Release: alt15
Summary: UniSet - library for building distributed industrial control systems
......@@ -406,6 +406,10 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet2.pc
%changelog
* Sun Feb 01 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt15
- fixed minor bug in uniset2-smonit utility
- minor fixes
* Mon Jan 26 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt14
- change LogServer,LogSession,LogReader interfaces
......
......@@ -875,7 +875,7 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
for( auto i=0; i<ret.bcnt; i++ )
{
ModbusRTU::DataBits b(ret.data[i]);
for( auto k=0;k<ModbusRTU::BitsPerByte && m<p->q_count; k++,it++,m++ )
for( unsigned int k=0;k<ModbusRTU::BitsPerByte && m<p->q_count; k++,it++,m++ )
it->second->mbval = b[k];
}
it--;
......@@ -889,7 +889,7 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
for( auto i=0; i<ret.bcnt; i++ )
{
ModbusRTU::DataBits b(ret.data[i]);
for( auto k=0;k<ModbusRTU::BitsPerByte && m<p->q_count; k++,it++,m++ )
for( unsigned int k=0;k<ModbusRTU::BitsPerByte && m<p->q_count; k++,it++,m++ )
it->second->mbval = b[k] ? 1 : 0;
}
it--;
......@@ -974,7 +974,7 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
}
ModbusRTU::ForceCoilsMessage msg(dev->mbaddr,p->mbreg);
for( auto i=0; i<p->q_count; i++,it++ )
for( unsigned i=0; i<p->q_count; i++,it++ )
msg.addBit( (it->second->mbval ? true : false) );
it--;
......@@ -1298,7 +1298,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
else
{
ModbusRTU::ModbusData* data = new ModbusRTU::ModbusData[VTypes::F2::wsize()];
for( unsigned int k=0; k<VTypes::F2::wsize(); k++, i++ )
for( int k=0; k<VTypes::F2::wsize(); k++, i++ )
data[k] = i->second->mbval;
float f=0;
......@@ -1327,14 +1327,14 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
{
float f = IOBase::processingFasAO( p, shm, force_out );
VTypes::F4 f4(f);
for( unsigned int k=0; k<VTypes::F4::wsize(); k++, i++ )
for( int k=0; k<VTypes::F4::wsize(); k++, i++ )
i->second->mbval = f4.raw.v[k];
}
}
else
{
ModbusRTU::ModbusData* data = new ModbusRTU::ModbusData[VTypes::F4::wsize()];
for( unsigned int k=0; k<VTypes::F4::wsize(); k++, i++ )
for( int k=0; k<VTypes::F4::wsize(); k++, i++ )
data[k] = i->second->mbval;
VTypes::F4 f(data,VTypes::F4::wsize());
......@@ -1369,7 +1369,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
else
{
ModbusRTU::ModbusData* data = new ModbusRTU::ModbusData[VTypes::I2::wsize()];
for( unsigned int k=0; k<VTypes::I2::wsize(); k++, i++ )
for( int k=0; k<VTypes::I2::wsize(); k++, i++ )
data[k] = i->second->mbval;
int v = 0;
......@@ -1415,7 +1415,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
else
{
ModbusRTU::ModbusData* data = new ModbusRTU::ModbusData[VTypes::U2::wsize()];
for( unsigned int k=0; k<VTypes::U2::wsize(); k++, i++ )
for( int k=0; k<VTypes::U2::wsize(); k++, i++ )
data[k] = i->second->mbval;
unsigned int v = 0;
......
......@@ -161,6 +161,11 @@ public:
inline void showLogType(bool s)
{ show_logtype = s; }
inline std::ostream& log(Debug::type l)
{
return this->operator[](l);
}
// короткие функции (для удобства)
// log.level1() - вывод с датой и временем "date time [LEVEL] ...",
// если вывод даты и времени не выключен при помощи showDateTime(false)
......
......@@ -144,7 +144,7 @@ class ModbusClient
/*! установить паузу при ожидании символа */
inline void setSleepPause( timeout_t usec ){ sleepPause_usec = usec; }
void initLog( UniSetTypes::Configuration* conf, const std::string& name, const std::string& logfile="" );
void initLog( std::shared_ptr<UniSetTypes::Configuration> conf, const std::string& name, const std::string& logfile="" );
void setLog( std::shared_ptr<DebugStream> dlog );
......
......@@ -7,7 +7,7 @@ using namespace std;
#if 0
UModbus::UModbus( UTypes::Params* p )throw(UException):
mb(0),
port(512),
port(502),
ip(""),
tout_msec(5000)
{
......@@ -22,10 +22,10 @@ UModbus::UModbus( UTypes::Params* p )throw(UException):
}
//---------------------------------------------------------------------------
UModbus::UModbus( int argc, char** argv )throw(UException):
mb(0),
ip(""),
port(512),
tout_msec(5000)
mb(0),
port(502),
ip(""),
tout_msec(5000)
{
try
{
......@@ -40,8 +40,8 @@ tout_msec(5000)
// --------------------------------------------------------------------------
UModbus::UModbus():
mb(0),
port(502),
ip(""),
port(512),
tout_msec(5000)
{
mb = new ModbusTCPMaster();
......
......@@ -220,7 +220,7 @@ void ComPort485F::sendByte( unsigned char x )
// --------------------------------------------------------------------------------
void ComPort485F::save2queue( unsigned char*msg, int len, int bnum )
{
for( unsigned int i=0; i<len && i<bnum; i++ )
for( auto i=0; i<len && i<bnum; i++ )
{
wq.push(msg[i]);
// fprintf(stderr,"save 2 squeue: %x\n",msg[i]);
......
......@@ -1258,7 +1258,7 @@ mbErrCode ModbusClient::send( ModbusMessage& msg )
}
// -------------------------------------------------------------------------
void ModbusClient::initLog( UniSetTypes::Configuration* conf,
void ModbusClient::initLog( std::shared_ptr<UniSetTypes::Configuration> conf,
const std::string& lname, const string& logfile )
{
conf->initLogStream(dlog,lname);
......
......@@ -58,7 +58,7 @@ mbErrCode ModbusTCPCore::sendData( ost::TCPStream* tcp, unsigned char* buf, int
try
{
for( unsigned int i=0; i<len; i++ )
for( auto i=0; i<len; i++ )
(*tcp) << buf[i];
return erNoError;
......
......@@ -33,13 +33,13 @@ TCPSession(server)
// -------------------------------------------------------------------------
LogSession::LogSession( ost::TCPSocket &server, std::shared_ptr<DebugStream>& _log, timeout_t _sessTimeout, timeout_t _cmdTimeout, timeout_t _outTimeout, timeout_t _delay ):
TCPSession(server),
peername(""),
caddr(""),
log(_log),
sessTimeout(_sessTimeout),
cmdTimeout(_cmdTimeout),
outTimeout(_outTimeout),
delayTime(_delay),
peername(""),
caddr(""),
log(_log),
cancelled(false)
{
log_notify = ATOMIC_VAR_INIT(0);
......
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