Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
7c5b1249
Commit
7c5b1249
authored
Oct 27, 2011
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modbus RTU added
parent
e431ce45
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
4055 additions
and
12 deletions
+4055
-12
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_master.c
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_master.c
+795
-0
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_module.c
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_module.c
+180
-0
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_server.c
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_server.c
+1223
-0
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_servermodule.c
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_servermodule.c
+168
-0
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_slave.c
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_slave.c
+275
-0
otherio/lib/rt/src/os_linux/rt_io_mb_rtu.h
otherio/lib/rt/src/os_linux/rt_io_mb_rtu.h
+261
-0
otherio/lib/rt/src/rt_io_otherio.meth
otherio/lib/rt/src/rt_io_otherio.meth
+5
-0
otherio/wbl/mcomp/src/otherio.wb_load
otherio/wbl/mcomp/src/otherio.wb_load
+1049
-12
src/wbl/pwrb/src/pwrb_td_stallactionenum.wb_load
src/wbl/pwrb/src/pwrb_td_stallactionenum.wb_load
+88
-0
wb/exp/wb/src/pwr_wb_palette.cnf
wb/exp/wb/src/pwr_wb_palette.cnf
+11
-0
No files found.
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_master.c
0 → 100644
View file @
7c5b1249
This diff is collapsed.
Click to expand it.
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_module.c
0 → 100644
View file @
7c5b1249
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2011 SSAB Oxelosund AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_errh.h"
#include "rt_io_bus.h"
#include "rt_mb_msg.h"
#include "rt_io_mb_rtu.h"
/*----------------------------------------------------------------------------*\
Init method for the Modbus module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardInit
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sCardLocalMsg
*
local
;
pwr_sClass_Modbus_RTU_Module
*
op
;
int
i
;
op
=
(
pwr_sClass_Modbus_RTU_Module
*
)
cp
->
op
;
local
=
((
io_sCardLocal
*
)
cp
->
Local
)
->
msg
;
for
(
i
=
0
;
i
<
IO_MAXCHAN
;
i
++
)
{
local
->
scancount
[
i
]
=
0
;
}
op
->
Status
=
pwr_eModbusModule_StatusEnum_StatusUnknown
;
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Read method for the Modbus RTU module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardRead
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sCardLocalMsg
*
local
;
io_sRackLocal
*
local_rack
=
(
io_sRackLocal
*
)
rp
->
Local
;
pwr_sClass_Modbus_RTU_Module
*
op
;
pwr_sClass_Modbus_RTU_Slave
*
slave
;
op
=
(
pwr_sClass_Modbus_RTU_Module
*
)
cp
->
op
;
local
=
((
io_sCardLocal
*
)
cp
->
Local
)
->
msg
;
slave
=
(
pwr_sClass_Modbus_RTU_Slave
*
)
rp
->
op
;
if
(
op
->
ScanInterval
>
1
)
{
local
->
has_read_method
=
1
;
if
(
local
->
interval_cnt
!=
0
)
{
local
->
interval_cnt
++
;
if
(
local
->
interval_cnt
>=
op
->
ScanInterval
)
local
->
interval_cnt
=
0
;
return
IO__SUCCESS
;
}
local
->
interval_cnt
++
;
}
if
(
slave
->
Status
==
MB__NORMAL
||
local_rack
->
reset_inputs
)
{
io_bus_card_read
(
ctx
,
rp
,
cp
,
slave
->
Inputs
,
NULL
,
pwr_eByteOrderingEnum_BigEndian
,
pwr_eFloatRepEnum_FloatIntel
);
}
// printf("Method Modbus_RTU_Module-IoCardRead\n");
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Write method for the Modbus RTU module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardWrite
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sCardLocalMsg
*
local
;
pwr_sClass_Modbus_RTU_Module
*
op
;
pwr_sClass_Modbus_RTU_Slave
*
slave
;
op
=
(
pwr_sClass_Modbus_RTU_Module
*
)
cp
->
op
;
local
=
((
io_sCardLocal
*
)
cp
->
Local
)
->
msg
;
slave
=
(
pwr_sClass_Modbus_RTU_Slave
*
)
rp
->
op
;
if
(
op
->
ScanInterval
>
1
)
{
if
(
!
local
->
has_read_method
)
{
if
(
local
->
interval_cnt
!=
0
)
{
local
->
interval_cnt
++
;
if
(
local
->
interval_cnt
>=
op
->
ScanInterval
)
local
->
interval_cnt
=
0
;
return
IO__SUCCESS
;
}
local
->
interval_cnt
++
;
}
else
if
(
local
->
interval_cnt
!=
1
)
return
IO__SUCCESS
;
}
if
(
slave
->
Status
==
MB__NORMAL
)
{
io_bus_card_write
(
ctx
,
cp
,
slave
->
Outputs
,
pwr_eByteOrderingEnum_BigEndian
,
pwr_eFloatRepEnum_FloatIntel
);
}
// printf("Method Modbus_RTU_Module-IoCardWrite\n");
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport
pwr_BindIoMethods
(
Modbus_RTU_Module
)
=
{
pwr_BindIoMethod
(
IoCardInit
),
pwr_BindIoMethod
(
IoCardRead
),
pwr_BindIoMethod
(
IoCardWrite
),
pwr_NullMethod
};
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_server.c
0 → 100644
View file @
7c5b1249
This diff is collapsed.
Click to expand it.
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_servermodule.c
0 → 100644
View file @
7c5b1249
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2011 SSAB Oxelosund AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <unistd.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_errh.h"
#include "rt_io_bus.h"
#include "rt_mb_msg.h"
#include "rt_io_mb_rtu.h"
#include "co_time.h"
/*----------------------------------------------------------------------------*\
Init method for the Modbus server module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardInit
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sServerModuleLocal
*
local
;
pwr_sClass_Modbus_RTU_ServerModule
*
op
;
int
i
;
op
=
(
pwr_sClass_Modbus_RTU_ServerModule
*
)
cp
->
op
;
local
=
(
io_sServerModuleLocal
*
)
cp
->
Local
;
for
(
i
=
0
;
i
<
IO_MAXCHAN
;
i
++
)
{
local
->
scancount
[
i
]
=
0
;
}
op
->
Status
=
pwr_eModbusModule_StatusEnum_StatusUnknown
;
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Read method for the Modbus RTU server module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardRead
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sServerModuleLocal
*
local
;
io_sServerLocal
*
local_server
;
pwr_sClass_Modbus_RTU_ServerModule
*
op
;
pwr_sClass_Modbus_RTU_Server
*
server
;
op
=
(
pwr_sClass_Modbus_RTU_ServerModule
*
)
cp
->
op
;
local
=
(
io_sServerModuleLocal
*
)
cp
->
Local
;
server
=
(
pwr_sClass_Modbus_RTU_Server
*
)
rp
->
op
;
local_server
=
(
io_sServerLocal
*
)
rp
->
Local
;
if
(
server
->
DisableServer
||
!
local
)
return
IO__SUCCESS
;
if
(
server
->
Status
==
MB__NORMAL
)
{
thread_MutexLock
(
&
local_server
->
mutex
);
io_bus_card_read
(
ctx
,
rp
,
cp
,
local
->
input_area
,
NULL
,
pwr_eByteOrderingEnum_BigEndian
,
pwr_eFloatRepEnum_FloatIntel
);
thread_MutexUnlock
(
&
local_server
->
mutex
);
}
// printf("Method Modbus_Module-IoCardRead\n");
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Write method for the Modbus RTU server module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardWrite
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sServerModuleLocal
*
local
;
io_sServerLocal
*
local_server
;
pwr_sClass_Modbus_RTU_ServerModule
*
op
;
pwr_sClass_Modbus_RTU_Server
*
server
;
op
=
(
pwr_sClass_Modbus_RTU_ServerModule
*
)
cp
->
op
;
local
=
(
io_sServerModuleLocal
*
)
cp
->
Local
;
server
=
(
pwr_sClass_Modbus_RTU_Server
*
)
rp
->
op
;
local_server
=
(
io_sServerLocal
*
)
rp
->
Local
;
if
(
server
->
DisableServer
||
!
local
)
return
IO__SUCCESS
;
if
(
server
->
Status
==
MB__NORMAL
)
{
thread_MutexLock
(
&
local_server
->
mutex
);
io_bus_card_write
(
ctx
,
cp
,
local
->
output_area
,
pwr_eByteOrderingEnum_BigEndian
,
pwr_eFloatRepEnum_FloatIntel
);
thread_MutexUnlock
(
&
local_server
->
mutex
);
}
// printf("Method Modbus_Module-IoCardWrite\n");
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport
pwr_BindIoMethods
(
Modbus_RTU_ServerModule
)
=
{
pwr_BindIoMethod
(
IoCardInit
),
pwr_BindIoMethod
(
IoCardRead
),
pwr_BindIoMethod
(
IoCardWrite
),
pwr_NullMethod
};
otherio/lib/rt/src/os_linux/rt_io_m_mb_rtu_slave.c
0 → 100644
View file @
7c5b1249
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2011 SSAB Oxelosund AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* rt_io_m_mb_rtu_slave.c -- io methods for a Modbus RTU slave */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "pwr.h"
#include "co_cdh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "rt_gdh.h"
#include "rt_io_base.h"
#include "rt_io_bus.h"
#include "rt_io_msg.h"
#include "rt_errh.h"
#include "co_cdh.h"
#include "co_time.h"
#include "rt_mb_msg.h"
#include "rt_io_mb_rtu.h"
/*----------------------------------------------------------------------------*\
Init method for the Modbus_TCP slave
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoRackInit
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
)
{
io_sCardLocal
*
local_card
;
io_sCard
*
cardp
;
io_sRackLocal
*
local
;
int
no_di
;
int
no_do
;
pwr_sClass_Modbus_RTU_Slave
*
op
;
char
name
[
196
];
pwr_tStatus
sts
;
pwr_tCid
cid
;
io_sChannel
*
chanp
;
int
i
;
sts
=
gdh_ObjidToName
(
rp
->
Objid
,
(
char
*
)
&
name
,
sizeof
(
name
),
cdh_mNName
);
errh_Info
(
"Init of Modbus TCP Slave and Modules %s"
,
name
);
op
=
(
pwr_sClass_Modbus_RTU_Slave
*
)
rp
->
op
;
rp
->
Local
=
calloc
(
1
,
sizeof
(
io_sRackLocal
));
local
=
rp
->
Local
;
op
->
Status
=
MB__NORMAL
;
/* Do configuration check and initialize modules. */
cardp
=
rp
->
cardlist
;
unsigned
int
prev_input_area_offset
=
0
;
unsigned
int
prev_output_area_offset
=
0
;
unsigned
int
input_area_offset
=
0
;
unsigned
int
output_area_offset
=
0
;
unsigned
int
input_area_chansize
=
0
;
unsigned
int
output_area_chansize
=
0
;
while
(
cardp
)
{
local_card
=
calloc
(
1
,
sizeof
(
*
local_card
));
cid
=
cardp
->
Class
;
/* Find the super class */
while
(
ODD
(
gdh_GetSuperClass
(
cid
,
&
cid
,
cardp
->
Objid
)))
;
switch
(
cid
)
{
case
pwr_cClass_Modbus_RTU_Module
:
{
pwr_sClass_Modbus_RTU_Module
*
modulep
;
cardp
->
Local
=
local_card
;
no_di
=
0
;
no_do
=
0
;
local_card
->
msg
[
0
].
input_area
=
(
void
*
)
&
(
op
->
Inputs
)
+
input_area_offset
+
input_area_chansize
;
local_card
->
msg
[
0
].
output_area
=
(
void
*
)
&
(
op
->
Outputs
)
+
output_area_offset
+
output_area_chansize
;
modulep
=
(
pwr_sClass_Modbus_RTU_Module
*
)
cardp
->
op
;
modulep
->
Status
=
pwr_eModbusModule_StatusEnum_StatusUnknown
;
io_bus_card_init
(
ctx
,
cardp
,
&
input_area_offset
,
&
input_area_chansize
,
&
output_area_offset
,
&
output_area_chansize
,
pwr_eByteOrderingEnum_BigEndian
);
/* Count number of di and do */
for
(
i
=
0
;
i
<
cardp
->
ChanListSize
;
i
++
)
{
chanp
=
&
cardp
->
chanlist
[
i
];
switch
(
chanp
->
ChanClass
)
{
case
pwr_cClass_ChanDi
:
no_di
++
;
break
;
case
pwr_cClass_ChanDo
:
no_do
++
;
break
;
}
}
local_card
->
msg
[
0
].
input_size
=
input_area_offset
+
input_area_chansize
-
prev_input_area_offset
;
local_card
->
msg
[
0
].
output_size
=
output_area_offset
+
output_area_chansize
-
prev_output_area_offset
;
local_card
->
msg
[
0
].
no_di
=
no_di
;
local_card
->
msg
[
0
].
no_do
=
no_do
;
break
;
}
}
/* End - switch ... */
prev_input_area_offset
=
input_area_offset
+
input_area_chansize
;
prev_output_area_offset
=
output_area_offset
+
output_area_chansize
;
cardp
=
cardp
->
next
;
}
local
->
input_size
=
input_area_offset
+
input_area_chansize
;
local
->
output_size
=
output_area_offset
+
output_area_chansize
;
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Read method for the Modbus_TCP slave
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoRackRead
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
)
{
#if 0
io_sRackLocal *local;
pwr_sClass_Modbus_TCP_Slave *sp;
pwr_tStatus sts;
pwr_tTime now;
pwr_tDeltaTime dt;
local = rp->Local;
sp = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
/* Receive data */
if ((sp->Status == MB__NORMAL) && !sp->SingleOp) {
sts = mb_recv_data(local, rp, sp);
}
if (sp->DisableSlave != 1) {
if (sp->Status == MB__NORMAL) {
sp->ErrorCount = 0;
}
else {
sp->ErrorCount++;
}
if (sp->ErrorCount > sp->ErrorLimit) {
memset(&sp->Inputs, 0, local->input_size);
}
}
else {
sp->ErrorCount = 0;
sp->Status = MB__DISABLED;
}
#endif
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Write method for the Modbus_TCP slave
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoRackWrite
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
)
{
#if 0
io_sRackLocal *local;
pwr_sClass_Modbus_TCP_Slave *sp;
pwr_tStatus sts;
local = rp->Local;
sp = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
local->expected_msgs = 0;
if (sp->Status == MB__NORMAL && sp->DisableSlave != 1) {
sts = mb_send_data( rp, ap->Local, local, ap->op, sp, mb_mSendMask_WriteReq);
}
if (sp->DisableSlave == 1) sp->Status = MB__DISABLED;
#endif
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoRackClose
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
)
{
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport
pwr_BindIoMethods
(
Modbus_RTU_Slave
)
=
{
pwr_BindIoMethod
(
IoRackInit
),
pwr_BindIoMethod
(
IoRackRead
),
pwr_BindIoMethod
(
IoRackWrite
),
pwr_BindIoMethod
(
IoRackClose
),
pwr_NullMethod
};
otherio/lib/rt/src/os_linux/rt_io_mb_rtu.h
0 → 100644
View file @
7c5b1249
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2011 SSAB Oxelosund AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#ifndef pwr_class_h
#include "pwr_class.h"
#endif
#define IO_MAXCHAN 96
#define MAX_MSGS_LOST 5
// These constants are obsolete from V4.1, except for the old style
// (Pb_Di, Pb_Do etc)
#define PB_MODULE_STATE_NOTINIT 0
#define PB_MODULE_STATE_OPERATE 1
#define PB_NUMREP_UNSIGNEDINT 0
#define PB_NUMREP_SIGNEDINT 1
#define PB_NUMREP_FLOATIEEE 2
#define PB_NUMREP_FLOATVAX 3
#define PB_NUMREP_FLOATINTEL 4
#define PB_ORIENTATION_BYTE 8
#define PB_ORIENTATION_WORD 16
#define PB_ORIENTATION_DWORD 32
#define PB_UDATA_DIAG 1
#define MB_MAX_CONNECTIONS 20
typedef
pwr_tMask
mb_tSendMask
;
typedef
enum
{
mb_mSendMask_ReadReq
=
1
,
mb_mSendMask_WriteReq
=
2
,
}
mb_mSendMask
;
typedef
struct
{
int
initialized
;
int
fd
;
}
io_sAgentLocal
;
typedef
struct
{
int
initialized
;
short
int
trans_id
;
int
input_size
;
int
output_size
;
int
msgs_lost
;
pwr_tTime
last_try_connect_time
;
int
reset_inputs
;
}
io_sRackLocal
;
typedef
struct
{
void
*
input_area
;
void
*
output_area
;
int
scancount
[
IO_MAXCHAN
];
int
trans_id
;
int
input_size
;
int
output_size
;
short
int
no_di
;
short
int
no_do
;
int
interval_cnt
;
int
has_read_method
;
}
io_sCardLocalMsg
;
typedef
struct
{
io_sCardLocalMsg
msg
[
2
];
}
io_sCardLocal
;
typedef
struct
{
int
initialized
;
int
fd
;
int
input_size
;
int
output_size
;
pwr_tTime
last_req_time
;
thread_sMutex
mutex
;
thread_s
receive_thread
;
}
io_sServerLocal
;
typedef
struct
{
void
*
input_area
;
void
*
output_area
;
int
scancount
[
IO_MAXCHAN
];
int
trans_id
;
int
input_size
;
int
output_size
;
int
no_di
;
int
no_do
;
int
di_offset
;
int
do_offset
;
int
di_size
;
int
do_size
;
}
io_sServerModuleLocal
;
#pragma pack(1)
typedef
struct
_read_req
{
unsigned
char
unit_id
;
unsigned
char
fc
;
short
int
addr
;
short
int
quant
;
short
int
crc
;
}
read_req
;
typedef
struct
_rec_buf
{
unsigned
char
unit_id
;
unsigned
char
fc
;
unsigned
char
buf
[
255
];
}
rec_buf
;
typedef
struct
_write_single_req
{
unsigned
char
unit_id
;
unsigned
char
fc
;
short
int
addr
;
short
int
value
;
short
int
crc
;
}
write_single_req
;
typedef
struct
_write_reg_req
{
unsigned
char
unit_id
;
unsigned
char
fc
;
short
int
addr
;
short
int
quant
;
unsigned
char
bc
;
short
int
reg
[
125
];
short
int
crc
;
}
write_reg_req
;
typedef
struct
_write_coils_req
{
unsigned
char
unit_id
;
unsigned
char
fc
;
short
int
addr
;
short
int
quant
;
unsigned
char
bc
;
unsigned
char
reg
[
247
];
short
int
crc
;
}
write_coils_req
;
typedef
struct
_read_dev_id_req
{
unsigned
char
unit_id
;
unsigned
char
fc
;
unsigned
char
mei_type
;
unsigned
char
id_code
;
unsigned
char
object_id
;
short
int
crc
;
}
read_dev_id_req
;
typedef
struct
_res_write
{
unsigned
char
unit_id
;
unsigned
char
fc
;
short
int
addr
;
short
int
quant
;
unsigned
char
buf
[
248
];
short
int
crc
;
}
res_write
;
typedef
struct
_res_read
{
unsigned
char
unit_id
;
unsigned
char
fc
;
unsigned
char
bc
;
unsigned
char
buf
[
251
];
short
int
crc
;
}
res_read
;
typedef
struct
_res_fault
{
unsigned
char
unit_id
;
unsigned
char
fc
;
unsigned
char
ec
;
short
int
crc
;
}
res_fault
;
typedef
struct
_rsp_fault
{
unsigned
char
unit_id
;
unsigned
char
fc
;
unsigned
char
ec
;
short
int
crc
;
}
rsp_fault
;
typedef
struct
_rsp_read
{
unsigned
char
unit_id
;
unsigned
char
fc
;
unsigned
char
bc
;
unsigned
char
buf
[
250
];
short
int
crc
;
}
rsp_read
;
typedef
struct
_rsp_write
{
unsigned
char
unit_id
;
unsigned
char
fc
;
short
int
addr
;
short
int
quant
;
short
int
crc
;
}
rsp_write
;
typedef
struct
_rsp_single_write
{
unsigned
char
unit_id
;
unsigned
char
fc
;
short
int
addr
;
short
int
value
;
short
int
crc
;
}
rsp_single_write
;
typedef
struct
_rsp_dev_id
{
unsigned
char
unit_id
;
unsigned
char
fc
;
unsigned
char
mei_type
;
unsigned
char
id_code
;
unsigned
char
conformity_level
;
unsigned
char
more_follows
;
unsigned
char
next_object_id
;
unsigned
char
number_of_objects
;
unsigned
char
list
[
80
];
short
int
crc
;
}
rsp_dev_id
;
#pragma pack(0)
pwr_tStatus
mb_recv_data
(
io_sRackLocal
*
local
,
io_sRack
*
rp
,
pwr_sClass_Modbus_TCP_Slave
*
sp
);
pwr_tStatus
mb_send_data
(
io_sRackLocal
*
local
,
io_sRack
*
rp
,
pwr_sClass_Modbus_TCP_Slave
*
sp
,
mb_tSendMask
mask
);
otherio/lib/rt/src/rt_io_otherio.meth
View file @
7c5b1249
...
...
@@ -6,6 +6,11 @@ Modbus_ModuleReadWrite
Modbus_Master
Modbus_TCP_Server
Modbus_TCP_ServerModule
Modbus_RTU_Slave
Modbus_RTU_Module
Modbus_RTU_Master
Modbus_RTU_Server
Modbus_RTU_ServerModule
Arduino_Uno
#if OS_LINUX
GPIO
...
...
otherio/wbl/mcomp/src/otherio.wb_load
View file @
7c5b1249
This diff is collapsed.
Click to expand it.
src/wbl/pwrb/src/pwrb_td_stallactionenum.wb_load
0 → 100644
View file @
7c5b1249
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2011 SSAB Oxelosund AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_td_stallactionenum.wb_load -- Defines the enum type StallAction
!
SObject pwrb:Type
!/**
! @Version 1.0
! @Group Types
! Enumeration for I/O stall action.
!*/
Object StallActionEnum $TypeDef 58
Body SysBody
Attr TypeRef = "pwrs:Type-$Enum"
Attr PgmName = "StallActionEnum"
EndBody
!/**
! No.
!*/
Object No $Value
Body SysBody
Attr PgmName = "No"
Attr Text = "No"
Attr Value = 0
EndBody
EndObject
!/**
! Reset inputs.
!*/
Object ResetInputs $Value
Body SysBody
Attr PgmName = "ResetInputs"
Attr Text = "Reset inputs"
Attr Value = 1
EndBody
EndObject
!/**
! Emergency break.
!*/
Object EmergencyBreak $Value
Body SysBody
Attr PgmName = "EmergencyBreak"
Attr Text = "Set emergency break"
Attr Value = 2
EndBody
EndObject
EndObject
EndSObject
wb/exp/wb/src/pwr_wb_palette.cnf
View file @
7c5b1249
...
...
@@ -307,6 +307,17 @@ palette NavigatorPalette
class Modbus_TCP_ServerModule
}
}
menu Modbus_RTU
{
class Modbus_RTU_Master
class Modbus_RTU_Slave
class Modbus_RTU_Module
menu Server
{
class Modbus_RTU_Server
class Modbus_RTU_ServerModule
}
}
menu Hilscher_cifX
{
class Hilscher_cifX_Master
...
...
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