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
3e9fcd84
Commit
3e9fcd84
authored
Dec 11, 2010
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Доработал IOControl. Добавил поддержку режима тестирования.
parent
6363ba08
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
135 additions
and
3 deletions
+135
-3
test.xml
conf/test.xml
+1
-0
IOControl.cc
extensions/IOControl/IOControl.cc
+114
-2
IOControl.h
extensions/IOControl/IOControl.h
+20
-1
No files found.
conf/test.xml
View file @
3e9fcd84
...
@@ -129,6 +129,7 @@
...
@@ -129,6 +129,7 @@
<item
default=
"-655360"
iotype=
"AI"
mb_vtype=
"I2"
mbaddr=
"0x01"
mbreg=
"0x12"
mbtcp=
"2"
mbtype=
"rtu"
name=
"MB1_AS"
priority=
"Medium"
textname=
"Analog input"
/>
<item
default=
"-655360"
iotype=
"AI"
mb_vtype=
"I2"
mbaddr=
"0x01"
mbreg=
"0x12"
mbtcp=
"2"
mbtype=
"rtu"
name=
"MB1_AS"
priority=
"Medium"
textname=
"Analog input"
/>
<item
default=
"6553604"
iotype=
"AI"
mb_vtype=
"U2"
mbaddr=
"0x01"
mbreg=
"0x14"
mbtcp=
"2"
mbtype=
"rtu"
name=
"MB2_AS"
priority=
"Medium"
textname=
"Analog input"
/>
<item
default=
"6553604"
iotype=
"AI"
mb_vtype=
"U2"
mbaddr=
"0x01"
mbreg=
"0x14"
mbtcp=
"2"
mbtype=
"rtu"
name=
"MB2_AS"
priority=
"Medium"
textname=
"Analog input"
/>
<item
default=
"65536045"
iotype=
"AI"
mb_vtype=
"F2"
mbaddr=
"0x01"
mbreg=
"0x17"
mbtcp=
"2"
mbtype=
"rtu"
name=
"MB3_AS"
priority=
"Medium"
textname=
"Analog input"
/>
<item
default=
"65536045"
iotype=
"AI"
mb_vtype=
"F2"
mbaddr=
"0x01"
mbreg=
"0x17"
mbtcp=
"2"
mbtype=
"rtu"
name=
"MB3_AS"
priority=
"Medium"
textname=
"Analog input"
/>
<item
iotype=
"AI"
name=
"IOTestMode_AS"
priority=
"Medium"
textname=
"testmode for IOControl"
/>
</sensors>
</sensors>
<thresholds
name=
"thresholds"
>
<thresholds
name=
"thresholds"
>
<sensor
iotype=
"AI"
name=
"AI_AS"
>
<sensor
iotype=
"AI"
name=
"AI_AS"
>
...
...
extensions/IOControl/IOControl.cc
View file @
3e9fcd84
...
@@ -43,7 +43,10 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
...
@@ -43,7 +43,10 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
force_out
(
false
),
force_out
(
false
),
activated
(
false
),
activated
(
false
),
readconf_ok
(
false
),
readconf_ok
(
false
),
term
(
false
)
term
(
false
),
testMode_as
(
UniSetTypes
::
DefaultObjectId
),
testmode
(
tmNone
),
prev_testmode
(
tmNone
)
{
{
// {
// {
// string myfullname = conf->oind->getNameById(id);
// string myfullname = conf->oind->getNameById(id);
...
@@ -140,7 +143,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
...
@@ -140,7 +143,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
if
(
testLamp_S
==
DefaultObjectId
)
if
(
testLamp_S
==
DefaultObjectId
)
{
{
ostringstream
err
;
ostringstream
err
;
err
<<
myname
<<
":
не найден идентификатор для датчика ТестЛамп:
"
<<
testlamp
;
err
<<
myname
<<
":
Unkown ID for
"
<<
testlamp
;
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(init): "
<<
err
.
str
()
<<
endl
;
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(init): "
<<
err
.
str
()
<<
endl
;
throw
SystemError
(
err
.
str
());
throw
SystemError
(
err
.
str
());
}
}
...
@@ -148,6 +151,21 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
...
@@ -148,6 +151,21 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
unideb
[
Debug
::
INFO
]
<<
myname
<<
"(init): testLamp_S='"
<<
testlamp
<<
"'"
<<
endl
;
unideb
[
Debug
::
INFO
]
<<
myname
<<
"(init): testLamp_S='"
<<
testlamp
<<
"'"
<<
endl
;
}
}
string
tmode
=
conf
->
getArgParam
(
"--io-test-mode"
,
it
.
getProp
(
"testmode_as"
));
if
(
!
tmode
.
empty
()
)
{
testMode_as
=
conf
->
getSensorID
(
tmode
);
if
(
testMode_as
==
DefaultObjectId
)
{
ostringstream
err
;
err
<<
myname
<<
": Unknown ID for "
<<
tmode
;
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(init): "
<<
err
.
str
()
<<
endl
;
throw
SystemError
(
err
.
str
());
}
unideb
[
Debug
::
INFO
]
<<
myname
<<
"(init): testMode_as='"
<<
testmode
<<
"'"
<<
endl
;
}
shm
=
new
SMInterface
(
icID
,
&
ui
,
myid
,
ic
);
shm
=
new
SMInterface
(
icID
,
&
ui
,
myid
,
ic
);
// определяем фильтр
// определяем фильтр
...
@@ -270,6 +288,7 @@ void IOControl::execute()
...
@@ -270,6 +288,7 @@ void IOControl::execute()
shm
->
initAIterator
(
aitHeartBeat
);
shm
->
initAIterator
(
aitHeartBeat
);
shm
->
initDIterator
(
ditTestLamp
);
shm
->
initDIterator
(
ditTestLamp
);
shm
->
initAIterator
(
aitTestMode
);
PassiveTimer
ptAct
(
activateTimeout
);
PassiveTimer
ptAct
(
activateTimeout
);
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
...
@@ -305,6 +324,7 @@ void IOControl::execute()
...
@@ -305,6 +324,7 @@ void IOControl::execute()
{
{
if
(
!
noCards
)
if
(
!
noCards
)
{
{
check_testmode
();
check_testlamp
();
check_testlamp
();
if
(
ptBlink
.
checkTime
()
)
if
(
ptBlink
.
checkTime
()
)
...
@@ -370,6 +390,9 @@ void IOControl::execute()
...
@@ -370,6 +390,9 @@ void IOControl::execute()
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
void
IOControl
::
iopoll
()
void
IOControl
::
iopoll
()
{
{
if
(
testmode
==
tmOffPoll
)
return
;
// Опрос приоритетной очереди
// Опрос приоритетной очереди
for
(
PIOMap
::
iterator
it
=
pmap
.
begin
();
it
!=
pmap
.
end
();
++
it
)
for
(
PIOMap
::
iterator
it
=
pmap
.
begin
();
it
!=
pmap
.
end
();
++
it
)
{
{
...
@@ -415,6 +438,14 @@ void IOControl::ioread( IOInfo* it )
...
@@ -415,6 +438,14 @@ void IOControl::ioread( IOInfo* it )
if
(
it
->
ignore
||
it
->
ncard
==
defCardNum
)
if
(
it
->
ignore
||
it
->
ncard
==
defCardNum
)
return
;
return
;
// если включён режим "в соответсвии с конфигурационным файлом"
// и при этом не стоит для этого канал "игнорировать в тестовом режиме"
if
(
testmode
==
tmConfigIgnore
&&
!
it
->
ignore_testmode
)
return
;
if
(
testmode
==
tmConfigEnable
&&
!
it
->
enable_testmode
)
return
;
ComediInterface
*
card
=
cards
.
getCard
(
it
->
ncard
);
ComediInterface
*
card
=
cards
.
getCard
(
it
->
ncard
);
// cout << conf->oind->getMapName(it->si.id)
// cout << conf->oind->getMapName(it->si.id)
...
@@ -713,6 +744,8 @@ bool IOControl::initIOItem( UniXML_iterator& it )
...
@@ -713,6 +744,8 @@ bool IOControl::initIOItem( UniXML_iterator& it )
inf
.
lamp
=
it
.
getIntProp
(
"lamp"
);
inf
.
lamp
=
it
.
getIntProp
(
"lamp"
);
inf
.
no_testlamp
=
it
.
getIntProp
(
"no_iotestlamp"
);
inf
.
no_testlamp
=
it
.
getIntProp
(
"no_iotestlamp"
);
inf
.
ignore_testmode
=
it
.
getIntProp
(
"ignore_testmode"
);
inf
.
enable_testmode
=
it
.
getIntProp
(
"enable_testmode"
);
inf
.
aref
=
0
;
inf
.
aref
=
0
;
inf
.
range
=
0
;
inf
.
range
=
0
;
...
@@ -947,6 +980,70 @@ void IOControl::delBlink( IOInfo* io, BlinkList& lst )
...
@@ -947,6 +980,70 @@ void IOControl::delBlink( IOInfo* io, BlinkList& lst )
}
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
IOControl
::
check_testmode
()
{
if
(
testMode_as
==
DefaultObjectId
)
return
;
try
{
if
(
force_out
)
testmode
=
shm
->
localGetValue
(
aitTestMode
,
testMode_as
);
if
(
prev_testmode
==
testmode
)
return
;
prev_testmode
=
testmode
;
// если режим "выключено всё"
// то гасим все выходы
if
(
testmode
==
tmOffPoll
)
{
// выставляем безопасные состояния
for
(
IOMap
::
iterator
it
=
iomap
.
begin
();
it
!=
iomap
.
end
();
++
it
)
{
if
(
it
->
ignore
)
continue
;
ComediInterface
*
card
=
cards
.
getCard
(
it
->
ncard
);
if
(
card
==
NULL
)
continue
;
try
{
if
(
it
->
subdev
==
DefaultSubdev
||
it
->
safety
==
NoSafety
)
continue
;
if
(
it
->
stype
==
UniversalIO
::
DigitalOutput
||
it
->
lamp
)
{
bool
set
=
it
->
invert
?
!
((
bool
)
it
->
safety
)
:
(
bool
)
it
->
safety
;
card
->
setDigitalChannel
(
it
->
subdev
,
it
->
channel
,
set
);
}
else
if
(
it
->
stype
==
UniversalIO
::
AnalogOutput
)
{
card
->
setAnalogChannel
(
it
->
subdev
,
it
->
channel
,
it
->
safety
,
it
->
range
,
it
->
aref
);
}
}
catch
(
Exception
&
ex
)
{
unideb
[
Debug
::
LEVEL3
]
<<
myname
<<
"(sigterm): "
<<
ex
<<
endl
;
}
catch
(...){}
}
}
}
catch
(
Exception
&
ex
)
{
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(check_testmode): "
<<
ex
<<
endl
;
}
catch
(...)
{
}
}
// -----------------------------------------------------------------------------
void
IOControl
::
check_testlamp
()
void
IOControl
::
check_testlamp
()
{
{
if
(
testLamp_S
==
DefaultObjectId
)
if
(
testLamp_S
==
DefaultObjectId
)
...
@@ -1232,6 +1329,16 @@ void IOControl::askSensors( UniversalIO::UIOCommand cmd )
...
@@ -1232,6 +1329,16 @@ void IOControl::askSensors( UniversalIO::UIOCommand cmd )
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
endl
;
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
endl
;
}
}
try
{
if
(
testMode_as
!=
DefaultObjectId
)
shm
->
askSensor
(
testMode_as
,
cmd
);
}
catch
(
Exception
&
ex
)
{
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
endl
;
}
for
(
IOMap
::
iterator
it
=
iomap
.
begin
();
it
!=
iomap
.
end
();
++
it
)
for
(
IOMap
::
iterator
it
=
iomap
.
begin
();
it
!=
iomap
.
end
();
++
it
)
{
{
if
(
it
->
ignore
)
if
(
it
->
ignore
)
...
@@ -1273,6 +1380,11 @@ void IOControl::sensorInfo( UniSetTypes::SensorMessage* sm )
...
@@ -1273,6 +1380,11 @@ void IOControl::sensorInfo( UniSetTypes::SensorMessage* sm )
unideb
[
Debug
::
INFO
]
<<
myname
<<
"(sensorInfo): test_lamp="
<<
sm
->
state
<<
endl
;
unideb
[
Debug
::
INFO
]
<<
myname
<<
"(sensorInfo): test_lamp="
<<
sm
->
state
<<
endl
;
isTestLamp
=
sm
->
state
;
isTestLamp
=
sm
->
state
;
}
}
else
if
(
sm
->
id
==
testMode_as
)
{
testmode
=
sm
->
value
;
check_testmode
();
}
for
(
IOMap
::
iterator
it
=
iomap
.
begin
();
it
!=
iomap
.
end
();
++
it
)
for
(
IOMap
::
iterator
it
=
iomap
.
begin
();
it
!=
iomap
.
end
();
++
it
)
{
{
...
...
extensions/IOControl/IOControl.h
View file @
3e9fcd84
...
@@ -191,7 +191,9 @@ class IOControl:
...
@@ -191,7 +191,9 @@ class IOControl:
aref
(
0
),
aref
(
0
),
range
(
0
),
range
(
0
),
lamp
(
false
),
lamp
(
false
),
no_testlamp
(
false
)
no_testlamp
(
false
),
ignore_testmode
(
false
),
enable_testmode
(
false
)
{}
{}
...
@@ -217,6 +219,8 @@ class IOControl:
...
@@ -217,6 +219,8 @@ class IOControl:
bool
lamp
;
/*!< признак, что данный выход является лампочкой (или сигнализатором) */
bool
lamp
;
/*!< признак, что данный выход является лампочкой (или сигнализатором) */
bool
no_testlamp
;
/*!< флаг исключения из 'проверки ламп' */
bool
no_testlamp
;
/*!< флаг исключения из 'проверки ламп' */
bool
ignore_testmode
;
/*!< флаг для режима тестирования tmConfigIgnore */
bool
enable_testmode
;
/*!< флаг для режима тестирования tmConfigEnable */
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
IOInfo
&
inf
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
IOInfo
&
inf
);
};
};
...
@@ -230,6 +234,14 @@ class IOControl:
...
@@ -230,6 +234,14 @@ class IOControl:
int
index
;
int
index
;
};
};
enum
TestModeID
{
tmNone
=
0
,
/*!< тестовый режим отключён */
tmOffPoll
=
1
,
/*!< отключить опрос */
tmConfigIgnore
=
2
,
/*!< специальный режим, в соответсвии с настройкой 'ignore_testmode' */
tmConfigEnable
=
3
/*!< специальный режим, в соответсвии с настройкой 'enable_testmode' */
};
void
execute
();
void
execute
();
protected
:
protected
:
...
@@ -237,6 +249,7 @@ class IOControl:
...
@@ -237,6 +249,7 @@ class IOControl:
void
iopoll
();
/*!< опрос карт в/в */
void
iopoll
();
/*!< опрос карт в/в */
void
ioread
(
IOInfo
*
it
);
void
ioread
(
IOInfo
*
it
);
void
check_testlamp
();
void
check_testlamp
();
void
check_testmode
();
void
blink
();
void
blink
();
// действия при завершении работы
// действия при завершении работы
...
@@ -334,6 +347,12 @@ class IOControl:
...
@@ -334,6 +347,12 @@ class IOControl:
UniSetTypes
::
ObjectId
sidTestSMReady
;
UniSetTypes
::
ObjectId
sidTestSMReady
;
bool
term
;
bool
term
;
UniSetTypes
::
ObjectId
testMode_as
;
IOController
::
AIOStateList
::
iterator
aitTestMode
;
long
testmode
;
long
prev_testmode
;
private
:
private
:
};
};
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
...
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