Commit 3c22204f authored by Claes Sjofors's avatar Claes Sjofors

PSS9000 IOM card methods updated

parent 07ff0b80
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -15,23 +13,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. 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
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview 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 Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ssab_mioup.c -- io methods for ssab cards. */
......@@ -61,16 +44,17 @@
#include "qbus_io.h"
#include "rt_io_m_ssab_locals.h"
#include "rt_io_bfbeth.h"
#include "rt_io_card_write.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define IO_MAXCHAN 32
#define ADDR_DO_OFFSET 1
#define ADDR_AI_OFFSET 3
#define ADDR_AO_OFFSET 19
#define IO_MAXCHAN 128
#define ADDR_DO_OFFSET 16
#define ADDR_AI_OFFSET 48
#define ADDR_AO_OFFSET 32
typedef struct {
unsigned int Address;
......@@ -135,6 +119,65 @@ static pwr_tStatus AoRangeToCoef(
return IO__SUCCESS;
}
void io_DoPackWord_Mio(
io_sCard *cp,
pwr_tUInt16 *data)
{
io_sChannel *chanp;
chanp = &cp->chanlist[4];
*data = 0;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 1;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 2;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 4;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 8;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 16;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 32;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 64;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 128;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 256;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 512;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 1024;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 2048;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 4096;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 8192;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 16384;
chanp++;
if ( chanp->cop && chanp->sop && * (pwr_tUInt16 *) (chanp->vbp))
*data |= 32768;
chanp++;
}
static pwr_tStatus AiRangeToCoef(
io_sChannel *chanp)
{
......@@ -267,11 +310,19 @@ static pwr_tStatus IoCardRead (
pwr_sClass_Ai *sop;
int sts;
qbus_io_read rb;
qbus_io_write writeb;
int bfb_error = 0;
pwr_tTime now;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ssab_BaseMCard *) cp->op;
writeb.Address = local->Address;
writeb.Data = 0;
sts = write(local->Qbus_fp, &writeb, sizeof(writeb));
writeb.Address = local->Address + 2;
writeb.Data = 0x0001;
sts = write( (int) local->Qbus_fp, &writeb, sizeof(writeb));
chanp = &cp->chanlist[0];
for ( i = 0; i < op->MaxNoOfAiChannels; i++)
......@@ -293,15 +344,25 @@ static pwr_tStatus IoCardRead (
{
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
rb.Address = local->Address + 2*i + ADDR_AI_OFFSET;
sts = read( local->Qbus_fp, &rb, sizeof(rb));
data = (unsigned short) rb.Data;
writeb.Address = local->Address;
writeb.Data = ADDR_AI_OFFSET + 16*i;
sts = write(local->Qbus_fp, &writeb, sizeof(writeb));
if(sts != -1)
{
rb.Address = local->Address + 2;
sts = read( local->Qbus_fp, &rb, sizeof(rb));
data = (pwr_tInt16) rb.Data;
}
}
else {
/* Ethernet I/O, Get data from current address */
data = bfbeth_get_data(r_local, (pwr_tUInt16) (local->Address + 2*i + ADDR_AI_OFFSET), &sts);
bfbeth_set_write_req(r_local, (pwr_tUInt16) (local->Address), (pwr_tUInt16) (ADDR_AI_OFFSET + 16*i));
data = bfbeth_get_data(r_local, (pwr_tUInt16) (local->Address + 2), &sts);
/* Yes, we want to read this address the next time aswell */
bfbeth_set_read_req(r_local, (pwr_tUInt16) (local->Address + 2*i + ADDR_AI_OFFSET));
bfbeth_set_read_req(r_local, (pwr_tUInt16) (local->Address + 2));
if (sts == -1) {
/* Error handling for ethernet Qbus-I/O */
......@@ -413,7 +474,7 @@ static pwr_tStatus IoCardWrite (
int fixout;
pwr_tUInt16 data = 0;
pwr_tFloat32 rawvalue;
qbus_io_write wb;
qbus_io_write writeb;
int sts;
pwr_tTime now;
pwr_tUInt16 invmask;
......@@ -467,13 +528,23 @@ static pwr_tStatus IoCardWrite (
data = sop->RawValue;
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
wb.Data = data;
wb.Address = local->Address + 2*i + ADDR_AO_OFFSET;
sts = write( local->Qbus_fp, &wb, sizeof(wb));
writeb.Address = local->Address;
writeb.Data = ADDR_AO_OFFSET + 16*i;
sts = write( local->Qbus_fp, &writeb, sizeof(writeb));
if(sts != -1)
{
writeb.Address = local->Address + 2;
writeb.Data = data;
sts = write( local->Qbus_fp, &writeb, sizeof(writeb));
}
}
else {
/* Ethernet I/O, Request a write to current address */
bfbeth_set_write_req(r_local, (pwr_tUInt16) (local->Address + 2*i + ADDR_AO_OFFSET), data);
bfbeth_set_write_req(r_local, (pwr_tUInt16) (local->Address), (pwr_tUInt16) (ADDR_AO_OFFSET + 16*i));
bfbeth_set_write_req(r_local, (pwr_tUInt16) (local->Address + 2), data);
sts = 1;
}
......@@ -509,13 +580,16 @@ static pwr_tStatus IoCardWrite (
local->OldTestOn[i] = cop->TestOn;
chanp++;
}
if ( local->WriteFirst)
local->WriteFirst--;
if ( ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT)
data = op->DoFixedOutValue;
else
io_DoPackWord( cp, &data, i);
io_DoPackWord_Mio( cp, &data);
testmask = op->DoTestMask;
invmask = op->DoInvMask;
......@@ -532,13 +606,20 @@ static pwr_tStatus IoCardWrite (
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
/* Write to local Q-bus */
wb.Data = data;
wb.Address = local->Address + ADDR_DO_OFFSET;
sts = write( local->Qbus_fp, &wb, sizeof(wb));
writeb.Address = local->Address;
writeb.Data = ADDR_DO_OFFSET;
sts = write( local->Qbus_fp, &writeb, sizeof(writeb));
writeb.Data = data;
writeb.Address = local->Address + 2;
sts = write( local->Qbus_fp, &writeb, sizeof(writeb));
}
else {
/* Ethernet I/O, Request a write to current address */
bfbeth_set_write_req(r_local, (pwr_tUInt16) local->Address + ADDR_DO_OFFSET, data);
bfbeth_set_write_req(r_local, (pwr_tUInt16) local->Address, (pwr_tUInt16) (ADDR_DO_OFFSET));
bfbeth_set_write_req(r_local, (pwr_tUInt16) local->Address + 2, data);
sts = 1;
}
......
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