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
6700fc00
Commit
6700fc00
authored
Nov 08, 2014
by
Aleksei Vinogradov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.set:packages/uniset
parents
8f6ba6d9
4f920f58
Hide whitespace changes
Inline
Side-by-side
Showing
47 changed files
with
706 additions
and
278 deletions
+706
-278
admin.cc
Utilities/Admin/admin.cc
+121
-56
admin.sh
Utilities/Admin/admin.sh
+1
-1
ctl-cpp-cc-alone-ask.xsl
Utilities/codegen/ctl-cpp-cc-alone-ask.xsl
+8
-3
ctl-cpp-cc-alone.xsl
Utilities/codegen/ctl-cpp-cc-alone.xsl
+3
-4
ctl-cpp-cc-ask.xsl
Utilities/codegen/ctl-cpp-cc-ask.xsl
+6
-4
ctl-cpp-cc.xsl
Utilities/codegen/ctl-cpp-cc.xsl
+3
-3
testgen.src.xml
Utilities/codegen/tests/testgen.src.xml
+2
-0
libuniset.spec
conf/libuniset.spec
+27
-1
test.xml
conf/test.xml
+3
-2
DBInterface.cc
extensions/DBServer-MySQL/DBInterface.cc
+24
-6
DBInterface.h
extensions/DBServer-MySQL/DBInterface.h
+2
-0
DBServer_MySQL.cc
extensions/DBServer-MySQL/DBServer_MySQL.cc
+1
-1
DBServer_SQLite.cc
extensions/DBServer-SQLite/DBServer_SQLite.cc
+8
-5
PassiveLProcessor.cc
extensions/LogicProcessor/PassiveLProcessor.cc
+1
-1
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+119
-36
MBExchange.h
extensions/ModbusMaster/MBExchange.h
+5
-0
RTUExchange.cc
extensions/ModbusMaster/RTUExchange.cc
+6
-9
start_fg_mbtcpmulti.sh
extensions/ModbusMaster/start_fg_mbtcpmulti.sh
+1
-1
vtconv.cc
extensions/ModbusMaster/vtconv.cc
+23
-2
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+35
-6
SMDBServer.cc
extensions/SMDBServer/SMDBServer.cc
+1
-1
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+1
-0
smemory.cc
extensions/SharedMemory/smemory.cc
+4
-4
UNetExchange.cc
extensions/UNetUDP/UNetExchange.cc
+40
-20
UNetExchange.h
extensions/UNetUDP/UNetExchange.h
+4
-1
UNetReceiver.cc
extensions/UNetUDP/UNetReceiver.cc
+30
-3
UNetReceiver.h
extensions/UNetUDP/UNetReceiver.h
+6
-2
uninet.cc
extensions/UniNetwork/uninet.cc
+3
-3
Extensions.h
extensions/include/Extensions.h
+0
-3
IOBase.h
extensions/include/IOBase.h
+1
-1
VTypes.h
extensions/include/VTypes.h
+52
-1
Extensions.cc
extensions/lib/Extensions.cc
+0
-30
MTR.cc
extensions/lib/MTR.cc
+19
-5
VTypes.cc
extensions/lib/VTypes.cc
+15
-3
ComPort.h
include/ComPort.h
+3
-3
DelayTimer.h
include/DelayTimer.h
+18
-6
ModbusTCPMaster.h
include/modbus/ModbusTCPMaster.h
+3
-1
UTCPStream.h
include/modbus/UTCPStream.h
+24
-0
ComPort.cc
src/Communications/ComPort.cc
+2
-2
ComPort485F.cc
src/Communications/ComPort485F.cc
+3
-3
Makefile.am
src/Communications/Modbus/Makefile.am
+1
-1
ModbusRTUMaster.cc
src/Communications/Modbus/ModbusRTUMaster.cc
+3
-3
ModbusRTUSlave.cc
src/Communications/Modbus/ModbusRTUSlave.cc
+4
-4
ModbusTCPMaster.cc
src/Communications/Modbus/ModbusTCPMaster.cc
+13
-13
UTCPStream.cc
src/Communications/Modbus/UTCPStream.cc
+35
-0
IOController.cc
src/Processes/IOController.cc
+10
-2
Configuration.cc
src/Various/Configuration.cc
+12
-22
No files found.
Utilities/Admin/admin.cc
View file @
6700fc00
...
@@ -49,6 +49,7 @@ static struct option longopts[] = {
...
@@ -49,6 +49,7 @@ static struct option longopts[] = {
{
"getRawValue"
,
required_argument
,
0
,
'w'
},
{
"getRawValue"
,
required_argument
,
0
,
'w'
},
{
"getCalibrate"
,
required_argument
,
0
,
'y'
},
{
"getCalibrate"
,
required_argument
,
0
,
'y'
},
{
"oinfo"
,
required_argument
,
0
,
'p'
},
{
"oinfo"
,
required_argument
,
0
,
'p'
},
{
"verbose"
,
no_argument
,
0
,
'v'
},
{
NULL
,
0
,
0
,
0
}
{
NULL
,
0
,
0
,
0
}
};
};
...
@@ -110,17 +111,18 @@ static void usage()
...
@@ -110,17 +111,18 @@ static void usage()
cout
<<
endl
;
cout
<<
endl
;
print_help
(
36
,
"-w|--getRawValue id1@node1=val,id2@node2=val2,id3=val3,.. "
,
"Получить 'сырое' значение.
\n
"
);
print_help
(
36
,
"-w|--getRawValue id1@node1=val,id2@node2=val2,id3=val3,.. "
,
"Получить 'сырое' значение.
\n
"
);
print_help
(
36
,
"-y|--getCalibrate id1@node1=val,id2@node2=val2,id3=val3,.. "
,
"Получить параметры калибровки.
\n
"
);
print_help
(
36
,
"-y|--getCalibrate id1@node1=val,id2@node2=val2,id3=val3,.. "
,
"Получить параметры калибровки.
\n
"
);
print_help
(
36
,
"-v|--verbose"
,
"Подробный вывод логов.
\n
"
);
cout
<<
endl
;
cout
<<
endl
;
}
}
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
/*!
/*!
\todo Сделать по умолчанию режим silent и ключ --verbose.
\todo Оптимизировать commandToAll, т.к. сейчас НА КАЖДОМ ШАГЕ цикла
\todo Оптимизировать commandToAll, т.к. сейчас НА КАЖДОМ ШАГЕ цикла
создаётся сообщение и происходит преобразование в TransportMessage.
создаётся сообщение и происходит преобразование в TransportMessage.
TransportMessage можно создать один раз до цикла.
TransportMessage можно создать один раз до цикла.
*/
*/
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
static
bool
verb
=
false
;
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
try
try
...
@@ -128,7 +130,7 @@ int main(int argc, char** argv)
...
@@ -128,7 +130,7 @@ int main(int argc, char** argv)
int
optindex
=
0
;
int
optindex
=
0
;
char
opt
=
0
;
char
opt
=
0
;
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hc:beomsfur:l:i:x:g:w:y:p:"
,
longopts
,
&
optindex
))
!=
-
1
)
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"
v
hc:beomsfur:l:i:x:g:w:y:p:"
,
longopts
,
&
optindex
))
!=
-
1
)
{
{
switch
(
opt
)
//разбираем параметры
switch
(
opt
)
//разбираем параметры
{
{
...
@@ -136,6 +138,10 @@ int main(int argc, char** argv)
...
@@ -136,6 +138,10 @@ int main(int argc, char** argv)
usage
();
usage
();
return
0
;
return
0
;
case
'v'
:
verb
=
true
;
break
;
case
'c'
:
//--confile
case
'c'
:
//--confile
conffile
=
optarg
;
conffile
=
optarg
;
break
;
break
;
...
@@ -202,7 +208,8 @@ int main(int argc, char** argv)
...
@@ -202,7 +208,8 @@ int main(int argc, char** argv)
uniset_init
(
argc
,
argv
,
conffile
);
uniset_init
(
argc
,
argv
,
conffile
);
UniversalInterface
ui
(
conf
);
UniversalInterface
ui
(
conf
);
Command
cmd
=
Exist
;
Command
cmd
=
Exist
;
verb
=
true
;
ObjectRepository
*
rep
=
new
ObjectRepository
(
conf
);
ObjectRepository
*
rep
=
new
ObjectRepository
(
conf
);
commandToAll
(
conf
->
getServicesSection
(),
rep
,
(
Command
)
cmd
);
commandToAll
(
conf
->
getServicesSection
(),
rep
,
(
Command
)
cmd
);
commandToAll
(
conf
->
getControllersSection
(),
rep
,
(
Command
)
cmd
);
commandToAll
(
conf
->
getControllersSection
(),
rep
,
(
Command
)
cmd
);
...
@@ -297,26 +304,33 @@ int main(int argc, char** argv)
...
@@ -297,26 +304,33 @@ int main(int argc, char** argv)
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
cout
<<
"admin(main): "
<<
ex
<<
endl
;
if
(
verb
)
cout
<<
"admin(main): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
cerr
<<
"поймали CORBA::SystemException:"
<<
ex
.
NP_minorString
()
<<
endl
;
if
(
verb
)
cerr
<<
"поймали CORBA::SystemException:"
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(
CORBA
::
Exception
&
)
catch
(
CORBA
::
Exception
&
)
{
{
cerr
<<
"поймали CORBA::Exception."
<<
endl
;
if
(
verb
)
cerr
<<
"поймали CORBA::Exception."
<<
endl
;
}
}
catch
(
omniORB
::
fatalException
&
fe
)
catch
(
omniORB
::
fatalException
&
fe
)
{
{
cerr
<<
"поймали omniORB::fatalException:"
<<
endl
;
if
(
verb
)
cerr
<<
" file: "
<<
fe
.
file
()
<<
endl
;
{
cerr
<<
" line: "
<<
fe
.
line
()
<<
endl
;
cerr
<<
"поймали omniORB::fatalException:"
<<
endl
;
cerr
<<
" mesg: "
<<
fe
.
errmsg
()
<<
endl
;
cerr
<<
" file: "
<<
fe
.
file
()
<<
endl
;
cerr
<<
" line: "
<<
fe
.
line
()
<<
endl
;
cerr
<<
" mesg: "
<<
fe
.
errmsg
()
<<
endl
;
}
}
}
catch
(...)
catch
(...)
{
{
cerr
<<
"неизвестное исключение"
<<
endl
;
if
(
verb
)
cerr
<<
"неизвестное исключение"
<<
endl
;
}
}
return
1
;
return
1
;
...
@@ -325,15 +339,17 @@ int main(int argc, char** argv)
...
@@ -325,15 +339,17 @@ int main(int argc, char** argv)
// ==============================================================================================
// ==============================================================================================
static
bool
commandToAll
(
const
string
&
section
,
ObjectRepository
*
rep
,
Command
cmd
)
static
bool
commandToAll
(
const
string
&
section
,
ObjectRepository
*
rep
,
Command
cmd
)
{
{
cout
<<
"
\n
||=======******** "
<<
section
<<
" ********=========||
\n
"
<<
endl
;
if
(
verb
)
cout
<<
"
\n
||=======******** "
<<
section
<<
" ********=========||
\n
"
<<
endl
;
try
try
{
{
ListObjectName
ls
;
ListObjectName
ls
;
rep
->
list
(
section
.
c_str
(),
&
ls
);
rep
->
list
(
section
.
c_str
(),
&
ls
);
if
(
ls
.
empty
()
)
if
(
ls
.
empty
()
)
{
{
cout
<<
"пусто!!!!!!"
<<
endl
;
if
(
verb
)
cout
<<
"пусто!!!!!!"
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -361,7 +377,8 @@ static bool commandToAll(const string& section, ObjectRepository *rep, Command c
...
@@ -361,7 +377,8 @@ static bool commandToAll(const string& section, ObjectRepository *rep, Command c
if
(
CORBA
::
is_nil
(
obj
))
break
;
if
(
CORBA
::
is_nil
(
obj
))
break
;
SystemMessage
msg
(
SystemMessage
::
StartUp
);
SystemMessage
msg
(
SystemMessage
::
StartUp
);
obj
->
push
(
Message
::
transport
(
msg
)
);
obj
->
push
(
Message
::
transport
(
msg
)
);
cout
<<
setw
(
55
)
<<
ob
<<
" <--- start OK"
<<
endl
;
if
(
verb
)
cout
<<
setw
(
55
)
<<
ob
<<
" <--- start OK"
<<
endl
;
}
}
break
;
break
;
...
@@ -370,7 +387,8 @@ static bool commandToAll(const string& section, ObjectRepository *rep, Command c
...
@@ -370,7 +387,8 @@ static bool commandToAll(const string& section, ObjectRepository *rep, Command c
if
(
CORBA
::
is_nil
(
obj
))
break
;
if
(
CORBA
::
is_nil
(
obj
))
break
;
SystemMessage
msg
(
SystemMessage
::
FoldUp
);
SystemMessage
msg
(
SystemMessage
::
FoldUp
);
obj
->
push
(
Message
::
transport
(
msg
)
);
obj
->
push
(
Message
::
transport
(
msg
)
);
cout
<<
setw
(
55
)
<<
ob
<<
" <--- foldUp OK"
<<
endl
;
if
(
verb
)
cout
<<
setw
(
55
)
<<
ob
<<
" <--- foldUp OK"
<<
endl
;
}
}
break
;
break
;
...
@@ -379,15 +397,19 @@ static bool commandToAll(const string& section, ObjectRepository *rep, Command c
...
@@ -379,15 +397,19 @@ static bool commandToAll(const string& section, ObjectRepository *rep, Command c
if
(
CORBA
::
is_nil
(
obj
))
break
;
if
(
CORBA
::
is_nil
(
obj
))
break
;
SystemMessage
msg
(
SystemMessage
::
Finish
);
SystemMessage
msg
(
SystemMessage
::
Finish
);
obj
->
push
(
Message
::
transport
(
msg
)
);
obj
->
push
(
Message
::
transport
(
msg
)
);
cout
<<
setw
(
55
)
<<
ob
<<
" <--- finish OK"
<<
endl
;
if
(
verb
)
cout
<<
setw
(
55
)
<<
ob
<<
" <--- finish OK"
<<
endl
;
}
}
break
;
break
;
case
Exist
:
case
Exist
:
{
{
if
(
obj
->
exist
())
if
(
obj
->
exist
())
cout
<<
setw
(
55
)
<<
ob
<<
" <--- exist ok
\n
"
;
{
else
if
(
verb
)
cout
<<
setw
(
55
)
<<
ob
<<
" <--- exist ok
\n
"
;
}
else
if
(
verb
)
cout
<<
setw
(
55
)
<<
ob
<<
" <--- exist NOT OK
\n
"
;
cout
<<
setw
(
55
)
<<
ob
<<
" <--- exist NOT OK
\n
"
;
}
}
break
;
break
;
...
@@ -396,7 +418,8 @@ static bool commandToAll(const string& section, ObjectRepository *rep, Command c
...
@@ -396,7 +418,8 @@ static bool commandToAll(const string& section, ObjectRepository *rep, Command c
{
{
SystemMessage
sm
(
SystemMessage
::
ReConfiguration
);
SystemMessage
sm
(
SystemMessage
::
ReConfiguration
);
obj
->
push
(
sm
.
transport_msg
());
obj
->
push
(
sm
.
transport_msg
());
cout
<<
setw
(
55
)
<<
ob
<<
" <--- configure ok
\n
"
;
if
(
verb
)
cout
<<
setw
(
55
)
<<
ob
<<
" <--- configure ok
\n
"
;
}
}
break
;
break
;
...
@@ -404,24 +427,28 @@ static bool commandToAll(const string& section, ObjectRepository *rep, Command c
...
@@ -404,24 +427,28 @@ static bool commandToAll(const string& section, ObjectRepository *rep, Command c
{
{
SystemMessage
msg
(
SystemMessage
::
LogRotate
);
SystemMessage
msg
(
SystemMessage
::
LogRotate
);
obj
->
push
(
Message
::
transport
(
msg
)
);
obj
->
push
(
Message
::
transport
(
msg
)
);
cout
<<
setw
(
55
)
<<
ob
<<
" <--- logrotate ok
\n
"
;
if
(
verb
)
cout
<<
setw
(
55
)
<<
ob
<<
" <--- logrotate ok
\n
"
;
break
;
break
;
}
}
default:
default:
{
{
cout
<<
"неизвестная команда -"
<<
cmd
<<
endl
;
if
(
verb
)
cout
<<
"неизвестная команда -"
<<
cmd
<<
endl
;
return
false
;
return
false
;
}
}
}
}
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
cout
<<
setw
(
55
)
<<
ob
<<
" <--- "
<<
ex
<<
endl
;
if
(
verb
)
cout
<<
setw
(
55
)
<<
ob
<<
" <--- "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
cout
<<
setw
(
55
)
<<
ob
<<
" <--- недоступен!!(CORBA::SystemException): "
<<
ex
.
NP_minorString
()
<<
endl
;
if
(
verb
)
cout
<<
setw
(
55
)
<<
ob
<<
" <--- недоступен!!(CORBA::SystemException): "
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
}
}
}
}
...
@@ -443,7 +470,8 @@ static void createSections( UniSetTypes::Configuration* rconf )
...
@@ -443,7 +470,8 @@ static void createSections( UniSetTypes::Configuration* rconf )
repf
.
createRootSection
(
rconf
->
getObjectsSection
());
repf
.
createRootSection
(
rconf
->
getObjectsSection
());
repf
.
createRootSection
(
rconf
->
getControllersSection
());
repf
.
createRootSection
(
rconf
->
getControllersSection
());
repf
.
createRootSection
(
rconf
->
getServicesSection
());
repf
.
createRootSection
(
rconf
->
getServicesSection
());
cout
<<
"(create): created"
<<
endl
;
if
(
verb
)
cout
<<
"(create): created"
<<
endl
;
}
}
// ==============================================================================================
// ==============================================================================================
...
@@ -458,7 +486,8 @@ int omap()
...
@@ -458,7 +486,8 @@ int omap()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
unideb
[
Debug
::
CRIT
]
<<
" configuration init FAILED!!!
\n
"
;
if
(
verb
)
unideb
[
Debug
::
CRIT
]
<<
" configuration init FAILED!!!
\n
"
;
return
1
;
return
1
;
}
}
return
0
;
return
0
;
...
@@ -476,7 +505,8 @@ int msgmap()
...
@@ -476,7 +505,8 @@ int msgmap()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
unideb
[
Debug
::
CRIT
]
<<
" configuration init FAILED!!! "
<<
ex
<<
endl
;;
if
(
verb
)
unideb
[
Debug
::
CRIT
]
<<
" configuration init FAILED!!! "
<<
ex
<<
endl
;;
return
1
;
return
1
;
}
}
...
@@ -490,16 +520,20 @@ int setValue( const string& args, UniversalInterface &ui, Configuration* conf )
...
@@ -490,16 +520,20 @@ int setValue( const string& args, UniversalInterface &ui, Configuration* conf )
typedef
std
::
list
<
UniSetTypes
::
ParamSInfo
>
SList
;
typedef
std
::
list
<
UniSetTypes
::
ParamSInfo
>
SList
;
SList
sl
=
UniSetTypes
::
getSInfoList
(
args
,
conf
);
SList
sl
=
UniSetTypes
::
getSInfoList
(
args
,
conf
);
cout
<<
"====== setValue ======"
<<
endl
;
if
(
verb
)
cout
<<
"====== setValue ======"
<<
endl
;
for
(
SList
::
iterator
it
=
sl
.
begin
();
it
!=
sl
.
end
();
it
++
)
for
(
SList
::
iterator
it
=
sl
.
begin
();
it
!=
sl
.
end
();
it
++
)
{
{
try
try
{
{
UniversalIO
::
IOTypes
t
=
conf
->
getIOType
(
it
->
si
.
id
);
UniversalIO
::
IOTypes
t
=
conf
->
getIOType
(
it
->
si
.
id
);
cout
<<
" value: "
<<
it
->
val
<<
endl
;
if
(
verb
)
cout
<<
" name: ("
<<
it
->
si
.
id
<<
") "
<<
it
->
fname
<<
endl
;
{
cout
<<
" iotype: "
<<
t
<<
endl
;
cout
<<
" value: "
<<
it
->
val
<<
endl
;
cout
<<
" text: "
<<
conf
->
oind
->
getTextName
(
it
->
si
.
id
)
<<
"
\n\n
"
;
cout
<<
" name: ("
<<
it
->
si
.
id
<<
") "
<<
it
->
fname
<<
endl
;
cout
<<
" iotype: "
<<
t
<<
endl
;
cout
<<
" text: "
<<
conf
->
oind
->
getTextName
(
it
->
si
.
id
)
<<
"
\n\n
"
;
}
if
(
it
->
si
.
node
==
DefaultObjectId
)
if
(
it
->
si
.
node
==
DefaultObjectId
)
it
->
si
.
node
=
conf
->
getLocalNode
();
it
->
si
.
node
=
conf
->
getLocalNode
();
...
@@ -523,14 +557,16 @@ int setValue( const string& args, UniversalInterface &ui, Configuration* conf )
...
@@ -523,14 +557,16 @@ int setValue( const string& args, UniversalInterface &ui, Configuration* conf )
break
;
break
;
default:
default:
cerr
<<
"FAILED: Unknown 'iotype' for "
<<
it
->
fname
<<
endl
;
if
(
verb
)
cerr
<<
"FAILED: Unknown 'iotype' for "
<<
it
->
fname
<<
endl
;
err
=
1
;
err
=
1
;
break
;
break
;
}
}
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
cerr
<<
"(setValue): "
<<
ex
<<
endl
;;
if
(
verb
)
cerr
<<
"(setValue): "
<<
ex
<<
endl
;;
err
=
1
;
err
=
1
;
}
}
}
}
...
@@ -545,16 +581,21 @@ int getValue( const string& args, UniversalInterface &ui, Configuration* conf )
...
@@ -545,16 +581,21 @@ int getValue( const string& args, UniversalInterface &ui, Configuration* conf )
typedef
std
::
list
<
UniSetTypes
::
ParamSInfo
>
SList
;
typedef
std
::
list
<
UniSetTypes
::
ParamSInfo
>
SList
;
SList
sl
=
UniSetTypes
::
getSInfoList
(
args
,
UniSetTypes
::
conf
);
SList
sl
=
UniSetTypes
::
getSInfoList
(
args
,
UniSetTypes
::
conf
);
cout
<<
"====== getValue ======"
<<
endl
;
if
(
verb
)
cout
<<
"====== getValue ======"
<<
endl
;
for
(
SList
::
iterator
it
=
sl
.
begin
();
it
!=
sl
.
end
();
it
++
)
for
(
SList
::
iterator
it
=
sl
.
begin
();
it
!=
sl
.
end
();
it
++
)
{
{
try
try
{
{
UniversalIO
::
IOTypes
t
=
conf
->
getIOType
(
it
->
si
.
id
);
UniversalIO
::
IOTypes
t
=
conf
->
getIOType
(
it
->
si
.
id
);
cout
<<
" name: ("
<<
it
->
si
.
id
<<
") "
<<
it
->
fname
<<
endl
;
cout
<<
" iotype: "
<<
t
<<
endl
;
if
(
verb
)
cout
<<
" text: "
<<
conf
->
oind
->
getTextName
(
it
->
si
.
id
)
<<
"
\n\n
"
;
{
cout
<<
" name: ("
<<
it
->
si
.
id
<<
") "
<<
it
->
fname
<<
endl
;
cout
<<
" iotype: "
<<
t
<<
endl
;
cout
<<
" text: "
<<
conf
->
oind
->
getTextName
(
it
->
si
.
id
)
<<
"
\n\n
"
;
}
if
(
it
->
si
.
node
==
DefaultObjectId
)
if
(
it
->
si
.
node
==
DefaultObjectId
)
it
->
si
.
node
=
conf
->
getLocalNode
();
it
->
si
.
node
=
conf
->
getLocalNode
();
...
@@ -562,23 +603,31 @@ int getValue( const string& args, UniversalInterface &ui, Configuration* conf )
...
@@ -562,23 +603,31 @@ int getValue( const string& args, UniversalInterface &ui, Configuration* conf )
{
{
case
UniversalIO
:
:
DigitalOutput
:
case
UniversalIO
:
:
DigitalOutput
:
case
UniversalIO
:
:
DigitalInput
:
case
UniversalIO
:
:
DigitalInput
:
cout
<<
" state: "
<<
ui
.
getState
(
it
->
si
.
id
,
it
->
si
.
node
)
<<
endl
;
if
(
verb
)
cout
<<
" state: "
<<
ui
.
getState
(
it
->
si
.
id
,
it
->
si
.
node
)
<<
endl
;
else
cout
<<
ui
.
getState
(
it
->
si
.
id
,
it
->
si
.
node
);
break
;
break
;
case
UniversalIO
:
:
AnalogOutput
:
case
UniversalIO
:
:
AnalogOutput
:
case
UniversalIO
:
:
AnalogInput
:
case
UniversalIO
:
:
AnalogInput
:
cout
<<
" value: "
<<
ui
.
getValue
(
it
->
si
.
id
,
it
->
si
.
node
)
<<
endl
;
if
(
verb
)
cout
<<
" value: "
<<
ui
.
getValue
(
it
->
si
.
id
,
it
->
si
.
node
)
<<
endl
;
else
cout
<<
ui
.
getValue
(
it
->
si
.
id
,
it
->
si
.
node
);
break
;
break
;
default:
default:
cerr
<<
"FAILED: Unknown 'iotype' for "
<<
it
->
fname
<<
endl
;
if
(
verb
)
cerr
<<
"FAILED: Unknown 'iotype' for "
<<
it
->
fname
<<
endl
;
err
=
1
;
err
=
1
;
break
;
break
;
}
}
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
cerr
<<
"(getValue): "
<<
ex
<<
endl
;
if
(
verb
)
cerr
<<
"(getValue): "
<<
ex
<<
endl
;
err
=
1
;
err
=
1
;
}
}
}
}
...
@@ -591,7 +640,8 @@ int getCalibrate( const std::string& args, UniversalInterface &ui )
...
@@ -591,7 +640,8 @@ int getCalibrate( const std::string& args, UniversalInterface &ui )
int
err
=
0
;
int
err
=
0
;
typedef
std
::
list
<
UniSetTypes
::
ParamSInfo
>
SList
;
typedef
std
::
list
<
UniSetTypes
::
ParamSInfo
>
SList
;
SList
sl
=
UniSetTypes
::
getSInfoList
(
args
,
UniSetTypes
::
conf
);
SList
sl
=
UniSetTypes
::
getSInfoList
(
args
,
UniSetTypes
::
conf
);
cout
<<
"====== getCalibrate ======"
<<
endl
;
if
(
verb
)
cout
<<
"====== getCalibrate ======"
<<
endl
;
for
(
SList
::
iterator
it
=
sl
.
begin
();
it
!=
sl
.
end
();
it
++
)
for
(
SList
::
iterator
it
=
sl
.
begin
();
it
!=
sl
.
end
();
it
++
)
{
{
if
(
it
->
si
.
node
==
DefaultObjectId
)
if
(
it
->
si
.
node
==
DefaultObjectId
)
...
@@ -621,21 +671,30 @@ int getRawValue( const std::string& args, UniversalInterface &ui )
...
@@ -621,21 +671,30 @@ int getRawValue( const std::string& args, UniversalInterface &ui )
int
err
=
0
;
int
err
=
0
;
typedef
std
::
list
<
UniSetTypes
::
ParamSInfo
>
SList
;
typedef
std
::
list
<
UniSetTypes
::
ParamSInfo
>
SList
;
SList
sl
=
UniSetTypes
::
getSInfoList
(
args
,
UniSetTypes
::
conf
);
SList
sl
=
UniSetTypes
::
getSInfoList
(
args
,
UniSetTypes
::
conf
);
cout
<<
"====== getRawValue ======"
<<
endl
;
if
(
verb
)
cout
<<
"====== getRawValue ======"
<<
endl
;
for
(
SList
::
iterator
it
=
sl
.
begin
();
it
!=
sl
.
end
();
it
++
)
for
(
SList
::
iterator
it
=
sl
.
begin
();
it
!=
sl
.
end
();
it
++
)
{
{
if
(
it
->
si
.
node
==
DefaultObjectId
)
if
(
it
->
si
.
node
==
DefaultObjectId
)
it
->
si
.
node
=
conf
->
getLocalNode
();
it
->
si
.
node
=
conf
->
getLocalNode
();
cout
<<
" name: ("
<<
it
->
si
.
id
<<
") "
<<
it
->
fname
<<
endl
;
if
(
verb
)
cout
<<
" text: "
<<
conf
->
oind
->
getTextName
(
it
->
si
.
id
)
<<
"
\n\n
"
;
{
cout
<<
" name: ("
<<
it
->
si
.
id
<<
") "
<<
it
->
fname
<<
endl
;
cout
<<
" text: "
<<
conf
->
oind
->
getTextName
(
it
->
si
.
id
)
<<
"
\n\n
"
;
}
try
try
{
{
cout
<<
" value: "
<<
ui
.
getRawValue
(
it
->
si
)
<<
endl
;
if
(
verb
)
cout
<<
" value: "
<<
ui
.
getRawValue
(
it
->
si
)
<<
endl
;
else
cout
<<
" value: "
<<
ui
.
getRawValue
(
it
->
si
);
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
cerr
<<
"(getRawValue): "
<<
ex
<<
endl
;;
if
(
verb
)
cerr
<<
"(getRawValue): "
<<
ex
<<
endl
;;
err
=
1
;
err
=
1
;
}
}
}
}
...
@@ -659,14 +718,16 @@ int logRotate( const string& arg, UniversalInterface &ui )
...
@@ -659,14 +718,16 @@ int logRotate( const string& arg, UniversalInterface &ui )
UniSetTypes
::
ObjectId
id
=
conf
->
oind
->
getIdByName
(
arg
);
UniSetTypes
::
ObjectId
id
=
conf
->
oind
->
getIdByName
(
arg
);
if
(
id
==
DefaultObjectId
)
if
(
id
==
DefaultObjectId
)
{
{
cout
<<
"(logrotate): name='"
<<
arg
<<
"' не найдено!!!
\n
"
;
if
(
verb
)
cout
<<
"(logrotate): name='"
<<
arg
<<
"' не найдено!!!
\n
"
;
return
1
;
return
1
;
}
}
SystemMessage
sm
(
SystemMessage
::
LogRotate
);
SystemMessage
sm
(
SystemMessage
::
LogRotate
);
TransportMessage
tm
(
sm
.
transport_msg
());
TransportMessage
tm
(
sm
.
transport_msg
());
ui
.
send
(
id
,
tm
);
ui
.
send
(
id
,
tm
);
cout
<<
"
\n
Send 'LogRotate' to "
<<
arg
<<
" OK.
\n
"
;
if
(
verb
)
cout
<<
"
\n
Send 'LogRotate' to "
<<
arg
<<
" OK.
\n
"
;
}
}
return
0
;
return
0
;
}
}
...
@@ -688,13 +749,15 @@ int configure( const string& arg, UniversalInterface &ui )
...
@@ -688,13 +749,15 @@ int configure( const string& arg, UniversalInterface &ui )
UniSetTypes
::
ObjectId
id
=
conf
->
oind
->
getIdByName
(
arg
);
UniSetTypes
::
ObjectId
id
=
conf
->
oind
->
getIdByName
(
arg
);
if
(
id
==
DefaultObjectId
)
if
(
id
==
DefaultObjectId
)
{
{
cout
<<
"(configure): name='"
<<
arg
<<
"' не найдено!!!
\n
"
;
if
(
verb
)
cout
<<
"(configure): name='"
<<
arg
<<
"' не найдено!!!
\n
"
;
return
1
;
return
1
;
}
}
SystemMessage
sm
(
SystemMessage
::
ReConfiguration
);
SystemMessage
sm
(
SystemMessage
::
ReConfiguration
);
TransportMessage
tm
(
sm
.
transport_msg
());
TransportMessage
tm
(
sm
.
transport_msg
());
ui
.
send
(
id
,
tm
);
ui
.
send
(
id
,
tm
);
cout
<<
"
\n
Send 'ReConfigure' to "
<<
arg
<<
" OK.
\n
"
;
if
(
verb
)
cout
<<
"
\n
Send 'ReConfigure' to "
<<
arg
<<
" OK.
\n
"
;
}
}
return
0
;
return
0
;
}
}
...
@@ -705,7 +768,8 @@ int oinfo( const string& arg, UniversalInterface &ui )
...
@@ -705,7 +768,8 @@ int oinfo( const string& arg, UniversalInterface &ui )
UniSetTypes
::
ObjectId
oid
(
uni_atoi
(
arg
));
UniSetTypes
::
ObjectId
oid
(
uni_atoi
(
arg
));
if
(
oid
==
0
)
if
(
oid
==
0
)
{
{
cout
<<
"(oinfo): Не задан OID!"
<<
endl
;
if
(
verb
)
cout
<<
"(oinfo): Не задан OID!"
<<
endl
;
return
1
;
return
1
;
}
}
...
@@ -713,7 +777,8 @@ int oinfo( const string& arg, UniversalInterface &ui )
...
@@ -713,7 +777,8 @@ int oinfo( const string& arg, UniversalInterface &ui )
UniSetObject_i_var
obj
=
UniSetObject_i
::
_narrow
(
o
);
UniSetObject_i_var
obj
=
UniSetObject_i
::
_narrow
(
o
);
if
(
CORBA
::
is_nil
(
obj
))
if
(
CORBA
::
is_nil
(
obj
))
{
{
cout
<<
"(oinfo): объект "
<<
oid
<<
" недоступен"
<<
endl
;
if
(
verb
)
cout
<<
"(oinfo): объект "
<<
oid
<<
" недоступен"
<<
endl
;
}
}
else
else
{
{
...
...
Utilities/Admin/admin.sh
View file @
6700fc00
#!/bin/sh
#!/bin/sh
./uniset-start.sh
-f
"./uniset-admin --confile test.xml --
`
basename
$0
.sh
`
$1
$2
$3
$4
"
./uniset-start.sh
-f
"./uniset-admin --confile test.xml --
`
basename
$0
.sh
`
$1
$2
$3
$4
$5
"
exit
$?
exit
$?
Utilities/codegen/ctl-cpp-cc-alone-ask.xsl
View file @
6700fc00
...
@@ -194,6 +194,9 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
...
@@ -194,6 +194,9 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
ui.setValue(_sid, _val);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::askState( UniSetTypes::ObjectId _sid, UniversalIO::UIOCommand _cmd, UniSetTypes::ObjectId _node )
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::askState( UniSetTypes::ObjectId _sid, UniversalIO::UIOCommand _cmd, UniSetTypes::ObjectId _node )
...
@@ -243,16 +246,16 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
...
@@ -243,16 +246,16 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
unideb[Debug::CRIT]
<<
myname
<<
"(getState): Обращение к неизвестному ДИСКРЕТНОМУ датчику sid="
<<
_sid
<<
endl;
return 0
;
return ui.getValue(_sid)
;
}
}
catch(Exception
&
ex)
catch(Exception
&
ex)
{
{
unideb[Debug::CRIT]
<<
myname
<<
"(getState): "
<<
ex
<<
endl;
unideb[Debug::CRIT]
<<
myname
<<
"(getState): "
<<
ex
<<
endl;
throw;
throw;
}
}
return 0;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::updateOutputs( bool _force )
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::updateOutputs( bool _force )
...
@@ -262,7 +265,9 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
...
@@ -262,7 +265,9 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
<xsl:if
test=
"normalize-space(../../@msg)!='1'"
>
<xsl:if
test=
"normalize-space(../../@msg)!='1'"
>
<xsl:choose>
<xsl:choose>
<xsl:when
test=
"normalize-space(@vartype)='out'"
>
<xsl:when
test=
"normalize-space(@vartype)='out'"
>
<xsl:if
test=
"normalize-space(../../@force)=''"
>
if( _force || prev_
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"../../@name"
/>
!=
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"../../@name"
/>
)
if( _force || prev_
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"../../@name"
/>
!=
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"../../@name"
/>
)
</xsl:if>
{
{
<xsl:call-template
name=
"setdata"
/>
<xsl:call-template
name=
"setdata"
/>
prev_
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"../../@name"
/>
=
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"../../@name"
/>
;
prev_
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"../../@name"
/>
=
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"../../@name"
/>
;
...
...
Utilities/codegen/ctl-cpp-cc-alone.xsl
View file @
6700fc00
...
@@ -173,6 +173,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
...
@@ -173,6 +173,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
ui.setValue( _sid, _val );
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -192,10 +194,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
...
@@ -192,10 +194,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
unideb[Debug::CRIT]
<<
myname
<<
"(getState): Обращение к неизвестному ДИСКРЕТНОМУ датчику sid="
return ui.getValue(_sid);
<<
_sid
<<
endl;
return 0;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::updateOutputs( bool _force )
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::updateOutputs( bool _force )
...
...
Utilities/codegen/ctl-cpp-cc-ask.xsl
View file @
6700fc00
...
@@ -120,12 +120,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
...
@@ -120,12 +120,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
}
}
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
ui.setValue( _sid, _val );
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::updateOutputs( bool _force )
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::updateOutputs( bool _force )
{
{
<xsl:for-each
select=
"//smap/item"
>
<xsl:for-each
select=
"//smap/item"
>
<xsl:if
test=
"normalize-space(@force)=''"
>
if( _force || prev_
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"@name"
/>
!=
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"@name"
/>
)
if( _force || prev_
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"@name"
/>
!=
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"@name"
/>
)
</xsl:if>
{
{
<xsl:choose>
<xsl:choose>
<xsl:when
test=
"normalize-space(@vartype)='out'"
><xsl:call-template
name=
"setdata"
/></xsl:when>
<xsl:when
test=
"normalize-space(@vartype)='out'"
><xsl:call-template
name=
"setdata"
/></xsl:when>
...
@@ -210,16 +214,14 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
...
@@ -210,16 +214,14 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
</xsl:choose>
</xsl:choose>
}
}
</xsl:for-each>
</xsl:for-each>
unideb[Debug::CRIT]
<<
myname
<<
"(getState): Обращение к неизвестному ДИСКРЕТНОМУ датчику sid="
<<
_sid
<<
endl
;
return ui.getValue(_sid)
;
}
}
catch(Exception
&
ex)
catch(Exception
&
ex)
{
{
unideb[Debug::CRIT]
<<
myname
<<
"(getState): "
<<
ex
<<
endl;
unideb[Debug::CRIT]
<<
myname
<<
"(getState): "
<<
ex
<<
endl;
throw;
throw;
}
}
return 0;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
...
Utilities/codegen/ctl-cpp-cc.xsl
View file @
6700fc00
...
@@ -124,6 +124,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId sid
...
@@ -124,6 +124,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId sid
}
}
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
ui.setValue( sid, val );
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::updateOutputs( bool force )
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::updateOutputs( bool force )
...
@@ -190,9 +192,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
...
@@ -190,9 +192,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
return
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"@name"
/>
;
return
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"@name"
/>
;
</xsl:for-each>
</xsl:for-each>
unideb[Debug::CRIT]
<<
myname
<<
"(getState): Обращение к неизвестному ДИСКРЕТНОМУ датчику sid="
return ui.getValue(_sid);
<<
_sid
<<
endl;
return 0;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::preSensorInfo( UniSetTypes::SensorMessage* sm )
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::preSensorInfo( UniSetTypes::SensorMessage* sm )
...
...
Utilities/codegen/tests/testgen.src.xml
View file @
6700fc00
...
@@ -42,7 +42,9 @@
...
@@ -42,7 +42,9 @@
<item
name=
"input1_s"
vartype=
"in"
iotype=
"DI"
comment=
"comment for input1"
smTestID=
"1"
/>
<item
name=
"input1_s"
vartype=
"in"
iotype=
"DI"
comment=
"comment for input1"
smTestID=
"1"
/>
<item
name=
"input2_s"
vartype=
"in"
iotype=
"DI"
comment=
"comment for input2"
/>
<item
name=
"input2_s"
vartype=
"in"
iotype=
"DI"
comment=
"comment for input2"
/>
<item
name=
"output1_c"
vartype=
"out"
iotype=
"DO"
omment=
"comment for output1"
no_check_id=
"1"
/>
<item
name=
"output1_c"
vartype=
"out"
iotype=
"DO"
omment=
"comment for output1"
no_check_id=
"1"
/>
<item
name=
"output2_c"
vartype=
"out"
iotype=
"DO"
omment=
"comment for output2"
no_check_id=
"1"
force=
"1"
/>
<item
name=
"loglevel_s"
vartype=
"in"
iotype=
"AI"
omment=
"log level control"
loglevel=
"1"
/>
<item
name=
"loglevel_s"
vartype=
"in"
iotype=
"AI"
omment=
"log level control"
loglevel=
"1"
/>
</smap>
</smap>
<msgmap>
<msgmap>
...
...
conf/libuniset.spec
View file @
6700fc00
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
Name: libuniset
Name: libuniset
Version: 1.7
Version: 1.7
Release: alt
7
Release: alt
15
Summary: UniSet - library for building distributed industrial control systems
Summary: UniSet - library for building distributed industrial control systems
...
@@ -336,6 +336,32 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
...
@@ -336,6 +336,32 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet.pc
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
%changelog
* Sun Jun 22 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt15
- optimization: add insert-buffer for DBServer_MySQL (see uniset-docs)
* Sat Jun 14 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt14
- backport UTCPStream for MBTCPMultiMaster
* Tue Apr 29 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt13
- (uniset-codegen): add "force" parameters for vartype="out"
* Thu Apr 24 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt12
- remove deprecated Extensions:getHeartBeatTime(). Use conf->getHeartBeatTime()
- rename parameter: "time_msec" --> "msec" for <HeartBeatTime msec=""/>
* Thu Apr 24 2014 Pavel Vainerman <pv@server> 1.7-alt11
- minor fixes IOControl::setValue
* Tue Apr 01 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt10
- add new vtype: F2r, I2r, U2r (reverse data order)
* Wed Mar 19 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt9
- add thresholds processing for ModbusMaster (TCP and RTU)
- minor fixes
* Fri Mar 07 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt8
- fixed bug in ComPort class (getTimeout. eterbug #9890)
* Wed Feb 12 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt7
* Wed Feb 12 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt7
- revert last changes ("ModbusMaster: add thread for check connection")
- revert last changes ("ModbusMaster: add thread for check connection")
...
...
conf/test.xml
View file @
6700fc00
...
@@ -55,8 +55,9 @@
...
@@ -55,8 +55,9 @@
<item
addr=
"0x01"
invert=
"0"
modeSensor=
"MB1_Mode_AS"
respondSensor=
"RespondRTU_S"
timeout=
"5000"
/>
<item
addr=
"0x01"
invert=
"0"
modeSensor=
"MB1_Mode_AS"
respondSensor=
"RespondRTU_S"
timeout=
"5000"
/>
</DeviceList>
</DeviceList>
<GateList>
<GateList>
<item
ip=
"127.0.0.1"
port=
"2048"
recv_timeout=
"200"
/>
<item
ip=
"192.168.56.60"
port=
"2048"
recv_timeout=
"200"
/>
<item
ip=
"127.0.0.1"
port=
"2049"
recv_timeout=
"200"
/>
<item
ip=
"10.10.2.1"
port=
"2049"
recv_timeout=
"200"
/>
<item
ip=
"localhost"
port=
"2048"
recv_timeout=
"200"
/>
</GateList>
</GateList>
</MBMultiMaster1>
</MBMultiMaster1>
<MBSlave2
addr=
"0x3"
>
<MBSlave2
addr=
"0x3"
>
...
...
extensions/DBServer-MySQL/DBInterface.cc
View file @
6700fc00
...
@@ -47,13 +47,14 @@ DBInterface::~DBInterface()
...
@@ -47,13 +47,14 @@ DBInterface::~DBInterface()
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
bool
DBInterface
::
connect
(
const
string
&
host
,
const
string
&
user
,
const
string
&
pswd
,
const
string
&
dbname
)
bool
DBInterface
::
connect
(
const
string
&
host
,
const
string
&
user
,
const
string
&
pswd
,
const
string
&
dbname
)
{
{
if
(
!
mysql_real_connect
(
mysql
,
host
.
c_str
(),
user
.
c_str
(),
pswd
.
c_str
(),
dbname
.
c_str
(),
0
,
NULL
,
0
)
)
if
(
!
mysql_real_connect
(
mysql
,
host
.
c_str
(),
user
.
c_str
(),
pswd
.
c_str
(),
dbname
.
c_str
(),
0
,
NULL
,
0
)
)
// CLIENT_MULTI_STATEMENTS)
)
{
{
cout
<<
error
()
<<
endl
;
cout
<<
error
()
<<
endl
;
mysql_close
(
mysql
);
mysql_close
(
mysql
);
connected
=
false
;
connected
=
false
;
return
false
;
return
false
;
}
}
connected
=
true
;
connected
=
true
;
return
true
;
return
true
;
}
}
...
@@ -78,28 +79,45 @@ bool DBInterface::insert( const string& q )
...
@@ -78,28 +79,45 @@ bool DBInterface::insert( const string& q )
queryok
=
true
;
queryok
=
true
;
return
true
;
return
true
;
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
bool
DBInterface
::
query
(
const
string
&
q
)
bool
DBInterface
::
query
(
const
string
&
q
)
{
{
return
query
(
q
.
c_str
(),
true
);
}
// -----------------------------------------------------------------------------------------
bool
DBInterface
::
query
(
const
char
*
q
,
bool
noLastQ
)
{
if
(
!
mysql
)
if
(
!
mysql
)
return
false
;
return
false
;
if
(
mysql_query
(
mysql
,
q
.
c_str
()
)
)
if
(
mysql_query
(
mysql
,
q
)
)
{
{
queryok
=
false
;
queryok
=
false
;
return
false
;
return
false
;
}
}
lastQ
=
(
noLastQ
)
?
q
:
""
;
lastQ
=
q
;
result
=
mysql_store_result
(
mysql
);
// _use_result - некорректно работает с _num_rows
result
=
mysql_store_result
(
mysql
);
// _use_result - некорректно работает с _num_rows
#if 0
// Если при соединении используется CLIENT_MULTI_STATEMENTS
// то необходимо вынуть все результаты..
while( mysql_more_results(mysql) )
{
cerr << "**** store result..." << endl;
if( mysql_next_result(mysql) >=0 )
mysql_store_result(mysql);
}
#endif
if
(
numRows
()
==
0
)
if
(
numRows
()
==
0
)
{
{
queryok
=
false
;
queryok
=
false
;
return
false
;
return
false
;
}
}
queryok
=
true
;
queryok
=
true
;
return
true
;
return
true
;
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
...
...
extensions/DBServer-MySQL/DBInterface.h
View file @
6700fc00
...
@@ -47,6 +47,8 @@ class DBInterface
...
@@ -47,6 +47,8 @@ class DBInterface
bool
close
();
bool
close
();
bool
query
(
const
std
::
string
&
q
);
bool
query
(
const
std
::
string
&
q
);
bool
query
(
const
char
*
q
,
bool
noLastQ
=
false
);
// noLastQ - не запоминать запрос
const
std
::
string
lastQuery
();
const
std
::
string
lastQuery
();
bool
insert
(
const
std
::
string
&
q
);
bool
insert
(
const
std
::
string
&
q
);
...
...
extensions/DBServer-MySQL/DBServer_MySQL.cc
View file @
6700fc00
...
@@ -282,7 +282,7 @@ void DBServer_MySQL::parse( UniSetTypes::SensorMessage *si )
...
@@ -282,7 +282,7 @@ void DBServer_MySQL::parse( UniSetTypes::SensorMessage *si )
gettimeofday
(
&
si
->
tm
,
&
tz
);
gettimeofday
(
&
si
->
tm
,
&
tz
);
}
}
// см.
DBTABLE AnalogSensors, DigitalSensors
// см.
main_history
ostringstream
data
;
ostringstream
data
;
data
<<
"INSERT INTO "
<<
tblName
(
si
->
type
)
data
<<
"INSERT INTO "
<<
tblName
(
si
->
type
)
<<
"(date, time, time_usec, sensor_id, value, node) VALUES( '"
<<
"(date, time, time_usec, sensor_id, value, node) VALUES( '"
...
...
extensions/DBServer-SQLite/DBServer_SQLite.cc
View file @
6700fc00
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include <sys/time.h>
#include <sys/time.h>
#include <sstream>
#include <sstream>
#include <iomanip>
#include <iomanip>
#include <cmath>
#include "ORepHelpers.h"
#include "ORepHelpers.h"
#include "DBServer_SQLite.h"
#include "DBServer_SQLite.h"
...
@@ -258,7 +259,9 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si )
...
@@ -258,7 +259,9 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si )
struct
timezone
tz
;
struct
timezone
tz
;
gettimeofday
(
&
si
->
tm
,
&
tz
);
gettimeofday
(
&
si
->
tm
,
&
tz
);
}
}
float
val
=
(
float
)
si
->
value
/
(
float
)
pow10
(
si
->
ci
.
precision
);
// см. DBTABLE AnalogSensors, DigitalSensors
// см. DBTABLE AnalogSensors, DigitalSensors
ostringstream
data
;
ostringstream
data
;
data
<<
"INSERT INTO "
<<
tblName
(
si
->
type
)
data
<<
"INSERT INTO "
<<
tblName
(
si
->
type
)
...
@@ -266,10 +269,10 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si )
...
@@ -266,10 +269,10 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si )
// Поля таблицы
// Поля таблицы
<<
ui
.
dateToString
(
si
->
sm_tv_sec
,
"-"
)
<<
"','"
// date
<<
ui
.
dateToString
(
si
->
sm_tv_sec
,
"-"
)
<<
"','"
// date
<<
ui
.
timeToString
(
si
->
sm_tv_sec
,
":"
)
<<
"','"
// time
<<
ui
.
timeToString
(
si
->
sm_tv_sec
,
":"
)
<<
"','"
// time
<<
si
->
sm_tv_usec
<<
"',"
// time_usec
<<
si
->
sm_tv_usec
<<
"',
'
"
// time_usec
<<
si
->
id
<<
"
,
"
// sensor_id
<<
si
->
id
<<
"
','
"
// sensor_id
<<
si
->
value
<<
"
,
"
// value
<<
si
->
value
<<
"
','
"
// value
<<
si
->
node
<<
")"
;
// node
<<
si
->
node
<<
"
'
)"
;
// node
if
(
unideb
.
debugging
(
DBLEVEL
)
)
if
(
unideb
.
debugging
(
DBLEVEL
)
)
unideb
[
DBLEVEL
]
<<
myname
<<
"(insert_main_history): "
<<
data
.
str
()
<<
endl
;
unideb
[
DBLEVEL
]
<<
myname
<<
"(insert_main_history): "
<<
data
.
str
()
<<
endl
;
...
...
extensions/LogicProcessor/PassiveLProcessor.cc
View file @
6700fc00
...
@@ -28,7 +28,7 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o
...
@@ -28,7 +28,7 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o
throw
SystemError
(
err
.
str
());
throw
SystemError
(
err
.
str
());
}
}
int
heartbeatTime
=
getHeartBeatTime
(
);
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-heartbeat-time"
,
conf
->
getHeartBeatTime
()
);
if
(
heartbeatTime
)
if
(
heartbeatTime
)
ptHeartBeat
.
setTiming
(
heartbeatTime
);
ptHeartBeat
.
setTiming
(
heartbeatTime
);
else
else
...
...
extensions/ModbusMaster/MBExchange.cc
View file @
6700fc00
...
@@ -80,7 +80,7 @@ pollActivated(false)
...
@@ -80,7 +80,7 @@ pollActivated(false)
initPause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-initPause"
,
it
.
getProp
(
"initPause"
),
3000
);
initPause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-initPause"
,
it
.
getProp
(
"initPause"
),
3000
);
sleepPause_usec
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-sleepPause-usec"
,
it
.
getProp
(
"sle
pe
Pause"
),
100
);
sleepPause_usec
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-sleepPause-usec"
,
it
.
getProp
(
"sle
ep
Pause"
),
100
);
force
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-force"
,
it
.
getProp
(
"force"
));
force
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-force"
,
it
.
getProp
(
"force"
));
force_out
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-force-out"
,
it
.
getProp
(
"force_out"
));
force_out
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-force-out"
,
it
.
getProp
(
"force_out"
));
...
@@ -99,7 +99,7 @@ pollActivated(false)
...
@@ -99,7 +99,7 @@ pollActivated(false)
throw
SystemError
(
err
.
str
());
throw
SystemError
(
err
.
str
());
}
}
int
heartbeatTime
=
getHeartBeatTime
(
);
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-heartbeat-time"
,
it
.
getProp
(
"heartbeatTime"
),
conf
->
getHeartBeatTime
()
);
if
(
heartbeatTime
)
if
(
heartbeatTime
)
ptHeartBeat
.
setTiming
(
heartbeatTime
);
ptHeartBeat
.
setTiming
(
heartbeatTime
);
else
else
...
@@ -309,9 +309,17 @@ void MBExchange::initIterators()
...
@@ -309,9 +309,17 @@ void MBExchange::initIterators()
{
{
shm
->
initDIterator
(
it2
->
dit
);
shm
->
initDIterator
(
it2
->
dit
);
shm
->
initAIterator
(
it2
->
ait
);
shm
->
initAIterator
(
it2
->
ait
);
shm
->
initAIterator
(
it2
->
t_ait
);
}
}
}
}
}
}
for
(
ThresholdList
::
iterator
t
=
thrlist
.
begin
();
t
!=
thrlist
.
end
();
++
t
)
{
shm
->
initDIterator
(
t
->
dit
);
shm
->
initAIterator
(
t
->
ait
);
shm
->
initAIterator
(
t
->
t_ait
);
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
bool
MBExchange
::
checkUpdateSM
(
bool
wrFunc
,
long
mdev
)
bool
MBExchange
::
checkUpdateSM
(
bool
wrFunc
,
long
mdev
)
...
@@ -725,6 +733,11 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
...
@@ -725,6 +733,11 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
VTypes
::
F2
f
(
data
,
VTypes
::
F2
::
wsize
());
VTypes
::
F2
f
(
data
,
VTypes
::
F2
::
wsize
());
IOBase
::
processingFasAI
(
p
,
(
float
)
f
,
shm
,
true
);
IOBase
::
processingFasAI
(
p
,
(
float
)
f
,
shm
,
true
);
}
}
else
if
(
p
->
vType
==
VTypes
::
vtF2r
)
{
VTypes
::
F2r
f
(
data
,
VTypes
::
F2r
::
wsize
());
IOBase
::
processingFasAI
(
p
,
(
float
)
f
,
shm
,
true
);
}
else
if
(
p
->
vType
==
VTypes
::
vtF4
)
else
if
(
p
->
vType
==
VTypes
::
vtF4
)
{
{
VTypes
::
F4
f
(
data
,
VTypes
::
F4
::
wsize
());
VTypes
::
F4
f
(
data
,
VTypes
::
F4
::
wsize
());
...
@@ -735,11 +748,21 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
...
@@ -735,11 +748,21 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
VTypes
::
I2
i2
(
data
,
VTypes
::
I2
::
wsize
());
VTypes
::
I2
i2
(
data
,
VTypes
::
I2
::
wsize
());
IOBase
::
processingAsAI
(
p
,
(
int
)
i2
,
shm
,
true
);
IOBase
::
processingAsAI
(
p
,
(
int
)
i2
,
shm
,
true
);
}
}
else
if
(
p
->
vType
==
VTypes
::
vtI2r
)
{
VTypes
::
I2r
i2
(
data
,
VTypes
::
I2
::
wsize
());
IOBase
::
processingAsAI
(
p
,
(
int
)
i2
,
shm
,
true
);
}
else
if
(
p
->
vType
==
VTypes
::
vtU2
)
else
if
(
p
->
vType
==
VTypes
::
vtU2
)
{
{
VTypes
::
U2
u2
(
data
,
VTypes
::
U2
::
wsize
());
VTypes
::
U2
u2
(
data
,
VTypes
::
U2
::
wsize
());
IOBase
::
processingAsAI
(
p
,
(
unsigned
int
)
u2
,
shm
,
true
);
IOBase
::
processingAsAI
(
p
,
(
unsigned
int
)
u2
,
shm
,
true
);
}
}
else
if
(
p
->
vType
==
VTypes
::
vtU2r
)
{
VTypes
::
U2r
u2
(
data
,
VTypes
::
U2
::
wsize
());
IOBase
::
processingAsAI
(
p
,
(
unsigned
int
)
u2
,
shm
,
true
);
}
return
true
;
return
true
;
}
}
...
@@ -1257,7 +1280,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1257,7 +1280,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
return
;
return
;
}
}
else
if
(
p
->
vType
==
VTypes
::
vtF2
)
else
if
(
p
->
vType
==
VTypes
::
vtF2
||
p
->
vType
==
VTypes
::
vtF2r
)
{
{
RegMap
::
iterator
i
(
p
->
reg
->
rit
);
RegMap
::
iterator
i
(
p
->
reg
->
rit
);
if
(
save
)
if
(
save
)
...
@@ -1265,9 +1288,18 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1265,9 +1288,18 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
if
(
r
->
mb_initOK
)
if
(
r
->
mb_initOK
)
{
{
float
f
=
IOBase
::
processingFasAO
(
p
,
shm
,
force_out
);
float
f
=
IOBase
::
processingFasAO
(
p
,
shm
,
force_out
);
VTypes
::
F2
f2
(
f
);
if
(
p
->
vType
==
VTypes
::
vtF2
)
for
(
int
k
=
0
;
k
<
VTypes
::
F2
::
wsize
();
k
++
,
i
++
)
{
i
->
second
->
mbval
=
f2
.
raw
.
v
[
k
];
VTypes
::
F2
f2
(
f
);
for
(
int
k
=
0
;
k
<
VTypes
::
F2
::
wsize
();
k
++
,
i
++
)
i
->
second
->
mbval
=
f2
.
raw
.
v
[
k
];
}
else
if
(
p
->
vType
==
VTypes
::
vtF2r
)
{
VTypes
::
F2r
f2
(
f
);
for
(
int
k
=
0
;
k
<
VTypes
::
F2r
::
wsize
();
k
++
,
i
++
)
i
->
second
->
mbval
=
f2
.
raw
.
v
[
k
];
}
r
->
sm_initOK
=
true
;
r
->
sm_initOK
=
true
;
}
}
...
@@ -1277,11 +1309,22 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1277,11 +1309,22 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
ModbusRTU
::
ModbusData
*
data
=
new
ModbusRTU
::
ModbusData
[
VTypes
::
F2
::
wsize
()];
ModbusRTU
::
ModbusData
*
data
=
new
ModbusRTU
::
ModbusData
[
VTypes
::
F2
::
wsize
()];
for
(
int
k
=
0
;
k
<
VTypes
::
F2
::
wsize
();
k
++
,
i
++
)
for
(
int
k
=
0
;
k
<
VTypes
::
F2
::
wsize
();
k
++
,
i
++
)
data
[
k
]
=
i
->
second
->
mbval
;
data
[
k
]
=
i
->
second
->
mbval
;
VTypes
::
F2
f
(
data
,
VTypes
::
F2
::
wsize
());
float
f
=
0
;
if
(
p
->
vType
==
VTypes
::
vtF2
)
{
VTypes
::
F2
f1
(
data
,
VTypes
::
F2
::
wsize
());
f
=
(
float
)
f1
;
}
else
if
(
p
->
vType
==
VTypes
::
vtF2r
)
{
VTypes
::
F2r
f1
(
data
,
VTypes
::
F2r
::
wsize
());
f
=
(
float
)
f1
;
}
delete
[]
data
;
delete
[]
data
;
IOBase
::
processingFasAI
(
p
,
(
float
)
f
,
shm
,
force
);
IOBase
::
processingFasAI
(
p
,
f
,
shm
,
force
);
}
}
}
}
else
if
(
p
->
vType
==
VTypes
::
vtF4
)
else
if
(
p
->
vType
==
VTypes
::
vtF4
)
...
@@ -1309,7 +1352,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1309,7 +1352,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
IOBase
::
processingFasAI
(
p
,
(
float
)
f
,
shm
,
force
);
IOBase
::
processingFasAI
(
p
,
(
float
)
f
,
shm
,
force
);
}
}
}
}
else
if
(
p
->
vType
==
VTypes
::
vtI2
)
else
if
(
p
->
vType
==
VTypes
::
vtI2
||
p
->
vType
==
VTypes
::
vtI2r
)
{
{
RegMap
::
iterator
i
(
p
->
reg
->
rit
);
RegMap
::
iterator
i
(
p
->
reg
->
rit
);
if
(
save
)
if
(
save
)
...
@@ -1317,10 +1360,18 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1317,10 +1360,18 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
if
(
r
->
mb_initOK
)
if
(
r
->
mb_initOK
)
{
{
long
v
=
IOBase
::
processingAsAO
(
p
,
shm
,
force_out
);
long
v
=
IOBase
::
processingAsAO
(
p
,
shm
,
force_out
);
VTypes
::
I2
i2
(
v
);
if
(
p
->
vType
==
VTypes
::
vtI2
)
for
(
int
k
=
0
;
k
<
VTypes
::
I2
::
wsize
();
k
++
,
i
++
)
{
i
->
second
->
mbval
=
i2
.
raw
.
v
[
k
];
VTypes
::
I2
i2
(
v
);
for
(
int
k
=
0
;
k
<
VTypes
::
I2
::
wsize
();
k
++
,
i
++
)
i
->
second
->
mbval
=
i2
.
raw
.
v
[
k
];
}
else
if
(
p
->
vType
==
VTypes
::
vtI2r
)
{
VTypes
::
I2r
i2
(
v
);
for
(
int
k
=
0
;
k
<
VTypes
::
I2
::
wsize
();
k
++
,
i
++
)
i
->
second
->
mbval
=
i2
.
raw
.
v
[
k
];
}
r
->
sm_initOK
=
true
;
r
->
sm_initOK
=
true
;
}
}
}
}
...
@@ -1330,13 +1381,23 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1330,13 +1381,23 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
for
(
int
k
=
0
;
k
<
VTypes
::
I2
::
wsize
();
k
++
,
i
++
)
for
(
int
k
=
0
;
k
<
VTypes
::
I2
::
wsize
();
k
++
,
i
++
)
data
[
k
]
=
i
->
second
->
mbval
;
data
[
k
]
=
i
->
second
->
mbval
;
VTypes
::
I2
i2
(
data
,
VTypes
::
I2
::
wsize
());
int
v
=
0
;
if
(
p
->
vType
==
VTypes
::
vtI2
)
{
VTypes
::
I2
i2
(
data
,
VTypes
::
I2
::
wsize
());
v
=
(
int
)
i2
;
}
else
if
(
p
->
vType
==
VTypes
::
vtI2r
)
{
VTypes
::
I2r
i2
(
data
,
VTypes
::
I2
::
wsize
());
v
=
(
int
)
i2
;
}
delete
[]
data
;
delete
[]
data
;
IOBase
::
processingAsAI
(
p
,
v
,
shm
,
force
);
IOBase
::
processingAsAI
(
p
,
(
int
)
i2
,
shm
,
force
);
}
}
}
}
else
if
(
p
->
vType
==
VTypes
::
vtU2
)
else
if
(
p
->
vType
==
VTypes
::
vtU2
||
p
->
vType
==
VTypes
::
vtU2r
)
{
{
RegMap
::
iterator
i
(
p
->
reg
->
rit
);
RegMap
::
iterator
i
(
p
->
reg
->
rit
);
if
(
save
)
if
(
save
)
...
@@ -1344,9 +1405,18 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1344,9 +1405,18 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
if
(
r
->
mb_initOK
)
if
(
r
->
mb_initOK
)
{
{
long
v
=
IOBase
::
processingAsAO
(
p
,
shm
,
force_out
);
long
v
=
IOBase
::
processingAsAO
(
p
,
shm
,
force_out
);
VTypes
::
U2
u2
(
v
);
if
(
p
->
vType
==
VTypes
::
vtU2
)
for
(
int
k
=
0
;
k
<
VTypes
::
U2
::
wsize
();
k
++
,
i
++
)
{
i
->
second
->
mbval
=
u2
.
raw
.
v
[
k
];
VTypes
::
U2
u2
(
v
);
for
(
int
k
=
0
;
k
<
VTypes
::
U2
::
wsize
();
k
++
,
i
++
)
i
->
second
->
mbval
=
u2
.
raw
.
v
[
k
];
}
else
if
(
p
->
vType
==
VTypes
::
vtU2r
)
{
VTypes
::
U2r
u2
(
v
);
for
(
int
k
=
0
;
k
<
VTypes
::
U2
::
wsize
();
k
++
,
i
++
)
i
->
second
->
mbval
=
u2
.
raw
.
v
[
k
];
}
r
->
sm_initOK
=
true
;
r
->
sm_initOK
=
true
;
}
}
...
@@ -1357,16 +1427,26 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1357,16 +1427,26 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
for
(
int
k
=
0
;
k
<
VTypes
::
U2
::
wsize
();
k
++
,
i
++
)
for
(
int
k
=
0
;
k
<
VTypes
::
U2
::
wsize
();
k
++
,
i
++
)
data
[
k
]
=
i
->
second
->
mbval
;
data
[
k
]
=
i
->
second
->
mbval
;
VTypes
::
U2
u2
(
data
,
VTypes
::
U2
::
wsize
());
unsigned
int
v
=
0
;
if
(
p
->
vType
==
VTypes
::
vtU2
)
{
VTypes
::
U2
u2
(
data
,
VTypes
::
U2
::
wsize
());
v
=
(
unsigned
int
)
u2
;
}
else
if
(
p
->
vType
==
VTypes
::
vtU2r
)
{
VTypes
::
U2r
u2
(
data
,
VTypes
::
U2
::
wsize
());
v
=
(
unsigned
int
)
u2
;
}
delete
[]
data
;
delete
[]
data
;
IOBase
::
processingAsAI
(
p
,
v
,
shm
,
force
);
IOBase
::
processingAsAI
(
p
,
(
unsigned
int
)
u2
,
shm
,
force
);
}
}
}
}
return
;
return
;
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty):(NameNotFound) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
...
@@ -1832,6 +1912,15 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
...
@@ -1832,6 +1912,15 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
if
(
!
IOBase
::
initItem
(
&
p
,
it
,
shm
,
&
dlog
,
myname
)
)
if
(
!
IOBase
::
initItem
(
&
p
,
it
,
shm
,
&
dlog
,
myname
)
)
return
false
;
return
false
;
// проверяем не пороговый ли это датчик (т.е. не связанный с обменом)
// тогда заносим его в отдельный список
if
(
p
.
t_ai
!=
DefaultObjectId
)
{
thrlist
.
push_back
(
p
);
return
true
;
}
if
(
it
.
getIntProp
(
prop_prefix
+
"rawdata"
)
)
if
(
it
.
getIntProp
(
prop_prefix
+
"rawdata"
)
)
{
{
p
.
cal
.
minRaw
=
0
;
p
.
cal
.
minRaw
=
0
;
...
@@ -2838,18 +2927,12 @@ void MBExchange::poll()
...
@@ -2838,18 +2927,12 @@ void MBExchange::poll()
updateSM
();
updateSM
();
// check thresholds
// check thresholds
for
(
MBExchange
::
RTUDeviceMap
::
iterator
it1
=
rmap
.
begin
();
it1
!=
rmap
.
end
();
++
it1
)
for
(
ThresholdList
::
iterator
t
=
thrlist
.
begin
();
t
!=
thrlist
.
end
();
++
t
)
{
{
RTUDevice
*
d
(
it1
->
second
);
if
(
!
checkProcActive
()
)
for
(
MBExchange
::
RegMap
::
iterator
it
=
d
->
regmap
.
begin
();
it
!=
d
->
regmap
.
end
();
++
it
)
return
;
{
if
(
!
checkProcActive
()
)
IOBase
::
processingThreshold
(
&
(
*
t
),
shm
,
force
);
return
;
RegInfo
*
r
(
it
->
second
);
for
(
PList
::
iterator
i
=
r
->
slst
.
begin
();
i
!=
r
->
slst
.
end
();
++
i
)
IOBase
::
processingThreshold
(
&
(
*
i
),
shm
,
force
);
}
}
}
if
(
trReopen
.
hi
(
allNotRespond
)
)
if
(
trReopen
.
hi
(
allNotRespond
)
)
...
...
extensions/ModbusMaster/MBExchange.h
View file @
6700fc00
...
@@ -325,6 +325,11 @@ class MBExchange:
...
@@ -325,6 +325,11 @@ class MBExchange:
PassiveTimer
ptReopen
;
/*!< таймер для переоткрытия соединения */
PassiveTimer
ptReopen
;
/*!< таймер для переоткрытия соединения */
Trigger
trReopen
;
Trigger
trReopen
;
// т.к. пороговые датчики не связаны напрямую с обменом, создаём для них отдельный список
// и отдельно его проверяем потом
typedef
std
::
list
<
IOBase
>
ThresholdList
;
ThresholdList
thrlist
;
private
:
private
:
MBExchange
();
MBExchange
();
...
...
extensions/ModbusMaster/RTUExchange.cc
View file @
6700fc00
...
@@ -301,17 +301,14 @@ void RTUExchange::poll()
...
@@ -301,17 +301,14 @@ void RTUExchange::poll()
updateSM
();
updateSM
();
// check thresholds
// check thresholds
for
(
MBExchange
::
RTUDeviceMap
::
iterator
it1
=
rmap
.
begin
();
it1
!=
rmap
.
end
();
++
it1
)
for
(
ThresholdList
::
iterator
t
=
thrlist
.
begin
();
t
!=
thrlist
.
end
();
++
t
)
{
{
RTUDevice
*
d
(
it1
->
second
);
if
(
!
checkProcActive
()
)
for
(
RTUExchange
::
RegMap
::
iterator
it
=
d
->
regmap
.
begin
();
it
!=
d
->
regmap
.
end
();
++
it
)
return
;
{
RegInfo
*
r
(
it
->
second
);
IOBase
::
processingThreshold
(
&
(
*
t
),
shm
,
force
);
for
(
PList
::
iterator
i
=
r
->
slst
.
begin
();
i
!=
r
->
slst
.
end
();
++
i
)
IOBase
::
processingThreshold
(
&
(
*
i
),
shm
,
force
);
}
}
}
if
(
trReopen
.
hi
(
allNotRespond
)
)
if
(
trReopen
.
hi
(
allNotRespond
)
)
ptReopen
.
reset
();
ptReopen
.
reset
();
...
...
extensions/ModbusMaster/start_fg_mbtcpmulti.sh
View file @
6700fc00
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
--mbtcp-recv-timeout
3000
\
--mbtcp-recv-timeout
3000
\
--mbtcp-timeout
2000
\
--mbtcp-timeout
2000
\
--mbtcp-force-disconnect
1
\
--mbtcp-force-disconnect
1
\
--mbtcp-polltime
30
00
\
--mbtcp-polltime
1
00
\
--mbtcp-force-out
1
\
--mbtcp-force-out
1
\
$*
$*
...
...
extensions/ModbusMaster/vtconv.cc
View file @
6700fc00
...
@@ -9,11 +9,11 @@ using namespace VTypes;
...
@@ -9,11 +9,11 @@ using namespace VTypes;
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
static
void
print_help
()
static
void
print_help
()
{
{
printf
(
"Usage: vtconv TYPE[F2|F
4|I2|U2
] hex1 hex2 [hex3 hex4]
\n
"
);
printf
(
"Usage: vtconv TYPE[F2|F
2r|F4|I2|U2|I2r|U2r
] hex1 hex2 [hex3 hex4]
\n
"
);
}
}
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
int
main
(
int
argc
,
const
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
{
{
/*
/*
VTypes::F2 f2;
VTypes::F2 f2;
f2.raw.val = 2.345;
f2.raw.val = 2.345;
...
@@ -89,6 +89,13 @@ int main( int argc, const char **argv )
...
@@ -89,6 +89,13 @@ int main( int argc, const char **argv )
<<
" v[1]="
<<
v
[
1
]
<<
" v[1]="
<<
v
[
1
]
<<
" --> (float) "
<<
(
float
)
f
<<
endl
;
<<
" --> (float) "
<<
(
float
)
f
<<
endl
;
}
}
else
if
(
!
strcmp
(
type
,
"F2r"
)
)
{
VTypes
::
F2r
f
(
v
,
sizeof
(
v
));
cout
<<
"(F2r): v[0]="
<<
v
[
0
]
<<
" v[1]="
<<
v
[
1
]
<<
" --> (float) "
<<
(
float
)
f
<<
endl
;
}
else
if
(
!
strcmp
(
type
,
"F4"
)
)
else
if
(
!
strcmp
(
type
,
"F4"
)
)
{
{
VTypes
::
F4
f
(
v
,
sizeof
(
v
));
VTypes
::
F4
f
(
v
,
sizeof
(
v
));
...
@@ -105,6 +112,13 @@ int main( int argc, const char **argv )
...
@@ -105,6 +112,13 @@ int main( int argc, const char **argv )
<<
" v[1]="
<<
v
[
1
]
<<
" v[1]="
<<
v
[
1
]
<<
" --> (int) "
<<
(
int
)
i
<<
endl
;
<<
" --> (int) "
<<
(
int
)
i
<<
endl
;
}
}
else
if
(
!
strcmp
(
type
,
"I2r"
)
)
{
VTypes
::
I2r
i
(
v
,
sizeof
(
v
));
cout
<<
"(I2r): v[0]="
<<
v
[
0
]
<<
" v[1]="
<<
v
[
1
]
<<
" --> (int) "
<<
(
int
)
i
<<
endl
;
}
else
if
(
!
strcmp
(
type
,
"U2"
)
)
else
if
(
!
strcmp
(
type
,
"U2"
)
)
{
{
VTypes
::
U2
i
(
v
,
sizeof
(
v
));
VTypes
::
U2
i
(
v
,
sizeof
(
v
));
...
@@ -112,6 +126,13 @@ int main( int argc, const char **argv )
...
@@ -112,6 +126,13 @@ int main( int argc, const char **argv )
<<
" v[1]="
<<
v
[
1
]
<<
" v[1]="
<<
v
[
1
]
<<
" --> (unsigned int) "
<<
(
unsigned
int
)
i
<<
endl
;
<<
" --> (unsigned int) "
<<
(
unsigned
int
)
i
<<
endl
;
}
}
else
if
(
!
strcmp
(
type
,
"U2r"
)
)
{
VTypes
::
U2r
i
(
v
,
sizeof
(
v
));
cout
<<
"(U2r): v[0]="
<<
v
[
0
]
<<
" v[1]="
<<
v
[
1
]
<<
" --> (unsigned int) "
<<
(
unsigned
int
)
i
<<
endl
;
}
else
else
{
{
cout
<<
" Unknown type: "
<<
type
<<
endl
;
cout
<<
" Unknown type: "
<<
type
<<
endl
;
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
6700fc00
...
@@ -77,8 +77,8 @@ prefix(prefix)
...
@@ -77,8 +77,8 @@ prefix(prefix)
if
(
speed
.
empty
()
)
if
(
speed
.
empty
()
)
speed
=
"38400"
;
speed
=
"38400"
;
bool
use485F
=
conf
->
getArgInt
(
"--
rs
-use485F"
,
it
.
getProp
(
"use485F"
));
bool
use485F
=
conf
->
getArgInt
(
"--
"
+
prefix
+
"
-use485F"
,
it
.
getProp
(
"use485F"
));
bool
transmitCtl
=
conf
->
getArgInt
(
"--
rs
-transmit-ctl"
,
it
.
getProp
(
"transmitCtl"
));
bool
transmitCtl
=
conf
->
getArgInt
(
"--
"
+
prefix
+
"
-transmit-ctl"
,
it
.
getProp
(
"transmitCtl"
));
ModbusRTUSlaveSlot
*
rs
=
new
ModbusRTUSlaveSlot
(
dev
,
use485F
,
transmitCtl
);
ModbusRTUSlaveSlot
*
rs
=
new
ModbusRTUSlaveSlot
(
dev
,
use485F
,
transmitCtl
);
rs
->
setSpeed
(
speed
);
rs
->
setSpeed
(
speed
);
...
@@ -160,7 +160,7 @@ prefix(prefix)
...
@@ -160,7 +160,7 @@ prefix(prefix)
throw
SystemError
(
err
.
str
());
throw
SystemError
(
err
.
str
());
}
}
int
heartbeatTime
=
getHeartBeatTime
(
);
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-heartbeat-time"
,
it
.
getProp
(
"heartbeatTime"
),
conf
->
getHeartBeatTime
()
);
if
(
heartbeatTime
)
if
(
heartbeatTime
)
ptHeartBeat
.
setTiming
(
heartbeatTime
);
ptHeartBeat
.
setTiming
(
heartbeatTime
);
else
else
...
@@ -186,7 +186,7 @@ prefix(prefix)
...
@@ -186,7 +186,7 @@ prefix(prefix)
dlog
[
Debug
::
INFO
]
<<
myname
<<
": init test_id="
<<
test_id
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
": init test_id="
<<
test_id
<<
endl
;
wait_msec
=
getHeartBeatTime
()
-
100
;
wait_msec
=
conf
->
getHeartBeatTime
()
-
100
;
if
(
wait_msec
<
500
)
if
(
wait_msec
<
500
)
wait_msec
=
500
;
wait_msec
=
500
;
...
@@ -197,7 +197,6 @@ prefix(prefix)
...
@@ -197,7 +197,6 @@ prefix(prefix)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): rs-timeout="
<<
msec
<<
" msec"
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): rs-timeout="
<<
msec
<<
" msec"
<<
endl
;
// build file list...
// build file list...
xmlNode
*
fnode
=
0
;
xmlNode
*
fnode
=
0
;
UniXML
*
xml
=
conf
->
getConfXML
();
UniXML
*
xml
=
conf
->
getConfXML
();
...
@@ -1287,7 +1286,7 @@ ModbusRTU::mbErrCode MBSlave::real_read_it( IOMap::iterator& it, ModbusRTU::Modb
...
@@ -1287,7 +1286,7 @@ ModbusRTU::mbErrCode MBSlave::real_read_it( IOMap::iterator& it, ModbusRTU::Modb
{
{
val
=
IOBase
::
processingAsAO
(
p
,
shm
,
force
);
val
=
IOBase
::
processingAsAO
(
p
,
shm
,
force
);
}
}
if
(
p
->
vtype
==
VTypes
::
vtF2
)
else
if
(
p
->
vtype
==
VTypes
::
vtF2
)
{
{
float
f
=
IOBase
::
processingFasAO
(
p
,
shm
,
force
);
float
f
=
IOBase
::
processingFasAO
(
p
,
shm
,
force
);
VTypes
::
F2
f2
(
f
);
VTypes
::
F2
f2
(
f
);
...
@@ -1297,6 +1296,16 @@ ModbusRTU::mbErrCode MBSlave::real_read_it( IOMap::iterator& it, ModbusRTU::Modb
...
@@ -1297,6 +1296,16 @@ ModbusRTU::mbErrCode MBSlave::real_read_it( IOMap::iterator& it, ModbusRTU::Modb
// if( p->wnum >=0 && p->wnum < f4.wsize()
// if( p->wnum >=0 && p->wnum < f4.wsize()
val
=
f2
.
raw
.
v
[
p
->
wnum
];
val
=
f2
.
raw
.
v
[
p
->
wnum
];
}
}
else
if
(
p
->
vtype
==
VTypes
::
vtF2r
)
{
float
f
=
IOBase
::
processingFasAO
(
p
,
shm
,
force
);
VTypes
::
F2r
f2
(
f
);
// оптимизируем и проверку не делаем
// считая, что при "загрузке" всё было правильно
// инициализировано
// if( p->wnum >=0 && p->wnum < f4.wsize()
val
=
f2
.
raw
.
v
[
p
->
wnum
];
}
else
if
(
p
->
vtype
==
VTypes
::
vtF4
)
else
if
(
p
->
vtype
==
VTypes
::
vtF4
)
{
{
float
f
=
IOBase
::
processingFasAO
(
p
,
shm
,
force
);
float
f
=
IOBase
::
processingFasAO
(
p
,
shm
,
force
);
...
@@ -1317,6 +1326,16 @@ ModbusRTU::mbErrCode MBSlave::real_read_it( IOMap::iterator& it, ModbusRTU::Modb
...
@@ -1317,6 +1326,16 @@ ModbusRTU::mbErrCode MBSlave::real_read_it( IOMap::iterator& it, ModbusRTU::Modb
// if( p->wnum >=0 && p->wnum < i2.wsize()
// if( p->wnum >=0 && p->wnum < i2.wsize()
val
=
i2
.
raw
.
v
[
p
->
wnum
];
val
=
i2
.
raw
.
v
[
p
->
wnum
];
}
}
else
if
(
p
->
vtype
==
VTypes
::
vtI2r
)
{
long
v
=
IOBase
::
processingAsAO
(
p
,
shm
,
force
);
VTypes
::
I2r
i2
(
v
);
// оптимизируем и проверку не делаем
// считая, что при "загрузке" всё было правильно
// инициализировано
// if( p->wnum >=0 && p->wnum < i2.wsize()
val
=
i2
.
raw
.
v
[
p
->
wnum
];
}
else
if
(
p
->
vtype
==
VTypes
::
vtU2
)
else
if
(
p
->
vtype
==
VTypes
::
vtU2
)
{
{
unsigned
long
v
=
IOBase
::
processingAsAO
(
p
,
shm
,
force
);
unsigned
long
v
=
IOBase
::
processingAsAO
(
p
,
shm
,
force
);
...
@@ -1327,6 +1346,16 @@ ModbusRTU::mbErrCode MBSlave::real_read_it( IOMap::iterator& it, ModbusRTU::Modb
...
@@ -1327,6 +1346,16 @@ ModbusRTU::mbErrCode MBSlave::real_read_it( IOMap::iterator& it, ModbusRTU::Modb
// if( p->wnum >=0 && p->wnum < u2.wsize()
// if( p->wnum >=0 && p->wnum < u2.wsize()
val
=
u2
.
raw
.
v
[
p
->
wnum
];
val
=
u2
.
raw
.
v
[
p
->
wnum
];
}
}
else
if
(
p
->
vtype
==
VTypes
::
vtU2r
)
{
unsigned
long
v
=
IOBase
::
processingAsAO
(
p
,
shm
,
force
);
VTypes
::
U2r
u2
(
v
);
// оптимизируем и проверку не делаем
// считая, что при "загрузке" всё было правильно
// инициализировано
// if( p->wnum >=0 && p->wnum < u2.wsize()
val
=
u2
.
raw
.
v
[
p
->
wnum
];
}
else
else
val
=
IOBase
::
processingAsAO
(
p
,
shm
,
force
);
val
=
IOBase
::
processingAsAO
(
p
,
shm
,
force
);
}
}
...
...
extensions/SMDBServer/SMDBServer.cc
View file @
6700fc00
...
@@ -46,7 +46,7 @@ prefix(prefix)
...
@@ -46,7 +46,7 @@ prefix(prefix)
throw
SystemError
(
err
.
str
());
throw
SystemError
(
err
.
str
());
}
}
int
heartbeatTime
=
getHeartBeatTime
(
);
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-heartbeat-time"
,
it
.
getProp
(
"heartbeatTime"
),
conf
->
getHeartBeatTime
()
);
if
(
heartbeatTime
)
if
(
heartbeatTime
)
ptHeartBeat
.
setTiming
(
heartbeatTime
);
ptHeartBeat
.
setTiming
(
heartbeatTime
);
else
else
...
...
extensions/SharedMemory/SharedMemory.cc
View file @
6700fc00
...
@@ -32,6 +32,7 @@ void SharedMemory::help_print( int argc, const char* const* argv )
...
@@ -32,6 +32,7 @@ void SharedMemory::help_print( int argc, const char* const* argv )
cout
<<
"--pulsar-id - датчик 'мигания'"
<<
endl
;
cout
<<
"--pulsar-id - датчик 'мигания'"
<<
endl
;
cout
<<
"--pulsar-msec - период 'мигания'. По умолчанию: 5000."
<<
endl
;
cout
<<
"--pulsar-msec - период 'мигания'. По умолчанию: 5000."
<<
endl
;
cout
<<
"--pulsar-iotype - [DI|DO]тип датчика для 'мигания'. По умолчанию DI."
<<
endl
;
cout
<<
"--pulsar-iotype - [DI|DO]тип датчика для 'мигания'. По умолчанию DI."
<<
endl
;
cout
<<
"--db-logging [1,0] - Включение логирования в DBServer. По умолчанию 0 (выключено)"
<<
endl
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
SharedMemory
::
SharedMemory
(
ObjectId
id
,
string
datafile
,
std
::
string
confname
)
:
SharedMemory
::
SharedMemory
(
ObjectId
id
,
string
datafile
,
std
::
string
confname
)
:
...
...
extensions/SharedMemory/smemory.cc
View file @
6700fc00
...
@@ -44,19 +44,19 @@ int main(int argc, const char **argv)
...
@@ -44,19 +44,19 @@ int main(int argc, const char **argv)
}
}
catch
(
SystemError
&
err
)
catch
(
SystemError
&
err
)
{
{
unideb
[
Debug
::
CRIT
]
<<
"(smemory): "
<<
err
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
"(smemory): "
<<
err
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
unideb
[
Debug
::
CRIT
]
<<
"(smemory): "
<<
ex
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
"(smemory): "
<<
ex
<<
endl
;
}
}
catch
(
std
::
exception
&
e
)
catch
(
std
::
exception
&
e
)
{
{
unideb
[
Debug
::
CRIT
]
<<
"(smemory): "
<<
e
.
what
()
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
"(smemory): "
<<
e
.
what
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
unideb
[
Debug
::
CRIT
]
<<
"(smemory): catch(...)"
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
"(smemory): catch(...)"
<<
endl
;
}
}
return
1
;
return
1
;
...
...
extensions/UNetUDP/UNetExchange.cc
View file @
6700fc00
...
@@ -56,15 +56,15 @@ sender2(0)
...
@@ -56,15 +56,15 @@ sender2(0)
UniXML_iterator
n_it
(
nodes
);
UniXML_iterator
n_it
(
nodes
);
string
default_ip
(
n_it
.
getProp
(
"unet
_broadcast_ip"
));
string
default_ip
(
n_it
.
getProp
(
prefix
+
"
_broadcast_ip"
));
string
default_ip2
(
n_it
.
getProp
(
"unet
_broadcast_ip2"
));
string
default_ip2
(
n_it
.
getProp
(
prefix
+
"
_broadcast_ip2"
));
if
(
!
n_it
.
goChildren
()
)
if
(
!
n_it
.
goChildren
()
)
throw
UniSetTypes
::
SystemError
(
"(UNetExchange): Items not found for <nodes>"
);
throw
UniSetTypes
::
SystemError
(
"(UNetExchange): Items not found for <nodes>"
);
for
(
;
n_it
.
getCurrent
();
n_it
.
goNext
()
)
for
(
;
n_it
.
getCurrent
();
n_it
.
goNext
()
)
{
{
if
(
n_it
.
getIntProp
(
"unet
_ignore"
)
)
if
(
n_it
.
getIntProp
(
prefix
+
"
_ignore"
)
)
{
{
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): unet_ignore.. for "
<<
n_it
.
getProp
(
"name"
)
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): unet_ignore.. for "
<<
n_it
.
getProp
(
"name"
)
<<
endl
;
continue
;
continue
;
...
@@ -80,13 +80,13 @@ sender2(0)
...
@@ -80,13 +80,13 @@ sender2(0)
string
h2
(
""
);
string
h2
(
""
);
if
(
!
default_ip
.
empty
()
)
if
(
!
default_ip
.
empty
()
)
h
=
default_ip
;
h
=
default_ip
;
if
(
!
n_it
.
getProp
(
"unet
_broadcast_ip"
).
empty
()
)
if
(
!
n_it
.
getProp
(
prefix
+
"
_broadcast_ip"
).
empty
()
)
h
=
n_it
.
getProp
(
"unet
_broadcast_ip"
);
h
=
n_it
.
getProp
(
prefix
+
"
_broadcast_ip"
);
if
(
!
default_ip2
.
empty
()
)
if
(
!
default_ip2
.
empty
()
)
h2
=
default_ip2
;
h2
=
default_ip2
;
if
(
!
n_it
.
getProp
(
"unet
_broadcast_ip2"
).
empty
()
)
if
(
!
n_it
.
getProp
(
prefix
+
"
_broadcast_ip2"
).
empty
()
)
h2
=
n_it
.
getProp
(
"unet
_broadcast_ip2"
);
h2
=
n_it
.
getProp
(
prefix
+
"
_broadcast_ip2"
);
if
(
h
.
empty
()
)
if
(
h
.
empty
()
)
{
{
...
@@ -102,12 +102,12 @@ sender2(0)
...
@@ -102,12 +102,12 @@ sender2(0)
// Если указано поле unet_port - используем его
// Если указано поле unet_port - используем его
// Иначе port = идентификатору узла
// Иначе port = идентификатору узла
int
p
=
n_it
.
getIntProp
(
"id"
);
int
p
=
n_it
.
getIntProp
(
"id"
);
if
(
!
n_it
.
getProp
(
"unet
_port"
).
empty
()
)
if
(
!
n_it
.
getProp
(
prefix
+
"
_port"
).
empty
()
)
p
=
n_it
.
getIntProp
(
"unet
_port"
);
p
=
n_it
.
getIntProp
(
prefix
+
"
_port"
);
int
p2
=
p
;
// по умолчанию порт на втором канале такой же как на первом
int
p2
=
p
;
// по умолчанию порт на втором канале такой же как на первом
if
(
!
n_it
.
getProp
(
"unet
_port2"
).
empty
()
)
if
(
!
n_it
.
getProp
(
prefix
+
"
_port2"
).
empty
()
)
p2
=
n_it
.
getIntProp
(
"unet
_port2"
);
p2
=
n_it
.
getIntProp
(
prefix
+
"
_port2"
);
string
n
(
n_it
.
getProp
(
"name"
));
string
n
(
n_it
.
getProp
(
"name"
));
if
(
n
==
conf
->
getLocalNodeName
()
)
if
(
n
==
conf
->
getLocalNodeName
()
)
...
@@ -152,9 +152,9 @@ sender2(0)
...
@@ -152,9 +152,9 @@ sender2(0)
continue
;
continue
;
}
}
bool
resp_invert
=
n_it
.
getIntProp
(
"unet
_respond_invert"
);
bool
resp_invert
=
n_it
.
getIntProp
(
prefix
+
"
_respond_invert"
);
string
s_resp_id
(
n_it
.
getProp
(
"unet
_respond1_id"
));
string
s_resp_id
(
n_it
.
getProp
(
prefix
+
"
_respond1_id"
));
UniSetTypes
::
ObjectId
resp_id
=
UniSetTypes
::
DefaultObjectId
;
UniSetTypes
::
ObjectId
resp_id
=
UniSetTypes
::
DefaultObjectId
;
if
(
!
s_resp_id
.
empty
()
)
if
(
!
s_resp_id
.
empty
()
)
{
{
...
@@ -168,7 +168,7 @@ sender2(0)
...
@@ -168,7 +168,7 @@ sender2(0)
}
}
}
}
string
s_resp2_id
(
n_it
.
getProp
(
"unet
_respond2_id"
));
string
s_resp2_id
(
n_it
.
getProp
(
prefix
+
"
_respond2_id"
));
UniSetTypes
::
ObjectId
resp2_id
=
UniSetTypes
::
DefaultObjectId
;
UniSetTypes
::
ObjectId
resp2_id
=
UniSetTypes
::
DefaultObjectId
;
if
(
!
s_resp2_id
.
empty
()
)
if
(
!
s_resp2_id
.
empty
()
)
{
{
...
@@ -182,7 +182,7 @@ sender2(0)
...
@@ -182,7 +182,7 @@ sender2(0)
}
}
}
}
string
s_lp_id
(
n_it
.
getProp
(
"unet
_lostpackets1_id"
));
string
s_lp_id
(
n_it
.
getProp
(
prefix
+
"
_lostpackets1_id"
));
UniSetTypes
::
ObjectId
lp_id
=
UniSetTypes
::
DefaultObjectId
;
UniSetTypes
::
ObjectId
lp_id
=
UniSetTypes
::
DefaultObjectId
;
if
(
!
s_lp_id
.
empty
()
)
if
(
!
s_lp_id
.
empty
()
)
{
{
...
@@ -196,7 +196,7 @@ sender2(0)
...
@@ -196,7 +196,7 @@ sender2(0)
}
}
}
}
string
s_lp2_id
(
n_it
.
getProp
(
"unet
_lostpackets2_id"
));
string
s_lp2_id
(
n_it
.
getProp
(
prefix
+
"
_lostpackets2_id"
));
UniSetTypes
::
ObjectId
lp2_id
=
UniSetTypes
::
DefaultObjectId
;
UniSetTypes
::
ObjectId
lp2_id
=
UniSetTypes
::
DefaultObjectId
;
if
(
!
s_lp2_id
.
empty
()
)
if
(
!
s_lp2_id
.
empty
()
)
{
{
...
@@ -210,7 +210,7 @@ sender2(0)
...
@@ -210,7 +210,7 @@ sender2(0)
}
}
}
}
string
s_lp_comm_id
(
n_it
.
getProp
(
"unet
_lostpackets_id"
));
string
s_lp_comm_id
(
n_it
.
getProp
(
prefix
+
"
_lostpackets_id"
));
UniSetTypes
::
ObjectId
lp_comm_id
=
UniSetTypes
::
DefaultObjectId
;
UniSetTypes
::
ObjectId
lp_comm_id
=
UniSetTypes
::
DefaultObjectId
;
if
(
!
s_lp_comm_id
.
empty
()
)
if
(
!
s_lp_comm_id
.
empty
()
)
{
{
...
@@ -224,7 +224,7 @@ sender2(0)
...
@@ -224,7 +224,7 @@ sender2(0)
}
}
}
}
string
s_resp_comm_id
(
n_it
.
getProp
(
"unet
_respond_id"
));
string
s_resp_comm_id
(
n_it
.
getProp
(
prefix
+
"
_respond_id"
));
UniSetTypes
::
ObjectId
resp_comm_id
=
UniSetTypes
::
DefaultObjectId
;
UniSetTypes
::
ObjectId
resp_comm_id
=
UniSetTypes
::
DefaultObjectId
;
if
(
!
s_resp_comm_id
.
empty
()
)
if
(
!
s_resp_comm_id
.
empty
()
)
{
{
...
@@ -310,7 +310,7 @@ sender2(0)
...
@@ -310,7 +310,7 @@ sender2(0)
throw
SystemError
(
err
.
str
());
throw
SystemError
(
err
.
str
());
}
}
int
heartbeatTime
=
getHeartBeatTime
(
);
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-heartbeat-time"
,
it
.
getProp
(
"heartbeatTime"
),
conf
->
getHeartBeatTime
()
);
if
(
heartbeatTime
)
if
(
heartbeatTime
)
ptHeartBeat
.
setTiming
(
heartbeatTime
);
ptHeartBeat
.
setTiming
(
heartbeatTime
);
else
else
...
@@ -776,4 +776,24 @@ void UNetExchange::receiverEvent( UNetReceiver* r, UNetReceiver::Event ev )
...
@@ -776,4 +776,24 @@ void UNetExchange::receiverEvent( UNetReceiver* r, UNetReceiver::Event ev )
}
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UNetExchange
::
ignore_item
(
UniSetTypes
::
ObjectId
id
,
bool
set
)
{
std
::
list
<
UNetReceiver
*>
rList
=
get_receivers
();
std
::
list
<
UNetReceiver
*>::
iterator
rIt
=
rList
.
begin
();
for
(;
rIt
!=
rList
.
end
();
++
rIt
)
(
*
rIt
)
->
ignore_item
(
id
,
set
);
}
// -----------------------------------------------------------------------------
std
::
list
<
UNetReceiver
*>
UNetExchange
::
get_receivers
()
{
std
::
list
<
UNetReceiver
*>
tList
;
for
(
ReceiverList
::
iterator
it
=
recvlist
.
begin
();
it
!=
recvlist
.
end
();
++
it
)
{
if
(
it
->
r1
)
tList
.
push_back
(
it
->
r1
);
if
(
it
->
r2
)
tList
.
push_back
(
it
->
r2
);
}
return
tList
;
}
// -----------------------------------------------------------------------------
extensions/UNetUDP/UNetExchange.h
View file @
6700fc00
...
@@ -90,7 +90,10 @@ class UNetExchange:
...
@@ -90,7 +90,10 @@ class UNetExchange:
static
void
help_print
(
int
argc
,
const
char
*
argv
[]
);
static
void
help_print
(
int
argc
,
const
char
*
argv
[]
);
bool
checkExistUNetHost
(
const
std
::
string
&
host
,
ost
::
tpport_t
port
);
bool
checkExistUNetHost
(
const
std
::
string
&
host
,
ost
::
tpport_t
port
);
std
::
list
<
UNetReceiver
*>
get_receivers
();
/*! игнорировать запись датчика в SM */
void
ignore_item
(
UniSetTypes
::
ObjectId
id
=
UniSetTypes
::
DefaultObjectId
,
bool
set
=
true
);
protected
:
protected
:
xmlNode
*
cnode
;
xmlNode
*
cnode
;
...
...
extensions/UNetUDP/UNetReceiver.cc
View file @
6700fc00
...
@@ -297,8 +297,9 @@ void UNetReceiver::real_update()
...
@@ -297,8 +297,9 @@ void UNetReceiver::real_update()
if
(
lockUpdate
)
if
(
lockUpdate
)
continue
;
continue
;
}
}
if
(
ii
.
ignore
)
if
(
ii
.
iotype
==
UniversalIO
::
DigitalInput
)
continue
;
else
if
(
ii
.
iotype
==
UniversalIO
::
DigitalInput
)
shm
->
localSaveState
(
ii
.
dit
,
id
,
val
,
shm
->
ID
());
shm
->
localSaveState
(
ii
.
dit
,
id
,
val
,
shm
->
ID
());
else
if
(
ii
.
iotype
==
UniversalIO
::
AnalogInput
)
else
if
(
ii
.
iotype
==
UniversalIO
::
AnalogInput
)
shm
->
localSaveValue
(
ii
.
ait
,
id
,
val
,
shm
->
ID
());
shm
->
localSaveValue
(
ii
.
ait
,
id
,
val
,
shm
->
ID
());
...
@@ -341,7 +342,9 @@ void UNetReceiver::real_update()
...
@@ -341,7 +342,9 @@ void UNetReceiver::real_update()
continue
;
continue
;
}
}
if
(
ii
.
iotype
==
UniversalIO
::
DigitalInput
)
if
(
ii
.
ignore
)
continue
;
else
if
(
ii
.
iotype
==
UniversalIO
::
DigitalInput
)
shm
->
localSaveState
(
ii
.
dit
,
d
.
id
,
d
.
val
,
shm
->
ID
());
shm
->
localSaveState
(
ii
.
dit
,
d
.
id
,
d
.
val
,
shm
->
ID
());
else
if
(
ii
.
iotype
==
UniversalIO
::
AnalogInput
)
else
if
(
ii
.
iotype
==
UniversalIO
::
AnalogInput
)
shm
->
localSaveValue
(
ii
.
ait
,
d
.
id
,
d
.
val
,
shm
->
ID
());
shm
->
localSaveValue
(
ii
.
ait
,
d
.
id
,
d
.
val
,
shm
->
ID
());
...
@@ -519,6 +522,30 @@ void UNetReceiver::initIterators()
...
@@ -519,6 +522,30 @@ void UNetReceiver::initIterators()
}
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UNetReceiver
::
ignore_item
(
UniSetTypes
::
ObjectId
id
,
bool
set
)
{
for
(
ItemVec
::
iterator
it
=
d_icache
.
begin
();
it
!=
d_icache
.
end
();
++
it
)
{
if
(
id
==
UniSetTypes
::
DefaultObjectId
)
it
->
ignore
=
set
;
else
if
(
id
==
it
->
id
)
{
it
->
ignore
=
set
;
return
;
}
}
for
(
ItemVec
::
iterator
it
=
a_icache
.
begin
();
it
!=
a_icache
.
end
();
++
it
)
{
if
(
id
==
UniSetTypes
::
DefaultObjectId
)
it
->
ignore
=
set
;
else
if
(
id
==
it
->
id
)
{
it
->
ignore
=
set
;
return
;
}
}
}
// -----------------------------------------------------------------------------
void
UNetReceiver
::
initDCache
(
UniSetUDP
::
UDPMessage
&
pack
,
bool
force
)
void
UNetReceiver
::
initDCache
(
UniSetUDP
::
UDPMessage
&
pack
,
bool
force
)
{
{
if
(
!
force
&&
pack
.
dcount
==
d_icache
.
size
()
)
if
(
!
force
&&
pack
.
dcount
==
d_icache
.
size
()
)
...
...
extensions/UNetUDP/UNetReceiver.h
View file @
6700fc00
...
@@ -93,6 +93,8 @@ class UNetReceiver
...
@@ -93,6 +93,8 @@ class UNetReceiver
typedef
sigc
::
slot
<
void
,
UNetReceiver
*
,
Event
>
EventSlot
;
typedef
sigc
::
slot
<
void
,
UNetReceiver
*
,
Event
>
EventSlot
;
void
connectEvent
(
EventSlot
sl
);
void
connectEvent
(
EventSlot
sl
);
/*! игнорировать запись датчика в SM */
void
ignore_item
(
UniSetTypes
::
ObjectId
id
=
UniSetTypes
::
DefaultObjectId
,
bool
set
=
true
);
protected
:
protected
:
...
@@ -174,10 +176,12 @@ class UNetReceiver
...
@@ -174,10 +176,12 @@ class UNetReceiver
IOController
::
AIOStateList
::
iterator
ait
;
IOController
::
AIOStateList
::
iterator
ait
;
IOController
::
DIOStateList
::
iterator
dit
;
IOController
::
DIOStateList
::
iterator
dit
;
UniversalIO
::
IOTypes
iotype
;
UniversalIO
::
IOTypes
iotype
;
bool
ignore
;
/*!< флаг игнорирования сохранения в SM*/
ItemInfo
()
:
ItemInfo
()
:
id
(
UniSetTypes
::
DefaultObjectId
),
id
(
UniSetTypes
::
DefaultObjectId
),
iotype
(
UniversalIO
::
UnknownIOType
){}
iotype
(
UniversalIO
::
UnknownIOType
),
ignore
(
false
){}
};
};
typedef
std
::
vector
<
ItemInfo
>
ItemVec
;
typedef
std
::
vector
<
ItemInfo
>
ItemVec
;
...
...
extensions/UniNetwork/uninet.cc
View file @
6700fc00
...
@@ -58,15 +58,15 @@ int main(int argc, const char **argv)
...
@@ -58,15 +58,15 @@ int main(int argc, const char **argv)
}
}
catch
(
SystemError
&
err
)
catch
(
SystemError
&
err
)
{
{
unideb
[
Debug
::
CRIT
]
<<
"(uninetwork): "
<<
err
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
"(uninetwork): "
<<
err
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
unideb
[
Debug
::
CRIT
]
<<
"(uninetwork): "
<<
ex
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
"(uninetwork): "
<<
ex
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
unideb
[
Debug
::
CRIT
]
<<
"(uninetwork): catch(...)"
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
"(uninetwork): catch(...)"
<<
endl
;
}
}
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
...
...
extensions/include/Extensions.h
View file @
6700fc00
...
@@ -13,9 +13,6 @@ namespace UniSetExtensions
...
@@ -13,9 +13,6 @@ namespace UniSetExtensions
/*! Получение идентификатора объекта(процесса) разделяемой памяти */
/*! Получение идентификатора объекта(процесса) разделяемой памяти */
UniSetTypes
::
ObjectId
getSharedMemoryID
();
UniSetTypes
::
ObjectId
getSharedMemoryID
();
/*! Получение времени для подтверждения "живости" */
int
getHeartBeatTime
();
xmlNode
*
findNode
(
xmlNode
*
node
,
const
std
::
string
&
snode
,
const
std
::
string
&
field
);
xmlNode
*
findNode
(
xmlNode
*
node
,
const
std
::
string
&
snode
,
const
std
::
string
&
field
);
xmlNode
*
getCalibrationsSection
();
xmlNode
*
getCalibrationsSection
();
...
...
extensions/include/IOBase.h
View file @
6700fc00
...
@@ -101,7 +101,7 @@ static const int NoSafety = -1;
...
@@ -101,7 +101,7 @@ static const int NoSafety = -1;
хранится идентификатор аналогового датчика
хранится идентификатор аналогового датчика
с которым он связан */
с которым он связан */
IONotifyController_i
::
ThresholdInfo
ti
;
IONotifyController_i
::
ThresholdInfo
ti
;
IOController
::
AIOStateList
::
iterator
t_ait
;
/*! итератор на датчик по которому формируется порог */
IOController
::
AIOStateList
::
iterator
ait
;
IOController
::
AIOStateList
::
iterator
ait
;
IOController
::
DIOStateList
::
iterator
dit
;
IOController
::
DIOStateList
::
iterator
dit
;
...
...
extensions/include/VTypes.h
View file @
6700fc00
...
@@ -16,12 +16,15 @@ namespace VTypes
...
@@ -16,12 +16,15 @@ namespace VTypes
{
{
vtUnknown
,
vtUnknown
,
vtF2
,
/*!< двойное слово float(4 байта). В виде строки задаётся как \b "F2". */
vtF2
,
/*!< двойное слово float(4 байта). В виде строки задаётся как \b "F2". */
vtF2r
,
/*!< двойное слово float(4 байта). С перевёрнутой (reverse) последовательностью слов. \b "F2r". */
vtF4
,
/*!< 8-х байтовое слово (double). В виде строки задаётся как \b "F4". */
vtF4
,
/*!< 8-х байтовое слово (double). В виде строки задаётся как \b "F4". */
vtByte
,
/*!< байт. В виде строки задаётся как \b "byte". */
vtByte
,
/*!< байт. В виде строки задаётся как \b "byte". */
vtUnsigned
,
/*!< беззнаковое целое (2 байта). В виде строки задаётся как \b "unsigned". */
vtUnsigned
,
/*!< беззнаковое целое (2 байта). В виде строки задаётся как \b "unsigned". */
vtSigned
,
/*!< знаковое целое (2 байта). В виде строки задаётся как \b "signed". */
vtSigned
,
/*!< знаковое целое (2 байта). В виде строки задаётся как \b "signed". */
vtI2
,
/*!< целое (4 байта). В виде строки задаётся как \b "I2".*/
vtI2
,
/*!< целое (4 байта). В виде строки задаётся как \b "I2".*/
vtU2
/*!< беззнаковое целое (4 байта). В виде строки задаётся как \b "U2".*/
vtI2r
,
/*!< целое (4 байта). С перевёрнутой (reverse) последовательностью слов. В виде строки задаётся как \b "I2r".*/
vtU2
,
/*!< беззнаковое целое (4 байта). В виде строки задаётся как \b "U2".*/
vtU2r
/*!< беззнаковое целое (4 байта). С перевёрнутой (reverse) последовательностью слов. В виде строки задаётся как \b "U2r".*/
};
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
VType
&
vt
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
VType
&
vt
);
...
@@ -67,6 +70,24 @@ namespace VTypes
...
@@ -67,6 +70,24 @@ namespace VTypes
F2mem
raw
;
F2mem
raw
;
};
};
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
class
F2r
:
public
F2
{
public
:
// ------------------------------------------
// конструкторы на разные случаи...
F2r
(){}
F2r
(
float
f
)
:
F2
(
f
){}
F2r
(
const
ModbusRTU
::
ModbusData
*
data
,
int
size
)
:
F2
(
data
,
size
)
{
std
::
swap
(
raw
.
v
[
0
],
raw
.
v
[
1
]);
}
~
F2r
(){}
};
// --------------------------------------------------------------------------
class
F4
class
F4
{
{
public
:
public
:
...
@@ -239,6 +260,21 @@ namespace VTypes
...
@@ -239,6 +260,21 @@ namespace VTypes
I2mem
raw
;
I2mem
raw
;
};
};
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
class
I2r
:
public
I2
{
public
:
I2r
(){}
I2r
(
int
v
)
:
I2
(
v
){}
I2r
(
const
ModbusRTU
::
ModbusData
*
data
,
int
size
)
:
I2
(
data
,
size
)
{
std
::
swap
(
raw
.
v
[
0
],
raw
.
v
[
1
]);
}
~
I2r
(){}
};
// --------------------------------------------------------------------------
class
U2
class
U2
{
{
public
:
public
:
...
@@ -274,6 +310,21 @@ namespace VTypes
...
@@ -274,6 +310,21 @@ namespace VTypes
U2mem
raw
;
U2mem
raw
;
};
};
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
class
U2r
:
public
U2
{
public
:
U2r
(){}
U2r
(
int
v
)
:
U2
(
v
){}
U2r
(
const
ModbusRTU
::
ModbusData
*
data
,
int
size
)
:
U2
(
data
,
size
)
{
std
::
swap
(
raw
.
v
[
0
],
raw
.
v
[
1
]);
}
~
U2r
(){}
};
// --------------------------------------------------------------------------
}
// end of namespace VTypes
}
// end of namespace VTypes
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
...
...
extensions/lib/Extensions.cc
View file @
6700fc00
...
@@ -32,36 +32,6 @@ namespace UniSetExtensions
...
@@ -32,36 +32,6 @@ namespace UniSetExtensions
return
shmID
;
return
shmID
;
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
static
int
heartBeatTime
=
-
1
;
// начальная инициализация
int
getHeartBeatTime
()
{
if
(
heartBeatTime
!=
-
1
)
return
heartBeatTime
;
xmlNode
*
cnode
=
conf
->
getNode
(
"HeartBeatTime"
);
if
(
cnode
==
NULL
)
{
ostringstream
err
;
err
<<
"Not found conf-node for HeartBeatTime"
;
cerr
<<
err
.
str
()
<<
endl
;
throw
SystemError
(
err
.
str
());
}
UniXML_iterator
it
(
cnode
);
heartBeatTime
=
it
.
getIntProp
(
"time_msec"
);
if
(
heartBeatTime
<=
0
)
{
heartBeatTime
=
0
;
dlog
[
Debug
::
WARN
]
<<
"(getHeartBeatTime): механизм 'HEARTBEAT' ОТКЛЮЧЁН!"
<<
endl
;
}
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
"(getHeartBeatTime): heartbeat time = "
<<
heartBeatTime
<<
endl
;
return
heartBeatTime
;
}
// -------------------------------------------------------------------------
void
escape_string
(
string
&
s
)
void
escape_string
(
string
&
s
)
{
{
if
(
s
.
empty
()
)
if
(
s
.
empty
()
)
...
...
extensions/lib/MTR.cc
View file @
6700fc00
...
@@ -431,12 +431,26 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr,
...
@@ -431,12 +431,26 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr,
// if( !ok )
// if( !ok )
// return false;
// return false;
}
}
ModbusRTU
::
WriteSingleOutputRetMessage
ret
=
mb
->
write06
(
addr
,
regUpdateConfiguration
,
1
);
if
(
verb
)
cout
<<
"(mtr-setup): save parameters "
<<
endl
;
return
true
;
try
{
ModbusRTU
::
ModbusData
dat
=
1
;
ModbusRTU
::
WriteSingleOutputRetMessage
ret
=
mb
->
write06
(
addr
,
regUpdateConfiguration
,
dat
);
if
(
ret
.
start
==
regUpdateConfiguration
&&
ret
.
data
==
dat
)
{
if
(
verb
)
cout
<<
"(mtr-setup): save parameters "
<<
endl
;
return
true
;
}
}
catch
(
ModbusRTU
::
mbException
&
ex
)
{
}
if
(
verb
)
cout
<<
"(mtr-setup): not save parameters "
<<
endl
;
return
false
;
}
}
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
MTR
::
MTRError
update_configuration
(
ModbusRTUMaster
*
mb
,
ModbusRTU
::
ModbusAddr
slaveaddr
,
MTR
::
MTRError
update_configuration
(
ModbusRTUMaster
*
mb
,
ModbusRTU
::
ModbusAddr
slaveaddr
,
...
...
extensions/lib/VTypes.cc
View file @
6700fc00
...
@@ -18,6 +18,8 @@ VType str2type( const std::string& s )
...
@@ -18,6 +18,8 @@ VType str2type( const std::string& s )
return
vtByte
;
return
vtByte
;
if
(
s
==
"F2"
||
s
==
"f2"
)
if
(
s
==
"F2"
||
s
==
"f2"
)
return
vtF2
;
return
vtF2
;
if
(
s
==
"F2r"
||
s
==
"f2r"
)
return
vtF2r
;
if
(
s
==
"F4"
||
s
==
"f4"
)
if
(
s
==
"F4"
||
s
==
"f4"
)
return
vtF4
;
return
vtF4
;
if
(
s
==
"Unsigned"
||
s
==
"unsigned"
)
if
(
s
==
"Unsigned"
||
s
==
"unsigned"
)
...
@@ -26,8 +28,12 @@ VType str2type( const std::string& s )
...
@@ -26,8 +28,12 @@ VType str2type( const std::string& s )
return
vtSigned
;
return
vtSigned
;
if
(
s
==
"I2"
||
s
==
"i2"
)
if
(
s
==
"I2"
||
s
==
"i2"
)
return
vtI2
;
return
vtI2
;
if
(
s
==
"I2r"
||
s
==
"i2r"
)
return
vtI2r
;
if
(
s
==
"U2"
||
s
==
"u2"
)
if
(
s
==
"U2"
||
s
==
"u2"
)
return
vtU2
;
return
vtU2
;
if
(
s
==
"U2r"
||
s
==
"u2r"
)
return
vtU2r
;
return
vtUnknown
;
return
vtUnknown
;
}
}
...
@@ -38,6 +44,8 @@ string type2str( VType t )
...
@@ -38,6 +44,8 @@ string type2str( VType t )
return
"Byte"
;
return
"Byte"
;
if
(
t
==
vtF2
)
if
(
t
==
vtF2
)
return
"F2"
;
return
"F2"
;
if
(
t
==
vtF2r
)
return
"F2r"
;
if
(
t
==
vtF4
)
if
(
t
==
vtF4
)
return
"F4"
;
return
"F4"
;
if
(
t
==
vtUnsigned
)
if
(
t
==
vtUnsigned
)
...
@@ -46,8 +54,12 @@ string type2str( VType t )
...
@@ -46,8 +54,12 @@ string type2str( VType t )
return
"Signed"
;
return
"Signed"
;
if
(
t
==
vtI2
)
if
(
t
==
vtI2
)
return
"I2"
;
return
"I2"
;
if
(
t
==
vtI2r
)
return
"I2r"
;
if
(
t
==
vtU2
)
if
(
t
==
vtU2
)
return
"U2"
;
return
"U2"
;
if
(
t
==
vtU2r
)
return
"U2r"
;
return
"vtUnknown"
;
return
"vtUnknown"
;
}
}
...
@@ -56,7 +68,7 @@ int wsize( VType t )
...
@@ -56,7 +68,7 @@ int wsize( VType t )
{
{
if
(
t
==
vtByte
)
if
(
t
==
vtByte
)
return
Byte
::
wsize
();
return
Byte
::
wsize
();
if
(
t
==
vtF2
)
if
(
t
==
vtF2
||
t
==
vtF2r
)
return
F2
::
wsize
();
return
F2
::
wsize
();
if
(
t
==
vtF4
)
if
(
t
==
vtF4
)
return
F4
::
wsize
();
return
F4
::
wsize
();
...
@@ -64,9 +76,9 @@ int wsize( VType t )
...
@@ -64,9 +76,9 @@ int wsize( VType t )
return
Unsigned
::
wsize
();
return
Unsigned
::
wsize
();
if
(
t
==
vtSigned
)
if
(
t
==
vtSigned
)
return
Signed
::
wsize
();
return
Signed
::
wsize
();
if
(
t
==
vtI2
)
if
(
t
==
vtI2
||
t
==
vtI2r
)
return
I2
::
wsize
();
return
I2
::
wsize
();
if
(
t
==
vtU2
)
if
(
t
==
vtU2
||
t
==
vtU2r
)
return
U2
::
wsize
();
return
U2
::
wsize
();
return
1
;
return
1
;
...
...
include/ComPort.h
View file @
6700fc00
...
@@ -82,9 +82,9 @@ public:
...
@@ -82,9 +82,9 @@ public:
void
setCharacterSize
(
CharacterSize
);
void
setCharacterSize
(
CharacterSize
);
void
setStopBits
(
StopBits
sBit
);
void
setStopBits
(
StopBits
sBit
);
virtual
void
setTimeout
(
int
timeout
);
virtual
void
setTimeout
(
int
msec
);
void
setWaiting
(
bool
waiting
);
inline
int
getTimeout
(){
return
uTimeout
/
1000
;
}
// msec
inline
int
getTimeout
(){
return
uTimeout
*
1000
;
}
// msec
void
setWaiting
(
bool
waiting
);
virtual
unsigned
char
receiveByte
();
virtual
unsigned
char
receiveByte
();
virtual
void
sendByte
(
unsigned
char
x
);
virtual
void
sendByte
(
unsigned
char
x
);
...
...
include/DelayTimer.h
View file @
6700fc00
...
@@ -34,6 +34,7 @@ class DelayTimer
...
@@ -34,6 +34,7 @@ class DelayTimer
onDelay
(
0
),
offDelay
(
0
),
waiting_on
(
false
),
waiting_off
(
false
){}
onDelay
(
0
),
offDelay
(
0
),
waiting_on
(
false
),
waiting_off
(
false
){}
DelayTimer
(
timeout_t
on_msec
,
timeout_t
off_msec
)
:
prevState
(
false
),
state
(
false
),
DelayTimer
(
timeout_t
on_msec
,
timeout_t
off_msec
)
:
prevState
(
false
),
state
(
false
),
onDelay
(
on_msec
),
offDelay
(
off_msec
),
waiting_on
(
false
),
waiting_off
(
false
)
onDelay
(
on_msec
),
offDelay
(
off_msec
),
waiting_on
(
false
),
waiting_off
(
false
)
{
{
}
}
...
@@ -44,25 +45,33 @@ class DelayTimer
...
@@ -44,25 +45,33 @@ class DelayTimer
{
{
onDelay
=
on_msec
;
onDelay
=
on_msec
;
offDelay
=
off_msec
;
offDelay
=
off_msec
;
waiting_on
=
false
;
waiting_off
=
false
;
state
=
false
;
}
}
// запустить часы (заново)
// запустить часы (заново)
inline
void
reset
()
inline
void
reset
()
{
{
pt
.
reset
();
pt
.
reset
();
waiting_on
=
false
;
waiting_off
=
false
;
state
=
false
;
}
}
inline
bool
check
(
bool
st
)
inline
bool
check
(
bool
st
)
{
{
if
(
waiting_off
)
if
(
waiting_off
)
{
{
if
(
!
st
&&
pt
.
checkTime
()
)
if
(
pt
.
checkTime
()
)
{
{
waiting_off
=
false
;
waiting_off
=
false
;
state
=
false
;
if
(
!
st
)
state
=
false
;
return
state
;
return
state
;
}
}
else
if
(
st
!=
prevState
)
else
if
(
st
!=
prevState
&&
!
st
)
pt
.
reset
();
pt
.
reset
();
prevState
=
st
;
prevState
=
st
;
...
@@ -71,13 +80,16 @@ class DelayTimer
...
@@ -71,13 +80,16 @@ class DelayTimer
if
(
waiting_on
)
if
(
waiting_on
)
{
{
if
(
st
&&
pt
.
checkTime
()
)
if
(
pt
.
checkTime
()
)
{
{
waiting_on
=
false
;
waiting_on
=
false
;
state
=
true
;
if
(
st
)
state
=
true
;
else
return
state
;
return
state
;
}
}
else
if
(
st
!=
prevState
)
else
if
(
st
!=
prevState
&&
st
)
pt
.
reset
();
pt
.
reset
();
prevState
=
st
;
prevState
=
st
;
...
...
include/modbus/ModbusTCPMaster.h
View file @
6700fc00
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include <cc++/socket.h>
#include <cc++/socket.h>
#include "ModbusTypes.h"
#include "ModbusTypes.h"
#include "ModbusClient.h"
#include "ModbusClient.h"
#include "UTCPStream.h"
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
/*! Modbus TCP master interface */
/*! Modbus TCP master interface */
class
ModbusTCPMaster
:
class
ModbusTCPMaster
:
...
@@ -42,11 +43,12 @@ class ModbusTCPMaster:
...
@@ -42,11 +43,12 @@ class ModbusTCPMaster:
ModbusRTU
::
ModbusMessage
&
reply
,
timeout_t
timeout
);
ModbusRTU
::
ModbusMessage
&
reply
,
timeout_t
timeout
);
private
:
private
:
ost
::
TCPStream
*
tcp
;
U
TCPStream
*
tcp
;
ModbusRTU
::
ModbusData
nTransaction
;
ModbusRTU
::
ModbusData
nTransaction
;
std
::
queue
<
unsigned
char
>
qrecv
;
std
::
queue
<
unsigned
char
>
qrecv
;
PassiveTimer
ptTimeout
;
PassiveTimer
ptTimeout
;
std
::
string
iaddr
;
std
::
string
iaddr
;
int
port
;
bool
force_disconnect
;
bool
force_disconnect
;
};
};
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
...
...
include/modbus/UTCPStream.h
0 → 100644
View file @
6700fc00
// -------------------------------------------------------------------------
#ifndef UTCPStream_H_
#define UTCPStream_H_
// -------------------------------------------------------------------------
#include <string>
#include <cc++/socket.h>
// -------------------------------------------------------------------------
class
UTCPStream
:
public
ost
::
TCPStream
{
public
:
UTCPStream
();
virtual
~
UTCPStream
();
void
create
(
const
std
::
string
&
hname
,
int
port
,
bool
throwflag
=
false
,
timeout_t
timer
=
0
);
protected
:
private
:
};
// -------------------------------------------------------------------------
#endif // UTCPStream_H_
// -------------------------------------------------------------------------
src/Communications/ComPort.cc
View file @
6700fc00
...
@@ -257,9 +257,9 @@ void ComPort::sendByte(unsigned char x)
...
@@ -257,9 +257,9 @@ void ComPort::sendByte(unsigned char x)
}
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Lav: убрать, переделать в receiveBlock
// Lav: убрать, переделать в receiveBlock
void
ComPort
::
setTimeout
(
int
timeout
)
void
ComPort
::
setTimeout
(
int
msec
)
{
{
uTimeout
=
timeout
;
uTimeout
=
msec
*
1000
;
}
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Lav: ситуация, когда отправлено меньше запрошенного, не типична и должна
// Lav: ситуация, когда отправлено меньше запрошенного, не типична и должна
...
...
src/Communications/ComPort485F.cc
View file @
6700fc00
...
@@ -73,10 +73,10 @@ ComPort485F::ComPort485F( string dev, int gpio_num, bool tmit_ctrl ):
...
@@ -73,10 +73,10 @@ ComPort485F::ComPort485F( string dev, int gpio_num, bool tmit_ctrl ):
}
}
}
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
void
ComPort485F
::
setTimeout
(
int
timeout
)
void
ComPort485F
::
setTimeout
(
int
msec
)
{
{
tout_msec
=
timeout
/
1000
;
tout_msec
=
msec
;
ComPort
::
setTimeout
(
timeout
);
ComPort
::
setTimeout
(
msec
);
}
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
unsigned
char
ComPort485F
::
m_receiveByte
(
bool
wait
)
unsigned
char
ComPort485F
::
m_receiveByte
(
bool
wait
)
...
...
src/Communications/Modbus/Makefile.am
View file @
6700fc00
...
@@ -5,7 +5,7 @@ noinst_LTLIBRARIES = libModbus.la
...
@@ -5,7 +5,7 @@ noinst_LTLIBRARIES = libModbus.la
libModbus_la_SOURCES
=
ModbusTypes.cc ModbusHelpers.cc
\
libModbus_la_SOURCES
=
ModbusTypes.cc ModbusHelpers.cc
\
ModbusClient.cc ModbusServer.cc ModbusServerSlot.cc
\
ModbusClient.cc ModbusServer.cc ModbusServerSlot.cc
\
ModbusRTUSlave.cc ModbusRTUSlaveSlot.cc ModbusRTUMaster.cc
\
ModbusRTUSlave.cc ModbusRTUSlaveSlot.cc ModbusRTUMaster.cc
\
ModbusTCPCore.cc ModbusTCPServer.cc ModbusTCPServerSlot.cc ModbusTCPMaster.cc
ModbusTCPCore.cc ModbusTCPServer.cc ModbusTCPServerSlot.cc ModbusTCPMaster.cc
UTCPStream.cc
libModbus_la_CXXFLAGS
=
-I
$(top_builddir)
/include/Communications/modbus
$(SIGC_CFLAGS)
$(COMCPP_CFLAGS)
libModbus_la_CXXFLAGS
=
-I
$(top_builddir)
/include/Communications/modbus
$(SIGC_CFLAGS)
$(COMCPP_CFLAGS)
libModbus_la_LIBADD
=
$(SIGC_LIBS)
$(COMCPP_LIBS)
libModbus_la_LIBADD
=
$(SIGC_LIBS)
$(COMCPP_LIBS)
...
...
src/Communications/Modbus/ModbusRTUMaster.cc
View file @
6700fc00
...
@@ -35,7 +35,7 @@ ModbusRTUMaster::ModbusRTUMaster( const string dev, bool use485, bool tr_ctl ):
...
@@ -35,7 +35,7 @@ ModbusRTUMaster::ModbusRTUMaster( const string dev, bool use485, bool tr_ctl ):
port
->
setCharacterSize
(
ComPort
::
CSize8
);
port
->
setCharacterSize
(
ComPort
::
CSize8
);
port
->
setStopBits
(
ComPort
::
OneBit
);
port
->
setStopBits
(
ComPort
::
OneBit
);
port
->
setWaiting
(
true
);
port
->
setWaiting
(
true
);
port
->
setTimeout
(
replyTimeOut_ms
*
1000
);
port
->
setTimeout
(
replyTimeOut_ms
);
// port->setBlocking(false);
// port->setBlocking(false);
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
...
@@ -51,7 +51,7 @@ ModbusRTUMaster::ModbusRTUMaster( ComPort* com ):
...
@@ -51,7 +51,7 @@ ModbusRTUMaster::ModbusRTUMaster( ComPort* com ):
port
->
setCharacterSize
(
ComPort
::
CSize8
);
port
->
setCharacterSize
(
ComPort
::
CSize8
);
port
->
setStopBits
(
ComPort
::
OneBit
);
port
->
setStopBits
(
ComPort
::
OneBit
);
port
->
setWaiting
(
true
);
port
->
setWaiting
(
true
);
port
->
setTimeout
(
replyTimeOut_ms
*
1000
);
port
->
setTimeout
(
replyTimeOut_ms
);
// port->setBlocking(false);
// port->setBlocking(false);
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
...
@@ -116,7 +116,7 @@ int ModbusRTUMaster::getNextData( unsigned char* buf, int len )
...
@@ -116,7 +116,7 @@ int ModbusRTUMaster::getNextData( unsigned char* buf, int len )
void
ModbusRTUMaster
::
setChannelTimeout
(
timeout_t
msec
)
void
ModbusRTUMaster
::
setChannelTimeout
(
timeout_t
msec
)
{
{
if
(
port
)
if
(
port
)
port
->
setTimeout
(
msec
*
1000
);
port
->
setTimeout
(
msec
);
}
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
mbErrCode
ModbusRTUMaster
::
sendData
(
unsigned
char
*
buf
,
int
len
)
mbErrCode
ModbusRTUMaster
::
sendData
(
unsigned
char
*
buf
,
int
len
)
...
...
src/Communications/Modbus/ModbusRTUSlave.cc
View file @
6700fc00
...
@@ -35,7 +35,7 @@ ModbusRTUSlave::ModbusRTUSlave( const string dev, bool use485, bool tr_ctl ):
...
@@ -35,7 +35,7 @@ ModbusRTUSlave::ModbusRTUSlave( const string dev, bool use485, bool tr_ctl ):
port
->
setCharacterSize
(
ComPort
::
CSize8
);
port
->
setCharacterSize
(
ComPort
::
CSize8
);
port
->
setStopBits
(
ComPort
::
OneBit
);
port
->
setStopBits
(
ComPort
::
OneBit
);
port
->
setWaiting
(
true
);
port
->
setWaiting
(
true
);
port
->
setTimeout
(
recvTimeOut_ms
*
1000
);
port
->
setTimeout
(
recvTimeOut_ms
);
// port->setBlocking(false);
// port->setBlocking(false);
}
}
...
@@ -49,7 +49,7 @@ ModbusRTUSlave::ModbusRTUSlave( ComPort* com ):
...
@@ -49,7 +49,7 @@ ModbusRTUSlave::ModbusRTUSlave( ComPort* com ):
port
->
setCharacterSize
(
ComPort
::
CSize8
);
port
->
setCharacterSize
(
ComPort
::
CSize8
);
port
->
setStopBits
(
ComPort
::
OneBit
);
port
->
setStopBits
(
ComPort
::
OneBit
);
port
->
setWaiting
(
true
);
port
->
setWaiting
(
true
);
port
->
setTimeout
(
recvTimeOut_ms
*
1000
);
port
->
setTimeout
(
recvTimeOut_ms
);
// port->setBlocking(false);
// port->setBlocking(false);
}
}
...
@@ -129,9 +129,9 @@ int ModbusRTUSlave::getNextData( unsigned char* buf, int len )
...
@@ -129,9 +129,9 @@ int ModbusRTUSlave::getNextData( unsigned char* buf, int len )
void
ModbusRTUSlave
::
setChannelTimeout
(
timeout_t
msec
)
void
ModbusRTUSlave
::
setChannelTimeout
(
timeout_t
msec
)
{
{
if
(
msec
==
UniSetTimer
::
WaitUpTime
)
if
(
msec
==
UniSetTimer
::
WaitUpTime
)
port
->
setTimeout
(
15
*
60
*
1000
*
1000
);
// используем просто большое время (15 минут). Переведя его в наносекунды
.
port
->
setTimeout
(
15
*
60
*
1000
);
// используем просто большое время (15 минут)
.
else
else
port
->
setTimeout
(
msec
*
1000
);
port
->
setTimeout
(
msec
);
}
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
mbErrCode
ModbusRTUSlave
::
sendData
(
unsigned
char
*
buf
,
int
len
)
mbErrCode
ModbusRTUSlave
::
sendData
(
unsigned
char
*
buf
,
int
len
)
...
...
src/Communications/Modbus/ModbusTCPMaster.cc
View file @
6700fc00
...
@@ -14,6 +14,7 @@ ModbusTCPMaster::ModbusTCPMaster():
...
@@ -14,6 +14,7 @@ ModbusTCPMaster::ModbusTCPMaster():
tcp
(
0
),
tcp
(
0
),
nTransaction
(
0
),
nTransaction
(
0
),
iaddr
(
""
),
iaddr
(
""
),
port
(
0
),
force_disconnect
(
true
)
force_disconnect
(
true
)
{
{
setCRCNoCheckit
(
true
);
setCRCNoCheckit
(
true
);
...
@@ -272,18 +273,17 @@ void ModbusTCPMaster::cleanInputStream()
...
@@ -272,18 +273,17 @@ void ModbusTCPMaster::cleanInputStream()
while
(
ret
>
0
);
while
(
ret
>
0
);
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
bool
ModbusTCPMaster
::
checkConnection
(
const
std
::
string
ip
,
int
port
,
int
timeout_msec
)
bool
ModbusTCPMaster
::
checkConnection
(
const
std
::
string
ip
,
int
_
port
,
int
timeout_msec
)
{
{
try
try
{
{
ostringstream
s
;
ostringstream
s
;
s
<<
ip
<<
":"
<<
port
;
s
<<
ip
<<
":"
<<
_
port
;
// Проверяем просто попыткой создать соединение..
// Проверяем просто попыткой создать соединение..
// ost::Thread::setException(ost::Thread::throwException);
UTCPStream
t
;
// TCPStream (const char *name, Family family=IPV4, unsigned mss=536, bool throwflag=false, timeout_t timer=0)
t
.
create
(
ip
,
_port
,
true
,
timeout_msec
);
ost
::
TCPStream
t
(
s
.
str
().
c_str
(),
ost
::
Socket
::
IPV4
,
536
,
true
,
timeout_msec
);
t
.
disconnect
();
t
.
disconnect
();
return
true
;
return
true
;
}
}
...
@@ -311,10 +311,9 @@ void ModbusTCPMaster::reconnect()
...
@@ -311,10 +311,9 @@ void ModbusTCPMaster::reconnect()
try
try
{
{
// TCPStream (const char *name, Family family=IPV4, unsigned mss=536, bool throwflag=false, timeout_t timer=0)
tcp
=
new
UTCPStream
();
tcp
=
new
ost
::
TCPStream
(
iaddr
.
c_str
(),
ost
::
Socket
::
IPV4
,
536
,
true
,
500
);
tcp
->
create
(
iaddr
,
port
,
true
,
500
);
tcp
->
setTimeout
(
replyTimeOut_ms
);
tcp
->
setTimeout
(
replyTimeOut_ms
);
tcp
->
setKeepAlive
(
true
);
}
}
catch
(
std
::
exception
&
e
)
catch
(
std
::
exception
&
e
)
{
{
...
@@ -342,7 +341,7 @@ void ModbusTCPMaster::connect( const std::string addr, int port )
...
@@ -342,7 +341,7 @@ void ModbusTCPMaster::connect( const std::string addr, int port )
connect
(
ia
,
port
);
connect
(
ia
,
port
);
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
void
ModbusTCPMaster
::
connect
(
ost
::
InetAddress
addr
,
int
port
)
void
ModbusTCPMaster
::
connect
(
ost
::
InetAddress
addr
,
int
_
port
)
{
{
if
(
tcp
)
if
(
tcp
)
{
{
...
@@ -354,19 +353,20 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port )
...
@@ -354,19 +353,20 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port )
// if( !tcp )
// if( !tcp )
// {
// {
ostringstream
s
;
ostringstream
s
;
s
<<
addr
<<
":"
<<
port
;
s
<<
addr
;
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
"(ModbusTCPMaster): connect to "
<<
s
.
str
()
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
"(ModbusTCPMaster): connect to "
<<
addr
<<
":"
<<
_port
<<
endl
;
iaddr
=
s
.
str
();
iaddr
=
s
.
str
();
port
=
_port
;
ost
::
Thread
::
setException
(
ost
::
Thread
::
throwException
);
ost
::
Thread
::
setException
(
ost
::
Thread
::
throwException
);
try
try
{
{
tcp
=
new
ost
::
TCPStream
(
iaddr
.
c_str
(),
ost
::
Socket
::
IPV4
,
536
,
true
,
500
);
tcp
=
new
UTCPStream
();
tcp
->
create
(
iaddr
,
port
,
true
,
500
);
tcp
->
setTimeout
(
replyTimeOut_ms
);
tcp
->
setTimeout
(
replyTimeOut_ms
);
tcp
->
setKeepAlive
(
true
);
}
}
catch
(
std
::
exception
&
e
)
catch
(
std
::
exception
&
e
)
{
{
...
...
src/Communications/Modbus/UTCPStream.cc
0 → 100644
View file @
6700fc00
#include <iostream>
#include <string>
#include <fcntl.h>
#include <errno.h>
#include <cstring>
#include <cc++/socket.h>
#include "modbus/UTCPStream.h"
#include "PassiveTimer.h"
#include "UniSetTypes.h"
// -------------------------------------------------------------------------
using
namespace
std
;
// -------------------------------------------------------------------------
UTCPStream
::~
UTCPStream
()
{
}
// -------------------------------------------------------------------------
UTCPStream
::
UTCPStream
()
:
TCPStream
(
ost
::
Socket
::
IPV4
,
true
)
{
}
// -------------------------------------------------------------------------
void
UTCPStream
::
create
(
const
std
::
string
&
hname
,
int
port
,
bool
throwflag
,
timeout_t
t
)
{
family
=
ost
::
Socket
::
IPV4
;
timeout
=
t
;
unsigned
mss
=
536
;
setError
(
throwflag
);
ost
::
IPV4Host
h
(
hname
.
c_str
());
connect
(
h
,
port
,
mss
);
setKeepAlive
(
true
);
setLinger
(
true
);
//setCompletion(false);
}
// -------------------------------------------------------------------------
src/Processes/IOController.cc
View file @
6700fc00
...
@@ -469,8 +469,16 @@ void IOController::setValue( const IOController_i::SensorInfo& si, CORBA::Long v
...
@@ -469,8 +469,16 @@ void IOController::setValue( const IOController_i::SensorInfo& si, CORBA::Long v
if
(
sup_id
==
UniSetTypes
::
DefaultObjectId
)
if
(
sup_id
==
UniSetTypes
::
DefaultObjectId
)
sup_id
=
getId
();
sup_id
=
getId
();
IOController
::
AIOStateList
::
iterator
li
(
aioList
.
end
());
try
localSetValue
(
li
,
si
,
value
,
sup_id
);
{
IOController
::
AIOStateList
::
iterator
li
(
aioList
.
end
());
localSetValue
(
li
,
si
,
value
,
sup_id
);
}
// getValue if not found...
catch
(
IOController_i
::
NameNotFound
)
{
IOController
::
DIOStateList
::
iterator
li
(
dioList
.
end
());
localSetState
(
li
,
si
,
(
value
?
true
:
false
),
sup_id
);
}
}
}
void
IOController
::
fastSetValue
(
const
IOController_i
::
SensorInfo
&
si
,
CORBA
::
Long
value
,
UniSetTypes
::
ObjectId
sup_id
)
void
IOController
::
fastSetValue
(
const
IOController_i
::
SensorInfo
&
si
,
CORBA
::
Long
value
,
UniSetTypes
::
ObjectId
sup_id
)
...
...
src/Various/Configuration.cc
View file @
6700fc00
...
@@ -86,14 +86,14 @@ Configuration::Configuration():
...
@@ -86,14 +86,14 @@ Configuration::Configuration():
mi
(
NULL
),
mi
(
NULL
),
oind
(
NULL
),
oind
(
NULL
),
NSName
(
"NameService"
),
NSName
(
"NameService"
),
repeatCount
(
2
),
repeatTimeout
(
100
),
repeatCount
(
2
),
repeatTimeout
(
100
),
localTimerService
(
UniSetTypes
::
DefaultObjectId
),
localTimerService
(
UniSetTypes
::
DefaultObjectId
),
localDBServer
(
UniSetTypes
::
DefaultObjectId
),
localDBServer
(
UniSetTypes
::
DefaultObjectId
),
localInfoServer
(
UniSetTypes
::
DefaultObjectId
),
localInfoServer
(
UniSetTypes
::
DefaultObjectId
),
localNode
(
UniSetTypes
::
DefaultObjectId
),
localNode
(
UniSetTypes
::
DefaultObjectId
),
localNodeName
(
""
),
localNodeName
(
""
),
fileConfName
(
""
),
fileConfName
(
""
),
heartbeat_msec
(
10
000
)
heartbeat_msec
(
5
000
)
{
{
// unideb[Debug::CRIT] << " configuration FAILED!!!!!!!!!!!!!!!!!" << endl;
// unideb[Debug::CRIT] << " configuration FAILED!!!!!!!!!!!!!!!!!" << endl;
// throw Exception();
// throw Exception();
...
@@ -228,10 +228,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
...
@@ -228,10 +228,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
throw
;
throw
;
}
}
// default value
heartbeat_msec
=
5000
;
// cerr << "*************** initConfiguration: xmlOpen: " << pt.getCurrent() << " msec " << endl;
// cerr << "*************** initConfiguration: xmlOpen: " << pt.getCurrent() << " msec " << endl;
// pt.reset();
// pt.reset();
...
@@ -278,9 +274,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
...
@@ -278,9 +274,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
// Настраиваем отладочные логи
// Настраиваем отладочные логи
initDebug
(
unideb
,
"UniSetDebug"
);
initDebug
(
unideb
,
"UniSetDebug"
);
// cerr << "*************** initConfiguration: oind: " << pt.getCurrent() << " msec " << endl;
// pt.reset();
// default init...
// default init...
transientIOR
=
false
;
transientIOR
=
false
;
localIOR
=
false
;
localIOR
=
false
;
...
@@ -291,20 +284,14 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
...
@@ -291,20 +284,14 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
initParameters
();
initParameters
();
// help
// if( !getArgParam("--help").empty() )
// help(cout);
initRepSections
();
initRepSections
();
// localIOR
// localIOR
// localIOR = false; // ??. initParameters()
int
lior
=
getArgInt
(
"--localIOR"
);
int
lior
=
getArgInt
(
"--localIOR"
);
if
(
lior
)
if
(
lior
)
localIOR
=
lior
;
localIOR
=
lior
;
// transientIOR
// transientIOR
// transientIOR = false; // ??. initParameters()
int
tior
=
getArgInt
(
"--transientIOR"
);
int
tior
=
getArgInt
(
"--transientIOR"
);
if
(
tior
)
if
(
tior
)
transientIOR
=
tior
;
transientIOR
=
tior
;
...
@@ -312,9 +299,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
...
@@ -312,9 +299,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
if
(
imagesDir
[
0
]
!=
'/'
&&
imagesDir
[
0
]
!=
'.'
)
if
(
imagesDir
[
0
]
!=
'/'
&&
imagesDir
[
0
]
!=
'.'
)
imagesDir
=
dataDir
+
imagesDir
+
"/"
;
imagesDir
=
dataDir
+
imagesDir
+
"/"
;
// cerr << "*************** initConfiguration: parameters...: " << pt.getCurrent() << " msec " << endl;
// pt.reset();
// считываем список узлов
// считываем список узлов
createNodesList
();
createNodesList
();
...
@@ -596,10 +580,16 @@ void Configuration::initParameters()
...
@@ -596,10 +580,16 @@ void Configuration::initParameters()
if
(
confDir
.
empty
()
)
if
(
confDir
.
empty
()
)
confDir
=
getRootDir
();
confDir
=
getRootDir
();
}
}
else
if
(
name
==
"HeartBeatTime"
)
}
{
heartbeat_msec
=
it
.
getIntProp
(
"name"
);
// Heartbeat init...
}
xmlNode
*
cnode
=
conf
->
getNode
(
"HeartBeatTime"
);
if
(
cnode
)
{
UniXML_iterator
hit
(
cnode
);
heartbeat_msec
=
hit
.
getIntProp
(
"msec"
);
if
(
heartbeat_msec
<=
0
)
heartbeat_msec
=
5000
;
}
}
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
...
...
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