Commit 60f6ed3d authored by Claes Sjöfors's avatar Claes Sjöfors

Profibus merged

parent b12b2d08
...@@ -831,7 +831,7 @@ typedef struct T_SET_CONFIGURATION_REQ ...@@ -831,7 +831,7 @@ typedef struct T_SET_CONFIGURATION_REQ
max_nr_of_sap_buffers; /* max # of SAP-Buffers (all CR) */ max_nr_of_sap_buffers; /* max # of SAP-Buffers (all CR) */
USIGN16 max_nr_of_poll_list_entries; /* max # of Poll-List-Entries USIGN16 max_nr_of_poll_list_entries; /* max # of Poll-List-Entries
(all CR) */ (all CR) */
USIGN16 max_data_buffer_size; /* max size of FMS-/FMA7-PDU-Buffer */ USIGN16 max_data_buffer_size; /* max size of FMS-/FMA7-PDU-Buffer */
} T_SET_CONFIGURATION_REQ; } T_SET_CONFIGURATION_REQ;
#endif #endif
......
...@@ -108,7 +108,7 @@ extern "C" { ...@@ -108,7 +108,7 @@ extern "C" {
#define MODE_MODUL_MCL 13 /* Command: B_SYSFKT */ #define MODE_MODUL_MCL 13 /* Command: B_SYSFKT */
#define MODE_DISTRIBUTOR_DRIVER \ #define MODE_DISTRIBUTOR_DRIVER \
14 /* Command: B_SYSFKT ->function 1 = insert \ 14 /* Command: B_SYSFKT ->function 1 = insert \
*/ */
#define MODE_PRINT_DRIVER 15 /* Command: B_SYSFKT */ #define MODE_PRINT_DRIVER 15 /* Command: B_SYSFKT */
#define MODE_GET_RCS_ERROR 16 /* Command: B_SYSFKT */ #define MODE_GET_RCS_ERROR 16 /* Command: B_SYSFKT */
......
This diff is collapsed.
...@@ -52,8 +52,8 @@ ...@@ -52,8 +52,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Ao Init method for the Pb module Ao
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Ao* op; pwr_sClass_Pb_Ao* op;
...@@ -63,20 +63,24 @@ static pwr_tStatus IoCardInit( ...@@ -63,20 +63,24 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Ao*)cp->op; op = (pwr_sClass_Pb_Ao*)cp->op;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
if (rp->Class != pwr_cClass_Pb_DP_Slave) { if (rp->Class != pwr_cClass_Pb_DP_Slave)
{
errh_Info("Illegal object type %s", cp->Name); errh_Info("Illegal object type %s", cp->Name);
return IO__SUCCESS; return IO__SUCCESS;
} }
if (op->Status >= PB_MODULE_STATE_OPERATE) { if (op->Status >= PB_MODULE_STATE_OPERATE)
{
// Calculate polycoeff // Calculate polycoeff
for (i = 0; i < cp->ChanListSize; i++) { for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i]; chanp = &cp->chanlist[i];
if (!chanp->cop) if (!chanp->cop)
continue; continue;
io_AoRangeToCoef(chanp); io_AoRangeToCoef(chanp);
} }
} else }
else
errh_Info("Error initializing Pb module Ao %s", cp->Name); errh_Info("Error initializing Pb module Ao %s", cp->Name);
return IO__SUCCESS; return IO__SUCCESS;
...@@ -85,8 +89,8 @@ static pwr_tStatus IoCardInit( ...@@ -85,8 +89,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Write method for the Pb module Ao Write method for the Pb module Ao
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite( static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Ao* op; pwr_sClass_Pb_Ao* op;
...@@ -109,10 +113,12 @@ static pwr_tStatus IoCardWrite( ...@@ -109,10 +113,12 @@ static pwr_tStatus IoCardWrite(
op = (pwr_sClass_Pb_Ao*)cp->op; op = (pwr_sClass_Pb_Ao*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op; slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) { if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
fixout = ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT; fixout = ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT;
for (i = 0; i < cp->ChanListSize; i++) { for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i]; chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop) if (!chanp->cop || !chanp->sop)
continue; continue;
...@@ -125,7 +131,8 @@ static pwr_tStatus IoCardWrite( ...@@ -125,7 +131,8 @@ static pwr_tStatus IoCardWrite(
value = cop->FixedOutValue; value = cop->FixedOutValue;
else if (cop->TestOn) else if (cop->TestOn)
value = cop->TestValue; value = cop->TestValue;
else { else
{
value = *(pwr_tFloat32*)chanp->vbp; value = *(pwr_tFloat32*)chanp->vbp;
} }
...@@ -152,50 +159,66 @@ static pwr_tStatus IoCardWrite( ...@@ -152,50 +159,66 @@ static pwr_tStatus IoCardWrite(
// Calculate signal value // Calculate signal value
sop->SigValue = cop->SigValPolyCoef1 * value + cop->SigValPolyCoef0; sop->SigValue = cop->SigValPolyCoef1 * value + cop->SigValPolyCoef0;
if (op->BytesPerChannel == 4) { if (op->BytesPerChannel == 4)
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata32 = (pwr_tUInt32)rawvalue; udata32 = (pwr_tUInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(udata32); udata32 = swap32(udata32);
memcpy(local->output_area + op->OffsetOutputs + 4 * i, &udata32, 4); memcpy(local->output_area + op->OffsetOutputs + 4 * i, &udata32, 4);
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data32 = (pwr_tInt32)rawvalue; data32 = (pwr_tInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32); data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 4 * i, &data32, 4); memcpy(local->output_area + op->OffsetOutputs + 4 * i, &data32, 4);
} }
}
} else if (op->BytesPerChannel == 3) { else if (op->BytesPerChannel == 3)
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata32 = (pwr_tUInt32)rawvalue; udata32 = (pwr_tUInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(udata32); udata32 = swap32(udata32);
memcpy(local->output_area + op->OffsetOutputs + 3 * i, &udata32, 3); memcpy(local->output_area + op->OffsetOutputs + 3 * i, &udata32, 3);
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data32 = (pwr_tInt32)rawvalue; data32 = (pwr_tInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32); data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 3 * i, &data32, 3); memcpy(local->output_area + op->OffsetOutputs + 3 * i, &data32, 3);
} }
}
} else if (op->BytesPerChannel == 2) { else if (op->BytesPerChannel == 2)
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata16 = (pwr_tUInt16)rawvalue; udata16 = (pwr_tUInt16)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata16 = swap16(udata16); udata16 = swap16(udata16);
memcpy(local->output_area + op->OffsetOutputs + 2 * i, &udata16, 2); memcpy(local->output_area + op->OffsetOutputs + 2 * i, &udata16, 2);
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data16 = (pwr_tInt16)rawvalue; data16 = (pwr_tInt16)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data16 = swap16(data16); data16 = swap16(data16);
memcpy(local->output_area + op->OffsetOutputs + 2 * i, &data16, 2); memcpy(local->output_area + op->OffsetOutputs + 2 * i, &data16, 2);
} }
}
} else if (op->BytesPerChannel == 1) { else if (op->BytesPerChannel == 1)
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata8 = (pwr_tUInt8)rawvalue; udata8 = (pwr_tUInt8)rawvalue;
memcpy(local->output_area + op->OffsetOutputs + i, &udata8, 1); memcpy(local->output_area + op->OffsetOutputs + i, &udata8, 1);
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data8 = (pwr_tInt8)rawvalue; data8 = (pwr_tInt8)rawvalue;
memcpy(local->output_area + op->OffsetOutputs + i, &data8, 1); memcpy(local->output_area + op->OffsetOutputs + i, &data8, 1);
} }
...@@ -209,8 +232,8 @@ static pwr_tStatus IoCardWrite( ...@@ -209,8 +232,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -224,6 +247,6 @@ static pwr_tStatus IoCardClose( ...@@ -224,6 +247,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Ao) pwr_dExport pwr_BindIoMethods(Pb_Ao) = {
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod }; pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
...@@ -54,8 +54,8 @@ ...@@ -54,8 +54,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Move di data word to valuebase. Move di data word to valuebase.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
void pbio_DiUnpackWord( void pbio_DiUnpackWord(io_sCard* cp, pwr_tUInt16 data, pwr_tUInt16 mask,
io_sCard* cp, pwr_tUInt16 data, pwr_tUInt16 mask, int index) int index)
{ {
io_sChannel* chanp; io_sChannel* chanp;
...@@ -64,7 +64,8 @@ void pbio_DiUnpackWord( ...@@ -64,7 +64,8 @@ void pbio_DiUnpackWord(
else else
chanp = &cp->chanlist[16]; chanp = &cp->chanlist[16];
if (mask == IO_CONVMASK_ALL) { if (mask == IO_CONVMASK_ALL)
{
/* No conversion test */ /* No conversion test */
if (chanp->cop && chanp->sop) if (chanp->cop && chanp->sop)
*(pwr_tUInt16*)(chanp->vbp) = ((data & 1) != 0); *(pwr_tUInt16*)(chanp->vbp) = ((data & 1) != 0);
...@@ -114,7 +115,9 @@ void pbio_DiUnpackWord( ...@@ -114,7 +115,9 @@ void pbio_DiUnpackWord(
if (chanp->cop && chanp->sop) if (chanp->cop && chanp->sop)
*(pwr_tUInt16*)(chanp->vbp) = ((data & 32768) != 0); *(pwr_tUInt16*)(chanp->vbp) = ((data & 32768) != 0);
chanp++; chanp++;
} else { }
else
{
if (chanp->cop && chanp->sop && mask & 1) if (chanp->cop && chanp->sop && mask & 1)
*(pwr_tUInt16*)(chanp->vbp) = ((data & 1) != 0); *(pwr_tUInt16*)(chanp->vbp) = ((data & 1) != 0);
chanp++; chanp++;
...@@ -169,8 +172,8 @@ void pbio_DiUnpackWord( ...@@ -169,8 +172,8 @@ void pbio_DiUnpackWord(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Di Init method for the Pb module Di
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Di* op; pwr_sClass_Pb_Di* op;
...@@ -180,8 +183,8 @@ static pwr_tStatus IoCardInit( ...@@ -180,8 +183,8 @@ static pwr_tStatus IoCardInit(
// Check configuration // Check configuration
if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16 if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16 &&
&& op->NumberOfChannels != 32) op->NumberOfChannels != 32)
op->Status = PB_MODULE_STATE_NOTINIT; op->Status = PB_MODULE_STATE_NOTINIT;
if (op->Orientation > op->NumberOfChannels) if (op->Orientation > op->NumberOfChannels)
...@@ -196,8 +199,8 @@ static pwr_tStatus IoCardInit( ...@@ -196,8 +199,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Read method for the Pb module Di Read method for the Pb module Di
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead( static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Di* op; pwr_sClass_Pb_Di* op;
...@@ -208,22 +211,27 @@ static pwr_tStatus IoCardRead( ...@@ -208,22 +211,27 @@ static pwr_tStatus IoCardRead(
pwr_sClass_Di* sig_di; pwr_sClass_Di* sig_di;
pwr_tUInt32 mask = 0; pwr_tUInt32 mask = 0;
pwr_tUInt16 data[2] = { 0, 0 }; pwr_tUInt16 data[2] = {0, 0};
pwr_tUInt32* data32; pwr_tUInt32* data32;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
op = (pwr_sClass_Pb_Di*)cp->op; op = (pwr_sClass_Pb_Di*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op; slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) { if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
memcpy(&data, local->input_area + op->OffsetInputs, op->BytesOfInput); memcpy(&data, local->input_area + op->OffsetInputs, op->BytesOfInput);
data32 = (pwr_tUInt32*)&data; data32 = (pwr_tUInt32*)&data;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) { if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (op->Orientation == PB_ORIENTATION_WORD) { {
if (op->Orientation == PB_ORIENTATION_WORD)
{
data[0] = swap16(data[0]); data[0] = swap16(data[0]);
data[1] = swap16(data[1]); data[1] = swap16(data[1]);
} else if (op->Orientation == PB_ORIENTATION_DWORD) { }
else if (op->Orientation == PB_ORIENTATION_DWORD)
{
*data32 = swap32(*data32); *data32 = swap32(*data32);
} }
} }
...@@ -233,11 +241,13 @@ static pwr_tStatus IoCardRead( ...@@ -233,11 +241,13 @@ static pwr_tStatus IoCardRead(
data[1] = data[1] ^ op->InvMask2; data[1] = data[1] ^ op->InvMask2;
// Packa upp // Packa upp
for (i = 0; i < cp->ChanListSize; i++) { for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i]; chanp = &cp->chanlist[i];
chan_di = (pwr_sClass_ChanDi*)chanp->cop; chan_di = (pwr_sClass_ChanDi*)chanp->cop;
sig_di = (pwr_sClass_Di*)chanp->sop; sig_di = (pwr_sClass_Di*)chanp->sop;
if (chan_di && sig_di) { if (chan_di && sig_di)
{
mask = 1 << chan_di->Number; mask = 1 << chan_di->Number;
*(pwr_tUInt16*)(chanp->vbp) = ((*data32 & mask) != 0); *(pwr_tUInt16*)(chanp->vbp) = ((*data32 & mask) != 0);
} }
...@@ -258,8 +268,8 @@ static pwr_tStatus IoCardRead( ...@@ -258,8 +268,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -273,5 +283,6 @@ static pwr_tStatus IoCardClose( ...@@ -273,5 +283,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Di) = { pwr_BindIoMethod(IoCardInit), pwr_dExport pwr_BindIoMethods(Pb_Di) = {
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardClose), pwr_NullMethod }; pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
...@@ -52,8 +52,8 @@ ...@@ -52,8 +52,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Do Init method for the Pb module Do
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Do* op; pwr_sClass_Pb_Do* op;
...@@ -61,8 +61,8 @@ static pwr_tStatus IoCardInit( ...@@ -61,8 +61,8 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Do*)cp->op; op = (pwr_sClass_Pb_Do*)cp->op;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16 if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16 &&
&& op->NumberOfChannels != 32) op->NumberOfChannels != 32)
op->Status = PB_MODULE_STATE_NOTINIT; op->Status = PB_MODULE_STATE_NOTINIT;
if (op->Orientation > op->NumberOfChannels) if (op->Orientation > op->NumberOfChannels)
...@@ -77,8 +77,8 @@ static pwr_tStatus IoCardInit( ...@@ -77,8 +77,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Write method for the Pb module Do Write method for the Pb module Do
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite( static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Do* op; pwr_sClass_Pb_Do* op;
...@@ -90,22 +90,25 @@ static pwr_tStatus IoCardWrite( ...@@ -90,22 +90,25 @@ static pwr_tStatus IoCardWrite(
pwr_tUInt32 mask = 0; pwr_tUInt32 mask = 0;
pwr_tInt32 do_actval; pwr_tInt32 do_actval;
pwr_tUInt16 data[2] = { 0, 0 }; pwr_tUInt16 data[2] = {0, 0};
pwr_tUInt32* data32; pwr_tUInt32* data32;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
op = (pwr_sClass_Pb_Do*)cp->op; op = (pwr_sClass_Pb_Do*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op; slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) { if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
data32 = (pwr_tUInt32*)&data; data32 = (pwr_tUInt32*)&data;
// Packa ner // Packa ner
for (i = 0; i < cp->ChanListSize; i++) { for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i]; chanp = &cp->chanlist[i];
chan_do = (pwr_sClass_ChanDo*)chanp->cop; chan_do = (pwr_sClass_ChanDo*)chanp->cop;
sig_do = (pwr_sClass_Do*)chanp->sop; sig_do = (pwr_sClass_Do*)chanp->sop;
if (chan_do && sig_do) { if (chan_do && sig_do)
{
mask = 1 << chan_do->Number; mask = 1 << chan_do->Number;
do_actval = *(pwr_tInt32*)chanp->vbp; do_actval = *(pwr_tInt32*)chanp->vbp;
if (do_actval != 0) if (do_actval != 0)
...@@ -118,11 +121,15 @@ static pwr_tStatus IoCardWrite( ...@@ -118,11 +121,15 @@ static pwr_tStatus IoCardWrite(
io_DoPackWord(cp, &data[0], 0); io_DoPackWord(cp, &data[0], 0);
if (op->NumberOfChannels > 16) io_DoPackWord(cp, &data[1], 1); if (op->NumberOfChannels > 16) io_DoPackWord(cp, &data[1], 1);
*/ */
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) { if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (op->Orientation == PB_ORIENTATION_WORD) { {
if (op->Orientation == PB_ORIENTATION_WORD)
{
data[0] = swap16(data[0]); data[0] = swap16(data[0]);
data[1] = swap16(data[1]); data[1] = swap16(data[1]);
} else if (op->Orientation == PB_ORIENTATION_DWORD) { }
else if (op->Orientation == PB_ORIENTATION_DWORD)
{
*data32 = swap32(*data32); *data32 = swap32(*data32);
} }
} }
...@@ -135,8 +142,8 @@ static pwr_tStatus IoCardWrite( ...@@ -135,8 +142,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -150,6 +157,6 @@ static pwr_tStatus IoCardClose( ...@@ -150,6 +157,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Do) pwr_dExport pwr_BindIoMethods(Pb_Do) = {
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod }; pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
...@@ -112,7 +112,8 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -112,7 +112,8 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
latent_input_count = 0; latent_input_count = 0;
latent_output_count = 0; latent_output_count = 0;
while (cardp) { while (cardp)
{
local_card = calloc(1, sizeof(*local_card)); local_card = calloc(1, sizeof(*local_card));
cardp->Local = local_card; cardp->Local = local_card;
local_card->input_area = (void*)&(op->Inputs); local_card->input_area = (void*)&(op->Inputs);
...@@ -124,7 +125,8 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -124,7 +125,8 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
while (ODD(gdh_GetSuperClass(cid, &cid, cardp->Objid))) while (ODD(gdh_GetSuperClass(cid, &cid, cardp->Objid)))
; ;
switch (cid) { switch (cid)
{
/* Old style configuring with Pb_xx objects. Still here for combatibility /* Old style configuring with Pb_xx objects. Still here for combatibility
reasons. reasons.
New systems (from v4.1.3) should be build with Pb_Module objects or New systems (from v4.1.3) should be build with Pb_Module objects or
...@@ -186,16 +188,19 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -186,16 +188,19 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
mp = (pwr_sClass_Pb_Module*)cardp->op; mp = (pwr_sClass_Pb_Module*)cardp->op;
mp->Status = PB__INITFAIL; mp->Status = PB__INITFAIL;
cardp->offset = 0; cardp->offset = 0;
for (i = 0; i < cardp->ChanListSize; i++) { for (i = 0; i < cardp->ChanListSize; i++)
{
chanp = &cardp->chanlist[i]; chanp = &cardp->chanlist[i];
if (is_diag(&chanp->ChanAref)) { if (is_diag(&chanp->ChanAref))
{
chanp->udata |= PB_UDATA_DIAG; chanp->udata |= PB_UDATA_DIAG;
switch (chanp->ChanClass) { switch (chanp->ChanClass)
{
case pwr_cClass_ChanIi: case pwr_cClass_ChanIi:
chanp->offset = ((pwr_sClass_ChanIi*)chanp->cop)->Number; chanp->offset = ((pwr_sClass_ChanIi*)chanp->cop)->Number;
chanp->size chanp->size =
= GetChanSize(((pwr_sClass_ChanIi*)chanp->cop)->Representation); GetChanSize(((pwr_sClass_ChanIi*)chanp->cop)->Representation);
break; break;
default: default:
errh_Error("Diagnostic channel class, card %s", cardp->Name); errh_Error("Diagnostic channel class, card %s", cardp->Name);
...@@ -203,30 +208,34 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -203,30 +208,34 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
continue; continue;
} }
if (chanp->ChanClass != pwr_cClass_ChanDi) { if (chanp->ChanClass != pwr_cClass_ChanDi)
{
input_counter += latent_input_count; input_counter += latent_input_count;
latent_input_count = 0; latent_input_count = 0;
} }
if (chanp->ChanClass != pwr_cClass_ChanDo) { if (chanp->ChanClass != pwr_cClass_ChanDo)
{
output_counter += latent_output_count; output_counter += latent_output_count;
latent_output_count = 0; latent_output_count = 0;
} }
switch (chanp->ChanClass) { switch (chanp->ChanClass)
{
case pwr_cClass_ChanDi: case pwr_cClass_ChanDi:
chan_di = (pwr_sClass_ChanDi*)chanp->cop; chan_di = (pwr_sClass_ChanDi*)chanp->cop;
if (chan_di->Number == 0) { if (chan_di->Number == 0)
{
input_counter += latent_input_count; input_counter += latent_input_count;
latent_input_count = 0; latent_input_count = 0;
} }
chanp->offset = input_counter; chanp->offset = input_counter;
chanp->mask = 1 << chan_di->Number; chanp->mask = 1 << chan_di->Number;
if (chan_di->Representation == pwr_eDataRepEnum_Bit16 if (chan_di->Representation == pwr_eDataRepEnum_Bit16 &&
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap16(chanp->mask); chanp->mask = swap16(chanp->mask);
if (chan_di->Representation == pwr_eDataRepEnum_Bit32 if (chan_di->Representation == pwr_eDataRepEnum_Bit32 &&
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap32(chanp->mask); chanp->mask = swap32(chanp->mask);
if (chan_di->Number == 0) if (chan_di->Number == 0)
latent_input_count = GetChanSize(chan_di->Representation); latent_input_count = GetChanSize(chan_di->Representation);
...@@ -269,18 +278,19 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -269,18 +278,19 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
case pwr_cClass_ChanDo: case pwr_cClass_ChanDo:
chan_do = (pwr_sClass_ChanDo*)chanp->cop; chan_do = (pwr_sClass_ChanDo*)chanp->cop;
if (chan_do->Number == 0) { if (chan_do->Number == 0)
{
output_counter += latent_output_count; output_counter += latent_output_count;
latent_output_count = 0; latent_output_count = 0;
} }
chanp->offset = output_counter; chanp->offset = output_counter;
chan_size = GetChanSize(chan_do->Representation); chan_size = GetChanSize(chan_do->Representation);
chanp->mask = 1 << chan_do->Number; chanp->mask = 1 << chan_do->Number;
if (chan_do->Representation == pwr_eDataRepEnum_Bit16 if (chan_do->Representation == pwr_eDataRepEnum_Bit16 &&
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap16(chanp->mask); chanp->mask = swap16(chanp->mask);
if (chan_do->Representation == pwr_eDataRepEnum_Bit32 if (chan_do->Representation == pwr_eDataRepEnum_Bit32 &&
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap32(chanp->mask); chanp->mask = swap32(chanp->mask);
if (chan_do->Number == 0) if (chan_do->Number == 0)
latent_output_count = GetChanSize(chan_do->Representation); latent_output_count = GetChanSize(chan_do->Representation);
...@@ -342,35 +352,45 @@ static pwr_tStatus IoRackRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -342,35 +352,45 @@ static pwr_tStatus IoRackRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
/* The reading of the process image is now performed at the agent level, /* 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. */ this eliminates the need for board specific code at the rack level. */
if (sp->DisableSlave != 1 && mp->DisableBus != 1) { if (sp->DisableSlave != 1 && mp->DisableBus != 1)
if (sp->Status == PB__NORMAL) { {
if (sp->Status == PB__NORMAL)
{
sp->ErrorCount = 0; sp->ErrorCount = 0;
} else { }
else
{
if (local->start_cnt >= local->start_time) if (local->start_cnt >= local->start_time)
sp->ErrorCount++; sp->ErrorCount++;
} }
if (sp->ErrorCount == sp->ErrorSoftLimit) { if (sp->ErrorCount == sp->ErrorSoftLimit)
{
errh_Error("IO Error soft limit reached on card '%s'", rp->Name); errh_Error("IO Error soft limit reached on card '%s'", rp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1; ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(rp->Objid); ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(rp->Objid);
} }
if (sp->ErrorCount == sp->ErrorHardLimit) { if (sp->ErrorCount == sp->ErrorHardLimit)
{
errh_Error("IO Error hard limit reached on card '%s', stall action %d", errh_Error("IO Error hard limit reached on card '%s', stall action %d",
rp->Name, sp->StallAction); rp->Name, sp->StallAction);
ctx->IOHandler->CardErrorHardLimit = 1; ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(rp->Objid); ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(rp->Objid);
} }
if (sp->ErrorCount > sp->ErrorHardLimit if (sp->ErrorCount > sp->ErrorHardLimit &&
&& sp->StallAction == pwr_ePbStallAction_ResetInputs) { sp->StallAction == pwr_ePbStallAction_ResetInputs)
{
memset(&sp->Inputs, 0, sp->BytesOfInput); memset(&sp->Inputs, 0, sp->BytesOfInput);
} }
if (sp->ErrorCount > sp->ErrorHardLimit if (sp->ErrorCount > sp->ErrorHardLimit &&
&& sp->StallAction == pwr_ePbStallAction_EmergencyBreak) { sp->StallAction == pwr_ePbStallAction_EmergencyBreak)
{
ctx->Node->EmergBreakTrue = 1; ctx->Node->EmergBreakTrue = 1;
} }
} else { }
else
{
sp->ErrorCount = 0; sp->ErrorCount = 0;
sp->Status = PB__DISABLED; sp->Status = PB__DISABLED;
} }
...@@ -410,6 +430,7 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -410,6 +430,7 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_DP_Slave) = { pwr_BindIoMethod(IoRackInit), pwr_dExport pwr_BindIoMethods(Pb_DP_Slave) = {
pwr_BindIoMethod(IoRackRead), pwr_BindIoMethod(IoRackWrite), pwr_BindIoMethod(IoRackInit), pwr_BindIoMethod(IoRackRead),
pwr_BindIoMethod(IoRackClose), pwr_NullMethod }; pwr_BindIoMethod(IoRackWrite), pwr_BindIoMethod(IoRackClose),
pwr_NullMethod};
...@@ -65,8 +65,9 @@ ...@@ -65,8 +65,9 @@
static unsigned char req_res_buffer[512]; static unsigned char req_res_buffer[512];
static short fdlif_sda_sdn_sdr_req(io_sAgentLocal* local_agent, static short fdlif_sda_sdn_sdr_req(io_sAgentLocal* local_agent,
pwr_sClass_Pb_FDL_SAP* sap, pwr_sClass_Pb_FDL_DataTransfer* op, pwr_sClass_Pb_FDL_SAP* sap,
io_sFDLCardLocal* local) pwr_sClass_Pb_FDL_DataTransfer* op,
io_sFDLCardLocal* local)
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION FUNCTIONAL_DESCRIPTION
...@@ -106,16 +107,20 @@ possible return values: ...@@ -106,16 +107,20 @@ possible return values:
*/ */
sdb.comm_ref = 0; sdb.comm_ref = 0;
sdb.layer = FDLIF; sdb.layer = FDLIF;
switch (op->Type) { switch (op->Type)
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDA: { {
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDA:
{
sdb.service = FDLIF_SDA; sdb.service = FDLIF_SDA;
break; break;
} }
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDN: { case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDN:
{
sdb.service = FDLIF_SDN; sdb.service = FDLIF_SDN;
break; break;
} }
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SRD: { case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SRD:
{
sdb.service = FDLIF_SRD; sdb.service = FDLIF_SRD;
break; break;
} }
...@@ -128,15 +133,17 @@ possible return values: ...@@ -128,15 +133,17 @@ possible return values:
sdb.invoke_id = local->invoke_id = local_agent->invoke_id; sdb.invoke_id = local->invoke_id = local_agent->invoke_id;
local_agent->invoke_id = (local_agent->invoke_id + 1) % 128; local_agent->invoke_id = (local_agent->invoke_id + 1) % 128;
result = profi_snd_req_res( // result = profi_snd_req_res(
(T_PROFI_DEVICE_HANDLE*)local_agent, &sdb, (void*)req, PB_FALSE); // (T_PROFI_DEVICE_HANDLE*)local_agent, &sdb, (void*)req, PB_FALSE);
result = profi_snd_req_res(&sdb, (void*)req, PB_FALSE);
return ((pwr_tBoolean)(result == E_OK)); return ((pwr_tBoolean)(result == E_OK));
} }
static short fdlif_reply_update_mult_req(io_sAgentLocal* local_agent, static short fdlif_reply_update_mult_req(io_sAgentLocal* local_agent,
pwr_sClass_Pb_FDL_SAP* sap, pwr_sClass_Pb_FDL_DataTransfer* op, pwr_sClass_Pb_FDL_SAP* sap,
io_sFDLCardLocal* local) pwr_sClass_Pb_FDL_DataTransfer* op,
io_sFDLCardLocal* local)
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION FUNCTIONAL_DESCRIPTION
...@@ -179,8 +186,9 @@ possible return values: ...@@ -179,8 +186,9 @@ possible return values:
sdb.invoke_id = local->invoke_id = local_agent->invoke_id; sdb.invoke_id = local->invoke_id = local_agent->invoke_id;
local_agent->invoke_id = (local_agent->invoke_id + 1) % 128; local_agent->invoke_id = (local_agent->invoke_id + 1) % 128;
result = profi_snd_req_res( // result = profi_snd_req_res((T_PROFI_DEVICE_HANDLE*)local_agent, &sdb,
(T_PROFI_DEVICE_HANDLE*)local_agent, &sdb, (void*)req, PB_FALSE); // (void*)req, PB_FALSE);
result = profi_snd_req_res(&sdb, (void*)req, PB_FALSE);
return ((pwr_tBoolean)(result == E_OK)); return ((pwr_tBoolean)(result == E_OK));
} }
...@@ -188,8 +196,8 @@ possible return values: ...@@ -188,8 +196,8 @@ possible return values:
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Init method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sFDLCardLocal* local; io_sFDLCardLocal* local;
pwr_sClass_Pb_FDL_DataTransfer* op = (pwr_sClass_Pb_FDL_DataTransfer*)cp->op; pwr_sClass_Pb_FDL_DataTransfer* op = (pwr_sClass_Pb_FDL_DataTransfer*)cp->op;
...@@ -206,8 +214,8 @@ static pwr_tStatus IoCardInit( ...@@ -206,8 +214,8 @@ static pwr_tStatus IoCardInit(
local->byte_ordering = ((pwr_sClass_Pb_FDL_SAP*)rp->op)->ByteOrdering; local->byte_ordering = ((pwr_sClass_Pb_FDL_SAP*)rp->op)->ByteOrdering;
io_bus_card_init(ctx, cp, &input_area_offset, &input_area_chansize, io_bus_card_init(ctx, cp, &input_area_offset, &input_area_chansize,
&output_area_offset, &output_area_chansize, local->byte_ordering, &output_area_offset, &output_area_chansize,
io_eAlignment_Packed); local->byte_ordering, io_eAlignment_Packed);
local->input_area_size = input_area_offset + input_area_chansize; local->input_area_size = input_area_offset + input_area_chansize;
local->output_area_size = output_area_offset + output_area_chansize; local->output_area_size = output_area_offset + output_area_chansize;
...@@ -227,13 +235,13 @@ static pwr_tStatus IoCardInit( ...@@ -227,13 +235,13 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Read method for the Pb FDL Data transfer module Read method for the Pb FDL Data transfer module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead( static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sFDLCardLocal* local = (io_sFDLCardLocal*)cp->Local; io_sFDLCardLocal* local = (io_sFDLCardLocal*)cp->Local;
io_bus_card_read(ctx, rp, cp, local->input_area, 0, local->byte_ordering, io_bus_card_read(ctx, rp, cp, local->input_area, 0, local->byte_ordering,
local->float_representation); local->float_representation);
return IO__SUCCESS; return IO__SUCCESS;
} }
...@@ -241,8 +249,8 @@ static pwr_tStatus IoCardRead( ...@@ -241,8 +249,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Write method for the Pb FDL Data transfer module Write method for the Pb FDL Data transfer module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite( static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sAgentLocal* local_agent = (io_sAgentLocal*)ap->Local; io_sAgentLocal* local_agent = (io_sAgentLocal*)ap->Local;
pwr_sClass_Pb_FDL_DataTransfer* op = (pwr_sClass_Pb_FDL_DataTransfer*)cp->op; pwr_sClass_Pb_FDL_DataTransfer* op = (pwr_sClass_Pb_FDL_DataTransfer*)cp->op;
...@@ -251,16 +259,21 @@ static pwr_tStatus IoCardWrite( ...@@ -251,16 +259,21 @@ static pwr_tStatus IoCardWrite(
op->Status = sap->Status; op->Status = sap->Status;
if (op->Status == PB__NORMAL) { if (op->Status == PB__NORMAL)
{
io_bus_card_write(ctx, cp, local->output_area, local->byte_ordering, io_bus_card_write(ctx, cp, local->output_area, local->byte_ordering,
local->float_representation); local->float_representation);
if (op->SendReq) { if (op->SendReq)
{
pthread_mutex_lock(&local_agent->mutex); pthread_mutex_lock(&local_agent->mutex);
if (sap->Responder) { if (sap->Responder)
{
fdlif_reply_update_mult_req(local_agent, sap, op, local); fdlif_reply_update_mult_req(local_agent, sap, op, local);
} else { }
else
{
fdlif_sda_sdn_sdr_req(local_agent, sap, op, local); fdlif_sda_sdn_sdr_req(local_agent, sap, op, local);
} }
op->SendReq = 0; op->SendReq = 0;
...@@ -274,8 +287,8 @@ static pwr_tStatus IoCardWrite( ...@@ -274,8 +287,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Close method for the Pb module Close method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -290,7 +303,7 @@ static pwr_tStatus IoCardClose( ...@@ -290,7 +303,7 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_FDL_DataTransfer) pwr_dExport pwr_BindIoMethods(Pb_FDL_DataTransfer) = {
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardClose), pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardClose),
pwr_NullMethod }; pwr_NullMethod};
...@@ -85,5 +85,6 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -85,5 +85,6 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_FDL_SAP) = { pwr_BindIoMethod(IoRackInit), pwr_dExport pwr_BindIoMethods(Pb_FDL_SAP) = {pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackClose), pwr_NullMethod }; pwr_BindIoMethod(IoRackClose),
pwr_NullMethod};
This diff is collapsed.
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Ii Init method for the Pb module Ii
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Ii* op; pwr_sClass_Pb_Ii* op;
...@@ -60,7 +60,8 @@ static pwr_tStatus IoCardInit( ...@@ -60,7 +60,8 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Ii*)cp->op; op = (pwr_sClass_Pb_Ii*)cp->op;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
if (rp->Class != pwr_cClass_Pb_DP_Slave) { if (rp->Class != pwr_cClass_Pb_DP_Slave)
{
errh_Info("Illegal object type %s", cp->Name); errh_Info("Illegal object type %s", cp->Name);
return IO__SUCCESS; return IO__SUCCESS;
} }
...@@ -74,8 +75,8 @@ static pwr_tStatus IoCardInit( ...@@ -74,8 +75,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Read method for the Pb Ii card Read method for the Pb Ii card
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead( static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Ii* op; pwr_sClass_Pb_Ii* op;
...@@ -95,8 +96,10 @@ static pwr_tStatus IoCardRead( ...@@ -95,8 +96,10 @@ static pwr_tStatus IoCardRead(
op = (pwr_sClass_Pb_Ii*)cp->op; op = (pwr_sClass_Pb_Ii*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op; slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) { if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
for (i = 0; i < cp->ChanListSize; i++) { {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i]; chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop) if (!chanp->cop || !chanp->sop)
continue; continue;
...@@ -104,54 +107,76 @@ static pwr_tStatus IoCardRead( ...@@ -104,54 +107,76 @@ static pwr_tStatus IoCardRead(
cop = (pwr_sClass_ChanIi*)chanp->cop; cop = (pwr_sClass_ChanIi*)chanp->cop;
sop = (pwr_sClass_Ii*)chanp->sop; sop = (pwr_sClass_Ii*)chanp->sop;
if (cop->ConversionOn) { if (cop->ConversionOn)
if (op->BytesPerChannel == 4) { {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { if (op->BytesPerChannel == 4)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
memcpy(&udata32, local->input_area + op->OffsetInputs + 4 * i, 4); memcpy(&udata32, local->input_area + op->OffsetInputs + 4 * i, 4);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(udata32); udata32 = swap32(udata32);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata32; *(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata32;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
memcpy(&data32, local->input_area + op->OffsetInputs + 4 * i, 4); memcpy(&data32, local->input_area + op->OffsetInputs + 4 * i, 4);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32); data32 = swap32(data32);
*(pwr_tInt32*)chanp->vbp = data32; *(pwr_tInt32*)chanp->vbp = data32;
} }
} else if (op->BytesPerChannel == 3) { }
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { else if (op->BytesPerChannel == 3)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata32 = 0; udata32 = 0;
memcpy(&udata32, local->input_area + op->OffsetInputs + 3 * i, 3); memcpy(&udata32, local->input_area + op->OffsetInputs + 3 * i, 3);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) { if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
{
udata32 = swap32(udata32); udata32 = swap32(udata32);
udata32 = udata32 >> 8; udata32 = udata32 >> 8;
} }
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata32; *(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata32;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data32 = 0; data32 = 0;
memcpy(&data32, local->input_area + op->OffsetInputs + 3 * i, 3); memcpy(&data32, local->input_area + op->OffsetInputs + 3 * i, 3);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) { if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
{
data32 = swap32(data32); data32 = swap32(data32);
data32 = data32 >> 8; data32 = data32 >> 8;
} }
*(pwr_tInt32*)chanp->vbp = data32; *(pwr_tInt32*)chanp->vbp = data32;
} }
} else if (op->BytesPerChannel == 2) { }
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { else if (op->BytesPerChannel == 2)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
memcpy(&udata16, local->input_area + op->OffsetInputs + 2 * i, 2); memcpy(&udata16, local->input_area + op->OffsetInputs + 2 * i, 2);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata16 = swap16(udata16); udata16 = swap16(udata16);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata16; *(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata16;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
memcpy(&data16, local->input_area + op->OffsetInputs + 2 * i, 2); memcpy(&data16, local->input_area + op->OffsetInputs + 2 * i, 2);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data16 = swap16(data16); data16 = swap16(data16);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)data16; *(pwr_tInt32*)chanp->vbp = (pwr_tInt32)data16;
} }
} else if (op->BytesPerChannel == 1) { }
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { else if (op->BytesPerChannel == 1)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
memcpy(&udata8, local->input_area + op->OffsetInputs + i, 1); memcpy(&udata8, local->input_area + op->OffsetInputs + i, 1);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata8; *(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata8;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
memcpy(&data8, local->input_area + op->OffsetInputs + i, 1); memcpy(&data8, local->input_area + op->OffsetInputs + i, 1);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)data8; *(pwr_tInt32*)chanp->vbp = (pwr_tInt32)data8;
} }
...@@ -166,8 +191,8 @@ static pwr_tStatus IoCardRead( ...@@ -166,8 +191,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Close method for the Pb Ii card Close method for the Pb Ii card
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -181,5 +206,6 @@ static pwr_tStatus IoCardClose( ...@@ -181,5 +206,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Ii) = { pwr_BindIoMethod(IoCardInit), pwr_dExport pwr_BindIoMethods(Pb_Ii) = {
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardClose), pwr_NullMethod }; pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Io Init method for the Pb module Io
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Io* op; pwr_sClass_Pb_Io* op;
...@@ -58,12 +58,14 @@ static pwr_tStatus IoCardInit( ...@@ -58,12 +58,14 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Io*)cp->op; op = (pwr_sClass_Pb_Io*)cp->op;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
if (rp->Class != pwr_cClass_Pb_DP_Slave) { if (rp->Class != pwr_cClass_Pb_DP_Slave)
{
errh_Info("Illegal object type %s", cp->Name); errh_Info("Illegal object type %s", cp->Name);
return IO__SUCCESS; return IO__SUCCESS;
} }
if (op->Status < PB_MODULE_STATE_OPERATE) { if (op->Status < PB_MODULE_STATE_OPERATE)
{
errh_Info("Error initializing Pb module Io %s", cp->Name); errh_Info("Error initializing Pb module Io %s", cp->Name);
} }
...@@ -73,8 +75,8 @@ static pwr_tStatus IoCardInit( ...@@ -73,8 +75,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Write method for the Pb module Io Write method for the Pb module Io
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite( static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Io* op; pwr_sClass_Pb_Io* op;
...@@ -91,8 +93,10 @@ static pwr_tStatus IoCardWrite( ...@@ -91,8 +93,10 @@ static pwr_tStatus IoCardWrite(
op = (pwr_sClass_Pb_Io*)cp->op; op = (pwr_sClass_Pb_Io*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op; slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) { if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
for (i = 0; i < cp->ChanListSize; i++) { {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i]; chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop) if (!chanp->cop || !chanp->sop)
continue; continue;
...@@ -105,20 +109,27 @@ static pwr_tStatus IoCardWrite( ...@@ -105,20 +109,27 @@ static pwr_tStatus IoCardWrite(
data32 = *(pwr_tInt32*)chanp->vbp; data32 = *(pwr_tInt32*)chanp->vbp;
if (op->BytesPerChannel == 4) { if (op->BytesPerChannel == 4)
{
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32); data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 4 * i, &data32, 4); memcpy(local->output_area + op->OffsetOutputs + 4 * i, &data32, 4);
} else if (op->BytesPerChannel == 3) { }
else if (op->BytesPerChannel == 3)
{
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32); data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 3 * i, &data32, 3); memcpy(local->output_area + op->OffsetOutputs + 3 * i, &data32, 3);
} else if (op->BytesPerChannel == 2) { }
else if (op->BytesPerChannel == 2)
{
data16 = (pwr_tInt16)data32; data16 = (pwr_tInt16)data32;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data16 = swap16(data16); data16 = swap16(data16);
memcpy(local->output_area + op->OffsetOutputs + 2 * i, &data16, 2); memcpy(local->output_area + op->OffsetOutputs + 2 * i, &data16, 2);
} else if (op->BytesPerChannel == 1) { }
else if (op->BytesPerChannel == 1)
{
data8 = (pwr_tInt8)data32; data8 = (pwr_tInt8)data32;
memcpy(local->output_area + op->OffsetOutputs + i, &data8, 1); memcpy(local->output_area + op->OffsetOutputs + i, &data8, 1);
} }
...@@ -130,8 +141,8 @@ static pwr_tStatus IoCardWrite( ...@@ -130,8 +141,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -145,6 +156,6 @@ static pwr_tStatus IoCardClose( ...@@ -145,6 +156,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Io) pwr_dExport pwr_BindIoMethods(Pb_Io) = {
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod }; pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
...@@ -52,8 +52,8 @@ ...@@ -52,8 +52,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Init method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Module* op; pwr_sClass_Pb_Module* op;
...@@ -62,7 +62,8 @@ static pwr_tStatus IoCardInit( ...@@ -62,7 +62,8 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Module*)cp->op; op = (pwr_sClass_Pb_Module*)cp->op;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
for (i = 0; i < IO_MAXCHAN; i++) { for (i = 0; i < IO_MAXCHAN; i++)
{
local->scancount[i] = 0; local->scancount[i] = 0;
} }
...@@ -74,8 +75,8 @@ static pwr_tStatus IoCardInit( ...@@ -74,8 +75,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Read method for the Pb module Read method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead( static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Module* op; pwr_sClass_Pb_Module* op;
...@@ -92,7 +93,7 @@ static pwr_tStatus IoCardRead( ...@@ -92,7 +93,7 @@ static pwr_tStatus IoCardRead(
/* all inputs will be zeroed */ /* all inputs will be zeroed */
io_bus_card_read(ctx, rp, cp, local->input_area, slave->Diag, io_bus_card_read(ctx, rp, cp, local->input_area, slave->Diag,
slave->ByteOrdering, slave->FloatRepresentation); slave->ByteOrdering, slave->FloatRepresentation);
// printf("Method Pb_Module-IoCardRead\n"); // printf("Method Pb_Module-IoCardRead\n");
return IO__SUCCESS; return IO__SUCCESS;
...@@ -101,8 +102,8 @@ static pwr_tStatus IoCardRead( ...@@ -101,8 +102,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Write method for the Pb module Write method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite( static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Module* op; pwr_sClass_Pb_Module* op;
...@@ -114,9 +115,10 @@ static pwr_tStatus IoCardWrite( ...@@ -114,9 +115,10 @@ static pwr_tStatus IoCardWrite(
op->Status = slave->Status; op->Status = slave->Status;
if (op->Status == PB__NORMAL) { if (op->Status == PB__NORMAL)
{
io_bus_card_write(ctx, cp, local->output_area, slave->ByteOrdering, io_bus_card_write(ctx, cp, local->output_area, slave->ByteOrdering,
slave->FloatRepresentation); slave->FloatRepresentation);
} }
// printf("Method Pb_Module-IoCardWrite\n"); // printf("Method Pb_Module-IoCardWrite\n");
return IO__SUCCESS; return IO__SUCCESS;
...@@ -125,8 +127,8 @@ static pwr_tStatus IoCardWrite( ...@@ -125,8 +127,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Close method for the Pb module Close method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -141,6 +143,7 @@ static pwr_tStatus IoCardClose( ...@@ -141,6 +143,7 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Module) = { pwr_BindIoMethod(IoCardInit), pwr_dExport pwr_BindIoMethods(Pb_Module) = {
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod }; pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardClose),
pwr_NullMethod};
This diff is collapsed.
...@@ -80,8 +80,7 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap) ...@@ -80,8 +80,7 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
/* Allocate area for local data structure */ /* Allocate area for local data structure */
ap->Local = (io_sAgentLocal*)new io_sAgentLocal; ap->Local = (io_sAgentLocal*)new io_sAgentLocal;
if (!ap->Local) if (!ap->Local) {
{
// errh_Error( "ERROR config Profibus DP Master %s - %s", ap->Name, // errh_Error( "ERROR config Profibus DP Master %s - %s", ap->Name,
// "calloc"); // "calloc");
return IO__ERRINIDEVICE; return IO__ERRINIDEVICE;
...@@ -148,48 +147,39 @@ static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap) ...@@ -148,48 +147,39 @@ static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap)
// pthread_mutex_lock(&local->mutex); // pthread_mutex_lock(&local->mutex);
for (ii = 1; ii < local->device_data.size(); ii++) for (ii = 1; ii < local->device_data.size(); ii++) {
{ if (local->device_data[ii]->device_state == PNAK_DEVICE_STATE_CONNECTED) {
if (local->device_data[ii]->device_state == PNAK_DEVICE_STATE_CONNECTED) for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++) {
{
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++)
{
pn_iocr_data = local->device_data[ii]->iocr_data[jj]; pn_iocr_data = local->device_data[ii]->iocr_data[jj];
if (pn_iocr_data->type == PROFINET_IO_CR_TYPE_INPUT) if (pn_iocr_data->type == PROFINET_IO_CR_TYPE_INPUT) {
{
data_length = pn_iocr_data->io_data_length; data_length = pn_iocr_data->io_data_length;
sts = pnak_get_iocr_data(0, pn_iocr_data->identifier, sts = pnak_get_iocr_data(0, pn_iocr_data->identifier,
pn_iocr_data->io_data, &data_length, &ioxs, pn_iocr_data->io_data, &data_length, &ioxs, &status_data);
&status_data);
if (sts == PNAK_OK) if (sts == PNAK_OK) {
{ for (kk = 0; kk < local->device_data[ii]->module_data.size();
for (kk = 0; kk < local->device_data[ii]->module_data.size(); kk++) kk++) {
{
for (ll = 0; ll < local->device_data[ii] for (ll = 0; ll < local->device_data[ii]
->module_data[kk] ->module_data[kk]
->submodule_data.size(); ->submodule_data.size();
ll++) ll++) {
{ submodule = local->device_data[ii]
submodule = ->module_data[kk]
local->device_data[ii]->module_data[kk]->submodule_data[ll]; ->submodule_data[ll];
if ((submodule->type == PROFINET_IO_SUBMODULE_TYPE_INPUT) || if ((submodule->type == PROFINET_IO_SUBMODULE_TYPE_INPUT)
(submodule->type == || (submodule->type
PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT)) == PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT)) {
{
io_datap = (pn_iocr_data->io_data + submodule->offset_io_in); io_datap = (pn_iocr_data->io_data + submodule->offset_io_in);
clean_io_datap = (pn_iocr_data->clean_io_data + clean_io_datap = (pn_iocr_data->clean_io_data
submodule->offset_clean_io_in); + submodule->offset_clean_io_in);
memcpy(clean_io_datap, io_datap, memcpy(
submodule->io_in_data_length); clean_io_datap, io_datap, submodule->io_in_data_length);
} }
} }
} }
} } else {
else
{
printf("pnak_get_iocr_data failed!\n"); printf("pnak_get_iocr_data failed!\n");
} }
} }
...@@ -228,45 +218,37 @@ static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap) ...@@ -228,45 +218,37 @@ static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap)
// pthread_mutex_lock(&local->mutex); // pthread_mutex_lock(&local->mutex);
for (ii = 1; ii < local->device_data.size(); ii++) for (ii = 1; ii < local->device_data.size(); ii++) {
{ if (slave_list != NULL) {
if (slave_list != NULL)
{
sp = (pwr_sClass_PnDevice*)slave_list->op; sp = (pwr_sClass_PnDevice*)slave_list->op;
slave_list = slave_list->next; slave_list = slave_list->next;
} }
if (local->device_data[ii]->device_state == PNAK_DEVICE_STATE_CONNECTED) if (local->device_data[ii]->device_state == PNAK_DEVICE_STATE_CONNECTED) {
{ for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++) {
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++)
{
pn_iocr_data = local->device_data[ii]->iocr_data[jj]; pn_iocr_data = local->device_data[ii]->iocr_data[jj];
if (pn_iocr_data->type == PROFINET_IO_CR_TYPE_OUTPUT) if (pn_iocr_data->type == PROFINET_IO_CR_TYPE_OUTPUT) {
{
data_length = pn_iocr_data->io_data_length; data_length = pn_iocr_data->io_data_length;
/* Set io status to good */ /* Set io status to good */
memset(pn_iocr_data->io_data, 0x80, memset(pn_iocr_data->io_data, 0x80,
data_length); // 0x80 is PNAK_IOXS_STATUS_DATA_GOOD data_length); // 0x80 is PNAK_IOXS_STATUS_DATA_GOOD
for (kk = 0; kk < local->device_data[ii]->module_data.size(); kk++) for (kk = 0; kk < local->device_data[ii]->module_data.size(); kk++) {
{ for (ll = 0; ll < local->device_data[ii]
for (ll = 0; ->module_data[kk]
ll < ->submodule_data.size();
local->device_data[ii]->module_data[kk]->submodule_data.size(); ll++) {
ll++) submodule
{ = local->device_data[ii]->module_data[kk]->submodule_data[ll];
submodule = if ((submodule->type == PROFINET_IO_SUBMODULE_TYPE_OUTPUT)
local->device_data[ii]->module_data[kk]->submodule_data[ll]; || (submodule->type
if ((submodule->type == PROFINET_IO_SUBMODULE_TYPE_OUTPUT) || == PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT)) {
(submodule->type ==
PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT))
{
io_datap = (pn_iocr_data->io_data + submodule->offset_io_out); io_datap = (pn_iocr_data->io_data + submodule->offset_io_out);
clean_io_datap = (pn_iocr_data->clean_io_data + clean_io_datap = (pn_iocr_data->clean_io_data
submodule->offset_clean_io_out); + submodule->offset_clean_io_out);
memcpy(io_datap, clean_io_datap, submodule->io_out_data_length); memcpy(io_datap, clean_io_datap, submodule->io_out_data_length);
/*status_datap = io_datap + submodule->io_out_data_length; /*status_datap = io_datap + submodule->io_out_data_length;
...@@ -276,60 +258,51 @@ static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap) ...@@ -276,60 +258,51 @@ static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap)
} }
} }
} }
char ioxs = CYCLIC_DATA_STATUS_DATA_VALID | char ioxs = CYCLIC_DATA_STATUS_DATA_VALID
CYCLIC_DATA_STATUS_STATE_PRIMARY | | CYCLIC_DATA_STATUS_STATE_PRIMARY | CYCLIC_DATA_STATUS_STATE_RUN
CYCLIC_DATA_STATUS_STATE_RUN | | CYCLIC_DATA_STATUS_NORMAL_OPERATION;
CYCLIC_DATA_STATUS_NORMAL_OPERATION;
sts = pnak_set_iocr_data(0, pn_iocr_data->identifier, sts = pnak_set_iocr_data(0, pn_iocr_data->identifier,
pn_iocr_data->io_data, pn_iocr_data->io_data, pn_iocr_data->io_data_length, ioxs);
pn_iocr_data->io_data_length, ioxs); if (sts != PNAK_OK) {
if (sts != PNAK_OK)
{
printf("pnak_set_iocr_data failed!\n"); printf("pnak_set_iocr_data failed!\n");
} }
} }
} }
if (slave_list != NULL) if (slave_list != NULL) {
{
/* Check if there is a write request pending ?? */ /* Check if there is a write request pending ?? */
if (sp->WriteReq.SendReq) if (sp->WriteReq.SendReq) {
{ if ((sp->WriteReq.Length > 0)
if ((sp->WriteReq.Length > 0) && && (sp->WriteReq.Length <= sizeof(sp->WriteReq.Data))) {
(sp->WriteReq.Length <= sizeof(sp->WriteReq.Data))) for (jj = 0; jj < local->device_data[ii]->module_data.size();
{ jj++) {
for (jj = 0; jj < local->device_data[ii]->module_data.size(); jj++) if (local->device_data[ii]->module_data[jj]->slot_number
{ == sp->WriteReq.SlotNumber) {
if (local->device_data[ii]->module_data[jj]->slot_number ==
sp->WriteReq.SlotNumber)
{
for (kk = 0; kk < local->device_data[ii] for (kk = 0; kk < local->device_data[ii]
->module_data[jj] ->module_data[jj]
->submodule_data.size(); ->submodule_data.size();
kk++) kk++) {
{
if (local->device_data[ii] if (local->device_data[ii]
->module_data[jj] ->module_data[jj]
->submodule_data[kk] ->submodule_data[kk]
->subslot_number == sp->WriteReq.SubslotNumber) ->subslot_number
{ == sp->WriteReq.SubslotNumber) {
if (local->device_data[ii] if (local->device_data[ii]
->module_data[jj] ->module_data[jj]
->submodule_data[kk] ->submodule_data[kk]
->api > 0) ->api
{ > 0) {
sp->WriteReq.Api = local->device_data[ii] sp->WriteReq.Api = local->device_data[ii]
->module_data[jj] ->module_data[jj]
->submodule_data[kk] ->submodule_data[kk]
->api; ->api;
} }
pack_write_req(&local->service_req_res, pack_write_req(&local->service_req_res,
local->device_data[ii]->device_ref, local->device_data[ii]->device_ref, &sp->WriteReq);
&sp->WriteReq);
sts = pnak_send_service_req_res(0, &local->service_req_res); sts = pnak_send_service_req_res(0, &local->service_req_res);
errh_Info("Profinet - Asynch write, dev: %d", errh_Info("Profinet - Asynch write, dev: %d",
local->device_data[ii]->device_ref); local->device_data[ii]->device_ref);
break; break;
} }
} }
......
...@@ -80,8 +80,7 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -80,8 +80,7 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
latent_input_count = 0; latent_input_count = 0;
latent_output_count = 0; latent_output_count = 0;
while (cardp) while (cardp) {
{
local_card = (io_sPnCardLocal*)calloc(1, sizeof(*local_card)); local_card = (io_sPnCardLocal*)calloc(1, sizeof(*local_card));
cardp->Local = local_card; cardp->Local = local_card;
local_card->input_area = ((io_sPnRackLocal*)(rp->Local))->inputs; local_card->input_area = ((io_sPnRackLocal*)(rp->Local))->inputs;
...@@ -93,38 +92,32 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -93,38 +92,32 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
while (ODD(gdh_GetSuperClass(cid, &cid, cardp->Objid))) while (ODD(gdh_GetSuperClass(cid, &cid, cardp->Objid)))
; ;
switch (cid) switch (cid) {
{ /* New style configuring (from v4.1.3) with Pb_Module objects or subclass.
/* New style configuring (from v4.1.3) with Pb_Module objects or subclass. Loop all channels
Loop all channels in the module and set channel size and offset. */
in the module and set channel size and offset. */
case pwr_cClass_PnModule: case pwr_cClass_PnModule:
mp = (pwr_sClass_PnModule*)cardp->op; mp = (pwr_sClass_PnModule*)cardp->op;
mp->Status = PB__INITFAIL; mp->Status = PB__INITFAIL;
cardp->offset = 0; cardp->offset = 0;
for (i = 0; i < cardp->ChanListSize; i++) for (i = 0; i < cardp->ChanListSize; i++) {
{
chanp = &cardp->chanlist[i]; chanp = &cardp->chanlist[i];
if (chanp->ChanClass != pwr_cClass_ChanDi) if (chanp->ChanClass != pwr_cClass_ChanDi) {
{
input_counter += latent_input_count; input_counter += latent_input_count;
latent_input_count = 0; latent_input_count = 0;
} }
if (chanp->ChanClass != pwr_cClass_ChanDo) if (chanp->ChanClass != pwr_cClass_ChanDo) {
{
output_counter += latent_output_count; output_counter += latent_output_count;
latent_output_count = 0; latent_output_count = 0;
} }
switch (chanp->ChanClass) switch (chanp->ChanClass) {
{
case pwr_cClass_ChanDi: case pwr_cClass_ChanDi:
chan_di = (pwr_sClass_ChanDi*)chanp->cop; chan_di = (pwr_sClass_ChanDi*)chanp->cop;
if (chan_di->Number == 0) if (chan_di->Number == 0) {
{
input_counter += latent_input_count; input_counter += latent_input_count;
latent_input_count = 0; latent_input_count = 0;
} }
...@@ -138,15 +131,15 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -138,15 +131,15 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
// byte order. Maybe booleans can be // byte order. Maybe booleans can be
// considered Little Endian... // considered Little Endian...
// More TODO: Check host endianess aswell and take action accordingly // More TODO: Check host endianess aswell and take action accordingly
if (chan_di->Representation == pwr_eDataRepEnum_Bit16 && if (chan_di->Representation == pwr_eDataRepEnum_Bit16
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) && op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap16(chanp->mask); chanp->mask = swap16(chanp->mask);
if (chan_di->Representation == pwr_eDataRepEnum_Bit32 && if (chan_di->Representation == pwr_eDataRepEnum_Bit32
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) && op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap32(chanp->mask); chanp->mask = swap32(chanp->mask);
if (chan_di->Number == 0) if (chan_di->Number == 0)
latent_input_count = latent_input_count
GetChanSize((pwr_eDataRepEnum)chan_di->Representation); = GetChanSize((pwr_eDataRepEnum)chan_di->Representation);
// printf("Di channel found in %s, Number %d, Offset %d\n", // printf("Di channel found in %s, Number %d, Offset %d\n",
// cardp->Name, chan_di->Number, chanp->offset); // cardp->Name, chan_di->Number, chanp->offset);
break; break;
...@@ -186,23 +179,22 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -186,23 +179,22 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
case pwr_cClass_ChanDo: case pwr_cClass_ChanDo:
chan_do = (pwr_sClass_ChanDo*)chanp->cop; chan_do = (pwr_sClass_ChanDo*)chanp->cop;
if (chan_do->Number == 0) if (chan_do->Number == 0) {
{
output_counter += latent_output_count; output_counter += latent_output_count;
latent_output_count = 0; latent_output_count = 0;
} }
chanp->offset = output_counter; chanp->offset = output_counter;
chan_size = GetChanSize((pwr_eDataRepEnum)chan_do->Representation); chan_size = GetChanSize((pwr_eDataRepEnum)chan_do->Representation);
chanp->mask = 1 << chan_do->Number; chanp->mask = 1 << chan_do->Number;
if (chan_do->Representation == pwr_eDataRepEnum_Bit16 && if (chan_do->Representation == pwr_eDataRepEnum_Bit16
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) && op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap16(chanp->mask); chanp->mask = swap16(chanp->mask);
if (chan_do->Representation == pwr_eDataRepEnum_Bit32 && if (chan_do->Representation == pwr_eDataRepEnum_Bit32
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) && op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap32(chanp->mask); chanp->mask = swap32(chanp->mask);
if (chan_do->Number == 0) if (chan_do->Number == 0)
latent_output_count = latent_output_count
GetChanSize((pwr_eDataRepEnum)chan_do->Representation); = GetChanSize((pwr_eDataRepEnum)chan_do->Representation);
// printf("Do channel found in %s, Number %d, Offset %d\n", // printf("Do channel found in %s, Number %d, Offset %d\n",
// cardp->Name, chan_do->Number, chanp->offset); // cardp->Name, chan_do->Number, chanp->offset);
break; break;
...@@ -256,40 +248,31 @@ static pwr_tStatus IoRackRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -256,40 +248,31 @@ static pwr_tStatus IoRackRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
/* The reading of the process image is now performed at the agent level, /* 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. */ this eliminates the need for board specific code at the rack level. */
if (sp->Status == PB__NORMAL) if (sp->Status == PB__NORMAL) {
{
sp->ErrorCount = 0; sp->ErrorCount = 0;
} } else {
else
{
if (local->start_cnt >= local->start_time) if (local->start_cnt >= local->start_time)
sp->ErrorCount++; sp->ErrorCount++;
} }
if (sp->ErrorCount == sp->ErrorHardLimit) if (sp->ErrorCount == sp->ErrorHardLimit) {
{
errh_Error("IO Error hard limit reached on card '%s', stall action %d", errh_Error("IO Error hard limit reached on card '%s', stall action %d",
rp->Name, sp->StallAction); rp->Name, sp->StallAction);
ctx->IOHandler->CardErrorHardLimit = 1; ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(rp->Objid); ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(rp->Objid);
sp->ErrorCount++; sp->ErrorCount++;
} } else if (sp->ErrorCount == sp->ErrorSoftLimit) {
else if (sp->ErrorCount == sp->ErrorSoftLimit)
{
errh_Error("IO Error soft limit reached on card '%s'", rp->Name); errh_Error("IO Error soft limit reached on card '%s'", rp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1; ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(rp->Objid); ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(rp->Objid);
sp->ErrorCount++; sp->ErrorCount++;
} }
if (sp->ErrorCount > sp->ErrorHardLimit) if (sp->ErrorCount > sp->ErrorHardLimit) {
{ if (sp->StallAction == pwr_ePbStallAction_ResetInputs) {
if (sp->StallAction == pwr_ePbStallAction_ResetInputs)
{
if (((io_sPnRackLocal*)(rp->Local))->bytes_of_input > 0) if (((io_sPnRackLocal*)(rp->Local))->bytes_of_input > 0)
memset(((io_sPnRackLocal*)(rp->Local))->inputs, 0, memset(((io_sPnRackLocal*)(rp->Local))->inputs, 0,
((io_sPnRackLocal*)(rp->Local))->bytes_of_input); ((io_sPnRackLocal*)(rp->Local))->bytes_of_input);
} } else if (sp->StallAction == pwr_ePbStallAction_EmergencyBreak)
else if (sp->StallAction == pwr_ePbStallAction_EmergencyBreak)
ctx->Node->EmergBreakTrue = 1; ctx->Node->EmergBreakTrue = 1;
} }
...@@ -307,33 +290,26 @@ static pwr_tStatus IoRackWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -307,33 +290,26 @@ static pwr_tStatus IoRackWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
/* The writing of the process image is now performed at the agent level, /* 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. */ this eliminates the need for board specific code at the rack level. */
if (sp->Status == PB__NORMAL) if (sp->Status == PB__NORMAL) {
{
sp->ErrorCount = 0; sp->ErrorCount = 0;
} } else {
else
{
if (local->start_cnt >= local->start_time) if (local->start_cnt >= local->start_time)
sp->ErrorCount++; sp->ErrorCount++;
} }
if (sp->ErrorCount == sp->ErrorHardLimit) if (sp->ErrorCount == sp->ErrorHardLimit) {
{
errh_Error("IO Error hard limit reached on card '%s', stall action %d", errh_Error("IO Error hard limit reached on card '%s', stall action %d",
rp->Name, sp->StallAction); rp->Name, sp->StallAction);
ctx->IOHandler->CardErrorHardLimit = 1; ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(rp->Objid); ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(rp->Objid);
sp->ErrorCount++; sp->ErrorCount++;
} } else if (sp->ErrorCount == sp->ErrorSoftLimit) {
else if (sp->ErrorCount == sp->ErrorSoftLimit)
{
errh_Error("IO Error soft limit reached on card '%s'", rp->Name); errh_Error("IO Error soft limit reached on card '%s'", rp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1; ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(rp->Objid); ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(rp->Objid);
sp->ErrorCount++; sp->ErrorCount++;
} }
if (sp->ErrorCount > sp->ErrorHardLimit) if (sp->ErrorCount > sp->ErrorHardLimit) {
{
if (sp->StallAction == pwr_ePbStallAction_EmergencyBreak) if (sp->StallAction == pwr_ePbStallAction_EmergencyBreak)
ctx->Node->EmergBreakTrue = 1; ctx->Node->EmergBreakTrue = 1;
} }
...@@ -353,7 +329,6 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -353,7 +329,6 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(PnDevice) = { pwr_dExport pwr_BindIoMethods(PnDevice) = { pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackInit), pwr_BindIoMethod(IoRackRead), pwr_BindIoMethod(IoRackRead), pwr_BindIoMethod(IoRackWrite),
pwr_BindIoMethod(IoRackWrite), pwr_BindIoMethod(IoRackClose), pwr_BindIoMethod(IoRackClose), pwr_NullMethod };
pwr_NullMethod};
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pnmodule Init method for the Pnmodule
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp, static pwr_tStatus IoCardInit(
io_sCard* cp) io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
{ {
io_sPnCardLocal* local; io_sPnCardLocal* local;
pwr_sClass_PnModule* op; pwr_sClass_PnModule* op;
...@@ -57,8 +57,8 @@ static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp, ...@@ -57,8 +57,8 @@ static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Read method for the Pn module Read method for the Pn module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp, static pwr_tStatus IoCardRead(
io_sCard* cp) io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
{ {
io_sPnCardLocal* local; io_sPnCardLocal* local;
pwr_sClass_PnModule* op; pwr_sClass_PnModule* op;
...@@ -75,7 +75,7 @@ static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp, ...@@ -75,7 +75,7 @@ static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
/* all inputs will be zeroed */ /* all inputs will be zeroed */
io_bus_card_read(ctx, rp, cp, local->input_area, 0, slave->ByteOrdering, io_bus_card_read(ctx, rp, cp, local->input_area, 0, slave->ByteOrdering,
slave->FloatRepresentation); slave->FloatRepresentation);
return IO__SUCCESS; return IO__SUCCESS;
} }
...@@ -83,8 +83,8 @@ static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp, ...@@ -83,8 +83,8 @@ static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Write method for the Pn module Write method for the Pn module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp, static pwr_tStatus IoCardWrite(
io_sCard* cp) io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
{ {
io_sPnCardLocal* local; io_sPnCardLocal* local;
pwr_sClass_PnModule* op; pwr_sClass_PnModule* op;
...@@ -96,10 +96,9 @@ static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp, ...@@ -96,10 +96,9 @@ static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
op->Status = slave->Status; op->Status = slave->Status;
if (op->Status == PB__NORMAL) if (op->Status == PB__NORMAL) {
{
io_bus_card_write(ctx, cp, local->output_area, slave->ByteOrdering, io_bus_card_write(ctx, cp, local->output_area, slave->ByteOrdering,
slave->FloatRepresentation); slave->FloatRepresentation);
} }
// printf("Method Pb_Module-IoCardWrite\n"); // printf("Method Pb_Module-IoCardWrite\n");
return IO__SUCCESS; return IO__SUCCESS;
...@@ -108,8 +107,8 @@ static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp, ...@@ -108,8 +107,8 @@ static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Close method for the Pb module Close method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp, static pwr_tStatus IoCardClose(
io_sCard* cp) io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
{ {
io_sPnCardLocal* local; io_sPnCardLocal* local;
local = (io_sPnCardLocal*)cp->Local; local = (io_sPnCardLocal*)cp->Local;
...@@ -124,7 +123,6 @@ static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp, ...@@ -124,7 +123,6 @@ static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(PnModule) = { pwr_dExport pwr_BindIoMethods(PnModule) = { pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardClose), pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_NullMethod};
...@@ -102,6 +102,7 @@ typedef struct _agent_args ...@@ -102,6 +102,7 @@ typedef struct _agent_args
{ {
void* local; void* local;
io_sAgent* ap; io_sAgent* ap;
io_tCtx ctx;
} agent_args; } agent_args;
typedef struct typedef struct
......
This diff is collapsed.
...@@ -175,7 +175,8 @@ public: ...@@ -175,7 +175,8 @@ public:
GsdmlChannelDiag(); GsdmlChannelDiag();
unsigned short error_type; unsigned short error_type;
char name[200]; char name[200];
char help[4096]; // We need a large buffer for most of the help text in the diagnostics... char help[4096]; // We need a large buffer for most of the help text in the
// diagnostics...
int print(std::ofstream& fp); int print(std::ofstream& fp);
}; };
...@@ -213,7 +214,8 @@ public: ...@@ -213,7 +214,8 @@ public:
static GsdmlSlotData* paste_slotdata; static GsdmlSlotData* paste_slotdata;
std::vector<GsdmlChannelDiag*> channel_diag; std::vector<GsdmlChannelDiag*> channel_diag;
~GsdmlDeviceData() { ~GsdmlDeviceData()
{
device_reset(); device_reset();
channel_diag_reset(); channel_diag_reset();
} }
......
This diff is collapsed.
This diff is collapsed.
/*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2019 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* 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 ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. 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
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR 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 ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/*****************************************************************************/ /*****************************************************************************/
/* */ /* */
/* SOFTING AG */ /* SOFTING AG */
......
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