Commit 1554195f authored by Claes Sjofors's avatar Claes Sjofors

Merge branch 'master' of pwrcvs:/data1/git/pwr

parents ea6eeeaf d4c08858
......@@ -47,6 +47,8 @@ void CompModePID_Fo_exec( plc_sThread *tp, pwr_sClass_CompModePID_Fo *object);
void CompPID_Fo_init( pwr_sClass_CompPID_Fo *object);
void CompPID_Fo_exec( plc_sThread *tp, pwr_sClass_CompPID_Fo *object);
void CompOnOffBurnerFo_exec( plc_sThread *tp, pwr_sClass_CompOnOffBurnerFo *object);
void CompOnOffBurnerFo_init( pwr_sClass_CompOnOffBurnerFo *object);
void CompOnOffZoneFo_exec( plc_sThread *tp, pwr_sClass_CompOnOffZoneFo *object);
void CompOnOffZoneFo_init( pwr_sClass_CompOnOffZoneFo *object);
#endif
Volume BaseComponent $ClassVolume 0.0.0.10
Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X11660"
Attr NextOix = "_X11664"
Attr NextCix = "_X199"
Attr NextTix[0] = "_X18"
EndBody
......@@ -152528,7 +152528,7 @@ Fc PPO5 Motor Aggregate
Object RtBody $ObjBodyDef 1 13-MAR-2008 14:07:37.80
Body SysBody 13-MAR-2008 14:08:17.06
Attr StructName = "BaseFcPPO3Fo"
Attr NextAix = "_X38"
Attr NextAix = "_X39"
EndBody
!/**
! Input for power on. When PowerOn is set the converter should
......@@ -152610,6 +152610,14 @@ Fc PPO5 Motor Aggregate
Attr GraphName = "eno"
EndBody
EndObject
Object SupDisabled $Input 38 23-MAY-2012 10:52:57.33
Body SysBody 23-MAY-2012 09:40:17.10
Attr PgmName = "SupDisabled"
Attr Flags = 8192
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "dis"
EndBody
EndObject
!/**
! @Summary The main object connected to this function object.
! The main object connected to this object.
......@@ -152657,9 +152665,9 @@ Fc PPO5 Motor Aggregate
EndObject
EndObject
Object GraphPlcNode $GraphPlcNode 9749 13-MAR-2008 14:07:37.80
Body SysBody 19-MAR-2010 12:47:13.63
Body SysBody 23-MAY-2012 11:04:08.50
Attr object_type = 11
Attr parameters[0] = 6
Attr parameters[0] = 7
Attr parameters[1] = 1
Attr parameters[2] = 2
Attr parameters[3] = 0
......@@ -152691,7 +152699,7 @@ Fc PPO5 Motor Aggregate
Object Code PlcTemplate 9752 13-MAR-2008 14:07:37.80
Body RtBody 13-MAR-2008 14:07:37.80
EndBody
Body DevBody 25-NOV-2010 16:33:01.39
Body DevBody 23-MAY-2012 09:47:31.58
Buffer PlcProgram
Attr oid = "BaseComponent:Class-BaseFcPPO3Fo-Code"
Attr cid = "pwrb:Class-PlcTemplate"
......@@ -152705,7 +152713,7 @@ Fc PPO5 Motor Aggregate
Attr defnamecount[99] = 6
Attr defnamecount[102] = 1
Attr defnamecount[136] = 1
Attr defnamecount[137] = 15
Attr defnamecount[137] = 16
Attr defnamecount[138] = 2
Attr defnamecount[139] = 13
Attr defnamecount[140] = 9
......@@ -152715,7 +152723,7 @@ Fc PPO5 Motor Aggregate
Attr defnamecount[252] = 6
Attr defnamecount[253] = 2
Attr defnamecount[255] = 28
Attr defnamecount[256] = 33
Attr defnamecount[256] = 34
Attr defnamecount[258] = 4
Attr defnamecount[259] = 1
Attr defnamecount[263] = 6
......@@ -152724,14 +152732,14 @@ Fc PPO5 Motor Aggregate
Attr defnamecount[266] = 2
Attr defnamecount[267] = 1
Attr defnamecount[271] = 5
Attr connamecount = 250
Attr connamecount = 252
EndBuffer
EndBody
Object W WindowPlc 9753 13-MAR-2008 14:07:37.80
Body RtBody 13-MAR-2008 14:07:37.80
EndBody
Body DevBody 25-NOV-2010 16:33:01.39
Attr Modified = "25-NOV-2010 16:33:01.39"
Body DevBody 23-MAY-2012 09:47:31.58
Attr Modified = "23-MAY-2012 09:47:31.58"
Buffer PlcWindow
Attr oid = "BaseComponent:Class-BaseFcPPO3Fo-Code-W"
Attr cid = "pwrb:Class-WindowPlc"
......@@ -152741,6 +152749,49 @@ Fc PPO5 Motor Aggregate
Attr refconcount = 1
EndBuffer
EndBody
Object cn251 ConDigital 11664 23-MAY-2012 09:46:49.09
Body DevBody 23-MAY-2012 09:47:31.58
Buffer PlcConnection
Attr oid = "BaseComponent:Class-BaseFcPPO3Fo-Code-W-cn251"
Attr object_type = 23
Attr cid = "pwrb:Class-ConDigital"
Attr attributes = 90
Attr source_point = 2
Attr source_oid = "BaseComponent:Class-BaseFcPPO3Fo-Code-W-AlarmOk"
Attr dest_oid = "BaseComponent:Class-BaseFcPPO3Fo-Code-W-GetDp33"
Attr point_count = 2
Buffer point[0]
Attr x = 1.239778e+00
Attr y = 4.600000e+00
EndBuffer
Buffer point[1]
Attr x = 2.670000e+00
Attr y = 4.600000e+00
EndBuffer
Buffer point[2]
Attr x = 1.376611e+00
Attr y = 4.700000e+00
EndBuffer
Buffer point[3]
Attr x = 1.239778e+00
Attr y = 4.700000e+00
EndBuffer
Buffer point[4]
EndBuffer
Buffer point[5]
EndBuffer
Buffer point[6]
EndBuffer
Buffer point[7]
EndBuffer
Buffer point[8]
EndBuffer
Buffer point[9]
EndBuffer
Attr woid = "BaseComponent:Class-BaseFcPPO3Fo-Code-W"
EndBuffer
EndBody
EndObject
Object cn249 ConAnalog 11635 25-NOV-2010 16:32:48.79
Body DevBody 25-NOV-2010 16:33:01.39
Buffer PlcConnection
......@@ -154362,13 +154413,13 @@ Fc PPO5 Motor Aggregate
EndBody
EndObject
Object cn110 ConDigital 9799 13-MAR-2008 14:07:37.80
Body DevBody 19-MAR-2010 15:45:11.39
Body DevBody 23-MAY-2012 09:46:53.88
Buffer PlcConnection
Attr oid = "BaseComponent:Class-BaseFcPPO3Fo-Code-W-cn110"
Attr object_type = 23
Attr cid = "pwrb:Class-ConDigital"
Attr attributes = 90
Attr source_point = 2
Attr source_point = 3
Attr source_oid = "BaseComponent:Class-BaseFcPPO3Fo-Code-W-AlarmOk"
Attr dest_oid = "BaseComponent:Class-BaseFcPPO3Fo-Code-W-StoDp18"
Attr point_count = 2
......@@ -157041,18 +157092,19 @@ Yellow = Warning"
Object AlarmOk And 9908 13-MAR-2008 14:07:37.80
Body RtBody 13-MAR-2008 14:07:37.80
EndBody
Body DevBody 19-MAR-2010 15:45:11.39
Body DevBody 23-MAY-2012 09:46:53.88
Buffer PlcNode
Attr object_type = 90
Attr cid = "pwrb:Class-And"
Attr oid = "BaseComponent:Class-BaseFcPPO3Fo-Code-W-AlarmOk"
Attr x = 2.650000e+00
Attr y = -3.575000e+00
Attr y = -3.625000e+00
Attr width = 2.073333e-01
Attr heigth = 1.000000e-01
Attr heigth = 1.500000e-01
Attr woid = "BaseComponent:Class-BaseFcPPO3Fo-Code-W"
Attr mask[0] = 6
Attr mask[0] = 14
Attr mask[1] = 1
Attr mask[2] = 8
EndBuffer
EndBody
EndObject
......@@ -157890,6 +157942,24 @@ Yellow = Warning"
EndBuffer
EndBody
EndObject
Object GetDp33 GetDp 11663 23-MAY-2012 09:46:49.09
Body RtBody 23-MAY-2012 09:46:49.09
EndBody
Body DevBody 23-MAY-2012 09:47:31.58
Attr DpObject = "$PlcFo:BaseComponent-Class-BaseFcPPO3Fo.SupDisabled"
Buffer PlcNode
Attr object_type = 256
Attr cid = "pwrb:Class-GetDp"
Attr oid = "BaseComponent:Class-BaseFcPPO3Fo-Code-W-GetDp33"
Attr x = 8.500000e-01
Attr y = -3.625000e+00
Attr width = 3.897778e-01
Attr heigth = 5.000000e-02
Attr woid = "BaseComponent:Class-BaseFcPPO3Fo-Code-W"
Attr mask[1] = 1
EndBuffer
EndBody
EndObject
EndObject
EndObject
Object Template BaseFcPPO3Fo 2195685376 01-JAN-1970 01:00:00.00
This diff is collapsed.
......@@ -71,12 +71,12 @@ static pwr_tStatus IoCardInit (
io_sCard *cp
)
{
io_sCardLocal *local;
io_sCardLocalMsg *local;
pwr_sClass_Modbus_Module *op;
int i;
op = (pwr_sClass_Modbus_Module *) cp->op;
local = (io_sCardLocal *) cp->Local;
local = ((io_sCardLocal *) cp->Local)->msg;
for (i = 0; i < IO_MAXCHAN; i++) {
local->scancount[i] = 0;
......@@ -98,12 +98,12 @@ static pwr_tStatus IoCardRead (
io_sCard *cp
)
{
io_sCardLocal *local;
io_sCardLocalMsg *local;
pwr_sClass_Modbus_Module *op;
pwr_sClass_Modbus_TCP_Slave *slave;
op = (pwr_sClass_Modbus_Module *) cp->op;
local = (io_sCardLocal *) cp->Local;
local = ((io_sCardLocal *) cp->Local)->msg;
slave = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
if ( op->ScanInterval > 1) {
......@@ -118,7 +118,7 @@ static pwr_tStatus IoCardRead (
}
if (slave->Status == MB__NORMAL) {
io_bus_card_read(ctx, rp, cp, local->input_area, NULL, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
io_bus_card_read(ctx, rp, cp, slave->Inputs, NULL, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
}
// printf("Method Modbus_Module-IoCardRead\n");
return IO__SUCCESS;
......@@ -135,13 +135,13 @@ static pwr_tStatus IoCardWrite (
io_sCard *cp
)
{
io_sCardLocal *local;
io_sCardLocalMsg *local;
pwr_sClass_Modbus_Module *op;
pwr_sClass_Modbus_TCP_Slave *slave;
op = (pwr_sClass_Modbus_Module *) cp->op;
local = (io_sCardLocal *) cp->Local;
local = ((io_sCardLocal *) cp->Local)->msg;
slave = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
if ( op->ScanInterval > 1) {
......@@ -159,7 +159,7 @@ static pwr_tStatus IoCardWrite (
}
if (slave->Status == MB__NORMAL) {
io_bus_card_write(ctx, cp, local->output_area, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
io_bus_card_write(ctx, cp, slave->Outputs, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
}
// printf("Method Modbus_Module-IoCardWrite\n");
return IO__SUCCESS;
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA 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_locals.h"
/*----------------------------------------------------------------------------*\
Init method for the Modbus module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sCardLocal *local;
pwr_sClass_Modbus_ModuleReadWrite *op;
int i;
op = (pwr_sClass_Modbus_ModuleReadWrite *) cp->op;
local = (io_sCardLocal *) cp->Local;
for (i = 0; i < IO_MAXCHAN; i++) {
local->msg[0].scancount[i] = 0;
local->msg[1].scancount[i] = 0;
}
op->Read.Status = pwr_eModbusModule_StatusEnum_StatusUnknown;
op->Write.Status = pwr_eModbusModule_StatusEnum_StatusUnknown;
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Read method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sCardLocal *local;
pwr_sClass_Modbus_ModuleReadWrite *op;
pwr_sClass_Modbus_TCP_Slave *slave;
op = (pwr_sClass_Modbus_ModuleReadWrite *) cp->op;
local = (io_sCardLocal *) cp->Local;
slave = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
if ( op->Read.ScanInterval > 1) {
local->msg[0].has_read_method = 1;
if ( local->msg[0].interval_cnt != 0) {
local->msg[0].interval_cnt++;
if ( local->msg[0].interval_cnt >= op->Read.ScanInterval)
local->msg[0].interval_cnt = 0;
return IO__SUCCESS;
}
local->msg[0].interval_cnt++;
}
if (slave->Status == MB__NORMAL) {
io_bus_card_read(ctx, rp, cp, slave->Inputs, NULL, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
}
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Write method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sCardLocal *local;
pwr_sClass_Modbus_ModuleReadWrite *op;
pwr_sClass_Modbus_TCP_Slave *slave;
op = (pwr_sClass_Modbus_ModuleReadWrite *) cp->op;
local = (io_sCardLocal *) cp->Local;
slave = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
if ( op->Write.ScanInterval > 1) {
if ( !local->msg[1].has_read_method) {
if ( local->msg[1].interval_cnt != 0) {
local->msg[1].interval_cnt++;
if ( local->msg[1].interval_cnt >= op->Write.ScanInterval)
local->msg[1].interval_cnt = 0;
return IO__SUCCESS;
}
local->msg[1].interval_cnt++;
}
else if ( local->msg[1].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_Module-IoCardWrite\n");
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Modbus_ModuleReadWrite) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA 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
};
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA 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
};
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA 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
};
......@@ -852,26 +852,12 @@ static pwr_tStatus mb_init_channels( io_tCtx ctx, io_sAgent *ap, io_sRack *rp)
io_sServerModuleLocal *local_card;
io_sCard *cardp;
io_sServerLocal *local;
short input_counter;
short output_counter;
short card_input_counter;
short card_output_counter;
pwr_sClass_Modbus_TCP_Server *op;
pwr_sClass_Modbus_TCP_ServerModule *mp;
char name[196];
pwr_tStatus sts;
pwr_tCid cid;
io_sChannel *chanp;
int i, latent_input_counter, latent_output_counter;
pwr_tInt32 chan_size;
pwr_sClass_ChanDi *chan_di;
pwr_sClass_ChanDo *chan_do;
pwr_sClass_ChanAi *chan_ai;
pwr_sClass_ChanAit *chan_ait;
pwr_sClass_ChanIi *chan_ii;
pwr_sClass_ChanAo *chan_ao;
pwr_sClass_ChanIo *chan_io;
int i;
sts = gdh_ObjidToName(rp->Objid, (char *) &name, sizeof(name), cdh_mNName);
......@@ -885,169 +871,83 @@ static pwr_tStatus mb_init_channels( io_tCtx ctx, io_sAgent *ap, io_sRack *rp)
cardp = rp->cardlist;
input_counter = 0;
output_counter = 0;
card_input_counter = 0;
card_output_counter = 0;
latent_input_counter = 0;
latent_output_counter = 0;
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));
cardp->Local = local_card;
input_counter = input_counter + card_input_counter + latent_input_counter;
output_counter = output_counter + card_output_counter + latent_output_counter;
local_card->input_area = (void *) &(op->Inputs) + input_counter;
local_card->output_area = (void *) &(op->Outputs) + output_counter;
card_input_counter = 0;
card_output_counter = 0;
latent_input_counter = 0;
latent_output_counter = 0;
/* From v4.1.3 we can have subclasses, find the super class */
cid = cardp->Class;
while ( ODD( gdh_GetSuperClass( cid, &cid, cardp->Objid))) ;
switch (cid) {
case pwr_cClass_Modbus_TCP_ServerModule:
mp = (pwr_sClass_Modbus_TCP_ServerModule *) cardp->op;
mp->Status = pwr_eModbusModule_StatusEnum_StatusUnknown;
for (i = 0; i < cardp->ChanListSize; i++) {
chanp = &cardp->chanlist[i];
if ( is_diag( &chanp->ChanAref)) {
chanp->udata |= PB_UDATA_DIAG;
switch (chanp->ChanClass) {
case pwr_cClass_ChanIi:
chanp->offset = ((pwr_sClass_ChanIi *)chanp->cop)->Number;
chanp->size = GetChanSize( ((pwr_sClass_ChanIi *)chanp->cop)->Representation);
break;
default:
errh_Error( "Diagnostic channel class, card %s", cardp->Name);
}
continue;
}
if (chanp->ChanClass != pwr_cClass_ChanDi) {
card_input_counter += latent_input_counter;
latent_input_counter = 0;
}
local_card->input_area = (void *) &(op->Inputs) + input_area_offset +
input_area_chansize;
local_card->output_area = (void *) &(op->Outputs) + output_area_offset +
output_area_chansize;
if (chanp->ChanClass != pwr_cClass_ChanDo) {
card_output_counter += latent_output_counter;
latent_output_counter = 0;
}
switch (chanp->ChanClass) {
case pwr_cClass_ChanDi:
chan_di = (pwr_sClass_ChanDi *) chanp->cop;
if (chan_di->Number == 0) {
card_input_counter += latent_input_counter;
latent_input_counter = 0;
}
chanp->offset = card_input_counter;
chanp->mask = 1 << chan_di->Number;
if (chan_di->Representation == pwr_eDataRepEnum_Bit16)
chanp->mask = swap16(chanp->mask);
if (chan_di->Representation == pwr_eDataRepEnum_Bit32)
chanp->mask = swap32((unsigned short) chanp->mask);
if (chan_di->Number == 0) latent_input_counter = GetChanSize(chan_di->Representation);
if (local_card->di_size == 0)
local_card->di_offset = chanp->offset;
if (chan_di->Number == 0 || local_card->di_size == 0)
local_card->di_size += GetChanSize(chan_di->Representation);
// printf("Di channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_di->Number, chanp->offset);
break;
case pwr_cClass_ChanAi:
chan_ai = (pwr_sClass_ChanAi *) chanp->cop;
chanp->offset = card_input_counter;
chan_size = GetChanSize(chan_ai->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_input_counter += chan_size;
io_AiRangeToCoef(chanp);
// printf("Ai channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_ai->Number, chanp->offset);
break;
case pwr_cClass_ChanAit:
chan_ait = (pwr_sClass_ChanAit *) chanp->cop;
chanp->offset = card_input_counter;
chan_size = GetChanSize(chan_ait->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_input_counter += chan_size;
io_AiRangeToCoef(chanp);
break;
case pwr_cClass_ChanIi:
chan_ii = (pwr_sClass_ChanIi *) chanp->cop;
chanp->offset = card_input_counter;
chan_size = GetChanSize(chan_ii->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_input_counter += chan_size;
// printf("Ii channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_ii->Number, chanp->offset);
break;
case pwr_cClass_ChanDo:
chan_do = (pwr_sClass_ChanDo *) chanp->cop;
if (chan_do->Number == 0) {
card_output_counter += latent_output_counter;
latent_output_counter = 0;
}
chanp->offset = card_output_counter;
chan_size = GetChanSize(chan_do->Representation);
chanp->mask = 1 << chan_do->Number;
if (chan_do->Representation == pwr_eDataRepEnum_Bit16)
chanp->mask = swap16(chanp->mask);
if (chan_do->Representation == pwr_eDataRepEnum_Bit32)
chanp->mask = swap32((unsigned short) chanp->mask);
if (chan_do->Number == 0) latent_output_counter = GetChanSize(chan_do->Representation);
if (local_card->do_size == 0)
local_card->do_offset = chanp->offset;
if (chan_do->Number == 0 || local_card->do_size == 0)
local_card->do_size += GetChanSize(chan_do->Representation);
// printf("Do channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_do->Number, chanp->offset);
break;
case pwr_cClass_ChanAo:
chan_ao = (pwr_sClass_ChanAo *) chanp->cop;
chanp->offset = card_output_counter;
chan_size = GetChanSize(chan_ao->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_output_counter += chan_size;
io_AoRangeToCoef(chanp);
// printf("Ao channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_ao->Number, chanp->offset);
break;
case pwr_cClass_ChanIo:
chan_io = (pwr_sClass_ChanIo *) chanp->cop;
chanp->offset = card_output_counter;
chan_size = GetChanSize(chan_io->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_output_counter += chan_size;
// printf("Io channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_io->Number, chanp->offset);
break;
}
} /* End - for ... */
break;
} /* End - switch ... */
local_card->input_size = card_input_counter + latent_input_counter;
local_card->output_size = card_output_counter + latent_output_counter;
io_bus_card_init( ctx, cardp, &input_area_offset, &input_area_chansize,
&output_area_offset, &output_area_chansize,
pwr_eByteOrderingEnum_BigEndian);
for (i = 0; i < cardp->ChanListSize; i++) {
chanp = &cardp->chanlist[i];
switch (chanp->ChanClass) {
case pwr_cClass_ChanDi: {
pwr_sClass_ChanDi *chan_di = (pwr_sClass_ChanDi *) chanp->cop;
if (local_card->di_size == 0)
local_card->di_offset = chanp->offset;
if (chan_di->Number == 0 || local_card->di_size == 0)
local_card->di_size += GetChanSize(chan_di->Representation);
break;
}
case pwr_cClass_ChanDo: {
pwr_sClass_ChanDo *chan_do = (pwr_sClass_ChanDo *) chanp->cop;
if (local_card->do_size == 0)
local_card->do_offset = chanp->offset;
if (chan_do->Number == 0 || local_card->do_size == 0)
local_card->do_size += GetChanSize(chan_do->Representation);
break;
}
case pwr_cClass_ChanD: {
pwr_sClass_ChanD *chan_d = (pwr_sClass_ChanD *) chanp->cop;
if ( chan_d->Type == pwr_eDChanTypeEnum_Di) {
if (local_card->di_size == 0)
local_card->di_offset = chanp->offset;
if (chan_d->Number == 0 || local_card->di_size == 0)
local_card->di_size += GetChanSize(chan_d->Representation);
}
else {
if (local_card->do_size == 0)
local_card->do_offset = chanp->offset;
if (chan_d->Number == 0 || local_card->do_size == 0)
local_card->do_size += GetChanSize(chan_d->Representation);
}
break;
}
}
}
local_card->input_size = input_area_offset + input_area_chansize -
prev_input_area_offset;
local_card->output_size = output_area_offset + output_area_chansize -
prev_output_area_offset;
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_counter + card_input_counter + latent_input_counter;
local->output_size = output_counter + card_output_counter + latent_output_counter;
local->input_size = input_area_offset + input_area_chansize;
local->output_size = output_area_offset + output_area_chansize;
return IO__SUCCESS;
}
......
......@@ -112,6 +112,10 @@ typedef struct {
short int no_do;
int interval_cnt;
int has_read_method;
} io_sCardLocalMsg;
typedef struct {
io_sCardLocalMsg msg[2];
} io_sCardLocal;
typedef struct {
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA 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);
......@@ -46,3 +46,6 @@
120102 cs profinet Profinet, set correct status on profinet device when losing connection
120120 cs profinet Profinet, IO status wasn't set properly
120227 cs profinet Profinet configurator bugfix in submodule index
120608 rk profinet Profinet configurator bugfix in submodule index
120608 rk profinet Profinet configurator bugfix in module deletion
120608 rk profinet Profinet configurator, added flexibility when changeing device type keeping same gsdml-file
......@@ -241,6 +241,8 @@ void PnViewerPNAC::set_device_properties( unsigned char *macaddress, unsigned ch
sts = wait_service_con(local, 0);
}
sleep(3);
pack_set_ip_settings_req(&local->service_req_res, &dev_info);
sts = pnak_send_service_req_res(0, &local->service_req_res);
......
......@@ -1039,6 +1039,85 @@ void GsdmlAttrNav::device_changed_ok( void *ctx, void *data)
}
void GsdmlAttrNav::device_update_change( void *ctx)
{
GsdmlAttrNav *attrnav = (GsdmlAttrNav *)ctx;
// Get new item
attrnav->device_item = attrnav->gsdml->ApplicationProcess->DeviceAccessPointList->DeviceAccessPointItem[attrnav->device_num - 1];
gsdml_UseableModules *um = attrnav->device_item->UseableModules;
// Save the enum numbers for the slots
for ( unsigned int ii = 0; ii < attrnav->dev_data.slot_data.size(); ii++) {
if (ii == 0) {
attrnav->dev_data.slot_data[ii]->slot_reset();
attrnav->dev_data.slot_data[ii]->module_ident_number = attrnav->device_item->Body.ModuleIdentNumber;
continue;
}
if (attrnav->dev_data.slot_data[ii]->module_enum_number == 0) {
break;
}
for ( unsigned int jj = 0; jj < um->ModuleItemRef.size(); jj++) {
gsdml_ModuleItem *mi = (gsdml_ModuleItem *)um->ModuleItemRef[jj]->Body.ModuleItemTarget.p;
if (attrnav->dev_data.slot_data[ii]->module_ident_number == mi->Body.ModuleIdentNumber) {
attrnav->dev_data.slot_data[ii]->module_enum_number = jj + 1;
break;
}
}
}
}
pwr_tBoolean GsdmlAttrNav::device_check_change_ok( void *ctx)
{
GsdmlAttrNav *attrnav = (GsdmlAttrNav *)ctx;
pwr_tBoolean found, check_ok;
gsdml_UseableModules *um = attrnav->gsdml->ApplicationProcess->DeviceAccessPointList->DeviceAccessPointItem[attrnav->device_num - 1]->UseableModules;
check_ok = true;
for ( unsigned int ii = 0; ii < attrnav->dev_data.slot_data.size(); ii++) {
if (ii == 0) {
continue;
}
if (attrnav->dev_data.slot_data[ii]->module_enum_number == 0) {
break;
}
found = FALSE;
for ( unsigned int jj = 0; jj < um->ModuleItemRef.size(); jj++) {
if ( um->ModuleItemRef[jj]->Body.AllowedInSlots.list &&
um->ModuleItemRef[jj]->Body.AllowedInSlots.list->in_list(ii)) {
gsdml_ModuleItem *mi = (gsdml_ModuleItem *)um->
ModuleItemRef[jj]->Body.ModuleItemTarget.p;
if (attrnav->dev_data.slot_data[ii]->module_ident_number == mi->Body.ModuleIdentNumber) {
found = TRUE;
break;
}
}
}
if (!found) {
check_ok = FALSE;
break;
}
}
return check_ok;
}
void GsdmlAttrNav::device_changed_cancel( void *ctx, void *data)
{
long int old_device = (long int )data;
......@@ -1504,8 +1583,10 @@ int GsdmlAttrNav::save( const char *filename)
ModuleItemRef[dev_data.slot_data[i]->module_enum_number-1]->Body.ModuleItemTarget.p;
dev_data.slot_data[i]->module_ident_number = mi->Body.ModuleIdentNumber;
}
else
else {
dev_data.slot_data[i]->module_ident_number = 0;
dev_data.slot_data[i]->module_class = 0;
}
}
}
......@@ -1662,6 +1743,7 @@ int GsdmlAttrNav::save( const char *filename)
}
ssd->api = vsd->Body.API;
ssd->submodule_ident_number = vsd->Body.SubmoduleIdentNumber;
if ( !vsd->IOData)
continue;
......@@ -2127,13 +2209,19 @@ int ItemPnDevice::scan( GsdmlAttrNav *attrnav, void *p)
return 1;
}
else {
attrnav->wow->DisplayQuestion( attrnav, "Device Changed",
"All configuration data will be lost when changing the device.\n"
"Do you really want to change the device ?",
GsdmlAttrNav::device_changed_ok, GsdmlAttrNav::device_changed_cancel,
(void *)old_value);
attrnav->device_confirm_active = 1;
return 1;
if (GsdmlAttrNav::device_check_change_ok( attrnav)) {
GsdmlAttrNav::device_update_change(attrnav);
}
else {
attrnav->wow->DisplayQuestion( attrnav, "Device Changed",
"All configuration data will be lost when changing the device.\n"
"Do you really want to change the device ?",
GsdmlAttrNav::device_changed_ok, GsdmlAttrNav::device_changed_cancel,
(void *)old_value);
attrnav->device_confirm_active = 1;
return 1;
}
}
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Proview V3.4b (3.4.1-1)
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment