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
b43bc14b
Commit
b43bc14b
authored
Sep 15, 2009
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use getArgInt and getArgPInt
parent
63977bf7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
38 deletions
+21
-38
MBTCPMaster.cc
extensions/MBTCPMaster/MBTCPMaster.cc
+19
-36
UDPExchange.cc
extensions/UDPExchange/UDPExchange.cc
+1
-1
UniExchange.cc
extensions/UniNetwork/UniExchange.cc
+1
-1
No files found.
extensions/MBTCPMaster/MBTCPMaster.cc
View file @
b43bc14b
...
@@ -50,36 +50,27 @@ prefix(prefix)
...
@@ -50,36 +50,27 @@ prefix(prefix)
throw
UniSetTypes
::
SystemError
(
myname
+
"(MBMaster): Unknown inet addr...(Use: "
+
pname
+
")"
);
throw
UniSetTypes
::
SystemError
(
myname
+
"(MBMaster): Unknown inet addr...(Use: "
+
pname
+
")"
);
string
tmp
(
"--"
+
prefix
+
"-gateway-port"
);
string
tmp
(
"--"
+
prefix
+
"-gateway-port"
);
port
=
atoi
(
conf
->
getArgParam
(
tmp
,
it
.
getProp
(
"gateway_port"
)).
c_str
(
));
port
=
conf
->
getArgInt
(
tmp
,
it
.
getProp
(
"gateway_port"
));
if
(
port
<=
0
)
if
(
port
<=
0
)
throw
UniSetTypes
::
SystemError
(
myname
+
"(MBMaster): Unknown inet port...(Use: "
+
tmp
+
")"
);
throw
UniSetTypes
::
SystemError
(
myname
+
"(MBMaster): Unknown inet port...(Use: "
+
tmp
+
")"
);
recv_timeout
=
atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-recv-timeout"
,
it
.
getProp
(
"recv_timeout"
)).
c_str
());
recv_timeout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-recv-timeout"
,
it
.
getProp
(
"recv_timeout"
),
50
);
if
(
recv_timeout
<=
0
)
recv_timeout
=
50
;
int
alltout
=
atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-all-timeout"
,
it
.
getProp
(
"all_timeout"
)).
c_str
());
if
(
alltout
<=
0
)
alltout
=
2000
;
int
alltout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-all-timeout"
,
it
.
getProp
(
"all_timeout"
),
2000
);
ptAllNotRespond
.
setTiming
(
alltout
);
ptAllNotRespond
.
setTiming
(
alltout
);
noQueryOptimization
=
atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-no-query-optimization"
,
it
.
getProp
(
"no_query_optimization"
)).
c_str
(
));
noQueryOptimization
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-no-query-optimization"
,
it
.
getProp
(
"no_query_optimization"
));
mbregFromID
=
atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-reg-from-id"
,
it
.
getProp
(
"reg_from_id"
)).
c_str
(
));
mbregFromID
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-reg-from-id"
,
it
.
getProp
(
"reg_from_id"
));
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): mbregFromID="
<<
mbregFromID
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): mbregFromID="
<<
mbregFromID
<<
endl
;
polltime
=
atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-polltime"
,
it
.
getProp
(
"polltime"
)).
c_str
());
polltime
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-polltime"
,
it
.
getProp
(
"polltime"
),
100
);
if
(
!
polltime
)
polltime
=
100
;
initPause
=
atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-initPause"
,
it
.
getProp
(
"initPause"
)).
c_str
());
initPause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-initPause"
,
it
.
getProp
(
"initPause"
),
3000
);
if
(
!
initPause
)
initPause
=
3000
;
force
=
atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-force"
,
it
.
getProp
(
"force"
)).
c_str
(
));
force
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-force"
,
it
.
getProp
(
"force"
));
force_out
=
atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-force-out"
,
it
.
getProp
(
"force_out"
)).
c_str
(
));
force_out
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-force-out"
,
it
.
getProp
(
"force_out"
));
if
(
shm
->
isLocalwork
()
)
if
(
shm
->
isLocalwork
()
)
{
{
...
@@ -109,9 +100,7 @@ prefix(prefix)
...
@@ -109,9 +100,7 @@ prefix(prefix)
else
else
ptHeartBeat
.
setTiming
(
UniSetTimer
::
WaitUpTime
);
ptHeartBeat
.
setTiming
(
UniSetTimer
::
WaitUpTime
);
maxHeartBeat
=
atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-heartbeat-max"
,
it
.
getProp
(
"heartbeat_max"
)).
c_str
());
maxHeartBeat
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-heartbeat-max"
,
it
.
getProp
(
"heartbeat_max"
),
10
);
if
(
maxHeartBeat
<=
0
)
maxHeartBeat
=
10
;
test_id
=
sidHeartBeat
;
test_id
=
sidHeartBeat
;
}
}
else
else
...
@@ -128,9 +117,7 @@ prefix(prefix)
...
@@ -128,9 +117,7 @@ prefix(prefix)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): test_id="
<<
test_id
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): test_id="
<<
test_id
<<
endl
;
activateTimeout
=
atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-activate-timeout"
).
c_str
());
activateTimeout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-activate-timeout"
,
20000
);
if
(
activateTimeout
<=
0
)
activateTimeout
=
20000
;
initMB
(
false
);
initMB
(
false
);
...
@@ -192,13 +179,13 @@ void MBTCPMaster::initMB( bool reopen )
...
@@ -192,13 +179,13 @@ void MBTCPMaster::initMB( bool reopen )
void
MBTCPMaster
::
waitSMReady
()
void
MBTCPMaster
::
waitSMReady
()
{
{
// waiting for SM is ready...
// waiting for SM is ready...
int
ready_timeout
=
atoi
(
conf
->
getArgParam
(
"--mbm-sm-ready-timeout"
,
"15000"
).
c_str
()
);
int
ready_timeout
=
conf
->
getArgInt
(
"--mbm-sm-ready-timeout"
,
"15000"
);
if
(
ready_timeout
==
0
)
if
(
ready_timeout
==
0
)
ready_timeout
=
15000
;
ready_timeout
=
15000
;
else
if
(
ready_timeout
<
0
)
else
if
(
ready_timeout
<
0
)
ready_timeout
=
UniSetTimer
::
WaitUpTime
;
ready_timeout
=
UniSetTimer
::
WaitUpTime
;
if
(
!
shm
->
waitSMready
(
ready_timeout
,
50
)
)
if
(
!
shm
->
waitSMready
(
ready_timeout
,
50
)
)
{
{
ostringstream
err
;
ostringstream
err
;
err
<<
myname
<<
"(waitSMReady): SharedMemory "
<<
ready_timeout
<<
" "
;
err
<<
myname
<<
"(waitSMReady): SharedMemory "
<<
ready_timeout
<<
" "
;
...
@@ -1072,8 +1059,8 @@ bool MBTCPMaster::initRSProperty( RSProperty& p, UniXML_iterator& it )
...
@@ -1072,8 +1059,8 @@ bool MBTCPMaster::initRSProperty( RSProperty& p, UniXML_iterator& it )
bool
MBTCPMaster
::
initRegInfo
(
RegInfo
*
r
,
UniXML_iterator
&
it
,
MBTCPMaster
::
RTUDevice
*
dev
)
bool
MBTCPMaster
::
initRegInfo
(
RegInfo
*
r
,
UniXML_iterator
&
it
,
MBTCPMaster
::
RTUDevice
*
dev
)
{
{
r
->
dev
=
dev
;
r
->
dev
=
dev
;
r
->
mbval
=
UniSetTypes
::
uni_atoi
(
it
.
getProp
(
"default"
).
c_str
()
);
r
->
mbval
=
it
.
getIntProp
(
"default"
);
r
->
offset
=
UniSetTypes
::
uni_atoi
(
it
.
getProp
(
"tcp_mboffset"
).
c_str
()
);
r
->
offset
=
it
.
getIntProp
(
"tcp_mboffset"
);
if
(
dev
->
dtype
!=
MBTCPMaster
::
dtRTU
)
if
(
dev
->
dtype
!=
MBTCPMaster
::
dtRTU
)
{
{
...
@@ -1087,7 +1074,7 @@ bool MBTCPMaster::initRegInfo( RegInfo* r, UniXML_iterator& it, MBTCPMaster::RT
...
@@ -1087,7 +1074,7 @@ bool MBTCPMaster::initRegInfo( RegInfo* r, UniXML_iterator& it, MBTCPMaster::RT
if
(
it
.
getProp
(
"id"
).
empty
()
)
if
(
it
.
getProp
(
"id"
).
empty
()
)
r
->
mbreg
=
conf
->
getSensorID
(
it
.
getProp
(
"name"
));
r
->
mbreg
=
conf
->
getSensorID
(
it
.
getProp
(
"name"
));
else
else
r
->
mbreg
=
UniSetTypes
::
uni_atoi
(
it
.
getProp
(
"id"
).
c_str
()
);
r
->
mbreg
=
it
.
getIntProp
(
"id"
);
}
}
else
else
{
{
...
@@ -1383,13 +1370,9 @@ bool MBTCPMaster::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX
...
@@ -1383,13 +1370,9 @@ bool MBTCPMaster::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX
}
}
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(initDeviceInfo): add addr="
<<
ModbusRTU
::
addr2str
(
a
)
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(initDeviceInfo): add addr="
<<
ModbusRTU
::
addr2str
(
a
)
<<
endl
;
int
tout
=
atoi
(
it
.
getProp
(
"timeout"
).
c_str
());
int
tout
=
it
.
getPIntProp
(
"timeout"
,
UniSetTimer
::
WaitUpTime
);
if
(
tout
>
0
)
d
->
second
->
resp_ptTimeout
.
setTiming
(
tout
);
d
->
second
->
resp_ptTimeout
.
setTiming
(
tout
);
else
d
->
second
->
resp_invert
=
it
.
getIntProp
(
"invert"
);
d
->
second
->
resp_ptTimeout
.
setTiming
(
UniSetTimer
::
WaitUpTime
);
d
->
second
->
resp_invert
=
atoi
(
it
.
getProp
(
"invert"
).
c_str
());
return
true
;
return
true
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
...
extensions/UDPExchange/UDPExchange.cc
View file @
b43bc14b
...
@@ -119,7 +119,7 @@ maxItem(0)
...
@@ -119,7 +119,7 @@ maxItem(0)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): test_id="
<<
test_id
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): test_id="
<<
test_id
<<
endl
;
activateTimeout
=
conf
->
getArgPInt
(
"--activate-timeout"
)
,
20000
);
activateTimeout
=
conf
->
getArgPInt
(
"--activate-timeout"
,
20000
);
timeout_t
msec
=
conf
->
getArgPInt
(
"--udp-timeout"
,
it
.
getProp
(
"timeout"
),
3000
);
timeout_t
msec
=
conf
->
getArgPInt
(
"--udp-timeout"
,
it
.
getProp
(
"timeout"
),
3000
);
...
...
extensions/UniNetwork/UniExchange.cc
View file @
b43bc14b
...
@@ -53,7 +53,7 @@ smReadyTimeout(15000)
...
@@ -53,7 +53,7 @@ smReadyTimeout(15000)
ptUpdate
.
setTiming
(
updatetime
);
ptUpdate
.
setTiming
(
updatetime
);
smReadyTimeout
=
atoi
(
conf
->
getArgParam
(
"--io-sm-ready-timeout"
,
it
.
getProp
(
"ready_timeout"
)).
c_str
(
));
smReadyTimeout
=
conf
->
getArgInt
(
"--io-sm-ready-timeout"
,
it
.
getProp
(
"ready_timeout"
));
if
(
smReadyTimeout
==
0
)
if
(
smReadyTimeout
==
0
)
smReadyTimeout
=
15000
;
smReadyTimeout
=
15000
;
else
if
(
smReadyTimeout
<
0
)
else
if
(
smReadyTimeout
<
0
)
...
...
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