Commit 6e0d9a22 authored by Pavel Vainerman's avatar Pavel Vainerman

Добавлен userparam в функцию UniSetObject::getInfo(),

для возможности "регулировать" вывод информации (setbug #8686)
parent da428026
......@@ -46,6 +46,7 @@
void broadcast(in UniSetTypes::TransportMessage msg);
/*! получение информации о состоянии подчиненных объектов(менеджеров)
* \param userparam - Необязательный пользовательский параметр (см. UniSetObject_i::getInfo()).
* \param MaxLength - ограничение размера возвращаемой
* последовательности структур SimpleInfo.
* \note Если у менеджера количество подчиненных объектов
......@@ -60,7 +61,7 @@
* \todo Подумать насчет применения итератора, при слишком
* большом( >1000 ) количестве подчиненных объектов...
*/
UniSetTypes::SimpleInfoSeq getObjectsInfo( in long MaxLength );
UniSetTypes::SimpleInfoSeq getObjectsInfo( in long MaxLength, in long userparam );
};
//}; // end of module UniSet
......
......@@ -41,7 +41,11 @@
{
UniSetTypes::ObjectId getId(); /*!< получение идентификатора объекта */
UniSetTypes::ObjectType getType(); /*!< получение типа объекта */
UniSetTypes::SimpleInfo getInfo(); /*!< получение информации о внутреннем состоянии объекта */
/*! получение информации о внутреннем состоянии объекта
\param userparam - Необязательный пользовательский параметр
*/
UniSetTypes::SimpleInfo getInfo( in long userparam );
boolean exist(); /*!< проверка существования объекта */
......
......@@ -71,7 +71,7 @@ int getRawValue( const string& args, UInterface& ui );
int getChangedTime( const string& args, UInterface& ui );
int getState( const string& args, UInterface& ui );
int getCalibrate( const string& args, UInterface& ui );
int oinfo( const string& args, UInterface& ui );
int oinfo(const string& args, UInterface& ui , int userparam );
// --------------------------------------------------------------------------
static void print_help(int width, const string& cmd, const string& help, const string& tab = " " )
{
......@@ -106,7 +106,8 @@ static void usage()
cout << endl;
print_help(36, "-r|--configure [FullObjName] ", "Посылка SystemMessage::ReConfiguration всем объектам (процессам) или заданному по имени (FullObjName).\n");
print_help(36, "-l|--logrotate [FullObjName] ", "Посылка SystemMessage::LogRotate всем объектам (процессам) или заданному по имени (FullObjName).\n");
print_help(36, "-p|--oinfo id1@node1,id2@node2,id3,...", "Получить информацию об объектах (SimpleInfo).\n");
print_help(36, "-p|--oinfo id1@node1,id2@node2,id3,... [userparam]", "Получить информацию об объектах (SimpleInfo). \n userparam - необязательный параметр передаваемый в getInfo() каждому объекту\n");
print_help(36, "", "userparam - необязательный параметр передаваемый в getInfo() каждому объекту\n");
cout << endl;
print_help(48, "-x|--setValue id1@node1=val,id2@node2=val2,id3=val3,.. ", "Выставить значения датчиков\n");
print_help(36, "-g|--getValue id1@node1,id2@node2,id3,id4 ", "Получить значения датчиков.\n");
......@@ -140,7 +141,7 @@ int main(int argc, char** argv)
while(1)
{
opt = getopt_long(argc, argv, "hc:beosfur:l:i:x:g:w:y:p:vq", longopts, &optindex);
opt = getopt_long(argc, argv, "hc:beosfur:l:i::x:g:w:y:p:vq", longopts, &optindex);
if( opt == -1 )
break;
......@@ -222,7 +223,12 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf);
ui.initBackId(UniSetTypes::AdminID);
return oinfo(optarg, ui);
int userparam = 0;
if( optind < argc )
userparam = uni_atoi(argv[optind]);
return oinfo(optarg, ui, userparam);
}
break;
......@@ -934,7 +940,7 @@ int configure( const string& arg, UInterface& ui )
}
// --------------------------------------------------------------------------------------
int oinfo( const string& args, UInterface& ui )
int oinfo( const string& args, UInterface& ui, int userparam )
{
auto conf = uniset_conf();
auto sl = UniSetTypes::getObjectsList( args, conf );
......@@ -956,7 +962,7 @@ int oinfo( const string& args, UInterface& ui )
}
else
{
SimpleInfo_var inf = obj->getInfo();
SimpleInfo_var inf = obj->getInfo(userparam);
cout << inf->info << endl;
}
}
......
......@@ -169,7 +169,7 @@
void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() );
void updateValues();
virtual UniSetTypes::SimpleInfo* getInfo() override;
virtual UniSetTypes::SimpleInfo* getInfo( CORBA::Long userparam = 0 ) override;
virtual bool setMsg( UniSetTypes::ObjectId code, bool state = true );
......@@ -427,10 +427,10 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSysCommand( const SystemMessage*
sysCommand(_sm);
}
// -----------------------------------------------------------------------------
UniSetTypes::SimpleInfo* <xsl:value-of select="$CLASSNAME"/>_SK::getInfo()
UniSetTypes::SimpleInfo* <xsl:value-of select="$CLASSNAME"/>_SK::getInfo( CORBA::Long userparam )
{
<xsl:if test="not(normalize-space($BASECLASS)='')">UniSetTypes::SimpleInfo_var i = <xsl:value-of select="$BASECLASS"/>::getInfo();</xsl:if>
<xsl:if test="normalize-space($BASECLASS)=''">UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo();</xsl:if>
<xsl:if test="not(normalize-space($BASECLASS)='')">UniSetTypes::SimpleInfo_var i = <xsl:value-of select="$BASECLASS"/>::getInfo(userparam);</xsl:if>
<xsl:if test="normalize-space($BASECLASS)=''">UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo(userparam);</xsl:if>
ostringstream inf;
......
......@@ -455,6 +455,7 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
* Mon Dec 14 2015 Pavel Vainerman <pv@altlinux.ru> 2.2-alt12
- refactoring: remove xxx_LT classes
- add new function for LT_Object
- add userparam for UniSetObject::getInfo( int userparam )
* Tue Nov 03 2015 Pavel Vainerman <pv@altlinux.ru> 2.2-alt11
- RRDServer: add support 'dsname', check RRD_MAX_DSNAME_LEN
......
......@@ -3255,9 +3255,9 @@ std::ostream& operator<<( std::ostream& os, const MBExchange::ExchangeMode& em )
return os;
}
// -----------------------------------------------------------------------------
UniSetTypes::SimpleInfo* MBExchange::getInfo()
UniSetTypes::SimpleInfo* MBExchange::getInfo( CORBA::Long userparam )
{
UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo();
UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo(userparam);
ostringstream inf;
......
......@@ -232,7 +232,7 @@ class MBExchange:
return mblog;
}
virtual UniSetTypes::SimpleInfo* getInfo() override;
virtual UniSetTypes::SimpleInfo* getInfo( CORBA::Long userparam = 0 ) override;
protected:
virtual void step();
......
......@@ -246,9 +246,9 @@ std::shared_ptr<MBTCPMaster> MBTCPMaster::init_mbmaster(int argc, const char* co
return make_shared<MBTCPMaster>(ID, icID, ic, prefix);
}
// -----------------------------------------------------------------------------
UniSetTypes::SimpleInfo* MBTCPMaster::getInfo()
UniSetTypes::SimpleInfo* MBTCPMaster::getInfo( CORBA::Long userparam )
{
UniSetTypes::SimpleInfo_var i = MBExchange::getInfo();
UniSetTypes::SimpleInfo_var i = MBExchange::getInfo(userparam);
ostringstream inf;
......
......@@ -210,7 +210,7 @@ class MBTCPMaster:
/*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* const* argv );
virtual UniSetTypes::SimpleInfo* getInfo() override;
virtual UniSetTypes::SimpleInfo* getInfo( CORBA::Long userparam = 0 ) override;
protected:
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
......
......@@ -515,9 +515,9 @@ const std::string MBTCPMultiMaster::MBSlaveInfo::getShortInfo() const
return std::move(s.str());
}
// -----------------------------------------------------------------------------
UniSetTypes::SimpleInfo* MBTCPMultiMaster::getInfo()
UniSetTypes::SimpleInfo* MBTCPMultiMaster::getInfo( CORBA::Long userparam )
{
UniSetTypes::SimpleInfo_var i = MBExchange::getInfo();
UniSetTypes::SimpleInfo_var i = MBExchange::getInfo(userparam);
ostringstream inf;
......
......@@ -234,7 +234,7 @@ class MBTCPMultiMaster:
/*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* const* argv );
virtual UniSetTypes::SimpleInfo* getInfo() override;
virtual UniSetTypes::SimpleInfo* getInfo( CORBA::Long userparam = 0 ) override;
protected:
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
......
......@@ -2375,9 +2375,9 @@ ModbusRTU::mbErrCode MBSlave::read4314( ModbusRTU::MEIMessageRDI& query,
return erNoError;
}
// -------------------------------------------------------------------------
UniSetTypes::SimpleInfo* MBSlave::getInfo()
UniSetTypes::SimpleInfo* MBSlave::getInfo( CORBA::Long userparam )
{
UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo();
UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo(userparam);
ostringstream inf;
......
......@@ -370,7 +370,7 @@ class MBSlave:
return mblog;
}
virtual UniSetTypes::SimpleInfo* getInfo() override;
virtual UniSetTypes::SimpleInfo* getInfo( CORBA::Long userparam = 0 ) override;
protected:
......
......@@ -377,9 +377,9 @@ const std::string MBTCPPersistentSlave::ClientInfo::getShortInfo() const
return std::move(s.str());
}
// -----------------------------------------------------------------------------
UniSetTypes::SimpleInfo* MBTCPPersistentSlave::getInfo()
UniSetTypes::SimpleInfo* MBTCPPersistentSlave::getInfo( CORBA::Long userparam )
{
UniSetTypes::SimpleInfo_var i = MBSlave::getInfo();
UniSetTypes::SimpleInfo_var i = MBSlave::getInfo(userparam);
ostringstream inf;
......
......@@ -32,7 +32,7 @@ class MBTCPPersistentSlave:
/*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* const* argv );
UniSetTypes::SimpleInfo* getInfo() override;
UniSetTypes::SimpleInfo* getInfo( CORBA::Long userparam ) override;
protected:
virtual void execute_tcp() override;
......
......@@ -955,9 +955,9 @@ bool SharedMemory::initFromSM( UniSetTypes::ObjectId sm_id, UniSetTypes::ObjectI
return false;
}
// ----------------------------------------------------------------------------
UniSetTypes::SimpleInfo* SharedMemory::getInfo()
UniSetTypes::SimpleInfo* SharedMemory::getInfo( CORBA::Long userparam )
{
UniSetTypes::SimpleInfo_var i = IONotifyController::getInfo();
UniSetTypes::SimpleInfo_var i = IONotifyController::getInfo(userparam);
ostringstream inf;
......@@ -965,7 +965,6 @@ UniSetTypes::SimpleInfo* SharedMemory::getInfo()
inf << vmon.pretty_str() << endl;
inf << "LogServer: " << logserv_host << ":" << logserv_port << endl;
i->info = inf.str().c_str();
return i._retn();
}
......
......@@ -298,7 +298,7 @@ class SharedMemory:
// чтобы понять, когда можно получать от SM данные.
virtual CORBA::Boolean exist() override;
virtual UniSetTypes::SimpleInfo* getInfo() override;
virtual UniSetTypes::SimpleInfo* getInfo( CORBA::Long userparam = 0 ) override;
void addReadItem( Restorer_XML::ReaderSlot sl );
......
......@@ -893,9 +893,9 @@ void UNetExchange::receiverEvent( const shared_ptr<UNetReceiver>& r, UNetReceive
}
}
// -----------------------------------------------------------------------------
UniSetTypes::SimpleInfo* UNetExchange::getInfo()
UniSetTypes::SimpleInfo* UNetExchange::getInfo( CORBA::Long userparam )
{
UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo();
UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo(userparam);
ostringstream inf;
......
......@@ -123,7 +123,7 @@ class UNetExchange:
return unetlog;
}
virtual UniSetTypes::SimpleInfo* getInfo() override;
virtual UniSetTypes::SimpleInfo* getInfo( CORBA::Long userparam = 0 ) override;
protected:
......
......@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-12-14+03:00
// generate timestamp: 2015-12-15+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
......@@ -39,7 +39,7 @@ class UObject_SK:
void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() );
void updateValues();
virtual UniSetTypes::SimpleInfo* getInfo() override;
virtual UniSetTypes::SimpleInfo* getInfo( CORBA::Long userparam = 0 ) override;
virtual bool setMsg( UniSetTypes::ObjectId code, bool state = true );
......
......@@ -11,7 +11,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-12-14+03:00
// generate timestamp: 2015-12-15+03:00
// -----------------------------------------------------------------------------
#include <memory>
#include <iomanip>
......@@ -401,9 +401,9 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
sysCommand(_sm);
}
// -----------------------------------------------------------------------------
UniSetTypes::SimpleInfo* UObject_SK::getInfo()
UniSetTypes::SimpleInfo* UObject_SK::getInfo( CORBA::Long userparam )
{
UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo();
UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo(userparam);
ostringstream inf;
......
......@@ -50,7 +50,7 @@ class IOController:
return UniSetTypes::ObjectType("IOController");
}
virtual UniSetTypes::SimpleInfo* getInfo() override;
virtual UniSetTypes::SimpleInfo* getInfo( ::CORBA::Long userparam = 0 ) override;
virtual CORBA::Long getValue( UniSetTypes::ObjectId sid ) override;
......
......@@ -75,7 +75,7 @@ class UniSetManager:
// ------ функции объявленные в интерфейсе(IDL) ------
virtual void broadcast( const UniSetTypes::TransportMessage& msg) override;
virtual UniSetTypes::SimpleInfoSeq* getObjectsInfo( CORBA::Long MaxLength = 300 ) override ;
virtual UniSetTypes::SimpleInfoSeq* getObjectsInfo( CORBA::Long MaxLength = 300, CORBA::Long userparam = 0 ) override ;
// --------------------------
virtual bool add( const std::shared_ptr<UniSetObject>& obj );
......@@ -151,8 +151,8 @@ class UniSetManager:
typedef UniSetManagerList::iterator MListIterator;
int getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, UniSetTypes::SimpleInfoSeq* seq,
int begin, const long uplimit );
int getObjectsInfo(const std::shared_ptr<UniSetManager>& mngr, UniSetTypes::SimpleInfoSeq* seq,
int begin, const long uplimit, CORBA::Long userparam );
PortableServer::POA_var poa;
PortableServer::POAManager_var pman;
......
......@@ -103,7 +103,7 @@ class UniSetObject:
{
return UniSetTypes::ObjectType("UniSetObject");
}
virtual UniSetTypes::SimpleInfo* getInfo() override;
virtual UniSetTypes::SimpleInfo* getInfo( ::CORBA::Long userparam = 0 ) override;
friend std::ostream& operator<<(std::ostream& os, UniSetObject& obj );
//! поместить сообщение в очередь
......
......@@ -514,12 +514,12 @@ int UniSetManager::objectsCount()
// ------------------------------------------------------------------------------------------
int UniSetManager::getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, SimpleInfoSeq* seq,
int begin, const long uplimit )
int begin, const long uplimit, CORBA::Long userparam )
{
auto ind = begin;
// получаем у самого менджера
SimpleInfo_var msi = mngr->getInfo();
SimpleInfo_var msi = mngr->getInfo(userparam);
(*seq)[ind] = msi;
ind++;
......@@ -531,7 +531,7 @@ int UniSetManager::getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, S
{
try
{
SimpleInfo_var si = (*it)->getInfo();
SimpleInfo_var si = (*it)->getInfo(userparam);
(*seq)[ind] = si;
ind++;
......@@ -555,7 +555,7 @@ int UniSetManager::getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, S
// а далее у его менеджеров (рекурсивно)
for( auto& i : mlist )
{
ind = getObjectsInfo(i, seq, ind, uplimit);
ind = getObjectsInfo(i, seq, ind, uplimit, userparam );
if( ind > uplimit )
break;
......@@ -565,7 +565,7 @@ int UniSetManager::getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, S
}
// ------------------------------------------------------------------------------------------
SimpleInfoSeq* UniSetManager::getObjectsInfo( CORBA::Long maxlength )
SimpleInfoSeq* UniSetManager::getObjectsInfo(CORBA::Long maxlength , CORBA::Long userparam )
{
SimpleInfoSeq* res = new SimpleInfoSeq(); // ЗА ОСВОБОЖДЕНИЕ ПАМЯТИ ОТВЕЧАЕТ КЛИЕНТ!!!!!!
// поэтому ему лучше пользоваться при получении _var-классом
......@@ -580,7 +580,7 @@ SimpleInfoSeq* UniSetManager::getObjectsInfo( CORBA::Long maxlength )
int ind = 0;
const int limit = length;
ind = getObjectsInfo( get_mptr(), res, ind, limit );
ind = getObjectsInfo( get_mptr(), res, ind, limit, userparam );
return res;
}
......
......@@ -926,7 +926,7 @@ timeout_t UniSetObject::askTimer( TimerId timerid, timeout_t timeMS, clock_t tic
}
// ------------------------------------------------------------------------------------------
UniSetTypes::SimpleInfo* UniSetObject::getInfo()
UniSetTypes::SimpleInfo* UniSetObject::getInfo( ::CORBA::Long userparam )
{
ostringstream info;
info.setf(ios::left, ios::adjustfield);
......
......@@ -849,7 +849,7 @@ void IOController::USensorInfo::checkDepend( std::shared_ptr<USensorInfo>& d_it,
ic->localSetValue( it, si.id, real_value, sup_id );
}
// -----------------------------------------------------------------------------
UniSetTypes::SimpleInfo* IOController::getInfo()
UniSetTypes::SimpleInfo* IOController::getInfo( ::CORBA::Long userparam )
{
UniSetTypes::SimpleInfo_var i = UniSetManager::getInfo();
......@@ -859,7 +859,6 @@ UniSetTypes::SimpleInfo* IOController::getInfo()
inf << "isPingDBServer = " << isPingDBServer << endl;
inf << "ioListSize = " << ioList.size() << endl;
i->info = inf.str().c_str();
return i._retn();
}
......
......@@ -231,7 +231,11 @@ extensions/UniNetwork/uninet.cc
extensions/libUniSet2Extensions.pc.in
extensions/Makefile.am
IDL/Processes/Makefile.am
IDL/Processes/IOController_i.idl
IDL/UniSetTypes/Makefile.am
IDL/UniSetTypes/UniSetTypes_i.idl
IDL/UniSetTypes/UniSetObject_i.idl
IDL/UniSetTypes/UniSetManager_i.idl
IDL/Makefile.am
include/modbus/Makefile.am
include/modbus/ModbusClient.h
......
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