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
07eba77f
Commit
07eba77f
authored
Aug 21, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make style..
parent
6db2f221
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
58 additions
and
54 deletions
+58
-54
mb-perf-test.cc
extensions/ModbusMaster/mb-perf-test.cc
+5
-3
MessageType.h
include/MessageType.h
+1
-1
UniSetTypes.h
include/UniSetTypes.h
+1
-1
ModbusTCPCore.cc
src/Communications/Modbus/ModbusTCPCore.cc
+4
-4
ModbusTCPMaster.cc
src/Communications/Modbus/ModbusTCPMaster.cc
+1
-1
UniSetTypes.cc
src/ObjectRepository/UniSetTypes.cc
+20
-20
IONotifyController.cc
src/Processes/IONotifyController.cc
+3
-2
NCRestorer_XML.cc
src/Processes/NCRestorer_XML.cc
+1
-0
MessageType.cc
src/Various/MessageType.cc
+4
-4
develop.cc
tests/develop.cc
+18
-18
No files found.
extensions/ModbusMaster/mb-perf-test.cc
View file @
07eba77f
...
...
@@ -56,13 +56,15 @@ int main( int argc, const char** argv )
auto
act
=
UniSetActivator
::
Instance
();
int
count
=
conf
->
getArgPInt
(
"--count"
,
50
);
for
(
int
i
=
1
;
i
<=
count
;
i
++
)
int
count
=
conf
->
getArgPInt
(
"--count"
,
50
);
for
(
int
i
=
1
;
i
<=
count
;
i
++
)
{
ostringstream
prefix
;
prefix
<<
"mbtcp"
<<
i
;
auto
mb
=
MBTCPMultiMaster
::
init_mbmaster
(
argc
,
argv
,
shmID
,
nullptr
,
prefix
.
str
());
auto
mb
=
MBTCPMultiMaster
::
init_mbmaster
(
argc
,
argv
,
shmID
,
nullptr
,
prefix
.
str
());
if
(
!
mb
)
{
cerr
<<
"(main): "
<<
prefix
.
str
()
<<
" init failed..."
<<
endl
;
...
...
include/MessageType.h
View file @
07eba77f
...
...
@@ -229,7 +229,7 @@ namespace UniSetTypes
ConfirmMessage
(
const
VoidMessage
*
msg
);
ConfirmMessage
(
ObjectId
in_sensor_id
,
double
in_sensor_value
,
const
double
&
in_sensor_value
,
const
timespec
&
in_sensor_time
,
const
timespec
&
in_confirm_time
,
Priority
in_priority
=
Message
::
Medium
);
...
...
include/UniSetTypes.h
View file @
07eba77f
...
...
@@ -185,7 +185,7 @@ namespace UniSetTypes
inline
bool
operator
!=
(
const
struct
timespec
&
r1
,
const
struct
timespec
&
r2
)
{
return
!
(
operator
==
(
r1
,
r2
));
return
!
(
operator
==
(
r1
,
r2
));
}
/*! Разбивка строки по указанному символу */
...
...
src/Communications/Modbus/ModbusTCPCore.cc
View file @
07eba77f
...
...
@@ -34,7 +34,7 @@ size_t ModbusTCPCore::readNextData(UTCPStream* tcp,
#ifdef USE_BUFFER_FOR_READ
max
=
std
::
max
(
max
,(
size_t
)
DEFAULT_BUFFER_SIZE_FOR_READ
);
max
=
std
::
max
(
max
,
(
size_t
)
DEFAULT_BUFFER_SIZE_FOR_READ
);
char
*
buf
=
new
char
[
max
];
...
...
@@ -60,7 +60,7 @@ size_t ModbusTCPCore::readNextData(UTCPStream* tcp,
catch
(
ost
::
SockException
&
e
)
{
if
(
e
.
getSocketError
()
==
ost
::
Socket
::
errConnectFailed
||
e
.
getSocketError
()
==
ost
::
Socket
::
errConnectInvalid
)
e
.
getSocketError
()
==
ost
::
Socket
::
errConnectInvalid
)
{
commfail
=
true
;
}
...
...
@@ -136,7 +136,7 @@ size_t ModbusTCPCore::readDataFD( int fd, std::queue<unsigned char>& qrecv, size
#ifdef USE_BUFFER_FOR_READ
max
=
std
::
max
(
max
,(
size_t
)
DEFAULT_BUFFER_SIZE_FOR_READ
);
max
=
std
::
max
(
max
,
(
size_t
)
DEFAULT_BUFFER_SIZE_FOR_READ
);
char
*
buf
=
new
char
[
max
];
...
...
@@ -197,7 +197,7 @@ size_t ModbusTCPCore::readDataFD( int fd, std::queue<unsigned char>& qrecv, size
if
(
commfail
)
throw
UniSetTypes
::
CommFailed
();
return
std
::
min
(
qrecv
.
size
(),
max
);
return
std
::
min
(
qrecv
.
size
(),
max
);
}
// ------------------------------------------------------------------------
size_t
ModbusTCPCore
::
getDataFD
(
int
fd
,
std
::
queue
<
unsigned
char
>&
qrecv
,
...
...
src/Communications/Modbus/ModbusTCPMaster.cc
View file @
07eba77f
...
...
@@ -329,7 +329,7 @@ void ModbusTCPMaster::cleanInputStream()
}
while
(
ret
>
0
);
}
catch
(
...
){}
catch
(
...
)
{}
}
// -------------------------------------------------------------------------
void
ModbusTCPMaster
::
setReadTimeout
(
timeout_t
msec
)
...
...
src/ObjectRepository/UniSetTypes.cc
View file @
07eba77f
...
...
@@ -590,34 +590,34 @@ std::string UniSetTypes::replace_all( const std::string& src, const std::string&
// -------------------------------------------------------------------------
timeval
UniSetTypes
::
to_timeval
(
const
chrono
::
system_clock
::
duration
&
d
)
{
struct
timeval
tv
;
struct
timeval
tv
;
if
(
d
.
count
()
==
0
)
tv
.
tv_sec
=
tv
.
tv_usec
=
0
;
else
{
std
::
chrono
::
seconds
const
sec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
d
);
tv
.
tv_sec
=
sec
.
count
();
tv
.
tv_usec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
d
-
sec
).
count
();
}
if
(
d
.
count
()
==
0
)
tv
.
tv_sec
=
tv
.
tv_usec
=
0
;
else
{
std
::
chrono
::
seconds
const
sec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
d
);
tv
.
tv_sec
=
sec
.
count
();
tv
.
tv_usec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
d
-
sec
).
count
();
}
return
std
::
move
(
tv
);
return
std
::
move
(
tv
);
}
// -------------------------------------------------------------------------
timespec
UniSetTypes
::
to_timespec
(
const
chrono
::
system_clock
::
duration
&
d
)
{
struct
timespec
ts
;
struct
timespec
ts
;
if
(
d
.
count
()
==
0
)
ts
.
tv_sec
=
ts
.
tv_nsec
=
0
;
else
{
std
::
chrono
::
seconds
const
sec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
d
);
ts
.
tv_sec
=
sec
.
count
();
ts
.
tv_nsec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
nanoseconds
>
(
d
-
sec
).
count
();
}
if
(
d
.
count
()
==
0
)
ts
.
tv_sec
=
ts
.
tv_nsec
=
0
;
else
{
std
::
chrono
::
seconds
const
sec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
d
);
ts
.
tv_sec
=
sec
.
count
();
ts
.
tv_nsec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
nanoseconds
>
(
d
-
sec
).
count
();
}
return
std
::
move
(
ts
);
return
std
::
move
(
ts
);
}
// -------------------------------------------------------------------------
timespec
UniSetTypes
::
now_to_timespec
()
...
...
src/Processes/IONotifyController.cc
View file @
07eba77f
...
...
@@ -88,7 +88,8 @@ SimpleInfo* IONotifyController::getInfo( ::CORBA::Long userparam )
auto
oind
=
uniset_conf
()
->
oind
;
uniset_rwmutex_rlock
lock
(
askIOMutex
);
for
(
auto
&&
a
:
askIOList
)
for
(
auto
&&
a
:
askIOList
)
{
auto
&
i
=
a
.
second
;
...
...
@@ -100,7 +101,7 @@ SimpleInfo* IONotifyController::getInfo( ::CORBA::Long userparam )
inf
<<
"("
<<
setw
(
6
)
<<
a
.
first
<<
")["
<<
oind
->
getMapName
(
a
.
first
)
<<
"]"
<<
endl
;
for
(
const
auto
&
c
:
i
.
clst
)
for
(
const
auto
&
c
:
i
.
clst
)
{
inf
<<
" "
<<
"("
<<
setw
(
6
)
<<
c
.
id
<<
")"
<<
setw
(
35
)
<<
ORepHelpers
::
getShortName
(
oind
->
getMapName
(
c
.
id
))
...
...
src/Processes/NCRestorer_XML.cc
View file @
07eba77f
...
...
@@ -442,6 +442,7 @@ void NCRestorer_XML::read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode
if
(
cit
.
goChildren
()
)
{
IONotifyController
::
ConsumerListInfo
lst
;
if
(
getConsumerList
(
xml
,
cit
,
lst
)
)
{
std
::
shared_ptr
<
IOController
::
USensorInfo
>
uinf
=
std
::
static_pointer_cast
<
IOController
::
USensorInfo
>
(
inf
);
...
...
src/Various/MessageType.cc
View file @
07eba77f
...
...
@@ -196,10 +196,10 @@ namespace UniSetTypes
}
//--------------------------------------------------------------------------------------------
ConfirmMessage
::
ConfirmMessage
(
UniSetTypes
::
ObjectId
in_sensor_id
,
double
in_sensor_value
,
const
timespec
&
in_sensor_time
,
const
timespec
&
in_confirm_time
,
Priority
in_priority
)
:
const
double
&
in_sensor_value
,
const
timespec
&
in_sensor_time
,
const
timespec
&
in_confirm_time
,
Priority
in_priority
)
:
sensor_id
(
in_sensor_id
),
sensor_value
(
in_sensor_value
),
sensor_time
(
in_sensor_time
),
...
...
tests/develop.cc
View file @
07eba77f
...
...
@@ -30,24 +30,24 @@ int main( int argc, const char** argv )
return
0
;
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
p1
,
p2
,
p3
;
p2
=
std
::
chrono
::
system_clock
::
now
();
p3
=
p2
-
std
::
chrono
::
hours
(
24
);
std
::
time_t
epoch_time
=
std
::
chrono
::
system_clock
::
to_time_t
(
p1
);
std
::
cout
<<
"epoch: "
<<
std
::
ctime
(
&
epoch_time
);
std
::
time_t
today_time
=
std
::
chrono
::
system_clock
::
to_time_t
(
p2
);
std
::
cout
<<
"today: "
<<
std
::
ctime
(
&
today_time
);
std
::
cout
<<
"hours since epoch: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
hours
>
(
p2
.
time_since_epoch
()).
count
()
<<
'\n'
;
std
::
cout
<<
"yesterday, hours since epoch: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
hours
>
(
p3
.
time_since_epoch
()).
count
()
<<
'\n'
;
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
p1
,
p2
,
p3
;
p2
=
std
::
chrono
::
system_clock
::
now
();
p3
=
p2
-
std
::
chrono
::
hours
(
24
);
std
::
time_t
epoch_time
=
std
::
chrono
::
system_clock
::
to_time_t
(
p1
);
std
::
cout
<<
"epoch: "
<<
std
::
ctime
(
&
epoch_time
);
std
::
time_t
today_time
=
std
::
chrono
::
system_clock
::
to_time_t
(
p2
);
std
::
cout
<<
"today: "
<<
std
::
ctime
(
&
today_time
);
std
::
cout
<<
"hours since epoch: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
hours
>
(
p2
.
time_since_epoch
()).
count
()
<<
'\n'
;
std
::
cout
<<
"yesterday, hours since epoch: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
hours
>
(
p3
.
time_since_epoch
()).
count
()
<<
'\n'
;
return
0
;
unsigned
char
dat
[]
=
{
'1'
,
'2'
,
'3'
,
'4'
};
...
...
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