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
949e7b6e
Commit
949e7b6e
authored
Aug 19, 2009
by
Pavel Vaynerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add BLINK2, BLINK3 to IOControl (and new release)
parent
0c3eb913
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
248 additions
and
37 deletions
+248
-37
libuniset.spec
conf/libuniset.spec
+3
-0
IOControl.cc
extensions/IOControl/IOControl.cc
+213
-33
IOControl.h
extensions/IOControl/IOControl.h
+32
-4
UniSetTypes.h
include/UniSetTypes.h
+0
-0
No files found.
conf/libuniset.spec
View file @
949e7b6e
...
...
@@ -175,6 +175,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Wed Aug 19 2009 Pavel Vainerman <pv@etersoft.ru> 0.96-eter49
- add BLINK2, BLINK3 to IOControl
* Tue Aug 18 2009 Pavel Vainerman <pv@etersoft.ru> 0.96-eter48
- fixed bug in PassiveTimer
...
...
extensions/IOControl/IOControl.cc
View file @
949e7b6e
...
...
@@ -31,6 +31,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
shm
(
0
),
myid
(
id
),
blink_state
(
true
),
blink2_state
(
true
),
blink3_state
(
true
),
testLamp_S
(
UniSetTypes
::
DefaultObjectId
),
isTestLamp
(
false
),
sidHeartBeat
(
UniSetTypes
::
DefaultObjectId
),
...
...
@@ -53,6 +55,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
defCardNum
=
atoi
(
conf
->
getArgParam
(
"--io-default-cardnum"
,
"-1"
).
c_str
());
unideb
[
Debug
::
INFO
]
<<
myname
<<
"(init): numcards="
<<
numcards
<<
endl
;
UniXML_iterator
it
(
cnode
);
noCards
=
true
;
...
...
@@ -152,7 +156,19 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
ptBlink
.
setTiming
(
blink_msec
);
smReadyTimeout
=
conf
->
getArgInt
(
"--io-sm-ready-timeout"
,
it
.
getProp
(
"ready_timeout"
));
int
blink2_msec
=
conf
->
getArgInt
(
"--io-blink2-time"
,
it
.
getProp
(
"blink2-time"
));
if
(
blink2_msec
<=
0
)
blink2_msec
=
150
;
ptBlink2
.
setTiming
(
blink2_msec
);
int
blink3_msec
=
conf
->
getArgInt
(
"--io-blink3-time"
,
it
.
getProp
(
"blink3-time"
));
if
(
blink3_msec
<=
0
)
blink3_msec
=
100
;
ptBlink3
.
setTiming
(
blink2_msec
);
smReadyTimeout
=
atoi
(
conf
->
getArgParam
(
"--io-sm-ready-timeout"
,
it
.
getProp
(
"ready_timeout"
)).
c_str
());
if
(
smReadyTimeout
==
0
)
smReadyTimeout
=
15000
;
else
if
(
smReadyTimeout
<
0
)
...
...
@@ -211,6 +227,9 @@ IOControl::~IOControl()
// ݣ delete
// cdiagram new
//
for
(
unsigned
int
i
=
0
;
i
<
cards
.
size
();
i
++
)
delete
cards
[
i
];
delete
shm
;
}
...
...
@@ -242,6 +261,7 @@ void IOControl::execute()
}
iomap
.
resize
(
maxItem
);
maxHalf
=
maxItem
/
2
;
unideb
[
Debug
::
INFO
]
<<
myname
<<
"(init): iomap size = "
<<
iomap
.
size
()
<<
endl
;
cerr
<<
myname
<<
"(iomap size): "
<<
iomap
.
size
()
<<
endl
;
...
...
@@ -297,7 +317,25 @@ void IOControl::execute()
ptBlink
.
reset
();
try
{
blink
();
blink
(
lstBlink
,
blink_state
);
}
catch
(...){}
}
if
(
ptBlink2
.
checkTime
()
)
{
ptBlink2
.
reset
();
try
{
blink
(
lstBlink2
,
blink2_state
);
}
catch
(...){}
}
if
(
ptBlink3
.
checkTime
()
)
{
ptBlink3
.
reset
();
try
{
blink
(
lstBlink3
,
blink3_state
);
}
catch
(...){}
}
...
...
@@ -337,11 +375,51 @@ void IOControl::execute()
// --------------------------------------------------------------------------------
void
IOControl
::
iopoll
()
{
for
(
IOMap
::
iterator
it
=
iomap
.
begin
();
it
!=
iomap
.
end
();
++
it
)
//
for
(
PIOMap
::
iterator
it
=
pmap
.
begin
();
it
!=
pmap
.
end
();
++
it
)
{
if
(
it
->
ignore
||
it
->
ncard
==
defCardNum
)
if
(
it
->
priority
>
0
)
ioread
(
&
(
iomap
[
it
->
index
])
);
}
bool
prior
=
false
;
int
i
=
0
;
for
(
IOMap
::
iterator
it
=
iomap
.
begin
();
it
!=
iomap
.
end
();
++
it
,
i
++
)
{
if
(
it
->
ignore
)
continue
;
IOBase
::
processingThreshold
((
IOBase
*
)
&
(
*
it
),
shm
,
force
);
ioread
(
(
IOInfo
*
)
&
(
*
it
)
);
//
//
if
(
!
prior
&&
i
>
maxHalf
)
{
for
(
PIOMap
::
iterator
it
=
pmap
.
begin
();
it
!=
pmap
.
end
();
++
it
)
{
if
(
it
->
priority
>
1
)
ioread
(
&
(
iomap
[
it
->
index
])
);
}
prior
=
true
;
}
}
//
for
(
PIOMap
::
iterator
it
=
pmap
.
begin
();
it
!=
pmap
.
end
();
++
it
)
{
if
(
it
->
priority
>
2
)
ioread
(
&
(
iomap
[
it
->
index
])
);
}
}
// --------------------------------------------------------------------------------
void
IOControl
::
ioread
(
IOInfo
*
it
)
{
if
(
it
->
ignore
||
it
->
ncard
==
defCardNum
)
return
;
ComediInterface
*
card
=
cards
.
getCard
(
it
->
ncard
);
// cout << conf->oind->getMapName(it->si.id)
...
...
@@ -350,7 +428,7 @@ void IOControl::iopoll()
if
(
card
==
NULL
||
it
->
subdev
==
DefaultSubdev
||
it
->
channel
==
DefaultChannel
)
continue
;
return
;
// cout << conf->oind->getMapName(it->si.id)
// << " subdev: " << it->subdev << " chan: " << it->channel << endl;
...
...
@@ -358,7 +436,7 @@ void IOControl::iopoll()
if
(
it
->
si
.
id
==
DefaultObjectId
)
{
cerr
<<
myname
<<
"(iopoll): sid=DefaultObjectId?!"
<<
endl
;
continue
;
return
;
}
IOBase
*
ib
=
&
(
*
it
);
...
...
@@ -426,8 +504,14 @@ void IOControl::iopoll()
{
case
lmpOFF
:
{
if
(
force_out
&&
prev_val
==
lmpBLINK
)
delBlink
(
it
);
if
(
force_out
&&
(
prev_val
==
lmpBLINK
||
prev_val
==
lmpBLINK2
||
prev_val
==
lmpBLINK3
)
)
{
delBlink
(
it
,
lstBlink
);
delBlink
(
it
,
lstBlink2
);
delBlink
(
it
,
lstBlink3
);
}
if
(
it
->
no_testlamp
||
(
!
it
->
no_testlamp
&&
!
isTestLamp
)
)
card
->
setDigitalChannel
(
it
->
subdev
,
it
->
channel
,
0
);
...
...
@@ -436,8 +520,14 @@ void IOControl::iopoll()
case
lmpON
:
{
if
(
force_out
&&
prev_val
==
lmpBLINK
)
delBlink
(
it
);
if
(
force_out
&&
(
prev_val
==
lmpBLINK
||
prev_val
==
lmpBLINK2
||
prev_val
==
lmpBLINK3
)
)
{
delBlink
(
it
,
lstBlink
);
delBlink
(
it
,
lstBlink2
);
delBlink
(
it
,
lstBlink3
);
}
if
(
it
->
no_testlamp
||
(
!
it
->
no_testlamp
&&
!
isTestLamp
)
)
card
->
setDigitalChannel
(
it
->
subdev
,
it
->
channel
,
1
);
...
...
@@ -448,7 +538,35 @@ void IOControl::iopoll()
{
if
(
force_out
&&
prev_val
!=
lmpBLINK
)
{
addBlink
(
it
);
delBlink
(
it
,
lstBlink2
);
delBlink
(
it
,
lstBlink3
);
addBlink
(
it
,
lstBlink
);
// , ( )
card
->
setDigitalChannel
(
it
->
subdev
,
it
->
channel
,
1
);
}
}
break
;
case
lmpBLINK2
:
{
if
(
force_out
&&
prev_val
!=
lmpBLINK2
)
{
delBlink
(
it
,
lstBlink
);
delBlink
(
it
,
lstBlink3
);
addBlink
(
it
,
lstBlink2
);
// , ( )
card
->
setDigitalChannel
(
it
->
subdev
,
it
->
channel
,
1
);
}
}
break
;
case
lmpBLINK3
:
{
if
(
force_out
&&
prev_val
!=
lmpBLINK3
)
{
delBlink
(
it
,
lstBlink
);
delBlink
(
it
,
lstBlink2
);
addBlink
(
it
,
lstBlink3
);
// , ( )
card
->
setDigitalChannel
(
it
->
subdev
,
it
->
channel
,
1
);
}
...
...
@@ -456,7 +574,7 @@ void IOControl::iopoll()
break
;
default
:
continue
;
return
;
}
}
}
...
...
@@ -492,10 +610,7 @@ void IOControl::iopoll()
{
unideb
[
Debug
::
LEVEL3
]
<<
myname
<<
"(iopoll): catch ..."
<<
endl
;
}
}
for
(
IOMap
::
iterator
it
=
iomap
.
begin
();
it
!=
iomap
.
end
();
++
it
)
IOBase
::
processingThreshold
(
&
(
*
it
),
shm
,
force
);
}
// --------------------------------------------------------------------------------
void
IOControl
::
readConfiguration
()
...
...
@@ -564,7 +679,7 @@ bool IOControl::initIOItem( UniXML_iterator& it )
if
(
c
.
empty
()
||
inf
.
ncard
<
0
||
inf
.
ncard
>=
(
int
)
cards
.
size
()
)
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
unideb
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initIOItem): ("
<<
inf
.
ncard
<<
") "
<<
it
.
getProp
(
"name"
)
<<
" set default="
<<
defCardNum
<<
endl
;
...
...
@@ -638,6 +753,15 @@ bool IOControl::initIOItem( UniXML_iterator& it )
//
if
(
maxItem
>=
iomap
.
size
()
)
iomap
.
resize
(
maxItem
+
10
);
int
prior
=
atoi
((
it
.
getProp
(
"iopriority"
)).
c_str
());
if
(
prior
>
0
)
{
IOPriority
p
(
prior
,
maxItem
);
pmap
.
push_back
(
p
);
unideb
[
Debug
::
LEVEL3
]
<<
myname
<<
"(readItem): add to priority list: "
<<
it
.
getProp
(
"name"
)
<<
" priority="
<<
prior
<<
endl
;
}
iomap
[
maxItem
++
]
=
inf
;
return
true
;
...
...
@@ -776,17 +900,17 @@ void IOControl::initIOCard()
}
}
// -----------------------------------------------------------------------------
void
IOControl
::
blink
()
void
IOControl
::
blink
(
BlinkList
&
lst
,
bool
&
bstate
)
{
if
(
lstBlink
.
empty
()
)
return
;
for
(
BlinkList
::
iterator
it
=
lst
Blink
.
begin
();
it
!=
lstBlink
.
end
();
++
it
)
for
(
BlinkList
::
iterator
it
=
lst
.
begin
();
it
!=
lst
.
end
();
++
it
)
{
IO
Map
::
iterator
&
io
(
*
it
);
IO
Info
*
io
(
*
it
);
if
(
io
->
subdev
==
DefaultSubdev
||
io
->
channel
==
DefaultChannel
)
if
(
io
->
subdev
==
DefaultSubdev
||
io
->
channel
==
DefaultChannel
)
continue
;
...
...
@@ -804,27 +928,28 @@ void IOControl::blink()
}
}
b
link_
state
^=
true
;
bstate
^=
true
;
}
// -----------------------------------------------------------------------------
void
IOControl
::
addBlink
(
IOMap
::
iterator
&
io
)
void
IOControl
::
addBlink
(
IOInfo
*
io
,
BlinkList
&
lst
)
{
for
(
BlinkList
::
iterator
it
=
lst
Blink
.
begin
();
it
!=
lstBlink
.
end
();
++
it
)
for
(
BlinkList
::
iterator
it
=
lst
.
begin
();
it
!=
lst
.
end
();
++
it
)
{
if
(
(
*
it
)
==
io
)
return
;
}
lst
Blink
.
push_back
(
io
);
lst
.
push_back
(
io
);
}
// -----------------------------------------------------------------------------
void
IOControl
::
delBlink
(
IO
Map
::
iterator
&
io
)
void
IOControl
::
delBlink
(
IO
Info
*
io
,
BlinkList
&
lst
)
{
for
(
BlinkList
::
iterator
it
=
lstBlink
.
begin
();
it
!=
lstBlink
.
end
();
++
it
)
{
if
(
(
*
it
)
==
io
)
{
lst
Blink
.
erase
(
it
);
lst
.
erase
(
it
);
return
;
}
}
...
...
@@ -858,16 +983,22 @@ void IOControl::check_testlamp()
if
(
it
->
stype
==
UniversalIO
::
AnalogOutput
)
{
if
(
isTestLamp
)
addBlink
(
it
);
addBlink
(
&
(
*
it
),
lstBlink
);
else
if
(
it
->
value
!=
lmpBLINK
)
delBlink
(
it
);
{
delBlink
(
&
(
*
it
),
lstBlink
);
delBlink
(
&
(
*
it
),
lstBlink2
);
}
}
else
if
(
it
->
stype
==
UniversalIO
::
DigitalOutput
)
{
if
(
isTestLamp
)
addBlink
(
it
);
addBlink
(
&
(
*
it
),
lstBlink
);
else
delBlink
(
it
);
{
delBlink
(
&
(
*
it
),
lstBlink
);
delBlink
(
&
(
*
it
),
lstBlink2
);
}
}
}
}
...
...
@@ -937,6 +1068,8 @@ void IOControl::help_print( int argc, const char* const* argv )
cout
<<
"--io-s-filter-field - configure.xml "
<<
endl
;
cout
<<
"--io-s-filter-value - "
<<
endl
;
cout
<<
"--io-blink-time msec - , . configure.xml"
<<
endl
;
cout
<<
"--io-blink2-time msec - (lmpBLINK2), . configure.xml"
<<
endl
;
cout
<<
"--io-blink3-time msec - (lmpBLINK3), . configure.xml"
<<
endl
;
cout
<<
"--io-heartbeat-id - heartbeat-."
<<
endl
;
cout
<<
"--io-heartbeat-max - heartbeat-ޣ . 10."
<<
endl
;
cout
<<
"--io-ready-timeout - SM , . (-1 - '')"
<<
endl
;
...
...
@@ -1173,18 +1306,65 @@ void IOControl::sensorInfo( UniSetTypes::SensorMessage* sm )
switch
(
cur_val
)
{
case
lmpOFF
:
delBlink
(
it
);
delBlink
(
&
(
*
it
),
lstBlink
);
delBlink
(
&
(
*
it
),
lstBlink2
);
delBlink
(
&
(
*
it
),
lstBlink3
);
break
;
case
lmpON
:
delBlink
(
it
);
delBlink
(
&
(
*
it
),
lstBlink
);
delBlink
(
&
(
*
it
),
lstBlink2
);
delBlink
(
&
(
*
it
),
lstBlink3
);
break
;
case
lmpBLINK
:
{
if
(
prev_val
!=
lmpBLINK
)
{
addBlink
(
it
);
delBlink
(
&
(
*
it
),
lstBlink2
);
delBlink
(
&
(
*
it
),
lstBlink3
);
addBlink
(
&
(
*
it
),
lstBlink
);
// ,
// ( )
if
(
it
->
ignore
||
it
->
subdev
==
DefaultSubdev
||
it
->
channel
==
DefaultChannel
)
break
;
ComediInterface
*
card
=
cards
.
getCard
(
it
->
ncard
);
if
(
card
!=
NULL
)
card
->
setDigitalChannel
(
it
->
subdev
,
it
->
channel
,
1
);
}
}
break
;
case
lmpBLINK2
:
{
if
(
prev_val
!=
lmpBLINK2
)
{
delBlink
(
&
(
*
it
),
lstBlink
);
delBlink
(
&
(
*
it
),
lstBlink3
);
addBlink
(
&
(
*
it
),
lstBlink2
);
// ,
// ( )
if
(
it
->
ignore
||
it
->
subdev
==
DefaultSubdev
||
it
->
channel
==
DefaultChannel
)
break
;
ComediInterface
*
card
=
cards
.
getCard
(
it
->
ncard
);
if
(
card
!=
NULL
)
card
->
setDigitalChannel
(
it
->
subdev
,
it
->
channel
,
1
);
}
}
break
;
case
lmpBLINK3
:
{
if
(
prev_val
!=
lmpBLINK3
)
{
delBlink
(
&
(
*
it
),
lstBlink
);
delBlink
(
&
(
*
it
),
lstBlink2
);
addBlink
(
&
(
*
it
),
lstBlink3
);
// ,
// ( )
if
(
it
->
ignore
||
it
->
subdev
==
DefaultSubdev
||
it
->
channel
==
DefaultChannel
)
...
...
extensions/IOControl/IOControl.h
View file @
949e7b6e
...
...
@@ -114,13 +114,23 @@ class IOControl:
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
IOInfo
&
inf
);
};
struct
IOPriority
{
IOPriority
(
int
p
,
int
i
)
:
priority
(
p
),
index
(
i
){}
int
priority
;
int
index
;
};
void
execute
();
protected
:
void
iopoll
();
/*!< / */
void
blink
(
);
void
ioread
(
IOInfo
*
it
);
void
check_testlamp
();
void
blink
();
//
virtual
void
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
);
...
...
@@ -157,7 +167,12 @@ class IOControl:
typedef
std
::
vector
<
IOInfo
>
IOMap
;
IOMap
iomap
;
/*!< / */
typedef
std
::
list
<
IOPriority
>
PIOMap
;
PIOMap
pmap
;
/*!< / */
unsigned
int
maxItem
;
/*!< ( ) */
unsigned
int
maxHalf
;
int
filtersize
;
float
filterT
;
...
...
@@ -168,13 +183,26 @@ class IOControl:
UniversalInterface
ui
;
UniSetTypes
::
ObjectId
myid
;
typedef
std
::
list
<
IOMap
::
iterator
>
BlinkList
;
typedef
std
::
list
<
IOInfo
*>
BlinkList
;
void
addBlink
(
IOInfo
*
it
,
BlinkList
&
lst
);
void
delBlink
(
IOInfo
*
it
,
BlinkList
&
lst
);
void
blink
(
BlinkList
&
lst
,
bool
&
bstate
);
//
BlinkList
lstBlink
;
PassiveTimer
ptBlink
;
bool
blink_state
;
void
addBlink
(
IOMap
::
iterator
&
it
);
void
delBlink
(
IOMap
::
iterator
&
it
);
//
BlinkList
lstBlink2
;
PassiveTimer
ptBlink2
;
bool
blink2_state
;
//
BlinkList
lstBlink3
;
PassiveTimer
ptBlink3
;
bool
blink3_state
;
UniSetTypes
::
ObjectId
testLamp_S
;
Trigger
trTestLamp
;
...
...
include/UniSetTypes.h
View file @
949e7b6e
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