Commit 5c82d04c authored by claes's avatar claes

Remote rack io

parent ac27b101
/*
* Proview $Id: rt_io_m_di_dix2.c,v 1.2 2006-04-12 10:14:49 claes Exp $
* Proview $Id: rt_io_m_di_dix2.c,v 1.3 2006-04-12 12:14:38 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -51,6 +51,7 @@
typedef struct {
unsigned int Address[2];
int Qbus_fp;
unsigned int bfb_item;
struct {
pwr_sClass_Di *sop[16];
void *Data[16];
......@@ -80,12 +81,16 @@ static pwr_tStatus IoCardInit (
local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = r_local->Qbus_fp;
/* Set card address in racks local */
r_local->in.item[cp->offset].address = (pwr_tUInt16) (op->RegAddress & 0xFFFF);
r_local->in.item[cp->offset+1].address = (pwr_tUInt16) ((op->RegAddress+2) & 0xFFFF);
r_local->in.item[cp->offset].data = 0;
r_local->in.item[cp->offset+1].data = 0;
/* Get item offset from rack's local and increment it */
local->bfb_item = r_local->in_items;
r_local->in_items += 2;
/* Set card address in racks local in- and out-area */
r_local->in.item[local->bfb_item].address = (pwr_tUInt16) (op->RegAddress & 0xFFFF);
r_local->in.item[local->bfb_item+1].address = (pwr_tUInt16) ((op->RegAddress+2) & 0xFFFF);
r_local->in.item[local->bfb_item].data = 0;
r_local->in.item[local->bfb_item+1].data = 0;
/* Init filter */
for ( i = 0; i < 2; i++)
{
......@@ -176,7 +181,7 @@ static pwr_tStatus IoCardRead (
}
else {
/* Read from remote Q-bus, I/O-area stored in rack's local */
data = r_local->in.item[cp->offset+i].data;
data = r_local->in.item[local->bfb_item+i].data;
sts = 1;
}
......
/*
* Proview $Id: rt_io_m_do_hvdo32.c,v 1.2 2006-04-12 10:14:49 claes Exp $
* Proview $Id: rt_io_m_do_hvdo32.c,v 1.3 2006-04-12 12:14:38 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -51,6 +51,7 @@
typedef struct {
unsigned int Address[2];
int Qbus_fp;
unsigned int bfb_item;
struct {
pwr_sClass_Po *sop[16];
void *Data[16];
......@@ -68,6 +69,7 @@ static pwr_tStatus IoCardInit (
pwr_sClass_Do_HVDO32 *op;
io_sLocal *local;
int i, j;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
op = (pwr_sClass_Do_HVDO32 *) cp->op;
local = calloc( 1, sizeof(*local));
......@@ -77,8 +79,18 @@ static pwr_tStatus IoCardInit (
local->Address[0] = op->RegAddress;
local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
local->Qbus_fp = r_local->Qbus_fp;
/* Get item offset from rack's local and increment it */
local->bfb_item = r_local->out_items;
r_local->out_items += 2;
/* Set card address in racks local out-area and initialize data */
r_local->out.item[local->bfb_item].address = (pwr_tUInt16) (op->RegAddress & 0xFFFF);
r_local->out.item[local->bfb_item+1].address = (pwr_tUInt16) ((op->RegAddress+2) & 0xFFFF);
r_local->out.item[local->bfb_item].data = 0;
r_local->out.item[local->bfb_item+1].data = 0;
/* Init filter for Po signals */
for ( i = 0; i < 2; i++)
{
......@@ -134,7 +146,8 @@ static pwr_tStatus IoCardWrite (
io_sCard *cp
)
{
io_sLocal *local;
io_sLocal *local = (io_sLocal *) cp->Local;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
pwr_tUInt16 data = 0;
pwr_sClass_Do_HVDO32 *op;
pwr_tUInt16 invmask;
......@@ -144,7 +157,6 @@ static pwr_tStatus IoCardWrite (
qbus_io_write wb;
int sts;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Do_HVDO32 *) cp->op;
#if defined(OS_ELN)
......@@ -193,10 +205,19 @@ static pwr_tStatus IoCardWrite (
data = (data & ~ testmask) | (testmask & testvalue);
}
wb.Data = data;
wb.Address = local->Address[i];
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if ( sts == -1)
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
/* Write to local Q-bus */
wb.Data = data;
wb.Address = local->Address[i];
sts = write( local->Qbus_fp, &wb, sizeof(wb));
}
else {
/* Write to remote Q-bus, I/O-area stored in rack's local */
r_local->out.item[local->bfb_item+i].data = data;
sts = 1;
}
if ( sts <= 0)
{
#if 0
/* Exceptionhandler was called */
......
#define BFB_SERVICE_READ 1
#define BFB_SERVICE_WRITE 2
struct bfb_item {
pwr_tUInt16 address;
pwr_tUInt16 data;
......@@ -6,7 +9,7 @@ struct bfb_item {
struct bfb_buf {
pwr_tUInt16 service;
pwr_tUInt16 length;
struct bfb_item item[64];
struct bfb_item item[256];
};
typedef struct {
......
/*
* Proview $Id: rt_io_m_ssab_remoterack.c,v 1.2 2006-04-12 10:14:49 claes Exp $
* Proview $Id: rt_io_m_ssab_remoterack.c,v 1.3 2006-04-12 12:14:38 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -49,16 +49,9 @@ static pwr_tStatus IoRackInit (
)
{
io_sRackLocal *local;
io_sCard *cardp;
pwr_tCid cid;
pwr_sClass_Ssab_RemoteRack *op;
int sts, in_offset, out_offset;
int sts;
pwr_sClass_Di_DIX2 *dicp;
pwr_sClass_Do_HVDO32 *docp;
pwr_sClass_Ai_AI32uP *aicp;
pwr_sClass_Co_PI24BO *cocp;
op = (pwr_sClass_Ssab_RemoteRack *) rp->op;
local = calloc( 1, sizeof(*local));
rp->Local = local;
......@@ -98,49 +91,9 @@ static pwr_tStatus IoRackInit (
return IO__ERRINIDEVICE;
}
/* Loop all cards */
cardp = rp->cardlist;
in_offset = 0;
out_offset = 0;
local->in_items = 0;
local->out_items = 0;
while (cardp) {
cid = cardp->Class;
switch (cid) {
case pwr_cClass_Di_DIX2:
dicp = (pwr_sClass_Di_DIX2 *) cardp->op;
cardp->offset = in_offset;
in_offset += 2;
printf("Di card found, address: %d\n", dicp->RegAddress);
break;
case pwr_cClass_Do_HVDO32:
docp = (pwr_sClass_Do_HVDO32 *) cardp->op;
printf("Do card found, address: %d\n", docp->RegAddress);
cardp->offset = out_offset;
out_offset += 2;
break;
case pwr_cClass_Ai_AI32uP:
aicp = (pwr_sClass_Ai_AI32uP *) cardp->op;
printf("Ai card found, address: %d\n", aicp->RegAddress);
break;
case pwr_cClass_Co_PI24BO:
cocp = (pwr_sClass_Co_PI24BO *) cardp->op;
printf("Co card found, address: %d\n", cocp->RegAddress);
break;
}
cardp = cardp->next;
}
local->in_items = in_offset;
local->out_items = out_offset;
local->in.service = 1;
local->in.length = local->in_items*4 + 4;
op->RX_packets = 0;
op->TX_packets = 0;
......@@ -202,19 +155,15 @@ static pwr_tStatus IoRackWrite (
pwr_sClass_Ssab_RemoteRack *op = (pwr_sClass_Ssab_RemoteRack *) rp->op;
// Send write request
local->out.service = 2;
local->out.length = 8;
local->out.item[0].address = 64512;
local->out.item[0].data = 0xffff;
local->out.service = BFB_SERVICE_WRITE;
local->out.length = local->out_items*4 + 4;
sts = send(local->s, &local->out, local->out.length, 0);
op->TX_packets++;
// Send read request
local->in.service = BFB_SERVICE_READ;
local->in.length = local->in_items*4 + 4;
sts = send(local->s, &local->in, local->in.length, 0);
op->TX_packets++;
return IO__SUCCESS;
......
......@@ -7635,15 +7635,15 @@ Volume SsabOx $ClassVolume 0.0.250.5
EndObject
EndObject
Object Ssab_RemoteRack $ClassDef 29 10-FEB-2006 15:50:27.32
Body SysBody 10-FEB-2006 15:49:38.85
Body SysBody 06-APR-2006 08:38:48.21
Attr Editor = 0
Attr Method = 1
Attr Flags = 2128
Attr Flags = 10320
EndBody
Object RtBody $ObjBodyDef 1 10-FEB-2006 15:49:38.87
Body SysBody 10-FEB-2006 15:49:38.87
Attr StructName = "RemoteRack_SSAB"
Attr NextAix = "_X7"
Body SysBody 07-APR-2006 09:09:48.65
Attr StructName = "Ssab_RemoteRack"
Attr NextAix = "_X10"
EndBody
Object Description $Attribute 1 10-FEB-2006 15:49:38.87
Body SysBody 10-FEB-2006 15:49:38.87
......@@ -7675,6 +7675,21 @@ Volume SsabOx $ClassVolume 0.0.250.5
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
Object Status $Attribute 7 10-APR-2006 08:44:55.48
Body SysBody 10-APR-2006 08:45:13.67
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
Object RX_packets $Attribute 8 10-APR-2006 08:46:05.99
Body SysBody 10-APR-2006 08:46:46.68
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object TX_packets $Attribute 9 10-APR-2006 08:47:07.78
Body SysBody 10-APR-2006 08:47:00.72
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
EndObject
Object IoMethods $RtMethod 153 10-FEB-2006 16:02:06.68
Object IoRackInit $Method 154 10-FEB-2006 16:02:06.68
......
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