Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
ce1a189a
Commit
ce1a189a
authored
Nov 15, 2011
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(SImitator): добавил возможность указывать и AO датчики (не только AI)
parent
38f268e1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
13 deletions
+40
-13
main.cc
Utilities/SImitator/main.cc
+39
-12
start_fg.sh
Utilities/SImitator/start_fg.sh
+1
-1
No files found.
Utilities/SImitator/main.cc
View file @
ce1a189a
...
...
@@ -8,13 +8,19 @@ using namespace UniSetTypes;
void
help_print
()
{
cout
<<
endl
<<
"--help - Помощь по утилите"
<<
endl
;
cout
<<
"--sid id1,..,idXX - sensors ID (A
nalogInput
)"
<<
endl
;
cout
<<
"--sid id1,..,idXX - sensors ID (A
I,AO
)"
<<
endl
;
cout
<<
"--min val - Нижняя граница датчика. По умолчанию 0"
<<
endl
;
cout
<<
"--max val - Верхняя граница датчика. По умолчанию 100 "
<<
endl
;
cout
<<
"--step val - Шаг датчика. По умолчанию 1"
<<
endl
;
cout
<<
"--pause msec - Пауза. По умолчанию 200 мсек"
<<
endl
<<
endl
;
}
// -----------------------------------------------------------------------------
struct
IInfo
{
ObjectId
id
;
UniversalIO
::
IOTypes
iotype
;
};
// -----------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
{
try
...
...
@@ -30,7 +36,6 @@ int main( int argc, char **argv )
uniset_init
(
argc
,
argv
,
"configure.xml"
);
UniversalInterface
ui
;
UniSetTypes
::
IDList
lst
;
string
sid
(
conf
->
getArgParam
(
"--sid"
));
if
(
sid
.
empty
()
)
...
...
@@ -38,14 +43,30 @@ int main( int argc, char **argv )
cerr
<<
endl
<<
"Use --sid id1,..,idXX"
<<
endl
<<
endl
;
return
1
;
}
lst
=
UniSetTypes
::
explode
(
sid
);
std
::
list
<
ObjectId
>
l
=
lst
.
getList
();
UniSetTypes
::
IDList
lst1
=
UniSetTypes
::
explode
(
sid
);
std
::
list
<
ObjectId
>
l
1
=
lst1
.
getList
();
if
(
l
.
empty
()
)
if
(
l
1
.
empty
()
)
{
cerr
<<
endl
<<
"Use --sid id1,..,idXX"
<<
endl
<<
endl
;
return
1
;
}
std
::
list
<
IInfo
>
l
;
for
(
std
::
list
<
ObjectId
>::
iterator
it
=
l1
.
begin
();
it
!=
l1
.
end
();
++
it
)
{
UniversalIO
::
IOTypes
t
=
conf
->
getIOType
(
(
*
it
)
);
if
(
t
!=
UniversalIO
::
AnalogInput
&&
t
!=
UniversalIO
::
AnalogOutput
)
{
cerr
<<
endl
<<
"Неверный типа датчика '"
<<
t
<<
"' для id='"
<<
(
*
it
)
<<
"'. Тип должен быть AI или AO."
<<
endl
<<
endl
;
return
1
;
}
IInfo
i
;
i
.
id
=
(
*
it
);
i
.
iotype
=
t
;
l
.
push_back
(
i
);
}
int
amin
=
conf
->
getArgInt
(
"--min"
,
"0"
);
int
amax
=
conf
->
getArgInt
(
"--max"
,
"100"
);
...
...
@@ -92,15 +113,18 @@ int main( int argc, char **argv )
j
=
amin
;
cout
<<
"
\r
"
<<
" i = "
<<
j
<<
" "
<<
flush
;
for
(
std
::
list
<
ObjectId
>::
iterator
it
=
l
.
begin
();
it
!=
l
.
end
();
++
it
)
for
(
std
::
list
<
IInfo
>::
iterator
it
=
l
.
begin
();
it
!=
l
.
end
();
++
it
)
{
try
{
ui
.
saveValue
((
*
it
),
j
,
UniversalIO
::
AnalogInput
);
if
(
it
->
iotype
==
UniversalIO
::
AnalogInput
)
ui
.
saveValue
(
it
->
id
,
j
,
UniversalIO
::
AnalogInput
);
else
ui
.
setValue
(
it
->
id
,
j
);
}
catch
(
Exception
&
ex
)
{
cerr
<<
endl
<<
"save id="
<<
(
*
it
)
<<
" "
<<
ex
<<
endl
;
cerr
<<
endl
<<
"save id="
<<
it
->
id
<<
" "
<<
ex
<<
endl
;
}
}
...
...
@@ -117,15 +141,18 @@ int main( int argc, char **argv )
i
=
amax
;
cout
<<
"
\r
"
<<
" i = "
<<
i
<<
" "
<<
flush
;
for
(
std
::
list
<
ObjectId
>::
iterator
it
=
l
.
begin
();
it
!=
l
.
end
();
++
it
)
for
(
std
::
list
<
IInfo
>::
iterator
it
=
l
.
begin
();
it
!=
l
.
end
();
++
it
)
{
try
{
ui
.
saveValue
((
*
it
),
i
,
UniversalIO
::
AnalogInput
);
if
(
it
->
iotype
==
UniversalIO
::
AnalogInput
)
ui
.
saveValue
(
it
->
id
,
i
,
UniversalIO
::
AnalogInput
);
else
ui
.
setValue
(
it
->
id
,
i
);
}
catch
(
Exception
&
ex
)
{
cerr
<<
endl
<<
"save id="
<<
(
*
it
)
<<
" "
<<
ex
<<
endl
;
cerr
<<
endl
<<
"save id="
<<
it
->
id
<<
" "
<<
ex
<<
endl
;
}
}
}
...
...
Utilities/SImitator/start_fg.sh
View file @
ce1a189a
...
...
@@ -4,7 +4,7 @@ ulimit -Sc 1000000
#for i in `seq 1 20`;
#do
uniset-start.sh
-f
./uniset-simitator
--confile
test.xml
--sid
10,16
uniset-start.sh
-f
./uniset-simitator
--confile
test.xml
--sid
10,16
,9
#done
#wait
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment