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
8755ae5c
Commit
8755ae5c
authored
Aug 08, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make style
parent
c966df0d
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
56 additions
and
39 deletions
+56
-39
MBExchange.h
extensions/ModbusMaster/MBExchange.h
+1
-1
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+4
-0
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+6
-5
UNetReceiver.cc
extensions/UNetUDP/UNetReceiver.cc
+4
-3
urecv_perf_test.cc
extensions/UNetUDP/tests/urecv_perf_test.cc
+16
-13
ModbusServer.cc
src/Communications/Modbus/ModbusServer.cc
+1
-1
ModbusTCPServer.cc
src/Communications/Modbus/ModbusTCPServer.cc
+1
-0
IOController.cc
src/Processes/IOController.cc
+2
-2
IONotifyController.cc
src/Processes/IONotifyController.cc
+11
-5
NCRestorer.cc
src/Processes/NCRestorer.cc
+2
-1
NCRestorer_XML.cc
src/Processes/NCRestorer_XML.cc
+6
-6
Configuration.cc
src/Various/Configuration.cc
+1
-1
MessageType.cc
src/Various/MessageType.cc
+1
-1
No files found.
extensions/ModbusMaster/MBExchange.h
View file @
8755ae5c
...
...
@@ -286,7 +286,7 @@ class MBExchange:
RTUDeviceMap
devices
;
InitList
initRegList
;
/*!< список регистров для инициализации */
// UniSetTypes::uniset_rwmutex pollMutex;
// UniSetTypes::uniset_rwmutex pollMutex;
virtual
std
::
shared_ptr
<
ModbusClient
>
initMB
(
bool
reopen
=
false
)
=
0
;
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
8755ae5c
...
...
@@ -180,8 +180,10 @@ MBSlave::MBSlave(UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, const
ostringstream
n
;
n
<<
prefix
<<
"-exchangelog"
;
auto
l
=
loga
->
create
(
n
.
str
());
if
(
mblog
->
is_crit
()
)
l
->
addLevel
(
Debug
::
CRIT
);
if
(
mblog
->
is_warn
()
)
l
->
addLevel
(
Debug
::
WARN
);
...
...
@@ -215,6 +217,7 @@ MBSlave::MBSlave(UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, const
if
(
mblog
->
is_crit
()
)
l
->
addLevel
(
Debug
::
CRIT
);
if
(
mblog
->
is_warn
()
)
l
->
addLevel
(
Debug
::
WARN
);
...
...
@@ -630,6 +633,7 @@ void MBSlave::execute_tcp()
tcpCancelled
=
false
;
ost
::
Thread
::
setException
(
ost
::
Thread
::
throwException
);
try
{
tcpserver
->
run
(
vaddr
,
true
);
...
...
extensions/SharedMemory/SharedMemory.cc
View file @
8755ae5c
...
...
@@ -312,10 +312,11 @@ bool SharedMemory::activateObject()
hit
.
ioit
=
myioEnd
();
}
for
(
auto
&&
it
:
histmap
)
for
(
auto
&&
it
:
histmap
)
{
auto
i
=
myiofind
(
it
.
first
);
if
(
i
!=
myioEnd
()
)
if
(
i
!=
myioEnd
()
)
i
->
second
->
userdata
[
udataHistory
]
=
(
void
*
)(
&
(
it
.
second
));
}
...
...
@@ -755,9 +756,9 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
HistoryItList
&
lst
=
*
(
static_cast
<
HistoryItList
*>
(
usi
->
userdata
[
udataHistory
]));
// auto i = histmap.find(s_it->si.id);
// if( i == histmap.end() )
// return;
// auto i = histmap.find(s_it->si.id);
// if( i == histmap.end() )
// return;
long
value
=
0
;
long
sm_tv_sec
=
0
;
...
...
extensions/UNetUDP/UNetReceiver.cc
View file @
8755ae5c
...
...
@@ -218,6 +218,7 @@ void UNetReceiver::start()
{
activated
=
true
;
loop
.
evrun
(
this
,
true
);
if
(
!
upThread
->
isRunning
()
)
upThread
->
start
();
}
...
...
@@ -280,9 +281,9 @@ void UNetReceiver::statisticsEvent(ev::periodic& tm, int revents)
}
unetlog9
<<
myname
<<
"(statisctics):"
<<
" recvCount="
<<
recvCount
<<
"[per sec]"
<<
" upCount="
<<
upCount
<<
"[per sec]"
<<
endl
;
<<
" recvCount="
<<
recvCount
<<
"[per sec]"
<<
" upCount="
<<
upCount
<<
"[per sec]"
<<
endl
;
recvCount
=
0
;
upCount
=
0
;
...
...
extensions/UNetUDP/tests/urecv_perf_test.cc
View file @
8755ae5c
...
...
@@ -29,7 +29,7 @@ shared_ptr<SMInterface> smiInstance()
return
smi
;
}
// --------------------------------------------------------------------------
static
void
run_senders
(
size_t
max
,
const
std
::
string
&
s_host
,
size_t
count
=
50
,
timeout_t
usecpause
=
50
)
static
void
run_senders
(
size_t
max
,
const
std
::
string
&
s_host
,
size_t
count
=
50
,
timeout_t
usecpause
=
50
)
{
ost
::
IPV4Host
host
(
s_host
.
c_str
());
...
...
@@ -39,11 +39,11 @@ static void run_senders( size_t max, const std::string& s_host, size_t count=50,
cout
<<
"Run "
<<
max
<<
" senders ("
<<
s_host
<<
")"
<<
endl
;
// make sendesrs..
for
(
size_t
i
=
0
;
i
<
max
;
i
++
)
for
(
size_t
i
=
0
;
i
<
max
;
i
++
)
{
try
{
auto
s
=
make_shared
<
ost
::
UDPSocket
>
(
host
,
begPort
+
i
);
auto
s
=
make_shared
<
ost
::
UDPSocket
>
(
host
,
begPort
+
i
);
vsend
.
emplace_back
(
s
);
}
catch
(
ost
::
SockException
&
e
)
...
...
@@ -71,12 +71,12 @@ static void run_senders( size_t max, const std::string& s_host, size_t count=50,
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
mypack
.
addDData
(
i
,
i
);
for
(
size_t
i
=
0
;
i
<
max
;
i
++
)
for
(
size_t
i
=
0
;
i
<
max
;
i
++
)
{
try
{
if
(
vsend
[
i
]
)
vsend
[
i
]
->
setPeer
(
host
,
begPort
+
i
);
vsend
[
i
]
->
setPeer
(
host
,
begPort
+
i
);
}
catch
(
ost
::
SockException
&
e
)
{
...
...
@@ -104,7 +104,7 @@ static void run_senders( size_t max, const std::string& s_host, size_t count=50,
if
(
packetnum
==
0
)
packetnum
=
1
;
for
(
auto
&&
udp
:
vsend
)
for
(
auto
&&
udp
:
vsend
)
{
try
{
...
...
@@ -127,6 +127,7 @@ static void run_senders( size_t max, const std::string& s_host, size_t count=50,
}
}
usleep
(
usecpause
);
}
}
...
...
@@ -137,16 +138,17 @@ static void run_test( size_t max, const std::string& host )
vrecv
.
reserve
(
max
);
// make receivers..
for
(
size_t
i
=
0
;
i
<
max
;
i
++
)
for
(
size_t
i
=
0
;
i
<
max
;
i
++
)
{
auto
r
=
make_shared
<
UNetReceiver
>
(
host
,
begPort
+
i
,
smiInstance
());
auto
r
=
make_shared
<
UNetReceiver
>
(
host
,
begPort
+
i
,
smiInstance
());
r
->
setLockUpdate
(
true
);
vrecv
.
emplace_back
(
r
);
}
size_t
count
=
0
;
// Run receivers..
for
(
auto
&&
r
:
vrecv
)
for
(
auto
&&
r
:
vrecv
)
{
if
(
r
)
{
...
...
@@ -160,7 +162,7 @@ static void run_test( size_t max, const std::string& host )
// wait..
pause
();
for
(
auto
&&
r
:
vrecv
)
for
(
auto
&&
r
:
vrecv
)
{
if
(
r
)
r
->
stop
();
...
...
@@ -170,14 +172,15 @@ static void run_test( size_t max, const std::string& host )
int
main
(
int
argc
,
char
*
argv
[]
)
{
std
::
string
host
=
"127.255.255.255"
;
try
{
auto
conf
=
uniset_init
(
argc
,
argv
);
if
(
argc
>
1
&&
!
strcmp
(
argv
[
1
],
"s"
)
)
run_senders
(
10
,
host
);
if
(
argc
>
1
&&
!
strcmp
(
argv
[
1
],
"s"
)
)
run_senders
(
10
,
host
);
else
run_test
(
10
,
host
);
run_test
(
10
,
host
);
return
0
;
}
...
...
src/Communications/Modbus/ModbusServer.cc
View file @
8755ae5c
...
...
@@ -1695,7 +1695,7 @@ ModbusRTU::mbErrCode ModbusServer::replySetDateTime( ModbusRTU::SetDateTimeMessa
struct
timezone
tz
;
struct
timeval
set
;
if
(
gettimeofday
(
&
set
,
&
tz
)
==
0
)
if
(
gettimeofday
(
&
set
,
&
tz
)
==
0
)
{
struct
tm
t
;
localtime_r
(
&
set
.
tv_sec
,
&
t
);
...
...
src/Communications/Modbus/ModbusTCPServer.cc
View file @
8755ae5c
...
...
@@ -91,6 +91,7 @@ bool ModbusTCPServer::isActive() const
void
ModbusTCPServer
::
evprepare
()
{
ost
::
Thread
::
setException
(
ost
::
Thread
::
throwException
);
try
{
sock
=
make_shared
<
UTCPSocket
>
(
iaddr
,
port
);
...
...
src/Processes/IOController.cc
View file @
8755ae5c
...
...
@@ -379,7 +379,7 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& usi, bool force
struct
timeval
tm
;
tm
.
tv_sec
=
0
;
tm
.
tv_usec
=
0
;
gettimeofday
(
&
tm
,
NULL
);
gettimeofday
(
&
tm
,
NULL
);
ai
->
tv_sec
=
tm
.
tv_sec
;
ai
->
tv_usec
=
tm
.
tv_usec
;
ai
->
value
=
ai
->
default_val
;
...
...
@@ -776,7 +776,7 @@ IOController::ChangeUndefinedStateSignal IOController::signal_change_undefined_s
throw
IOController_i
::
NameNotFound
(
err
.
str
().
c_str
());
}
// uniset_rwmutex_rlock lock(it->second->val_lock);
// uniset_rwmutex_rlock lock(it->second->val_lock);
return
it
->
second
->
sigUndefChange
;
}
// -----------------------------------------------------------------------------
...
...
src/Processes/IONotifyController.cc
View file @
8755ae5c
...
...
@@ -269,8 +269,9 @@ void IONotifyController::ask( AskMap& askLst, const UniSetTypes::ObjectId sid,
{
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
auto
s
=
myiofind
(
sid
);
if
(
s
!=
myioEnd
()
)
s
->
second
->
userdata
[
udataConsumerList
]
=
(
void
*
)(
&
(
askIterator
->
second
));
s
->
second
->
userdata
[
udataConsumerList
]
=
(
void
*
)(
&
(
askIterator
->
second
));
else
s
->
second
->
userdata
[
udataConsumerList
]
=
nullptr
;
}
...
...
@@ -329,6 +330,7 @@ void IONotifyController::localSetValue( std::shared_ptr<IOController::USensorInf
{
uniset_rwmutex_rlock
lock
(
askIOMutex
);
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
if
(
usi
->
userdata
[
udataConsumerList
]
!=
nullptr
)
{
...
...
@@ -617,6 +619,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
}
it
=
askTMap
.
find
(
sid
);
if
(
li
!=
myioEnd
()
)
{
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
...
...
@@ -698,12 +701,14 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn
{
uniset_rwmutex_rlock
lock
(
trshMutex
);
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
if
(
usi
->
userdata
[
udataThresholdList
]
==
nullptr
)
return
;
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
ti
=
static_cast
<
ThresholdsListInfo
*>
(
usi
->
userdata
[
udataThresholdList
]);
if
(
ti
->
list
.
empty
()
)
return
;
}
...
...
@@ -817,7 +822,7 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet
throw
IOController_i
::
NameNotFound
(
err
.
str
().
c_str
());
}
for
(
const
auto
&
it2
:
it
->
second
.
list
)
for
(
const
auto
&
it2
:
it
->
second
.
list
)
{
/*! \warning На самом деле список разрешает иметь много порогов с одинаковым ID, для разных "заказчиков".
Но здесь мы возвращаем первый встретившийся..
...
...
@@ -877,7 +882,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
size_t
k
=
0
;
for
(
const
auto
&
it2
:
it
->
second
.
list
)
for
(
const
auto
&
it2
:
it
->
second
.
list
)
{
res
->
tlist
[
k
].
id
=
it2
.
id
;
res
->
tlist
[
k
].
hilimit
=
it2
.
hilimit
;
...
...
@@ -903,7 +908,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
{
size_t
i
=
0
;
for
(
auto
&&
it
:
askTMap
)
for
(
auto
&&
it
:
askTMap
)
{
try
{
...
...
@@ -931,7 +936,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
size_t
k
=
0
;
for
(
const
auto
&
it2
:
it
.
second
.
list
)
for
(
const
auto
&
it2
:
it
.
second
.
list
)
{
(
*
res
)[
i
].
tlist
[
k
].
id
=
it2
.
id
;
(
*
res
)[
i
].
tlist
[
k
].
hilimit
=
it2
.
hilimit
;
...
...
@@ -963,6 +968,7 @@ void IONotifyController::onChangeUndefinedState( std::shared_ptr<USensorInfo>& u
{
// lock
uniset_rwmutex_rlock
lock
(
askIOMutex
);
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
if
(
usi
->
userdata
[
udataConsumerList
]
!=
nullptr
)
{
...
...
src/Processes/NCRestorer.cc
View file @
8755ae5c
...
...
@@ -121,6 +121,7 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, std::shared_ptr<IOCon
{
auto
i
=
ic
->
myiofind
(
inf
->
si
.
id
);
ic
->
askTMap
[
inf
->
si
.
id
].
usi
=
i
->
second
;
//! \warning Оптимизация использует userdata! Это опасно, если кто-то ещё захочет его использовать!
if
(
i
->
second
)
i
->
second
->
userdata
[
IONotifyController
::
udataThresholdList
]
=
&
(
ic
->
askTMap
[
inf
->
si
.
id
]);
...
...
@@ -149,7 +150,7 @@ NCRestorer::SInfo& NCRestorer::SInfo::operator=( const IOController_i::SensorIOI
this
->
blocked
=
inf
.
blocked
;
this
->
dbignore
=
inf
.
dbignore
;
for
(
size_t
i
=
0
;
i
<
IOController
::
USensorInfo
::
MaxUserData
;
i
++
)
for
(
size_t
i
=
0
;
i
<
IOController
::
USensorInfo
::
MaxUserData
;
i
++
)
this
->
userdata
[
i
]
=
nullptr
;
return
*
this
;
...
...
src/Processes/NCRestorer_XML.cc
View file @
8755ae5c
...
...
@@ -295,7 +295,7 @@ bool NCRestorer_XML::getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode*
{
ostringstream
err
;
err
<<
"(NCRestorer_XML:getSensorInfo): unknown iotype="
<<
xml
->
getProp
(
it
,
"iotype"
)
<<
" for "
<<
xml
->
getProp
(
it
,
"name"
);
<<
" for "
<<
xml
->
getProp
(
it
,
"name"
);
ucrit
<<
err
.
str
()
<<
endl
;
throw
SystemError
(
err
.
str
());
}
...
...
@@ -334,8 +334,8 @@ bool NCRestorer_XML::getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode*
{
ostringstream
err
;
err
<<
"(NCRestorer_XML:getSensorInfo): sensor='"
<<
xml
->
getProp
(
it
,
"name"
)
<<
"' err: "
<<
" Unknown SensorID for depend='"
<<
d_txt
;
<<
xml
->
getProp
(
it
,
"name"
)
<<
"' err: "
<<
" Unknown SensorID for depend='"
<<
d_txt
;
ucrit
<<
err
.
str
()
<<
endl
;
throw
SystemError
(
err
.
str
());
...
...
@@ -491,7 +491,7 @@ bool NCRestorer_XML::getThresholdInfo( const std::shared_ptr<UniXML>& xml, xmlNo
{
ostringstream
err
;
err
<<
"(NCRestorer_XML:getThresholdInfo): "
<<
" Not found ID for "
<<
sid_name
;
<<
" Not found ID for "
<<
sid_name
;
ucrit
<<
err
.
str
()
<<
endl
;
throw
SystemError
(
err
.
str
());
...
...
@@ -505,8 +505,8 @@ bool NCRestorer_XML::getThresholdInfo( const std::shared_ptr<UniXML>& xml, xmlNo
{
ostringstream
err
;
err
<<
"(NCRestorer_XML:getThresholdInfo): "
<<
" Bad iotype("
<<
iotype
<<
") for "
<<
sid_name
<<
". iotype must be 'DI' or 'DO'."
;
<<
" Bad iotype("
<<
iotype
<<
") for "
<<
sid_name
<<
". iotype must be 'DI' or 'DO'."
;
ucrit
<<
err
.
str
()
<<
endl
;
throw
SystemError
(
err
.
str
());
...
...
src/Various/Configuration.cc
View file @
8755ae5c
...
...
@@ -702,7 +702,7 @@ namespace UniSetTypes
return
_argc
;
}
// -------------------------------------------------------------------------
const
char
*
const
*
Configuration
::
getArgv
()
const
const
char
*
const
*
Configuration
::
getArgv
()
const
{
return
_argv
;
}
...
...
src/Various/MessageType.cc
View file @
8755ae5c
...
...
@@ -58,7 +58,7 @@ namespace UniSetTypes
{
tm
.
tv_sec
=
0
;
tm
.
tv_usec
=
0
;
gettimeofday
(
&
tm
,
NULL
);
gettimeofday
(
&
tm
,
NULL
);
}
/*
...
...
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