Commit df0831a3 authored by Marcus Nordenberg's avatar Marcus Nordenberg

format code

parent ce758cd3
This diff is collapsed.
This diff is collapsed.
......@@ -171,7 +171,8 @@
/* ------------------------ RCS message definition ------------------------ */
typedef struct RCS_MESSAGEHEADERtag {
typedef struct RCS_MESSAGEHEADERtag
{
unsigned char rx; /* receiver */
unsigned char tx; /* transmitter */
unsigned char ln; /* lenght */
......@@ -182,7 +183,8 @@ typedef struct RCS_MESSAGEHEADERtag {
unsigned char e; /* extension */
} RCS_MESSAGEHEADER;
typedef struct RCS_MESSAGEtag {
typedef struct RCS_MESSAGEtag
{
unsigned char rx; /* receiver */
unsigned char tx; /* transmitter */
unsigned char ln; /* lenght */
......@@ -197,7 +199,8 @@ typedef struct RCS_MESSAGEtag {
/* ----------------- Standard telegram header ----------------------------- */
/* Keyword: MESSAGE, TASK_B_10 --------------------------------------------*/
typedef struct RCS_TELEGRAMHEADER_10tag {
typedef struct RCS_TELEGRAMHEADER_10tag
{
unsigned char device_adr; /* device address */
unsigned char data_area; /* data area */
unsigned short data_adr; /* data address */
......@@ -207,7 +210,8 @@ typedef struct RCS_TELEGRAMHEADER_10tag {
unsigned char function; /* function */
} RCS_TELEGRAMHEADER_10;
typedef struct RCS_MESSAGETELEGRAMHEADER_10_tag {
typedef struct RCS_MESSAGETELEGRAMHEADER_10_tag
{
unsigned char rx; /* receiver */
unsigned char tx; /* transmitter */
unsigned char ln; /* lenght */
......@@ -225,7 +229,8 @@ typedef struct RCS_MESSAGETELEGRAMHEADER_10_tag {
unsigned char function; /* function */
} RCS_MESSAGETELEGRAMHEADER_10;
typedef struct RCS_TELEGRAMHEADERDATA_10tag {
typedef struct RCS_TELEGRAMHEADERDATA_10tag
{
unsigned char device_adr;
unsigned char data_area;
unsigned short data_adr;
......@@ -237,7 +242,8 @@ typedef struct RCS_TELEGRAMHEADERDATA_10tag {
d[RCS_SEGMENT_LEN - RCS_MESSAGEHEADER_LEN - RCS_TELEGRAMHEADER_LEN];
} RCS_TELEGRAMHEADERDATA_10;
typedef struct RCS_MESSAGETELEGRAM_10tag {
typedef struct RCS_MESSAGETELEGRAM_10tag
{
unsigned char rx; /* receiver */
unsigned char tx; /* transmitter */
unsigned char ln; /* lenght */
......
This diff is collapsed.
......@@ -52,8 +52,8 @@
/*----------------------------------------------------------------------------*\
Init method for the Pb module Ao
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Ao* op;
......@@ -63,20 +63,24 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Ao*)cp->op;
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);
return IO__SUCCESS;
}
if (op->Status >= PB_MODULE_STATE_OPERATE) {
if (op->Status >= PB_MODULE_STATE_OPERATE)
{
// Calculate polycoeff
for (i = 0; i < cp->ChanListSize; i++) {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
if (!chanp->cop)
continue;
io_AoRangeToCoef(chanp);
}
} else
}
else
errh_Info("Error initializing Pb module Ao %s", cp->Name);
return IO__SUCCESS;
......@@ -85,8 +89,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Write method for the Pb module Ao
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Ao* op;
......@@ -109,10 +113,12 @@ static pwr_tStatus IoCardWrite(
op = (pwr_sClass_Pb_Ao*)cp->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;
for (i = 0; i < cp->ChanListSize; i++) {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop)
continue;
......@@ -125,7 +131,8 @@ static pwr_tStatus IoCardWrite(
value = cop->FixedOutValue;
else if (cop->TestOn)
value = cop->TestValue;
else {
else
{
value = *(pwr_tFloat32*)chanp->vbp;
}
......@@ -152,50 +159,66 @@ static pwr_tStatus IoCardWrite(
// Calculate signal value
sop->SigValue = cop->SigValPolyCoef1 * value + cop->SigValPolyCoef0;
if (op->BytesPerChannel == 4) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
if (op->BytesPerChannel == 4)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata32 = (pwr_tUInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(udata32);
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;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 4 * i, &data32, 4);
}
} else if (op->BytesPerChannel == 3) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
}
else if (op->BytesPerChannel == 3)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata32 = (pwr_tUInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(udata32);
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;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 3 * i, &data32, 3);
}
} else if (op->BytesPerChannel == 2) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
}
else if (op->BytesPerChannel == 2)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata16 = (pwr_tUInt16)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata16 = swap16(udata16);
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;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data16 = swap16(data16);
memcpy(local->output_area + op->OffsetOutputs + 2 * i, &data16, 2);
}
} else if (op->BytesPerChannel == 1) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
}
else if (op->BytesPerChannel == 1)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata8 = (pwr_tUInt8)rawvalue;
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;
memcpy(local->output_area + op->OffsetOutputs + i, &data8, 1);
}
......@@ -209,8 +232,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -224,6 +247,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Ao)
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Ao) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
......@@ -54,8 +54,8 @@
/*----------------------------------------------------------------------------*\
Move di data word to valuebase.
\*----------------------------------------------------------------------------*/
void pbio_DiUnpackWord(
io_sCard* cp, pwr_tUInt16 data, pwr_tUInt16 mask, int index)
void pbio_DiUnpackWord(io_sCard* cp, pwr_tUInt16 data, pwr_tUInt16 mask,
int index)
{
io_sChannel* chanp;
......@@ -64,7 +64,8 @@ void pbio_DiUnpackWord(
else
chanp = &cp->chanlist[16];
if (mask == IO_CONVMASK_ALL) {
if (mask == IO_CONVMASK_ALL)
{
/* No conversion test */
if (chanp->cop && chanp->sop)
*(pwr_tUInt16*)(chanp->vbp) = ((data & 1) != 0);
......@@ -114,7 +115,9 @@ void pbio_DiUnpackWord(
if (chanp->cop && chanp->sop)
*(pwr_tUInt16*)(chanp->vbp) = ((data & 32768) != 0);
chanp++;
} else {
}
else
{
if (chanp->cop && chanp->sop && mask & 1)
*(pwr_tUInt16*)(chanp->vbp) = ((data & 1) != 0);
chanp++;
......@@ -169,8 +172,8 @@ void pbio_DiUnpackWord(
/*----------------------------------------------------------------------------*\
Init method for the Pb module Di
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Di* op;
......@@ -180,8 +183,8 @@ static pwr_tStatus IoCardInit(
// Check configuration
if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16
&& op->NumberOfChannels != 32)
if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16 &&
op->NumberOfChannels != 32)
op->Status = PB_MODULE_STATE_NOTINIT;
if (op->Orientation > op->NumberOfChannels)
......@@ -196,8 +199,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Read method for the Pb module Di
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Di* op;
......@@ -208,22 +211,27 @@ static pwr_tStatus IoCardRead(
pwr_sClass_Di* sig_di;
pwr_tUInt32 mask = 0;
pwr_tUInt16 data[2] = { 0, 0 };
pwr_tUInt16 data[2] = {0, 0};
pwr_tUInt32* data32;
local = (io_sCardLocal*)cp->Local;
op = (pwr_sClass_Pb_Di*)cp->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);
data32 = (pwr_tUInt32*)&data;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) {
if (op->Orientation == PB_ORIENTATION_WORD) {
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
{
if (op->Orientation == PB_ORIENTATION_WORD)
{
data[0] = swap16(data[0]);
data[1] = swap16(data[1]);
} else if (op->Orientation == PB_ORIENTATION_DWORD) {
}
else if (op->Orientation == PB_ORIENTATION_DWORD)
{
*data32 = swap32(*data32);
}
}
......@@ -233,11 +241,13 @@ static pwr_tStatus IoCardRead(
data[1] = data[1] ^ op->InvMask2;
// Packa upp
for (i = 0; i < cp->ChanListSize; i++) {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
chan_di = (pwr_sClass_ChanDi*)chanp->cop;
sig_di = (pwr_sClass_Di*)chanp->sop;
if (chan_di && sig_di) {
if (chan_di && sig_di)
{
mask = 1 << chan_di->Number;
*(pwr_tUInt16*)(chanp->vbp) = ((*data32 & mask) != 0);
}
......@@ -258,8 +268,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -273,5 +283,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Di) = { pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Di) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
......@@ -52,8 +52,8 @@
/*----------------------------------------------------------------------------*\
Init method for the Pb module Do
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Do* op;
......@@ -61,8 +61,8 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Do*)cp->op;
local = (io_sCardLocal*)cp->Local;
if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16
&& op->NumberOfChannels != 32)
if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16 &&
op->NumberOfChannels != 32)
op->Status = PB_MODULE_STATE_NOTINIT;
if (op->Orientation > op->NumberOfChannels)
......@@ -77,8 +77,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Write method for the Pb module Do
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Do* op;
......@@ -90,22 +90,25 @@ static pwr_tStatus IoCardWrite(
pwr_tUInt32 mask = 0;
pwr_tInt32 do_actval;
pwr_tUInt16 data[2] = { 0, 0 };
pwr_tUInt16 data[2] = {0, 0};
pwr_tUInt32* data32;
local = (io_sCardLocal*)cp->Local;
op = (pwr_sClass_Pb_Do*)cp->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;
// Packa ner
for (i = 0; i < cp->ChanListSize; i++) {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
chan_do = (pwr_sClass_ChanDo*)chanp->cop;
sig_do = (pwr_sClass_Do*)chanp->sop;
if (chan_do && sig_do) {
if (chan_do && sig_do)
{
mask = 1 << chan_do->Number;
do_actval = *(pwr_tInt32*)chanp->vbp;
if (do_actval != 0)
......@@ -118,11 +121,15 @@ static pwr_tStatus IoCardWrite(
io_DoPackWord(cp, &data[0], 0);
if (op->NumberOfChannels > 16) io_DoPackWord(cp, &data[1], 1);
*/
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) {
if (op->Orientation == PB_ORIENTATION_WORD) {
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
{
if (op->Orientation == PB_ORIENTATION_WORD)
{
data[0] = swap16(data[0]);
data[1] = swap16(data[1]);
} else if (op->Orientation == PB_ORIENTATION_DWORD) {
}
else if (op->Orientation == PB_ORIENTATION_DWORD)
{
*data32 = swap32(*data32);
}
}
......@@ -135,8 +142,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -150,6 +157,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Do)
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Do) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
......@@ -112,7 +112,8 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
latent_input_count = 0;
latent_output_count = 0;
while (cardp) {
while (cardp)
{
local_card = calloc(1, sizeof(*local_card));
cardp->Local = local_card;
local_card->input_area = (void*)&(op->Inputs);
......@@ -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)))
;
switch (cid) {
switch (cid)
{
/* Old style configuring with Pb_xx objects. Still here for combatibility
reasons.
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)
mp = (pwr_sClass_Pb_Module*)cardp->op;
mp->Status = PB__INITFAIL;
cardp->offset = 0;
for (i = 0; i < cardp->ChanListSize; i++) {
for (i = 0; i < cardp->ChanListSize; i++)
{
chanp = &cardp->chanlist[i];
if (is_diag(&chanp->ChanAref)) {
if (is_diag(&chanp->ChanAref))
{
chanp->udata |= PB_UDATA_DIAG;
switch (chanp->ChanClass) {
switch (chanp->ChanClass)
{
case pwr_cClass_ChanIi:
chanp->offset = ((pwr_sClass_ChanIi*)chanp->cop)->Number;
chanp->size
= GetChanSize(((pwr_sClass_ChanIi*)chanp->cop)->Representation);
chanp->size =
GetChanSize(((pwr_sClass_ChanIi*)chanp->cop)->Representation);
break;
default:
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)
continue;
}
if (chanp->ChanClass != pwr_cClass_ChanDi) {
if (chanp->ChanClass != pwr_cClass_ChanDi)
{
input_counter += latent_input_count;
latent_input_count = 0;
}
if (chanp->ChanClass != pwr_cClass_ChanDo) {
if (chanp->ChanClass != pwr_cClass_ChanDo)
{
output_counter += latent_output_count;
latent_output_count = 0;
}
switch (chanp->ChanClass) {
switch (chanp->ChanClass)
{
case pwr_cClass_ChanDi:
chan_di = (pwr_sClass_ChanDi*)chanp->cop;
if (chan_di->Number == 0) {
if (chan_di->Number == 0)
{
input_counter += latent_input_count;
latent_input_count = 0;
}
chanp->offset = input_counter;
chanp->mask = 1 << chan_di->Number;
if (chan_di->Representation == pwr_eDataRepEnum_Bit16
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (chan_di->Representation == pwr_eDataRepEnum_Bit16 &&
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap16(chanp->mask);
if (chan_di->Representation == pwr_eDataRepEnum_Bit32
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (chan_di->Representation == pwr_eDataRepEnum_Bit32 &&
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap32(chanp->mask);
if (chan_di->Number == 0)
latent_input_count = GetChanSize(chan_di->Representation);
......@@ -269,18 +278,19 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
case pwr_cClass_ChanDo:
chan_do = (pwr_sClass_ChanDo*)chanp->cop;
if (chan_do->Number == 0) {
if (chan_do->Number == 0)
{
output_counter += latent_output_count;
latent_output_count = 0;
}
chanp->offset = output_counter;
chan_size = GetChanSize(chan_do->Representation);
chanp->mask = 1 << chan_do->Number;
if (chan_do->Representation == pwr_eDataRepEnum_Bit16
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (chan_do->Representation == pwr_eDataRepEnum_Bit16 &&
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap16(chanp->mask);
if (chan_do->Representation == pwr_eDataRepEnum_Bit32
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (chan_do->Representation == pwr_eDataRepEnum_Bit32 &&
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap32(chanp->mask);
if (chan_do->Number == 0)
latent_output_count = GetChanSize(chan_do->Representation);
......@@ -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,
this eliminates the need for board specific code at the rack level. */
if (sp->DisableSlave != 1 && mp->DisableBus != 1) {
if (sp->Status == PB__NORMAL) {
if (sp->DisableSlave != 1 && mp->DisableBus != 1)
{
if (sp->Status == PB__NORMAL)
{
sp->ErrorCount = 0;
} else {
}
else
{
if (local->start_cnt >= local->start_time)
sp->ErrorCount++;
}
if (sp->ErrorCount == sp->ErrorSoftLimit) {
if (sp->ErrorCount == sp->ErrorSoftLimit)
{
errh_Error("IO Error soft limit reached on card '%s'", rp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(rp->Objid);
}
if (sp->ErrorCount == sp->ErrorHardLimit) {
if (sp->ErrorCount == sp->ErrorHardLimit)
{
errh_Error("IO Error hard limit reached on card '%s', stall action %d",
rp->Name, sp->StallAction);
ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(rp->Objid);
}
if (sp->ErrorCount > sp->ErrorHardLimit
&& sp->StallAction == pwr_ePbStallAction_ResetInputs) {
if (sp->ErrorCount > sp->ErrorHardLimit &&
sp->StallAction == pwr_ePbStallAction_ResetInputs)
{
memset(&sp->Inputs, 0, sp->BytesOfInput);
}
if (sp->ErrorCount > sp->ErrorHardLimit
&& sp->StallAction == pwr_ePbStallAction_EmergencyBreak) {
if (sp->ErrorCount > sp->ErrorHardLimit &&
sp->StallAction == pwr_ePbStallAction_EmergencyBreak)
{
ctx->Node->EmergBreakTrue = 1;
}
} else {
}
else
{
sp->ErrorCount = 0;
sp->Status = PB__DISABLED;
}
......@@ -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.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_DP_Slave) = { pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackRead), pwr_BindIoMethod(IoRackWrite),
pwr_BindIoMethod(IoRackClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_DP_Slave) = {
pwr_BindIoMethod(IoRackInit), pwr_BindIoMethod(IoRackRead),
pwr_BindIoMethod(IoRackWrite), pwr_BindIoMethod(IoRackClose),
pwr_NullMethod};
......@@ -65,7 +65,8 @@
static unsigned char req_res_buffer[512];
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,
pwr_sClass_Pb_FDL_DataTransfer* op,
io_sFDLCardLocal* local)
/*-----------------------------------------------------------------------------
......@@ -106,16 +107,20 @@ possible return values:
*/
sdb.comm_ref = 0;
sdb.layer = FDLIF;
switch (op->Type) {
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDA: {
switch (op->Type)
{
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDA:
{
sdb.service = FDLIF_SDA;
break;
}
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDN: {
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDN:
{
sdb.service = FDLIF_SDN;
break;
}
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SRD: {
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SRD:
{
sdb.service = FDLIF_SRD;
break;
}
......@@ -128,14 +133,16 @@ possible return values:
sdb.invoke_id = local->invoke_id = local_agent->invoke_id;
local_agent->invoke_id = (local_agent->invoke_id + 1) % 128;
result = profi_snd_req_res(
(T_PROFI_DEVICE_HANDLE*)local_agent, &sdb, (void*)req, PB_FALSE);
// result = profi_snd_req_res(
// (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));
}
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,
pwr_sClass_Pb_FDL_DataTransfer* op,
io_sFDLCardLocal* local)
/*-----------------------------------------------------------------------------
......@@ -179,8 +186,9 @@ possible return values:
sdb.invoke_id = local->invoke_id = local_agent->invoke_id;
local_agent->invoke_id = (local_agent->invoke_id + 1) % 128;
result = profi_snd_req_res(
(T_PROFI_DEVICE_HANDLE*)local_agent, &sdb, (void*)req, PB_FALSE);
// result = profi_snd_req_res((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));
}
......@@ -188,8 +196,8 @@ possible return values:
/*----------------------------------------------------------------------------*\
Init method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sFDLCardLocal* local;
pwr_sClass_Pb_FDL_DataTransfer* op = (pwr_sClass_Pb_FDL_DataTransfer*)cp->op;
......@@ -206,8 +214,8 @@ static pwr_tStatus IoCardInit(
local->byte_ordering = ((pwr_sClass_Pb_FDL_SAP*)rp->op)->ByteOrdering;
io_bus_card_init(ctx, cp, &input_area_offset, &input_area_chansize,
&output_area_offset, &output_area_chansize, local->byte_ordering,
io_eAlignment_Packed);
&output_area_offset, &output_area_chansize,
local->byte_ordering, io_eAlignment_Packed);
local->input_area_size = input_area_offset + input_area_chansize;
local->output_area_size = output_area_offset + output_area_chansize;
......@@ -227,8 +235,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Read method for the Pb FDL Data transfer module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sFDLCardLocal* local = (io_sFDLCardLocal*)cp->Local;
......@@ -241,8 +249,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\
Write method for the Pb FDL Data transfer module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sAgentLocal* local_agent = (io_sAgentLocal*)ap->Local;
pwr_sClass_Pb_FDL_DataTransfer* op = (pwr_sClass_Pb_FDL_DataTransfer*)cp->op;
......@@ -251,16 +259,21 @@ static pwr_tStatus IoCardWrite(
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,
local->float_representation);
if (op->SendReq) {
if (op->SendReq)
{
pthread_mutex_lock(&local_agent->mutex);
if (sap->Responder) {
if (sap->Responder)
{
fdlif_reply_update_mult_req(local_agent, sap, op, local);
} else {
}
else
{
fdlif_sda_sdn_sdr_req(local_agent, sap, op, local);
}
op->SendReq = 0;
......@@ -274,8 +287,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\
Close method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -290,7 +303,7 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_FDL_DataTransfer)
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_dExport pwr_BindIoMethods(Pb_FDL_DataTransfer) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
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)
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_FDL_SAP) = { pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_FDL_SAP) = {pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackClose),
pwr_NullMethod};
This diff is collapsed.
......@@ -51,8 +51,8 @@
/*----------------------------------------------------------------------------*\
Init method for the Pb module Ii
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Ii* op;
......@@ -60,7 +60,8 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Ii*)cp->op;
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);
return IO__SUCCESS;
}
......@@ -74,8 +75,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Read method for the Pb Ii card
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Ii* op;
......@@ -95,8 +96,10 @@ static pwr_tStatus IoCardRead(
op = (pwr_sClass_Pb_Ii*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) {
for (i = 0; i < cp->ChanListSize; i++) {
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop)
continue;
......@@ -104,54 +107,76 @@ static pwr_tStatus IoCardRead(
cop = (pwr_sClass_ChanIi*)chanp->cop;
sop = (pwr_sClass_Ii*)chanp->sop;
if (cop->ConversionOn) {
if (op->BytesPerChannel == 4) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
if (cop->ConversionOn)
{
if (op->BytesPerChannel == 4)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
memcpy(&udata32, local->input_area + op->OffsetInputs + 4 * i, 4);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(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);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(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;
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 = udata32 >> 8;
}
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata32;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data32 = 0;
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 = data32 >> 8;
}
*(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);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata16 = swap16(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);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data16 = swap16(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);
*(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);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)data8;
}
......@@ -166,8 +191,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\
Close method for the Pb Ii card
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -181,5 +206,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Ii) = { pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Ii) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
......@@ -49,8 +49,8 @@
/*----------------------------------------------------------------------------*\
Init method for the Pb module Io
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Io* op;
......@@ -58,12 +58,14 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Io*)cp->op;
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);
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);
}
......@@ -73,8 +75,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Write method for the Pb module Io
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Io* op;
......@@ -91,8 +93,10 @@ static pwr_tStatus IoCardWrite(
op = (pwr_sClass_Pb_Io*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) {
for (i = 0; i < cp->ChanListSize; i++) {
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop)
continue;
......@@ -105,20 +109,27 @@ static pwr_tStatus IoCardWrite(
data32 = *(pwr_tInt32*)chanp->vbp;
if (op->BytesPerChannel == 4) {
if (op->BytesPerChannel == 4)
{
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32);
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)
data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 3 * i, &data32, 3);
} else if (op->BytesPerChannel == 2) {
}
else if (op->BytesPerChannel == 2)
{
data16 = (pwr_tInt16)data32;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data16 = swap16(data16);
memcpy(local->output_area + op->OffsetOutputs + 2 * i, &data16, 2);
} else if (op->BytesPerChannel == 1) {
}
else if (op->BytesPerChannel == 1)
{
data8 = (pwr_tInt8)data32;
memcpy(local->output_area + op->OffsetOutputs + i, &data8, 1);
}
......@@ -130,8 +141,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -145,6 +156,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Io)
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Io) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
......@@ -52,8 +52,8 @@
/*----------------------------------------------------------------------------*\
Init method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Module* op;
......@@ -62,7 +62,8 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Module*)cp->op;
local = (io_sCardLocal*)cp->Local;
for (i = 0; i < IO_MAXCHAN; i++) {
for (i = 0; i < IO_MAXCHAN; i++)
{
local->scancount[i] = 0;
}
......@@ -74,8 +75,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Read method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Module* op;
......@@ -101,8 +102,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\
Write method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Module* op;
......@@ -114,7 +115,8 @@ static pwr_tStatus IoCardWrite(
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,
slave->FloatRepresentation);
}
......@@ -125,8 +127,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\
Close method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -141,6 +143,7 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Module) = { pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Module) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardClose),
pwr_NullMethod};
This diff is collapsed.
......@@ -72,20 +72,23 @@
/* io_sAgentLocal now lives in the respective agent modules. */
typedef struct _io_sRackLocal {
typedef struct _io_sRackLocal
{
unsigned char fdl;
unsigned char dp;
unsigned int start_time;
unsigned int start_cnt;
} io_sRackLocal;
typedef struct {
typedef struct
{
void* input_area;
void* output_area;
int scancount[IO_MAXCHAN];
} io_sCardLocal;
typedef struct {
typedef struct
{
unsigned short invoke_id;
unsigned short input_area_size;
unsigned short output_area_size;
......@@ -95,12 +98,15 @@ typedef struct {
unsigned short float_representation;
} io_sFDLCardLocal;
typedef struct _agent_args {
typedef struct _agent_args
{
void* local;
io_sAgent* ap;
io_tCtx ctx;
} agent_args;
typedef struct {
typedef struct
{
int hServiceReadDevice; // Handle for Service device
int hServiceWriteDevice; // Handle for Service device
int hDpDataDevice; // Handle for DP-Data device
......
......@@ -39,7 +39,8 @@
/* rt_io_pn_locals.h -- Profinet io handling locals. */
typedef struct _io_sPnRackLocal {
typedef struct _io_sPnRackLocal
{
unsigned short bytes_of_input;
unsigned short bytes_of_output;
unsigned char* inputs;
......@@ -49,7 +50,8 @@ typedef struct _io_sPnRackLocal {
unsigned int start_cnt;
} io_sPnRackLocal;
typedef struct _io_sPnCardLocal {
typedef struct _io_sPnCardLocal
{
unsigned int input_area_size;
unsigned int output_area_size;
unsigned char* input_area;
......
......@@ -45,7 +45,8 @@
/* rt_io_pnak_locals.h -- Profinet io handling locals. */
typedef struct _PN_Alarm_Data {
typedef struct _PN_Alarm_Data
{
unsigned short alarm_type;
unsigned short alarm_prio;
unsigned short rem_alarms;
......@@ -58,12 +59,10 @@ typedef struct _PN_Alarm_Data {
unsigned char* data;
} PN_Alarm_Data;
class PnApiData {
class PnApiData
{
public:
PnApiData()
: api(0)
{
}
PnApiData() : api(0) {}
unsigned int api;
std::vector<unsigned int> module_index;
......@@ -73,14 +72,12 @@ public:
int print(std::ofstream& fp);
};
class PnIOCRData {
class PnIOCRData
{
public:
PnIOCRData()
: type(0)
, number_modules(0)
, identifier(0)
, io_data_length(0)
, clean_io_data_length(0)
: type(0), number_modules(0), identifier(0), io_data_length(0),
clean_io_data_length(0)
{
}
......@@ -97,16 +94,12 @@ public:
int print(std::ofstream& fp);
};
class PnSubmoduleData {
class PnSubmoduleData
{
public:
PnSubmoduleData()
: subslot_number(0)
, subslot_idx(0)
, type(0)
, state(0)
, ident_number(0)
, phys_ident_number(0)
, api(0)
: subslot_number(0), subslot_idx(0), type(0), state(0), ident_number(0),
phys_ident_number(0), api(0)
{
}
......@@ -133,14 +126,12 @@ public:
int print(std::ofstream& fp);
};
class PnModuleData {
class PnModuleData
{
public:
PnModuleData()
: slot_number(0)
, slot_idx(0)
, state(0)
, ident_number(0)
, phys_ident_number(0)
: slot_number(0), slot_idx(0), state(0), ident_number(0),
phys_ident_number(0)
{
}
......@@ -161,13 +152,11 @@ public:
int print(std::ofstream& fp);
};
class PnDeviceData {
class PnDeviceData
{
public:
PnDeviceData()
: device_ref(0)
, alarm_ref(0)
, device_state(0)
, no_diff_modules(0)
: device_ref(0), alarm_ref(0), device_state(0), no_diff_modules(0)
{
memset(&alarm_data, 0, sizeof(PN_Alarm_Data));
}
......@@ -182,10 +171,7 @@ public:
std::vector<PnModuleData*> module_data;
std::vector<PnIOCRData*> iocr_data;
~PnDeviceData()
{
device_reset();
}
~PnDeviceData() { device_reset(); }
void device_reset()
{
for (unsigned int i = 0; i < module_data.size(); i++)
......@@ -201,7 +187,8 @@ public:
int paste_slot(unsigned int slot_idx);
};
class PnDeviceInfo {
class PnDeviceInfo
{
public:
PnDeviceInfo() {}
unsigned char ipaddress[4];
......@@ -212,12 +199,14 @@ public:
int deviceid;
};
typedef struct _agent_args {
typedef struct _agent_args
{
void* local;
io_sAgent* ap;
} agent_args;
class io_sAgentLocal {
class io_sAgentLocal
{
public:
io_sAgentLocal() {}
......
......@@ -43,15 +43,12 @@
#include "co_xml_parser.h"
class GsdmlDataRecord {
class GsdmlDataRecord
{
public:
GsdmlDataRecord()
: record_idx(0)
, data(0)
, data_reversed_endianess(0)
, data_length(0)
, index(0)
, transfer_sequence(0)
: record_idx(0), data(0), data_reversed_endianess(0), data_length(0),
index(0), transfer_sequence(0)
{
}
......@@ -74,14 +71,11 @@ public:
int print(std::ofstream& fp, bool reverse_endianess);
};
class GsdmlIOCRData {
class GsdmlIOCRData
{
public:
GsdmlIOCRData()
: type(0)
, properties(0)
, send_clock_factor(0)
, phase(0)
, api(0)
: type(0), properties(0), send_clock_factor(0), phase(0), api(0)
{
}
......@@ -95,16 +89,13 @@ public:
int print(std::ofstream& fp);
};
class GsdmlSubslotData {
class GsdmlSubslotData
{
public:
GsdmlSubslotData()
: subslot_number(0)
, subslot_idx(0)
, submodule_enum_number(0)
, submodule_ident_number(0)
, api(0)
, io_input_length(0)
, io_output_length(0)
: subslot_number(0), subslot_idx(0), submodule_enum_number(0),
submodule_ident_number(0), api(0), io_input_length(0),
io_output_length(0)
{
}
......@@ -123,24 +114,22 @@ public:
delete data_record[i];
}
GsdmlSubslotData(const GsdmlSubslotData& x)
: subslot_number(x.subslot_number)
, subslot_idx(x.subslot_idx)
: subslot_number(x.subslot_number), subslot_idx(x.subslot_idx)
{
for (unsigned int i = 0; i < x.data_record.size(); i++)
{
for (unsigned int i = 0; i < x.data_record.size(); i++) {
data_record.push_back(new GsdmlDataRecord(*x.data_record[i]));
}
}
int print(std::ofstream& fp, bool reverse_endianess);
};
class GsdmlSlotData {
class GsdmlSlotData
{
public:
GsdmlSlotData()
: module_enum_number(0)
, module_class(0)
, module_oid(pwr_cNOid)
, slot_number(0)
, slot_idx(0)
: module_enum_number(0), module_class(0), module_oid(pwr_cNOid),
slot_number(0), slot_idx(0)
{
module_text[0] = 0;
}
......@@ -165,20 +154,20 @@ public:
subslot_data.clear();
}
GsdmlSlotData(const GsdmlSlotData& x)
: module_enum_number(x.module_enum_number)
, module_class(x.module_class)
, module_oid(pwr_cNObjid)
, slot_number(x.slot_number)
, slot_idx(x.slot_idx)
: module_enum_number(x.module_enum_number), module_class(x.module_class),
module_oid(pwr_cNObjid), slot_number(x.slot_number),
slot_idx(x.slot_idx)
{
for (unsigned int i = 0; i < x.subslot_data.size(); i++)
{
for (unsigned int i = 0; i < x.subslot_data.size(); i++) {
subslot_data.push_back(new GsdmlSubslotData(*x.subslot_data[i]));
}
}
int print(std::ofstream& fp, bool reverse_endianess);
};
class GsdmlChannelDiag {
class GsdmlChannelDiag
{
public:
GsdmlChannelDiag();
unsigned short error_type;
......@@ -189,15 +178,12 @@ public:
int print(std::ofstream& fp);
};
class GsdmlDeviceData {
class GsdmlDeviceData
{
public:
GsdmlDeviceData()
: device_num(0)
, vendor_id(0)
, device_id(0)
, byte_order(0)
, read_data_is_native_ordered(1)
, instance(0)
: device_num(0), vendor_id(0), device_id(0), byte_order(0),
read_data_is_native_ordered(1), instance(0)
{
device_name[0] = 0;
ip_address[0] = 0;
......@@ -254,13 +240,10 @@ public:
int get_value(const char* attr, char* buf, int bufsize);
};
class GsdmlDataReader : public co_xml_interpreter {
class GsdmlDataReader : public co_xml_interpreter
{
public:
GsdmlDataReader(GsdmlDeviceData* d)
: data(d)
, new_filename(0)
{
}
GsdmlDataReader(GsdmlDeviceData* d) : data(d), new_filename(0) {}
int tag(const char* name);
int metatag(const char* name);
int tag_end(const char* name);
......
......@@ -47,24 +47,24 @@
#define PN_MAX_MANU_SPEC_DIAGS 200
void pack_set_ip_settings_req(
T_PNAK_SERVICE_REQ_RES* ServiceReqRes, PnDeviceInfo* dev_info);
void pack_set_ip_settings_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
PnDeviceInfo* dev_info);
void pack_set_device_name_req(
T_PNAK_SERVICE_REQ_RES* ServiceReqRes, PnDeviceInfo* dev_info);
void pack_set_device_name_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
PnDeviceInfo* dev_info);
void pack_set_identification_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes);
void pack_get_device_state_req(
T_PNAK_SERVICE_REQ_RES* ServiceReqRes, unsigned short device_ref);
void pack_get_device_state_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
unsigned short device_ref);
void pack_write_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
unsigned short device_ref, pwr_sClass_PnWriteReq* wr_req);
void pack_get_los_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes);
void pack_get_alarm_req(
T_PNAK_SERVICE_REQ_RES* ServiceReqRes, unsigned short ref);
void pack_get_alarm_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
unsigned short ref);
void pack_alarm_ack_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
unsigned short ref, unsigned short prio);
......@@ -76,13 +76,13 @@ int unpack_write_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local);
int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local);
int unpack_get_alarm_con(
T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local, io_sAgent* ap);
int unpack_get_device_state_con(
T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local, io_sAgent* ap);
int unpack_get_alarm_con(T_PNAK_SERVICE_DESCRIPTION* pSdb,
io_sAgentLocal* local, io_sAgent* ap);
int unpack_get_device_state_con(T_PNAK_SERVICE_DESCRIPTION* pSdb,
io_sAgentLocal* local, io_sAgent* ap);
int unpack_download_con(
T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local);
int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb,
io_sAgentLocal* local);
int handle_service_con(io_sAgentLocal* local, io_sAgent* ap);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment