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
b9c92a58
Commit
b9c92a58
authored
Dec 13, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Modbus): рефакторинг кода и тестов, корректировка под 64bit
parent
de872cfc
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
72 additions
and
57 deletions
+72
-57
libuniset2.spec
conf/libuniset2.spec
+1
-0
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+0
-0
MBTCPTestServer.cc
extensions/ModbusMaster/tests/MBTCPTestServer.cc
+9
-8
MBTCPTestServer.h
extensions/ModbusMaster/tests/MBTCPTestServer.h
+4
-4
run_test_mbtcpmaster.sh
extensions/ModbusMaster/tests/run_test_mbtcpmaster.sh
+0
-0
test_mbtcpmaster.cc
extensions/ModbusMaster/tests/test_mbtcpmaster.cc
+26
-18
test_mbtcpmultimaster.cc
extensions/ModbusMaster/tests/test_mbtcpmultimaster.cc
+2
-0
VTypes.h
extensions/include/VTypes.h
+30
-27
No files found.
conf/libuniset2.spec
View file @
b9c92a58
...
@@ -505,6 +505,7 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
...
@@ -505,6 +505,7 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet2.pc
%exclude %_pkgconfigdir/libUniSet2.pc
# history of current unpublished changes
# history of current unpublished changes
# Modbus: refactoring code and test (for 64bit)
%changelog
%changelog
* Mon Dec 12 2016 Pavel Vainerman <pv@altlinux.ru> 2.6-alt6
* Mon Dec 12 2016 Pavel Vainerman <pv@altlinux.ru> 2.6-alt6
...
...
extensions/ModbusMaster/MBExchange.cc
View file @
b9c92a58
This diff is collapsed.
Click to expand it.
extensions/ModbusMaster/tests/MBTCPTestServer.cc
View file @
b9c92a58
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
#include <sstream>
#include <sstream>
#include <limits>
#include <Poco/Net/NetException.h>
#include <Poco/Net/NetException.h>
#include "UniSetTypes.h"
#include "UniSetTypes.h"
#include "MBTCPTestServer.h"
#include "MBTCPTestServer.h"
...
@@ -23,7 +24,7 @@ MBTCPTestServer::MBTCPTestServer( const std::unordered_set<ModbusAddr>& _vaddr,
...
@@ -23,7 +24,7 @@ MBTCPTestServer::MBTCPTestServer( const std::unordered_set<ModbusAddr>& _vaddr,
sslot
(
NULL
),
sslot
(
NULL
),
vaddr
(
_vaddr
),
vaddr
(
_vaddr
),
verbose
(
verb
),
verbose
(
verb
),
replyVal
(
-
1
),
replyVal
(
std
::
numeric_limits
<
uint32_t
>::
max
()
),
forceSingleCoilCmd
(
false
),
forceSingleCoilCmd
(
false
),
lastWriteOutputSingleRegister
(
0
),
lastWriteOutputSingleRegister
(
0
),
lastForceCoilsQ
(
0
,
0
),
lastForceCoilsQ
(
0
,
0
),
...
@@ -122,7 +123,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readCoilStatus( ReadCoilMessage& query,
...
@@ -122,7 +123,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readCoilStatus( ReadCoilMessage& query,
if
(
query
.
count
<=
1
)
if
(
query
.
count
<=
1
)
{
{
if
(
replyVal
!=
-
1
)
if
(
replyVal
!=
std
::
numeric_limits
<
uint32_t
>::
max
()
)
reply
.
addData
(
replyVal
);
reply
.
addData
(
replyVal
);
else
else
reply
.
addData
(
d
);
reply
.
addData
(
d
);
...
@@ -136,7 +137,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readCoilStatus( ReadCoilMessage& query,
...
@@ -136,7 +137,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readCoilStatus( ReadCoilMessage& query,
for
(
;
num
<
query
.
count
;
num
++
,
reg
++
)
for
(
;
num
<
query
.
count
;
num
++
,
reg
++
)
{
{
if
(
replyVal
!=
-
1
)
if
(
replyVal
!=
std
::
numeric_limits
<
uint32_t
>::
max
()
)
reply
.
addData
(
replyVal
);
reply
.
addData
(
replyVal
);
else
else
reply
.
addData
(
d
);
reply
.
addData
(
d
);
...
@@ -167,7 +168,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readInputStatus( ReadInputStatusMessage& q
...
@@ -167,7 +168,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readInputStatus( ReadInputStatusMessage& q
d
.
b
[
3
]
=
1
;
d
.
b
[
3
]
=
1
;
d
.
b
[
7
]
=
1
;
d
.
b
[
7
]
=
1
;
if
(
replyVal
==
-
1
)
if
(
replyVal
==
std
::
numeric_limits
<
uint32_t
>::
max
()
)
{
{
size_t
bnum
=
0
;
size_t
bnum
=
0
;
size_t
i
=
0
;
size_t
i
=
0
;
...
@@ -207,7 +208,7 @@ mbErrCode MBTCPTestServer::readInputRegisters( ReadInputMessage& query,
...
@@ -207,7 +208,7 @@ mbErrCode MBTCPTestServer::readInputRegisters( ReadInputMessage& query,
if
(
query
.
count
<=
1
)
if
(
query
.
count
<=
1
)
{
{
if
(
replyVal
!=
-
1
)
if
(
replyVal
!=
std
::
numeric_limits
<
uint32_t
>::
max
()
)
reply
.
addData
(
replyVal
);
reply
.
addData
(
replyVal
);
else
else
reply
.
addData
(
query
.
start
);
reply
.
addData
(
query
.
start
);
...
@@ -221,7 +222,7 @@ mbErrCode MBTCPTestServer::readInputRegisters( ReadInputMessage& query,
...
@@ -221,7 +222,7 @@ mbErrCode MBTCPTestServer::readInputRegisters( ReadInputMessage& query,
for
(
;
num
<
query
.
count
;
num
++
,
reg
++
)
for
(
;
num
<
query
.
count
;
num
++
,
reg
++
)
{
{
if
(
replyVal
!=
-
1
)
if
(
replyVal
!=
std
::
numeric_limits
<
uint32_t
>::
max
()
)
reply
.
addData
(
replyVal
);
reply
.
addData
(
replyVal
);
else
else
reply
.
addData
(
reg
);
reply
.
addData
(
reg
);
...
@@ -252,7 +253,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readOutputRegisters(
...
@@ -252,7 +253,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readOutputRegisters(
if
(
query
.
count
<=
1
)
if
(
query
.
count
<=
1
)
{
{
if
(
replyVal
!=
-
1
)
if
(
replyVal
!=
std
::
numeric_limits
<
uint32_t
>::
max
()
)
reply
.
addData
(
replyVal
);
reply
.
addData
(
replyVal
);
else
else
reply
.
addData
(
query
.
start
);
reply
.
addData
(
query
.
start
);
...
@@ -266,7 +267,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readOutputRegisters(
...
@@ -266,7 +267,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readOutputRegisters(
for
(
;
num
<
query
.
count
;
num
++
,
reg
++
)
for
(
;
num
<
query
.
count
;
num
++
,
reg
++
)
{
{
if
(
replyVal
!=
-
1
)
if
(
replyVal
!=
std
::
numeric_limits
<
uint32_t
>::
max
()
)
reply
.
addData
(
replyVal
);
reply
.
addData
(
replyVal
);
else
else
reply
.
addData
(
reg
);
reply
.
addData
(
reg
);
...
...
extensions/ModbusMaster/tests/MBTCPTestServer.h
View file @
b9c92a58
...
@@ -19,7 +19,7 @@ class MBTCPTestServer
...
@@ -19,7 +19,7 @@ class MBTCPTestServer
verbose
=
state
;
verbose
=
state
;
}
}
inline
void
setReply
(
long
val
)
inline
void
setReply
(
uint32_t
val
)
{
{
replyVal
=
val
;
replyVal
=
val
;
}
}
...
@@ -47,7 +47,7 @@ class MBTCPTestServer
...
@@ -47,7 +47,7 @@ class MBTCPTestServer
{
{
return
forceSingleCoilCmd
;
return
forceSingleCoilCmd
;
}
}
inline
int
getLastWriteOutputSingleRegister
()
inline
int
16_t
getLastWriteOutputSingleRegister
()
{
{
return
lastWriteOutputSingleRegister
;
return
lastWriteOutputSingleRegister
;
}
}
...
@@ -131,9 +131,9 @@ class MBTCPTestServer
...
@@ -131,9 +131,9 @@ class MBTCPTestServer
std
::
unordered_set
<
uniset
::
ModbusRTU
::
ModbusAddr
>
vaddr
;
/*!< адреса данного узла */
std
::
unordered_set
<
uniset
::
ModbusRTU
::
ModbusAddr
>
vaddr
;
/*!< адреса данного узла */
bool
verbose
;
bool
verbose
;
long
replyVal
;
uint32_t
replyVal
;
bool
forceSingleCoilCmd
;
bool
forceSingleCoilCmd
;
int
lastWriteOutputSingleRegister
;
int
16_t
lastWriteOutputSingleRegister
;
uniset
::
ModbusRTU
::
ForceCoilsMessage
lastForceCoilsQ
;
uniset
::
ModbusRTU
::
ForceCoilsMessage
lastForceCoilsQ
;
uniset
::
ModbusRTU
::
WriteOutputMessage
lastWriteOutputQ
;
uniset
::
ModbusRTU
::
WriteOutputMessage
lastWriteOutputQ
;
float
f2_test_value
=
{
0
.
0
};
float
f2_test_value
=
{
0
.
0
};
...
...
extensions/ModbusMaster/tests/run_test_mbtcpmaster.sh
View file @
b9c92a58
extensions/ModbusMaster/tests/test_mbtcpmaster.cc
View file @
b9c92a58
...
@@ -222,12 +222,12 @@ TEST_CASE("MBTCPMaster: 0x03 (read register outputs or memories or read word out
...
@@ -222,12 +222,12 @@ TEST_CASE("MBTCPMaster: 0x03 (read register outputs or memories or read word out
REQUIRE
(
ui
->
getValue
(
1004
)
==
-
10
);
REQUIRE
(
ui
->
getValue
(
1004
)
==
-
10
);
REQUIRE
(
ui
->
getValue
(
1005
)
==
-
10
);
REQUIRE
(
ui
->
getValue
(
1005
)
==
-
10
);
REQUIRE
(
ui
->
getValue
(
1006
)
==
-
10
);
REQUIRE
(
ui
->
getValue
(
1006
)
==
-
10
);
mbs
->
setReply
(
0
);
mbs
->
setReply
(
1
);
msleep
(
polltime
+
200
);
msleep
(
polltime
+
200
);
REQUIRE
(
ui
->
getValue
(
1003
)
==
0
);
REQUIRE
(
ui
->
getValue
(
1003
)
==
1
);
REQUIRE
(
ui
->
getValue
(
1004
)
==
0
);
REQUIRE
(
ui
->
getValue
(
1004
)
==
1
);
REQUIRE
(
ui
->
getValue
(
1005
)
==
0
);
REQUIRE
(
ui
->
getValue
(
1005
)
==
1
);
REQUIRE
(
ui
->
getValue
(
1006
)
==
0
);
REQUIRE
(
ui
->
getValue
(
1006
)
==
1
);
mbs
->
setReply
(
65535
);
mbs
->
setReply
(
65535
);
msleep
(
polltime
+
200
);
msleep
(
polltime
+
200
);
REQUIRE
(
ui
->
getValue
(
1003
)
==
-
1
);
REQUIRE
(
ui
->
getValue
(
1003
)
==
-
1
);
...
@@ -236,10 +236,14 @@ TEST_CASE("MBTCPMaster: 0x03 (read register outputs or memories or read word out
...
@@ -236,10 +236,14 @@ TEST_CASE("MBTCPMaster: 0x03 (read register outputs or memories or read word out
REQUIRE
(
ui
->
getValue
(
1006
)
==
-
1
);
REQUIRE
(
ui
->
getValue
(
1006
)
==
-
1
);
REQUIRE
(
ui
->
getValue
(
1007
)
==
65535
);
// unsigned
REQUIRE
(
ui
->
getValue
(
1007
)
==
65535
);
// unsigned
mbs
->
setReply
(
0xffff
);
mbs
->
setReply
(
std
::
numeric_limits
<
uint16_t
>::
max
()
);
msleep
(
polltime
+
200
);
REQUIRE
(
(
uint16_t
)
ui
->
getValue
(
1009
)
==
std
::
numeric_limits
<
uint16_t
>::
max
()
);
// U2
mbs
->
setReply
(
std
::
numeric_limits
<
int16_t
>::
max
()
);
msleep
(
polltime
+
200
);
msleep
(
polltime
+
200
);
REQUIRE
(
ui
->
getValue
(
1008
)
==
0xffffffff
);
// I2
REQUIRE
(
(
int16_t
)
ui
->
getValue
(
1008
)
==
std
::
numeric_limits
<
int16_t
>::
max
()
);
// I2
REQUIRE
(
ui
->
getValue
(
1009
)
==
0xffffffff
);
// U2
mbs
->
setReply
(
0xff
);
mbs
->
setReply
(
0xff
);
msleep
(
polltime
+
200
);
msleep
(
polltime
+
200
);
REQUIRE
(
ui
->
getValue
(
1008
)
==
0x00ff00ff
);
// I2
REQUIRE
(
ui
->
getValue
(
1008
)
==
0x00ff00ff
);
// I2
...
@@ -281,10 +285,14 @@ TEST_CASE("MBTCPMaster: 0x04 (read input registers or memories or read word outp
...
@@ -281,10 +285,14 @@ TEST_CASE("MBTCPMaster: 0x04 (read input registers or memories or read word outp
REQUIRE
(
ui
->
getValue
(
1013
)
==
-
1
);
REQUIRE
(
ui
->
getValue
(
1013
)
==
-
1
);
REQUIRE
(
ui
->
getValue
(
1014
)
==
65535
);
// unsigned
REQUIRE
(
ui
->
getValue
(
1014
)
==
65535
);
// unsigned
mbs
->
setReply
(
0xffff
);
mbs
->
setReply
(
std
::
numeric_limits
<
uint16_t
>::
max
()
);
msleep
(
polltime
+
200
);
msleep
(
polltime
+
200
);
REQUIRE
(
ui
->
getValue
(
1015
)
==
0xffffffff
);
// I2
REQUIRE
(
(
uint16_t
)
ui
->
getValue
(
1009
)
==
std
::
numeric_limits
<
uint16_t
>::
max
()
);
// U2
REQUIRE
(
ui
->
getValue
(
1016
)
==
0xffffffff
);
// U2
mbs
->
setReply
(
std
::
numeric_limits
<
int16_t
>::
max
()
);
msleep
(
polltime
+
200
);
REQUIRE
(
(
int16_t
)
ui
->
getValue
(
1008
)
==
std
::
numeric_limits
<
int16_t
>::
max
()
);
// I2
mbs
->
setReply
(
0xff
);
mbs
->
setReply
(
0xff
);
msleep
(
polltime
+
200
);
msleep
(
polltime
+
200
);
REQUIRE
(
ui
->
getValue
(
1015
)
==
0x00ff00ff
);
// I2
REQUIRE
(
ui
->
getValue
(
1015
)
==
0x00ff00ff
);
// I2
...
@@ -457,23 +465,23 @@ TEST_CASE("MBTCPMaster: 0x10 (write register outputs or memories)", "[modbus][0x
...
@@ -457,23 +465,23 @@ TEST_CASE("MBTCPMaster: 0x10 (write register outputs or memories)", "[modbus][0x
REQUIRE
(
q
.
addr
==
slaveADDR
);
REQUIRE
(
q
.
addr
==
slaveADDR
);
REQUIRE
(
q
.
start
==
31
);
REQUIRE
(
q
.
start
==
31
);
REQUIRE
(
q
.
quant
==
6
);
REQUIRE
(
q
.
quant
==
6
);
REQUIRE
(
q
.
data
[
0
]
==
(
u
nsigned
shor
t
)(
-
100
)
);
REQUIRE
(
q
.
data
[
0
]
==
(
u
int16_
t
)(
-
100
)
);
REQUIRE
(
q
.
data
[
2
]
==
(
u
nsigned
shor
t
)(
-
10
)
);
REQUIRE
(
q
.
data
[
2
]
==
(
u
int16_
t
)(
-
10
)
);
REQUIRE
(
q
.
data
[
3
]
==
(
u
nsigned
shor
t
)(
-
32767
)
);
REQUIRE
(
q
.
data
[
3
]
==
(
u
int16_
t
)(
-
32767
)
);
}
}
SECTION
(
"I2"
)
SECTION
(
"I2"
)
{
{
ui
->
setValue
(
1023
,
0xffffffff
);
ui
->
setValue
(
1023
,
std
::
numeric_limits
<
uint32_t
>::
max
()
);
REQUIRE
(
ui
->
getValue
(
1023
)
==
0xffffffff
);
REQUIRE
(
(
uint32_t
)
ui
->
getValue
(
1023
)
==
std
::
numeric_limits
<
uint32_t
>::
max
()
);
msleep
(
polltime
+
200
);
msleep
(
polltime
+
200
);
ModbusRTU
::
WriteOutputMessage
q
=
mbs
->
getLastWriteOutput
();
ModbusRTU
::
WriteOutputMessage
q
=
mbs
->
getLastWriteOutput
();
REQUIRE
(
q
.
addr
==
slaveADDR
);
REQUIRE
(
q
.
addr
==
slaveADDR
);
REQUIRE
(
q
.
start
==
31
);
REQUIRE
(
q
.
start
==
31
);
REQUIRE
(
q
.
quant
==
6
);
REQUIRE
(
q
.
quant
==
6
);
REQUIRE
(
q
.
data
[
4
]
==
0xffff
);
REQUIRE
(
q
.
data
[
4
]
==
std
::
numeric_limits
<
uint16_t
>::
max
()
);
REQUIRE
(
q
.
data
[
5
]
==
0xffff
);
REQUIRE
(
q
.
data
[
5
]
==
std
::
numeric_limits
<
uint16_t
>::
max
()
);
}
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
...
extensions/ModbusMaster/tests/test_mbtcpmultimaster.cc
View file @
b9c92a58
...
@@ -127,6 +127,8 @@ TEST_CASE("MBTCPMultiMaster: rotate channel", "[modbus][mbmaster][mbtcpmultimast
...
@@ -127,6 +127,8 @@ TEST_CASE("MBTCPMultiMaster: rotate channel", "[modbus][mbmaster][mbtcpmultimast
InitTest
();
InitTest
();
CHECK
(
ui
->
isExist
(
mbID
)
);
CHECK
(
ui
->
isExist
(
mbID
)
);
mbs1
->
setReply
(
0
);
msleep
(
polltime
+
1000
);
REQUIRE
(
ui
->
getValue
(
1003
)
==
0
);
REQUIRE
(
ui
->
getValue
(
1003
)
==
0
);
mbs1
->
setReply
(
100
);
mbs1
->
setReply
(
100
);
mbs2
->
setReply
(
10
);
mbs2
->
setReply
(
10
);
...
...
extensions/include/VTypes.h
View file @
b9c92a58
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#define _RTUTypes_H_
#define _RTUTypes_H_
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#include <string>
#include <string>
#include <stdint.h>
#include <cmath>
#include <cmath>
#include <cstring>
#include <cstring>
#include <ostream>
#include <ostream>
...
@@ -61,7 +62,7 @@ namespace uniset
...
@@ -61,7 +62,7 @@ namespace uniset
/*! тип хранения в памяти */
/*! тип хранения в памяти */
typedef
union
typedef
union
{
{
u
nsigned
shor
t
v
[
f2Size
];
u
int16_
t
v
[
f2Size
];
float
val
;
//
float
val
;
//
}
F2mem
;
}
F2mem
;
// ------------------------------------------
// ------------------------------------------
...
@@ -147,7 +148,7 @@ namespace uniset
...
@@ -147,7 +148,7 @@ namespace uniset
/*! тип хранения в памяти */
/*! тип хранения в памяти */
typedef
union
typedef
union
{
{
u
nsigned
shor
t
v
[
f4Size
];
u
int16_
t
v
[
f4Size
];
float
val
;
//
float
val
;
//
}
F4mem
;
}
F4mem
;
// ------------------------------------------
// ------------------------------------------
...
@@ -202,8 +203,8 @@ namespace uniset
...
@@ -202,8 +203,8 @@ namespace uniset
/*! тип хранения в памяти */
/*! тип хранения в памяти */
typedef
union
typedef
union
{
{
u
nsigned
shor
t
w
;
u
int16_
t
w
;
u
nsigned
char
b
[
bsize
];
u
int8_t
b
[
bsize
];
}
Bytemem
;
}
Bytemem
;
// ------------------------------------------
// ------------------------------------------
// конструкторы на разные случаи...
// конструкторы на разные случаи...
...
@@ -212,15 +213,11 @@ namespace uniset
...
@@ -212,15 +213,11 @@ namespace uniset
raw
.
w
=
0
;
raw
.
w
=
0
;
}
}
Byte
(
u
nsigned
char
b1
,
unsigned
char
b2
)
noexcept
Byte
(
u
int8_t
b1
,
uint8_t
b2
)
noexcept
{
{
raw
.
b
[
0
]
=
b1
;
raw
.
b
[
0
]
=
b1
;
raw
.
b
[
1
]
=
b2
;
raw
.
b
[
1
]
=
b2
;
}
}
Byte
(
const
long
&
val
)
noexcept
{
raw
.
w
=
val
;
}
Byte
(
const
ModbusRTU
::
ModbusData
dat
)
noexcept
Byte
(
const
ModbusRTU
::
ModbusData
dat
)
noexcept
{
{
...
@@ -240,16 +237,12 @@ namespace uniset
...
@@ -240,16 +237,12 @@ namespace uniset
return
vtByte
;
return
vtByte
;
}
}
// ------------------------------------------
// ------------------------------------------
operator
long
()
operator
uint16_t
()
{
return
lroundf
(
raw
.
w
);
}
operator
unsigned
short
()
{
{
return
raw
.
w
;
return
raw
.
w
;
}
}
u
nsigned
char
operator
[](
const
in
t
i
)
u
int8_t
operator
[](
const
size_
t
i
)
{
{
return
raw
.
b
[
i
];
return
raw
.
b
[
i
];
}
}
...
@@ -293,7 +286,7 @@ namespace uniset
...
@@ -293,7 +286,7 @@ namespace uniset
return
raw
;
return
raw
;
}
}
u
nsigned
shor
t
raw
;
u
int16_
t
raw
;
};
};
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
class
Signed
class
Signed
...
@@ -332,7 +325,7 @@ namespace uniset
...
@@ -332,7 +325,7 @@ namespace uniset
return
raw
;
return
raw
;
}
}
signed
shor
t
raw
;
int16_
t
raw
;
};
};
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
class
I2
class
I2
...
@@ -344,8 +337,8 @@ namespace uniset
...
@@ -344,8 +337,8 @@ namespace uniset
/*! тип хранения в памяти */
/*! тип хранения в памяти */
typedef
union
typedef
union
{
{
u
nsigned
shor
t
v
[
i2Size
];
u
int16_
t
v
[
i2Size
];
int
val
;
//
int
32_t
val
;
//
}
I2mem
;
}
I2mem
;
// ------------------------------------------
// ------------------------------------------
// конструкторы на разные случаи...
// конструкторы на разные случаи...
...
@@ -354,7 +347,7 @@ namespace uniset
...
@@ -354,7 +347,7 @@ namespace uniset
memset
(
raw
.
v
,
0
,
sizeof
(
raw
.
v
));
memset
(
raw
.
v
,
0
,
sizeof
(
raw
.
v
));
}
}
I2
(
int
v
)
noexcept
I2
(
int
32_t
v
)
noexcept
{
{
raw
.
val
=
v
;
raw
.
val
=
v
;
}
}
...
@@ -377,7 +370,7 @@ namespace uniset
...
@@ -377,7 +370,7 @@ namespace uniset
return
vtI2
;
return
vtI2
;
}
}
// ------------------------------------------
// ------------------------------------------
operator
int
()
operator
int
32_t
()
{
{
return
raw
.
val
;
return
raw
.
val
;
}
}
...
@@ -394,7 +387,7 @@ namespace uniset
...
@@ -394,7 +387,7 @@ namespace uniset
raw_backorder
.
val
=
0
;
raw_backorder
.
val
=
0
;
}
}
I2r
(
const
int
v
)
noexcept
:
I2
(
v
)
I2r
(
const
int
32_t
v
)
noexcept
:
I2
(
v
)
{
{
raw_backorder
=
raw
;
raw_backorder
=
raw
;
std
::
swap
(
raw_backorder
.
v
[
0
],
raw_backorder
.
v
[
1
]);
std
::
swap
(
raw_backorder
.
v
[
0
],
raw_backorder
.
v
[
1
]);
...
@@ -421,8 +414,8 @@ namespace uniset
...
@@ -421,8 +414,8 @@ namespace uniset
/*! тип хранения в памяти */
/*! тип хранения в памяти */
typedef
union
typedef
union
{
{
u
nsigned
shor
t
v
[
u2Size
];
u
int16_
t
v
[
u2Size
];
u
nsigned
in
t
val
;
//
u
int32_
t
val
;
//
}
U2mem
;
}
U2mem
;
// ------------------------------------------
// ------------------------------------------
// конструкторы на разные случаи...
// конструкторы на разные случаи...
...
@@ -431,7 +424,7 @@ namespace uniset
...
@@ -431,7 +424,7 @@ namespace uniset
memset
(
raw
.
v
,
0
,
sizeof
(
raw
.
v
));
memset
(
raw
.
v
,
0
,
sizeof
(
raw
.
v
));
}
}
U2
(
u
nsigned
in
t
v
)
noexcept
U2
(
u
int32_
t
v
)
noexcept
{
{
raw
.
val
=
v
;
raw
.
val
=
v
;
}
}
...
@@ -454,11 +447,21 @@ namespace uniset
...
@@ -454,11 +447,21 @@ namespace uniset
return
vtU2
;
return
vtU2
;
}
}
// ------------------------------------------
// ------------------------------------------
operator
unsigned
int
()
operator
uint32_t
()
{
return
raw
.
val
;
}
operator
long
()
{
{
return
raw
.
val
;
return
raw
.
val
;
}
}
operator
unsigned
long
()
{
return
(
uint32_t
)
raw
.
val
;
}
U2mem
raw
;
U2mem
raw
;
};
};
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
...
@@ -471,7 +474,7 @@ namespace uniset
...
@@ -471,7 +474,7 @@ namespace uniset
raw_backorder
.
val
=
0
;
raw_backorder
.
val
=
0
;
}
}
U2r
(
int
v
)
noexcept
:
U2
(
v
)
U2r
(
int
32_t
v
)
noexcept
:
U2
(
v
)
{
{
raw_backorder
=
raw
;
raw_backorder
=
raw
;
std
::
swap
(
raw_backorder
.
v
[
0
],
raw_backorder
.
v
[
1
]);
std
::
swap
(
raw_backorder
.
v
[
0
],
raw_backorder
.
v
[
1
]);
...
...
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