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
b2cf6d77
Commit
b2cf6d77
authored
Dec 16, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move UniSetObject::askTimer to public, make style
parent
b59446ed
Hide whitespace changes
Inline
Side-by-side
Showing
62 changed files
with
496 additions
and
368 deletions
+496
-368
admin.cc
Utilities/Admin/admin.cc
+2
-0
MBTCPServer.cc
Utilities/MBTester/MBTCPServer.cc
+1
-0
mbrtuslave.cc
Utilities/MBTester/mbrtuslave.cc
+1
-0
mbrtutester.cc
Utilities/MBTester/mbrtutester.cc
+1
-0
mbslave.cc
Utilities/MBTester/mbslave.cc
+5
-2
mbtcpserver.cc
Utilities/MBTester/mbtcpserver.cc
+4
-2
log-stdin.cc
Utilities/ULog/log-stdin.cc
+1
-0
log.cc
Utilities/ULog/log.cc
+1
-0
logserver.cc
Utilities/ULog/logserver.cc
+1
-0
TestGen.cc
Utilities/codegen/tests/TestGen.cc
+1
-0
libuniset2.spec
conf/libuniset2.spec
+4
-1
PostgreSQLInterface.h
extensions/DBServer-PostgreSQL/PostgreSQLInterface.h
+1
-1
IOControl.cc
extensions/IOControl/IOControl.cc
+1
-1
iocalibr.cc
extensions/IOControl/iocalibr.cc
+3
-0
iotest.cc
extensions/IOControl/iotest.cc
+1
-0
PassiveLProcessor.h
extensions/LogicProcessor/PassiveLProcessor.h
+1
-1
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+24
-18
MBTCPMaster.cc
extensions/ModbusMaster/MBTCPMaster.cc
+1
-1
MBTCPMultiMaster.cc
extensions/ModbusMaster/MBTCPMultiMaster.cc
+7
-6
RTUExchange.cc
extensions/ModbusMaster/RTUExchange.cc
+4
-4
RTUStorage.cc
extensions/ModbusMaster/RTUStorage.cc
+6
-2
mtr-read.cc
extensions/ModbusMaster/mtr-read.cc
+1
-0
mtr-setup.cc
extensions/ModbusMaster/mtr-setup.cc
+1
-0
rtustate.cc
extensions/ModbusMaster/rtustate.cc
+1
-0
MBTCPTestServer.cc
extensions/ModbusMaster/tests/MBTCPTestServer.cc
+1
-0
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+26
-14
MBSlave.h
extensions/ModbusSlave/MBSlave.h
+1
-1
RRDServer.cc
extensions/RRDServer/RRDServer.cc
+2
-1
SharedMemory.h
extensions/SharedMemory/SharedMemory.h
+16
-16
UNetExchange.cc
extensions/UNetUDP/UNetExchange.cc
+1
-0
unet-udp-tester.cc
extensions/UNetUDP/unet-udp-tester.cc
+1
-0
UniExchange.cc
extensions/UniNetwork/UniExchange.cc
+1
-1
MTR.h
extensions/include/MTR.h
+1
-1
UObject_SK.h
extensions/include/UObject_SK.h
+120
-102
IOBase.cc
extensions/lib/IOBase.cc
+6
-6
MTR.cc
extensions/lib/MTR.cc
+6
-6
UObject_SK.cc
extensions/lib/UObject_SK.cc
+155
-138
LT_Object.h
include/LT_Object.h
+1
-1
Trigger.h
include/Trigger.h
+4
-1
UniSetManager.h
include/UniSetManager.h
+1
-1
UniSetObject.h
include/UniSetObject.h
+3
-3
UModbus.cc
python/lib/pyUniSet/UModbus.cc
+1
-1
ModbusClient.cc
src/Communications/Modbus/ModbusClient.cc
+1
-1
ModbusRTUSlave.cc
src/Communications/Modbus/ModbusRTUSlave.cc
+2
-1
ModbusServer.cc
src/Communications/Modbus/ModbusServer.cc
+12
-7
ModbusTCPCore.cc
src/Communications/Modbus/ModbusTCPCore.cc
+3
-3
ModbusTCPServer.cc
src/Communications/Modbus/ModbusTCPServer.cc
+1
-0
ModbusTCPSession.cc
src/Communications/Modbus/ModbusTCPSession.cc
+3
-2
ModbusTypes.cc
src/Communications/Modbus/ModbusTypes.cc
+2
-0
UTCPStream.cc
src/Communications/TCP/UTCPStream.cc
+1
-0
LogReader.cc
src/Log/LogReader.cc
+1
-1
LogServer.cc
src/Log/LogServer.cc
+1
-0
LogSession.cc
src/Log/LogSession.cc
+5
-2
UniSetActivator.cc
src/ObjectRepository/UniSetActivator.cc
+7
-0
UniSetObject.cc
src/ObjectRepository/UniSetObject.cc
+2
-0
Configuration.cc
src/Various/Configuration.cc
+1
-0
LT_Object.cc
src/Various/LT_Object.cc
+4
-2
RunLock.cc
src/Various/RunLock.cc
+1
-0
SMonitor.cc
src/Various/SMonitor.cc
+2
-1
VMonitor.cc
src/Various/VMonitor.cc
+23
-15
WDTInterface.cc
src/Various/WDTInterface.cc
+2
-0
test_pulse.cc
tests/test_pulse.cc
+1
-1
No files found.
Utilities/Admin/admin.cc
View file @
b2cf6d77
...
...
@@ -225,6 +225,7 @@ int main(int argc, char** argv)
ui
.
initBackId
(
UniSetTypes
::
AdminID
);
int
userparam
=
0
;
if
(
optind
<
argc
)
userparam
=
uni_atoi
(
argv
[
optind
]);
...
...
@@ -538,6 +539,7 @@ static void createSections( const std::shared_ptr<UniSetTypes::Configuration>& r
int
omap
()
{
std
::
ios_base
::
fmtflags
old_flags
=
cout
.
flags
();
try
{
cout
.
setf
(
ios
::
left
,
ios
::
adjustfield
);
...
...
Utilities/MBTester/MBTCPServer.cc
View file @
b2cf6d77
...
...
@@ -398,6 +398,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage&
int seek = query.numpacket * ModbusRTU::FileTransferRetMessage::MaxDataLen;
int ret = lseek(fd, seek, SEEK_SET);
if( ret < 0 )
{
close(fd);
...
...
Utilities/MBTester/mbrtuslave.cc
View file @
b2cf6d77
...
...
@@ -54,6 +54,7 @@ int main( int argc, char** argv )
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"hva:d:s:yc:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
...
...
Utilities/MBTester/mbrtutester.cc
View file @
b2cf6d77
...
...
@@ -127,6 +127,7 @@ int main( int argc, char** argv )
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"hva:w:z:m:r:x:c:b:d:s:t:qn:u:yl:t:o:e:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
...
...
Utilities/MBTester/mbslave.cc
View file @
b2cf6d77
...
...
@@ -51,8 +51,10 @@ int main( int argc, char** argv )
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"hva:d:s:c:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
switch
(
opt
)
{
case
'h'
:
...
...
@@ -90,9 +92,10 @@ int main( int argc, char** argv )
}
}
auto
avec
=
UniSetTypes
::
explode_str
(
myaddr
,
','
);
auto
avec
=
UniSetTypes
::
explode_str
(
myaddr
,
','
);
std
::
unordered_set
<
ModbusRTU
::
ModbusAddr
>
vaddr
;
for
(
const
auto
&
a
:
avec
)
for
(
const
auto
&
a
:
avec
)
vaddr
.
emplace
(
ModbusRTU
::
str2mbAddr
(
a
)
);
if
(
verb
)
...
...
Utilities/MBTester/mbtcpserver.cc
View file @
b2cf6d77
...
...
@@ -50,6 +50,7 @@ int main( int argc, char** argv )
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"hva:p:i:bc:"
,
longopts
,
&
optindex
);
if
(
opt
!=
-
1
)
break
;
...
...
@@ -86,9 +87,10 @@ int main( int argc, char** argv )
}
}
auto
avec
=
UniSetTypes
::
explode_str
(
myaddr
,
','
);
auto
avec
=
UniSetTypes
::
explode_str
(
myaddr
,
','
);
std
::
unordered_set
<
ModbusRTU
::
ModbusAddr
>
vaddr
;
for
(
const
auto
&
a
:
avec
)
for
(
const
auto
&
a
:
avec
)
vaddr
.
emplace
(
ModbusRTU
::
str2mbAddr
(
a
)
);
if
(
verb
)
...
...
Utilities/ULog/log-stdin.cc
View file @
b2cf6d77
...
...
@@ -39,6 +39,7 @@ int main( int argc, char* argv[], char* envp[] )
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"hvi:p:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
...
...
Utilities/ULog/log.cc
View file @
b2cf6d77
...
...
@@ -82,6 +82,7 @@ int main( int argc, char** argv )
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"chvlf:a:p:i:d:s:n:eorbx:w:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
...
...
Utilities/ULog/logserver.cc
View file @
b2cf6d77
...
...
@@ -51,6 +51,7 @@ int main( int argc, char** argv )
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"hvi:p:d:m:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
...
...
Utilities/codegen/tests/TestGen.cc
View file @
b2cf6d77
...
...
@@ -11,6 +11,7 @@ TestGen::TestGen( UniSetTypes::ObjectId id, xmlNode* confnode ):
vmonit
(
bool_var
);
long
*
i
=
valptr
(
input2_s
);
if
(
!
i
)
cerr
<<
"input2_s NOT FOUND!!!"
<<
endl
;
else
...
...
conf/libuniset2.spec
View file @
b2cf6d77
...
...
@@ -13,7 +13,7 @@
Name: libuniset2
Version: 2.2
Release: alt1
2
Release: alt1
3
Summary: UniSet - library for building distributed industrial control systems
...
...
@@ -451,6 +451,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Wed Dec 16 2015 Pavel Vainerman <pv@altlinux.ru> 2.2-alt13
- set public for UniSetObject::askTimer
* Mon Dec 14 2015 Pavel Vainerman <pv@altlinux.ru> 2.2-alt12
- refactoring: remove xxx_LT classes
- add new function for LT_Object
...
...
extensions/DBServer-PostgreSQL/PostgreSQLInterface.h
View file @
b2cf6d77
...
...
@@ -46,7 +46,7 @@ class PostgreSQLInterface
class
PostgreSQLResult
{
public
:
PostgreSQLResult
(){}
PostgreSQLResult
()
{}
explicit
PostgreSQLResult
(
const
pqxx
::
result
&
res
);
~
PostgreSQLResult
();
...
...
extensions/IOControl/IOControl.cc
View file @
b2cf6d77
...
...
@@ -24,7 +24,7 @@ std::ostream& operator<<( std::ostream& os, IOControl::IOInfo& inf )
// -----------------------------------------------------------------------------
IOControl
::
IOControl
(
UniSetTypes
::
ObjectId
id
,
UniSetTypes
::
ObjectId
icID
,
const
std
::
shared_ptr
<
SharedMemory
>&
ic
,
int
numcards
,
const
std
::
string
&
prefix_
)
:
const
std
::
shared_ptr
<
SharedMemory
>&
ic
,
int
numcards
,
const
std
::
string
&
prefix_
)
:
UniSetObject
(
id
),
polltime
(
150
),
cards
(
11
),
...
...
extensions/IOControl/iocalibr.cc
View file @
b2cf6d77
...
...
@@ -86,6 +86,7 @@ int main(int argc, char* argv[])
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"hr:s:d:a:x:o:f:n:i:c:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
...
...
@@ -196,6 +197,7 @@ int main(int argc, char* argv[])
cout
<<
"
\r
"
<<
"data: "
<<
setw
(
5
)
<<
data
<<
" "
<<
flush
;
ssize_t
temp
=
read
(
fd
,
&
buf
,
sizeof
(
buf
));
if
(
temp
==
-
1
)
{
close
(
fd
);
...
...
@@ -347,6 +349,7 @@ void readCalibr(int fixed)
close
(
f
);
return
;
}
if
(
temp
>
1
)
{
int
s
;
...
...
extensions/IOControl/iotest.cc
View file @
b2cf6d77
...
...
@@ -71,6 +71,7 @@ int main(int argc, char* argv[])
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"habvr:w:i:o:s:d:c:p:m:q:x:z:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
...
...
extensions/LogicProcessor/PassiveLProcessor.h
View file @
b2cf6d77
...
...
@@ -19,7 +19,7 @@ class PassiveLProcessor:
public
:
PassiveLProcessor
(
UniSetTypes
::
ObjectId
objId
,
UniSetTypes
::
ObjectId
shmID
,
const
std
::
shared_ptr
<
SharedMemory
>&
ic
=
nullptr
,
const
std
::
string
&
prefix
=
"lproc"
);
UniSetTypes
::
ObjectId
shmID
,
const
std
::
shared_ptr
<
SharedMemory
>&
ic
=
nullptr
,
const
std
::
string
&
prefix
=
"lproc"
);
virtual
~
PassiveLProcessor
();
enum
Timers
...
...
extensions/ModbusMaster/MBExchange.cc
View file @
b2cf6d77
...
...
@@ -14,7 +14,7 @@ using namespace UniSetTypes;
using
namespace
UniSetExtensions
;
// -----------------------------------------------------------------------------
MBExchange
::
MBExchange
(
UniSetTypes
::
ObjectId
objId
,
UniSetTypes
::
ObjectId
shmId
,
const
std
::
shared_ptr
<
SharedMemory
>&
_ic
,
const
std
::
string
&
prefix
)
:
const
std
::
shared_ptr
<
SharedMemory
>&
_ic
,
const
std
::
string
&
prefix
)
:
UniSetObject
(
objId
),
allInitOK
(
false
),
initPause
(
3000
),
...
...
@@ -270,6 +270,7 @@ void MBExchange::waitSMReady()
// waiting for SM is ready...
int
tout
=
uniset_conf
()
->
getArgInt
(
"--"
+
prefix
+
"-sm-ready-timeout"
,
"15000"
);
timeout_t
ready_timeout
=
15000
;
if
(
tout
>
0
)
ready_timeout
=
tout
;
else
if
(
tout
<
0
)
...
...
@@ -333,10 +334,11 @@ void MBExchange::sigterm( int signo )
{
mbwarn
<<
myname
<<
"SIGTERM("
<<
signo
<<
"): "
<<
ex
.
what
()
<<
endl
;
}
// {
// std::exception_ptr p = std::current_exception();
// std::clog <<(p ? p.__cxa_exception_type()->name() : "null") << std::endl;
// }
// {
// std::exception_ptr p = std::current_exception();
// std::clog <<(p ? p.__cxa_exception_type()->name() : "null") << std::endl;
// }
}
// ------------------------------------------------------------------------------------------
void
MBExchange
::
readConfiguration
()
...
...
@@ -405,9 +407,10 @@ void MBExchange::initIterators()
shm
->
initIterator
(
d
->
resp_it
);
shm
->
initIterator
(
d
->
mode_it
);
for
(
auto
&&
m
:
d
->
pollmap
)
for
(
auto
&&
m
:
d
->
pollmap
)
{
auto
&
regmap
=
m
.
second
;
for
(
auto
it
=
regmap
->
begin
();
it
!=
regmap
->
end
();
++
it
)
{
for
(
auto
it2
=
it
->
second
->
slst
.
begin
();
it2
!=
it
->
second
->
slst
.
end
();
++
it2
)
...
...
@@ -432,9 +435,10 @@ void MBExchange::initValues()
{
auto
d
=
it1
->
second
;
for
(
auto
&&
m
:
d
->
pollmap
)
for
(
auto
&&
m
:
d
->
pollmap
)
{
auto
regmap
=
m
.
second
;
for
(
auto
it
=
regmap
->
begin
();
it
!=
regmap
->
end
();
++
it
)
{
for
(
auto
it2
=
it
->
second
->
slst
.
begin
();
it2
!=
it
->
second
->
slst
.
end
();
++
it2
)
...
...
@@ -543,9 +547,9 @@ std::ostream& operator<<( std::ostream& os, MBExchange::RTUDevice& d )
os
<<
" regs: "
<<
endl
;
for
(
const
auto
&
m
:
d
.
pollmap
)
for
(
const
auto
&
m
:
d
.
pollmap
)
{
for
(
const
auto
&
it
:
*
(
m
.
second
)
)
for
(
const
auto
&
it
:
*
(
m
.
second
)
)
os
<<
" "
<<
it
.
second
<<
endl
;
}
...
...
@@ -581,11 +585,11 @@ void MBExchange::rtuQueryOptimization( RTUDeviceMap& dm )
mbinfo
<<
myname
<<
"(rtuQueryOptimization): optimization..."
<<
endl
;
for
(
auto
&&
it1
:
dm
)
for
(
auto
&&
it1
:
dm
)
{
auto
d
=
it1
.
second
;
for
(
auto
&&
m
:
d
->
pollmap
)
for
(
auto
&&
m
:
d
->
pollmap
)
{
auto
&
regmap
=
m
.
second
;
...
...
@@ -1184,7 +1188,7 @@ void MBExchange::updateSM()
}
for
(
auto
&&
m
:
d
->
pollmap
)
for
(
auto
&&
m
:
d
->
pollmap
)
{
auto
&
regmap
=
m
.
second
;
...
...
@@ -1242,7 +1246,7 @@ void MBExchange::updateRTU( RegMap::iterator& rit )
{
auto
&
r
=
rit
->
second
;
for
(
auto
&&
it
:
r
->
slst
)
for
(
auto
&&
it
:
r
->
slst
)
updateRSProperty
(
&
it
,
false
);
}
...
...
@@ -2375,10 +2379,11 @@ bool MBExchange::initItem( UniXML::iterator& it )
std
::
shared_ptr
<
RegMap
>
rmap
;
auto
rit
=
dev
->
pollmap
.
find
(
pollfactor
);
if
(
rit
==
dev
->
pollmap
.
end
()
)
{
rmap
=
make_shared
<
RegMap
>
();
dev
->
pollmap
.
emplace
(
pollfactor
,
rmap
);
dev
->
pollmap
.
emplace
(
pollfactor
,
rmap
);
}
else
rmap
=
rit
->
second
;
...
...
@@ -2933,9 +2938,10 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
if
(
force_out
)
return
;
for
(
auto
&&
m
:
d
->
pollmap
)
for
(
auto
&&
m
:
d
->
pollmap
)
{
auto
&
regmap
=
m
.
second
;
for
(
auto
it
=
regmap
->
begin
();
it
!=
regmap
->
end
();
++
it
)
{
if
(
!
isWriteFunction
(
it
->
second
->
mbfunc
)
)
...
...
@@ -2984,7 +2990,7 @@ void MBExchange::sensorInfo( const UniSetTypes::SensorMessage* sm )
{
auto
&&
regmap
=
m
.
second
;
for
(
const
auto
&
it
:
(
*
regmap
)
)
for
(
const
auto
&
it
:
(
*
regmap
)
)
{
if
(
!
isWriteFunction
(
it
.
second
->
mbfunc
)
)
continue
;
...
...
@@ -3062,9 +3068,9 @@ bool MBExchange::poll()
d
->
prev_numreply
.
store
(
d
->
numreply
);
for
(
auto
&&
m
:
d
->
pollmap
)
for
(
auto
&&
m
:
d
->
pollmap
)
{
if
(
m
.
first
>
1
&&
(
ncycle
%
m
.
first
)
!=
0
)
if
(
m
.
first
>
1
&&
(
ncycle
%
m
.
first
)
!=
0
)
continue
;
auto
&&
regmap
=
m
.
second
;
...
...
extensions/ModbusMaster/MBTCPMaster.cc
View file @
b2cf6d77
...
...
@@ -12,7 +12,7 @@ using namespace UniSetTypes;
using
namespace
UniSetExtensions
;
// -----------------------------------------------------------------------------
MBTCPMaster
::
MBTCPMaster
(
UniSetTypes
::
ObjectId
objId
,
UniSetTypes
::
ObjectId
shmId
,
const
std
::
shared_ptr
<
SharedMemory
>&
ic
,
const
std
::
string
&
prefix
)
:
const
std
::
shared_ptr
<
SharedMemory
>&
ic
,
const
std
::
string
&
prefix
)
:
MBExchange
(
objId
,
shmId
,
ic
,
prefix
),
force_disconnect
(
true
)
{
...
...
extensions/ModbusMaster/MBTCPMultiMaster.cc
View file @
b2cf6d77
...
...
@@ -451,11 +451,12 @@ void MBTCPMultiMaster::sigterm( int signo )
{
mbcrit
<<
myname
<<
"(sigterm): "
<<
ex
.
what
()
<<
std
::
endl
;
}
// catch( ... )
// {
// std::exception_ptr p = std::current_exception();
// std::clog << (p ? p.__cxa_exception_type()->name() : "null") << std::endl;
// }
// catch( ... )
// {
// std::exception_ptr p = std::current_exception();
// std::clog << (p ? p.__cxa_exception_type()->name() : "null") << std::endl;
// }
}
// -----------------------------------------------------------------------------
...
...
@@ -508,7 +509,7 @@ const std::string MBTCPMultiMaster::MBSlaveInfo::getShortInfo() const
s
<<
myname
<<
" respond="
<<
respond
<<
" (respond_id="
<<
respond_id
<<
" respond_invert="
<<
respond_invert
<<
" recv_timeout="
<<
recv_timeout
<<
" resp_force="
<<
respond_force
<<
" use="
<<
use
<<
" ignore="
<<
ignore
<<
" priority="
<<
priority
<<
" use="
<<
use
<<
" ignore="
<<
ignore
<<
" priority="
<<
priority
<<
" persistent-connection="
<<
!
force_disconnect
<<
")"
;
...
...
extensions/ModbusMaster/RTUExchange.cc
View file @
b2cf6d77
...
...
@@ -10,7 +10,7 @@ using namespace UniSetTypes;
using
namespace
UniSetExtensions
;
// -----------------------------------------------------------------------------
RTUExchange
::
RTUExchange
(
UniSetTypes
::
ObjectId
objId
,
UniSetTypes
::
ObjectId
shmId
,
const
std
::
shared_ptr
<
SharedMemory
>&
ic
,
const
std
::
string
&
prefix_
)
:
const
std
::
string
&
prefix_
)
:
MBExchange
(
objId
,
shmId
,
ic
,
prefix_
),
mbrtu
(
0
),
defSpeed
(
ComPort
::
ComSpeed38400
),
...
...
@@ -251,14 +251,14 @@ bool RTUExchange::poll()
dlog3
<<
myname
<<
"(poll): ask addr="
<<
ModbusRTU
::
addr2str
(
d
->
mbaddr
)
<<
" regs="
<<
d
->
pollmap
.
size
()
<<
endl
;
for
(
auto
&&
m
:
d
->
pollmap
)
for
(
auto
&&
m
:
d
->
pollmap
)
{
if
(
m
.
first
!=
0
&&
(
ncycle
%
m
.
first
)
!=
0
)
if
(
m
.
first
!=
0
&&
(
ncycle
%
m
.
first
)
!=
0
)
continue
;
auto
rmap
=
m
.
second
;
for
(
auto
&&
it
=
rmap
->
begin
();
it
!=
rmap
->
end
();
++
it
)
for
(
auto
&&
it
=
rmap
->
begin
();
it
!=
rmap
->
end
();
++
it
)
{
try
{
...
...
extensions/ModbusMaster/RTUStorage.cc
View file @
b2cf6d77
...
...
@@ -132,8 +132,10 @@ void RTUStorage::poll( const std::shared_ptr<ModbusRTUMaster>& mb ) throw( Modbu
for
(
unsigned
int
i
=
0
;
i
<
8
;
i
++
)
{
int
k
=
i
+
8
*
b
;
if
(
k
>=
48
)
if
(
k
>=
48
)
break
;
unio_do
[
k
]
=
bits
[
i
];
}
}
...
...
@@ -152,8 +154,10 @@ void RTUStorage::poll( const std::shared_ptr<ModbusRTUMaster>& mb ) throw( Modbu
for
(
unsigned
int
i
=
0
;
i
<
8
;
i
++
)
{
int
k
=
i
+
8
*
b
;
if
(
k
>=
48
)
if
(
k
>=
48
)
break
;
unio_di
[
k
]
=
bits
[
i
];
}
}
...
...
extensions/ModbusMaster/mtr-read.cc
View file @
b2cf6d77
...
...
@@ -79,6 +79,7 @@ int main( int argc, char** argv )
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"hvyq:r:d:s:t:x:m:n:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
...
...
extensions/ModbusMaster/mtr-setup.cc
View file @
b2cf6d77
...
...
@@ -105,6 +105,7 @@ int main( int argc, char** argv )
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"hvw:r:x:d:s:t:l:n:yb:e:x:z:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
...
...
extensions/ModbusMaster/rtustate.cc
View file @
b2cf6d77
...
...
@@ -47,6 +47,7 @@ int main( int argc, char** argv )
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"hva:d:s:t:q:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
...
...
extensions/ModbusMaster/tests/MBTCPTestServer.cc
View file @
b2cf6d77
...
...
@@ -483,6 +483,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::fileTransfer( ModbusRTU::FileTransferMessa
int seek = query.numpacket * ModbusRTU::FileTransferRetMessage::MaxDataLen;
int ret = lseek(fd, seek, SEEK_SET);
if( ret < 0 )
{
close(fd);
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
b2cf6d77
...
...
@@ -217,7 +217,7 @@ MBSlave::MBSlave(UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, const
{
readConfiguration
();
mbinfo
<<
myname
<<
"(init): iomap size = "
<<
iomap
.
size
()
<<
" myaddr="
<<
ModbusServer
::
vaddr2str
(
vaddr
)
<<
endl
;
<<
" myaddr="
<<
ModbusServer
::
vaddr2str
(
vaddr
)
<<
endl
;
}
else
{
...
...
@@ -463,6 +463,7 @@ void MBSlave::waitSMReady()
// waiting for SM is ready...
int
tout
=
uniset_conf
()
->
getArgInt
(
"--"
+
prefix
+
"-sm-ready-timeout"
,
"15000"
);
timeout_t
ready_timeout
=
15000
;
if
(
tout
>
0
)
ready_timeout
=
tout
;
else
if
(
tout
<
0
)
...
...
@@ -491,6 +492,7 @@ void MBSlave::execute_rtu()
if
(
!
shm
->
isLocalwork
()
)
{
std
::
unique_lock
<
std
::
mutex
>
locker
(
mutexStartNotify
);
while
(
!
activated
)
startNotifyEvent
.
wait
(
locker
);
}
...
...
@@ -503,8 +505,8 @@ void MBSlave::execute_rtu()
}
mbinfo
<<
myname
<<
"(execute_rtu): thread running.."
<<
" iomap size = "
<<
iomap
.
size
()
<<
" myaddr="
<<
ModbusServer
::
vaddr2str
(
vaddr
)
<<
" iomap size = "
<<
iomap
.
size
()
<<
" myaddr="
<<
ModbusServer
::
vaddr2str
(
vaddr
)
<<
endl
;
while
(
!
cancelled
)
...
...
@@ -577,9 +579,9 @@ void MBSlave::execute_rtu()
}
}
for
(
auto
&&
rmap
:
iomap
)
for
(
auto
&&
rmap
:
iomap
)
{
for
(
auto
&&
it
:
rmap
.
second
)
for
(
auto
&&
it
:
rmap
.
second
)
IOBase
::
processingThreshold
(
&
it
.
second
,
shm
,
force
);
}
}
...
...
@@ -598,6 +600,7 @@ void MBSlave::execute_tcp()
if
(
!
shm
->
isLocalwork
()
)
{
std
::
unique_lock
<
std
::
mutex
>
locker
(
mutexStartNotify
);
while
(
!
activated
)
startNotifyEvent
.
wait
(
locker
);
}
...
...
@@ -610,8 +613,8 @@ void MBSlave::execute_tcp()
}
mbinfo
<<
myname
<<
"(execute_tcp): thread running.."
<<
" iomap size = "
<<
iomap
.
size
()
<<
" myaddr="
<<
ModbusServer
::
vaddr2str
(
vaddr
)
<<
" iomap size = "
<<
iomap
.
size
()
<<
" myaddr="
<<
ModbusServer
::
vaddr2str
(
vaddr
)
<<
endl
;
while
(
!
cancelled
)
...
...
@@ -685,9 +688,9 @@ void MBSlave::execute_tcp()
}
}
for
(
auto
&&
rmap
:
iomap
)
for
(
auto
&&
rmap
:
iomap
)
{
for
(
auto
&&
it
:
rmap
.
second
)
for
(
auto
&&
it
:
rmap
.
second
)
IOBase
::
processingThreshold
(
&
it
.
second
,
shm
,
force
);
}
}
...
...
@@ -802,7 +805,7 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd )
if
(
force
)
return
;
for
(
const
auto
&
rmap
:
iomap
)
for
(
const
auto
&
rmap
:
iomap
)
{
for
(
const
auto
&
it
:
rmap
.
second
)
{
...
...
@@ -823,10 +826,11 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd )
// ------------------------------------------------------------------------------------------
void
MBSlave
::
sensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
)
{
for
(
auto
&&
regs
:
iomap
)
for
(
auto
&&
regs
:
iomap
)
{
auto
&
rmap
=
regs
.
second
;
for
(
auto
it
=
rmap
.
begin
();
it
!=
rmap
.
end
();
++
it
)
for
(
auto
it
=
rmap
.
begin
();
it
!=
rmap
.
end
();
++
it
)
{
if
(
it
->
second
.
si
.
id
==
sm
->
id
)
{
...
...
@@ -1229,7 +1233,7 @@ bool MBSlave::BitRegProperty::check( const IOController_i::SensorInfo& si )
// ------------------------------------------------------------------------------------------
void
MBSlave
::
initIterators
()
{
for
(
auto
&&
regs
:
iomap
)
for
(
auto
&&
regs
:
iomap
)
{
auto
&
rmap
=
regs
.
second
;
...
...
@@ -1377,6 +1381,7 @@ ModbusRTU::mbErrCode MBSlave::readOutputRegisters( ModbusRTU::ReadOutputMessage&
mbinfo
<<
myname
<<
"(readOutputRegisters): "
<<
query
<<
endl
;
auto
regmap
=
iomap
.
find
(
query
.
addr
);
if
(
regmap
==
iomap
.
end
()
)
{
mbinfo
<<
myname
<<
"(readOutputRegisters): Unknown addr="
<<
ModbusRTU
::
addr2str
(
query
.
addr
)
<<
endl
;
...
...
@@ -1415,6 +1420,7 @@ ModbusRTU::mbErrCode MBSlave::writeOutputRegisters( ModbusRTU::WriteOutputMessag
mbinfo
<<
myname
<<
"(writeOutputRegisters): "
<<
query
<<
endl
;
auto
regmap
=
iomap
.
find
(
query
.
addr
);
if
(
regmap
==
iomap
.
end
()
)
{
mbinfo
<<
myname
<<
"(writeOutputRegisters): Unknown addr="
<<
ModbusRTU
::
addr2str
(
query
.
addr
)
<<
endl
;
...
...
@@ -1437,6 +1443,7 @@ ModbusRTU::mbErrCode MBSlave::writeOutputSingleRegister( ModbusRTU::WriteSingleO
mbinfo
<<
myname
<<
"(writeOutputSingleRegisters): "
<<
query
<<
endl
;
auto
regmap
=
iomap
.
find
(
query
.
addr
);
if
(
regmap
==
iomap
.
end
()
)
{
mbinfo
<<
myname
<<
"(writeOutputRegisters): Unknown addr="
<<
ModbusRTU
::
addr2str
(
query
.
addr
)
<<
endl
;
...
...
@@ -2046,6 +2053,7 @@ mbErrCode MBSlave::readInputRegisters( ReadInputMessage& query, ReadInputRetMess
mbinfo
<<
myname
<<
"(readInputRegisters): "
<<
query
<<
endl
;
auto
regmap
=
iomap
.
find
(
query
.
addr
);
if
(
regmap
==
iomap
.
end
()
)
{
mbinfo
<<
myname
<<
"(readInputRegisters): Unknown addr="
<<
ModbusRTU
::
addr2str
(
query
.
addr
)
<<
endl
;
...
...
@@ -2110,6 +2118,7 @@ ModbusRTU::mbErrCode MBSlave::readCoilStatus( ReadCoilMessage& query,
mbinfo
<<
myname
<<
"(readCoilStatus): "
<<
query
<<
endl
;
auto
regmap
=
iomap
.
find
(
query
.
addr
);
if
(
regmap
==
iomap
.
end
()
)
{
mbinfo
<<
myname
<<
"(readCoilStatus): Unknown addr="
<<
ModbusRTU
::
addr2str
(
query
.
addr
)
<<
endl
;
...
...
@@ -2121,7 +2130,7 @@ ModbusRTU::mbErrCode MBSlave::readCoilStatus( ReadCoilMessage& query,
if
(
query
.
count
<=
1
)
{
ModbusRTU
::
ModbusData
d
=
0
;
ModbusRTU
::
mbErrCode
ret
=
real_read
(
regmap
->
second
,
query
.
start
,
d
,
query
.
func
);
ModbusRTU
::
mbErrCode
ret
=
real_read
(
regmap
->
second
,
query
.
start
,
d
,
query
.
func
);
reply
.
addData
(
0
);
if
(
ret
==
ModbusRTU
::
erNoError
)
...
...
@@ -2182,6 +2191,7 @@ ModbusRTU::mbErrCode MBSlave::readInputStatus( ReadInputStatusMessage& query,
mbinfo
<<
myname
<<
"(readInputStatus): "
<<
query
<<
endl
;
auto
regmap
=
iomap
.
find
(
query
.
addr
);
if
(
regmap
==
iomap
.
end
()
)
{
mbinfo
<<
myname
<<
"(readInputStatus): Unknown addr="
<<
ModbusRTU
::
addr2str
(
query
.
addr
)
<<
endl
;
...
...
@@ -2254,6 +2264,7 @@ ModbusRTU::mbErrCode MBSlave::forceMultipleCoils( ModbusRTU::ForceCoilsMessage&
mbinfo
<<
myname
<<
"(forceMultipleCoils): "
<<
query
<<
endl
;
auto
regmap
=
iomap
.
find
(
query
.
addr
);
if
(
regmap
==
iomap
.
end
()
)
{
mbinfo
<<
myname
<<
"(forceMultipleCoils): Unknown addr="
<<
ModbusRTU
::
addr2str
(
query
.
addr
)
<<
endl
;
...
...
@@ -2290,6 +2301,7 @@ ModbusRTU::mbErrCode MBSlave::forceSingleCoil( ModbusRTU::ForceSingleCoilMessage
mbinfo
<<
myname
<<
"(forceSingleCoil): "
<<
query
<<
endl
;
auto
regmap
=
iomap
.
find
(
query
.
addr
);
if
(
regmap
==
iomap
.
end
()
)
{
mbinfo
<<
myname
<<
"(forceSingleCoil): Unknown addr="
<<
ModbusRTU
::
addr2str
(
query
.
addr
)
<<
endl
;
...
...
extensions/ModbusSlave/MBSlave.h
View file @
b2cf6d77
...
...
@@ -439,7 +439,7 @@ class MBSlave:
// то использовать unordered_map нельзя
typedef
std
::
map
<
ModbusRTU
::
RegID
,
IOProperty
>
RegMap
;
typedef
std
::
unordered_map
<
ModbusRTU
::
ModbusAddr
,
RegMap
>
IOMap
;
typedef
std
::
unordered_map
<
ModbusRTU
::
ModbusAddr
,
RegMap
>
IOMap
;
IOMap
iomap
;
/*!< список входов/выходов по адресам */
...
...
extensions/RRDServer/RRDServer.cc
View file @
b2cf6d77
...
...
@@ -12,7 +12,7 @@ using namespace UniSetTypes;
using
namespace
UniSetExtensions
;
// -----------------------------------------------------------------------------
RRDServer
::
RRDServer
(
UniSetTypes
::
ObjectId
objId
,
xmlNode
*
cnode
,
UniSetTypes
::
ObjectId
shmId
,
const
std
::
shared_ptr
<
SharedMemory
>&
ic
,
const
string
&
prefix
)
:
const
string
&
prefix
)
:
UObject_SK
(
objId
,
cnode
,
string
(
prefix
+
"-"
)),
prefix
(
prefix
)
{
...
...
@@ -156,6 +156,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
}
std
::
string
dsname
(
it1
.
getProp
(
ds
));
if
(
dsname
.
empty
()
)
dsname
=
it1
.
getProp
(
"name"
);
...
...
extensions/SharedMemory/SharedMemory.h
View file @
b2cf6d77
...
...
@@ -415,26 +415,26 @@ class SharedMemory:
class
HeartBeatInfo
{
public
:
HeartBeatInfo
()
:
a_sid
(
UniSetTypes
::
DefaultObjectId
),
d_sid
(
UniSetTypes
::
DefaultObjectId
),
reboot_msec
(
UniSetTimer
::
WaitUpTime
),
timer_running
(
false
),
ptReboot
(
UniSetTimer
::
WaitUpTime
)
{}
UniSetTypes
::
ObjectId
a_sid
;
// аналоговый счётчик
UniSetTypes
::
ObjectId
d_sid
;
// дискретный датчик состояния процесса
IOStateList
::
iterator
a_it
;
IOStateList
::
iterator
d_it
;
timeout_t
reboot_msec
;
/*!< Время в течение которого процесс обязан подтвердить своё существование,
HeartBeatInfo
()
:
a_sid
(
UniSetTypes
::
DefaultObjectId
),
d_sid
(
UniSetTypes
::
DefaultObjectId
),
reboot_msec
(
UniSetTimer
::
WaitUpTime
),
timer_running
(
false
),
ptReboot
(
UniSetTimer
::
WaitUpTime
)
{}
UniSetTypes
::
ObjectId
a_sid
;
// аналоговый счётчик
UniSetTypes
::
ObjectId
d_sid
;
// дискретный датчик состояния процесса
IOStateList
::
iterator
a_it
;
IOStateList
::
iterator
d_it
;
timeout_t
reboot_msec
;
/*!< Время в течение которого процесс обязан подтвердить своё существование,
иначе будет произведена перезагрузка контроллера по WDT (в случае если он включён).
Если данный параметр не указывать, то "не живость" процесса просто игнорируется
(т.е. только сброс датчика heartbeat (d_sid) в ноль). */
bool
timer_running
;
PassiveTimer
ptReboot
;
bool
timer_running
;
PassiveTimer
ptReboot
;
};
enum
Timers
...
...
extensions/UNetUDP/UNetExchange.cc
View file @
b2cf6d77
...
...
@@ -457,6 +457,7 @@ void UNetExchange::waitSMReady()
int
tout
=
uniset_conf
()
->
getArgInt
(
"--unet-sm-ready-timeout"
,
"15000"
);
timeout_t
ready_timeout
=
15000
;
if
(
tout
>
0
)
ready_timeout
=
tout
;
else
if
(
tout
<
0
)
...
...
extensions/UNetUDP/unet-udp-tester.cc
View file @
b2cf6d77
...
...
@@ -76,6 +76,7 @@ int main(int argc, char* argv[])
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"hs:c:r:p:n:t:x:blvdz:y:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
...
...
extensions/UniNetwork/UniExchange.cc
View file @
b2cf6d77
...
...
@@ -18,7 +18,7 @@ UniExchange::NetNodeInfo::NetNodeInfo():
}
// --------------------------------------------------------------------------
UniExchange
::
UniExchange
(
UniSetTypes
::
ObjectId
id
,
UniSetTypes
::
ObjectId
shmID
,
const
std
::
shared_ptr
<
SharedMemory
>&
ic
,
const
std
::
string
&
prefix
)
:
const
std
::
shared_ptr
<
SharedMemory
>&
ic
,
const
std
::
string
&
prefix
)
:
IOController
(
id
),
polltime
(
200
),
mymap
(
1
),
...
...
extensions/include/MTR.h
View file @
b2cf6d77
...
...
@@ -296,7 +296,7 @@ namespace MTR
val
=
raw
.
u2
.
val
*
pow
(
(
long
)
10
,
(
long
)
raw
.
u2
.
exp
);
}
T5
(
const
ModbusRTU
::
ModbusData
*
data
,
int
size
)
:
val
(
0
)
T5
(
const
ModbusRTU
::
ModbusData
*
data
,
int
size
)
:
val
(
0
)
{
if
(
size
>=
u2size
)
{
...
...
extensions/include/UObject_SK.h
View file @
b2cf6d77
...
...
@@ -3,10 +3,10 @@
/*
DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
ALL YOUR CHANGES WILL BE LOST.
НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-12-15+03:00
// -----------------------------------------------------------------------------
...
...
@@ -29,11 +29,11 @@ class UObject_SK:
public
UniSetObject
{
public
:
UObject_SK
(
UniSetTypes
::
ObjectId
id
,
xmlNode
*
node
=
UniSetTypes
::
uniset_conf
()
->
getNode
(
"UObject"
),
const
std
::
string
&
argprefix
=
""
);
UObject_SK
(
UniSetTypes
::
ObjectId
id
,
xmlNode
*
node
=
UniSetTypes
::
uniset_conf
()
->
getNode
(
"UObject"
),
const
std
::
string
&
argprefix
=
""
);
UObject_SK
();
virtual
~
UObject_SK
();
long
getValue
(
UniSetTypes
::
ObjectId
sid
);
void
setValue
(
UniSetTypes
::
ObjectId
sid
,
long
value
);
void
askSensor
(
UniSetTypes
::
ObjectId
sid
,
UniversalIO
::
UIOCommand
,
UniSetTypes
::
ObjectId
node
=
UniSetTypes
::
uniset_conf
()
->
getLocalNode
()
);
...
...
@@ -43,116 +43,128 @@ class UObject_SK:
virtual
bool
setMsg
(
UniSetTypes
::
ObjectId
code
,
bool
state
=
true
);
inline
std
::
shared_ptr
<
DebugStream
>
log
(){
return
mylog
;
}
inline
std
::
shared_ptr
<
LogAgregator
>
logAgregator
(){
return
loga
;
}
inline
std
::
shared_ptr
<
DebugStream
>
log
()
{
return
mylog
;
}
inline
std
::
shared_ptr
<
LogAgregator
>
logAgregator
()
{
return
loga
;
}
void
init_dlog
(
std
::
shared_ptr
<
DebugStream
>
d
);
// "синтаксический сахар"..для логов
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#ifndef mylogany
#define mylogany log()->any()
#endif
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
// Вспомогательные функции для удобства логирования
// ------------------------------------------------------------
/*! вывод в строку значение всех входов и выходов в формате
ObjectName:
in_xxx = val
in_xxx2 = val
out_zzz = val
...
*/
std
::
string
dumpIO
();
/*! Вывод в строку названия входа/выхода в формате: in_xxx(SensorName)
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
str
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
strval
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
/*! Вывод состояния внутренних переменных */
inline
std
::
string
dumpVars
(){
return
std
::
move
(
vmon
.
pretty_str
());
}
// ------------------------------------------------------------
std
::
string
help
();
// "синтаксический сахар"..для логов
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#ifndef mylogany
#define mylogany log()->any()
#endif
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
// Вспомогательные функции для удобства логирования
// ------------------------------------------------------------
/*! вывод в строку значение всех входов и выходов в формате
ObjectName:
in_xxx = val
in_xxx2 = val
out_zzz = val
...
*/
std
::
string
dumpIO
();
/*! Вывод в строку названия входа/выхода в формате: in_xxx(SensorName)
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
str
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
strval
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
/*! Вывод состояния внутренних переменных */
inline
std
::
string
dumpVars
()
{
return
std
::
move
(
vmon
.
pretty_str
());
}
// ------------------------------------------------------------
std
::
string
help
();
// Используемые идентификаторы
// Используемые идентификаторы сообщений
// Текущее значение
// --- public variables ---
// --- end of public variables ---
protected
:
// --- protected variables ---
// ---- end of protected variables ----
virtual
void
callback
()
override
;
virtual
void
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
)
override
;
virtual
void
sysCommand
(
const
UniSetTypes
::
SystemMessage
*
sm
){};
virtual
void
askSensors
(
UniversalIO
::
UIOCommand
cmd
){}
virtual
void
sensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
)
override
{}
virtual
void
timerInfo
(
const
UniSetTypes
::
TimerMessage
*
tm
)
override
{}
virtual
void
sysCommand
(
const
UniSetTypes
::
SystemMessage
*
sm
)
{};
virtual
void
askSensors
(
UniversalIO
::
UIOCommand
cmd
)
{}
virtual
void
sensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
)
override
{}
virtual
void
timerInfo
(
const
UniSetTypes
::
TimerMessage
*
tm
)
override
{}
virtual
void
sigterm
(
int
signo
)
override
;
virtual
bool
activateObject
()
override
;
virtual
std
::
string
getMonitInfo
(){
return
""
;
}
/*!< пользовательская информация выводимая в getInfo() */
virtual
std
::
string
getMonitInfo
()
{
return
""
;
/*!< пользовательская информация выводимая в getInfo() */
}
virtual
void
testMode
(
bool
state
);
void
updatePreviousValues
();
void
checkSensors
();
...
...
@@ -171,7 +183,7 @@ class UObject_SK:
int
resetMsgTime
;
// Выполнение очередного шага программы
virtual
void
step
(){}
virtual
void
step
()
{}
int
sleep_msec
;
/*!< пауза между итерациями */
bool
active
;
...
...
@@ -183,22 +195,28 @@ class UObject_SK:
PassiveTimer
ptHeartBeat
;
/*! < период "сердцебиения" */
UniSetTypes
::
ObjectId
idHeartBeat
;
/*! < идентификатор датчика (AI) "сердцебиения" */
int
maxHeartBeat
;
/*! < сохраняемое значение */
xmlNode
*
confnode
;
/*! получить числовое свойство из конф. файла по привязанной confnode */
int
getIntProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
uniset_conf
()
->
getIntProp
(
confnode
,
name
);
}
int
getIntProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
uniset_conf
()
->
getIntProp
(
confnode
,
name
);
}
/*! получить текстовое свойство из конф. файла по привязанной confnode */
inline
const
std
::
string
getProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
uniset_conf
()
->
getProp
(
confnode
,
name
);
}
inline
const
std
::
string
getProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
uniset_conf
()
->
getProp
(
confnode
,
name
);
}
timeout_t
smReadyTimeout
;
/*!< время ожидания готовности SM */
std
::
atomic_bool
activated
;
timeout_t
activateTimeout
;
/*!< время ожидания готовности UniSetObject к работе */
PassiveTimer
ptStartUpTimeout
;
/*!< время на блокировку обработки WatchDog, если недавно был StartUp */
int
askPause
;
/*!< пауза между неудачными попытками заказать датчики */
IOController_i
::
SensorInfo
si
;
bool
forceOut
;
/*!< флаг принудительного обноления "выходов" */
std
::
shared_ptr
<
LogAgregator
>
loga
;
std
::
shared_ptr
<
DebugStream
>
mylog
;
std
::
shared_ptr
<
LogServer
>
logserv
;
...
...
@@ -207,20 +225,20 @@ class UObject_SK:
// snap
bool
no_snap
=
{
false
};
VMonitor
vmon
;
private
:
// --- private variables ---
// --- end of private variables ---
// предыдущее значение (для работы UpdateValue())
// Используемые идентификаторы сообщений
bool
end_private
;
// вспомогательное поле (для внутреннего использования при генерировании кода)
};
...
...
extensions/lib/IOBase.cc
View file @
b2cf6d77
...
...
@@ -579,12 +579,12 @@ bool IOBase::initItem( IOBase* b, UniXML::iterator& it, const std::shared_ptr<SM
&&
d_on_msec
!=
UniSetTimer
::
WaitUpTime
&&
d_off_msec
!=
UniSetTimer
::
WaitUpTime
)
{
dlog
->
warn
()
<<
myname
<<
"(IOBase::readItem): "
<<
" 'debouncedelay' is used in conjunction with the 'ondelay' and 'offdelay'. Sure?"
<<
" [ debouncedelay="
<<
d_msec
<<
" ondelay="
<<
d_on_msec
<<
" offdelay="
<<
d_off_msec
<<
" ]"
<<
endl
;
dlog
->
warn
()
<<
myname
<<
"(IOBase::readItem): "
<<
" 'debouncedelay' is used in conjunction with the 'ondelay' and 'offdelay'. Sure?"
<<
" [ debouncedelay="
<<
d_msec
<<
" ondelay="
<<
d_on_msec
<<
" offdelay="
<<
d_off_msec
<<
" ]"
<<
endl
;
}
...
...
extensions/lib/MTR.cc
View file @
b2cf6d77
...
...
@@ -614,8 +614,8 @@ namespace MTR
{
std
::
ios_base
::
fmtflags
old_flags
=
os
.
flags
();
os
<<
setfill
(
'0'
)
<<
hex
<<
setw
(
2
)
<<
t
.
hour
()
<<
":"
<<
setw
(
2
)
<<
t
.
min
()
<<
" "
<<
setw
(
2
)
<<
t
.
day
()
<<
"/"
<<
setw
(
2
)
<<
t
.
mon
();
<<
setw
(
2
)
<<
t
.
hour
()
<<
":"
<<
setw
(
2
)
<<
t
.
min
()
<<
" "
<<
setw
(
2
)
<<
t
.
day
()
<<
"/"
<<
setw
(
2
)
<<
t
.
mon
();
os
.
setf
(
old_flags
);
return
os
;
}
...
...
@@ -623,8 +623,8 @@ namespace MTR
{
std
::
ios_base
::
fmtflags
old_flags
=
os
.
flags
();
os
<<
setfill
(
'0'
)
<<
hex
<<
setw
(
2
)
<<
t
.
hour
()
<<
":"
<<
setw
(
2
)
<<
t
.
min
()
<<
":"
<<
setw
(
2
)
<<
t
.
sec
()
<<
"."
<<
setw
(
2
)
<<
t
.
ssec
();
<<
setw
(
2
)
<<
t
.
hour
()
<<
":"
<<
setw
(
2
)
<<
t
.
min
()
<<
":"
<<
setw
(
2
)
<<
t
.
sec
()
<<
"."
<<
setw
(
2
)
<<
t
.
ssec
();
os
.
setf
(
old_flags
);
return
os
;
}
...
...
@@ -632,8 +632,8 @@ namespace MTR
{
std
::
ios_base
::
fmtflags
old_flags
=
os
.
flags
();
os
<<
setfill
(
'0'
)
<<
dec
<<
setw
(
4
)
<<
t
.
year
()
<<
"/"
<<
setw
(
2
)
<<
t
.
mon
()
<<
"/"
<<
setw
(
2
)
<<
t
.
day
();
<<
setw
(
4
)
<<
t
.
year
()
<<
"/"
<<
setw
(
2
)
<<
t
.
mon
()
<<
"/"
<<
setw
(
2
)
<<
t
.
day
();
os
.
setf
(
old_flags
);
return
os
;
}
...
...
extensions/lib/UObject_SK.cc
View file @
b2cf6d77
...
...
@@ -6,10 +6,10 @@
/*
DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
ALL YOUR CHANGES WILL BE LOST.
НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-12-15+03:00
// -----------------------------------------------------------------------------
...
...
@@ -32,26 +32,26 @@ using namespace UniSetTypes;
// -----------------------------------------------------------------------------
UObject_SK
::
UObject_SK
()
:
// Инициализация идентификаторов (имена берутся из конф. файла)
// Инициализация идентификаторов (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// variables
// variables
active
(
false
),
active
(
false
),
idHeartBeat
(
DefaultObjectId
),
maxHeartBeat
(
10
),
confnode
(
0
),
smReadyTimeout
(
0
),
activated
(
false
),
askPause
(
2000
),
forceOut
(
false
),
idHeartBeat
(
DefaultObjectId
),
maxHeartBeat
(
10
),
confnode
(
0
),
smReadyTimeout
(
0
),
activated
(
false
),
askPause
(
2000
),
forceOut
(
false
),
end_private
(
false
)
end_private
(
false
)
{
ucrit
<<
"UObject: init failed!!!!!!!!!!!!!!!"
<<
endl
;
throw
Exception
(
string
(
myname
+
": init failed!!!"
)
);
throw
Exception
(
string
(
myname
+
": init failed!!!"
)
);
}
// -----------------------------------------------------------------------------
// ( val, confval, default val )
...
...
@@ -59,41 +59,42 @@ static const std::string init3_str( const std::string& s1, const std::string& s2
{
if
(
!
s1
.
empty
()
)
return
s1
;
if
(
!
s2
.
empty
()
)
return
s2
;
return
s3
;
}
// -----------------------------------------------------------------------------
UObject_SK
::
UObject_SK
(
ObjectId
id
,
xmlNode
*
cnode
,
const
std
::
string
&
_argprefix
)
:
UniSetObject
(
id
),
// Инициализация идентификаторов (имена берутся из конф. файла)
UniSetObject
(
id
),
// Инициализация идентификаторов (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// variables
// variables
sleep_msec
(
150
),
active
(
true
),
argprefix
(
(
_argprefix
.
empty
()
?
myname
+
"-"
:
_argprefix
)
),
sleep_msec
(
150
),
active
(
true
),
argprefix
(
(
_argprefix
.
empty
()
?
myname
+
"-"
:
_argprefix
)
),
idHeartBeat
(
DefaultObjectId
),
maxHeartBeat
(
10
),
confnode
(
cnode
),
smReadyTimeout
(
0
),
activated
(
false
),
askPause
(
uniset_conf
()
->
getPIntProp
(
cnode
,
"askPause"
,
2000
)),
forceOut
(
false
),
idHeartBeat
(
DefaultObjectId
),
maxHeartBeat
(
10
),
confnode
(
cnode
),
smReadyTimeout
(
0
),
activated
(
false
),
askPause
(
uniset_conf
()
->
getPIntProp
(
cnode
,
"askPause"
,
2000
)),
forceOut
(
false
),
end_private
(
false
)
end_private
(
false
)
{
auto
conf
=
uniset_conf
();
if
(
UniSetTypes
::
findArgParam
(
"--print-id-list"
,
uniset_conf
()
->
getArgc
(),
uniset_conf
()
->
getArgv
())
!=
-
1
)
if
(
UniSetTypes
::
findArgParam
(
"--print-id-list"
,
uniset_conf
()
->
getArgc
(),
uniset_conf
()
->
getArgv
())
!=
-
1
)
{
// abort();
// abort();
}
...
...
@@ -104,15 +105,15 @@ end_private(false)
throw
SystemError
(
err
.
str
()
);
}
mylog
=
make_shared
<
DebugStream
>
();
mylog
=
make_shared
<
DebugStream
>
();
mylog
->
setLogName
(
myname
);
{
ostringstream
s
;
s
<<
argprefix
<<
"log"
;
conf
->
initLogStream
(
mylog
,
s
.
str
());
conf
->
initLogStream
(
mylog
,
s
.
str
());
}
loga
=
make_shared
<
LogAgregator
>
(
myname
+
"-loga"
);
loga
=
make_shared
<
LogAgregator
>
(
myname
+
"-loga"
);
loga
->
add
(
mylog
);
loga
->
add
(
ulog
());
...
...
@@ -129,13 +130,15 @@ end_private(false)
logserv_host
=
conf
->
getArg2Param
(
"--"
+
argprefix
+
"logserver-host"
,
it
.
getProp
(
"logserverHost"
),
"localhost"
);
logserv_port
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"logserver-port"
,
it
.
getProp
(
"logserverPort"
),
getId
());
}
forceOut
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"force-out"
,
it
.
getProp
(
"forceOut"
),
false
);
string
heart
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
));
forceOut
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"force-out"
,
it
.
getProp
(
"forceOut"
),
false
);
string
heart
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
));
if
(
!
heart
.
empty
()
)
{
idHeartBeat
=
conf
->
getSensorID
(
heart
);
if
(
idHeartBeat
==
DefaultObjectId
)
{
ostringstream
err
;
...
...
@@ -143,31 +146,34 @@ end_private(false)
throw
SystemError
(
err
.
str
());
}
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-time"
,
it
.
getProp
(
"heartbeatTime"
),
conf
->
getHeartBeatTime
());
if
(
heartbeatTime
>
0
)
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-time"
,
it
.
getProp
(
"heartbeatTime"
),
conf
->
getHeartBeatTime
());
if
(
heartbeatTime
>
0
)
ptHeartBeat
.
setTiming
(
heartbeatTime
);
else
ptHeartBeat
.
setTiming
(
UniSetTimer
::
WaitUpTime
);
maxHeartBeat
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-max"
,
it
.
getProp
(
"heartbeat_max"
),
10
);
maxHeartBeat
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-max"
,
it
.
getProp
(
"heartbeat_max"
),
10
);
}
// Инициализация значений
si
.
id
=
UniSetTypes
::
DefaultObjectId
;
si
.
node
=
conf
->
getLocalNode
();
sleep_msec
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"sleep-msec"
,
"150"
,
150
);
sleep_msec
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"sleep-msec"
,
"150"
,
150
);
string
s_resetTime
(
""
);
if
(
s_resetTime
.
empty
()
)
s_resetTime
=
"500"
;
resetMsgTime
=
uni_atoi
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"resetMsgTime"
),
conf
->
getProp
(
cnode
,
"resetMsgTime"
),
s_resetTime
));
resetMsgTime
=
uni_atoi
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"resetMsgTime"
),
conf
->
getProp
(
cnode
,
"resetMsgTime"
),
s_resetTime
));
ptResetMsg
.
setTiming
(
resetMsgTime
);
int
sm_tout
=
conf
->
getArgInt
(
"--"
+
argprefix
+
"sm-ready-timeout"
,
""
);
int
sm_tout
=
conf
->
getArgInt
(
"--"
+
argprefix
+
"sm-ready-timeout"
,
""
);
if
(
sm_tout
==
0
)
smReadyTimeout
=
60000
;
else
if
(
sm_tout
<
0
)
...
...
@@ -175,8 +181,8 @@ end_private(false)
else
smReadyTimeout
=
sm_tout
;
smTestID
=
conf
->
getSensorID
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"sm-test-id"
),
conf
->
getProp
(
cnode
,
"smTestID"
),
""
));
smTestID
=
conf
->
getSensorID
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"sm-test-id"
),
conf
->
getProp
(
cnode
,
"smTestID"
),
""
));
activateTimeout
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"activate-timeout"
,
20000
);
...
...
@@ -184,7 +190,7 @@ end_private(false)
ptStartUpTimeout
.
setTiming
(
msec
);
// ===================== <variables> =====================
// ===================== end of <variables> =====================
vmonit
(
sleep_msec
);
...
...
@@ -206,17 +212,17 @@ UObject_SK::~UObject_SK()
void
UObject_SK
::
updateValues
()
{
// Опрашиваем все входы...
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
updatePreviousValues
()
{
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
checkSensors
()
{
}
// -----------------------------------------------------------------------------
bool
UObject_SK
::
setMsg
(
UniSetTypes
::
ObjectId
_code
,
bool
_state
)
...
...
@@ -224,28 +230,28 @@ bool UObject_SK::setMsg( UniSetTypes::ObjectId _code, bool _state )
if
(
_code
==
UniSetTypes
::
DefaultObjectId
)
{
mylog8
<<
myname
<<
"(setMsg): попытка послать сообщение с DefaultObjectId"
<<
endl
;
return
false
;
return
false
;
}
mylog8
<<
myname
<<
"(setMsg): "
<<
(
_state
?
"SEND "
:
"RESET "
)
<<
endl
;
// взводим автоматический сброс
if
(
_state
)
{
ptResetMsg
.
reset
();
trResetMsg
.
hi
(
false
);
}
mylog8
<<
myname
<<
"(setMsg): "
<<
(
_state
?
"SEND "
:
"RESET "
)
<<
endl
;
// взводим автоматический сброс
if
(
_state
)
{
ptResetMsg
.
reset
();
trResetMsg
.
hi
(
false
);
}
mylog8
<<
myname
<<
"(setMsg): not found MessgeOID?!!"
<<
endl
;
mylog8
<<
myname
<<
"(setMsg): not found MessgeOID?!!"
<<
endl
;
return
false
;
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
resetMsg
()
{
mylog8
<<
myname
<<
"(resetMsg): reset messages.."
<<
endl
;
// reset messages
mylog8
<<
myname
<<
"(resetMsg): reset messages.."
<<
endl
;
// reset messages
}
// -----------------------------------------------------------------------------
...
...
@@ -255,7 +261,7 @@ void UObject_SK::testMode( bool _state )
return
;
// отключаем все выходы
}
// -----------------------------------------------------------------------------
std
::
string
UObject_SK
::
dumpIO
()
...
...
@@ -265,44 +271,48 @@ std::string UObject_SK::dumpIO()
std
::
list
<
std
::
string
>
v_in
;
ostringstream
s1
;
std
::
list
<
std
::
string
>
v_out
;
s
<<
endl
;
int
n
=
0
;
for
(
const
auto
&
e
:
v_in
)
for
(
const
auto
&
e
:
v_in
)
{
s
<<
e
;
if
(
(
n
++
)
%
2
)
if
(
(
n
++
)
%
2
)
s
<<
std
::
endl
;
}
s
<<
endl
;
n
=
0
;
for
(
const
auto
&
e
:
v_out
)
for
(
const
auto
&
e
:
v_out
)
{
s
<<
e
;
if
(
(
n
++
)
%
2
)
if
(
(
n
++
)
%
2
)
s
<<
std
::
endl
;
}
return
std
::
move
(
s
.
str
());
}
// ----------------------------------------------------------------------------
std
::
string
UObject_SK
::
str
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
)
{
ostringstream
s
;
return
""
;
}
// ----------------------------------------------------------------------------
std
::
string
UObject_SK
::
strval
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
)
{
ostringstream
s
;
return
""
;
}
// ----------------------------------------------------------------------------
...
...
@@ -323,19 +333,19 @@ void UObject_SK::processingMessage( UniSetTypes::VoidMessage* _msg )
{
case
Message
:
:
SensorInfo
:
preSensorInfo
(
reinterpret_cast
<
SensorMessage
*>
(
_msg
)
);
break
;
break
;
case
Message
:
:
Timer
:
preTimerInfo
(
reinterpret_cast
<
TimerMessage
*>
(
_msg
)
);
break
;
break
;
case
Message
:
:
SysCommand
:
preSysCommand
(
reinterpret_cast
<
SystemMessage
*>
(
_msg
)
);
break
;
break
;
default
:
break
;
}
}
}
catch
(
const
Exception
&
ex
)
{
...
...
@@ -349,11 +359,13 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
{
case
SystemMessage
:
:
WatchDog
:
uinfo
<<
myname
<<
"(preSysCommand): WatchDog"
<<
endl
;
if
(
!
active
||
!
ptStartUpTimeout
.
checkTime
()
)
{
uwarn
<<
myname
<<
"(preSysCommand): игнорируем WatchDog, потому-что только-что стартанули"
<<
endl
;
break
;
}
case
SystemMessage
:
:
StartUp
:
{
if
(
!
logserv_host
.
empty
()
&&
logserv_port
!=
0
&&
!
logserv
->
isRunning
()
)
...
...
@@ -374,21 +386,22 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
active
=
true
;
break
;
}
case
SystemMessage
:
:
FoldUp
:
case
SystemMessage
:
:
Finish
:
preAskSensors
(
UniversalIO
::
UIODontNotify
);
askSensors
(
UniversalIO
::
UIODontNotify
);
break
;
case
SystemMessage
:
:
LogRotate
:
{
// переоткрываем логи
mylogany
<<
myname
<<
"(preSysCommand): logRotate"
<<
endl
;
string
fname
(
log
()
->
getLogFile
()
);
if
(
!
fname
.
empty
()
)
{
mylog
->
logFile
(
fname
.
c_str
(),
true
);
mylog
->
logFile
(
fname
.
c_str
(),
true
);
mylogany
<<
myname
<<
"(preSysCommand): ***************** mylog LOG ROTATE *****************"
<<
endl
;
}
}
...
...
@@ -397,16 +410,16 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
default
:
break
;
}
sysCommand
(
_sm
);
}
// -----------------------------------------------------------------------------
UniSetTypes
::
SimpleInfo
*
UObject_SK
::
getInfo
(
CORBA
::
Long
userparam
)
{
UniSetTypes
::
SimpleInfo_var
i
=
UniSetObject
::
getInfo
(
userparam
);
ostringstream
inf
;
inf
<<
i
->
info
<<
endl
;
inf
<<
"LogServer: "
<<
logserv_host
<<
":"
<<
logserv_port
<<
endl
;
inf
<<
dumpIO
()
<<
endl
;
...
...
@@ -414,9 +427,9 @@ UniSetTypes::SimpleInfo* UObject_SK::getInfo( CORBA::Long userparam )
inf
<<
vmon
.
pretty_str
()
<<
endl
;
inf
<<
endl
;
inf
<<
getMonitInfo
()
<<
endl
;
i
->
info
=
inf
.
str
().
c_str
();
return
i
.
_retn
();
}
// -----------------------------------------------------------------------------
...
...
@@ -429,7 +442,7 @@ void UObject_SK::sigterm( int signo )
// -----------------------------------------------------------------------------
bool
UObject_SK
::
activateObject
()
{
// блокирование обработки Startup
// блокирование обработки Startup
// пока не пройдёт инициализация датчиков
// см. preSysCommand()
{
...
...
@@ -455,24 +468,24 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
if
(
_testID
==
DefaultObjectId
)
return
;
uinfo
<<
myname
<<
"(waitSM): waiting SM ready "
<<
wait_msec
<<
" msec"
<<
" testID="
<<
_testID
<<
endl
;
if
(
!
ui
->
waitReady
(
_testID
,
wait_msec
)
)
<<
wait_msec
<<
" msec"
<<
" testID="
<<
_testID
<<
endl
;
if
(
!
ui
->
waitReady
(
_testID
,
wait_msec
)
)
{
ostringstream
err
;
err
<<
myname
<<
"(waitSM): Не дождались готовности(exist) SharedMemory к работе в течение "
err
<<
myname
<<
"(waitSM): Не дождались готовности(exist) SharedMemory к работе в течение "
<<
wait_msec
<<
" мсек"
;
ucrit
<<
err
.
str
()
<<
endl
;
// terminate();
// abort();
ucrit
<<
err
.
str
()
<<
endl
;
// terminate();
// abort();
raise
(
SIGTERM
);
terminate
();
// throw SystemError(err.str());
// throw SystemError(err.str());
}
...
...
@@ -481,8 +494,8 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
std
::
string
UObject_SK
::
help
()
{
ostringstream
s
;
return
std
::
move
(
s
.
str
());
}
// ----------------------------------------------------------------------------
...
...
@@ -492,37 +505,39 @@ void UObject_SK::callback()
{
if
(
!
active
)
return
;
try
{
// проверка таймеров
checkTimers
(
this
);
if
(
resetMsgTime
>
0
&&
trResetMsg
.
hi
(
ptResetMsg
.
checkTime
())
)
if
(
resetMsgTime
>
0
&&
trResetMsg
.
hi
(
ptResetMsg
.
checkTime
())
)
{
// cout << myname << ": ********* reset messages *********" << endl;
// cout << myname << ": ********* reset messages *********" << endl;
resetMsg
();
}
// обработка сообщений (таймеров и т.п.)
for
(
unsigned
int
i
=
0
;
i
<
20
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
20
;
i
++
)
{
if
(
!
receiveMessage
(
msg
)
)
break
;
processingMessage
(
&
msg
);
updateOutputs
(
forceOut
);
// updatePreviousValues();
// updatePreviousValues();
}
// Выполнение шага программы
step
();
// "сердцебиение"
if
(
idHeartBeat
!=
DefaultObjectId
&&
ptHeartBeat
.
checkTime
()
)
if
(
idHeartBeat
!=
DefaultObjectId
&&
ptHeartBeat
.
checkTime
()
)
{
try
{
ui
->
setValue
(
idHeartBeat
,
maxHeartBeat
);
ui
->
setValue
(
idHeartBeat
,
maxHeartBeat
);
ptHeartBeat
.
reset
();
}
catch
(
const
Exception
&
ex
)
...
...
@@ -537,21 +552,21 @@ void UObject_SK::callback()
}
catch
(
const
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): "
<<
ex
<<
endl
;
ucrit
<<
myname
<<
"(execute): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
ucrit
<<
myname
<<
"(execute): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
ucrit
<<
myname
<<
"(execute): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
}
if
(
!
active
)
return
;
msleep
(
sleep_msec
);
}
// -----------------------------------------------------------------------------
...
...
@@ -559,32 +574,32 @@ void UObject_SK::setValue( UniSetTypes::ObjectId _sid, long _val )
{
if
(
_sid
==
UniSetTypes
::
DefaultObjectId
)
return
;
ui
->
setValue
(
_sid
,
_val
);
ui
->
setValue
(
_sid
,
_val
);
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
updateOutputs
(
bool
_force
)
{
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
preSensorInfo
(
const
UniSetTypes
::
SensorMessage
*
_sm
)
{
sensorInfo
(
_sm
);
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
initFromSM
()
{
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
askSensor
(
UniSetTypes
::
ObjectId
_sid
,
UniversalIO
::
UIOCommand
_cmd
,
UniSetTypes
::
ObjectId
_node
)
{
ui
->
askRemoteSensor
(
_sid
,
_cmd
,
_node
,
getId
());
ui
->
askRemoteSensor
(
_sid
,
_cmd
,
_node
,
getId
());
}
// -----------------------------------------------------------------------------
long
UObject_SK
::
getValue
(
UniSetTypes
::
ObjectId
_sid
)
...
...
@@ -597,7 +612,7 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
}
catch
(
const
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(getValue): "
<<
ex
<<
endl
;
ucrit
<<
myname
<<
"(getValue): "
<<
ex
<<
endl
;
throw
;
}
}
...
...
@@ -606,33 +621,35 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
void
UObject_SK
::
preAskSensors
(
UniversalIO
::
UIOCommand
_cmd
)
{
PassiveTimer
ptAct
(
activateTimeout
);
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
{
{
cout
<<
myname
<<
"(preAskSensors): wait activate..."
<<
endl
;
msleep
(
300
);
if
(
activated
)
break
;
}
if
(
!
activated
)
ucrit
<<
myname
<<
"(preAskSensors): ************* don`t activated?! ************"
<<
endl
;
<<
"(preAskSensors): ************* don`t activated?! ************"
<<
endl
;
for
(
;;
)
{
try
{
return
;
}
catch
(
const
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(preAskSensors): "
<<
ex
<<
endl
;
ucrit
<<
myname
<<
"(preAskSensors): "
<<
ex
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
}
msleep
(
askPause
);
}
...
...
include/LT_Object.h
View file @
b2cf6d77
...
...
@@ -109,7 +109,7 @@ class LT_Object
\return Возвращает время [мсек] оставшееся до срабатывания очередного таймера
*/
virtual
timeout_t
askTimer
(
UniSetTypes
::
TimerId
timerid
,
timeout_t
timeMS
,
clock_t
ticks
=
-
1
,
UniSetTypes
::
Message
::
Priority
p
=
UniSetTypes
::
Message
::
High
);
UniSetTypes
::
Message
::
Priority
p
=
UniSetTypes
::
Message
::
High
);
/*!
...
...
include/Trigger.h
View file @
b2cf6d77
...
...
@@ -72,7 +72,10 @@ class Trigger
return
false
;
}
inline
bool
get
(){
return
oldstate
;
}
inline
bool
get
()
{
return
oldstate
;
}
private
:
bool
oldstate
;
/*!< предыдущее состояние */
...
...
include/UniSetManager.h
View file @
b2cf6d77
...
...
@@ -152,7 +152,7 @@ class UniSetManager:
typedef
UniSetManagerList
::
iterator
MListIterator
;
int
getObjectsInfo
(
const
std
::
shared_ptr
<
UniSetManager
>&
mngr
,
UniSetTypes
::
SimpleInfoSeq
*
seq
,
int
begin
,
const
long
uplimit
,
CORBA
::
Long
userparam
);
int
begin
,
const
long
uplimit
,
CORBA
::
Long
userparam
);
PortableServer
::
POA_var
poa
;
PortableServer
::
POAManager_var
pman
;
...
...
include/UniSetObject.h
View file @
b2cf6d77
...
...
@@ -116,6 +116,9 @@ class UniSetObject:
return
(
UniSetTypes
::
ObjectPtr
)
CORBA
::
Object
::
_duplicate
(
oref
);
}
virtual
timeout_t
askTimer
(
UniSetTypes
::
TimerId
timerid
,
timeout_t
timeMS
,
clock_t
ticks
=
-
1
,
UniSetTypes
::
Message
::
Priority
p
=
UniSetTypes
::
Message
::
High
)
override
;
protected
:
/*! обработка приходящих сообщений */
virtual
void
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
);
...
...
@@ -123,9 +126,6 @@ class UniSetObject:
virtual
void
sensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
)
{}
virtual
void
timerInfo
(
const
UniSetTypes
::
TimerMessage
*
tm
)
{}
virtual
timeout_t
askTimer
(
UniSetTypes
::
TimerId
timerid
,
timeout_t
timeMS
,
clock_t
ticks
=
-
1
,
UniSetTypes
::
Message
::
Priority
p
=
UniSetTypes
::
Message
::
High
)
override
;
/*! Получить сообщение */
bool
receiveMessage
(
UniSetTypes
::
VoidMessage
&
vm
);
...
...
python/lib/pyUniSet/UModbus.cc
View file @
b2cf6d77
...
...
@@ -123,7 +123,7 @@ bool UModbus::getBit( int addr, int mbreg, int mbfunc )throw(UException)
}
// --------------------------------------------------------------------------
long
UModbus
::
mbread
(
int
mbaddr
,
int
mbreg
,
int
mbfunc
,
const
string
&
s_vtype
,
int
nbit
,
const
string
&
new_ip
,
int
new_port
)
throw
(
UException
)
const
string
&
new_ip
,
int
new_port
)
throw
(
UException
)
{
using
namespace
VTypes
;
...
...
src/Communications/Modbus/ModbusClient.cc
View file @
b2cf6d77
...
...
@@ -994,7 +994,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout
{
size_t
onum
=
0
;
while
(
(
rlen
+
2
)
<
sizeof
(
rbuf
.
data
)
&&
onum
<
mPreRDI
.
objNum
)
while
(
(
rlen
+
2
)
<
sizeof
(
rbuf
.
data
)
&&
onum
<
mPreRDI
.
objNum
)
{
// сперва получаем два байта, для определения длины последующих данных
size_t
szDataLen
=
2
;
// object id + len
...
...
src/Communications/Modbus/ModbusRTUSlave.cc
View file @
b2cf6d77
...
...
@@ -96,7 +96,8 @@ mbErrCode ModbusRTUSlave::receive(const std::unordered_set<ModbusAddr>& vmbaddr,
if
(
aftersend_msec
>
0
)
msleep
(
aftersend_msec
);
// usleep(10000);
// usleep(10000);
return
res
;
}
...
...
src/Communications/Modbus/ModbusServer.cc
View file @
b2cf6d77
...
...
@@ -72,16 +72,18 @@ bool ModbusServer::checkAddr(const std::unordered_set<ModbusAddr>& vaddr, const
return
true
;
auto
i
=
vaddr
.
find
(
addr
);
return
(
i
!=
vaddr
.
end
());
return
(
i
!=
vaddr
.
end
());
}
// --------------------------------------------------------------------------------
std
::
string
ModbusServer
::
vaddr2str
(
const
std
::
unordered_set
<
ModbusAddr
>&
vaddr
)
{
ostringstream
s
;
s
<<
"[ "
;
for
(
const
auto
&
a
:
vaddr
)
for
(
const
auto
&
a
:
vaddr
)
s
<<
addr2str
(
a
)
<<
" "
;
s
<<
"]"
;
s
<<
"]"
;
return
std
::
move
(
s
.
str
());
}
...
...
@@ -583,7 +585,7 @@ mbErrCode ModbusServer::recv( const std::unordered_set<ModbusRTU::ModbusAddr>& v
{
bcnt
=
getNextData
((
unsigned
char
*
)(
&
rbuf
),
sizeof
(
ModbusAddr
));
if
(
bcnt
>
0
&&
checkAddr
(
vaddr
,
rbuf
.
addr
)
)
if
(
bcnt
>
0
&&
checkAddr
(
vaddr
,
rbuf
.
addr
)
)
{
begin
=
true
;
break
;
...
...
@@ -599,7 +601,7 @@ mbErrCode ModbusServer::recv( const std::unordered_set<ModbusRTU::ModbusAddr>& v
// Lav: конечно стоит, нам же надо буфер чистить
*/
// Проверка кому адресован пакет... (только если не включён режим отвечать на любые адреса)
if
(
!
(
onBroadcast
&&
rbuf
.
addr
==
BroadcastAddr
)
&&
!
checkAddr
(
vaddr
,
rbuf
.
addr
)
)
if
(
!
(
onBroadcast
&&
rbuf
.
addr
==
BroadcastAddr
)
&&
!
checkAddr
(
vaddr
,
rbuf
.
addr
)
)
{
if
(
dlog
->
is_warn
()
)
{
...
...
@@ -1505,7 +1507,7 @@ std::unordered_set<ModbusAddr> ModbusServer::addr2vaddr(ModbusAddr& mbaddr)
mbErrCode
ModbusServer
::
receive_one
(
ModbusAddr
a
,
timeout_t
msec
)
{
auto
v
=
addr2vaddr
(
a
);
return
receive
(
v
,
msec
);
return
receive
(
v
,
msec
);
}
// -------------------------------------------------------------------------
...
...
@@ -1548,6 +1550,7 @@ ModbusRTU::mbErrCode ModbusServer::replyFileTransfer( const std::string& fname,
if
(
ret
==
-
1
)
{
close
(
fd
);
if
(
dlog
&&
dlog
->
is_warn
()
)
(
*
dlog
)[
Debug
::
WARN
]
<<
"(replyFileTransfer): open '"
<<
fname
<<
"' with error: "
<<
strerror
(
errno
)
<<
endl
;
...
...
@@ -1561,6 +1564,7 @@ ModbusRTU::mbErrCode ModbusServer::replyFileTransfer( const std::string& fname,
if
(
ret
<
0
)
{
close
(
fd
);
if
(
dlog
&&
dlog
->
is_warn
()
)
(
*
dlog
)[
Debug
::
WARN
]
<<
"(replyFileTransfer): read from '"
<<
fname
<<
"' with error: "
<<
strerror
(
errno
)
<<
endl
;
...
...
@@ -1572,6 +1576,7 @@ ModbusRTU::mbErrCode ModbusServer::replyFileTransfer( const std::string& fname,
if
(
fstat
(
fd
,
&
fs
)
<
0
)
{
close
(
fd
);
if
(
dlog
&&
dlog
->
is_warn
()
)
(
*
dlog
)[
Debug
::
WARN
]
<<
"(replyFileTransfer): fstat for '"
<<
fname
<<
"' with error: "
<<
strerror
(
errno
)
<<
endl
;
...
...
@@ -1620,7 +1625,7 @@ ModbusRTU::mbErrCode ModbusServer::replySetDateTime( ModbusRTU::SetDateTimeMessa
set
.
tv_sec
=
mktime
(
&
t
);
// может вернуть -1 (!)
set
.
tv_usec
=
0
;
if
(
set
.
tv_sec
>=
0
&&
settimeofday
(
&
set
,
&
tz
)
==
0
)
if
(
set
.
tv_sec
>=
0
&&
settimeofday
(
&
set
,
&
tz
)
==
0
)
{
// подтверждаем сохранение
// в ответе возвращаем установленное время...
...
...
src/Communications/Modbus/ModbusTCPCore.cc
View file @
b2cf6d77
...
...
@@ -4,7 +4,7 @@ using namespace std;
using
namespace
ModbusRTU
;
// -------------------------------------------------------------------------
size_t
ModbusTCPCore
::
readNextData
(
ost
::
TCPStream
*
tcp
,
std
::
queue
<
unsigned
char
>&
qrecv
,
int
max
)
std
::
queue
<
unsigned
char
>&
qrecv
,
int
max
)
{
if
(
!
tcp
||
!
tcp
->
isConnected
()
)
return
0
;
...
...
@@ -26,8 +26,8 @@ size_t ModbusTCPCore::readNextData( ost::TCPStream* tcp,
}
// ------------------------------------------------------------------------
size_t
ModbusTCPCore
::
getNextData
(
ost
::
TCPStream
*
tcp
,
std
::
queue
<
unsigned
char
>&
qrecv
,
unsigned
char
*
buf
,
size_t
len
)
std
::
queue
<
unsigned
char
>&
qrecv
,
unsigned
char
*
buf
,
size_t
len
)
{
if
(
!
tcp
||
!
tcp
->
isConnected
()
)
return
0
;
...
...
src/Communications/Modbus/ModbusTCPServer.cc
View file @
b2cf6d77
...
...
@@ -232,6 +232,7 @@ mbErrCode ModbusTCPServer::receive(const std::unordered_set<ModbusAddr>& vmbaddr
{
if
(
dlog
->
is_crit
()
)
dlog
->
crit
()
<<
"(ModbusTCPServer): "
<<
e
.
what
()
<<
endl
;
return
erInternalErrorCode
;
}
...
...
src/Communications/Modbus/ModbusTCPSession.cc
View file @
b2cf6d77
...
...
@@ -33,8 +33,9 @@ ModbusTCPSession::ModbusTCPSession(ost::TCPSocket& server, const std::unordered_
{
setCRCNoCheckit
(
true
);
timeout_t
tout
=
timeout
/
1000
;
if
(
tout
<=
0
)
timeout_t
tout
=
timeout
/
1000
;
if
(
tout
<=
0
)
tout
=
3
;
setKeepAlive
(
true
);
...
...
src/Communications/Modbus/ModbusTypes.cc
View file @
b2cf6d77
...
...
@@ -997,6 +997,7 @@ ModbusMessage ReadOutputRetMessage::transport_msg()
ind
+=
bcnt
;
}
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
),
szModbusHeader
+
sizeof
(
bcnt
)
+
bcnt
);
...
...
@@ -1209,6 +1210,7 @@ ModbusMessage ReadInputRetMessage::transport_msg()
ind
+=
bcnt
;
}
// пересчитываем CRC по перевёрнутым данным
ModbusData
crc
=
checkCRC
(
(
ModbusByte
*
)(
&
mm
),
szModbusHeader
+
sizeof
(
bcnt
)
+
bcnt
);
...
...
src/Communications/TCP/UTCPStream.cc
View file @
b2cf6d77
...
...
@@ -28,6 +28,7 @@ bool UTCPStream::setKeepAliveParams(timeout_t timeout_sec, int keepcnt, int keep
SOCKET
fd
=
TCPStream
::
so
;
int
enable
=
1
;
bool
ok
=
true
;
if
(
setsockopt
(
fd
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
void
*
)
&
enable
,
sizeof
(
enable
))
==
-
1
)
ok
=
false
;
...
...
src/Log/LogReader.cc
View file @
b2cf6d77
...
...
@@ -307,7 +307,7 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ
log
<<
buf
;
}
else
if
(
n
==
0
&&
readcount
<=
0
)
else
if
(
n
==
0
&&
readcount
<=
0
)
break
;
if
(
rcount
>
0
&&
readcount
>
0
)
...
...
src/Log/LogServer.cc
View file @
b2cf6d77
...
...
@@ -31,6 +31,7 @@ LogServer::~LogServer()
if
(
thr
)
{
thr
->
stop
();
if
(
thr
->
isRunning
()
)
thr
->
join
();
}
...
...
src/Log/LogSession.cc
View file @
b2cf6d77
...
...
@@ -19,6 +19,7 @@ using namespace UniSetTypes;
LogSession
::~
LogSession
()
{
cancelled
=
true
;
if
(
isRunning
()
)
{
ost
::
Thread
::
join
();
...
...
@@ -310,6 +311,7 @@ void LogSession::run()
disconnect
();
cancelled
=
true
;
if
(
slog
.
debugging
(
Debug
::
INFO
)
)
slog
[
Debug
::
INFO
]
<<
peername
<<
"(run): thread stopping..."
<<
endl
;
...
...
@@ -325,6 +327,7 @@ void LogSession::final()
try
{
auto
s
=
shared_from_this
();
if
(
s
)
slFin
(
s
);
}
...
...
@@ -350,8 +353,8 @@ NullLogSession::~NullLogSession()
{
cancelled
=
true
;
// if( isRunning() )
// exit(); // terminate();
// if( isRunning() )
// exit(); // terminate();
}
// ---------------------------------------------------------------------
void
NullLogSession
::
add
(
ost
::
TCPSocket
&
sock
)
...
...
src/ObjectRepository/UniSetActivator.cc
View file @
b2cf6d77
...
...
@@ -204,11 +204,14 @@ void terminate_thread()
g_act
->
terminated
(
g_signo
);
#if 0
try
{
ulogsys << "TERMINATE THREAD: orb shutdown.." << endl;
if( g_act->orb )
g_act->orb->shutdown(true);
ulogsys << "TERMINATE THREAD: orb shutdown ok.." << endl;
}
catch( const omniORB::fatalException& fe )
...
...
@@ -222,7 +225,9 @@ void terminate_thread()
{
ulogsys << "(TERMINATE THREAD): " << ex.what() << endl;
}
#endif
if
(
g_fini_thread
&&
g_fini_thread
->
joinable
()
)
g_fini_thread
->
join
();
...
...
@@ -385,8 +390,10 @@ void UniSetActivator::uaDestroy(int signo)
try
{
ulogsys
<<
myname
<<
"(uaDestroy): shutdown orb... "
<<
endl
;
if
(
orb
)
orb
->
shutdown
(
true
);
ulogsys
<<
myname
<<
"(uaDestroy): shutdown ok."
<<
endl
;
}
catch
(
const
omniORB
::
fatalException
&
fe
)
...
...
src/ObjectRepository/UniSetObject.cc
View file @
b2cf6d77
...
...
@@ -133,6 +133,7 @@ UniSetObject::UniSetObject( const string& name, const string& section ):
UniSetObject
::~
UniSetObject
()
{
#if 0
try
{
deactivate();
...
...
@@ -156,6 +157,7 @@ UniSetObject::~UniSetObject()
}
catch(...) {}
}
#endif
}
// ------------------------------------------------------------------------------------------
...
...
src/Various/Configuration.cc
View file @
b2cf6d77
...
...
@@ -196,6 +196,7 @@ namespace UniSetTypes
xmlNodesSec
=
0
;
// -------------------------------------------------------------------------
char
curdir
[
FILENAME_MAX
];
if
(
getcwd
(
curdir
,
FILENAME_MAX
)
==
NULL
)
rootDir
=
""
;
else
...
...
src/Various/LT_Object.cc
View file @
b2cf6d77
...
...
@@ -130,7 +130,8 @@ timeout_t LT_Object::getTimeInterval( TimerId timerid )
{
// lock
uniset_rwmutex_rlock
lock
(
lstMutex
);
for
(
const
auto
&
li
:
tlst
)
for
(
const
auto
&
li
:
tlst
)
{
if
(
li
.
id
==
timerid
)
return
li
.
tmr
.
getInterval
();
...
...
@@ -143,7 +144,8 @@ timeout_t LT_Object::getTimeLeft(TimerId timerid)
{
// lock
uniset_rwmutex_rlock
lock
(
lstMutex
);
for
(
const
auto
&
li
:
tlst
)
for
(
const
auto
&
li
:
tlst
)
{
if
(
li
.
id
==
timerid
)
return
li
.
curTimeMS
;
...
...
src/Various/RunLock.cc
View file @
b2cf6d77
...
...
@@ -48,6 +48,7 @@ bool RunLock::isLocked( const string& name )
char
ptr
[
10
];
int
n
=
fscanf
(
out
,
"%9s"
,
ptr
);
if
(
n
<
1
)
{
fclose
(
out
);
...
...
src/Various/SMonitor.cc
View file @
b2cf6d77
...
...
@@ -117,8 +117,9 @@ void SMonitor::sensorInfo( const SensorMessage* si )
int
ret
=
system
(
cmd
.
str
().
c_str
());
int
res
=
WEXITSTATUS
(
ret
);
if
(
res
!=
0
)
cerr
<<
"run script '"
<<
cmd
.
str
()
<<
"' failed.."
<<
endl
;
cerr
<<
"run script '"
<<
cmd
.
str
()
<<
"' failed.."
<<
endl
;
// if( WIFSIGNALED(ret) && (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))
// {
...
...
src/Various/VMonitor.cc
View file @
b2cf6d77
...
...
@@ -70,13 +70,13 @@
#define VMON_MAKE_PAIR(vlist, T) \
{\
for( const auto& e: m_##T ) \
vlist.push_back( std::make_pair(e.second, std::to_string(*(e.first))) );\
vlist.push_back( std::make_pair(e.second, std::to_string(*(e.first))) );\
}
// --------------------------------------------------------------------------
#define VMON_MAKE_PAIR_S(vlist, T) \
{\
for( const auto& e: m_##T ) \
vlist.push_back( std::make_pair(e.second,*e.first) );\
vlist.push_back( std::make_pair(e.second,*e.first) );\
}
// --------------------------------------------------------------------------
#define VMON_MAKE_PAIR2(vlist, T) \
...
...
@@ -113,9 +113,12 @@ std::ostream& operator<<( std::ostream& os, VMonitor& m )
{
auto
vlist
=
m
.
getList
();
// сортируем по алфавиту
vlist
.
sort
(
[](
const
std
::
pair
<
std
::
string
,
std
::
string
>
&
a
,
const
std
::
pair
<
std
::
string
,
std
::
string
>
&
b
)
{
return
a
.
first
<
b
.
first
;
});
vlist
.
sort
(
[](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
a
,
const
std
::
pair
<
std
::
string
,
std
::
string
>&
b
)
{
return
a
.
first
<
b
.
first
;
});
for
(
const
auto
&
e
:
vlist
)
for
(
const
auto
&
e
:
vlist
)
os
<<
e
.
first
<<
" = "
<<
e
.
second
;
return
os
;
...
...
@@ -130,15 +133,15 @@ std::string VMonitor::str()
// --------------------------------------------------------------------------
std
::
list
<
std
::
pair
<
std
::
string
,
std
::
string
>
>
VMonitor
::
getList
()
{
std
::
list
<
std
::
pair
<
std
::
string
,
std
::
string
>>
vlist
;
VMON_MAKE_PAIR2
(
vlist
,
int
);
VMON_MAKE_PAIR2
(
vlist
,
long
);
VMON_MAKE_PAIR2
(
vlist
,
short
);
std
::
list
<
std
::
pair
<
std
::
string
,
std
::
string
>>
vlist
;
VMON_MAKE_PAIR2
(
vlist
,
int
);
VMON_MAKE_PAIR2
(
vlist
,
long
);
VMON_MAKE_PAIR2
(
vlist
,
short
);
VMON_MAKE_PAIR_CHAR
(
vlist
);
VMON_MAKE_PAIR
(
vlist
,
bool
);
VMON_MAKE_PAIR
(
vlist
,
float
);
VMON_MAKE_PAIR
(
vlist
,
double
);
VMON_MAKE_PAIR_S
(
vlist
,
string
);
VMON_MAKE_PAIR
(
vlist
,
bool
);
VMON_MAKE_PAIR
(
vlist
,
float
);
VMON_MAKE_PAIR
(
vlist
,
double
);
VMON_MAKE_PAIR_S
(
vlist
,
string
);
return
std
::
move
(
vlist
);
}
// --------------------------------------------------------------------------
...
...
@@ -148,13 +151,18 @@ std::string VMonitor::pretty_str( int namewidth, int colnum )
std
::
ostringstream
os
;
// сортируем по алфавиту
vlist
.
sort
(
[](
const
std
::
pair
<
std
::
string
,
std
::
string
>
&
a
,
const
std
::
pair
<
std
::
string
,
std
::
string
>
&
b
)
{
return
a
.
first
<
b
.
first
;
});
vlist
.
sort
(
[](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
a
,
const
std
::
pair
<
std
::
string
,
std
::
string
>&
b
)
{
return
a
.
first
<
b
.
first
;
});
int
n
=
0
;
for
(
const
auto
&
e
:
vlist
)
for
(
const
auto
&
e
:
vlist
)
{
os
<<
std
::
right
<<
std
::
setw
(
namewidth
)
<<
e
.
first
<<
std
::
left
<<
" = "
<<
std
::
right
<<
std
::
setw
(
10
)
<<
e
.
second
;
if
(
(
n
++
)
%
colnum
)
if
(
(
n
++
)
%
colnum
)
os
<<
std
::
endl
;
}
...
...
src/Various/WDTInterface.cc
View file @
b2cf6d77
...
...
@@ -32,6 +32,7 @@ bool WDTInterface::ping()
}
int
ret
=
write
(
fd
,
(
void
*
)
CMD_PING
,
sizeof
(
CMD_PING
));
if
(
ret
==
-
1
)
{
cerr
<<
": Unable to open device "
<<
dev
<<
" with err: "
<<
strerror
(
errno
)
<<
endl
;
...
...
@@ -54,6 +55,7 @@ bool WDTInterface::stop()
}
int
ret
=
write
(
fd
,
(
void
*
)
CMD_STOP
,
sizeof
(
CMD_STOP
));
if
(
ret
==
-
1
)
{
cerr
<<
": Unable to open device "
<<
dev
<<
" with err: "
<<
strerror
(
errno
)
<<
endl
;
...
...
tests/test_pulse.cc
View file @
b2cf6d77
...
...
@@ -10,7 +10,7 @@ TEST_CASE("Pulse", "[Test for class 'Pulse' - impulse generator]" )
{
// Работа без задержки..(нулевые задержки)
Pulse
p
;
REQUIRE
(
p
.
getT1
()
==
0
);
REQUIRE
(
p
.
getT0
()
==
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