Commit cf48a37c authored by claes's avatar claes

All channels are present in iodata structure

parent 07ee1168
/* /*
* Proview $Id: rt_io_m_pb_ai.c,v 1.3 2006-07-03 06:20:03 claes Exp $ * Proview $Id: rt_io_m_pb_ai.c,v 1.4 2006-09-05 11:14:34 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -259,7 +259,7 @@ static pwr_tStatus IoCardRead ( ...@@ -259,7 +259,7 @@ static pwr_tStatus IoCardRead (
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) continue; if (!chanp->cop || !chanp->sop) continue;
cop = (pwr_sClass_ChanAi *) chanp->cop; cop = (pwr_sClass_ChanAi *) chanp->cop;
sop = (pwr_sClass_Ai *) chanp->sop; sop = (pwr_sClass_Ai *) chanp->sop;
......
/* /*
* Proview $Id: rt_io_m_pb_ao.c,v 1.3 2006-07-03 06:20:03 claes Exp $ * Proview $Id: rt_io_m_pb_ao.c,v 1.4 2006-09-05 11:14:34 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -120,7 +120,7 @@ static pwr_tStatus IoCardWrite ( ...@@ -120,7 +120,7 @@ static pwr_tStatus IoCardWrite (
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) continue; if (!chanp->cop || !chanp->sop) continue;
cop = (pwr_sClass_ChanAo *) chanp->cop; cop = (pwr_sClass_ChanAo *) chanp->cop;
sop = (pwr_sClass_Ao *) chanp->sop; sop = (pwr_sClass_Ao *) chanp->sop;
...@@ -130,8 +130,9 @@ static pwr_tStatus IoCardWrite ( ...@@ -130,8 +130,9 @@ 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;
}
// Make new coeff.. if necessary // Make new coeff.. if necessary
if (cop->CalculateNewCoef) if (cop->CalculateNewCoef)
......
/* /*
* Proview $Id: rt_io_m_pb_di.c,v 1.3 2006-07-03 06:20:03 claes Exp $ * Proview $Id: rt_io_m_pb_di.c,v 1.4 2006-09-05 11:14:34 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -42,6 +42,129 @@ ...@@ -42,6 +42,129 @@
#include "rt_errh.h" #include "rt_errh.h"
#include "rt_io_profiboard.h" #include "rt_io_profiboard.h"
#define IO_CONVMASK_ALL 0xFFFF
/*----------------------------------------------------------------------------*\
Move di data word to valuebase.
\*----------------------------------------------------------------------------*/
void pbio_DiUnpackWord(
io_sCard *cp,
pwr_tUInt16 data,
pwr_tUInt16 mask,
int index)
{
io_sChannel *chanp;
if ( index == 0)
chanp = &cp->chanlist[0];
else
chanp = &cp->chanlist[16];
if ( mask == IO_CONVMASK_ALL)
{
/* No conversion test */
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 1) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 2) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 4) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 8) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 16) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 32) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 64) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 128) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 256) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 512) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 1024) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 2048) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 4096) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 8192) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 16384) != 0);
chanp++;
if ( chanp->cop && chanp->sop)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 32768) != 0);
chanp++;
}
else
{
if ( chanp->cop && chanp->sop && mask & 1)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 1) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 2)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 2) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 4)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 4) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 8)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 8) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 16)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 16) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 32)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 32) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 64)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 64) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 128)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 128) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 256)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 256) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 512)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 512) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 1024)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 1024) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 2048)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 2048) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 4096)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 4096) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 8192)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 8192) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 16384)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 16384) != 0);
chanp++;
if ( chanp->cop && chanp->sop && mask & 32768)
* (pwr_tUInt16 *) (chanp->vbp) = ((data & 32768) != 0);
chanp++;
}
}
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Di Init method for the Pb module Di
...@@ -86,6 +209,11 @@ static pwr_tStatus IoCardRead ( ...@@ -86,6 +209,11 @@ static pwr_tStatus IoCardRead (
io_sCardLocal *local; io_sCardLocal *local;
pwr_sClass_Pb_Di *op; pwr_sClass_Pb_Di *op;
pwr_sClass_Pb_DP_Slave *slave; pwr_sClass_Pb_DP_Slave *slave;
int i;
io_sChannel *chanp;
pwr_sClass_ChanDi *chan_di;
pwr_sClass_Di *sig_di;
pwr_tUInt32 mask = 0;
pwr_tUInt16 data[2] = {0, 0}; pwr_tUInt16 data[2] = {0, 0};
pwr_tUInt32 *data32; pwr_tUInt32 *data32;
...@@ -97,6 +225,7 @@ static pwr_tStatus IoCardRead ( ...@@ -97,6 +225,7 @@ static pwr_tStatus IoCardRead (
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;
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) { if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) {
if (op->Orientation == PB_ORIENTATION_WORD) { if (op->Orientation == PB_ORIENTATION_WORD) {
...@@ -104,20 +233,33 @@ static pwr_tStatus IoCardRead ( ...@@ -104,20 +233,33 @@ static pwr_tStatus IoCardRead (
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 = (pwr_tUInt32 *) &data;
*data32 = swap32(*data32); *data32 = swap32(*data32);
} }
} }
// Packa upp // Mask?
data[0] = data[0] ^ op->InvMask1;
data[1] = data[1] ^ op->InvMask2;
// Packa upp
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) {
mask = 1<<chan_di->Number;
* (pwr_tUInt16 *) (chanp->vbp) = ((*data32 & mask) != 0);
}
}
/*
data[0] = data[0] ^ op->InvMask1; data[0] = data[0] ^ op->InvMask1;
io_DiUnpackWord(cp, data[0], op->ConvMask1, 0); pbio_DiUnpackWord(cp, data[0], op->ConvMask1, 0);
if (op->NumberOfChannels > 16) { if (op->NumberOfChannels > 16) {
data[1] = data[1] ^ op->InvMask2; data[1] = data[1] ^ op->InvMask2;
io_DiUnpackWord(cp, data[1], op->ConvMask2, 1); pbio_DiUnpackWord(cp, data[1], op->ConvMask2, 1);
} }
*/
} }
return IO__SUCCESS; return IO__SUCCESS;
......
/* /*
* Proview $Id: rt_io_m_pb_do.c,v 1.3 2006-07-03 06:20:03 claes Exp $ * Proview $Id: rt_io_m_pb_do.c,v 1.4 2006-09-05 11:14:34 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -84,6 +84,12 @@ static pwr_tStatus IoCardWrite ( ...@@ -84,6 +84,12 @@ static pwr_tStatus IoCardWrite (
io_sCardLocal *local; io_sCardLocal *local;
pwr_sClass_Pb_Do *op; pwr_sClass_Pb_Do *op;
pwr_sClass_Pb_DP_Slave *slave; pwr_sClass_Pb_DP_Slave *slave;
int i;
io_sChannel *chanp;
pwr_sClass_ChanDo *chan_do;
pwr_sClass_Do *sig_do;
pwr_tUInt32 mask = 0;
pwr_tInt32 do_actval;
pwr_tUInt16 data[2] = {0, 0}; pwr_tUInt16 data[2] = {0, 0};
pwr_tUInt32 *data32; pwr_tUInt32 *data32;
...@@ -94,16 +100,32 @@ static pwr_tStatus IoCardWrite ( ...@@ -94,16 +100,32 @@ static pwr_tStatus IoCardWrite (
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++) {
chanp = &cp->chanlist[i];
chan_do = (pwr_sClass_ChanDo *) chanp->cop;
sig_do = (pwr_sClass_Do *) chanp->sop;
if (chan_do && sig_do) {
mask = 1<<chan_do->Number;
do_actval = *(pwr_tInt32 *) chanp->vbp;
if (do_actval != 0)
*data32 |= mask;
else
*data32 &= ~mask;
}
}
/*
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_eByteOrdering_BigEndian) { if (slave->ByteOrdering == pwr_eByteOrdering_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 = (pwr_tUInt32 *) &data;
*data32 = swap32(*data32); *data32 = swap32(*data32);
} }
} }
......
/* /*
* Proview $Id: rt_io_m_pb_ii.c,v 1.3 2006-07-03 06:20:03 claes Exp $ * Proview $Id: rt_io_m_pb_ii.c,v 1.4 2006-09-05 11:14:34 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -103,7 +103,7 @@ static pwr_tStatus IoCardRead ( ...@@ -103,7 +103,7 @@ static pwr_tStatus IoCardRead (
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) continue; if (!chanp->cop || !chanp->sop) continue;
cop = (pwr_sClass_ChanIi *) chanp->cop; cop = (pwr_sClass_ChanIi *) chanp->cop;
sop = (pwr_sClass_Ii *) chanp->sop; sop = (pwr_sClass_Ii *) chanp->sop;
......
/* /*
* Proview $Id: rt_io_m_pb_io.c,v 1.3 2006-07-03 06:20:03 claes Exp $ * Proview $Id: rt_io_m_pb_io.c,v 1.4 2006-09-05 11:14:34 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -100,7 +100,7 @@ static pwr_tStatus IoCardWrite ( ...@@ -100,7 +100,7 @@ static pwr_tStatus IoCardWrite (
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) continue; if (!chanp->cop || !chanp->sop) continue;
cop = (pwr_sClass_ChanIo *) chanp->cop; cop = (pwr_sClass_ChanIo *) chanp->cop;
sop = (pwr_sClass_Io *) chanp->sop; sop = (pwr_sClass_Io *) chanp->sop;
......
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