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
21d51161
Commit
21d51161
authored
Aug 10, 2010
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new MTR type of variable: T16 and T17
parent
7f5124ec
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
153 additions
and
5 deletions
+153
-5
libuniset.spec
conf/libuniset.spec
+1
-1
MBTCPMaster.cc
extensions/MBTCPMaster/MBTCPMaster.cc
+31
-1
RTUExchange.cc
extensions/RTUExchange/RTUExchange.cc
+30
-2
mtrconv.cc
extensions/RTUExchange/mtrconv.cc
+11
-1
MTR.h
extensions/include/MTR.h
+68
-0
MTR.cc
extensions/lib/MTR.cc
+12
-0
No files found.
conf/libuniset.spec
View file @
21d51161
...
...
@@ -3,7 +3,7 @@
Name: libuniset
Version: 0.98
Release: eter
6
Release: eter
7
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
...
...
extensions/MBTCPMaster/MBTCPMaster.cc
View file @
21d51161
...
...
@@ -2046,7 +2046,37 @@ void MBTCPMaster::updateMTR( RegMap::iterator& rit )
}
continue
;
}
if
(
r
->
mtrType
==
MTR
::
mtT16
)
{
if
(
save
)
{
MTR
::
T16
t
(
IOBase
::
processingFasAO
(
&
(
*
it
),
shm
,
force_out
));
r
->
mbval
=
t
.
val
;
}
else
{
MTR
::
T16
t
(
r
->
mbval
);
IOBase
::
processingFasAI
(
&
(
*
it
),
t
.
fval
,
shm
,
force
);
}
continue
;
}
if
(
r
->
mtrType
==
MTR
::
mtT17
)
{
if
(
save
)
{
MTR
::
T17
t
(
IOBase
::
processingFasAO
(
&
(
*
it
),
shm
,
force_out
));
r
->
mbval
=
t
.
val
;
}
else
{
MTR
::
T17
t
(
r
->
mbval
);
IOBase
::
processingFasAI
(
&
(
*
it
),
t
.
fval
,
shm
,
force
);
}
continue
;
}
if
(
r
->
mtrType
==
MTR
::
mtF1
)
{
RegMap
::
iterator
i
(
rit
);
...
...
extensions/RTUExchange/RTUExchange.cc
View file @
21d51161
...
...
@@ -25,8 +25,6 @@ rs_pre_clean(false),
noQueryOptimization
(
false
),
allNotRespond
(
false
)
{
cout
<<
"$Id: RTUExchange.cc,v 1.4 2009/01/23 23:56:54 vpashka Exp $"
<<
endl
;
if
(
objId
==
DefaultObjectId
)
throw
UniSetTypes
::
SystemError
(
"(RTUExchange): objId=-1?!! Use --rs-name"
);
...
...
@@ -2119,6 +2117,36 @@ void RTUExchange::updateMTR( RegMap::iterator& rit )
}
continue
;
}
if
(
r
->
mtrType
==
MTR
::
mtT16
)
{
if
(
save
)
{
MTR
::
T16
t
(
IOBase
::
processingFasAO
(
&
(
*
it
),
shm
,
force_out
));
r
->
mbval
=
t
.
val
;
}
else
{
MTR
::
T16
t
(
r
->
mbval
);
IOBase
::
processingFasAI
(
&
(
*
it
),
t
.
fval
,
shm
,
force
);
}
continue
;
}
if
(
r
->
mtrType
==
MTR
::
mtT17
)
{
if
(
save
)
{
MTR
::
T17
t
(
IOBase
::
processingFasAO
(
&
(
*
it
),
shm
,
force_out
));
r
->
mbval
=
t
.
val
;
}
else
{
MTR
::
T17
t
(
r
->
mbval
);
IOBase
::
processingFasAI
(
&
(
*
it
),
t
.
fval
,
shm
,
force
);
}
continue
;
}
if
(
r
->
mtrType
==
MTR
::
mtF1
)
{
...
...
extensions/RTUExchange/mtrconv.cc
View file @
21d51161
...
...
@@ -11,7 +11,7 @@ using namespace MTR;
// --------------------------------------------------------------------------
static
void
print_help
()
{
printf
(
"Usage: mtrconv TYPE[T1...T12] hex1 hex2
\n
"
);
printf
(
"Usage: mtrconv TYPE[T1...T12
,T16,T17
] hex1 hex2
\n
"
);
}
// --------------------------------------------------------------------------
int
main
(
int
argc
,
const
char
**
argv
)
...
...
@@ -40,6 +40,16 @@ int main( int argc, const char **argv )
cout
<<
"(T1): v1="
<<
v1
<<
" --> (unsigned) "
<<
v1
<<
endl
;
else
if
(
!
strcmp
(
type
,
"T2"
)
)
cout
<<
"(T2): v1="
<<
v1
<<
" --> (signed) "
<<
(
signed
short
)
v1
<<
endl
;
else
if
(
!
strcmp
(
type
,
"T16"
)
)
{
T16
t
(
v1
);
cout
<<
"(T16): v1="
<<
t
.
val
<<
" float="
<<
t
.
fval
<<
endl
;
}
else
if
(
!
strcmp
(
type
,
"T17"
)
)
{
T17
t
(
v1
);
cout
<<
"(T17): v1="
<<
t
.
val
<<
" float="
<<
t
.
fval
<<
endl
;
}
else
if
(
!
strcmp
(
type
,
"T3"
)
)
{
T3
t
(
v1
,
v2
);
...
...
extensions/include/MTR.h
View file @
21d51161
...
...
@@ -29,6 +29,8 @@ namespace MTR
mtT7
,
mtT8
,
mtT9
,
mtT16
,
mtT17
,
mtF1
,
mtT_Str16
,
mtT_Str8
...
...
@@ -462,6 +464,72 @@ namespace MTR
// ------------------------------------------
T9mem
raw
;
};
// -------------------------------------------------------------------------
class
T16
{
public
:
T16
()
:
val
(
0
){}
T16
(
unsigned
short
v
)
:
val
(
v
)
{
fval
=
(
float
)(
val
)
/
100
.
0
;
}
T16
(
const
ModbusRTU
::
ModbusData
*
data
)
:
val
(
data
[
0
])
{
fval
=
(
float
)(
val
)
/
100
.
0
;
}
T16
(
float
f
)
:
fval
(
f
)
{
val
=
lroundf
(
fval
*
100
);
}
~
T16
(){}
// ------------------------------------------
/*! размер в словах */
static
int
wsize
(){
return
1
;
}
/*! тип значения */
static
MTRType
type
(){
return
mtT16
;
}
// ------------------------------------------
operator
float
(){
return
fval
;
}
operator
unsigned
short
(){
return
val
;
}
unsigned
short
val
;
float
fval
;
};
// --------------------------------------------------------------------------
class
T17
{
public
:
T17
()
:
val
(
0
){}
T17
(
signed
short
v
)
:
val
(
v
)
{
fval
=
(
float
)(
v
)
/
100
.
0
;
}
T17
(
unsigned
short
v
)
:
val
(
v
)
{
fval
=
(
float
)(
(
signed
short
)(
v
)
)
/
100
.
0
;
}
T17
(
const
ModbusRTU
::
ModbusData
*
data
)
:
val
(
data
[
0
])
{
fval
=
(
float
)(
val
)
/
100
.
0
;
}
T17
(
float
f
)
:
fval
(
f
)
{
val
=
lroundf
(
fval
*
100
);
}
~
T17
(){}
// ------------------------------------------
/*! размер в словах */
static
int
wsize
(){
return
1
;
}
/*! тип значения */
static
MTRType
type
(){
return
mtT17
;
}
// ------------------------------------------
operator
float
(){
return
fval
;
}
operator
signed
short
(){
return
val
;
}
signed
short
val
;
float
fval
;
};
// --------------------------------------------------------------------------
class
F1
{
...
...
extensions/lib/MTR.cc
View file @
21d51161
...
...
@@ -34,6 +34,10 @@ MTRType str2type( const std::string s )
return
mtT8
;
if
(
s
==
"T9"
)
return
mtT9
;
if
(
s
==
"T16"
)
return
mtT16
;
if
(
s
==
"T17"
)
return
mtT17
;
if
(
s
==
"F1"
)
return
mtF1
;
if
(
s
==
"T_Str16"
)
...
...
@@ -64,6 +68,10 @@ string type2str( MTRType t )
return
"T8"
;
if
(
t
==
mtT9
)
return
"T9"
;
if
(
t
==
mtT16
)
return
"T16"
;
if
(
t
==
mtT17
)
return
"T17"
;
if
(
t
==
mtF1
)
return
"F1"
;
if
(
t
==
mtT_Str16
)
...
...
@@ -94,6 +102,10 @@ int wsize( MTRType t )
return
T8
::
wsize
();
if
(
t
==
mtT9
)
return
T9
::
wsize
();
if
(
t
==
mtT16
)
return
T16
::
wsize
();
if
(
t
==
mtT17
)
return
T17
::
wsize
();
if
(
t
==
mtF1
)
return
F1
::
wsize
();
if
(
t
==
mtT_Str16
)
...
...
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