Commit 681a5bc1 authored by Pavel Vainerman's avatar Pavel Vainerman

modify uniset-simitator: add param fir use more sensors

parent c6821247
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#include <iostream> #include <iostream>
#include "Exceptions.h" #include "Exceptions.h"
#include "UniversalInterface.h" #include "UniversalInterface.h"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
using namespace std; using namespace std;
using namespace UniSetTypes; using namespace UniSetTypes;
...@@ -10,7 +9,7 @@ using namespace UniSetTypes; ...@@ -10,7 +9,7 @@ using namespace UniSetTypes;
void help_print() void help_print()
{ {
cout << endl << "--help - " << endl; cout << endl << "--help - " << endl;
cout << "--sid id - sensor ID (AnalogInput)" << endl; cout << "--sid id1,..,idXX - sensors ID (AnalogInput)" << endl;
cout << "--min val - . 0" << endl; cout << "--min val - . 0" << endl;
cout << "--max val - . 100 " << endl; cout << "--max val - . 100 " << endl;
cout << "--step val - . 1" << endl; cout << "--step val - . 1" << endl;
...@@ -30,16 +29,25 @@ int main( int argc, char **argv ) ...@@ -30,16 +29,25 @@ int main( int argc, char **argv )
} }
// ------------------------------------- // -------------------------------------
uniset_init(argc, argv, "configure.xml" ); uniset_init(argc, argv, "configure.xml" );
UniversalInterface ui; UniversalInterface ui;
UniSetTypes::IDList lst;
string sid(conf->getArgParam("--sid"));
if( sid.empty() )
{
cerr << endl << "Use --sid id1,..,idXX" << endl << endl;
return 1;
}
lst = UniSetTypes::explode(sid);
std::list<ObjectId> l = lst.getList();
int asid = conf->getArgInt("--sid",""); if( l.empty() )
if( asid<=0 )
{ {
cerr << endl << "Use --sid id" << endl << endl; cerr << endl << "Use --sid id1,..,idXX" << endl << endl;
return 1; return 1;
} }
int amin = conf->getArgInt("--min", "0"); int amin = conf->getArgInt("--min", "0");
int amax = conf->getArgInt("--max", "100"); int amax = conf->getArgInt("--max", "100");
if( amin>amax ) if( amin>amax )
...@@ -66,7 +74,7 @@ int main( int argc, char **argv ) ...@@ -66,7 +74,7 @@ int main( int argc, char **argv )
cout << endl << "------------------------------" << endl; cout << endl << "------------------------------" << endl;
cout << " :" << endl; cout << " :" << endl;
cout << "------------------------------" << endl; cout << "------------------------------" << endl;
cout << " sid = " << asid << endl; cout << " sid = " << sid << endl;
cout << " min = " << amin << endl; cout << " min = " << amin << endl;
cout << " max = " << amax << endl; cout << " max = " << amax << endl;
cout << " step = " << astep << endl; cout << " step = " << astep << endl;
...@@ -74,7 +82,8 @@ int main( int argc, char **argv ) ...@@ -74,7 +82,8 @@ int main( int argc, char **argv )
cout << "------------------------------" << endl << endl; cout << "------------------------------" << endl << endl;
int i = amin-astep, j = amax; int i = amin-astep, j = amax;
while(1) while(1)
{ {
if(i>=amax) if(i>=amax)
...@@ -83,12 +92,24 @@ int main( int argc, char **argv ) ...@@ -83,12 +92,24 @@ int main( int argc, char **argv )
if(j<amin) // if(j<amin) //
j = amin; j = amin;
cout << "\r" << " i = " << j <<" "<< flush; cout << "\r" << " i = " << j <<" "<< flush;
ui.saveValue(asid, j, UniversalIO::AnalogInput);
if(j<=amin) for( std::list<ObjectId>::iterator it=l.begin(); it!=l.end(); ++it )
{ {
i = amin; try
j = amax; {
} ui.saveValue((*it), j, UniversalIO::AnalogInput);
}
catch( Exception& ex )
{
cerr << endl << "save id="<< (*it) << " " << ex << endl;
}
}
if(j<=amin)
{
i = amin;
j = amax;
}
} }
else else
{ {
...@@ -96,7 +117,18 @@ int main( int argc, char **argv ) ...@@ -96,7 +117,18 @@ int main( int argc, char **argv )
if(i>amax) // if(i>amax) //
i = amax; i = amax;
cout << "\r" << " i = " << i <<" "<< flush; cout << "\r" << " i = " << i <<" "<< flush;
ui.saveValue(asid, i,UniversalIO::AnalogInput);
for( std::list<ObjectId>::iterator it=l.begin(); it!=l.end(); ++it )
{
try
{
ui.saveValue((*it), i, UniversalIO::AnalogInput);
}
catch( Exception& ex )
{
cerr << endl << "save id="<< (*it) << " " << ex << endl;
}
}
} }
msleep(amsec); msleep(amsec);
} }
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
ulimit -Sc 1000000 ulimit -Sc 1000000
uniset-start.sh -f ./uniset-simitator --confile test.xml --sid 10 uniset-start.sh -f ./uniset-simitator --confile test.xml --sid 10,16
#--unideb-add-levels info,crit,warn,level9,system #--unideb-add-levels info,crit,warn,level9,system
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