Commit 95b65cae authored by claes's avatar claes

Fixed evaluation of slave status

parent b6419c5c
/*
* Proview $Id: rt_io_m_pb_dp_slave.c,v 1.6 2007-01-12 13:28:31 claes Exp $
* Proview $Id: rt_io_m_pb_dp_slave.c,v 1.7 2007-04-30 09:41:31 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -335,32 +335,34 @@ static pwr_tStatus IoRackRead (
sp = (pwr_sClass_Pb_DP_Slave *) rp->op;
mp = (pwr_sClass_Pb_Profiboard *) ap->op;
if ((sp->Status == PB__NORMAL || sp->Status == PB__NOCONN) && mp->Status == PB__NORMAL && sp->DisableSlave != 1 && mp->DisableBus != 1) {
if (sp->Status == PB__NORMAL && mp->Status == PB__NORMAL && sp->DisableSlave != 1 && mp->DisableBus != 1) {
data_len = sp->BytesOfInput;
sts = profi_get_data(hDevice, ID_DP_SLAVE_IO_IMAGE, sp->OffsetInputs, &data_len, &sp->Inputs );
if ((sts != E_OK)) {
sp->Status = PB__NOCONN;
sp->ErrorCount++;
}
if (sp->DisableSlave != 1 && mp->DisableBus != 1) {
if (sp->Status == PB__NORMAL) {
sp->ErrorCount = 0;
}
else {
sp->Status = PB__NORMAL;
sp->ErrorCount = 0;
sp->ErrorCount++;
}
// Stall handling
if (sp->ErrorCount > sp->ErrorSoftLimit && 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;
}
}
else {
sp->ErrorCount = 0;
sp->Status = PB__DISABLED;
}
if (sp->DisableSlave == 1 || mp->DisableBus == 1) sp->Status = PB__DISABLED;
return IO__SUCCESS;
}
......
/*
* Proview $Id: rt_io_m_pb_profiboard.c,v 1.8 2007-02-07 14:43:49 claes Exp $
* Proview $Id: rt_io_m_pb_profiboard.c,v 1.9 2007-04-30 09:41:53 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -357,6 +357,30 @@ static void dp_get_slave_diag_con(T_DP_GET_SLAVE_DIAG_CON * get_slave_diag_con_p
memcpy(sp->Diag, diag_data_ptr + 1, MIN(get_slave_diag_con_ptr->diag_data_len - DP_MIN_SLAVE_DIAG_LEN, DP_MAX_EXT_DIAG_DATA_LEN));
/* Update slave status */
if (!(sp->StationStatus1 & ~pwr_mPbStationStatus1Mask_ExternalDiag) &&
!(sp->StationStatus2 & ~(pwr_mPbStationStatus2Mask_Default |
pwr_mPbStationStatus2Mask_ResponseMonitoringOn))) {
sp->Status = PB__NORMAL;
}
else if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_NonExistent) {
sp->Status = PB__NOCONN;
}
else if ((sp->StationStatus1 & (pwr_mPbStationStatus1Mask_ConfigFault |
pwr_mPbStationStatus1Mask_ParamFault)) ||
(sp->StationStatus2 & pwr_mPbStationStatus2Mask_NewParamsRequested)) {
sp->Status = PB__CONFIGERR;
}
else if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_MasterLock) {
sp->Status = PB__MASTERLOCK;
}
else //if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_NotReady)
{
sp->Status = PB__NOTREADY;
}
break;
}
......
/*
* Proview $Id: rt_io_m_siemens_diagrepeater.c,v 1.2 2007-04-27 13:42:45 claes Exp $
* Proview $Id: rt_io_m_siemens_diagrepeater.c,v 1.3 2007-04-30 09:40:30 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -60,9 +60,8 @@ static pwr_tStatus IoRackRead (
sp = (pwr_sClass_Siemens_DiagRepeater *) rp->op;
mp = (pwr_sClass_Pb_Profiboard *) ap->op;
if ((sp->Super.Status == PB__NORMAL || sp->Super.Status == PB__NOCONN) && mp->Status == PB__NORMAL && sp->Super.DisableSlave != 1 && mp->DisableBus != 1) {
if (mp->Status == PB__NORMAL && sp->Super.DisableSlave != 1 && mp->DisableBus != 1) {
sp->Super.Status = PB__NORMAL;
data_len = sp->Super.BytesOfDiag;
if (data_len > 0) {
......@@ -109,10 +108,29 @@ static pwr_tStatus IoRackRead (
} else {
memset(&sp->DP1, 0, sizeof(pwr_sClass_Siemens_DR_SegmStatus) * 4);
}
if (sp->Super.DisableSlave != 1 && mp->DisableBus != 1) {
if (sp->Super.DisableSlave == 1 || mp->DisableBus == 1) sp->Super.Status = PB__DISABLED;
if (sp->Super.Status == PB__NORMAL) {
sp->Super.ErrorCount = 0;
}
else {
sp->Super.ErrorCount++;
}
if (sp->Super.ErrorCount > sp->Super.ErrorSoftLimit && sp->Super.StallAction >= pwr_ePbStallAction_ResetInputs) {
memset(&sp->Super.Inputs, 0, sp->Super.BytesOfInput);
}
if (sp->Super.ErrorCount > sp->Super.ErrorHardLimit && sp->Super.StallAction >= pwr_ePbStallAction_EmergencyBreak) {
ctx->Node->EmergBreakTrue = 1;
}
}
else {
sp->Super.ErrorCount = 0;
sp->Super.Status = PB__DISABLED;
}
return IO__SUCCESS;
}
......
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