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
c6ffa6cc
Commit
c6ffa6cc
authored
Sep 10, 2009
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UniNetwork debugging part.2
parent
70196012
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
177 additions
and
6 deletions
+177
-6
libuniset.spec
conf/libuniset.spec
+4
-1
UniExchange.cc
extensions/UniNetwork/UniExchange.cc
+148
-2
UniExchange.h
extensions/UniNetwork/UniExchange.h
+20
-0
start_fg.sh
extensions/UniNetwork/start_fg.sh
+3
-1
IOController.h
include/IOController.h
+2
-2
No files found.
conf/libuniset.spec
View file @
c6ffa6cc
...
...
@@ -3,7 +3,7 @@
Name: libuniset
Version: 0.96
Release: eter
59
Release: eter
60
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
...
...
@@ -179,6 +179,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Thu Sep 10 2009 Pavel Vainerman <pv@altlinux.ru> 0.96-eter59
- UniNetwork debugging
* Wed Sep 09 2009 Pavel Vainerman <pv@altlinux.ru> 0.96-eter58
- UniNetwork debugging
...
...
extensions/UniNetwork/UniExchange.cc
View file @
c6ffa6cc
...
...
@@ -23,7 +23,10 @@ UniExchange::UniExchange( UniSetTypes::ObjectId id, UniSetTypes::ObjectId shmID,
SharedMemory
*
ic
,
const
std
::
string
prefix
)
:
IOController
(
id
),
shm
(
0
),
polltime
(
200
)
polltime
(
200
),
mymap
(
1
),
maxIndex
(
0
),
smReadyTimeout
(
15000
)
{
cnode
=
conf
->
getNode
(
myname
);
if
(
cnode
==
NULL
)
...
...
@@ -43,6 +46,20 @@ polltime(200)
polltime
=
200
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): polltime="
<<
polltime
<<
endl
;
int
updatetime
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-updatetime"
,
it
.
getProp
(
"updatetime"
));
if
(
updatetime
<=
0
)
updatetime
=
200
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): updatetime="
<<
polltime
<<
endl
;
ptUpdate
.
setTiming
(
updatetime
);
smReadyTimeout
=
atoi
(
conf
->
getArgParam
(
"--io-sm-ready-timeout"
,
it
.
getProp
(
"ready_timeout"
)).
c_str
());
if
(
smReadyTimeout
==
0
)
smReadyTimeout
=
15000
;
else
if
(
smReadyTimeout
<
0
)
smReadyTimeout
=
UniSetTimer
::
WaitUpTime
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): smReadyTimeout="
<<
smReadyTimeout
<<
endl
;
if
(
it
.
goChildren
()
)
{
...
...
@@ -88,7 +105,10 @@ polltime(200)
}
if
(
shm
->
isLocalwork
()
)
{
readConfiguration
();
mymap
.
resize
(
maxIndex
);
}
else
ic
->
addReadItem
(
sigc
::
mem_fun
(
this
,
&
UniExchange
::
readItem
)
);
}
...
...
@@ -103,6 +123,28 @@ UniExchange::~UniExchange()
// -----------------------------------------------------------------------------
void
UniExchange
::
execute
()
{
if
(
!
shm
->
waitSMready
(
smReadyTimeout
,
50
)
)
{
ostringstream
err
;
err
<<
myname
<<
"(execute): SharedMemory "
<<
smReadyTimeout
<<
" "
;
unideb
[
Debug
::
CRIT
]
<<
err
.
str
()
<<
endl
;
throw
SystemError
(
err
.
str
());
}
PassiveTimer
pt
(
UniSetTimer
::
WaitUpTime
);
if
(
shm
->
isLocalwork
()
)
{
maxIndex
=
0
;
readConfiguration
();
cerr
<<
"************************** readConfiguration: "
<<
pt
.
getCurrent
()
<<
" msec "
<<
endl
;
}
mymap
.
resize
(
maxIndex
);
initIterators
();
init_ok
=
true
;
while
(
1
)
{
for
(
NetNodeList
::
iterator
it
=
nlst
.
begin
();
it
!=
nlst
.
end
();
++
it
)
...
...
@@ -146,6 +188,12 @@ void UniExchange::execute()
if
(
!
ok
&&
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
": ****** cannot connect with node="
<<
it
->
node
<<
endl
;
}
if
(
ptUpdate
.
checkTime
()
)
{
updateLocalData
();
ptUpdate
.
reset
();
}
msleep
(
polltime
);
}
...
...
@@ -168,7 +216,11 @@ void UniExchange::NetNodeInfo::update( IOController_i::ShortMapSeq_var& map, SMI
{
shm
->
initDIterator
(
smap
[
i
].
dit
);
shm
->
initAIterator
(
smap
[
i
].
ait
);
smap
[
i
].
type
=
map
[
i
].
type
;
smap
[
i
].
id
=
map
[
i
].
id
;
}
smap
[
i
].
val
=
map
[
i
].
value
;
try
{
...
...
@@ -192,6 +244,66 @@ void UniExchange::NetNodeInfo::update( IOController_i::ShortMapSeq_var& map, SMI
}
}
// --------------------------------------------------------------------------
IOController_i
::
ShortMapSeq
*
UniExchange
::
getSensors
()
{
if
(
!
init_ok
)
throw
CORBA
::
COMM_FAILURE
();
IOController_i
::
ShortMapSeq
*
res
=
new
IOController_i
::
ShortMapSeq
();
res
->
length
(
mymap
.
size
()
);
int
i
=
0
;
for
(
SList
::
iterator
it
=
mymap
.
begin
();
it
!=
mymap
.
end
();
++
it
)
{
IOController_i
::
ShortMap
m
;
m
.
id
=
it
->
id
;
m
.
value
=
it
->
val
;
m
.
type
=
it
->
type
;
(
*
res
)[
i
++
]
=
m
;
}
return
res
;
}
// --------------------------------------------------------------------------
void
UniExchange
::
updateLocalData
()
{
for
(
SList
::
iterator
it
=
mymap
.
begin
();
it
!=
mymap
.
end
();
++
it
)
{
try
{
if
(
it
->
type
==
UniversalIO
::
DigitalInput
||
it
->
type
==
UniversalIO
::
DigitalOutput
)
{
it
->
val
=
shm
->
localGetState
(
it
->
dit
,
it
->
id
);
}
else
if
(
it
->
type
==
UniversalIO
::
AnalogInput
||
it
->
type
==
UniversalIO
::
AnalogOutput
)
{
it
->
val
=
shm
->
localGetValue
(
it
->
ait
,
it
->
id
);
}
}
catch
(
Exception
&
ex
)
{
dlog
[
Debug
::
INFO
]
<<
"(update): "
<<
ex
<<
endl
;
}
catch
(
...
)
{
dlog
[
Debug
::
INFO
]
<<
"(update): catch ..."
<<
endl
;
}
}
init_ok
=
true
;
}
// --------------------------------------------------------------------------
void
UniExchange
::
initIterators
()
{
for
(
SList
::
iterator
it
=
mymap
.
begin
();
it
!=
mymap
.
end
();
++
it
)
{
shm
->
initDIterator
(
it
->
dit
);
shm
->
initAIterator
(
it
->
ait
);
}
}
// --------------------------------------------------------------------------
void
UniExchange
::
askSensors
(
UniversalIO
::
UIOCommand
cmd
)
{
...
...
@@ -345,10 +457,44 @@ bool UniExchange::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec )
// ------------------------------------------------------------------------------------------
bool
UniExchange
::
initItem
(
UniXML_iterator
&
it
)
{
SInfo
i
;
i
.
id
=
DefaultObjectId
;
if
(
it
.
getProp
(
"id"
).
empty
()
)
i
.
id
=
conf
->
getSensorID
(
it
.
getProp
(
"name"
));
else
{
i
.
id
=
it
.
getIntProp
(
"id"
);
if
(
i
.
id
<=
0
)
i
.
id
=
DefaultObjectId
;
}
if
(
i
.
id
==
DefaultObjectId
)
{
if
(
dlog
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown ID for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
}
i
.
type
=
UniSetTypes
::
getIOType
(
it
.
getProp
(
"iotype"
));
if
(
i
.
type
==
UniversalIO
::
UnknownIOType
)
{
if
(
dlog
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown iotype= "
<<
it
.
getProp
(
"iotype"
)
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
}
i
.
val
=
0
;
mymap
[
maxIndex
++
]
=
i
;
if
(
maxIndex
>=
mymap
.
size
()
)
mymap
.
resize
(
maxIndex
+
10
);
return
true
;
}
// ------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UniExchange
::
help_print
(
int
argc
,
const
char
**
argv
)
{
cout
<<
"--unet-polltime msec - . 200 ."
<<
endl
;
...
...
extensions/UniNetwork/UniExchange.h
View file @
c6ffa6cc
...
...
@@ -8,6 +8,7 @@
#include "IOController.h"
#include "SMInterface.h"
#include "SharedMemory.h"
#include "PassiveTimer.h"
// -----------------------------------------------------------------------------
class
UniExchange
:
public
IOController
...
...
@@ -26,6 +27,8 @@ class UniExchange:
/*! help- */
static
void
help_print
(
int
argc
,
const
char
**
argv
);
virtual
IOController_i
::
ShortMapSeq
*
getSensors
();
protected
:
virtual
void
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
);
...
...
@@ -42,8 +45,17 @@ class UniExchange:
struct
SInfo
{
SInfo
()
:
val
(
0
),
id
(
UniSetTypes
::
DefaultObjectId
),
type
(
UniversalIO
::
UnknownIOType
)
{}
IOController
::
DIOStateList
::
iterator
dit
;
IOController
::
AIOStateList
::
iterator
ait
;
long
val
;
long
id
;
UniversalIO
::
IOTypes
type
;
};
typedef
std
::
vector
<
SInfo
>
SList
;
...
...
@@ -70,8 +82,16 @@ class UniExchange:
bool
check_item
(
UniXML_iterator
&
it
);
bool
readItem
(
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
bool
initItem
(
UniXML_iterator
&
it
);
void
updateLocalData
();
void
initIterators
();
int
polltime
;
PassiveTimer
ptUpdate
;
bool
init_ok
;
SList
mymap
;
int
maxIndex
;
int
smReadyTimeout
;
private
:
};
...
...
extensions/UniNetwork/start_fg.sh
View file @
c6ffa6cc
...
...
@@ -4,5 +4,7 @@ export LD_LIBRARY_PATH="../../lib/.libs;../lib/.libs"
ulimit
-Sc
10000000000
./uniset-start.sh
-f
./uniset-network
--confile
test.xml
--unet-id
SharedMemory
./uniset-start.sh
-f
./uniset-network
--confile
test.xml
\
--smemory-id
SharedMemory
\
--unet-id
UniExchange
include/IOController.h
View file @
c6ffa6cc
...
...
@@ -76,7 +76,7 @@ class IOController:
UniversalIO
::
IOTypes
type
=
UniversalIO
::
DigitalInput
,
UniSetTypes
::
ObjectId
sup_id
=
UniSetTypes
::
DefaultObjectId
);
/*! \warning , */
/*! \warning , */
virtual
void
saveValue
(
const
IOController_i
::
SensorInfo
&
si
,
CORBA
::
Long
value
,
UniversalIO
::
IOTypes
type
=
UniversalIO
::
AnalogInput
,
UniSetTypes
::
ObjectId
sup_id
=
UniSetTypes
::
DefaultObjectId
);
...
...
@@ -94,7 +94,7 @@ class IOController:
virtual
UniSetTypes
::
IDSeq
*
setOutputSeq
(
const
IOController_i
::
OutSeq
&
lst
,
UniSetTypes
::
ObjectId
sup_id
);
// ----------------------------------------------------------------
virtual
UniversalIO
::
IOTypes
getIOType
(
const
IOController_i
::
SensorInfo
&
si
);
virtual
UniversalIO
::
IOTypes
getIOType
(
const
IOController_i
::
SensorInfo
&
si
);
virtual
IOController_i
::
ASensorInfoSeq
*
getAnalogSensorsMap
();
virtual
IOController_i
::
DSensorInfoSeq
*
getDigitalSensorsMap
();
...
...
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