Commit 91002187 authored by Claes Sjofors's avatar Claes Sjofors

Profinet stall action added, and Profibus StartupTime to ignore errorcount at startup

parent 08f1360d
......@@ -109,6 +109,8 @@ static pwr_tStatus IoRackInit (
errh_Info( "Init of Profibus DP Slave and Modules %s", name);
op = (pwr_sClass_Pb_DP_Slave *) rp->op;
local->start_time = (int)(op->StartupTime / ctx->ScanTime);
// Do configuration check and initialize modules.
......@@ -329,10 +331,14 @@ static pwr_tStatus IoRackRead (
{
pwr_sClass_Pb_Profiboard *mp;
pwr_sClass_Pb_DP_Slave *sp;
io_sRackLocal *local = (io_sRackLocal *)rp->Local;
sp = (pwr_sClass_Pb_DP_Slave *) rp->op;
mp = (pwr_sClass_Pb_Profiboard *) ap->op;
if ( local->start_cnt < local->start_time)
local->start_cnt++;
/* The reading of the process image is now performed at the agent level,
this eliminates the need for board specific code at the rack level. */
......@@ -342,7 +348,8 @@ static pwr_tStatus IoRackRead (
sp->ErrorCount = 0;
}
else {
sp->ErrorCount++;
if ( local->start_cnt >= local->start_time)
sp->ErrorCount++;
}
if (sp->ErrorCount == sp->ErrorSoftLimit) {
......@@ -355,11 +362,11 @@ static pwr_tStatus IoRackRead (
ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref( rp->Objid);
}
if (sp->ErrorCount > sp->ErrorSoftLimit && sp->StallAction >= pwr_ePbStallAction_ResetInputs) {
if (sp->ErrorCount > sp->ErrorHardLimit && sp->StallAction == pwr_ePbStallAction_ResetInputs) {
memset(&sp->Inputs, 0, sp->BytesOfInput);
}
if (sp->ErrorCount > sp->ErrorHardLimit && sp->StallAction >= pwr_ePbStallAction_EmergencyBreak) {
if (sp->ErrorCount > sp->ErrorHardLimit && sp->StallAction == pwr_ePbStallAction_EmergencyBreak) {
ctx->Node->EmergBreakTrue = 1;
}
}
......
......@@ -55,6 +55,7 @@ static pwr_tStatus IoRackInit (
)
{
io_sPnCardLocal *local_card;
io_sPnRackLocal *local;
io_sCard *cardp;
short input_counter;
short output_counter;
......@@ -79,6 +80,9 @@ static pwr_tStatus IoRackInit (
errh_Info( "Init of Profinet Device and Modules %s", name);
op = (pwr_sClass_PnDevice *) rp->op;
local = (io_sPnRackLocal *) rp->Local;
local->start_time = (int)(op->StartupTime / ctx->ScanTime);
// Do configuration check and initialize modules.
......@@ -231,9 +235,11 @@ static pwr_tStatus IoRackRead (
io_sRack *rp
)
{
pwr_sClass_PnDevice *sp;
pwr_sClass_PnDevice *sp = (pwr_sClass_PnDevice *) rp->op;
io_sPnRackLocal *local = (io_sPnRackLocal *) rp->Local;
sp = (pwr_sClass_PnDevice *) rp->op;
if ( local->start_cnt < local->start_time)
local->start_cnt++;
/* The reading of the process image is now performed at the agent level,
this eliminates the need for board specific code at the rack level. */
......@@ -242,17 +248,30 @@ static pwr_tStatus IoRackRead (
sp->ErrorCount = 0;
}
else {
sp->ErrorCount++;
if ( local->start_cnt >= local->start_time)
sp->ErrorCount++;
}
if (sp->ErrorCount > sp->ErrorSoftLimit ) {
if ( ((io_sPnRackLocal *)(rp->Local))->bytes_of_input > 0)
memset(((io_sPnRackLocal *)(rp->Local))->inputs, 0, ((io_sPnRackLocal *)(rp->Local))->bytes_of_input);
if ( sp->ErrorCount == sp->ErrorHardLimit) {
errh_Error( "IO Error hard limit reached on card '%s', stall action %d", rp->Name, sp->StallAction);
ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref( rp->Objid);
sp->ErrorCount++;
}
else if (sp->ErrorCount == sp->ErrorSoftLimit) {
errh_Error( "IO Error soft limit reached on card '%s'", rp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref( rp->Objid);
sp->ErrorCount++;
}
if (sp->ErrorCount > sp->ErrorHardLimit) {
if ( sp->StallAction == pwr_ePbStallAction_ResetInputs) {
if ( ((io_sPnRackLocal *)(rp->Local))->bytes_of_input > 0)
memset(((io_sPnRackLocal *)(rp->Local))->inputs, 0, ((io_sPnRackLocal *)(rp->Local))->bytes_of_input);
}
else if (sp->StallAction == pwr_ePbStallAction_EmergencyBreak)
ctx->Node->EmergBreakTrue = 1;
}
// if (sp->ErrorCount > sp->ErrorHardLimit && sp->StallAction >= pwr_ePbStallAction_EmergencyBreak) {
// ctx->Node->EmergBreakTrue = 1;
// }
return IO__SUCCESS;
}
......@@ -267,13 +286,37 @@ static pwr_tStatus IoRackWrite (
io_sRack *rp
)
{
pwr_sClass_PnDevice *sp;
pwr_sClass_PnDevice *sp = (pwr_sClass_PnDevice *) rp->op;
io_sPnRackLocal *local = (io_sPnRackLocal *) rp->Local;
sp = (pwr_sClass_PnDevice *) rp->op;
/* The writing of the process image is now performed at the agent level,
this eliminates the need for board specific code at the rack level. */
if (sp->Status == PB__NORMAL) {
sp->ErrorCount = 0;
}
else {
if ( local->start_cnt >= local->start_time)
sp->ErrorCount++;
}
if ( sp->ErrorCount == sp->ErrorHardLimit) {
errh_Error( "IO Error hard limit reached on card '%s', stall action %d", rp->Name, sp->StallAction);
ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref( rp->Objid);
sp->ErrorCount++;
}
else if (sp->ErrorCount == sp->ErrorSoftLimit) {
errh_Error( "IO Error soft limit reached on card '%s'", rp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref( rp->Objid);
sp->ErrorCount++;
}
if (sp->ErrorCount > sp->ErrorHardLimit) {
if (sp->StallAction == pwr_ePbStallAction_EmergencyBreak)
ctx->Node->EmergBreakTrue = 1;
}
return IO__SUCCESS;
}
......
......@@ -76,6 +76,8 @@
typedef struct _io_sRackLocal {
unsigned char fdl;
unsigned char dp;
unsigned int start_time;
unsigned int start_cnt;
} io_sRackLocal;
......
......@@ -45,6 +45,8 @@ typedef struct _io_sPnRackLocal {
unsigned char *inputs;
unsigned char *outputs;
void *userdata;
unsigned int start_time;
unsigned int start_cnt;
} io_sPnRackLocal;
typedef struct _io_sPnCardLocal {
......
......@@ -1150,7 +1150,7 @@ Volume Profibus $ClassVolume 0.0.250.7
Object RtBody $ObjBodyDef 1 16-JAN-2006 09:46:40.50
Body SysBody 16-JAN-2006 09:46:40.50
Attr StructName = "Pb_DP_Slave"
Attr NextAix = "_X44"
Attr NextAix = "_X45"
EndBody
!/**
! Description of slave
......@@ -1425,6 +1425,13 @@ Volume Profibus $ClassVolume 0.0.250.7
Attr TypeRef = "pwrs:Type-$UInt8"
EndBody
EndObject
Object StartupTime $Attribute 44 22-FEB-2017 12:50:19.18
Body SysBody 22-FEB-2017 12:50:20.51
Attr PgmName = "StartupTime"
Attr Size = 4
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Length of the parameter data to be sent to the slave during initialization.
!*/
......@@ -1772,13 +1779,14 @@ Volume Profibus $ClassVolume 0.0.250.7
EndBody
EndObject
Object Template Pb_DP_Slave 2149285888 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00
Body RtBody 22-FEB-2017 12:49:46.90
Attr Process = 1
Attr StallAction = 1
Attr ErrorSoftLimit = 15
Attr ErrorHardLimit = 50
Attr WdFact1 = 10
Attr WdFact2 = 10
Attr StartupTime = 5.000000e+00
EndBody
EndObject
EndObject
......@@ -3427,7 +3435,7 @@ Volume Profibus $ClassVolume 0.0.250.7
Object RtBody $ObjBodyDef 1 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr StructName = "PnDevice"
Attr NextAix = "_X106"
Attr NextAix = "_X108"
EndBody
!/**
! Description.
......@@ -3506,6 +3514,20 @@ Volume Profibus $ClassVolume 0.0.250.7
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
Object StallAction $Attribute 106 22-FEB-2017 15:27:36.86
Body SysBody 22-FEB-2017 15:27:36.86
Attr PgmName = "StallAction"
Attr Size = 4
Attr TypeRef = "Profibus:Type-PbStallActionEnum"
EndBody
EndObject
Object StartupTime $Attribute 107 22-FEB-2017 16:11:42.18
Body SysBody 22-FEB-2017 16:11:42.18
Attr PgmName = "StartupTime"
Attr Size = 4
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! ErrorCount will increase every cycle if status is not PN__NORMAL.
!*/
......@@ -3798,8 +3820,10 @@ Volume Profibus $ClassVolume 0.0.250.7
EndBody
EndObject
Object Template PnDevice 2151907328 01-JAN-1970 01:00:00.00
Body RtBody 30-JUN-2010 11:04:35.19
Body RtBody 22-FEB-2017 16:12:07.73
Attr Process = 1
Attr StallAction = 1
Attr StartupTime = 5.000000e+00
Attr ErrorSoftLimit = 100
Attr ErrorHardLimit = 1000
EndBody
......@@ -3878,7 +3902,7 @@ Volume Profibus $ClassVolume 0.0.250.7
Object Slot $Attribute 22 09-DEC-2016 14:42:22.14
Body SysBody 09-DEC-2016 14:43:00.76
Attr PgmName = "Slot"
Attr Size = 40
Attr Size = 4
Attr Flags = 1024
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
......
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