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
67899026
Commit
67899026
authored
Oct 11, 2018
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Plain Diff
backported to p8 as 2.7-alt15.M80P.16 (with rpmbph script)
parents
95a8e54d
c1f75ad9
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
65 additions
and
38 deletions
+65
-38
ctl-cpp-cc-alone-ask.xsl
Utilities/codegen/ctl-cpp-cc-alone-ask.xsl
+0
-0
ctl-cpp-cc-alone.xsl
Utilities/codegen/ctl-cpp-cc-alone.xsl
+0
-0
ctl-cpp-cc-ask.xsl
Utilities/codegen/ctl-cpp-cc-ask.xsl
+0
-0
ctl-cpp-cc.xsl
Utilities/codegen/ctl-cpp-cc.xsl
+0
-0
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+0
-0
libuniset2.spec
conf/libuniset2.spec
+8
-2
UDPPacket.h
extensions/UNetUDP/UDPPacket.h
+2
-2
UNetExchange.cc
extensions/UNetUDP/UNetExchange.cc
+3
-3
UNetReceiver.cc
extensions/UNetUDP/UNetReceiver.cc
+9
-3
UNetReceiver.h
extensions/UNetUDP/UNetReceiver.h
+3
-1
UNetSender.cc
extensions/UNetUDP/UNetSender.cc
+10
-5
UNetSender.h
extensions/UNetUDP/UNetSender.h
+9
-4
start_fg.sh
extensions/UNetUDP/start_fg.sh
+1
-1
ModbusTypes.h
include/modbus/ModbusTypes.h
+4
-4
ModbusTypes.cc
src/Communications/Modbus/ModbusTypes.cc
+6
-5
test_modbustypes.cc
tests/test_modbustypes.cc
+10
-8
No files found.
Utilities/codegen/ctl-cpp-cc-alone-ask.xsl
View file @
67899026
Utilities/codegen/ctl-cpp-cc-alone.xsl
View file @
67899026
Utilities/codegen/ctl-cpp-cc-ask.xsl
View file @
67899026
Utilities/codegen/ctl-cpp-cc.xsl
View file @
67899026
Utilities/codegen/ctl-cpp-common.xsl
View file @
67899026
conf/libuniset2.spec
View file @
67899026
...
...
@@ -26,7 +26,7 @@
Name: libuniset2
Version: 2.7
Release: alt1
4.M80P.15
Release: alt1
5.M80P.16
Summary: UniSet - library for building distributed industrial control systems
License: LGPL
...
...
@@ -546,9 +546,15 @@ rm -f %buildroot%_docdir/%oname/html/*.md5
# history of current unpublished changes
%changelog
* T
ue Sep 04 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt14.M80P.15
* T
hu Oct 11 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt15.M80P.16
- backport to ALTLinux p8 (by rpmbph script)
* Thu Oct 11 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt16
- (codegen): reformat
- (Modbus): modify genRegID(), update test, used 'using' instead 'typedef'
- (UNet): set default prefix for log setup (default: "--unet-log")
- (UNet): increased the maximum allowed number of analog values for node (2000)
* Tue Sep 04 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt15
- (mtr): fix bug for read from 'serial device'
- (UNet): added "undefined_value" property
...
...
extensions/UNetUDP/UDPPacket.h
View file @
67899026
...
...
@@ -87,8 +87,8 @@ namespace uniset
// с другой стороны в текущей реализации
// в сеть посылается фактическое количество данных, а не sizeof(UDPPacket).
// При текущих настройках sizeof(UDPPacket) =
32654
(!)
static
const
size_t
MaxACount
=
15
00
;
// При текущих настройках sizeof(UDPPacket) =
72679
(!)
static
const
size_t
MaxACount
=
20
00
;
static
const
size_t
MaxDCount
=
5000
;
static
const
size_t
MaxDDataCount
=
1
+
MaxDCount
/
8
*
sizeof
(
unsigned
char
);
...
...
extensions/UNetUDP/UNetExchange.cc
View file @
67899026
...
...
@@ -164,7 +164,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
}
unetinfo
<<
myname
<<
"(init): init sender.. my node "
<<
n_it
.
getProp
(
"name"
)
<<
endl
;
sender
=
make_shared
<
UNetSender
>
(
h
,
p
,
shm
,
false
,
s_field
,
s_fvalue
,
prefix
);
sender
=
make_shared
<
UNetSender
>
(
h
,
p
,
shm
,
false
,
s_field
,
s_fvalue
,
"unet"
,
prefix
);
sender
->
setSendPause
(
sendpause
);
sender
->
setCheckConnectionPause
(
checkConnectionPause
);
loga
->
add
(
sender
->
getLog
());
...
...
@@ -326,7 +326,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
unetinfo
<<
myname
<<
"(init): (node='"
<<
n
<<
"') add basic receiver "
<<
h
<<
":"
<<
p
<<
endl
;
auto
r
=
make_shared
<
UNetReceiver
>
(
h
,
p
,
shm
);
auto
r
=
make_shared
<
UNetReceiver
>
(
h
,
p
,
shm
,
false
,
prefix
);
loga
->
add
(
r
->
getLog
());
...
...
@@ -358,7 +358,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
unetinfo
<<
myname
<<
"(init): (node='"
<<
n
<<
"') add reserv receiver "
<<
h2
<<
":"
<<
p2
<<
endl
;
r2
=
make_shared
<
UNetReceiver
>
(
h2
,
p2
,
shm
);
r2
=
make_shared
<
UNetReceiver
>
(
h2
,
p2
,
shm
,
false
,
prefix
);
loga
->
add
(
r2
->
getLog
());
...
...
extensions/UNetUDP/UNetReceiver.cc
View file @
67899026
...
...
@@ -40,7 +40,10 @@ bool UNetReceiver::PacketCompare::operator()(const UniSetUDP::UDPMessage& lhs,
}
*/
// ------------------------------------------------------------------------------------------
UNetReceiver
::
UNetReceiver
(
const
std
::
string
&
s_host
,
int
_port
,
const
std
::
shared_ptr
<
SMInterface
>&
smi
,
bool
nocheckConnection
)
:
UNetReceiver
::
UNetReceiver
(
const
std
::
string
&
s_host
,
int
_port
,
const
std
::
shared_ptr
<
SMInterface
>&
smi
,
bool
nocheckConnection
,
const
std
::
string
&
prefix
)
:
shm
(
smi
),
recvpause
(
10
),
updatepause
(
100
),
...
...
@@ -71,11 +74,14 @@ UNetReceiver::UNetReceiver(const std::string& s_host, int _port, const std::shar
addr
=
s_host
.
c_str
();
ostringstream
logname
;
logname
<<
prefix
<<
"-R-"
<<
s_host
<<
":"
<<
setw
(
4
)
<<
port
;
unetlog
=
make_shared
<
DebugStream
>
();
unetlog
->
setLogName
(
myname
);
unetlog
->
setLogName
(
logname
.
str
()
);
auto
conf
=
uniset_conf
();
conf
->
initLogStream
(
unetlog
,
myname
);
conf
->
initLogStream
(
unetlog
,
prefix
+
"-log"
);
upThread
=
unisetstd
::
make_unique
<
ThreadCreator
<
UNetReceiver
>
>
(
this
,
&
UNetReceiver
::
updateThread
);
...
...
extensions/UNetUDP/UNetReceiver.h
View file @
67899026
...
...
@@ -101,7 +101,9 @@ namespace uniset
public
std
::
enable_shared_from_this
<
UNetReceiver
>
{
public
:
UNetReceiver
(
const
std
::
string
&
host
,
int
port
,
const
std
::
shared_ptr
<
SMInterface
>&
smi
,
bool
nocheckConnection
=
false
);
UNetReceiver
(
const
std
::
string
&
host
,
int
port
,
const
std
::
shared_ptr
<
SMInterface
>&
smi
,
bool
nocheckConnection
=
false
,
const
std
::
string
&
prefix
=
"unet"
);
virtual
~
UNetReceiver
();
void
start
();
...
...
extensions/UNetUDP/UNetSender.cc
View file @
67899026
...
...
@@ -31,10 +31,12 @@ namespace uniset
// -----------------------------------------------------------------------------
UNetSender
::
UNetSender
(
const
std
::
string
&
_host
,
const
int
_port
,
const
std
::
shared_ptr
<
SMInterface
>&
smi
,
bool
nocheckConnection
,
const
std
::
string
&
s_f
,
const
std
::
string
&
s_val
,
const
std
::
string
&
s_prefix
,
size_t
maxDCount
,
size_t
maxACount
)
:
const
std
::
string
&
s_prefix
,
const
std
::
string
&
prefix
,
size_t
maxDCount
,
size_t
maxACount
)
:
s_field
(
s_f
),
s_fvalue
(
s_val
),
prefix
(
s_prefix
),
pr
op_pr
efix
(
s_prefix
),
shm
(
smi
),
port
(
_port
),
s_host
(
_host
),
...
...
@@ -55,11 +57,14 @@ namespace uniset
myname
=
s
.
str
();
}
ostringstream
logname
;
logname
<<
prefix
<<
"-S-"
<<
s_host
<<
"-"
<<
port
;
unetlog
=
make_shared
<
DebugStream
>
();
unetlog
->
setLogName
(
myname
);
unetlog
->
setLogName
(
logname
.
str
()
);
auto
conf
=
uniset_conf
();
conf
->
initLogStream
(
unetlog
,
myname
);
conf
->
initLogStream
(
unetlog
,
prefix
+
"-log"
);
unetinfo
<<
myname
<<
"(init): read filter-field='"
<<
s_field
<<
"' filter-value='"
<<
s_fvalue
<<
"'"
<<
endl
;
...
...
@@ -407,7 +412,7 @@ namespace uniset
return
false
;
}
int
priority
=
it
.
getPIntProp
(
prefix
+
"_sendfactor"
,
0
);
int
priority
=
it
.
getPIntProp
(
pr
op_pr
efix
+
"_sendfactor"
,
0
);
auto
&
pk
=
mypacks
[
priority
];
...
...
extensions/UNetUDP/UNetSender.h
View file @
67899026
...
...
@@ -69,9 +69,14 @@ namespace uniset
class
UNetSender
{
public
:
UNetSender
(
const
std
::
string
&
host
,
const
int
port
,
const
std
::
shared_ptr
<
SMInterface
>&
smi
,
bool
nocheckConnection
=
false
,
const
std
::
string
&
s_field
=
""
,
const
std
::
string
&
s_fvalue
=
""
,
const
std
::
string
&
prefix
=
"unet"
,
size_t
maxDCount
=
UniSetUDP
::
MaxDCount
,
size_t
maxACount
=
UniSetUDP
::
MaxACount
);
UNetSender
(
const
std
::
string
&
host
,
const
int
port
,
const
std
::
shared_ptr
<
SMInterface
>&
smi
,
bool
nocheckConnection
=
false
,
const
std
::
string
&
s_field
=
""
,
const
std
::
string
&
s_fvalue
=
""
,
const
std
::
string
&
prop_prefix
=
"unet"
,
const
std
::
string
&
prefix
=
"unet"
,
size_t
maxDCount
=
UniSetUDP
::
MaxDCount
,
size_t
maxACount
=
UniSetUDP
::
MaxACount
);
virtual
~
UNetSender
();
...
...
@@ -175,7 +180,7 @@ namespace uniset
std
::
string
s_field
=
{
""
};
std
::
string
s_fvalue
=
{
""
};
std
::
string
prefix
=
{
""
};
std
::
string
pr
op_pr
efix
=
{
""
};
const
std
::
shared_ptr
<
SMInterface
>
shm
;
std
::
shared_ptr
<
DebugStream
>
unetlog
;
...
...
extensions/UNetUDP/start_fg.sh
View file @
67899026
...
...
@@ -3,6 +3,6 @@
uniset2-start.sh
-f
./uniset2-unetexchange
--unet-name
UNetExchange
--unet-run-logserver
\
--confile
test.xml
--smemory-id
SharedMemory
\
--unet-filter-field
rs
--unet-filter-value
2
--unet-maxdifferense
40
--unet-sendpause
1000
\
--dlog-add-levels
info,crit,warn
--unet-log-add-levels
info,crit,warn,any
$*
--dlog-add-levels
info,crit,warn
--unet-log-add-levels
info,crit,warn,any
--unet-S-localhost-3000-add-levels
any
$*
#--unet-nodes-confnode specnet
include/modbus/ModbusTypes.h
View file @
67899026
...
...
@@ -79,7 +79,7 @@ namespace uniset
};
typedef
unsigned
long
RegID
;
using
RegID
=
size_t
;
/*! Получение уникального ID (hash?) на основе номера функции и регистра
* Требования к данной функции:
...
...
@@ -87,7 +87,7 @@ namespace uniset
* 2. одинаковые регистры, но разные функции должны давать разный ID
* 3. регистры идущие подряд, должны давать ID идущие тоже подряд
*/
RegID
genRegID
(
const
ModbusRTU
::
ModbusData
r
,
const
in
t
fn
);
RegID
genRegID
(
const
ModbusRTU
::
ModbusData
r
,
const
uint8_
t
fn
);
// определение размера данных в зависимости от типа сообщения
// возвращает -1 - если динамический размер сообщения или размер неизвестен
...
...
@@ -134,7 +134,7 @@ namespace uniset
*/
};
const
u
nsigned
char
MBErrMask
=
0x80
;
const
u
int8_t
MBErrMask
=
0x80
;
// ---------------------------------------------------------------------
uint16_t
SWAPSHORT
(
uint16_t
x
);
// ---------------------------------------------------------------------
...
...
@@ -1217,7 +1217,7 @@ namespace uniset
std
::
string
val
;
};
typedef
std
::
list
<
RDIObjectInfo
>
RDIObjectList
;
using
RDIObjectList
=
std
::
list
<
RDIObjectInfo
>
;
/*! Ответ для 0x2B/0x0E */
struct
MEIMessageRetRDI
:
...
...
src/Communications/Modbus/ModbusTypes.cc
View file @
67899026
...
...
@@ -3651,16 +3651,17 @@ namespace uniset
return
s
.
str
();
}
// ----------------------------------------------------------------------
ModbusRTU
::
RegID
ModbusRTU
::
genRegID
(
const
ModbusRTU
::
ModbusData
mbreg
,
const
in
t
fn
)
ModbusRTU
::
RegID
ModbusRTU
::
genRegID
(
const
ModbusRTU
::
ModbusData
mbreg
,
const
uint8_
t
fn
)
{
// диапазоны:
// mbreg: 0..65535
// fn: 0...255
int
max
=
numeric_limits
<
ModbusRTU
::
ModbusData
>::
max
();
// по идее 65535
int
fn_max
=
numeric_limits
<
ModbusRTU
::
ModbusByte
>::
max
();
// по идее 255
size_t
reg_max
=
numeric_limits
<
ModbusRTU
::
ModbusData
>::
max
();
// по идее 65535
// fn необходимо привести к диапазону 0..max
return
max
+
mbreg
+
max
+
uniset
::
lcalibrate
(
fn
,
0
,
fn_max
,
0
,
max
,
false
);
// задача функции сдвинуть диапазон за рабочий диапазон для регистров (65535)
// а так же обеспечить, чтобы для каждого нового номера функции был свой диапазон
// не пересекающийся с другими
return
reg_max
+
mbreg
+
(
reg_max
*
fn
)
+
1
;
}
// ----------------------------------------------------------------------
size_t
ModbusRTU
::
numBytes
(
const
size_t
nbits
)
...
...
tests/test_modbustypes.cc
View file @
67899026
...
...
@@ -125,23 +125,25 @@ TEST_CASE("numBytes function", "[modbus][numbytes]" )
REQUIRE
(
ModbusRTU
::
numBytes
(
257
)
==
33
);
}
// ---------------------------------------------------------------
#if 0
#warning VERY LONG TIME TEST
TEST_CASE
(
"genRegID"
,
"[modbus][genRegID]"
)
{
in
t max_reg = numeric_limits<ModbusRTU::ModbusData>::max();
in
t max_fn = numeric_limits<ModbusRTU::ModbusByte>::max();
size_
t
max_reg
=
numeric_limits
<
ModbusRTU
::
ModbusData
>::
max
();
size_
t
max_fn
=
numeric_limits
<
ModbusRTU
::
ModbusByte
>::
max
();
ModbusRTU
::
RegID
prevID
=
ModbusRTU
::
genRegID
(
0
,
0
);
for(
in
t f = 1; f < max_fn; f++ )
for
(
size_
t
f
=
1
;
f
<
max_fn
;
f
++
)
{
ModbusRTU
::
RegID
minID
=
ModbusRTU
::
genRegID
(
0
,
f
);
REQUIRE( minID > prevID );
for( int r = 1; r < max_reg; r++ )
// для каждого нового номера функции должен быть свой диапазон
// не пересекающийся с другими
REQUIRE
(
minID
>
(
prevID
+
max_reg
-
1
)
);
prevID
=
minID
;
for
(
size_t
r
=
1
;
r
<
max_reg
;
r
++
)
REQUIRE
(
ModbusRTU
::
genRegID
(
r
,
f
)
==
minID
+
r
);
}
}
#endif
// ---------------------------------------------------------------
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