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
e751a8d7
Commit
e751a8d7
authored
Aug 04, 2009
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix warnings and tabs
parent
1a422150
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
81 additions
and
74 deletions
+81
-74
IOControl.cc
extensions/IOControl/IOControl.cc
+0
-1
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+2
-2
LT_Object.h
include/LT_Object.h
+2
-2
Mutex.h
include/Mutex.h
+1
-1
PassiveTimer.h
include/PassiveTimer.h
+0
-7
UniSetObject.h
include/UniSetObject.h
+2
-2
ModbusServer.h
include/modbus/ModbusServer.h
+1
-0
ModbusTCPMaster.cc
src/Communications/Modbus/ModbusTCPMaster.cc
+3
-3
ModbusTCPServer.cc
src/Communications/Modbus/ModbusTCPServer.cc
+1
-1
ModbusTypes.cc
src/Communications/Modbus/ModbusTypes.cc
+12
-12
IOController.cc
src/Processes/IOController.cc
+2
-0
IONotifyController.cc
src/Processes/IONotifyController.cc
+0
-2
TimerService.cc
src/Services/TimerService.cc
+4
-4
PassiveSysTimer.cc
src/Timers/PassiveSysTimer.cc
+10
-10
PassiveTimer.cc
src/Timers/PassiveTimer.cc
+33
-20
Configuration.cc
src/Various/Configuration.cc
+1
-1
LT_Object.cc
src/Various/LT_Object.cc
+2
-2
Mutex.cc
src/Various/Mutex.cc
+2
-2
SMonitor.cc
src/Various/SMonitor.cc
+1
-1
TableStorage.cc
src/Various/TableStorage.cc
+2
-1
No files found.
extensions/IOControl/IOControl.cc
View file @
e751a8d7
...
@@ -91,7 +91,6 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
...
@@ -91,7 +91,6 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
string
stype
=
conf
->
getArgParam
(
t1
.
str
(),
it
.
getProp
(
t2
.
str
()));
string
stype
=
conf
->
getArgParam
(
t1
.
str
(),
it
.
getProp
(
t2
.
str
()));
if
(
!
stype
.
empty
()
)
if
(
!
stype
.
empty
()
)
{
{
// ComediInterface::SubdevType st = (ComediInterface::SubdevType)UniSetTypes::uni_atoi(stype.c_str());
ComediInterface
::
SubdevType
st
=
ComediInterface
::
str2type
(
stype
.
c_str
());
ComediInterface
::
SubdevType
st
=
ComediInterface
::
str2type
(
stype
.
c_str
());
if
(
!
stype
.
empty
()
&&
st
==
ComediInterface
::
Unknown
)
if
(
!
stype
.
empty
()
&&
st
==
ComediInterface
::
Unknown
)
{
{
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
e751a8d7
...
@@ -19,9 +19,9 @@ UniSetObject_LT(objId),
...
@@ -19,9 +19,9 @@ UniSetObject_LT(objId),
mbslot
(
0
),
mbslot
(
0
),
shm
(
0
),
shm
(
0
),
initPause
(
0
),
initPause
(
0
),
askCount
(
0
),
test_id
(
DefaultObjectId
),
test_id
(
DefaultObjectId
),
askcount_id
(
DefaultObjectId
),
askcount_id
(
DefaultObjectId
),
askCount
(
0
),
activated
(
false
),
activated
(
false
),
activateTimeout
(
500
),
activateTimeout
(
500
),
pingOK
(
true
),
pingOK
(
true
),
...
@@ -51,7 +51,7 @@ prefix(prefix)
...
@@ -51,7 +51,7 @@ prefix(prefix)
force
=
uni_atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-force"
,
it
.
getProp
(
"force"
)));
force
=
uni_atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-force"
,
it
.
getProp
(
"force"
)));
int
recv_timeout
=
atoi
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-recv-timeout"
,
it
.
getProp
(
"recv_timeout"
)).
c_str
());
//
int recv_timeout = atoi(conf->getArgParam("--" + prefix + "-recv-timeout",it.getProp("recv_timeout")).c_str());
string
saddr
=
conf
->
getArgParam
(
"--"
+
prefix
+
"-my-addr"
,
it
.
getProp
(
"addr"
));
string
saddr
=
conf
->
getArgParam
(
"--"
+
prefix
+
"-my-addr"
,
it
.
getProp
(
"addr"
));
...
...
include/LT_Object.h
View file @
e751a8d7
...
@@ -157,8 +157,8 @@ class LT_Object
...
@@ -157,8 +157,8 @@ class LT_Object
short
curTick
;
short
curTick
;
//
//
bool
operator
<
(
const
TimerInfo
&
ti
)
const
bool
operator
<
(
const
TimerInfo
&
ti
)
const
{
{
return
curTimeMS
>
ti
.
curTimeMS
;
return
curTimeMS
>
ti
.
curTimeMS
;
}
}
...
...
include/Mutex.h
View file @
e751a8d7
...
@@ -66,10 +66,10 @@ namespace UniSetTypes
...
@@ -66,10 +66,10 @@ namespace UniSetTypes
friend
class
uniset_mutex_lock
;
friend
class
uniset_mutex_lock
;
uniset_mutex
(
const
uniset_mutex
&
r
);
uniset_mutex
(
const
uniset_mutex
&
r
);
const
uniset_mutex
&
operator
=
(
const
uniset_mutex
&
r
);
const
uniset_mutex
&
operator
=
(
const
uniset_mutex
&
r
);
omni_condition
*
cnd
;
std
::
string
nm
;
std
::
string
nm
;
omni_semaphore
sem
;
omni_semaphore
sem
;
omni_mutex
mtx
;
omni_mutex
mtx
;
omni_condition
*
cnd
;
mutex_atomic_t
locked
;
mutex_atomic_t
locked
;
};
};
...
...
include/PassiveTimer.h
View file @
e751a8d7
...
@@ -30,13 +30,6 @@
...
@@ -30,13 +30,6 @@
#include <sys/time.h>
#include <sys/time.h>
//#include "Exceptions.h"
//#include "Exceptions.h"
//----------------------------------------------------------------------------------------
// CLK_TCK
#ifndef CLK_TCK
#define CLK_TCK sysconf(_SC_CLK_TCK)
#endif
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
/*! \class UniSetTimer
/*! \class UniSetTimer
...
...
include/UniSetObject.h
View file @
e751a8d7
...
@@ -95,7 +95,7 @@ class UniSetObject:
...
@@ -95,7 +95,7 @@ class UniSetObject:
virtual
void
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
);
virtual
void
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
);
/*! */
/*! */
bool
receiveMessage
(
UniSetTypes
::
VoidMessage
&
msg
);
bool
receiveMessage
(
UniSetTypes
::
VoidMessage
&
vm
);
/*! */
/*! */
unsigned
int
countMessages
();
unsigned
int
countMessages
();
...
@@ -219,7 +219,7 @@ class UniSetObject:
...
@@ -219,7 +219,7 @@ class UniSetObject:
bool
reg
;
bool
reg
;
bool
active
;
bool
active
;
bool
threadcreate
;
bool
threadcreate
;
UniSetTimer
*
tmr
;
UniSetTimer
*
tmr
;
UniSetTypes
::
ObjectId
myid
;
UniSetTypes
::
ObjectId
myid
;
CORBA
::
Object_var
oref
;
CORBA
::
Object_var
oref
;
ThreadCreator
<
UniSetObject
>*
thr
;
ThreadCreator
<
UniSetObject
>*
thr
;
...
...
include/modbus/ModbusServer.h
View file @
e751a8d7
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#define ModbusServer_H_
#define ModbusServer_H_
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
#include <string>
#include <string>
#include "Debug.h"
#include "Debug.h"
#include "Mutex.h"
#include "Mutex.h"
#include "Configuration.h"
#include "Configuration.h"
...
...
src/Communications/Modbus/ModbusTCPMaster.cc
View file @
e751a8d7
...
@@ -97,8 +97,8 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
...
@@ -97,8 +97,8 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
if
(
res
!=
erNoError
)
if
(
res
!=
erNoError
)
return
res
;
return
res
;
if
(
!
tcp
->
isPending
(
ost
::
Socket
::
pendingOutput
,
timeout
)
)
if
(
!
tcp
->
isPending
(
ost
::
Socket
::
pendingOutput
,
timeout
)
)
return
erTimeOut
;
return
erTimeOut
;
if
(
timeout
!=
TIMEOUT_INF
)
if
(
timeout
!=
TIMEOUT_INF
)
{
{
...
@@ -124,7 +124,7 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
...
@@ -124,7 +124,7 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
dlog
(
Debug
::
INFO
)
<<
endl
;
dlog
(
Debug
::
INFO
)
<<
endl
;
}
}
if
(
ret
<
sizeof
(
rmh
)
)
if
(
ret
<
(
int
)
sizeof
(
rmh
)
)
return
erHardwareError
;
return
erHardwareError
;
rmh
.
swapdata
();
rmh
.
swapdata
();
...
...
src/Communications/Modbus/ModbusTCPServer.cc
View file @
e751a8d7
...
@@ -150,7 +150,7 @@ mbErrCode ModbusTCPServer::tcp_processing( ost::TCPStream& tcp, ModbusTCP::MBAPH
...
@@ -150,7 +150,7 @@ mbErrCode ModbusTCPServer::tcp_processing( ost::TCPStream& tcp, ModbusTCP::MBAPH
while
(
!
qrecv
.
empty
()
)
while
(
!
qrecv
.
empty
()
)
qrecv
.
pop
();
qrecv
.
pop
();
int
len
=
getNextData
((
unsigned
char
*
)(
&
mhead
),
sizeof
(
mhead
));
unsigned
int
len
=
getNextData
((
unsigned
char
*
)(
&
mhead
),
sizeof
(
mhead
));
if
(
len
<
sizeof
(
mhead
)
)
if
(
len
<
sizeof
(
mhead
)
)
return
erInvalidFormat
;
return
erInvalidFormat
;
...
...
src/Communications/Modbus/ModbusTypes.cc
View file @
e751a8d7
...
@@ -369,7 +369,7 @@ DataBits::operator ModbusByte()
...
@@ -369,7 +369,7 @@ DataBits::operator ModbusByte()
ModbusByte
DataBits
::
mbyte
()
ModbusByte
DataBits
::
mbyte
()
{
{
ModbusByte
ubyte
=
0
;
ModbusByte
ubyte
=
0
;
for
(
int
i
=
0
;
i
<
b
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
b
.
size
();
i
++
)
{
{
if
(
b
[
i
]
)
if
(
b
[
i
]
)
ubyte
|=
1
<<
i
;
ubyte
|=
1
<<
i
;
...
@@ -380,7 +380,7 @@ ModbusByte DataBits::mbyte()
...
@@ -380,7 +380,7 @@ ModbusByte DataBits::mbyte()
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
const
DataBits
&
DataBits
::
operator
=
(
const
ModbusByte
&
r
)
const
DataBits
&
DataBits
::
operator
=
(
const
ModbusByte
&
r
)
{
{
for
(
int
i
=
0
;
i
<
b
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
b
.
size
();
i
++
)
b
[
i
]
=
r
&
(
1
<<
i
);
b
[
i
]
=
r
&
(
1
<<
i
);
return
(
*
this
);
return
(
*
this
);
...
@@ -389,7 +389,7 @@ const DataBits& DataBits::operator=( const ModbusByte& r )
...
@@ -389,7 +389,7 @@ const DataBits& DataBits::operator=( const ModbusByte& r )
std
::
ostream
&
ModbusRTU
::
operator
<<
(
std
::
ostream
&
os
,
DataBits
&
d
)
std
::
ostream
&
ModbusRTU
::
operator
<<
(
std
::
ostream
&
os
,
DataBits
&
d
)
{
{
os
<<
"["
;
os
<<
"["
;
for
(
int
i
=
d
.
b
.
size
()
-
1
;
i
>=
0
;
i
--
)
for
(
int
i
=
(
int
)
d
.
b
.
size
()
-
1
;
i
>=
0
;
i
--
)
os
<<
d
.
b
[
i
];
os
<<
d
.
b
[
i
];
os
<<
"]"
;
os
<<
"]"
;
...
@@ -425,7 +425,7 @@ DataBits16::operator ModbusData()
...
@@ -425,7 +425,7 @@ DataBits16::operator ModbusData()
ModbusData
DataBits16
::
mdata
()
ModbusData
DataBits16
::
mdata
()
{
{
ModbusData
udata
=
0
;
ModbusData
udata
=
0
;
for
(
int
i
=
0
;
i
<
b
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
b
.
size
();
i
++
)
{
{
if
(
b
[
i
]
)
if
(
b
[
i
]
)
udata
|=
1
<<
i
;
udata
|=
1
<<
i
;
...
@@ -436,7 +436,7 @@ ModbusData DataBits16::mdata()
...
@@ -436,7 +436,7 @@ ModbusData DataBits16::mdata()
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
const
DataBits16
&
DataBits16
::
operator
=
(
const
ModbusData
&
r
)
const
DataBits16
&
DataBits16
::
operator
=
(
const
ModbusData
&
r
)
{
{
for
(
int
i
=
0
;
i
<
b
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
b
.
size
();
i
++
)
b
[
i
]
=
r
&
(
1
<<
i
);
b
[
i
]
=
r
&
(
1
<<
i
);
return
(
*
this
);
return
(
*
this
);
...
@@ -445,7 +445,7 @@ const DataBits16& DataBits16::operator=( const ModbusData& r )
...
@@ -445,7 +445,7 @@ const DataBits16& DataBits16::operator=( const ModbusData& r )
std
::
ostream
&
ModbusRTU
::
operator
<<
(
std
::
ostream
&
os
,
DataBits16
&
d
)
std
::
ostream
&
ModbusRTU
::
operator
<<
(
std
::
ostream
&
os
,
DataBits16
&
d
)
{
{
os
<<
"["
;
os
<<
"["
;
for
(
int
i
=
d
.
b
.
size
()
-
1
;
i
>=
0
;
i
--
)
for
(
int
i
=
(
int
)
d
.
b
.
size
()
-
1
;
i
>=
0
;
i
--
)
os
<<
d
.
b
[
i
];
os
<<
d
.
b
[
i
];
os
<<
"]"
;
os
<<
"]"
;
...
@@ -876,7 +876,7 @@ void ReadOutputRetMessage::init( ModbusMessage& m )
...
@@ -876,7 +876,7 @@ void ReadOutputRetMessage::init( ModbusMessage& m )
func
=
m
.
func
;
func
=
m
.
func
;
// bcnt = m.data[0];
// bcnt = m.data[0];
int
cnt
=
m
.
data
[
0
]
/
sizeof
(
ModbusData
);
unsigned
int
cnt
=
m
.
data
[
0
]
/
sizeof
(
ModbusData
);
if
(
cnt
>
MAXLENPACKET
/
sizeof
(
ModbusData
)
)
if
(
cnt
>
MAXLENPACKET
/
sizeof
(
ModbusData
)
)
{
{
// cerr << "(ReadOutputRetMessage): BAD bcnt="
// cerr << "(ReadOutputRetMessage): BAD bcnt="
...
@@ -889,7 +889,7 @@ void ReadOutputRetMessage::init( ModbusMessage& m )
...
@@ -889,7 +889,7 @@ void ReadOutputRetMessage::init( ModbusMessage& m )
memcpy
(
&
data
,
&
(
m
.
data
[
1
]),
bcnt
);
memcpy
(
&
data
,
&
(
m
.
data
[
1
]),
bcnt
);
//
//
for
(
int
i
=
0
;
i
<
cnt
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
cnt
;
i
++
)
data
[
i
]
=
SWAPSHORT
(
data
[
i
]);
data
[
i
]
=
SWAPSHORT
(
data
[
i
]);
memcpy
(
&
crc
,
&
(
m
.
data
[
bcnt
+
1
]),
szCRC
);
memcpy
(
&
crc
,
&
(
m
.
data
[
bcnt
+
1
]),
szCRC
);
...
@@ -1092,7 +1092,7 @@ void ReadInputRetMessage::init( ModbusMessage& m )
...
@@ -1092,7 +1092,7 @@ void ReadInputRetMessage::init( ModbusMessage& m )
func
=
m
.
func
;
func
=
m
.
func
;
// bcnt = m.data[0];
// bcnt = m.data[0];
int
cnt
=
m
.
data
[
0
]
/
sizeof
(
ModbusData
);
unsigned
int
cnt
=
m
.
data
[
0
]
/
sizeof
(
ModbusData
);
if
(
cnt
>
MAXLENPACKET
/
sizeof
(
ModbusData
)
)
if
(
cnt
>
MAXLENPACKET
/
sizeof
(
ModbusData
)
)
throw
mbException
(
erPacketTooLong
);
throw
mbException
(
erPacketTooLong
);
...
@@ -1101,10 +1101,10 @@ void ReadInputRetMessage::init( ModbusMessage& m )
...
@@ -1101,10 +1101,10 @@ void ReadInputRetMessage::init( ModbusMessage& m )
memcpy
(
&
data
,
&
(
m
.
data
[
1
]),
bcnt
);
memcpy
(
&
data
,
&
(
m
.
data
[
1
]),
bcnt
);
//
//
for
(
int
i
=
0
;
i
<
cnt
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
cnt
;
i
++
)
data
[
i
]
=
SWAPSHORT
(
data
[
i
]);
data
[
i
]
=
SWAPSHORT
(
data
[
i
]);
memcpy
(
&
crc
,
&
(
m
.
data
[
bcnt
+
1
]),
szCRC
);
memcpy
(
&
crc
,
&
(
m
.
data
[
bcnt
+
1
]),
szCRC
);
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
int
ReadInputRetMessage
::
getDataLen
(
ModbusMessage
&
m
)
int
ReadInputRetMessage
::
getDataLen
(
ModbusMessage
&
m
)
...
@@ -2910,7 +2910,7 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os, FileTransferRetMessage* m
...
@@ -2910,7 +2910,7 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os, FileTransferRetMessage* m
std
::
ostream
&
ModbusTCP
::
operator
<<
(
std
::
ostream
&
os
,
MBAPHeader
&
m
)
std
::
ostream
&
ModbusTCP
::
operator
<<
(
std
::
ostream
&
os
,
MBAPHeader
&
m
)
{
{
// m.swapdata();
// m.swapdata();
for
(
int
i
=
0
;
i
<
sizeof
(
m
);
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
sizeof
(
m
);
i
++
)
os
<<
((
unsigned
char
*
)(
&
m
))[
i
];
os
<<
((
unsigned
char
*
)(
&
m
))[
i
];
// m.swapdata();
// m.swapdata();
return
os
;
return
os
;
...
...
src/Processes/IOController.cc
View file @
e751a8d7
...
@@ -896,6 +896,8 @@ UniSetTypes::Message::Priority IOController::getMessagePriority(UniSetTypes::Key
...
@@ -896,6 +896,8 @@ UniSetTypes::Message::Priority IOController::getMessagePriority(UniSetTypes::Key
return
(
UniSetTypes
::
Message
::
Priority
)
it
->
second
.
priority
;
return
(
UniSetTypes
::
Message
::
Priority
)
it
->
second
.
priority
;
}
}
break
;
break
;
default
:
break
;
}
}
return
UniSetTypes
::
Message
::
Medium
;
// ??
return
UniSetTypes
::
Message
::
Medium
;
// ??
...
...
src/Processes/IONotifyController.cc
View file @
e751a8d7
...
@@ -203,7 +203,6 @@ void IONotifyController::askState( const IOController_i::SensorInfo& si,
...
@@ -203,7 +203,6 @@ void IONotifyController::askState( const IOController_i::SensorInfo& si,
// , ...
// , ...
DIOStateList
::
iterator
li
=
mydioEnd
();
DIOStateList
::
iterator
li
=
mydioEnd
();
bool
st
=
localGetState
(
li
,
si
);
// lock ???
// lock ???
if
(
li
==
mydioEnd
()
)
if
(
li
==
mydioEnd
()
)
...
@@ -288,7 +287,6 @@ void IONotifyController::askValue(const IOController_i::SensorInfo& si,
...
@@ -288,7 +287,6 @@ void IONotifyController::askValue(const IOController_i::SensorInfo& si,
// , ...
// , ...
AIOStateList
::
iterator
li
=
myaioEnd
();
AIOStateList
::
iterator
li
=
myaioEnd
();
long
val
=
localGetValue
(
li
,
si
);
if
(
li
->
second
.
type
!=
UniversalIO
::
AnalogInput
)
if
(
li
->
second
.
type
!=
UniversalIO
::
AnalogInput
)
{
{
ostringstream
err
;
ostringstream
err
;
...
...
src/Services/TimerService.cc
View file @
e751a8d7
...
@@ -107,7 +107,7 @@ void TimerService::askTimer( const TimerService_i::Timer& ti, const UniSetTypes:
...
@@ -107,7 +107,7 @@ void TimerService::askTimer( const TimerService_i::Timer& ti, const UniSetTypes:
{
{
li
->
curTick
=
ti
.
ticks
;
li
->
curTick
=
ti
.
ticks
;
li
->
tmr
.
setTiming
(
ti
.
timeMS
);
li
->
tmr
.
setTiming
(
ti
.
timeMS
);
li
->
not_ping
=
false
;
li
->
not_ping
=
false
;
li
->
lifetmr
.
reset
();
li
->
lifetmr
.
reset
();
unideb
[
Debug
::
INFO
]
<<
myname
<<
": (id="
<<
ti
.
timerid
<<
") "
unideb
[
Debug
::
INFO
]
<<
myname
<<
": (id="
<<
ti
.
timerid
<<
") "
<<
ti
.
timeMS
<<
" [] "
<<
ui
.
getNameById
(
ci
.
id
)
<<
ti
.
timeMS
<<
" [] "
<<
ui
.
getNameById
(
ci
.
id
)
...
@@ -212,7 +212,7 @@ void TimerService::work()
...
@@ -212,7 +212,7 @@ void TimerService::work()
if
(
!
AskLifeTimeSEC
)
if
(
!
AskLifeTimeSEC
)
{
{
unideb
[
Debug
::
WARN
]
<<
myname
<<
": "
<<
ui
.
getNameById
(
li
->
cinf
.
id
,
li
->
cinf
.
node
)
<<
endl
;
unideb
[
Debug
::
WARN
]
<<
myname
<<
": "
<<
ui
.
getNameById
(
li
->
cinf
.
id
,
li
->
cinf
.
node
)
<<
endl
;
li
=
tlst
.
erase
(
li
);
li
=
tlst
.
erase
(
li
);
if
(
tlst
.
empty
()
)
if
(
tlst
.
empty
()
)
isSleep
=
true
;
isSleep
=
true
;
continue
;
continue
;
...
@@ -225,7 +225,7 @@ void TimerService::work()
...
@@ -225,7 +225,7 @@ void TimerService::work()
else
if
(
li
->
lifetmr
.
checkTime
()
)
else
if
(
li
->
lifetmr
.
checkTime
()
)
{
{
unideb
[
Debug
::
WARN
]
<<
myname
<<
": "
<<
ui
.
getNameById
(
li
->
cinf
.
id
,
li
->
cinf
.
node
)
<<
endl
;
unideb
[
Debug
::
WARN
]
<<
myname
<<
": "
<<
ui
.
getNameById
(
li
->
cinf
.
id
,
li
->
cinf
.
node
)
<<
endl
;
li
=
tlst
.
erase
(
li
);
li
=
tlst
.
erase
(
li
);
if
(
tlst
.
empty
()
)
if
(
tlst
.
empty
()
)
isSleep
=
true
;
isSleep
=
true
;
continue
;
continue
;
...
@@ -237,7 +237,7 @@ void TimerService::work()
...
@@ -237,7 +237,7 @@ void TimerService::work()
//
//
if
(
!
li
->
curTick
)
if
(
!
li
->
curTick
)
{
{
li
=
tlst
.
erase
(
li
);
li
=
tlst
.
erase
(
li
);
if
(
tlst
.
empty
()
)
if
(
tlst
.
empty
()
)
isSleep
=
true
;
isSleep
=
true
;
continue
;
continue
;
...
...
src/Timers/PassiveSysTimer.cc
View file @
e751a8d7
...
@@ -103,7 +103,7 @@ int PassiveSysTimer::wait(int timeMS)
...
@@ -103,7 +103,7 @@ int PassiveSysTimer::wait(int timeMS)
if
(
sigaction
(
SIGALRM
,
&
action
,
0
)
==
-
1
)
if
(
sigaction
(
SIGALRM
,
&
action
,
0
)
==
-
1
)
{
{
cerr
<<
"PassiveSysTimer: error sigaction"
<<
endl
;
cerr
<<
"PassiveSysTimer: error sigaction"
<<
endl
;
return
0
;
return
false
;
}
}
...
@@ -112,7 +112,7 @@ int PassiveSysTimer::wait(int timeMS)
...
@@ -112,7 +112,7 @@ int PassiveSysTimer::wait(int timeMS)
terminated
=
0
;
terminated
=
0
;
int
sec
;
int
sec
;
int
msec
;
int
msec
;
if
(
timeMS
==
WaitUpTime
)
if
(
timeMS
==
WaitUpTime
)
{
{
...
@@ -126,19 +126,19 @@ int PassiveSysTimer::wait(int timeMS)
...
@@ -126,19 +126,19 @@ int PassiveSysTimer::wait(int timeMS)
}
}
mtimer
.
it_value
.
tv_sec
=
sec
;
mtimer
.
it_value
.
tv_sec
=
sec
;
mtimer
.
it_value
.
tv_usec
=
msec
;
mtimer
.
it_value
.
tv_usec
=
msec
;
mtimer
.
it_interval
.
tv_sec
=
0
;
mtimer
.
it_interval
.
tv_sec
=
0
;
mtimer
.
it_interval
.
tv_usec
=
0
;
mtimer
.
it_interval
.
tv_usec
=
0
;
setitimer
(
ITIMER_REAL
,
&
mtimer
,
(
struct
itimerval
*
)
0
);
setitimer
(
ITIMER_REAL
,
&
mtimer
,
(
struct
itimerval
*
)
0
);
PassiveTimer
::
setTiming
(
timeMS
);
// PassiveTimer-
PassiveTimer
::
setTiming
(
timeMS
);
// PassiveTimer-
sigset_t
mask
,
oldmask
;
sigset_t
mask
,
oldmask
;
sigemptyset
(
&
mask
);
sigemptyset
(
&
mask
);
//
//
sigaddset
(
&
mask
,
SIGALRM
);
sigaddset
(
&
mask
,
SIGALRM
);
sigprocmask
(
SIG_BLOCK
,
&
mask
,
&
oldmask
);
sigprocmask
(
SIG_BLOCK
,
&
mask
,
&
oldmask
);
if
(
timeMS
==
WaitUpTime
)
if
(
timeMS
==
WaitUpTime
)
{
{
while
(
!
terminated
)
while
(
!
terminated
)
...
@@ -148,10 +148,10 @@ int PassiveSysTimer::wait(int timeMS)
...
@@ -148,10 +148,10 @@ int PassiveSysTimer::wait(int timeMS)
sigsuspend
(
&
oldmask
);
sigsuspend
(
&
oldmask
);
terminated
=
1
;
terminated
=
1
;
sigprocmask
(
SIG_UNBLOCK
,
&
mask
,
NULL
);
sigprocmask
(
SIG_UNBLOCK
,
&
mask
,
NULL
);
// cout << "PassiveSysTimer: time ok"<< endl;
// cout << "PassiveSysTimer: time ok"<< endl;
return
1
;
return
true
;
}
}
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
...
...
src/Timers/PassiveTimer.cc
View file @
e751a8d7
...
@@ -29,15 +29,22 @@
...
@@ -29,15 +29,22 @@
#include <unistd.h>
#include <unistd.h>
#include "PassiveTimer.h"
#include "PassiveTimer.h"
//----------------------------------------------------------------------------------------
// CLK_TCK
#ifndef CLK_TCK
#define CLK_TCK sysconf(_SC_CLK_TCK)
#endif
//----------------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
PassiveTimer
::
PassiveTimer
(
)
:
PassiveTimer
::
PassiveTimer
(
)
:
timeAct
(
0
),
timeAct
(
0
),
timeSS
(
0
),
timeSS
(
0
),
timeStart
(
0
)
timeStart
(
0
),
clock_ticks
(
sysconf
(
_SC_CLK_TCK
))
{
{
clock_ticks
=
sysconf
(
_SC_CLK_TCK
);
setTiming
(
WaitUpTime
);
setTiming
(
-
1
);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -45,65 +52,71 @@ timeStart(0)
...
@@ -45,65 +52,71 @@ timeStart(0)
PassiveTimer
::
PassiveTimer
(
int
timeMS
)
:
PassiveTimer
::
PassiveTimer
(
int
timeMS
)
:
timeAct
(
0
),
timeAct
(
0
),
timeSS
(
0
),
timeSS
(
0
),
timeStart
(
0
)
timeStart
(
0
),
clock_ticks
(
sysconf
(
_SC_CLK_TCK
))
{
{
// printf("const =%d\n",timeMS);
// printf("const =%d\n",timeMS);
clock_ticks
=
sysconf
(
_SC_CLK_TCK
);
setTiming
(
timeMS
);
setTiming
(
timeMS
);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/*! \note timeMS<0, */
bool
PassiveTimer
::
checkTime
()
bool
PassiveTimer
::
checkTime
()
{
{
// printf("times=%d, act=%d\n",times(0),timeAct);
// printf("times=%d, act=%d\n",times(0),timeAct);
// printf("%d\n",timeSS); msleep(10);
// printf("%d\n",timeSS); msleep(10);
if
(
timeSS
<
0
)
// == WaitUpTime
;
if
(
timeSS
==
WaitUpTime
)
;
return
false
;
return
false
;
if
(
times
(
0
)
>=
timeAct
)
if
(
times
()
>=
timeAct
)
return
true
;
return
true
;
return
false
;
return
false
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
//
void
PassiveTimer
::
setTiming
(
in
t
timeMS
)
timeout_t
PassiveTimer
::
setTiming
(
timeout_
t
timeMS
)
{
{
if
(
timeMS
<
0
)
if
(
timeMS
==
WaitUpTime
)
{
{
// getCurrent()
timeSS
=
WaitUpTime
;
// ӣ-
timeSS
=
WaitUpTime
;
timeStart
=
times
(
0
);
// PassiveTimer::reset();
}
}
else
else
{
{
timeSS
=
timeMS
/
10
;
//
timeSS
=
timeMS
/
10
;
//
if
(
timeMS
%
10
)
if
(
timeMS
%
10
)
timeSS
++
;
//
timeSS
++
;
//
PassiveTimer
::
reset
();
}
}
PassiveTimer
::
reset
();
return
getInterval
();
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
//
void
PassiveTimer
::
reset
(
void
)
void
PassiveTimer
::
reset
(
void
)
{
{
timeStart
=
times
(
0
);
timeStart
=
times
();
if
(
timeSS
==
WaitUpTime
)
return
;
timeAct
=
(
timeSS
*
clock_ticks
)
/
100
+
timeStart
;
timeAct
=
(
timeSS
*
clock_ticks
)
/
100
+
timeStart
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
//
in
t
PassiveTimer
::
getCurrent
()
timeout_
t
PassiveTimer
::
getCurrent
()
{
{
return
(
times
(
0
)
-
timeStart
)
*
1000
/
clock_ticks
;
return
(
times
()
-
timeStart
)
*
1000
/
clock_ticks
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
PassiveTimer
::
terminate
()
void
PassiveTimer
::
terminate
()
{
{
timeAct
=
0
;
timeAct
=
0
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
clock_t
PassiveTimer
::
times
()
{
// Linux NULL
struct
tms
tm
;
return
::
times
(
&
tm
);
}
src/Various/Configuration.cc
View file @
e751a8d7
...
@@ -129,7 +129,7 @@ Configuration::Configuration( int argc, const char** argv, const string xmlfile
...
@@ -129,7 +129,7 @@ Configuration::Configuration( int argc, const char** argv, const string xmlfile
_argc
(
argc
),
_argc
(
argc
),
_argv
(
argv
),
_argv
(
argv
),
NSName
(
"NameService"
),
NSName
(
"NameService"
),
repeatCount
(
2
),
repeatTimeout
(
100
),
repeatCount
(
2
),
repeatTimeout
(
100
),
localTimerService
(
UniSetTypes
::
DefaultObjectId
),
localTimerService
(
UniSetTypes
::
DefaultObjectId
),
localDBServer
(
UniSetTypes
::
DefaultObjectId
),
localDBServer
(
UniSetTypes
::
DefaultObjectId
),
localInfoServer
(
UniSetTypes
::
DefaultObjectId
),
localInfoServer
(
UniSetTypes
::
DefaultObjectId
),
...
...
src/Various/LT_Object.cc
View file @
e751a8d7
...
@@ -88,14 +88,14 @@ int LT_Object::checkTimers( UniSetObject* obj )
...
@@ -88,14 +88,14 @@ int LT_Object::checkTimers( UniSetObject* obj )
//
//
if
(
!
li
->
curTick
)
if
(
!
li
->
curTick
)
{
{
li
=
tlst
.
erase
(
li
);
li
=
tlst
.
erase
(
li
);
if
(
tlst
.
empty
()
)
if
(
tlst
.
empty
()
)
sleepTime
=
UniSetTimer
::
WaitUpTime
;
sleepTime
=
UniSetTimer
::
WaitUpTime
;
continue
;
continue
;
}
}
else
if
(
li
->
curTick
>
0
)
else
if
(
li
->
curTick
>
0
)
li
->
curTick
--
;
li
->
curTick
--
;
li
->
reset
();
li
->
reset
();
resort
=
true
;
resort
=
true
;
}
}
...
...
src/Various/Mutex.cc
View file @
e751a8d7
...
@@ -35,8 +35,8 @@ using namespace UniSetTypes;
...
@@ -35,8 +35,8 @@ using namespace UniSetTypes;
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
static
mutex_atomic_t
mutex_atomic_read
(
mutex_atomic_t
*
m
){
return
(
*
m
);
}
static
mutex_atomic_t
mutex_atomic_read
(
mutex_atomic_t
*
m
){
return
(
*
m
);
}
static
mutex_atomic_t
mutex_atomic_set
(
mutex_atomic_t
*
m
,
int
val
){
return
(
*
m
)
=
val
;
}
static
mutex_atomic_t
mutex_atomic_set
(
mutex_atomic_t
*
m
,
int
val
){
return
(
*
m
)
=
val
;
}
static
void
mutex_atomic_inc
(
mutex_atomic_t
*
m
){
(
*
m
)
++
;
}
//
static void mutex_atomic_inc( mutex_atomic_t* m ){ (*m)++; }
static
void
mutex_atomic_dec
(
mutex_atomic_t
*
m
){
(
*
m
)
--
;
}
//
static void mutex_atomic_dec( mutex_atomic_t* m ){ (*m)--; }
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#ifndef HAVE_LINUX_LIBC_HEADERS_INCLUDE_LINUX_FUTEX_H
#ifndef HAVE_LINUX_LIBC_HEADERS_INCLUDE_LINUX_FUTEX_H
uniset_mutex
::
uniset_mutex
()
:
uniset_mutex
::
uniset_mutex
()
:
...
...
src/Various/SMonitor.cc
View file @
e751a8d7
...
@@ -178,7 +178,7 @@ void SMonitor::sensorInfo( SensorMessage *si )
...
@@ -178,7 +178,7 @@ void SMonitor::sensorInfo( SensorMessage *si )
cmd
<<
" "
<<
si
->
sm_tv_sec
<<
" "
<<
si
->
sm_tv_usec
;
cmd
<<
" "
<<
si
->
sm_tv_sec
<<
" "
<<
si
->
sm_tv_usec
;
int
ret
=
system
(
cmd
.
str
().
c_str
());
(
void
)
system
(
cmd
.
str
().
c_str
());
// if( WIFSIGNALED(ret) && (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))
// if( WIFSIGNALED(ret) && (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))
// {
// {
// cout << "finish..." << endl;
// cout << "finish..." << endl;
...
...
src/Various/TableStorage.cc
View file @
e751a8d7
...
@@ -154,9 +154,10 @@ int TableStorage::addRow(char* key, char* value)
...
@@ -154,9 +154,10 @@ int TableStorage::addRow(char* key, char* value)
if
((
tbl
->
status
==
2
)
||
(
tbl
->
status
==
3
))
st
=
2
;
if
((
tbl
->
status
==
2
)
||
(
tbl
->
status
==
3
))
st
=
2
;
else
st
=
4
;
else
st
=
4
;
if
(
j
==
0
)
if
(
j
==
0
)
{
if
(
st
==
2
)
st
=
4
;
if
(
st
==
2
)
st
=
4
;
else
st
=
2
;
else
st
=
2
;
}
tbl
->
status
=
st
;
tbl
->
status
=
st
;
strcpy
(
tbl
->
key
,
key
);
strcpy
(
tbl
->
key
,
key
);
...
...
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