Commit 4e1bea37 authored by Pavel Vaynerman's avatar Pavel Vaynerman

Merge branch 'master' of git.eter:/projects/uniset

parents ee470b31 8936f108
......@@ -41,7 +41,7 @@ static struct option longopts[] = {
{ "confile", required_argument, 0, 'c' },
{ "create", no_argument, 0, 'b' },
{ "exist", no_argument, 0, 'e' },
{ "omap", no_argument, 0, 'o' },
{ "omap", no_argument, 0, 'o' },
{ "msgmap", no_argument, 0, 'm' },
{ "start", no_argument, 0, 's' },
{ "finish", no_argument, 0, 'f' },
......@@ -58,9 +58,9 @@ static struct option longopts[] = {
{ "setState", required_argument, 0, 'j' },
{ "getValue", required_argument, 0, 'g' },
{ "getState", required_argument, 0, 'k' },
{ "getRawValue", required_argument, 0, 'w' },
{ "getCalibrate", required_argument, 0, 'y' },
{ "oinfo", required_argument, 0, 'p' },
{ "getRawValue", required_argument, 0, 'w' },
{ "getCalibrate", required_argument, 0, 'y' },
{ "oinfo", required_argument, 0, 'p' },
{ NULL, 0, 0, 0 }
};
......@@ -69,10 +69,10 @@ string conffile("configure.xml");
// --------------------------------------------------------------------------
static bool commandToAll(const string section, ObjectRepository *rep, Command cmd);
static void createSections(UniSetTypes::Configuration* c);
bool separateArgs(string &args, string &arg);
static bool separateArgs(string &args, string &arg);
//static bool getID( const string arg, ObjectId id, ObjectId node );
// --------------------------------------------------------------------------
int omap();
int omap();
int msgmap();
int configure( string args, UniversalInterface &ui );
int logRotate( string args, UniversalInterface &ui );
......@@ -88,7 +88,7 @@ int getValue( string args, UniversalInterface &ui );
int getRawValue( string args, UniversalInterface &ui );
int getState( string args, UniversalInterface &ui );
int getCalibrate( string args, UniversalInterface &ui );
int oinfo( string args, UniversalInterface &ui );
int oinfo( string args, UniversalInterface &ui );
// --------------------------------------------------------------------------
static void print_help(int width, const string cmd, const string help, const string tab=" " )
......@@ -331,7 +331,7 @@ int main(int argc, char** argv)
uniset_init(argc,argv,conffile);
UniversalInterface ui(conf);
Command cmd=StartUp;
Command cmd=StartUp;
ObjectRepository* rep = new ObjectRepository(conf);
commandToAll(conf->getServicesSection(), rep, (Command)cmd);
commandToAll(conf->getControllersSection(), rep, (Command)cmd);
......@@ -369,7 +369,7 @@ int main(int argc, char** argv)
commandToAll(conf->getControllersSection(), rep, (Command)cmd);
commandToAll(conf->getObjectsSection(), rep, (Command)cmd);
delete rep;
cout<<"(finish): done"<<endl;
cout<<"(finish): done"<<endl;
}
return 0;
......@@ -410,7 +410,7 @@ int main(int argc, char** argv)
commandToAll(conf->getControllersSection(), rep, (Command)cmd);
commandToAll(conf->getObjectsSection(), rep, (Command)cmd);
delete rep;
// cout<<"(foldUp): done"<<endl;
// cout<<"(foldUp): done"<<endl;
}
return 0;
......@@ -591,7 +591,7 @@ bool separateArgs(string &args,string &arg)
if (args==arg)
args="";
return true;
return true;
}
// ==============================================================================================
......@@ -642,7 +642,7 @@ int alarm(string args, UniversalInterface &ui)
UniSetTypes::DefaultObjectId, conf->getLocalNode());
TransportMessage tm(am.transport_msg());
cout << "Administrator Alarm: " << endl;
cout << "Administrator Alarm: " << endl;
ui.send(conf->getInfoServer(), tm);
return 0;
}
......@@ -672,13 +672,13 @@ int alarm(string args, UniversalInterface &ui)
{
cerr<<"(alarm): ch is not specified ! \n";
unideb[Debug::WARN] << "ch is not specified ! \n";
return 1;
return 1;
}
switch(chid)
{
case 1:
ch = AlarmMessage::Normal;
ch = AlarmMessage::Normal;
break;
case 2:
......@@ -741,7 +741,7 @@ int info(string arg, UniversalInterface &ui)
cout << "info: (" << code << ") ";
cout << conf->mi->getMessage(code);
ui.send(conf->getInfoServer(), tm);
cout << "send info OK" << endl;
cout << "send info OK" << endl;
return 0;
}
......@@ -802,7 +802,7 @@ int dnotify(string args, UniversalInterface &ui)
cout << ": " << conf->oind->getMapName(id) << "\n\n";
SensorMessage sm(sid,(bool)val);
sm.consumer = id;
sm.consumer = id;
TransportMessage tm(sm.transport_msg());
ui.send(id,tm);
......@@ -815,7 +815,8 @@ int saveValue(string args, UniversalInterface &ui)
int err;
err=0;
string arg;
UniSetTypes::ObjectId sid(DefaultObjectId);
UniSetTypes::ObjectId sid = DefaultObjectId;
UniSetTypes::ObjectId node = DefaultObjectId;
long val;
cout << "====== saveValue ======" << endl;
......@@ -823,7 +824,7 @@ int saveValue(string args, UniversalInterface &ui)
{
if( isdigit( arg[0] ) )
{
if( sscanf( arg.c_str(),"%ld=%ld",&sid,&val ) < 2 )
if( sscanf( arg.c_str(),"%ld:%ld=%ld",&sid,&node,&val ) < 2 )
{
cout << i <<"\t------------------------"<< endl;
cerr << "!!!!!!!!! SensorId=Value #"<<i<<" '"<<arg<<"' !!!!!!\n"<< endl;
......@@ -848,14 +849,17 @@ int saveValue(string args, UniversalInterface &ui)
continue;
}
}
cout << i <<"\t------------------------"<< endl;
cout << i <<"\t------------------------"<< endl;
try
{
// cout <<"\n\t"<<sid<<"\t"<<val<<endl;
// cout <<"\n\t"<<sid<<"\t"<<val<<endl;
cout << " value: " << val << endl;
cout << " name: (" << sid << ") " << conf->oind->getMapName(sid) << endl;
cout << " text: " << conf->oind->getTextName(sid) << "\n\n";
ui.saveValue(sid,val,UniversalIO::AnalogInput);
if( node == DefaultObjectId )
node = conf->getLocalNode();
ui.saveValue(sid,val,UniversalIO::AnalogInput,node);
}
catch(Exception& ex)
{
......@@ -1319,3 +1323,32 @@ int oinfo(string arg, UniversalInterface &ui )
}
// --------------------------------------------------------------------------------------
/*
bool getID( const string arg, ObjectId id, ObjectId node )
{
if( isdigit( arg[0] ) )
{
if( sscanf( arg.c_str(),"%ld",&id ) < 1 )
{
cout << i <<"\t------------------------"<< endl;
cerr << "!!!!!!!! SensorID #"<<i<<" '"<<arg<<"' !!!!!!!\n"<< endl;
err = 1;
vout<<"| "<<arg<<"\t| ?\t| SensorID !!!\n-----------------\n";
continue;
}
}
string::size_type pos = arg.find_first_of(":");
if( pos == string::npos )
{
id = uni_atoi(arg);
return true;
}
id = uni_atoi(name.substr(0,pos-1));
node = uni_atoi( name.substr(pos+1,name.size()) );
return true;
}
*/
// --------------------------------------------------------------------------------------
......@@ -30,7 +30,10 @@ libUniSetIOControl_la_SOURCES = ComediInterface.cc IOControl.cc
# install
devel_include_HEADERS = *.h
devel_includedir = $(includedir)/@PACKAGE@/extensions
devel_includedir = $(pkgincludedir)/extensions
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libUniSetIOControl.pc
all-local:
ln -sf ../IOControl/$(devel_include_HEADERS) ../include
......@@ -28,7 +28,10 @@ bin_PROGRAMS = @PACKAGE@-logicproc @PACKAGE@-plogicproc
# install
devel_include_HEADERS = *.h
devel_includedir = $(includedir)/@PACKAGE@/extensions
devel_includedir = $(pkgincludedir)/extensions
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libUniSetLogicProcessor.pc
all-local:
ln -sf ../LogicProcessor/$(devel_include_HEADERS) ../include
......@@ -17,7 +17,10 @@ libUniSetMBTCPMaster_la_SOURCES = MBMaster.cc
# install
devel_include_HEADERS = *.h
devel_includedir = $(includedir)/@PACKAGE@/extensions
devel_includedir = $(pkgincludedir)/extensions
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libUniSetMBTCPMaster.pc
all-local:
ln -sf ../MBTCPMaster/$(devel_include_HEADERS) ../include
......@@ -17,7 +17,10 @@ libUniSetMBSlave_la_SOURCES = MBSlave.cc
# install
devel_include_HEADERS = *.h
devel_includedir = $(includedir)/@PACKAGE@/extensions
devel_includedir = $(pkgincludedir)/extensions
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libUniSetMBSlave.pc
all-local:
ln -sf ../ModbusSlave/$(devel_include_HEADERS) ../include
......@@ -29,7 +29,10 @@ rtustate_SOURCES = rtustate.cc
# install
devel_include_HEADERS = *.h
devel_includedir = $(includedir)/@PACKAGE@/extensions
devel_includedir = $(pkgincludedir)/extensions
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libUniSetRTU.pc
all-local:
ln -sf ../RTUExchange/$(devel_include_HEADERS) ../include
......@@ -14,7 +14,10 @@ include $(top_builddir)/conf/setting.mk
# install
devel_include_HEADERS = *.h
devel_includedir = $(includedir)/@PACKAGE@/extensions
devel_includedir = $(pkgincludedir)/extensions
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libUniSetSharedMemory.pc
all-local:
ln -sf ../SharedMemory/$(devel_include_HEADERS) ../include
......@@ -18,7 +18,10 @@ libUniSetUDP_la_SOURCES = UDPPacket.cc UDPExchange.cc
# install
devel_include_HEADERS = *.h
devel_includedir = $(includedir)/@PACKAGE@/extensions
devel_includedir = $(pkgincludedir)/extensions
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libUniSetUDP.pc
all-local:
ln -sf ../UDPExchange/$(devel_include_HEADERS) ../include
......@@ -8,7 +8,7 @@ include $(top_builddir)/conf/common.mk
# install
devel_include_HEADERS = *.h *.hh
devel_includedir = $(includedir)/@PACKAGE@
devel_includedir = $(pkgincludedir)
all-local:
test -L extensions || ln -s ../extensions/include extensions
......@@ -81,6 +81,8 @@ public:
// name node
static std::string getProp(xmlNode* node, const std::string name);
static int getIntProp(xmlNode* node, const std::string name);
/// if value if not positive ( <= 0 ), returns def
static int getPIntProp(xmlNode* node, const std::string name, int def);
// name node
static void setProp(xmlNode* node, const std::string name, const std::string text);
......@@ -126,6 +128,8 @@ class UniXML_iterator
std::string getProp(const std::string name);
int getIntProp(const std::string name);
/// if value if not positive ( <= 0 ), returns def
int getPIntProp(const std::string name, int def);
void setProp(const std::string name, const std::string text);
/*! . false, */
......
......@@ -33,7 +33,7 @@ cflags()
libs()
{
echo -n "-L$EXPORTPATH/lib "
pkg-config --libs $1 | sed -e "s|-L$prefix ||g"
pkg-config --libs $1 | sed -e "s|-L$prefix | |g"
}
export UNISET_CFLAGS="$( cflags $PCFILE )"
......@@ -43,19 +43,19 @@ export UNISET_LIBS="$( libs $PCFILE )"
ext_cflags()
{
# FIXME: really use extensions/
echo -n "-I$1"
echo -n "-I$1 "
cflags $1/$2
}
ext_libs()
{
echo -n "-L$1"
echo -n "-L$1 "
libs $1/$2
}
EXFILE="$EXPORTPATH/extensions libUniSetExtensions.pc"
export UNISET_EXT_CFLAGS="-I$EXPORTPATH/extensions/include $( ext_cflags $EXFILE )"
export UNISET_EXT_LIBS="$( ext_libs $EXFILE )"
export UNISET_EXT_LIBS="-L$EXPORTPATH/extensions/lib $( ext_libs $EXFILE )"
EXFILE="$EXPORTPATH/extensions/IOControl libUniSetIOControl.pc"
export UNISET_EXT_IO_CFLAGS="$( ext_cflags $EXFILE )"
......
......@@ -226,8 +226,8 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
}
try
{
if( unixml.getProp(cnode,"idfromfile").empty() || unixml.getIntProp(cnode,"idfromfile")==0 )
{
if( unixml.getIntProp(cnode,"idfromfile") == 0 )
oind = new ObjectIndex_XML(unixml); //(fileConfName);
else
oind = new ObjectIndex_idXML(unixml); //(fileConfName);
......@@ -247,7 +247,7 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
mi = new DefaultMessageInterface();
else
{
if( unixml.getProp(cnode,"idfromfile").empty() || unixml.getIntProp(cnode,"idfromfile")==0 )
if( unixml.getIntProp(cnode,"idfromfile") == 0 )
mi = new MessageInterface_XML(unixml); // (fileConfName);
else
mi = new MessageInterface_idXML(unixml); // (fileConfName);
......@@ -277,17 +277,17 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
initRepSections();
// localIOR
// localIOR
// localIOR = false; // ??. initParameters()
string lior( getArgParam("--localIOR") );
if( !lior.empty() )
localIOR = uni_atoi(lior);
int lior = getArgInt("--localIOR");
if( lior )
localIOR = lior;
// transientIOR
// transientIOR = false; // ??. initParameters()
string tior( getArgParam("--transientIOR") );
if( !tior.empty() )
transientIOR = uni_atoi(tior);
int tior = getArgInt("--transientIOR");
if( tior )
transientIOR = tior;
if( imagesDir[0]!='/' && imagesDir[0]!='.' )
imagesDir = dataDir + imagesDir + "/";
......
......@@ -203,6 +203,8 @@ bool CycleStorage::create(const char* name, int inf_sz, int inf_count, int seek)
if(fseek(file,seekpos,0)==-1) return false;
CycleStorageElem *jrn = (CycleStorageElem*)new char[full_size];
for( int i=0; i<full_size; i++ )
*((char*)jrn+i) = 0;
jrn->status=0;
/*! */
......@@ -232,7 +234,8 @@ bool CycleStorage::addRow(void* str)
if(file==NULL) return false;
CycleStorageElem *jrn = (CycleStorageElem*)new char[full_size];
int i=0;
for( i=0; i<full_size; i++ )
*((char*)jrn+i) = 0;
/*! 2 - (head=-1), 1 (head=tail=0) )
*/
......
......@@ -210,6 +210,9 @@ bool TableBlockStorage::create(const char* name, int key_sz, int inf_sz, int inf
/*! */
mem = (TableBlockStorageElem*) new char[block_size*full_size];
for( i=0; i<block_size*full_size; i++ )
*((char*)mem+i) = 0;
StorageAttr sa;
sa.k_size=k_size;
sa.inf_size=inf_size;
......@@ -259,7 +262,11 @@ bool TableBlockStorage::addRow(void* key, void* value)
/*! , pos>=0, , empty */
if(pos>=0) empty=pos;
else memcpy(keyPointer(empty),key,k_size);
else
{
if( empty<0 ) return false; /*! false, */
memcpy(keyPointer(empty),key,k_size);
}
elemPointer(empty)->count=++max;
memcpy(valPointer(empty),value,inf_size);
......
......@@ -213,6 +213,14 @@ int UniXML::getIntProp(xmlNode* node, const string name )
return UniSetTypes::uni_atoi((const char*)::xmlGetProp(node, (const xmlChar*)name.c_str()));
}
int UniXML::getPIntProp(xmlNode* node, const string name, int def )
{
int i = getIntProp(node, name);
if (i <= 0)
return def;
return i;
}
void UniXML::setProp(xmlNode* node, string name, string text)
{
xmlSetProp(node, (const xmlChar*)name.c_str(), local2xml(text));
......@@ -448,6 +456,15 @@ int UniXML_iterator::getIntProp( const string name )
{
return UniSetTypes::uni_atoi((char*)::xmlGetProp(curNode, (const xmlChar*)name.c_str()));
}
int UniXML_iterator::getPIntProp( const string name, int def )
{
int i = getIntProp(name);
if (i <= 0)
return def;
return i;
}
// -------------------------------------------------------------------------
void UniXML_iterator::setProp( const string name, const string text )
{
......
......@@ -21,6 +21,17 @@ int main()
return 1;
}
PassiveTimer pt3(UniSetTimer::WaitUpTime);
cout << "pt3.getCurrent(): " << pt3.getCurrent() << endl;
msleep(3000);
int pt3_ms = pt3.getCurrent();
cout << "pt3.getCurrent(): " << pt3_ms << endl;
if( pt3_ms < 3000 )
{
cerr << "BAD getCurrent() function for WaitUpTime timer (pt3)" << endl;
return 1;
}
while(1)
{
......
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