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
562e8cd4
Commit
562e8cd4
authored
Dec 25, 2018
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes after checking PVS-Studio (static anaylzer)
parent
2c035327
Hide whitespace changes
Inline
Side-by-side
Showing
55 changed files
with
519 additions
and
360 deletions
+519
-360
Makefile.am
Makefile.am
+5
-0
README.md
README.md
+2
-0
admin.cc
Utilities/Admin/admin.cc
+17
-17
MBSlave.cc
Utilities/MBTester/MBSlave.cc
+5
-5
log2val.cc
Utilities/ULog/log2val.cc
+1
-1
logserver.cc
Utilities/ULog/logserver.cc
+0
-5
ctl-cpp-cc-ask.xsl
Utilities/codegen/ctl-cpp-cc-ask.xsl
+6
-6
ctl-cpp-cc.xsl
Utilities/codegen/ctl-cpp-cc.xsl
+1
-1
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+2
-2
DBServer_PostgreSQL.cc
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
+1
-3
IOControl.cc
extensions/IOControl/IOControl.cc
+13
-16
IOControl.h
extensions/IOControl/IOControl.h
+19
-21
iotest.cc
extensions/IOControl/iotest.cc
+1
-1
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+46
-62
vtconv.cc
extensions/ModbusMaster/vtconv.cc
+1
-1
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+42
-52
start_tcp_fg.sh
extensions/ModbusSlave/start_tcp_fg.sh
+2
-0
mbslave_perf_test.cc
extensions/ModbusSlave/tests/mbslave_perf_test.cc
+4
-4
tests_with_sm.sh
extensions/ModbusSlave/tests/tests_with_sm.sh
+3
-2
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+4
-4
UDPPacket.h
extensions/UNetUDP/UDPPacket.h
+1
-1
UNetSender.cc
extensions/UNetUDP/UNetSender.cc
+1
-1
test_unetudp.cc
extensions/UNetUDP/tests/test_unetudp.cc
+1
-1
urecv_perf_test.cc
extensions/UNetUDP/tests/urecv_perf_test.cc
+1
-1
UniExchange.cc
extensions/UniNetwork/UniExchange.cc
+1
-1
IOBase.h
extensions/include/IOBase.h
+3
-0
UObject_SK.h
extensions/include/UObject_SK.h
+1
-1
VTypes.h
extensions/include/VTypes.h
+3
-3
IOBase.cc
extensions/lib/IOBase.cc
+112
-4
MTR.cc
extensions/lib/MTR.cc
+5
-2
SMInterface.cc
extensions/lib/SMInterface.cc
+4
-5
UObject_SK.cc
extensions/lib/UObject_SK.cc
+7
-7
test_vtypes.cc
extensions/tests/test_vtypes.cc
+14
-14
Configuration.h
include/Configuration.h
+1
-1
MessageType.h
include/MessageType.h
+1
-1
UniSetTypes.h
include/UniSetTypes.h
+5
-13
ModbusTCPServer.h
include/modbus/ModbusTCPServer.h
+1
-1
ModbusTypes.h
include/modbus/ModbusTypes.h
+18
-0
ComPort485F.cc
src/Communications/ComPort485F.cc
+3
-1
ModbusTCPMaster.cc
src/Communications/Modbus/ModbusTCPMaster.cc
+4
-4
ModbusTCPServer.cc
src/Communications/Modbus/ModbusTCPServer.cc
+3
-3
ModbusTypes.cc
src/Communications/Modbus/ModbusTypes.cc
+22
-22
Configuration.cc
src/Core/Configuration.cc
+18
-10
MessageType.cc
src/Core/MessageType.cc
+1
-0
UInterface.cc
src/Core/UInterface.cc
+4
-6
UniSetManager.cc
src/Core/UniSetManager.cc
+34
-34
UniSetObject.cc
src/Core/UniSetObject.cc
+8
-5
UniSetTypes.cc
src/Core/UniSetTypes.cc
+44
-1
LogReader.cc
src/Log/LogReader.cc
+1
-1
EventLoopServer.cc
src/Processes/EventLoopServer.cc
+5
-2
PassiveObject.cc
src/Processes/PassiveObject.cc
+4
-4
test_mutex.cc
tests/test_mutex.cc
+5
-5
test_sscanf_hex.cc
tests/test_sscanf_hex.cc
+1
-1
UModbus.cc
wrappers/core/UModbus.cc
+1
-1
UProxyObject.cc
wrappers/core/UProxyObject.cc
+6
-0
No files found.
Makefile.am
View file @
562e8cd4
...
...
@@ -19,6 +19,11 @@ clean-local:
install-data-local
:
$(MAKE)
-C
$(FIRSTSUBDIRS)
-j1
install
pvs-check
:
make clean
pvs-studio-analyzer trace
--
jmake
pvs-studio-analyzer analyze
-j
$(nproc)
plog-converter
-a
GA:1,2
-t
tasklist
-o
uniset.pvs.tasks PVS-Studio.log
if
HAVE_COVERAGE
COVERAGE_DIRS
=
$(COVERAGE_DEFAULT_DIRS)
...
...
README.md
View file @
562e8cd4
...
...
@@ -27,3 +27,5 @@ More information:
*
[
RU
]
https://habr.com/post/278535/
*
[
RU
]
https://habr.com/post/171711/
*
[
RU
]
https://wiki.etersoft.ru/UniSet2/docs/
periodically checked by
[
PVS-Studio Analyzer
](
https://www.viva64.com/en/pvs-studio/
)
Utilities/Admin/admin.cc
View file @
562e8cd4
...
...
@@ -382,11 +382,6 @@ int main(int argc, char** argv)
return
0
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
!
quiet
)
cout
<<
"admin(main): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
if
(
!
quiet
)
...
...
@@ -407,6 +402,11 @@ int main(int argc, char** argv)
cerr
<<
" mesg: "
<<
fe
.
errmsg
()
<<
endl
;
}
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
!
quiet
)
cout
<<
"admin(main): "
<<
ex
<<
endl
;
}
catch
(
std
::
exception
&
ex
)
{
if
(
!
quiet
)
...
...
@@ -546,15 +546,15 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository
}
}
}
catch
(
const
uniset
::
Exception
&
ex
)
catch
(
const
CORBA
::
System
Exception
&
ex
)
{
if
(
!
quiet
)
cerr
<<
setw
(
55
)
<<
oname
<<
" <--- "
<<
ex
<<
endl
;
cerr
<<
setw
(
55
)
<<
oname
<<
" <--- недоступен!!(CORBA::SystemException): "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
CORBA
::
System
Exception
&
ex
)
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
!
quiet
)
cerr
<<
setw
(
55
)
<<
oname
<<
" <--- недоступен!!(CORBA::SystemException): "
<<
ex
.
NP_minorString
()
<<
endl
;
cerr
<<
setw
(
55
)
<<
oname
<<
" <--- "
<<
ex
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
...
...
@@ -730,7 +730,7 @@ int getValue( const string& args, UInterface& ui )
// до числа, то сперва получаем val
long
val
=
ui
.
getValue
(
it
.
si
.
id
,
it
.
si
.
node
);
if
(
csv
&&
num
++
>
0
)
if
(
num
++
>
0
)
cout
<<
","
;
cout
<<
val
;
...
...
@@ -888,13 +888,6 @@ int getTimeChange( const std::string& args, UInterface& ui )
else
cout
<<
ui
.
getTimeChange
(
it
.
si
.
id
,
it
.
si
.
node
);
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
!
quiet
)
cerr
<<
"(getChangedTime): "
<<
ex
<<
endl
;;
err
=
1
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
if
(
!
quiet
)
...
...
@@ -921,6 +914,13 @@ int getTimeChange( const std::string& args, UInterface& ui )
err
=
1
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
!
quiet
)
cerr
<<
"(getChangedTime): "
<<
ex
<<
endl
;;
err
=
1
;
}
catch
(
const
std
::
exception
&
ex
)
{
if
(
!
quiet
)
...
...
Utilities/MBTester/MBSlave.cc
View file @
562e8cd4
...
...
@@ -29,11 +29,11 @@ MBSlave::MBSlave(const std::unordered_set<ModbusAddr>& _vaddr, const std::string
// if( replyTimeout <= 0 )
// replyTimeout = 2000;
if
(
verbose
)
cout
<<
"(init): "
<<
" addr="
<<
ModbusServer
::
vaddr2str
(
vaddr
)
<<
" dev="
<<
dev
<<
" speed="
<<
speed
;
//
if( verbose )
//
cout << "(init): "
//
<< " addr=" << ModbusServer::vaddr2str(vaddr)
//
<< " dev=" << dev
//
<< " speed=" << speed;
rscomm
=
new
ModbusRTUSlaveSlot
(
dev
,
use485
);
...
...
Utilities/ULog/log2val.cc
View file @
562e8cd4
...
...
@@ -7,7 +7,7 @@ using namespace std;
// --------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
2
||
(
argc
>
1
&&
(
!
strcmp
(
argv
[
1
],
"--help"
)
||
!
strcmp
(
argv
[
1
],
"-h"
)))
)
if
(
argc
<
2
||
(
argc
>
1
&&
(
!
strcmp
(
argv
[
1
],
"--help"
)
||
!
strcmp
(
argv
[
1
],
"-h"
)))
)
// -V560
{
cout
<<
"Usage: lo2gval [ info,warn,crit,level1...level9,init,repository,system,exception | any ]"
<<
endl
;
return
0
;
...
...
Utilities/ULog/logserver.cc
View file @
562e8cd4
...
...
@@ -123,11 +123,6 @@ int main( int argc, char** argv )
}
}
if
(
!
checkfilter
.
empty
()
)
{
}
if
(
verb
)
{
cout
<<
"(init): listen "
<<
addr
<<
":"
<<
port
...
...
Utilities/codegen/ctl-cpp-cc-ask.xsl
View file @
562e8cd4
...
...
@@ -95,15 +95,15 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() noexcept
updateOutputs(forceOut);
updatePreviousValues();
}
catch( const uniset::Exception
&
ex )
{
mycrit
<<
myname
<<
"(execute): "
<<
ex
<<
endl;
}
catch( const CORBA::SystemException
&
ex )
{
mycrit
<<
myname
<<
"(execute): СORBA::SystemException: "
<<
ex.NP_minorString()
<<
endl;
}
catch( const uniset::Exception
&
ex )
{
mycrit
<<
myname
<<
"(execute): "
<<
ex
<<
endl;
}
catch( const std::exception
&
ex )
{
mycrit
<<
myname
<<
"(execute): catch "
<<
ex.what()
<<
endl;
...
...
@@ -289,7 +289,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
</xsl:template>
<xsl:template
name=
"setdata"
>
if(
<xsl:value-of
select=
"@name"
/>
!= DefaultObjectId )
if(
<xsl:value-of
select=
"@name"
/>
!= DefaultObjectId )
// -V547
{
try
{
...
...
@@ -307,7 +307,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
<xsl:template
name=
"setdata_value"
>
<xsl:param
name=
"setval"
>
0
</xsl:param>
if(
<xsl:value-of
select=
"@name"
/>
!= DefaultObjectId )
if(
<xsl:value-of
select=
"@name"
/>
!= DefaultObjectId )
// -V547
{
try
{
...
...
Utilities/codegen/ctl-cpp-cc.xsl
View file @
562e8cd4
...
...
@@ -231,7 +231,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
<xsl:template
name=
"setdata"
>
try
{
if(
<xsl:value-of
select=
"@name"
/>
!= DefaultObjectId )
if(
<xsl:value-of
select=
"@name"
/>
!= DefaultObjectId )
// -V547
{
si.id =
<xsl:value-of
select=
"@name"
/>
;
si.node = node_
<xsl:value-of
select=
"@name"
/>
;
...
...
Utilities/codegen/ctl-cpp-common.xsl
View file @
562e8cd4
...
...
@@ -1263,7 +1263,7 @@ end_private(false)
sleep_msec = conf->getArgPInt("--" + argprefix + "sleep-msec","
<xsl:call-template
name=
"settings"
><xsl:with-param
name=
"varname"
select=
"'sleep-msec'"
/></xsl:call-template>
",
<xsl:call-template
name=
"settings"
><xsl:with-param
name=
"varname"
select=
"'sleep-msec'"
/></xsl:call-template>
);
string s_resetTime("
<xsl:call-template
name=
"settings"
><xsl:with-param
name=
"varname"
select=
"'resetMsgTime'"
/></xsl:call-template>
");
if( s_resetTime.empty() )
if( s_resetTime.empty() )
// -V547
s_resetTime = "500";
resetMsgTime = uni_atoi(init3_str(conf->getArgParam("--" + argprefix + "resetMsgTime"),conf->getProp(cnode,"resetMsgTime"),s_resetTime));
...
...
@@ -1285,7 +1285,7 @@ end_private(false)
</xsl:if>
</xsl:for-each>
if( smTestID == DefaultObjectId )
if( smTestID == DefaultObjectId )
// -V547
smTestID = getSMTestID();
activateTimeout = conf->getArgPInt("--" + argprefix + "activate-timeout", 120000);
...
...
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
View file @
562e8cd4
...
...
@@ -192,7 +192,7 @@ void DBServer_PostgreSQL::flushInsertBuffer()
// Чистим заданное число
size_t
delnum
=
lroundf
(
ibufSize
*
ibufOverflowCleanFactor
);
auto
end
=
ibuf
.
end
();
auto
beg
=
ibuf
.
end
();
auto
beg
=
ibuf
.
begin
();
// Удаляем последние (новые)
if
(
lastRemove
)
...
...
@@ -202,8 +202,6 @@ void DBServer_PostgreSQL::flushInsertBuffer()
else
{
// Удаляем первые (старые)
beg
=
ibuf
.
begin
();
end
=
ibuf
.
begin
();
std
::
advance
(
end
,
delnum
);
}
...
...
extensions/IOControl/IOControl.cc
View file @
562e8cd4
...
...
@@ -158,21 +158,18 @@ namespace uniset
{
ComediInterface
::
SubdevType
st
=
ComediInterface
::
str2type
(
stype
.
c_str
());
if
(
!
stype
.
empty
()
&&
st
==
ComediInterface
::
Unknown
)
if
(
st
==
ComediInterface
::
Unknown
)
{
ostringstream
err
;
err
<<
"Unknown subdev type '"
<<
stype
<<
" for "
<<
t1
.
str
();
throw
SystemError
(
err
.
str
());
}
if
(
!
stype
.
empty
()
)
{
ioinfo
<<
myname
<<
"(init): card"
<<
i
<<
" subdev"
<<
s
<<
" set type "
<<
stype
<<
endl
;
ioinfo
<<
myname
<<
"(init): card"
<<
i
<<
" subdev"
<<
s
<<
" set type "
<<
stype
<<
endl
;
cards
[
i
]
->
configureSubdev
(
s
-
1
,
st
);
}
cards
[
i
]
->
configureSubdev
(
s
-
1
,
st
);
}
}
}
...
...
@@ -469,15 +466,15 @@ namespace uniset
ptHeartBeat
.
reset
();
}
}
catch
(
const
uniset
::
Exception
&
ex
)
{
iolog3
<<
myname
<<
"(execute): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
iolog3
<<
myname
<<
"(execute): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
iolog3
<<
myname
<<
"(execute): "
<<
ex
<<
endl
;
}
catch
(...)
{
iolog3
<<
myname
<<
"(execute): catch ..."
<<
endl
;
...
...
@@ -733,15 +730,15 @@ namespace uniset
{
iolog3
<<
myname
<<
"(iopoll): (BadRange)..."
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
iolog3
<<
myname
<<
"(iopoll): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
iolog3
<<
myname
<<
"(iopoll): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
iolog3
<<
myname
<<
"(iopoll): "
<<
ex
<<
endl
;
}
}
// --------------------------------------------------------------------------------
void
IOControl
::
readConfiguration
()
...
...
extensions/IOControl/IOControl.h
View file @
562e8cd4
...
...
@@ -201,6 +201,14 @@ namespace uniset
delete
(
*
this
)[
i
];
}
inline
ComediInterface
*
getCard
(
int
ncard
)
const
{
if
(
ncard
>
0
&&
ncard
<
size
()
)
return
(
*
this
)[
ncard
];
return
nullptr
;
}
inline
ComediInterface
*
getCard
(
size_t
ncard
)
const
{
if
(
ncard
<
size
()
)
...
...
@@ -253,21 +261,11 @@ namespace uniset
IOInfo
(
IOInfo
&&
r
)
=
default
;
IOInfo
&
operator
=
(
IOInfo
&&
r
)
=
default
;
IOInfo
()
:
subdev
(
DefaultSubdev
),
channel
(
DefaultChannel
),
ncard
(
-
1
),
aref
(
0
),
range
(
0
),
lamp
(
false
),
no_testlamp
(
false
),
enable_testmode
(
false
),
disable_testmode
(
false
)
{}
IOInfo
(){}
int
subdev
;
/*!< (UNIO) подустройство (см. comedi_test для конкретной карты в/в) */
int
channel
;
/*!< (UNIO) канал [0...23] */
int
ncard
;
/*!< номер карты [1|2]. -1 - не определена. */
int
subdev
=
{
DefaultSubdev
};
/*!< (UNIO) подустройство (см. comedi_test для конкретной карты в/в) */
int
channel
=
{
DefaultChannel
};
/*!< (UNIO) канал [0...23] */
int
ncard
=
{
DefaultCard
}
;
/*!< номер карты [1|2]. -1 - не определена. */
/*! Вид подключения
0 - analog ref = analog ground
...
...
@@ -275,9 +273,9 @@ namespace uniset
2 - analog ref = differential
3 - analog ref = other (undefined)
*/
int
aref
;
int
aref
=
{
0
}
;
int
adelay
;
/*! Задержка на чтение аналоговых входов с мультиплексированием ( в мкс ) */
int
adelay
=
{
0
}
;
/*! Задержка на чтение аналоговых входов с мультиплексированием ( в мкс ) */
/*! Измерительный диапазон
0 - -10В - 10В
...
...
@@ -285,12 +283,12 @@ namespace uniset
2 - -2.5В - 2.5В
3 - -1.25В - 1.25В
*/
int
range
;
int
range
=
{
0
}
;
bool
lamp
;
/*!< признак, что данный выход является лампочкой (или сигнализатором) */
bool
no_testlamp
;
/*!< флаг исключения из 'проверки ламп' */
bool
enable_testmode
;
/*!< флаг для режима тестирования tmConfigEnable */
bool
disable_testmode
;
/*!< флаг для режима тестирования tmConfigDisable */
bool
lamp
=
{
false
}
;
/*!< признак, что данный выход является лампочкой (или сигнализатором) */
bool
no_testlamp
=
{
false
}
;
/*!< флаг исключения из 'проверки ламп' */
bool
enable_testmode
=
{
false
}
;
/*!< флаг для режима тестирования tmConfigEnable */
bool
disable_testmode
=
{
false
}
;
/*!< флаг для режима тестирования tmConfigDisable */
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
IOInfo
&
inf
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
std
::
shared_ptr
<
IOInfo
>&
inf
);
...
...
extensions/IOControl/iotest.cc
View file @
562e8cd4
...
...
@@ -302,7 +302,7 @@ int main(int argc, char* argv[])
}
}
if
(
!
blink
)
if
(
blink
==
0
)
// -V776
break
;
val
=
val
?
0
:
1
;
...
...
extensions/ModbusMaster/MBExchange.cc
View file @
562e8cd4
...
...
@@ -30,22 +30,6 @@ namespace uniset
using
namespace
std
;
using
namespace
uniset
::
extensions
;
// -----------------------------------------------------------------------------
// вспомогательная структура для предотвращения утечки памяти
struct
DataGuard
{
DataGuard
(
size_t
sz
)
{
data
=
new
ModbusRTU
::
ModbusData
[
sz
];
}
~
DataGuard
()
{
delete
[]
data
;
}
ModbusRTU
::
ModbusData
*
data
;
};
// -----------------------------------------------------------------------------
MBExchange
::
MBExchange
(
uniset
::
ObjectId
objId
,
uniset
::
ObjectId
shmId
,
const
std
::
shared_ptr
<
SharedMemory
>&
_ic
,
const
std
::
string
&
prefix
)
:
UniSetObject
(
objId
),
...
...
@@ -793,7 +777,7 @@ namespace uniset
case
ModbusRTU
:
:
fnReadInputStatus
:
{
ModbusRTU
::
ReadInputStatusRetMessage
ret
=
mb
->
read02
(
dev
->
mbaddr
,
p
->
mbreg
,
q_count
);
DataGuard
d
(
q_count
);
ModbusRTU
::
DataGuard
d
(
q_count
);
size_t
m
=
0
;
for
(
size_t
i
=
0
;
i
<
ret
.
bcnt
;
i
++
)
...
...
@@ -804,14 +788,14 @@ namespace uniset
d
.
data
[
m
]
=
b
[
k
];
}
p
->
initOK
=
initSMValue
(
d
.
data
,
q_count
,
&
(
p
->
p
));
p
->
initOK
=
initSMValue
(
d
.
data
,
d
.
len
,
&
(
p
->
p
));
}
break
;
case
ModbusRTU
:
:
fnReadCoilStatus
:
{
ModbusRTU
::
ReadCoilRetMessage
ret
=
mb
->
read01
(
dev
->
mbaddr
,
p
->
mbreg
,
q_count
);
DataGuard
d
(
q_count
);
ModbusRTU
::
DataGuard
d
(
q_count
);
size_t
m
=
0
;
for
(
size_t
i
=
0
;
i
<
ret
.
bcnt
;
i
++
)
...
...
@@ -822,7 +806,7 @@ namespace uniset
d
.
data
[
m
]
=
b
[
k
];
}
p
->
initOK
=
initSMValue
(
d
.
data
,
q_count
,
&
(
p
->
p
));
p
->
initOK
=
initSMValue
(
d
.
data
,
d
.
len
,
&
(
p
->
p
));
}
break
;
...
...
@@ -930,7 +914,7 @@ namespace uniset
else
if
(
p
->
vType
==
VTypes
::
vtF4
)
{
VTypes
::
F4
f
(
data
,
VTypes
::
F4
::
wsize
());
IOBase
::
processingF
asAI
(
p
,
(
float
)
f
,
shm
,
true
);
IOBase
::
processingF
64asAI
(
p
,
(
double
)
f
,
shm
,
true
);
}
else
if
(
p
->
vType
==
VTypes
::
vtI2
)
{
...
...
@@ -967,15 +951,15 @@ namespace uniset
{
mblog3
<<
myname
<<
"(initSMValue): (BadRange)..."
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(initSMValue): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
mblog3
<<
myname
<<
"(initSMValue): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(initSMValue): "
<<
ex
<<
endl
;
}
catch
(...)
{
mblog3
<<
myname
<<
"(initSMValue): catch ..."
<<
endl
;
...
...
@@ -1227,15 +1211,15 @@ namespace uniset
{
mblog3
<<
myname
<<
"(updateSM): (BadRange)..."
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
mblog3
<<
myname
<<
"(updateSM): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
}
catch
(
std
::
exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateSM): check modeSensor: "
<<
ex
.
what
()
<<
endl
;
...
...
@@ -1265,15 +1249,15 @@ namespace uniset
{
mblog3
<<
myname
<<
"(updateSM): (BadRange)..."
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
mblog3
<<
myname
<<
"(updateSM): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
}
catch
(
std
::
exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateSM): check safemodeSensor: "
<<
ex
.
what
()
<<
endl
;
...
...
@@ -1313,15 +1297,15 @@ namespace uniset
{
mblog3
<<
myname
<<
"(updateSM): (BadRange)..."
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
mblog3
<<
myname
<<
"(updateSM): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateSM): catch ..."
<<
endl
;
...
...
@@ -1596,7 +1580,7 @@ namespace uniset
if
(
p
->
vType
==
VTypes
::
vtF2
)
{
VTypes
::
F2
f1
(
d
.
data
,
VTypes
::
F2
::
wsize
()
);
VTypes
::
F2
f1
(
d
.
data
,
d
.
len
);
f
=
(
float
)
f1
;
}
else
if
(
p
->
vType
==
VTypes
::
vtF2r
)
...
...
@@ -1640,9 +1624,9 @@ namespace uniset
for
(
size_t
k
=
0
;
k
<
VTypes
::
F4
::
wsize
();
k
++
,
i
++
)
d
.
data
[
k
]
=
i
->
second
->
mbval
;
VTypes
::
F4
f
(
d
.
data
,
VTypes
::
F4
::
wsize
()
);
VTypes
::
F4
f
(
d
.
data
,
d
.
len
);
IOBase
::
processingF
asAI
(
p
,
(
float
)
f
,
shm
,
force
);
IOBase
::
processingF
64asAI
(
p
,
(
double
)
f
,
shm
,
force
);
}
}
}
...
...
@@ -1691,12 +1675,12 @@ namespace uniset
if
(
p
->
vType
==
VTypes
::
vtI2
)
{
VTypes
::
I2
i2
(
d
.
data
,
VTypes
::
I2
::
wsize
()
);
VTypes
::
I2
i2
(
d
.
data
,
d
.
len
);
v
=
(
int
)
i2
;
}
else
if
(
p
->
vType
==
VTypes
::
vtI2r
)
{
VTypes
::
I2r
i2
(
d
.
data
,
VTypes
::
I2
::
wsize
()
);
VTypes
::
I2r
i2
(
d
.
data
,
d
.
len
);
v
=
(
int
)
i2
;
}
...
...
@@ -1704,7 +1688,7 @@ namespace uniset
}
}
}
else
if
(
p
->
vType
==
VTypes
::
vtU2
||
p
->
vType
==
VTypes
::
vtU2r
)
else
if
(
p
->
vType
==
VTypes
::
vtU2
||
p
->
vType
==
VTypes
::
vtU2r
)
// -V560
{
auto
i
=
p
->
reg
->
rit
;
...
...
@@ -1750,12 +1734,12 @@ namespace uniset
if
(
p
->
vType
==
VTypes
::
vtU2
)
{
VTypes
::
U2
u2
(
d
.
data
,
VTypes
::
U2
::
wsize
()
);
VTypes
::
U2
u2
(
d
.
data
,
d
.
len
);
v
=
(
uint32_t
)
u2
;
}
else
if
(
p
->
vType
==
VTypes
::
vtU2r
)
{
VTypes
::
U2r
u2
(
d
.
data
,
VTypes
::
U2
::
wsize
()
);
VTypes
::
U2r
u2
(
d
.
data
,
d
.
len
);
v
=
(
uint32_t
)
u2
;
}
...
...
@@ -1778,15 +1762,15 @@ namespace uniset
{
mblog3
<<
myname
<<
"(updateRSProperty): (BadRange)..."
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateRSProperty): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
mblog3
<<
myname
<<
"(updateRSProperty): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateRSProperty): "
<<
ex
<<
endl
;
}
catch
(...)
{
mblog3
<<
myname
<<
"(updateRSProperty): catch ..."
<<
endl
;
...
...
@@ -1886,7 +1870,7 @@ namespace uniset
for
(
size_t
k
=
0
;
k
<
MTR
::
T3
::
wsize
();
k
++
,
i
++
)
d
.
data
[
k
]
=
i
->
second
->
mbval
;
MTR
::
T3
t
(
d
.
data
,
MTR
::
T3
::
wsize
()
);
MTR
::
T3
t
(
d
.
data
,
d
.
len
);
IOBase
::
processingAsAI
(
&
(
*
it
),
(
long
)
t
,
shm
,
force
);
}
}
...
...
@@ -1942,7 +1926,7 @@ namespace uniset
for
(
size_t
k
=
0
;
k
<
MTR
::
T5
::
wsize
();
k
++
,
i
++
)
d
.
data
[
k
]
=
i
->
second
->
mbval
;
MTR
::
T5
t
(
d
.
data
,
MTR
::
T5
::
wsize
()
);
MTR
::
T5
t
(
d
.
data
,
d
.
len
);
IOBase
::
processingFasAI
(
&
(
*
it
),
(
float
)
t
.
val
,
shm
,
force
);
}
...
...
@@ -1977,7 +1961,7 @@ namespace uniset
for
(
size_t
k
=
0
;
k
<
MTR
::
T6
::
wsize
();
k
++
,
i
++
)
d
.
data
[
k
]
=
i
->
second
->
mbval
;
MTR
::
T6
t
(
d
.
data
,
MTR
::
T6
::
wsize
()
);
MTR
::
T6
t
(
d
.
data
,
d
.
len
);
IOBase
::
processingFasAI
(
&
(
*
it
),
(
float
)
t
.
val
,
shm
,
force
);
}
...
...
@@ -2011,7 +1995,7 @@ namespace uniset
for
(
size_t
k
=
0
;
k
<
MTR
::
T7
::
wsize
();
k
++
,
i
++
)
d
.
data
[
k
]
=
i
->
second
->
mbval
;
MTR
::
T7
t
(
d
.
data
,
MTR
::
T7
::
wsize
()
);
MTR
::
T7
t
(
d
.
data
,
d
.
len
);
IOBase
::
processingFasAI
(
&
(
*
it
),
(
float
)
t
.
val
,
shm
,
force
);
}
...
...
@@ -2098,7 +2082,7 @@ namespace uniset
for
(
size_t
k
=
0
;
k
<
MTR
::
F1
::
wsize
();
k
++
,
i
++
)
d
.
data
[
k
]
=
i
->
second
->
mbval
;
MTR
::
F1
t
(
d
.
data
,
MTR
::
F1
::
wsize
()
);
MTR
::
F1
t
(
d
.
data
,
d
.
len
);
IOBase
::
processingFasAI
(
&
(
*
it
),
(
float
)
t
,
shm
,
force
);
}
}
...
...
@@ -2118,15 +2102,15 @@ namespace uniset
{
mblog3
<<
myname
<<
"(updateMTR): (BadRange)..."
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateMTR): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
mblog3
<<
myname
<<
"(updateMTR): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateMTR): "
<<
ex
<<
endl
;
}
catch
(...)
{
mblog3
<<
myname
<<
"(updateMTR): catch ..."
<<
endl
;
...
...
@@ -2185,15 +2169,15 @@ namespace uniset
{
mblog3
<<
myname
<<
"(updateRTU188): (BadRange)..."
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateRTU188): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
mblog3
<<
myname
<<
"(updateRTU188): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mblog3
<<
myname
<<
"(updateRTU188): "
<<
ex
<<
endl
;
}
catch
(...)
{
mblog3
<<
myname
<<
"(updateRTU188): catch ..."
<<
endl
;
...
...
extensions/ModbusMaster/vtconv.cc
View file @
562e8cd4
...
...
@@ -118,7 +118,7 @@ int main( int argc, const char** argv )
<<
" v[1]="
<<
v
[
1
]
<<
" v[2]="
<<
v
[
2
]
<<
" v[3]="
<<
v
[
3
]
<<
" --> (float
) "
<<
(
float
)
f
<<
endl
;
<<
" --> (float
64) "
<<
(
double
)
f
<<
endl
;
}
else
if
(
!
strcmp
(
type
,
"I2"
)
)
{
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
562e8cd4
...
...
@@ -1933,13 +1933,12 @@ namespace uniset
return
ModbusRTU
::
erInvalidFormat
;
}
ModbusRTU
::
ModbusData
*
d
=
new
ModbusRTU
::
ModbusData
[
VTypes
::
I2
::
wsize
()]
;
ModbusRTU
::
DataGuard
d
(
VTypes
::
I2
::
wsize
())
;
for
(
size_t
k
=
0
;
k
<
VTypes
::
I2
::
wsize
();
k
++
,
i
++
)
d
[
k
]
=
dat
[
i
];
d
.
data
[
k
]
=
dat
[
i
];
VTypes
::
I2
i2
(
d
,
VTypes
::
I2
::
wsize
());
delete
[]
d
;
VTypes
::
I2
i2
(
d
.
data
,
d
.
len
);
IOBase
::
processingAsAI
(
p
,
(
long
)
i2
,
shm
,
force
);
}
else
if
(
p
->
vtype
==
VTypes
::
vtI2r
)
...
...
@@ -1950,13 +1949,12 @@ namespace uniset
return
ModbusRTU
::
erInvalidFormat
;
}
ModbusRTU
::
ModbusData
*
d
=
new
ModbusRTU
::
ModbusData
[
VTypes
::
I2r
::
wsize
()]
;
ModbusRTU
::
DataGuard
d
(
VTypes
::
I2r
::
wsize
())
;
for
(
size_t
k
=
0
;
k
<
VTypes
::
I2r
::
wsize
();
k
++
,
i
++
)
d
[
k
]
=
dat
[
i
];
d
.
data
[
k
]
=
dat
[
i
];
VTypes
::
I2r
i2r
(
d
,
VTypes
::
I2r
::
wsize
());
delete
[]
d
;
VTypes
::
I2r
i2r
(
d
.
data
,
d
.
len
);
IOBase
::
processingAsAI
(
p
,
(
long
)
i2r
,
shm
,
force
);
}
else
if
(
p
->
vtype
==
VTypes
::
vtU2
)
...
...
@@ -1967,13 +1965,12 @@ namespace uniset
return
ModbusRTU
::
erInvalidFormat
;
}
ModbusRTU
::
ModbusData
*
d
=
new
ModbusRTU
::
ModbusData
[
VTypes
::
U2
::
wsize
()]
;
ModbusRTU
::
DataGuard
d
(
VTypes
::
U2
::
wsize
())
;
for
(
size_t
k
=
0
;
k
<
VTypes
::
U2
::
wsize
();
k
++
,
i
++
)
d
[
k
]
=
dat
[
i
];
d
.
data
[
k
]
=
dat
[
i
];
VTypes
::
U2
u2
(
d
,
VTypes
::
U2
::
wsize
());
delete
[]
d
;
VTypes
::
U2
u2
(
d
.
data
,
d
.
len
);
IOBase
::
processingAsAI
(
p
,
(
unsigned
long
)
u2
,
shm
,
force
);
}
else
if
(
p
->
vtype
==
VTypes
::
vtU2r
)
...
...
@@ -1984,13 +1981,12 @@ namespace uniset
return
ModbusRTU
::
erInvalidFormat
;
}
ModbusRTU
::
ModbusData
*
d
=
new
ModbusRTU
::
ModbusData
[
VTypes
::
U2r
::
wsize
()]
;
ModbusRTU
::
DataGuard
d
(
VTypes
::
U2r
::
wsize
())
;
for
(
size_t
k
=
0
;
k
<
VTypes
::
U2r
::
wsize
();
k
++
,
i
++
)
d
[
k
]
=
dat
[
i
];
d
.
data
[
k
]
=
dat
[
i
];
VTypes
::
U2r
u2r
(
d
,
VTypes
::
U2r
::
wsize
());
delete
[]
d
;
VTypes
::
U2r
u2r
(
d
.
data
,
d
.
len
);
IOBase
::
processingAsAI
(
p
,
(
unsigned
long
)
u2r
,
shm
,
force
);
}
else
if
(
p
->
vtype
==
VTypes
::
vtF2
)
...
...
@@ -2001,14 +1997,12 @@ namespace uniset
return
ModbusRTU
::
erInvalidFormat
;
}
ModbusRTU
::
ModbusData
*
d
=
new
ModbusRTU
::
ModbusData
[
VTypes
::
F2
::
wsize
()]
;
ModbusRTU
::
DataGuard
d
(
VTypes
::
F2
::
wsize
())
;
for
(
size_t
k
=
0
;
k
<
VTypes
::
F2
::
wsize
();
k
++
,
i
++
)
d
[
k
]
=
dat
[
i
];
VTypes
::
F2
f2
(
d
,
VTypes
::
F2
::
wsize
());
delete
[]
d
;
d
.
data
[
k
]
=
dat
[
i
];
VTypes
::
F2
f2
(
d
.
data
,
d
.
len
);
IOBase
::
processingFasAI
(
p
,
(
float
)
f2
,
shm
,
force
);
}
else
if
(
p
->
vtype
==
VTypes
::
vtF2r
)
...
...
@@ -2019,13 +2013,11 @@ namespace uniset
return
ModbusRTU
::
erInvalidFormat
;
}
ModbusRTU
::
ModbusData
*
d
=
new
ModbusRTU
::
ModbusData
[
VTypes
::
F2r
::
wsize
()];
ModbusRTU
::
DataGuard
d
(
VTypes
::
F2r
::
wsize
());
for
(
size_t
k
=
0
;
k
<
VTypes
::
F2r
::
wsize
();
k
++
,
i
++
)
d
[
k
]
=
dat
[
i
];
d
.
data
[
k
]
=
dat
[
i
];
VTypes
::
F2r
f2r
(
d
,
VTypes
::
F2r
::
wsize
());
delete
[]
d
;
VTypes
::
F2r
f2r
(
d
.
data
,
d
.
len
);
IOBase
::
processingFasAI
(
p
,
(
float
)
f2r
,
shm
,
force
);
}
else
if
(
p
->
vtype
==
VTypes
::
vtF4
)
...
...
@@ -2036,15 +2028,13 @@ namespace uniset
return
ModbusRTU
::
erInvalidFormat
;
}
ModbusRTU
::
ModbusData
*
d
=
new
ModbusRTU
::
ModbusData
[
VTypes
::
F4
::
wsize
()]
;
ModbusRTU
::
DataGuard
d
(
VTypes
::
F4
::
wsize
())
;
for
(
size_t
k
=
0
;
k
<
VTypes
::
F4
::
wsize
();
k
++
,
i
++
)
d
[
k
]
=
dat
[
i
];
VTypes
::
F4
f4
(
d
,
VTypes
::
F4
::
wsize
());
delete
[]
d
;
d
.
data
[
k
]
=
dat
[
i
];
IOBase
::
processingFasAI
(
p
,
(
float
)
f4
,
shm
,
force
);
VTypes
::
F4
f4
(
d
.
data
,
d
.
len
);
IOBase
::
processingFasAI
(
p
,
(
double
)
f4
,
shm
,
force
);
}
else
if
(
p
->
vtype
==
VTypes
::
vtByte
)
{
...
...
@@ -2078,17 +2068,17 @@ namespace uniset
mbwarn
<<
myname
<<
"(real_write_prop): "
<<
ex
<<
endl
;
return
ModbusRTU
::
erBadDataValue
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
smPingOK
)
mbcrit
<<
myname
<<
"(real_write_prop): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
if
(
smPingOK
)
mbcrit
<<
myname
<<
"(real_write_prop): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
smPingOK
)
mbcrit
<<
myname
<<
"(real_write_prop): "
<<
ex
<<
endl
;
}
catch
(...)
{
if
(
smPingOK
)
...
...
@@ -2456,17 +2446,17 @@ namespace uniset
mbwarn
<<
myname
<<
"(real_read_prop): "
<<
ex
<<
endl
;
return
ModbusRTU
::
erBadDataValue
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
smPingOK
)
mbcrit
<<
myname
<<
"(real_read_prop): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
if
(
smPingOK
)
mbcrit
<<
myname
<<
"(real_read_prop): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
smPingOK
)
mbcrit
<<
myname
<<
"(real_read_prop): "
<<
ex
<<
endl
;
}
catch
(...)
{
if
(
smPingOK
)
...
...
@@ -2608,17 +2598,17 @@ namespace uniset
mbwarn
<<
myname
<<
"(readCoilStatus): "
<<
ex
<<
endl
;
return
ModbusRTU
::
erBadDataAddress
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
smPingOK
)
mbcrit
<<
myname
<<
"(readCoilStatus): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
if
(
smPingOK
)
mbcrit
<<
myname
<<
"(readCoilStatus): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
smPingOK
)
mbcrit
<<
myname
<<
"(readCoilStatus): "
<<
ex
<<
endl
;
}
catch
(...)
{
if
(
smPingOK
)
...
...
@@ -2687,17 +2677,17 @@ namespace uniset
mbwarn
<<
myname
<<
"(readInputStatus): "
<<
ex
<<
endl
;
return
ModbusRTU
::
erBadDataAddress
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
smPingOK
)
mbcrit
<<
myname
<<
"(readInputStatus): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
if
(
smPingOK
)
mbcrit
<<
myname
<<
"(readInputStatus): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
smPingOK
)
mbcrit
<<
myname
<<
"(readInputStatus): "
<<
ex
<<
endl
;
}
catch
(...)
{
if
(
smPingOK
)
...
...
extensions/ModbusSlave/start_tcp_fg.sh
View file @
562e8cd4
...
...
@@ -6,6 +6,7 @@ uniset2-start.sh -f ./uniset2-mbslave --confile test.xml \
--mbs-type
TCP
--mbs-inet-addr
127.0.0.1
--mbs-inet-port
2048
--mbs-reg-from-id
1
--mbs-my-addr
0x01
\
--mbs-askcount-id
SVU_AskCount_AS
--mbs-respond-id
RespondRTU_S
--mbs-respond-invert
1
--ulog-add-levels
system
\
--mbs-log-add-levels
any
$*
# --mbs-exchangelog-add-levels any $*
# --mbs-force 1
#--mbs-reg-from-id 1 \
#--mbs-filter-field CAN2sender --mbs-filter-value SYSTSNode \
\ No newline at end of file
extensions/ModbusSlave/tests/mbslave_perf_test.cc
View file @
562e8cd4
...
...
@@ -54,14 +54,14 @@ int main( int argc, const char** argv )
act
->
run
(
false
);
return
0
;
}
catch
(
Exception
&
ex
)
{
cerr
<<
"(mbslave_perf_test): "
<<
ex
<<
endl
;
}
catch
(
CORBA
::
SystemException
&
ex
)
{
cerr
<<
"(mbslave_perf_test): "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
Exception
&
ex
)
{
cerr
<<
"(mbslave_perf_test): "
<<
ex
<<
endl
;
}
catch
(...)
{
cerr
<<
"(mbslave_perf_test): catch(...)"
<<
endl
;
...
...
extensions/ModbusSlave/tests/tests_with_sm.sh
View file @
562e8cd4
...
...
@@ -11,6 +11,6 @@ cd -
./uniset2-start.sh
-f
./tests-with-sm
$*
--
--confile
mbslave-test-configure.xml
--e-startup-pause
10
\
--mbs-name
MBSlave1
--mbs-type
TCP
--mbs-inet-addr
127.0.0.1
--mbs-inet-port
20048
\
--mbs-askcount-id
SVU_AskCount_AS
--mbs-respond-id
RespondRTU_S
--mbs-respond-invert
1
\
--mbs-filter-field
mbs
--mbs-filter-value
1
--mbs-initPause
100
#--mbs-log-add-levels any
--mbs-filter-field
mbs
--mbs-filter-value
1
--mbs-initPause
100
#
--mbs-log-add-levels any
\ No newline at end of file
extensions/SharedMemory/SharedMemory.cc
View file @
562e8cd4
...
...
@@ -996,14 +996,14 @@ namespace uniset
#endif
}
catch
(
const
uniset
::
Exception
&
ex
)
{
smcrit
<<
myname
<<
"(initFromSM): "
<<
ex
<<
endl
;
}
catch
(
const
IOController_i
::
NameNotFound
&
ex
)
{
smcrit
<<
myname
<<
"(initFromSM): not found sensor id="
<<
ii
.
si
.
id
<<
"'"
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
smcrit
<<
myname
<<
"(initFromSM): "
<<
ex
<<
endl
;
}
}
return
true
;
...
...
extensions/UNetUDP/UDPPacket.h
View file @
562e8cd4
...
...
@@ -95,7 +95,7 @@ namespace uniset
struct
UDPPacket
{
UDPPacket
()
noexcept
:
len
(
0
)
{}
UDPPacket
()
noexcept
:
len
(
0
)
{}
// -V730
size_t
len
;
uint8_t
data
[
sizeof
(
UDPHeader
)
+
MaxDCount
*
sizeof
(
long
)
+
MaxDDataCount
+
MaxACount
*
sizeof
(
UDPAData
)
];
...
...
extensions/UNetUDP/UNetSender.cc
View file @
562e8cd4
...
...
@@ -471,7 +471,7 @@ namespace uniset
return
false
;
}
}
else
if
(
p
.
iotype
==
UniversalIO
::
AI
||
p
.
iotype
==
UniversalIO
::
AO
)
else
if
(
p
.
iotype
==
UniversalIO
::
AI
||
p
.
iotype
==
UniversalIO
::
AO
)
// -V560
{
size_t
anum
=
packs_anum
[
priority
];
...
...
extensions/UNetUDP/tests/test_unetudp.cc
View file @
562e8cd4
...
...
@@ -70,7 +70,7 @@ static UniSetUDP::UDPMessage receive( unsigned int pnum = 0, timeout_t tout = 20
size_t
ret
=
udp_r
->
receiveBytes
(
&
(
buf
.
data
),
sizeof
(
buf
.
data
)
);
size_t
sz
=
UniSetUDP
::
UDPMessage
::
getMessage
(
pack
,
buf
);
if
(
sz
==
0
||
pnum
==
0
||
(
pnum
>
0
&&
pack
.
num
>=
pnum
)
)
if
(
sz
==
0
||
pnum
==
0
||
(
pnum
>
0
&&
pack
.
num
>=
pnum
)
)
// -V560
break
;
REQUIRE
(
pack
.
magic
==
UniSetUDP
::
UNETUDP_MAGICNUM
);
...
...
extensions/UNetUDP/tests/urecv_perf_test.cc
View file @
562e8cd4
...
...
@@ -94,7 +94,7 @@ static void run_senders( size_t max, const std::string& s_host, size_t count = 5
size_t
nc
=
1
;
while
(
nc
)
while
(
nc
)
// -V654
{
mypack
.
num
=
packetnum
++
;
...
...
extensions/UniNetwork/UniExchange.cc
View file @
562e8cd4
...
...
@@ -115,7 +115,7 @@ UniExchange::UniExchange(uniset::ObjectId id, uniset::ObjectId shmID,
node
=
conf
->
getNodeID
(
n1
);
}
if
(
id
==
DefaultObjectId
)
if
(
node
==
DefaultObjectId
)
throw
SystemError
(
"(UniExchange): Uknown ID for node="
+
n1
);
NetNodeInfo
ni
;
...
...
extensions/include/IOBase.h
View file @
562e8cd4
...
...
@@ -35,6 +35,7 @@ namespace uniset
{
static
const
int
DefaultSubdev
=
-
1
;
static
const
int
DefaultChannel
=
-
1
;
static
const
int
DefaultCard
=
-
1
;
// т.к. IOBase содержит rwmutex с запрещённым конструктором копирования
// приходится здесь тоже объявлять разрешенными только операции "перемещения"
...
...
@@ -175,11 +176,13 @@ namespace uniset
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
IOBase
&
inf
);
static
void
processingF64asAI
(
IOBase
*
it
,
double
new_val
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
);
static
void
processingFasAI
(
IOBase
*
it
,
float
new_val
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
);
static
void
processingAsAI
(
IOBase
*
it
,
long
new_val
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
);
static
void
processingAsDI
(
IOBase
*
it
,
bool
new_set
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
);
static
long
processingAsAO
(
IOBase
*
it
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
);
static
float
processingFasAO
(
IOBase
*
it
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
);
static
double
processingF64asAO
(
IOBase
*
it
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
);
static
bool
processingAsDO
(
IOBase
*
it
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
);
static
void
processingThreshold
(
IOBase
*
it
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
);
...
...
extensions/include/UObject_SK.h
View file @
562e8cd4
...
...
@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2018-1
0-16
+03:00
// generate timestamp: 2018-1
2-25
+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
...
...
extensions/include/VTypes.h
View file @
562e8cd4
...
...
@@ -149,7 +149,7 @@ namespace uniset
typedef
union
{
uint16_t
v
[
f4Size
];
float
val
;
//
double
val
;
//
}
F4mem
;
// ------------------------------------------
// конструкторы на разные случаи...
...
...
@@ -158,7 +158,7 @@ namespace uniset
memset
(
raw
.
v
,
0
,
sizeof
(
raw
.
v
));
}
F4
(
const
float
&
f
)
noexcept
F4
(
const
double
&
f
)
noexcept
{
memset
(
raw
.
v
,
0
,
sizeof
(
raw
.
v
));
raw
.
val
=
f
;
...
...
@@ -182,7 +182,7 @@ namespace uniset
return
vtF4
;
}
// ------------------------------------------
operator
float
()
operator
double
()
{
return
raw
.
val
;
}
...
...
extensions/lib/IOBase.cc
View file @
562e8cd4
...
...
@@ -270,7 +270,72 @@ namespace uniset
}
}
// -----------------------------------------------------------------------------
void
IOBase
::
processingFasAI
(
IOBase
*
it
,
float
fval
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
)
void
IOBase
::
processingFasAI
(
IOBase
*
it
,
float
fval
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
)
{
long
val
=
lroundf
(
fval
);
if
(
it
->
stype
==
UniversalIO
::
DI
||
it
->
stype
==
UniversalIO
::
DO
)
val
=
(
fval
!=
0
?
1
:
0
);
else
{
if
(
it
->
rawdata
)
{
val
=
0
;
memcpy
(
&
val
,
&
fval
,
std
::
min
(
sizeof
(
val
),
sizeof
(
fval
)));
}
else
if
(
it
->
cal
.
precision
!=
0
&&
!
it
->
noprecision
)
val
=
lroundf
(
fval
*
pow
(
10.0
,
it
->
cal
.
precision
)
);
// проверка на обрыв
if
(
it
->
check_channel_break
(
val
)
)
{
uniset_rwmutex_wrlock
lock
(
it
->
val_lock
);
it
->
value
=
ChannelBreakValue
;
shm
->
localSetUndefinedState
(
it
->
ioit
,
true
,
it
->
si
.
id
);
return
;
}
// проверка зависимости
if
(
!
it
->
check_depend
(
shm
)
)
val
=
it
->
d_off_value
;
else
{
// Читаем с использованием фильтра...
if
(
!
it
->
nofilter
)
{
if
(
it
->
df
.
size
()
>
1
)
it
->
df
.
add
(
val
);
val
=
it
->
df
.
filterRC
(
val
);
}
if
(
!
it
->
rawdata
)
{
IOController_i
::
CalibrateInfo
*
cal
(
&
(
it
->
cal
)
);
if
(
cal
->
maxRaw
!=
cal
->
minRaw
)
// задана обычная калибровка
val
=
uniset
::
lcalibrate
(
val
,
cal
->
minRaw
,
cal
->
maxRaw
,
cal
->
minCal
,
cal
->
maxCal
,
it
->
calcrop
);
}
}
}
{
uniset_rwmutex_wrlock
lock
(
it
->
val_lock
);
// если предыдущее значение "обрыв",
// то сбрасываем признак
if
(
it
->
value
==
ChannelBreakValue
)
shm
->
localSetUndefinedState
(
it
->
ioit
,
false
,
it
->
si
.
id
);
if
(
force
||
it
->
value
!=
val
)
{
shm
->
localSetValue
(
it
->
ioit
,
it
->
si
.
id
,
val
,
shm
->
ID
()
);
it
->
value
=
val
;
}
}
}
// -----------------------------------------------------------------------------
void
IOBase
::
processingF64asAI
(
IOBase
*
it
,
double
fval
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
)
{
long
val
=
lroundf
(
fval
);
...
...
@@ -398,9 +463,9 @@ namespace uniset
if
(
!
it
->
noprecision
&&
it
->
cal
.
precision
!=
0
)
val
=
lroundf
(
(
float
)
it
->
value
/
pow
(
10.0
,
it
->
cal
.
precision
)
);
IOController_i
::
CalibrateInfo
*
cal
(
&
(
it
->
cal
)
);
IOController_i
::
CalibrateInfo
*
cal
=
&
(
it
->
cal
);
if
(
cal
&&
cal
->
maxRaw
!=
cal
->
minRaw
)
// задана калибровка
if
(
cal
->
maxRaw
!=
cal
->
minRaw
)
// задана калибровка
{
// Калибруем в обратную сторону!!!
val
=
uniset
::
lcalibrate
(
val
,
cal
->
minCal
,
cal
->
maxCal
,
cal
->
minRaw
,
cal
->
maxRaw
,
it
->
calcrop
);
...
...
@@ -470,6 +535,49 @@ namespace uniset
return
fval
;
}
// -----------------------------------------------------------------------------
double
IOBase
::
processingF64asAO
(
IOBase
*
it
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
)
{
// проверка зависимости
if
(
!
it
->
check_depend
(
shm
)
)
return
(
double
)
it
->
d_off_value
;
uniset_rwmutex_rlock
lock
(
it
->
val_lock
);
long
val
=
it
->
value
;
if
(
force
)
{
val
=
shm
->
localGetValue
(
it
->
ioit
,
it
->
si
.
id
);
it
->
value
=
val
;
// обновим на всякий
}
if
(
it
->
rawdata
)
{
double
fval
=
0
;
memcpy
(
&
fval
,
&
val
,
std
::
min
(
sizeof
(
val
),
sizeof
(
fval
)));
return
fval
;
}
double
dval
=
val
;
if
(
it
->
stype
==
UniversalIO
::
AO
||
it
->
stype
==
UniversalIO
::
AI
)
{
IOController_i
::
CalibrateInfo
*
cal
(
&
(
it
->
cal
)
);
if
(
cal
->
maxRaw
!=
cal
->
minRaw
)
// задана калибровка
{
// Калибруем в обратную сторону!!!
dval
=
uniset
::
dcalibrate
(
dval
,
cal
->
minCal
,
cal
->
maxCal
,
cal
->
minRaw
,
cal
->
maxRaw
,
it
->
calcrop
);
}
if
(
!
it
->
noprecision
&&
it
->
cal
.
precision
!=
0
)
return
(
dval
/
pow
(
10.0
,
it
->
cal
.
precision
)
);
}
else
// if( it->stype == UniversalIO::DI || it->stype == UniversalIO::DO )
dval
=
val
?
1.0
:
0.0
;
return
dval
;
}
// -----------------------------------------------------------------------------
void
IOBase
::
processingThreshold
(
IOBase
*
it
,
const
std
::
shared_ptr
<
SMInterface
>&
shm
,
bool
force
)
{
if
(
it
->
t_ai
==
DefaultObjectId
)
...
...
@@ -760,7 +868,7 @@ namespace uniset
b
->
cdiagram
->
setCacheResortCycle
(
initIntProp
(
it
,
"cal_cacheresort"
,
prefix
,
init_prefix_only
));
}
}
else
if
(
b
->
stype
==
UniversalIO
::
DI
||
b
->
stype
==
UniversalIO
::
DO
)
else
if
(
b
->
stype
==
UniversalIO
::
DI
||
b
->
stype
==
UniversalIO
::
DO
)
// -V560
{
string
tai
(
initProp
(
it
,
"threshold_aid"
,
prefix
,
init_prefix_only
));
...
...
extensions/lib/MTR.cc
View file @
562e8cd4
...
...
@@ -302,12 +302,15 @@ namespace uniset
{
bool
start
=
false
;
while
(
!
ifs
.
eof
()
)
while
(
true
)
{
std
::
string
str
;
if
(
getline
(
ifs
,
str
)
)
{
if
(
ifs
.
eof
()
)
break
;
if
(
str
.
empty
()
)
continue
;
...
...
@@ -361,7 +364,7 @@ namespace uniset
dmap
[
reg
]
=
dlst
;
}
}
}
}
;
}
ifs
.
close
();
...
...
extensions/lib/SMInterface.cc
View file @
562e8cd4
...
...
@@ -74,16 +74,15 @@ using namespace uniset;
{ \
uwarn << "(" << __STRING(fname) << "): " << ex.err << endl; \
} \
catch( const uniset::Exception& ex ) \
{ \
uwarn << "(" << __STRING(fname) << "): " << ex << endl; \
} \
catch( const CORBA::SystemException& ex ) \
{ \
uwarn << "(" << __STRING(fname) << "): CORBA::SystemException: " \
<< ex.NP_minorString() << endl; \
} \
\
catch( const uniset::Exception& ex ) \
{ \
uwarn << "(" << __STRING(fname) << "): " << ex << endl; \
} \
oref = CORBA::Object::_nil(); \
throw uniset::TimeOut(); \
...
...
extensions/lib/UObject_SK.cc
View file @
562e8cd4
...
...
@@ -11,7 +11,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2018-1
0-16
+03:00
// generate timestamp: 2018-1
2-25
+03:00
// -----------------------------------------------------------------------------
#include <memory>
#include <iomanip>
...
...
@@ -176,7 +176,7 @@ end_private(false)
sleep_msec
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"sleep-msec"
,
"150"
,
150
);
string
s_resetTime
(
""
);
if
(
s_resetTime
.
empty
()
)
if
(
s_resetTime
.
empty
()
)
// -V547
s_resetTime
=
"500"
;
resetMsgTime
=
uni_atoi
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"resetMsgTime"
),
conf
->
getProp
(
cnode
,
"resetMsgTime"
),
s_resetTime
));
...
...
@@ -193,7 +193,7 @@ end_private(false)
smTestID
=
conf
->
getSensorID
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"sm-test-id"
),
conf
->
getProp
(
cnode
,
"smTestID"
),
""
));
if
(
smTestID
==
DefaultObjectId
)
if
(
smTestID
==
DefaultObjectId
)
// -V547
smTestID
=
getSMTestID
();
activateTimeout
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"activate-timeout"
,
120000
);
...
...
@@ -806,15 +806,15 @@ void UObject_SK::callback() noexcept
updateOutputs
(
forceOut
);
updatePreviousValues
();
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mycrit
<<
myname
<<
"(execute): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
mycrit
<<
myname
<<
"(execute): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
mycrit
<<
myname
<<
"(execute): "
<<
ex
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
mycrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
...
...
extensions/tests/test_vtypes.cc
View file @
562e8cd4
...
...
@@ -219,43 +219,43 @@ TEST_CASE("VTypes: F4", "[vtypes][F4]")
SECTION
(
"Default constructor"
)
{
F4
v
;
REQUIRE
(
(
float
)
v
==
0
);
REQUIRE
(
(
double
)
v
==
0
);
}
SECTION
(
"'float' constructor"
)
SECTION
(
"'float
64
' constructor"
)
{
{
F4
v
(
numeric_limits
<
float
>::
max
()
);
REQUIRE
(
(
float
)
v
==
numeric_limits
<
float
>::
max
()
);
F4
v
(
numeric_limits
<
double
>::
max
()
);
REQUIRE
(
(
double
)
v
==
numeric_limits
<
double
>::
max
()
);
}
{
F4
v
(
numeric_limits
<
float
>::
min
()
);
REQUIRE
(
(
float
)
v
==
numeric_limits
<
float
>::
min
()
);
F4
v
(
numeric_limits
<
double
>::
min
()
);
REQUIRE
(
(
double
)
v
==
numeric_limits
<
double
>::
min
()
);
}
}
SECTION
(
"Modbus constructor"
)
{
{
float
f
=
numeric_limits
<
float
>::
max
();
double
f
=
numeric_limits
<
double
>::
max
();
ModbusRTU
::
ModbusData
data
[
4
];
memcpy
(
data
,
&
f
,
sizeof
(
data
));
memcpy
(
data
,
&
f
,
sizeof
(
f
));
F4
v1
(
data
,
4
);
REQUIRE
(
(
float
)
v1
==
f
);
REQUIRE
(
(
double
)
v1
==
f
);
}
{
float
f
=
numeric_limits
<
float
>::
max
();
double
f
=
numeric_limits
<
double
>::
max
();
ModbusRTU
::
ModbusData
data5
[
5
];
memset
(
data5
,
0
,
sizeof
(
data5
));
memcpy
(
data5
,
&
f
,
4
*
sizeof
(
ModbusRTU
::
ModbusData
));
memcpy
(
data5
,
&
f
,
sizeof
(
f
));
F4
v2
(
data5
,
5
);
REQUIRE
(
(
float
)
v2
==
f
);
REQUIRE
(
(
double
)
v2
==
f
);
}
{
float
f
=
numeric_limits
<
float
>::
min
();
double
f
=
numeric_limits
<
double
>::
min
();
ModbusRTU
::
ModbusData
data
[
4
];
memcpy
(
data
,
&
f
,
sizeof
(
data
));
F4
v1
(
data
,
4
);
REQUIRE
(
(
float
)
v1
==
f
);
REQUIRE
(
(
double
)
v1
==
f
);
}
}
}
...
...
include/Configuration.h
View file @
562e8cd4
...
...
@@ -180,7 +180,7 @@ namespace uniset
virtual
void
initNode
(
uniset
::
NodeInfo
&
ninfo
,
UniXML
::
iterator
&
it
)
noexcept
;
void
initRepSections
();
std
::
string
getRepSectionName
(
const
std
::
string
&
sec
,
xmlNode
*
secnode
=
0
);
std
::
pair
<
std
::
string
,
xmlNode
*>
getRepSectionName
(
const
std
::
string
&
sec
);
void
setConfFileName
(
const
std
::
string
&
fn
=
""
);
void
initParameters
();
void
setLocalNode
(
const
std
::
string
&
nodename
);
...
...
include/MessageType.h
View file @
562e8cd4
...
...
@@ -96,7 +96,7 @@ namespace uniset
// для оптимизации, делаем конструктор, который не будет инициализировать свойства класса
// это необходимо для VoidMessage, который конструируется при помощи memcpy
VoidMessage
(
int
dummy
)
noexcept
:
Message
(
dummy
)
{}
VoidMessage
(
int
dummy
)
noexcept
:
Message
(
dummy
)
{}
// -V730
VoidMessage
(
const
TransportMessage
&
tm
)
noexcept
;
VoidMessage
()
noexcept
;
...
...
include/UniSetTypes.h
View file @
562e8cd4
...
...
@@ -76,20 +76,11 @@ namespace uniset
/*! генератор уникального положительного ключа
* Уникальность гарантируется только для пары значений id и node.
* \warning что тут у нас с переполнением..
* \warning Уникальность генерируемого ключа еще не проверялась,
но нареканий по использованию тоже не было :)
* \todo Желательно продумать что-нибудь с использованием хэш.
* \todo Желательно продумать что-нибудь с использованием хэш.
* \warning Уникальность не гарантирована, возможны коллизии
*/
inline
static
KeyType
key
(
const
uniset
::
ObjectId
id
,
const
uniset
::
ObjectId
node
)
{
return
KeyType
((
id
*
node
)
+
(
id
+
2
*
node
));
}
inline
static
KeyType
key
(
const
IOController_i
::
SensorInfo
&
si
)
{
return
key
(
si
.
id
,
si
.
node
);
}
KeyType
key
(
const
uniset
::
ObjectId
id
,
const
uniset
::
ObjectId
node
);
KeyType
key
(
const
IOController_i
::
SensorInfo
&
si
);
typedef
std
::
list
<
std
::
string
>
ListObjectName
;
/*!< Список объектов типа ObjectName */
...
...
@@ -318,6 +309,7 @@ namespace uniset
// limit - обрезать итоговое значение по границам
float
fcalibrate
(
float
raw
,
float
rawMin
,
float
rawMax
,
float
calMin
,
float
calMax
,
bool
limit
=
true
);
long
lcalibrate
(
long
raw
,
long
rawMin
,
long
rawMax
,
long
calMin
,
long
calMax
,
bool
limit
=
true
);
double
dcalibrate
(
double
raw
,
double
rawMin
,
double
rawMax
,
double
calMin
,
double
calMax
,
bool
limit
=
true
);
// установка значения в нужный диапазон
long
setinregion
(
long
raw
,
long
rawMin
,
long
rawMax
);
...
...
include/modbus/ModbusTCPServer.h
View file @
562e8cd4
...
...
@@ -148,7 +148,7 @@ namespace uniset
ev
::
timer
ioTimer
;
std
::
shared_ptr
<
UTCPSocket
>
sock
;
const
std
::
unordered_set
<
ModbusRTU
::
ModbusAddr
>*
vmbaddr
=
{
nullptr
}
;
std
::
unordered_set
<
ModbusRTU
::
ModbusAddr
>
vmbaddr
;
TimerSignal
m_timer_signal
;
timeout_t
tmTime_msec
=
{
UniSetTimer
::
WaitUpTime
};
// время по умолчанию для таймера (TimerSignal)
...
...
include/modbus/ModbusTypes.h
View file @
562e8cd4
...
...
@@ -154,6 +154,24 @@ namespace uniset
float
dat2f
(
const
ModbusData
dat1
,
const
ModbusData
dat2
);
size_t
numBytes
(
const
size_t
nbits
);
// сколько байт нужно для указанного количества бит
// -------------------------------------------------------------------------
// вспомогательная структура для предотвращения утечки памяти (RAII)
struct
DataGuard
{
DataGuard
(
size_t
sz
)
:
len
(
sz
)
{
data
=
new
ModbusRTU
::
ModbusData
[
sz
];
}
~
DataGuard
()
{
delete
[]
data
;
}
ModbusRTU
::
ModbusData
*
data
;
size_t
len
;
};
// -----------------------------------------------------------------------------
bool
isWriteFunction
(
SlaveFunctionCode
c
);
bool
isReadFunction
(
SlaveFunctionCode
c
);
// -------------------------------------------------------------------------
...
...
src/Communications/ComPort485F.cc
View file @
562e8cd4
...
...
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// --------------------------------------------------------------------------------
#include <
unistd.h
>
#include <
cstring
>
#include <termios.h>
#include <fcntl.h>
#include <errno.h>
...
...
@@ -83,6 +83,8 @@ ComPort485F::ComPort485F( const string& dev, char gpio_num, bool tmit_ctrl ):
gpio_num
(
gpio_num
),
tmit_ctrl_on
(
tmit_ctrl
)
{
memset
(
tbuf
,
0
,
sizeof
(
tbuf
));
if
(
tmit_ctrl_on
)
{
iopl
(
3
);
...
...
src/Communications/Modbus/ModbusTCPMaster.cc
View file @
562e8cd4
...
...
@@ -298,15 +298,15 @@ namespace uniset
if
(
tcp
)
tcp
->
forceDisconnect
();
}
catch
(
const
uniset
::
Exception
&
ex
)
catch
(
const
Poco
::
Net
::
NetException
&
e
)
{
if
(
dlog
->
is_warn
()
)
dlog
->
warn
()
<<
"(query):
"
<<
ex
<<
endl
;
dlog
->
warn
()
<<
"(query):
tcp error: "
<<
e
.
displayText
()
<<
endl
;
}
catch
(
const
Poco
::
Net
::
NetException
&
e
)
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
dlog
->
is_warn
()
)
dlog
->
warn
()
<<
"(query):
tcp error: "
<<
e
.
displayText
()
<<
endl
;
dlog
->
warn
()
<<
"(query):
"
<<
ex
<<
endl
;
}
catch
(
const
std
::
exception
&
e
)
{
...
...
src/Communications/Modbus/ModbusTCPServer.cc
View file @
562e8cd4
...
...
@@ -103,13 +103,13 @@ namespace uniset
// -------------------------------------------------------------------------
bool
ModbusTCPServer
::
run
(
const
std
::
unordered_set
<
ModbusAddr
>&
_vmbaddr
)
{
vmbaddr
=
&
_vmbaddr
;
vmbaddr
=
_vmbaddr
;
return
evrun
();
}
// -------------------------------------------------------------------------
bool
ModbusTCPServer
::
async_run
(
const
std
::
unordered_set
<
ModbusAddr
>&
_vmbaddr
)
{
vmbaddr
=
&
_vmbaddr
;
vmbaddr
=
_vmbaddr
;
return
async_evrun
();
}
// -------------------------------------------------------------------------
...
...
@@ -296,7 +296,7 @@ namespace uniset
connCount
++
;
auto
s
=
make_shared
<
ModbusTCPSession
>
(
ss
,
*
vmbaddr
,
sessTimeout
);
auto
s
=
make_shared
<
ModbusTCPSession
>
(
ss
,
vmbaddr
,
sessTimeout
);
s
->
connectReadCoil
(
sigc
::
mem_fun
(
this
,
&
ModbusTCPServer
::
readCoilStatus
)
);
s
->
connectReadInputStatus
(
sigc
::
mem_fun
(
this
,
&
ModbusTCPServer
::
readInputStatus
)
);
s
->
connectReadOutput
(
sigc
::
mem_fun
(
this
,
&
ModbusTCPServer
::
readOutputRegisters
)
);
...
...
src/Communications/Modbus/ModbusTypes.cc
View file @
562e8cd4
...
...
@@ -399,7 +399,7 @@ namespace uniset
size_t
last
=
sizeof
(
d
);
// индекс в массиве данных ( байтовый массив!!! )
// копируем
memcpy
(
mm
.
data
,
&
d
,
last
);
memcpy
(
mm
.
data
,
&
d
,
last
);
// -V512
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
.
pduhead
),
szModbusHeader
+
sizeof
(
d
)
);
...
...
@@ -428,7 +428,7 @@ namespace uniset
assert
(
m
.
pduhead
.
func
==
fnReadCoilStatus
);
// memset(this, 0, sizeof(*this));
memcpy
(
this
,
&
m
.
pduhead
,
sizeof
(
m
.
pduhead
));
memcpy
(
&
start
,
&
(
m
.
data
[
0
]),
szData
());
memcpy
(
&
start
,
m
.
data
,
szData
());
// -V512
// переворачиваем слова
start
=
SWAPSHORT
(
start
);
...
...
@@ -731,7 +731,7 @@ namespace uniset
size_t
last
=
sizeof
(
d
);
// индекс в массиве данных ( байтовый массив!!! )
// копируем
memcpy
(
mm
.
data
,
&
d
,
last
);
memcpy
(
mm
.
data
,
&
d
,
last
);
// -V512
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
.
pduhead
),
szModbusHeader
+
sizeof
(
d
)
);
...
...
@@ -760,7 +760,7 @@ namespace uniset
assert
(
m
.
pduhead
.
func
==
fnReadInputStatus
);
func
=
m
.
pduhead
.
func
;
addr
=
m
.
pduhead
.
addr
;
memcpy
(
&
start
,
&
m
.
data
,
szData
());
memcpy
(
&
start
,
&
m
.
data
,
szData
());
// -V512
// переворачиваем слова
start
=
SWAPSHORT
(
start
);
...
...
@@ -935,7 +935,7 @@ namespace uniset
size_t
last
(
sizeof
(
d
));
// индекс в массиве данных ( байтовый массив!!! )
// копируем
memcpy
(
mm
.
data
,
&
d
,
last
);
memcpy
(
mm
.
data
,
&
d
,
last
);
// -V512
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
.
pduhead
),
szModbusHeader
+
sizeof
(
d
)
);
...
...
@@ -967,7 +967,7 @@ namespace uniset
func
=
m
.
pduhead
.
func
;
addr
=
m
.
pduhead
.
addr
;
//memset(this, 0, sizeof(*this));
memcpy
(
&
start
,
&
m
.
data
,
szData
());
memcpy
(
&
start
,
&
m
.
data
,
szData
());
// -V512
// переворачиваем слова
start
=
SWAPSHORT
(
start
);
...
...
@@ -1012,7 +1012,7 @@ namespace uniset
size_t
cnt
=
m
.
data
[
0
]
/
sizeof
(
ModbusData
);
if
(
cnt
>
MAXLENPACKET
/
sizeof
(
ModbusData
)
)
if
(
cnt
>
MAXLENPACKET
/
sizeof
(
ModbusData
)
)
// -V547
throw
mbException
(
erPacketTooLong
);
count
=
cnt
;
...
...
@@ -1146,7 +1146,7 @@ namespace uniset
size_t
last
=
sizeof
(
d
);
// индекс в массиве данных ( байтовый массив!!! )
// копируем
memcpy
(
mm
.
data
,
&
d
,
last
);
memcpy
(
mm
.
data
,
&
d
,
last
);
// -V512
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
.
pduhead
),
szModbusHeader
+
sizeof
(
d
)
);
...
...
@@ -1176,7 +1176,7 @@ namespace uniset
assert
(
m
.
pduhead
.
func
==
fnReadInputRegisters
);
// memset(this, 0, sizeof(*this));
memcpy
(
this
,
&
m
.
pduhead
,
sizeof
(
m
.
pduhead
));
memcpy
(
&
start
,
m
.
data
,
szData
());
memcpy
(
&
start
,
m
.
data
,
szData
());
// -V512
// переворачиваем слова
start
=
SWAPSHORT
(
start
);
...
...
@@ -1222,7 +1222,7 @@ namespace uniset
// bcnt = m.data[0];
size_t
cnt
=
m
.
data
[
0
]
/
sizeof
(
ModbusData
);
if
(
cnt
>
MAXLENPACKET
/
sizeof
(
ModbusData
)
)
if
(
cnt
>
MAXLENPACKET
/
sizeof
(
ModbusData
)
)
// -V547
throw
mbException
(
erPacketTooLong
);
count
=
cnt
;
...
...
@@ -1418,7 +1418,7 @@ namespace uniset
ind
+=
sizeof
(
d
);
// копируем
memcpy
(
mm
.
data
,
&
d
,
ind
);
memcpy
(
mm
.
data
,
&
d
,
ind
);
// -V512
// copy bcnt
memcpy
(
&
(
mm
.
data
[
ind
]),
&
bcnt
,
sizeof
(
bcnt
));
...
...
@@ -1588,7 +1588,7 @@ namespace uniset
ModbusData
d
[
2
]
=
{
SWAPSHORT
(
start
),
SWAPSHORT
(
quant
)
};
size_t
last
=
sizeof
(
d
);
// копируем
memcpy
(
mm
.
data
,
&
d
,
last
);
memcpy
(
mm
.
data
,
&
d
,
last
);
// -V512
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
.
pduhead
),
szModbusHeader
+
last
);
...
...
@@ -1610,7 +1610,6 @@ namespace uniset
return
os
<<
(
*
m
);
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
WriteOutputMessage
::
WriteOutputMessage
(
ModbusAddr
a
,
ModbusData
s
)
:
start
(
s
),
quant
(
0
),
...
...
@@ -1618,6 +1617,7 @@ namespace uniset
{
addr
=
a
;
func
=
fnWriteOutputRegisters
;
memset
(
data
,
0
,
sizeof
(
data
));
}
// -------------------------------------------------------------------------
bool
WriteOutputMessage
::
addData
(
ModbusData
d
)
...
...
@@ -1653,7 +1653,7 @@ namespace uniset
ind
+=
sizeof
(
d
);
// копируем
memcpy
(
mm
.
data
,
&
d
,
ind
);
memcpy
(
mm
.
data
,
&
d
,
ind
);
// -V512
// copy bcnt
bcnt
=
quant
*
sizeof
(
ModbusData
);
...
...
@@ -1847,7 +1847,7 @@ namespace uniset
ModbusData
d
[
2
]
=
{
SWAPSHORT
(
start
),
SWAPSHORT
(
quant
)
};
size_t
last
=
sizeof
(
d
);
// копируем
memcpy
(
mm
.
data
,
&
d
,
last
);
memcpy
(
mm
.
data
,
&
d
,
last
);
// -V512
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
.
pduhead
),
szModbusHeader
+
last
);
...
...
@@ -1885,7 +1885,7 @@ namespace uniset
memcpy
(
&
mm
.
pduhead
,
this
,
szModbusHeader
);
ModbusData
d
[
2
]
=
{
SWAPSHORT
(
start
),
SWAPSHORT
(
data
)
};
size_t
last
=
sizeof
(
d
);
// индекс в массиве данных ( байтовый массив!!! )
memcpy
(
mm
.
data
,
&
d
,
last
);
memcpy
(
mm
.
data
,
&
d
,
last
);
// -V512
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
.
pduhead
),
szModbusHeader
+
last
);
// копируем CRC (последний элемент). Без переворачивания...
...
...
@@ -2016,7 +2016,7 @@ namespace uniset
size_t
last
=
sizeof
(
d
);
// индекс в массиве данных ( байтовый массив!!! )
// копируем
memcpy
(
mm
.
data
,
&
d
,
last
);
memcpy
(
mm
.
data
,
&
d
,
last
);
// -V512
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
.
pduhead
),
szModbusHeader
+
sizeof
(
d
)
);
...
...
@@ -2056,7 +2056,7 @@ namespace uniset
memcpy
(
&
mm
.
pduhead
,
this
,
szModbusHeader
);
ModbusData
d
[
2
]
=
{
SWAPSHORT
(
start
),
SWAPSHORT
(
data
)
};
size_t
last
=
sizeof
(
d
);
// индекс в массиве данных ( байтовый массив!!! )
memcpy
(
mm
.
data
,
&
d
,
last
);
memcpy
(
mm
.
data
,
&
d
,
last
);
// -V512
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
.
pduhead
),
szModbusHeader
+
last
);
// копируем CRC (последний элемент). Без переворачивания...
...
...
@@ -2194,7 +2194,7 @@ namespace uniset
size_t
last
=
sizeof
(
d
);
// индекс в массиве данных ( байтовый массив!!! )
// копируем
memcpy
(
mm
.
data
,
&
d
,
last
);
memcpy
(
mm
.
data
,
&
d
,
last
);
// -V512
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
.
pduhead
),
szModbusHeader
+
sizeof
(
d
)
);
...
...
@@ -2679,7 +2679,7 @@ namespace uniset
RDIObjectInfo
r
(
id
,
val
);
dlist
.
push_back
(
r
);
objNum
=
dlist
.
size
();
objNum
=
(
ModbusByte
)
dlist
.
size
();
// -V1029
bcnt
+=
val
.
size
()
+
2
;
// 2 = 'id'(byte) + 'len'(byte)
return
true
;
...
...
@@ -3132,7 +3132,7 @@ namespace uniset
mm.data[6] = century;
*/
size_t
bcnt
=
7
;
memcpy
(
mm
.
data
,
&
hour
,
bcnt
);
// копируем начиная с адреса 'hour' 7 байт.
memcpy
(
mm
.
data
,
&
hour
,
bcnt
);
//
-V512
копируем начиная с адреса 'hour' 7 байт.
// пересчитываем CRC
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
.
pduhead
),
szModbusHeader
+
bcnt
);
...
...
@@ -3427,7 +3427,7 @@ namespace uniset
// копируем данные (переворачиваем байты)
ModbusData
d
[
2
]
=
{
SWAPSHORT
(
numfile
),
SWAPSHORT
(
numpacket
)
};
size_t
last
=
sizeof
(
d
);
memcpy
(
mm
.
data
,
&
d
,
last
);
memcpy
(
mm
.
data
,
&
d
,
last
);
// -V512
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
.
pduhead
),
szModbusHeader
+
sizeof
(
d
)
);
...
...
src/Core/Configuration.cc
View file @
562e8cd4
...
...
@@ -19,7 +19,8 @@
* \author Vitaly Lipatov, Pavel Vainerman
*/
// --------------------------------------------------------------------------
#include <utility> // for make_pair
#include <tuple> // for std::tie
#include <unistd.h>
#include <libgen.h>
#include <fstream>
...
...
@@ -1099,17 +1100,24 @@ namespace uniset
}
secRoot
=
unixml
->
getProp
(
node
,
"name"
);
secSensors
=
makeSecName
(
secRoot
,
getRepSectionName
(
"sensors"
,
xmlSensorsSec
));
secObjects
=
makeSecName
(
secRoot
,
getRepSectionName
(
"objects"
,
xmlObjectsSec
));
secControlles
=
makeSecName
(
secRoot
,
getRepSectionName
(
"controllers"
,
xmlControllersSec
));
secServices
=
makeSecName
(
secRoot
,
getRepSectionName
(
"services"
,
xmlServicesSec
));
std
::
tie
(
secSensors
,
xmlSensorsSec
)
=
getRepSectionName
(
"sensors"
);
secSensors
=
makeSecName
(
secRoot
,
secSensors
);
std
::
tie
(
secObjects
,
xmlObjectsSec
)
=
getRepSectionName
(
"objects"
);
secObjects
=
makeSecName
(
secRoot
,
secObjects
);
std
::
tie
(
secControlles
,
xmlControllersSec
)
=
getRepSectionName
(
"controllers"
);
secControlles
=
makeSecName
(
secRoot
,
secControlles
);
std
::
tie
(
secServices
,
xmlServicesSec
)
=
getRepSectionName
(
"services"
);
secServices
=
makeSecName
(
secRoot
,
secServices
);
}
// -------------------------------------------------------------------------
// второй параметр намеренно передаётся и переопределяется
// это просто такой способ вернуть и строку и указатель на узел (одним махом)
string
Configuration
::
getRepSectionName
(
const
string
&
sec
,
xmlNode
*
secnode
)
std
::
pair
<
string
,
xmlNode
*>
Configuration
::
getRepSectionName
(
const
string
&
sec
)
{
secnode
=
unixml
->
findNode
(
unixml
->
getFirstNode
(),
sec
);
xmlNode
*
secnode
=
unixml
->
findNode
(
unixml
->
getFirstNode
(),
sec
);
if
(
secnode
==
NULL
)
{
...
...
@@ -1124,7 +1132,7 @@ namespace uniset
if
(
ret
.
empty
()
)
ret
=
unixml
->
getProp
(
secnode
,
"name"
);
return
ret
;
return
std
::
make_pair
(
ret
,
secnode
)
;
}
// -------------------------------------------------------------------------
void
Configuration
::
setConfFileName
(
const
string
&
fn
)
...
...
src/Core/MessageType.cc
View file @
562e8cd4
...
...
@@ -142,6 +142,7 @@ namespace uniset
type
=
Message
::
SysCommand
;
this
->
priority
=
priority
;
this
->
consumer
=
consumer
;
memset
(
data
,
0
,
sizeof
(
data
));
}
SystemMessage
::
SystemMessage
(
const
VoidMessage
*
msg
)
noexcept
:
...
...
src/Core/UInterface.cc
View file @
562e8cd4
...
...
@@ -919,7 +919,6 @@ namespace uniset
catch
(
const
CosNaming
::
NamingContext
::
NotFound
&
nf
)
{}
catch
(
const
CosNaming
::
NamingContext
::
InvalidName
&
nf
)
{}
catch
(
const
CosNaming
::
NamingContext
::
CannotProceed
&
cp
)
{}
catch
(
const
uniset
::
Exception
&
ex
)
{}
catch
(
const
CORBA
::
OBJECT_NOT_EXIST
&
ex
)
{
throw
uniset
::
ResolveNameError
(
"ObjectNOTExist"
);
...
...
@@ -934,6 +933,7 @@ namespace uniset
// uwarn << "UI(resolve): CORBA::SystemException" << endl;
throw
uniset
::
TimeOut
();
}
catch
(
const
uniset
::
Exception
&
ex
)
{}
catch
(
std
::
exception
&
ex
)
{
ucrit
<<
"UI(resolve): myID="
<<
myid
<<
": resolve id="
<<
rid
<<
"@"
<<
node
...
...
@@ -2381,22 +2381,20 @@ namespace uniset
pmsec
=
0
;
PassiveTimer
ptReady
(
msec
);
bool
ready
=
false
;
while
(
!
ptReady
.
checkTime
()
&&
!
ready
)
while
(
!
ptReady
.
checkTime
()
)
{
try
{
getValue
(
id
,
node
);
ready
=
true
;
break
;
return
true
;
}
catch
(...)
{}
msleep
(
pmsec
);
}
return
ready
;
return
false
;
}
// -----------------------------------------------------------------------------
bool
UInterface
::
waitReadyWithCancellation
(
const
ObjectId
id
,
int
msec
,
...
...
src/Core/UniSetManager.cc
View file @
562e8cd4
...
...
@@ -209,10 +209,6 @@ bool UniSetManager::removeObject( const std::shared_ptr<UniSetObject>& obj )
if
(
obj
)
obj
->
deactivate
();
}
catch
(
const
uniset
::
Exception
&
ex
)
{
uwarn
<<
myname
<<
"(removeObject): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
uwarn
<<
myname
<<
"(removeObject): поймали CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
...
...
@@ -228,6 +224,10 @@ bool UniSetManager::removeObject( const std::shared_ptr<UniSetObject>& obj )
<<
" line: "
<<
fe
.
line
()
<<
" mesg: "
<<
fe
.
errmsg
()
<<
endl
;
}
catch
(
const
uniset
::
Exception
&
ex
)
{
uwarn
<<
myname
<<
"(removeObject): "
<<
ex
<<
endl
;
}
catch
(...)
{}
olist
.
erase
(
li
);
...
...
@@ -273,21 +273,6 @@ void UniSetManager::managers( OManagerCommand cmd )
break
;
}
}
catch
(
const
uniset
::
Exception
&
ex
)
{
ostringstream
err
;
err
<<
myname
<<
"(managers): "
<<
ex
<<
endl
<<
" Не смог зарегистрировать (разрегистрировать) объект -->"
<<
li
->
getName
();
ucrit
<<
err
.
str
()
<<
endl
;
if
(
cmd
==
activ
)
{
cerr
<<
err
.
str
();
std
::
terminate
();
}
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
ostringstream
err
;
...
...
@@ -332,6 +317,21 @@ void UniSetManager::managers( OManagerCommand cmd )
std
::
terminate
();
}
}
catch
(
const
uniset
::
Exception
&
ex
)
{
ostringstream
err
;
err
<<
myname
<<
"(managers): "
<<
ex
<<
endl
<<
" Не смог зарегистрировать (разрегистрировать) объект -->"
<<
li
->
getName
();
ucrit
<<
err
.
str
()
<<
endl
;
if
(
cmd
==
activ
)
{
cerr
<<
err
.
str
();
std
::
terminate
();
}
}
}
}
// unlock
}
...
...
@@ -372,20 +372,6 @@ void UniSetManager::objects(OManagerCommand cmd)
break
;
}
}
catch
(
const
uniset
::
Exception
&
ex
)
{
ostringstream
err
;
err
<<
myname
<<
"(objects): "
<<
ex
<<
endl
;
err
<<
myname
<<
"(objects): не смог зарегистрировать (разрегистрировать) объект -->"
<<
li
->
getName
()
<<
endl
;
ucrit
<<
err
.
str
();
if
(
cmd
==
activ
)
{
cerr
<<
err
.
str
();
std
::
terminate
();
}
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
ostringstream
err
;
...
...
@@ -430,6 +416,20 @@ void UniSetManager::objects(OManagerCommand cmd)
std
::
terminate
();
}
}
catch
(
const
uniset
::
Exception
&
ex
)
{
ostringstream
err
;
err
<<
myname
<<
"(objects): "
<<
ex
<<
endl
;
err
<<
myname
<<
"(objects): не смог зарегистрировать (разрегистрировать) объект -->"
<<
li
->
getName
()
<<
endl
;
ucrit
<<
err
.
str
();
if
(
cmd
==
activ
)
{
cerr
<<
err
.
str
();
std
::
terminate
();
}
}
}
}
// unlock
}
...
...
@@ -660,7 +660,7 @@ SimpleInfoSeq* UniSetManager::getObjectsInfo(CORBA::Long maxlength, const char*
int
ind
=
0
;
const
int
limit
=
length
;
ind
=
getObjectsInfo
(
get_mptr
(),
res
,
ind
,
limit
,
userparam
);
(
void
)
getObjectsInfo
(
get_mptr
(),
res
,
ind
,
limit
,
userparam
);
return
res
;
}
...
...
src/Core/UniSetObject.cc
View file @
562e8cd4
...
...
@@ -288,9 +288,12 @@ namespace uniset
void
UniSetObject
::
unregistration
()
{
if
(
myid
<
0
)
// || !reg )
{
regOK
=
false
;
return
;
}
if
(
myid
==
uniset
::
DefaultObjectId
)
if
(
myid
==
uniset
::
DefaultObjectId
)
// -V547
{
uinfo
<<
myname
<<
"(unregister): myid=DefaultObjectId
\n
"
;
regOK
=
false
;
...
...
@@ -846,10 +849,6 @@ namespace uniset
break
;
}
}
catch
(
const
uniset
::
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(processingMessage): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
ucrit
<<
myname
<<
"(processingMessage): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
...
...
@@ -868,6 +867,10 @@ namespace uniset
<<
" mesg: "
<<
fe
.
errmsg
()
<<
endl
;
}
}
catch
(
const
uniset
::
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(processingMessage): "
<<
ex
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
ucrit
<<
myname
<<
"(processingMessage): "
<<
ex
.
what
()
<<
endl
;
...
...
src/Core/UniSetTypes.cc
View file @
562e8cd4
...
...
@@ -59,6 +59,37 @@ float uniset::fcalibrate( float raw, float rawMin, float rawMax,
return
ret
;
}
// -----------------------------------------------------------------------------
double
uniset
::
dcalibrate
(
double
raw
,
double
rawMin
,
double
rawMax
,
double
calMin
,
double
calMax
,
bool
limit
)
{
if
(
rawMax
==
rawMin
)
return
0
;
// деление на 0!!!
double
ret
=
(
raw
-
rawMin
)
*
(
calMax
-
calMin
)
/
(
rawMax
-
rawMin
)
+
calMin
;
if
(
!
limit
)
return
ret
;
// Переворачиваем calMin и calMax для проверки, если calMin > calMax
if
(
calMin
<
calMax
)
{
if
(
ret
<
calMin
)
return
calMin
;
if
(
ret
>
calMax
)
return
calMax
;
}
else
{
if
(
ret
>
calMin
)
return
calMin
;
if
(
ret
<
calMax
)
return
calMax
;
}
return
ret
;
}
// -------------------------------------------------------------------------
// Пересчитываем из исходных пределов в заданные
long
uniset
::
lcalibrate
(
long
raw
,
long
rawMin
,
long
rawMax
,
long
calMin
,
long
calMax
,
bool
limit
)
...
...
@@ -114,7 +145,7 @@ long uniset::setoutregion(long ret, long calMin, long calMax)
}
// -------------------------------------------------------------------------
uniset
::
IDList
::
IDList
(
const
std
::
vector
<
string
>&
svec
)
:
uniset
::
IDList
::
IDList
(
const
std
::
vector
<
string
>&
svec
)
:
// -V730
uniset
::
IDList
::
IDList
()
{
auto
conf
=
uniset_conf
();
...
...
@@ -662,3 +693,15 @@ string uniset::BadSymbolsToStr()
return
bad
;
}
// ---------------------------------------------------------------------------------------------------------------
uniset
::
KeyType
uniset
::
key
(
const
uniset
::
ObjectId
id
,
const
uniset
::
ObjectId
node
)
{
//! \warning что тут у нас с переполнением..
return
KeyType
(
(
id
*
node
)
+
(
id
+
2
*
node
)
);
}
// ---------------------------------------------------------------------------------------------------------------
uniset
::
KeyType
uniset
::
key
(
const
IOController_i
::
SensorInfo
&
si
)
{
return
key
(
si
.
id
,
si
.
node
);
}
// ---------------------------------------------------------------------------------------------------------------
src/Log/LogReader.cc
View file @
562e8cd4
...
...
@@ -350,7 +350,7 @@ void LogReader::readlogs( const std::string& _addr, int _port, LogServerTypes::C
{
rlog
.
warn
()
<<
"(LogReader): **** connection timeout.."
<<
endl
;
if
(
r
count
>
0
&&
r
eadcount
>
0
)
if
(
readcount
>
0
)
rcount
--
;
if
(
rcount
==
0
)
...
...
src/Processes/EventLoopServer.cc
View file @
562e8cd4
...
...
@@ -58,8 +58,8 @@ namespace uniset
thr
=
nullptr
;
}
i
f
(
!
thr
)
thr
=
unisetstd
::
make_unique
<
std
::
thread
>
(
[
&
]
{
defaultLoop
();
}
);
i
srunning
=
false
;
thr
=
unisetstd
::
make_unique
<
std
::
thread
>
(
[
&
]
{
defaultLoop
();
}
);
bool
ret
=
waitDefaultLoopRunning
(
timeout_msec
);
...
...
@@ -167,6 +167,9 @@ namespace uniset
// -------------------------------------------------------------------------
bool
EventLoopServer
::
waitDefaultLoopRunning
(
size_t
waitTimeout_msec
)
{
if
(
isrunning
)
return
true
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
looprunOK_mutex
);
looprunOK_event
.
wait_for
(
lock
,
std
::
chrono
::
milliseconds
(
waitTimeout_msec
),
[
&
]()
{
...
...
src/Processes/PassiveObject.cc
View file @
562e8cd4
...
...
@@ -101,10 +101,6 @@ void PassiveObject::processingMessage( const uniset::VoidMessage* msg )
break
;
}
}
catch
(
const
uniset
::
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(processingMessage): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
ucrit
<<
myname
<<
"(processingMessage): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
...
...
@@ -125,6 +121,10 @@ void PassiveObject::processingMessage( const uniset::VoidMessage* msg )
<<
" mesg: "
<<
fe
.
errmsg
()
<<
endl
;
}
}
catch
(
const
uniset
::
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(processingMessage): "
<<
ex
<<
endl
;
}
}
// -------------------------------------------------------------------------
void
PassiveObject
::
sysCommand
(
const
SystemMessage
*
sm
)
...
...
tests/test_mutex.cc
View file @
562e8cd4
...
...
@@ -11,7 +11,7 @@ using namespace uniset;
// -----------------------------------------------------------------------------
TEST_CASE
(
"uniset_rwmutex"
,
"[mutex][basic]"
)
{
SECTION
(
"simple lock"
)
;
SECTION
(
"simple lock"
)
{
uniset_rwmutex
m
(
"rwmutex"
);
...
...
@@ -34,7 +34,7 @@ TEST_CASE("uniset_rwmutex", "[mutex][basic]" )
// -----------------------------------------------------------------------------
TEST_CASE
(
"uniset_rwmutex_wrlock"
,
"[mutex][basic]"
)
{
SECTION
(
"simple lock"
)
;
SECTION
(
"simple lock"
)
{
uniset_rwmutex
m
;
{
...
...
@@ -46,7 +46,7 @@ TEST_CASE("uniset_rwmutex_wrlock", "[mutex][basic]" )
CHECK_FALSE
(
m
.
try_lock
()
);
}
SECTION
(
"exception lock"
)
;
SECTION
(
"exception lock"
)
{
uniset_rwmutex
m
;
...
...
@@ -67,7 +67,7 @@ TEST_CASE("uniset_rwmutex_wrlock", "[mutex][basic]" )
// -----------------------------------------------------------------------------
TEST_CASE
(
"uniset_rwmutex_rlock"
,
"[mutex][basic]"
)
{
SECTION
(
"simple lock"
)
;
SECTION
(
"simple lock"
)
{
uniset_rwmutex
m
;
{
...
...
@@ -79,7 +79,7 @@ TEST_CASE("uniset_rwmutex_rlock", "[mutex][basic]" )
CHECK_FALSE
(
m
.
try_lock
()
);
}
SECTION
(
"exception lock"
)
;
SECTION
(
"exception lock"
)
{
uniset_rwmutex
m
;
...
...
tests/test_sscanf_hex.cc
View file @
562e8cd4
...
...
@@ -14,7 +14,7 @@ TEST_CASE("sscanf hex", "[sscanf hex]")
REQUIRE
(
check
(
"100"
)
==
100
);
REQUIRE
(
check
(
"0x100"
)
==
0x100
);
REQUIRE
(
check
(
"0xFF"
)
==
0xff
);
REQUIRE
(
check
(
"010"
)
==
010
);
REQUIRE
(
check
(
"010"
)
==
010
);
// -V536
REQUIRE
(
check
(
"-10"
)
==
-
10
);
REQUIRE
(
check
(
"-1000"
)
==
-
1000
);
REQUIRE
(
check
(
""
)
==
0
);
...
...
wrappers/core/UModbus.cc
View file @
562e8cd4
...
...
@@ -275,7 +275,7 @@ long UModbus::data2value( uniset::VTypes::VType vtype, uniset::ModbusRTU::Modbus
else
if
(
vtype
==
VTypes
::
vtF4
)
{
VTypes
::
F4
f
(
data
,
VTypes
::
F4
::
wsize
());
return
lroundf
(
(
float
)
f
);
return
lroundf
(
(
double
)
f
);
}
else
if
(
vtype
==
VTypes
::
vtI2
)
{
...
...
wrappers/core/UProxyObject.cc
View file @
562e8cd4
...
...
@@ -53,6 +53,12 @@ class UProxyObject_impl:
struct
SInfo
{
SInfo
()
{
si
.
id
=
uniset
::
DefaultObjectId
;
si
.
node
=
uniset
::
DefaultObjectId
;
}
IOController_i
::
SensorInfo
si
;
long
value
=
{
0
};
float
fvalue
=
{
0.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