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

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

parents ee470b31 8936f108
......@@ -69,8 +69,8 @@ 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 msgmap();
......@@ -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;
......@@ -855,7 +856,10 @@ int saveValue(string args, UniversalInterface &ui)
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 )"
......
......@@ -227,7 +227,7 @@ 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);
......@@ -279,15 +279,15 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
// 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