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
78ce6738
Commit
78ce6738
authored
Sep 29, 2009
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add processing new vtypes (vtUnsigned,vtSigned)
parent
3d5d683d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
223 additions
and
13 deletions
+223
-13
MBTCPMaster.cc
extensions/MBTCPMaster/MBTCPMaster.cc
+55
-1
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+80
-4
MBSlave.h
extensions/ModbusSlave/MBSlave.h
+5
-2
RTUExchange.cc
extensions/RTUExchange/RTUExchange.cc
+73
-4
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+9
-1
VTypes.h
extensions/include/VTypes.h
+1
-1
No files found.
extensions/MBTCPMaster/MBTCPMaster.cc
View file @
78ce6738
...
...
@@ -1556,7 +1556,7 @@ void MBTCPMaster::updateRSProperty( RSProperty* p, bool write_only )
IOBase
::
processingAsDI
(
p
,
r
->
mbval
,
shm
,
force
);
}
else
IOBase
::
processingAsAI
(
p
,
r
->
mbval
,
shm
,
force
);
IOBase
::
processingAsAI
(
p
,
(
signed
short
)(
r
->
mbval
)
,
shm
,
force
);
}
return
;
}
...
...
@@ -1565,6 +1565,60 @@ void MBTCPMaster::updateRSProperty( RSProperty* p, bool write_only )
<<
" > 1 ?!! for id="
<<
p
->
si
.
id
<<
endl
;
return
;
}
else
if
(
p
->
vType
==
VTypes
::
vtSigned
)
{
if
(
save
)
{
if
(
p
->
stype
==
UniversalIO
::
DigitalInput
||
p
->
stype
==
UniversalIO
::
DigitalOutput
)
{
r
->
mbval
=
(
signed
short
)
IOBase
::
processingAsDO
(
p
,
shm
,
force_out
);
}
else
r
->
mbval
=
(
signed
short
)
IOBase
::
processingAsAO
(
p
,
shm
,
force_out
);
}
else
{
if
(
p
->
stype
==
UniversalIO
::
DigitalInput
||
p
->
stype
==
UniversalIO
::
DigitalOutput
)
{
IOBase
::
processingAsDI
(
p
,
r
->
mbval
,
shm
,
force
);
}
else
{
long
val
=
(
signed
short
)
r
->
mbval
;
IOBase
::
processingAsAI
(
p
,
val
,
shm
,
force
);
}
}
return
;
}
else
if
(
p
->
vType
==
VTypes
::
vtUnsigned
)
{
if
(
save
)
{
if
(
p
->
stype
==
UniversalIO
::
DigitalInput
||
p
->
stype
==
UniversalIO
::
DigitalOutput
)
{
r
->
mbval
=
(
unsigned
short
)
IOBase
::
processingAsDO
(
p
,
shm
,
force_out
);
}
else
r
->
mbval
=
(
unsigned
short
)
IOBase
::
processingAsAO
(
p
,
shm
,
force_out
);
}
else
{
if
(
p
->
stype
==
UniversalIO
::
DigitalInput
||
p
->
stype
==
UniversalIO
::
DigitalOutput
)
{
IOBase
::
processingAsDI
(
p
,
r
->
mbval
,
shm
,
force
);
}
else
{
long
val
=
(
unsigned
short
)
r
->
mbval
;
IOBase
::
processingAsAI
(
p
,
val
,
shm
,
force
);
}
}
return
;
}
else
if
(
p
->
vType
==
VTypes
::
vtByte
)
{
if
(
p
->
nbyte
<=
0
||
p
->
nbyte
>
VTypes
::
Byte
::
bsize
)
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
78ce6738
...
...
@@ -690,6 +690,23 @@ bool MBSlave::initItem( UniXML_iterator& it )
else
if
(
am
==
"rw"
)
p
.
amode
=
MBSlave
::
amRW
;
string
vt
(
it
.
getProp
(
"mb_vtype"
));
if
(
vt
.
empty
()
)
p
.
vtype
=
VTypes
::
vtUnknown
;
else
{
VTypes
::
VType
v
(
VTypes
::
str2type
(
vt
));
if
(
v
==
VTypes
::
vtUnknown
)
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown rtuVType="
<<
vt
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
}
p
.
vtype
=
v
;
}
iomap
[
p
.
mbreg
]
=
p
;
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
...
...
@@ -891,7 +908,7 @@ ModbusRTU::mbErrCode MBSlave::writeOutputSingleRegister( ModbusRTU::WriteSingleO
}
// -------------------------------------------------------------------------
ModbusRTU
::
mbErrCode
MBSlave
::
real_write
(
ModbusRTU
::
ModbusData
reg
,
ModbusRTU
::
ModbusData
val
)
ModbusRTU
::
ModbusData
mb
val
)
{
try
{
...
...
@@ -899,8 +916,8 @@ ModbusRTU::mbErrCode MBSlave::real_write( ModbusRTU::ModbusData reg,
{
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(write): save mbID="
<<
ModbusRTU
::
dat2str
(
reg
)
<<
" data="
<<
ModbusRTU
::
dat2str
(
val
)
<<
"("
<<
(
int
)
val
<<
")"
<<
endl
;
<<
" data="
<<
ModbusRTU
::
dat2str
(
mb
val
)
<<
"("
<<
(
int
)
mb
val
<<
")"
<<
endl
;
}
IOMap
::
iterator
it
=
iomap
.
find
(
reg
);
...
...
@@ -912,6 +929,65 @@ ModbusRTU::mbErrCode MBSlave::real_write( ModbusRTU::ModbusData reg,
if
(
p
->
amode
==
MBSlave
::
amRO
)
return
ModbusRTU
::
erBadDataAddress
;
if
(
p
->
vtype
==
VTypes
::
vtUnknown
)
{
if
(
p
->
stype
==
UniversalIO
::
DigitalInput
||
p
->
stype
==
UniversalIO
::
DigitalOutput
)
{
IOBase
::
processingAsDI
(
p
,
mbval
,
shm
,
force
);
}
else
{
long
val
=
(
signed
short
)(
mbval
);
IOBase
::
processingAsAI
(
p
,
val
,
shm
,
force
);
}
return
erNoError
;
}
else
if
(
p
->
vtype
==
VTypes
::
vtUnsigned
)
{
long
val
=
(
unsigned
short
)(
mbval
);
IOBase
::
processingAsAI
(
p
,
val
,
shm
,
force
);
}
else
if
(
p
->
vtype
==
VTypes
::
vtSigned
)
{
long
val
=
(
signed
short
)(
mbval
);
IOBase
::
processingAsAI
(
p
,
val
,
shm
,
force
);
}
/*
else if( p->vtype == VTypes::vtByte )
{
VTypes::Byte b(r->mbval);
IOBase::processingAsAI( p, b.raw.b[p->nbyte-1], shm, force );
return;
}
else if( p->vtype == VTypes::vtF2 )
{
RegMap::iterator i(p->reg->rit);
ModbusRTU::ModbusData* data = new ModbusRTU::ModbusData[VTypes::F2::wsize()];
for( int k=0; k<VTypes::F2::wsize(); k++, i++ )
data[k] = i->second->mbval;
VTypes::F2 f(data,VTypes::F2::wsize());
delete[] data;
IOBase::processingFasAI( p, (float)f, shm, force );
}
else if( p->vtype == VTypes::vtF4 )
{
RegMap::iterator i(p->reg->rit);
ModbusRTU::ModbusData* data = new ModbusRTU::ModbusData[VTypes::F4::wsize()];
for( int k=0; k<VTypes::F4::wsize(); k++, i++ )
data[k] = i->second->mbval;
VTypes::F4 f(data,VTypes::F4::wsize());
delete[] data;
IOBase::processingFasAI( p, (float)f, shm, force );
}
*/
/*
if( p->stype == UniversalIO::DigitalInput ||
p->stype == UniversalIO::DigitalOutput )
{
...
...
@@ -923,7 +999,7 @@ ModbusRTU::mbErrCode MBSlave::real_write( ModbusRTU::ModbusData reg,
{
IOBase::processingAsAI( p, val, shm, force );
}
*/
pingOK
=
true
;
return
ModbusRTU
::
erNoError
;
}
...
...
extensions/ModbusSlave/MBSlave.h
View file @
78ce6738
...
...
@@ -16,6 +16,7 @@
#include "SMInterface.h"
#include "SharedMemory.h"
#include "IOBase.h"
#include "VTypes.h"
#include "ThreadCreator.h"
// -----------------------------------------------------------------------------
class
MBSlave
:
...
...
@@ -45,11 +46,13 @@ class MBSlave:
struct
IOProperty
:
public
IOBase
{
ModbusRTU
::
ModbusData
mbreg
;
/*!< */
ModbusRTU
::
ModbusData
mbreg
;
/*!< */
AccessMode
amode
;
VTypes
::
VType
vtype
;
/*!< type of value */
IOProperty
()
:
mbreg
(
0
)
mbreg
(
0
),
vtype
(
VTypes
::
vtUnknown
)
{}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
IOProperty
&
p
);
...
...
extensions/RTUExchange/RTUExchange.cc
View file @
78ce6738
...
...
@@ -1707,14 +1707,29 @@ void RTUExchange::updateRSProperty( RSProperty* p, bool write_only )
}
return
;
}
if
(
p
->
rnum
<=
1
)
{
if
(
save
)
r
->
mbval
=
IOBase
::
processingAsAO
(
p
,
shm
,
force_out
);
{
if
(
p
->
stype
==
UniversalIO
::
DigitalInput
||
p
->
stype
==
UniversalIO
::
DigitalOutput
)
{
r
->
mbval
=
IOBase
::
processingAsDO
(
p
,
shm
,
force_out
);
}
else
r
->
mbval
=
IOBase
::
processingAsAO
(
p
,
shm
,
force_out
);
}
else
IOBase
::
processingAsAI
(
p
,
r
->
mbval
,
shm
,
force
);
{
if
(
p
->
stype
==
UniversalIO
::
DigitalInput
||
p
->
stype
==
UniversalIO
::
DigitalOutput
)
{
IOBase
::
processingAsDI
(
p
,
r
->
mbval
,
shm
,
force
);
}
else
IOBase
::
processingAsAI
(
p
,
(
signed
short
)(
r
->
mbval
),
shm
,
force
);
}
return
;
}
...
...
@@ -1722,6 +1737,60 @@ void RTUExchange::updateRSProperty( RSProperty* p, bool write_only )
<<
" > 1 ?!! for id="
<<
p
->
si
.
id
<<
endl
;
return
;
}
else
if
(
p
->
vType
==
VTypes
::
vtSigned
)
{
if
(
save
)
{
if
(
p
->
stype
==
UniversalIO
::
DigitalInput
||
p
->
stype
==
UniversalIO
::
DigitalOutput
)
{
r
->
mbval
=
(
signed
short
)
IOBase
::
processingAsDO
(
p
,
shm
,
force_out
);
}
else
r
->
mbval
=
(
signed
short
)
IOBase
::
processingAsAO
(
p
,
shm
,
force_out
);
}
else
{
if
(
p
->
stype
==
UniversalIO
::
DigitalInput
||
p
->
stype
==
UniversalIO
::
DigitalOutput
)
{
IOBase
::
processingAsDI
(
p
,
r
->
mbval
,
shm
,
force
);
}
else
{
long
val
=
(
signed
short
)
r
->
mbval
;
IOBase
::
processingAsAI
(
p
,
val
,
shm
,
force
);
}
}
return
;
}
else
if
(
p
->
vType
==
VTypes
::
vtUnsigned
)
{
if
(
save
)
{
if
(
p
->
stype
==
UniversalIO
::
DigitalInput
||
p
->
stype
==
UniversalIO
::
DigitalOutput
)
{
r
->
mbval
=
(
unsigned
short
)
IOBase
::
processingAsDO
(
p
,
shm
,
force_out
);
}
else
r
->
mbval
=
(
unsigned
short
)
IOBase
::
processingAsAO
(
p
,
shm
,
force_out
);
}
else
{
if
(
p
->
stype
==
UniversalIO
::
DigitalInput
||
p
->
stype
==
UniversalIO
::
DigitalOutput
)
{
IOBase
::
processingAsDI
(
p
,
r
->
mbval
,
shm
,
force
);
}
else
{
long
val
=
(
unsigned
short
)
r
->
mbval
;
IOBase
::
processingAsAI
(
p
,
val
,
shm
,
force
);
}
}
return
;
}
else
if
(
p
->
vType
==
VTypes
::
vtByte
)
{
if
(
p
->
nbyte
<=
0
||
p
->
nbyte
>
VTypes
::
Byte
::
bsize
)
...
...
extensions/SharedMemory/SharedMemory.cc
View file @
78ce6738
...
...
@@ -19,7 +19,7 @@ SharedMemory::SharedMemory( ObjectId id, string datafile ):
dblogging
(
false
),
msecPulsar
(
0
)
{
cout
<<
"$Id: SharedMemory.cc,v 1.4 2009/01/24 11:20:19 vpashka Exp $"
<<
endl
;
//
cout << "$Id: SharedMemory.cc,v 1.4 2009/01/24 11:20:19 vpashka Exp $" << endl;
xmlNode
*
cnode
=
conf
->
getNode
(
"SharedMemory"
);
if
(
cnode
==
NULL
)
...
...
@@ -627,12 +627,20 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
hi
.
fuse_invert
=
it
.
getIntProp
(
"fuse_invert"
);
hi
.
fuse_use_val
=
false
;
if
(
!
it
.
getProp
(
"fuse_value"
).
empty
()
)
{
hi
.
fuse_use_val
=
true
;
hi
.
fuse_val
=
it
.
getIntProp
(
"fuse_value"
);
}
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(buildHistory): add fuse_id"
<<
hi
.
fuse_id
<<
" fuse_val="
<<
hi
.
fuse_val
<<
" fuse_use_val="
<<
hi
.
fuse_use_val
<<
" fuse_invert="
<<
hi
.
fuse_invert
<<
endl
;
// WARNING: no check duplicates...
hist
.
push_back
(
hi
);
}
...
...
extensions/include/VTypes.h
View file @
78ce6738
...
...
@@ -25,7 +25,7 @@ namespace VTypes
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
VType
&
vt
);
// -------------------------------------------------------------------------
std
::
string
type2str
(
VType
t
);
/*!< */
std
::
string
type2str
(
VType
t
);
/*!< */
VType
str2type
(
const
std
::
string
s
);
/*!< */
int
wsize
(
VType
t
);
/*!< */
// -------------------------------------------------------------------------
...
...
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