Commit a9416210 authored by claes's avatar claes

*** empty log message ***

parent 0d5e18d6
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_ssaboxclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_m_ssab_locals.h"
void bfbeth_set_read_req(io_sRackLocal *r, pwr_tUInt16 address) {
r->read_req.item[r->next_read_req_item].address = address;
r->next_read_req_item++;
return;
}
void bfbeth_set_write_req(io_sRackLocal *r, pwr_tUInt16 address, pwr_tUInt16 data) {
r->write_req.item[r->next_write_req_item].address = address;
r->write_req.item[r->next_write_req_item].data = data;
r->next_write_req_item++;
return;
}
pwr_tUInt16 bfbeth_get_data(io_sRackLocal *r, pwr_tUInt16 address) {
int i;
for (i=0; i<350; i++) {
if (r->read_area.item[i].address == address)
return (r->read_area.item[i].data);
}
return 0;
}
void bfbeth_set_read_req( io_sRackLocal *r,
pwr_tUInt16 address);
void bfbeth_set_write_req( io_sRackLocal *r,
pwr_tUInt16 address,
pwr_tUInt16 data);
pwr_tUInt16 bfbeth_get_data( io_sRackLocal *r,
pwr_tUInt16 address);
/* /*
* Proview $Id: rt_io_m_ai_ai32up.c,v 1.2 2006-04-12 10:14:49 claes Exp $ * Proview $Id: rt_io_m_ai_ai32up.c,v 1.3 2006-06-02 07:57:23 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
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
typedef struct { typedef struct {
unsigned int Address; unsigned int Address;
int Qbus_fp; int Qbus_fp;
unsigned int bfb_item;
int ScanCount[IO_MAXCHAN]; int ScanCount[IO_MAXCHAN];
} io_sLocal; } io_sLocal;
...@@ -74,6 +75,7 @@ static pwr_tStatus AiRangeToCoef( ...@@ -74,6 +75,7 @@ static pwr_tStatus AiRangeToCoef(
{ {
cop->CalculateNewCoef = 0; cop->CalculateNewCoef = 0;
/* Coef for RawValue to SignalValue conversion */ /* Coef for RawValue to SignalValue conversion */
cop->SigValPolyCoef0 = 0; cop->SigValPolyCoef0 = 0;
cop->SigValPolyCoef1 = cop->ChannelSigValRangeHigh / 30000; cop->SigValPolyCoef1 = cop->ChannelSigValRangeHigh / 30000;
...@@ -115,13 +117,25 @@ static pwr_tStatus IoCardInit ( ...@@ -115,13 +117,25 @@ static pwr_tStatus IoCardInit (
io_sLocal *local; io_sLocal *local;
int i; int i;
io_sChannel *chanp; io_sChannel *chanp;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
op = (pwr_sClass_Ai_AI32uP *) cp->op; op = (pwr_sClass_Ai_AI32uP *) cp->op;
local = calloc( 1, sizeof(*local)); local = calloc( 1, sizeof(*local));
cp->Local = local; cp->Local = local;
local->Address = op->RegAddress; local->Address = op->RegAddress;
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, used by remote rack only
local->bfb_item = r_local->in_items;
r_local->in_items += op->MaxNoOfChannels;
/* Set card address in racks local in- and out-area, used by remote rack only
for (i=0; i<op->MaxNoOfChannels; i++) {
r_local->in.item[local->bfb_item+i].address = (pwr_tUInt16) ((op->RegAddress+i*2) & 0xFFFF);
r_local->in.item[local->bfb_item+i].data = 0;
}
*/
errh_Info( "Init of ai card '%s'", cp->Name); errh_Info( "Init of ai card '%s'", cp->Name);
/* Caluclate polycoeff */ /* Caluclate polycoeff */
...@@ -167,6 +181,7 @@ static pwr_tStatus IoCardRead ( ...@@ -167,6 +181,7 @@ static pwr_tStatus IoCardRead (
) )
{ {
io_sLocal *local; io_sLocal *local;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
pwr_tInt16 data = 0; pwr_tInt16 data = 0;
pwr_sClass_Ai_AI32uP *op; pwr_sClass_Ai_AI32uP *op;
int i; int i;
...@@ -202,9 +217,17 @@ static pwr_tStatus IoCardRead ( ...@@ -202,9 +217,17 @@ static pwr_tStatus IoCardRead (
#if defined(OS_ELN) #if defined(OS_ELN)
vaxc$establish(machfailread); vaxc$establish(machfailread);
#endif #endif
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
rb.Address = local->Address + 2*i; rb.Address = local->Address + 2*i;
sts = read( local->Qbus_fp, &rb, sizeof(rb)); sts = read( local->Qbus_fp, &rb, sizeof(rb));
data = (unsigned short) rb.Data; data = (unsigned short) rb.Data;
}
else {
/* Read from remote Q-bus, I/O-area stored in rack's local
data = r_local->in.item[local->bfb_item+i].data;*/
sts = 1;
}
if ( sts == -1) if ( sts == -1)
{ {
#if 0 #if 0
......
/* /*
* Proview $Id: rt_io_m_co_pi24bo.c,v 1.3 2006-04-18 08:17:44 claes Exp $ * Proview $Id: rt_io_m_co_pi24bo.c,v 1.4 2006-06-02 07:57:23 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
...@@ -92,21 +92,21 @@ static pwr_tStatus IoCardInit ( ...@@ -92,21 +92,21 @@ static pwr_tStatus IoCardInit (
errh_Info( "Init of co card '%s'", cp->Name); errh_Info( "Init of co card '%s'", cp->Name);
/* Get item offset from rack's local and increment it */ /* Get item offset from rack's local and increment it
/* This is a CO-card which means that we have both read and write possibilities */ /* This is a CO-card which means that we have both read and write possibilities
local->bfb_read_item = r_local->in_items; local->bfb_read_item = r_local->in_items;
r_local->in_items += op->MaxNoOfCounters*2; r_local->in_items += op->MaxNoOfCounters*2;
local->bfb_write_item = r_local->out_items; local->bfb_write_item = r_local->out_items;
r_local->out_items += op->MaxNoOfCounters*2; r_local->out_items += op->MaxNoOfCounters*2;
/* Set card address in racks local in- and out-area */ /* Set card address in racks local in- and out-area
for (i=0; i<op->MaxNoOfCounters; i++) { for (i=0; i<op->MaxNoOfCounters; i++) {
r_local->in.item[local->bfb_read_item+i*2].address = (pwr_tUInt16) ((op->RegAddress+i*2) & 0xFFFF); r_local->in.item[local->bfb_read_item+i*2].address = (pwr_tUInt16) ((op->RegAddress+i*2) & 0xFFFF);
r_local->in.item[local->bfb_read_item+i*2+1].address = (pwr_tUInt16) ((op->RegAddress+i*2+2) & 0xFFFF); r_local->in.item[local->bfb_read_item+i*2+1].address = (pwr_tUInt16) ((op->RegAddress+i*2+2) & 0xFFFF);
r_local->out.item[local->bfb_write_item+i*2].address = (pwr_tUInt16) ((op->RegAddress+i*2) & 0xFFFF); // We dont normally write r_local->out.item[local->bfb_write_item+i*2].address = (pwr_tUInt16) ((op->RegAddress+i*2) & 0xFFFF); // We dont normally write
r_local->out.item[local->bfb_write_item+i*2+1].address = (pwr_tUInt16) ((op->RegAddress+i*2+2) & 0xFFFF); // We dont normally write r_local->out.item[local->bfb_write_item+i*2+1].address = (pwr_tUInt16) ((op->RegAddress+i*2+2) & 0xFFFF); // We dont normally write
} }
*/
/* Configure card */ /* Configure card */
for ( i = 0; i < op->MaxNoOfCounters; i++) for ( i = 0; i < op->MaxNoOfCounters; i++)
{ {
...@@ -290,8 +290,8 @@ static pwr_tStatus IoCardRead ( ...@@ -290,8 +290,8 @@ static pwr_tStatus IoCardRead (
re_data[0] = (unsigned short) rb.Data; re_data[0] = (unsigned short) rb.Data;
} }
else { else {
/* Read from remote Q-bus, I/O-area stored in rack's local */ /* Read from remote Q-bus, I/O-area stored in rack's local
re_data[0] = r_local->in.item[local->bfb_read_item+2*i].data; re_data[0] = r_local->in.item[local->bfb_read_item+2*i].data; */
sts1 = 1; sts1 = 1;
} }
...@@ -304,8 +304,8 @@ static pwr_tStatus IoCardRead ( ...@@ -304,8 +304,8 @@ static pwr_tStatus IoCardRead (
re_data[1] = (unsigned short) rb.Data; re_data[1] = (unsigned short) rb.Data;
} }
else { else {
/* Read from remote Q-bus, I/O-area stored in rack's local */ /* Read from remote Q-bus, I/O-area stored in rack's local
re_data[1] = r_local->in.item[local->bfb_read_item+2*i+1].data; re_data[1] = r_local->in.item[local->bfb_read_item+2*i+1].data; */
sts2 = 1; sts2 = 1;
} }
} }
......
/* /*
* Proview $Id: rt_io_m_di_dix2.c,v 1.3 2006-04-12 12:14:38 claes Exp $ * Proview $Id: rt_io_m_di_dix2.c,v 1.4 2006-06-02 07:57:23 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,12 +42,14 @@ ...@@ -42,12 +42,14 @@
#include "rt_io_card_read.h" #include "rt_io_card_read.h"
#include "qbus_io.h" #include "qbus_io.h"
#include "rt_io_m_ssab_locals.h" #include "rt_io_m_ssab_locals.h"
#include "rt_io_bfbeth.h"
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
typedef struct { typedef struct {
unsigned int Address[2]; unsigned int Address[2];
int Qbus_fp; int Qbus_fp;
...@@ -81,16 +83,18 @@ static pwr_tStatus IoCardInit ( ...@@ -81,16 +83,18 @@ static pwr_tStatus IoCardInit (
local->Address[1] = op->RegAddress + 2; local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = r_local->Qbus_fp; local->Qbus_fp = r_local->Qbus_fp;
/* Get item offset from rack's local and increment it */ /* Get item offset from rack's local and increment it
local->bfb_item = r_local->in_items; local->bfb_item = r_local->in_items;
r_local->in_items += 2; r_local->in_items += 2;
/* Set card address in racks local in- and out-area */ 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].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+1].address = (pwr_tUInt16) ((op->RegAddress+2) & 0xFFFF);
r_local->in.item[local->bfb_item].data = 0; r_local->in.item[local->bfb_item].data = 0;
r_local->in.item[local->bfb_item+1].data = 0; r_local->in.item[local->bfb_item+1].data = 0;
*/
/* Init filter */ /* Init filter */
for ( i = 0; i < 2; i++) for ( i = 0; i < 2; i++)
{ {
...@@ -180,9 +184,11 @@ static pwr_tStatus IoCardRead ( ...@@ -180,9 +184,11 @@ static pwr_tStatus IoCardRead (
data = (unsigned short) rb.Data; data = (unsigned short) rb.Data;
} }
else { else {
/* Read from remote Q-bus, I/O-area stored in rack's local */ /* Ethernet I/O, Get data from current address */
data = r_local->in.item[local->bfb_item+i].data; data = bfbeth_get_data(r_local, (pwr_tUInt16) local->Address[i]);
sts = 1; sts = 1;
/* Yes, we want to read this address the next time aswell */
bfbeth_set_read_req(r_local, (pwr_tUInt16) local->Address[i]);
} }
if ( sts <= 0) if ( sts <= 0)
......
/* /*
* Proview $Id: rt_io_m_do_hvdo32.c,v 1.3 2006-04-12 12:14:38 claes Exp $ * Proview $Id: rt_io_m_do_hvdo32.c,v 1.4 2006-06-02 07:57:23 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,7 @@ ...@@ -42,6 +42,7 @@
#include "rt_io_card_write.h" #include "rt_io_card_write.h"
#include "qbus_io.h" #include "qbus_io.h"
#include "rt_io_m_ssab_locals.h" #include "rt_io_m_ssab_locals.h"
#include "rt_io_bfbeth.h"
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
...@@ -51,7 +52,6 @@ ...@@ -51,7 +52,6 @@
typedef struct { typedef struct {
unsigned int Address[2]; unsigned int Address[2];
int Qbus_fp; int Qbus_fp;
unsigned int bfb_item;
struct { struct {
pwr_sClass_Po *sop[16]; pwr_sClass_Po *sop[16];
void *Data[16]; void *Data[16];
...@@ -81,16 +81,17 @@ static pwr_tStatus IoCardInit ( ...@@ -81,16 +81,17 @@ static pwr_tStatus IoCardInit (
local->Address[1] = op->RegAddress + 2; local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = r_local->Qbus_fp; local->Qbus_fp = r_local->Qbus_fp;
/* Get item offset from rack's local and increment it */ /* Get item offset from rack's local and increment it
local->bfb_item = r_local->out_items; local->bfb_item = r_local->out_items;
r_local->out_items += 2; r_local->out_items += 2;
/* Set card address in racks local out-area and initialize data */ 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].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+1].address = (pwr_tUInt16) ((op->RegAddress+2) & 0xFFFF);
r_local->out.item[local->bfb_item].data = 0; r_local->out.item[local->bfb_item].data = 0;
r_local->out.item[local->bfb_item+1].data = 0; r_local->out.item[local->bfb_item+1].data = 0;
*/
/* Init filter for Po signals */ /* Init filter for Po signals */
for ( i = 0; i < 2; i++) for ( i = 0; i < 2; i++)
{ {
...@@ -212,8 +213,8 @@ static pwr_tStatus IoCardWrite ( ...@@ -212,8 +213,8 @@ static pwr_tStatus IoCardWrite (
sts = write( local->Qbus_fp, &wb, sizeof(wb)); sts = write( local->Qbus_fp, &wb, sizeof(wb));
} }
else { else {
/* Write to remote Q-bus, I/O-area stored in rack's local */ /* Ethernet I/O, Request a write to current address */
r_local->out.item[local->bfb_item+i].data = data; bfbeth_set_write_req(r_local, (pwr_tUInt16) local->Address[i], data);
sts = 1; sts = 1;
} }
......
/* /*
* Proview $Id: rt_io_m_ssab_aoup.c,v 1.2 2006-04-12 10:14:49 claes Exp $ * Proview $Id: rt_io_m_ssab_aoup.c,v 1.3 2006-06-02 07:57:23 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
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
typedef struct { typedef struct {
unsigned int Address; unsigned int Address;
int Qbus_fp; int Qbus_fp;
unsigned int bfb_item;
pwr_tFloat32 OldValue[IO_MAXCHAN]; pwr_tFloat32 OldValue[IO_MAXCHAN];
pwr_tBoolean OldTestOn[IO_MAXCHAN]; pwr_tBoolean OldTestOn[IO_MAXCHAN];
int WriteFirst; int WriteFirst;
...@@ -121,14 +122,25 @@ static pwr_tStatus IoCardInit ( ...@@ -121,14 +122,25 @@ static pwr_tStatus IoCardInit (
io_sChannel *chanp; io_sChannel *chanp;
int i; int i;
io_sLocal *local; io_sLocal *local;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
op = (pwr_sClass_Ssab_BaseACard *) cp->op; op = (pwr_sClass_Ssab_BaseACard *) cp->op;
local = calloc( 1, sizeof(*local)); local = calloc( 1, sizeof(*local));
local->Address = op->RegAddress; local->Address = op->RegAddress;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp; local->Qbus_fp = r_local->Qbus_fp;
errh_Info( "Init of ao card '%s'", cp->Name); errh_Info( "Init of ao card '%s'", cp->Name);
/* Get item offset from rack's local and increment it, used by remote rack only
local->bfb_item = r_local->out_items;
r_local->out_items += op->MaxNoOfChannels;
/* Set card address in racks local in- and out-area, used by remote rack only
for (i=0; i<op->MaxNoOfChannels; i++) {
r_local->out.item[local->bfb_item+i].address = (pwr_tUInt16) ((op->RegAddress+i*2) & 0xFFFF);
r_local->out.item[local->bfb_item+i].data = 0;
}
*/
/* Write the first 50 loops */ /* Write the first 50 loops */
local->WriteFirst = 50; local->WriteFirst = 50;
cp->Local = local; cp->Local = local;
...@@ -179,6 +191,7 @@ static pwr_tStatus IoCardWrite ( ...@@ -179,6 +191,7 @@ static pwr_tStatus IoCardWrite (
) )
{ {
io_sLocal *local; io_sLocal *local;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
pwr_sClass_Ssab_BaseACard *op; pwr_sClass_Ssab_BaseACard *op;
int i; int i;
io_sChannel *chanp; io_sChannel *chanp;
...@@ -240,9 +253,17 @@ static pwr_tStatus IoCardWrite ( ...@@ -240,9 +253,17 @@ static pwr_tStatus IoCardWrite (
#if defined(OS_ELN) #if defined(OS_ELN)
vaxc$establish(machfailwrite); vaxc$establish(machfailwrite);
#endif #endif
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
wb.Data = data; wb.Data = data;
wb.Address = local->Address + 2*i; wb.Address = local->Address + 2*i;
sts = write( local->Qbus_fp, &wb, sizeof(wb)); 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 == -1) if ( sts == -1)
{ {
/* Exceptionhandler was called */ /* Exceptionhandler was called */
......
...@@ -9,16 +9,20 @@ struct bfb_item { ...@@ -9,16 +9,20 @@ struct bfb_item {
struct bfb_buf { struct bfb_buf {
pwr_tUInt16 service; pwr_tUInt16 service;
pwr_tUInt16 length; pwr_tUInt16 length;
struct bfb_item item[256]; struct bfb_item item[350];
}; };
typedef struct { typedef struct {
/* Elements for Qbus local I/O */
int Qbus_fp; /* File pointer for local qbus device */ int Qbus_fp; /* File pointer for local qbus device */
int s; /* Socket for remote qbus node */ int s; /* Socket for remote qbus node */
struct sockaddr_in my_addr; /* Elements for Qbus ethernet I/O */
struct sockaddr_in rem_addr; struct sockaddr_in my_addr; /* My socket */
struct bfb_buf in; /* Data area for remote qbus node */ struct sockaddr_in rem_addr; /* Remote socket */
struct bfb_buf out; /* -"- */ struct bfb_buf read_area; /* Data area for the last inputs read (i.e. ack of read request) */
int in_items; struct bfb_buf write_area; /* Data area for the last outputs read (i.e. ack of write request) */
int out_items; struct bfb_buf read_req; /* Data area for the read request */
struct bfb_buf write_req; /* Data area for the write request */
int next_read_req_item; /* Index for next position in read request area */
int next_write_req_item; /* Index for next position in write request area */
} io_sRackLocal; } io_sRackLocal;
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