Commit 99ec0b4e authored by claes's avatar claes

Division of source tree and build tree in modules

parent bdd13f74
/*
* Proview $Id: dtt_rttsys.c,v 1.5 2005-10-25 15:28:10 claes Exp $
* Proview $Id: dtt_rttsys.c,v 1.6 2005-12-30 15:36:35 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -57,6 +57,7 @@
#include "co_cdh.h"
#include "co_time.h"
#include "rt_io_base.h"
#include "rt_io_util.h"
#include "rt_rtt.h"
#include "rt_rtt_edit.h"
#include "rt_rtt_menu.h"
......
/*
* Proview $Id: rt_io_m_ai_ai32up.c,v 1.3 2005-09-01 14:57:57 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ai_ai32up.c -- io methods for ssab cards.
OS Linux
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define IO_MAXCHAN 32
typedef struct {
unsigned int Address;
int Qbus_fp;
int ScanCount[IO_MAXCHAN];
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus AiRangeToCoef(
io_sChannel *chanp)
{
pwr_sClass_ChanAi *cop;
char buf[120];
pwr_tStatus sts;
pwr_tFloat32 PolyCoef1;
pwr_tFloat32 PolyCoef0;
cop = chanp->cop;
if ( cop)
{
cop->CalculateNewCoef = 0;
/* Coef for RawValue to SignalValue conversion */
cop->SigValPolyCoef0 = 0;
cop->SigValPolyCoef1 = cop->ChannelSigValRangeHigh / 30000;
/* Coef for SignalValue to ActualValue conversion */
if ( chanp->ChanClass != pwr_cClass_ChanAit && cop->SensorPolyType == 1)
{
if ( cop->SensorSigValRangeHigh != cop->SensorSigValRangeLow)
{
PolyCoef1 = (cop->ActValRangeHigh - cop->ActValRangeLow)/
(cop->SensorSigValRangeHigh - cop->SensorSigValRangeLow);
PolyCoef0 = cop->ActValRangeHigh - cop->SensorSigValRangeHigh *
PolyCoef1;
cop->SensorPolyCoef1 = cop->SigValPolyCoef1 * PolyCoef1;
cop->SensorPolyCoef0 = PolyCoef0 + PolyCoef1*
cop->SigValPolyCoef0;
}
else
{
sts = gdh_ObjidToName( chanp->ChanAref.Objid, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid SigValueRange in Ai channel %s", buf);
return IO__CHANRANGE;
}
}
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Ai_AI32uP *op;
io_sLocal *local;
int i;
io_sChannel *chanp;
op = (pwr_sClass_Ai_AI32uP *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
local->Address = op->RegAddress;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
errh_Info( "Init of ai card '%s'", cp->Name);
/* Caluclate polycoeff */
chanp = cp->chanlist;
for ( i = 0; i < cp->ChanListSize; i++)
{
AiRangeToCoef( chanp);
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
errh_Info( "IO closing ai card '%s'", cp->Name);
local = (io_sLocal *) cp->Local;
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tInt16 data = 0;
pwr_sClass_Ai_AI32uP *op;
int i;
pwr_tFloat32 actvalue;
io_sChannel *chanp;
pwr_sClass_ChanAi *cop;
pwr_sClass_Ai *sop;
int sts;
qbus_io_read rb;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ai_AI32uP *) cp->op;
chanp = &cp->chanlist[0];
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( !chanp->cop)
{
chanp++;
continue;
}
cop = (pwr_sClass_ChanAi *) chanp->cop;
sop = (pwr_sClass_Ai *) chanp->sop;
if ( cop->CalculateNewCoef)
AiRangeToCoef( chanp);
if ( cop->ConversionOn)
{
if ( local->ScanCount[i] <= 1)
{
#if defined(OS_ELN)
vaxc$establish(machfailread);
#endif
rb.Address = local->Address + 2*i;
sts = read( local->Qbus_fp, &rb, sizeof(rb));
data = (unsigned short) rb.Data;
if ( sts == -1)
{
#if 0
/* Exceptionhandler was called */
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal read error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
#endif
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
chanp++;
continue;
}
/* Convert rawvalue to sigvalue and actualvalue */
sop->RawValue = data;
sop->SigValue = data * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch ( chanp->ChanClass)
{
case pwr_cClass_ChanAi:
io_ConvertAi( cop, data, &actvalue);
break;
case pwr_cClass_ChanAit:
io_ConvertAit( (pwr_sClass_ChanAit *) cop, data, &actvalue);
break;
}
/* Filter */
if ( sop->FilterType == 1 &&
sop->FilterAttribute[0] > 0 &&
sop->FilterAttribute[0] > ctx->ScanTime)
{
actvalue = *(pwr_tFloat32 *)chanp->vbp +
ctx->ScanTime / sop->FilterAttribute[0] *
(actvalue - *(pwr_tFloat32 *)chanp->vbp);
}
*(pwr_tFloat32 *) chanp->vbp = actvalue;
local->ScanCount[i] = cop->ScanInterval + 1;
}
local->ScanCount[i]--;
}
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ai_AI32uP) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_ai_hvai32.c,v 1.4 2005-09-01 14:57:57 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ai_hvai32.c -- io methods for ssab cards.
OS Linux
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define MASKAI 0xFFF /* No polling bit in output data */
#define READYAI 0x8000 /* AI-read polling ready */
#define RMAX 100 /* Number of AI-read polling */
#define IO_MAXCHAN 32
typedef struct {
unsigned int Address;
int Qbus_fp;
int ScanCount[IO_MAXCHAN];
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus AiRangeToCoef(
io_sChannel *chanp)
{
pwr_sClass_ChanAi *cop;
char buf[120];
pwr_tStatus sts;
pwr_tFloat32 PolyCoef1;
pwr_tFloat32 PolyCoef0;
cop = chanp->cop;
if ( cop)
{
cop->CalculateNewCoef = 0;
/* Coef for RawValue to SignalValue conversion */
cop->SigValPolyCoef0 = cop->ChannelSigValRangeHigh * 1.024;
cop->SigValPolyCoef1 = - cop->ChannelSigValRangeHigh / 2048 * 1.024;
/* Coef for RawValue to ActualValue conversion */
if ( chanp->ChanClass != pwr_cClass_ChanAit && cop->SensorPolyType == 1)
{
if ( cop->SensorSigValRangeHigh != cop->SensorSigValRangeLow)
{
PolyCoef1 = (cop->ActValRangeHigh - cop->ActValRangeLow)/
(cop->SensorSigValRangeHigh - cop->SensorSigValRangeLow);
PolyCoef0 = cop->ActValRangeHigh - cop->SensorSigValRangeHigh *
PolyCoef1;
cop->SensorPolyCoef1 = cop->SigValPolyCoef1 * PolyCoef1;
cop->SensorPolyCoef0 = PolyCoef0 + PolyCoef1*
cop->SigValPolyCoef0;
}
else
{
sts = gdh_ObjidToName( chanp->ChanAref.Objid, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid SigValueRange in Ai channel %s", buf);
return IO__CHANRANGE;
}
}
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Ai_HVAI32 *op;
io_sLocal *local;
int i;
io_sChannel *chanp;
op = (pwr_sClass_Ai_HVAI32 *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
local->Address = op->RegAddress;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
errh_Info( "Init of ai card '%s'", cp->Name);
/* Caluclate polycoeff */
chanp = cp->chanlist;
for ( i = 0; i < cp->ChanListSize; i++)
{
AiRangeToCoef( chanp);
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
errh_Info( "IO closing ai card '%s'", cp->Name);
local = (io_sLocal *) cp->Local;
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tUInt16 data = 0;
pwr_sClass_Ai_HVAI32 *op;
int i, j;
pwr_tFloat32 actvalue;
io_sChannel *chanp;
pwr_sClass_ChanAi *cop;
pwr_sClass_Ai *sop;
int sts;
qbus_io_read rb;
qbus_io_write wb;
int timeout;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ai_HVAI32 *) cp->op;
chanp = &cp->chanlist[0];
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( !chanp->cop)
{
chanp++;
continue;
}
cop = (pwr_sClass_ChanAi *) chanp->cop;
sop = (pwr_sClass_Ai *) chanp->sop;
if ( cop->CalculateNewCoef)
AiRangeToCoef( chanp);
if ( cop->ConversionOn)
{
if ( local->ScanCount[i] <= 1)
{
#if defined(OS_ELN)
vaxc$establish(machfailread);
#endif
/* Write channel */
wb.Address = local->Address;
wb.Data = i;
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if ( sts != -1)
{
/* Read until ready-bit is set */
rb.Address = local->Address;
timeout = 1;
for ( j = 0; j < RMAX; j++)
{
sts = read( local->Qbus_fp, &rb, sizeof(rb));
if ( sts == -1)
break;
data = (unsigned short) rb.Data;
if( data & READYAI || sts == -1)
{
timeout = 0;
break;
}
}
}
data &= MASKAI;
if ( sts == -1 || timeout)
{
#if 0
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal read error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
#endif
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
chanp++;
continue;
}
/* Convert rawvalue to sigvalue and actualvalue */
sop->RawValue = data;
switch ( chanp->ChanClass)
{
case pwr_cClass_ChanAi:
io_ConvertAi( cop, (pwr_tInt16) data, &actvalue);
break;
case pwr_cClass_ChanAit:
io_ConvertAit( (pwr_sClass_ChanAit *) cop, (pwr_tInt16) data,
&actvalue);
break;
}
/* Check max/min */
if (actvalue > cop->ActValRangeHigh && cop->ActValRangeHigh > cop->ActValRangeLow)
actvalue = cop->ActValRangeHigh;
if (actvalue < cop->ActValRangeLow && cop->ActValRangeHigh > cop->ActValRangeLow)
actvalue = cop->ActValRangeLow;
/* Filter */
if ( sop->FilterType == 1 &&
sop->FilterAttribute[0] > 0 &&
sop->FilterAttribute[0] > ctx->ScanTime)
{
actvalue = *(pwr_tFloat32 *)chanp->vbp +
ctx->ScanTime / sop->FilterAttribute[0] *
(actvalue - *(pwr_tFloat32 *)chanp->vbp);
}
*(pwr_tFloat32 *) chanp->vbp = actvalue;
local->ScanCount[i] = cop->ScanInterval + 1;
}
local->ScanCount[i]--;
}
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ai_HVAI32) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_ao_hvao4.c,v 1.4 2005-09-01 14:57:57 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ao_hvao4.c -- io methods for ssab cards.
OS Linux
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "pwr.h"
#include "rt_errh.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_write.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define IO_MAXCHAN 8
typedef struct {
unsigned int Address;
int Qbus_fp;
pwr_tFloat32 OldValue[IO_MAXCHAN];
pwr_tBoolean OldTestOn[IO_MAXCHAN];
int WriteFirst;
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus AoRangeToCoef(
io_sChannel *chanp)
{
pwr_sClass_ChanAo *cop;
char buf[120];
pwr_tStatus sts;
pwr_tFloat32 PolyCoef1;
pwr_tFloat32 PolyCoef0;
cop = chanp->cop;
if ( cop)
{
cop->CalculateNewCoef = 0;
/* Coef for ActualValue to RawValue conversion */
if ( cop->ActValRangeHigh != cop->ActValRangeLow)
{
cop->SigValPolyCoef1 = (cop->SensorSigValRangeHigh - cop->SensorSigValRangeLow)/
(cop->ActValRangeHigh - cop->ActValRangeLow);
cop->SigValPolyCoef0 = cop->SensorSigValRangeHigh - cop->ActValRangeHigh *
cop->SigValPolyCoef1;
}
else
{
sts = gdh_ObjidToName( chanp->ChanAref.Objid, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid ActValueRange in Ao channel %s", buf);
return IO__CHANRANGE;
}
/* Coef for ActualValue to SignalValue conversion */
if ( cop->ChannelSigValRangeHigh != 0)
{
PolyCoef0 = 0;
PolyCoef1 = cop->RawValRangeHigh / cop->ChannelSigValRangeHigh;
cop->OutPolyCoef1 = cop->SigValPolyCoef1 * PolyCoef1;
cop->OutPolyCoef0 = PolyCoef0 + PolyCoef1*
cop->SigValPolyCoef0;
}
else
{
sts = gdh_ObjidToName( chanp->ChanAref.Objid, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid SigValueRange in Ao channel %s", buf);
return IO__CHANRANGE;
}
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Ao_HVAO4 *op;
io_sChannel *chanp;
int i;
io_sLocal *local;
op = (pwr_sClass_Ao_HVAO4 *) cp->op;
local = calloc( 1, sizeof(*local));
local->Address = op->RegAddress;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
errh_Info( "Init of ao card '%s'", cp->Name);
/* Write the first 50 loops */
local->WriteFirst = 50;
cp->Local = local;
/* Caluclate polycoeff */
chanp = cp->chanlist;
for ( i = 0; i < cp->ChanListSize; i++)
{
AoRangeToCoef( chanp);
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
local = (io_sLocal *) cp->Local;
errh_Info( "IO closing ao card '%s'", cp->Name);
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_sClass_Ao_HVAO4 *op;
int i;
io_sChannel *chanp;
pwr_sClass_ChanAo *cop;
pwr_sClass_Ao *sop;
pwr_tFloat32 value;
int fixout;
pwr_tUInt16 data;
pwr_tFloat32 rawvalue;
qbus_io_write wb;
int sts;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ao_HVAO4 *) cp->op;
fixout = ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT;
chanp = &cp->chanlist[0];
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( !chanp->cop)
{
chanp++;
continue;
}
cop = (pwr_sClass_ChanAo *) chanp->cop;
sop = (pwr_sClass_Ao *) chanp->sop;
if ( *(pwr_tFloat32 *)chanp->vbp != local->OldValue[i] ||
local->WriteFirst > 0 ||
cop->CalculateNewCoef ||
fixout ||
cop->TestOn || local->OldTestOn[i] != cop->TestOn)
{
if ( fixout)
value = cop->FixedOutValue;
else if ( cop->TestOn)
value = cop->TestValue;
else
value = *(pwr_tFloat32 *) chanp->vbp;
if ( cop->CalculateNewCoef)
AoRangeToCoef( chanp);
/* Convert to rawvalue */
if ( value > cop->ActValRangeHigh)
value = cop->ActValRangeHigh;
else if ( value < cop->ActValRangeLow)
value = cop->ActValRangeLow;
rawvalue = cop->OutPolyCoef1 * value + cop->OutPolyCoef0;
if ( rawvalue > 0)
sop->RawValue = rawvalue + 0.5;
else
sop->RawValue = rawvalue - 0.5;
data = sop->RawValue;
#if defined(OS_ELN)
vaxc$establish(machfailwrite);
#endif
wb.Data = data;
wb.Address = local->Address + 2*i;
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if ( sts == -1)
{
/* Exceptionhandler was called */
#if 0
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal write error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
#endif
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
chanp++;
continue;
}
else
local->OldValue[i] = value;
}
local->OldTestOn[i] = cop->TestOn;
chanp++;
}
if ( local->WriteFirst)
local->WriteFirst--;
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ao_HVAO4) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
pwr_dExport pwr_BindIoMethods(Ao_AO8uP) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
This diff is collapsed.
/*
* Proview $Id: rt_io_m_di_dix2.c,v 1.2 2005-09-01 14:57:57 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_di_dix2.c -- io methods for ssab cards.
OS Linux
*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include "pwr.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_filter_di.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
typedef struct {
unsigned int Address[2];
int Qbus_fp;
struct {
pwr_sClass_Di *sop[16];
void *Data[16];
pwr_tBoolean Found;
} Filter[2];
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Di_DIX2 *op;
io_sLocal *local;
int i, j;
op = (pwr_sClass_Di_DIX2 *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
errh_Info( "Init of di card '%s'", cp->Name);
local->Address[0] = op->RegAddress;
local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
/* Init filter */
for ( i = 0; i < 2; i++)
{
/* The filter handles one 16-bit word */
for ( j = 0; j < 16; j++)
local->Filter[i].sop[j] = cp->chanlist[i*16+j].sop;
io_InitDiFilter( local->Filter[i].sop, &local->Filter[i].Found,
local->Filter[i].Data, ctx->ScanTime);
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
int i;
local = (io_sLocal *) cp->Local;
errh_Info( "IO closing di card '%s'", cp->Name);
/* Free filter data */
for ( i = 0; i < 2; i++)
{
if ( local->Filter[i].Found)
io_CloseDiFilter( local->Filter[i].Data);
}
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tUInt16 data = 0;
pwr_sClass_Di_DIX2 *op;
pwr_tUInt16 invmask;
pwr_tUInt16 convmask;
int i;
int sts;
qbus_io_read rb;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Di_DIX2 *) cp->op;
for ( i = 0; i < 2; i++)
{
if ( i == 0)
{
convmask = op->ConvMask1;
invmask = op->InvMask1;
}
else
{
convmask = op->ConvMask2;
invmask = op->InvMask2;
if ( !convmask)
break;
if ( op->MaxNoOfChannels == 16)
break;
}
rb.Address = local->Address[i];
sts = read( local->Qbus_fp, &rb, sizeof(rb));
data = (unsigned short) rb.Data;
if ( sts == -1)
{
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
continue;
}
/* Invert */
data = data ^ invmask;
/* Filter ... */
if ( local->Filter[i].Found)
io_DiFilter( local->Filter[i].sop, &data, local->Filter[i].Data);
/* Move data to valuebase */
io_DiUnpackWord( cp, data, convmask, i);
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Di_DIX2) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_do_hvdo32.c,v 1.2 2005-09-01 14:57:57 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_do_hvdo32.c -- io methods for ssab cards.
OS Linux
*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include "pwr.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_filter_po.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_write.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
typedef struct {
unsigned int Address[2];
int Qbus_fp;
struct {
pwr_sClass_Po *sop[16];
void *Data[16];
pwr_tBoolean Found;
} Filter[2];
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Do_HVDO32 *op;
io_sLocal *local;
int i, j;
op = (pwr_sClass_Do_HVDO32 *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
errh_Info( "Init of do card '%s'", cp->Name);
local->Address[0] = op->RegAddress;
local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
/* Init filter for Po signals */
for ( i = 0; i < 2; i++)
{
/* The filter handles one 16-bit word */
for ( j = 0; j < 16; j++)
{
if ( cp->chanlist[i*16+j].SigClass == pwr_cClass_Po)
local->Filter[i].sop[j] = cp->chanlist[i*16+j].sop;
}
io_InitPoFilter( local->Filter[i].sop, &local->Filter[i].Found,
local->Filter[i].Data, ctx->ScanTime);
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
int i;
local = (io_sLocal *) cp->Local;
errh_Info( "IO closing do card '%s'", cp->Name);
/* Free filter data */
for ( i = 0; i < 2; i++)
{
if ( local->Filter[i].Found)
io_ClosePoFilter( local->Filter[i].Data);
}
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tUInt16 data = 0;
pwr_sClass_Do_HVDO32 *op;
pwr_tUInt16 invmask;
pwr_tUInt16 testmask;
pwr_tUInt16 testvalue;
int i;
qbus_io_write wb;
int sts;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Do_HVDO32 *) cp->op;
#if defined(OS_ELN)
vaxc$establish(machfailwrite);
#endif
for ( i = 0; i < 2; i++)
{
if ( ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT)
{
if ( i == 0)
data = op->FixedOutValue1;
else
data = op->FixedOutValue2;
}
else
io_DoPackWord( cp, &data, i);
if ( i == 0)
{
testmask = op->TestMask1;
invmask = op->InvMask1;
}
else
{
testmask = op->TestMask2;
invmask = op->InvMask2;
if ( op->MaxNoOfChannels == 16)
break;
}
/* Invert */
data = data ^ invmask;
/* Filter Po signals */
if ( local->Filter[i].Found)
io_PoFilter( local->Filter[i].sop, &data, local->Filter[i].Data);
/* Testvalues */
if ( testmask)
{
if ( i == 0)
testvalue = op->TestValue1;
else
testvalue = op->TestValue2;
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 0
/* Exceptionhandler was called */
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal write error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
#endif
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
continue;
}
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Do_HVDO32) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_rack_ssab.c,v 1.2 2005-09-01 14:57:57 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_rack_ssab.c -- io methods for ssab rack objects. */
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_errh.h"
#include "rt_io_rack_init.h"
#include "rt_io_msg.h"
typedef struct {
int Qbus_fp;
} io_sRackLocal;
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoRackInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp
)
{
io_sRackLocal *local;
/* Open Qbus driver */
local = calloc( 1, sizeof(*local));
rp->Local = local;
local->Qbus_fp = open("/dev/qbus", O_RDWR);
if ( local->Qbus_fp == -1)
{
errh_Error( "Qbus initialization error, IO rack %s", rp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
errh_Info( "Init of IO rack %s", rp->Name);
return 1;
}
static pwr_tStatus IoRackClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp
)
{
io_sRackLocal *local;
/* Close Qbus driver */
local = rp->Local;
close( local->Qbus_fp);
free( (char *)local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Rack_SSAB) = {
pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackClose),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_ssab.h,v 1.2 2005-09-01 14:57:57 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_ssab.h -- init, read and write ssab cards. */
typedef int DEVICE;
int ssab_close(
void *hv_device);
int ssabai_ini(
char *inidev,
void *adressini,
void *hv_device,
int relvec);
unsigned short ssabai_read(
void *reg_diP,
int grupp);
int ssabao_ini(
char *inidev,
void *adressini,
void *hv_device,
int relvec);
void ssabao_write(
short data,
void *reg_diP,
int channel);
int ssabd_ini(
char *inidev,
void *adressini,
void *hv_device,
int relvec);
unsigned short ssabdi_read(
void *reg_diP,
int grupp);
void ssabdo_write(
short data,
void *reg_diP,
int grupp);
void ssabco_read(
void *reg_diP,
int numofword,
int *co_id,
unsigned short *data,
int channel);
void ssabco_write(
unsigned short *data,
void *reg_P,
int channel);
unsigned short ssabaiup_read(
void *reg_diP,
int grupp);
/*
* Proview $Id: rt_io_base.c,v 1.16 2005-12-13 15:14:27 claes Exp $
* Proview $Id: rt_io_base.c,v 1.17 2005-12-30 15:36:36 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -61,60 +61,7 @@ pwr_tBoolean io_readerr;
pwr_tBoolean io_fatal_error;
pwr_dImport pwr_BindIoUserClasses(User);
pwr_dImport pwr_BindIoMethods(Node);
pwr_dImport pwr_BindIoMethods(Rack_SSAB);
pwr_dImport pwr_BindIoMethods(Di_DIX2);
pwr_dImport pwr_BindIoMethods(Do_HVDO32);
pwr_dImport pwr_BindIoMethods(Ao_HVAO4);
pwr_dImport pwr_BindIoMethods(Ao_AO8uP); // Share methods with HVAO4
pwr_dImport pwr_BindIoMethods(Ai_HVAI32);
pwr_dImport pwr_BindIoMethods(Ai_AI32uP);
pwr_dImport pwr_BindIoMethods(Co_PI24BO);
pwr_dImport pwr_BindIoMethods(Co_CO4uP); // Share methods with PI24BO
pwr_dImport pwr_BindIoMethods(Pb_Profiboard);
pwr_dImport pwr_BindIoMethods(Pb_DP_Slave);
pwr_dImport pwr_BindIoMethods(Pb_Module);
pwr_dImport pwr_BindIoMethods(Pb_Di);
pwr_dImport pwr_BindIoMethods(Pb_Do);
pwr_dImport pwr_BindIoMethods(Pb_Ai);
pwr_dImport pwr_BindIoMethods(Pb_Ao);
pwr_dImport pwr_BindIoMethods(Pb_Ii);
pwr_dImport pwr_BindIoMethods(Pb_Io);
pwr_dImport pwr_BindIoMethods(Ssab_AiuP);
pwr_dImport pwr_BindIoMethods(Ssab_AouP);
pwr_dImport pwr_BindIoMethods(Ssab_Di);
pwr_dImport pwr_BindIoMethods(Ssab_Do);
pwr_dImport pwr_BindIoMethods(Ssab_Co);
pwr_BindIoClasses(Base) = {
pwr_BindIoClass(Node),
pwr_BindIoClass(Rack_SSAB),
pwr_BindIoClass(Di_DIX2),
pwr_BindIoClass(Do_HVDO32),
pwr_BindIoClass(Ao_HVAO4),
pwr_BindIoClass(Ao_AO8uP),
pwr_BindIoClass(Ai_HVAI32),
pwr_BindIoClass(Ai_AI32uP),
pwr_BindIoClass(Co_PI24BO),
pwr_BindIoClass(Co_CO4uP),
pwr_BindIoClass(Pb_Profiboard),
pwr_BindIoClass(Pb_DP_Slave),
pwr_BindIoClass(Pb_Module),
pwr_BindIoClass(Pb_Di),
pwr_BindIoClass(Pb_Do),
pwr_BindIoClass(Pb_Ai),
pwr_BindIoClass(Pb_Ao),
pwr_BindIoClass(Pb_Ii),
pwr_BindIoClass(Pb_Io),
pwr_BindIoClass(Ssab_AiuP),
pwr_BindIoClass(Ssab_AouP),
pwr_BindIoClass(Ssab_Di),
pwr_BindIoClass(Ssab_Do),
pwr_BindIoClass(Ssab_Co),
pwr_NullClass
};
pwr_dImport pwr_BindIoClasses(Base);
typedef struct s_cardlist {
pwr_tObjid objid;
pwr_tUInt32 maxnoofchannels;
......@@ -1325,97 +1272,6 @@ static pwr_tStatus io_FindMethods(
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Find classes belonging to an specific IO-type.
\*----------------------------------------------------------------------------*/
pwr_tStatus io_GetIoTypeClasses(
io_eType type,
pwr_tClassId **classes,
int *size
)
{
pwr_tStatus sts;
pwr_sClassDef cdef;
pwr_tOid oid;
int add_class;
pwr_sAttrRef aref;
*size = 0;
*classes = calloc( IO_CLASSES_SIZE, sizeof(pwr_tCid));
for ( sts = gdh_GetClassList( pwr_eClass_ClassDef, &oid);
ODD(sts);
sts = gdh_GetNextObject( oid, &oid)) {
aref = cdh_ObjidToAref( oid);
sts = gdh_GetObjectInfoAttrref( &aref, &cdef, sizeof(cdef));
if ( EVEN(sts)) return sts;
add_class = 0;
switch ( type) {
case io_eType_Agent:
if ( cdef.Flags.b.IOAgent)
add_class = 1;
break;
case io_eType_Rack:
if ( cdef.Flags.b.IORack)
add_class = 1;
break;
case io_eType_Card:
if ( cdef.Flags.b.IOCard)
add_class = 1;
break;
default:
return IO__NOMETHOD;
}
if ( add_class) {
if ( *size >= IO_CLASSES_SIZE)
return IO__CLASSEXCEED;
(*classes)[ *size] = cdh_ClassObjidToId( oid);
(*size)++;
}
}
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Check if class is an IO-type.
\*----------------------------------------------------------------------------*/
int io_CheckClassIoType(
io_eType type,
pwr_tCid cid
)
{
pwr_tStatus sts;
pwr_sClassDef cdef;
pwr_sAttrRef aref;
aref = cdh_ObjidToAref( cdh_ClassIdToObjid( cid));
sts = gdh_GetObjectInfoAttrref( &aref, &cdef, sizeof(cdef));
if ( EVEN(sts)) return 0;
switch ( type) {
case io_eType_Agent:
if ( cdef.Flags.b.IOAgent)
return 1;
break;
case io_eType_Rack:
if ( cdef.Flags.b.IORack)
return 1;
break;
case io_eType_Card:
if ( cdef.Flags.b.IOCard)
return 1;
break;
default: ;
}
return 0;
}
/*----------------------------------------------------------------------------*\
Insert a card object into the context list.
......
/*
* Proview $Id: rt_io_base.h,v 1.5 2005-09-01 14:57:55 claes Exp $
* Proview $Id: rt_io_base.h,v 1.6 2005-12-30 15:36:36 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -40,6 +40,10 @@ typedef struct io_sCtx *io_tCtx;
#include "rt_io_supervise.h"
#endif
#ifndef rt_io_methods_h
#include "rt_io_methods.h"
#endif
#ifndef NULL
#define NULL (void *) 0
#endif
......@@ -53,46 +57,6 @@ extern pwr_tBoolean io_writeerr;
extern pwr_tBoolean io_readerr;
extern pwr_tBoolean io_fatal_error;
typedef struct {
pwr_tObjName MethodName;
pwr_tStatus (*Method)();
} pwr_sMethodBinding;
typedef struct {
pwr_tObjName ClassName;
pwr_sMethodBinding (*Methods)[];
} pwr_sClassBinding;
/* Base methods */
#if defined (__DECC) || defined (OS_LYNX) || defined (OS_LINUX)
# define pwr_BindIoMethods(Class) pwr_sMethodBinding pwr_g ## Class ## _IoMethods[]
# define pwr_BindIoClasses(Type) pwr_sClassBinding pwr_g ## Type ## _IoClassMethods[]
# define pwr_BindIoClass(Class) {#Class, (void *)pwr_g ## Class ## _IoMethods}
# define pwr_BindIoMethod(Method) {#Method, (pwr_tStatus (*)())Method}
#else
# define pwr_BindIoMethods(Class) pwr_sMethodBinding pwr_g/**/Class/**/_IoMethods[]
# define pwr_BindIoClasses(Type) pwr_sClassBinding pwr_g/**/Type/**/_IoClassMethods[]
# define pwr_BindIoClass(Class) {"Class", pwr_g/**/Class/**/_IoMethods}
# define pwr_BindIoMethod(Method) {"Method", (pwr_tStatus (*)())Method}
#endif
/* User methods */
#if defined (__DECC) || defined (OS_LYNX) || defined(OS_LINUX)
#define pwr_BindIoUserMethods(Class) pwr_sMethodBinding pwr_g ## Class ## _IoUserMethods[]
#define pwr_BindIoUserClasses(Type) pwr_sClassBinding pwr_g ## Type ## _IoUserClassMethods[]
#define pwr_BindIoUserClass(Class) {#Class, (void *)pwr_g ## Class ## _IoUserMethods}
#define pwr_BindIoUserMethod(Method) {#Method, (pwr_tStatus (*)())Method}
#else
#define pwr_BindIoUserMethods(Class) pwr_sMethodBinding pwr_g/**/Class/**/_IoUserMethods[]
#define pwr_BindIoUserClasses(Type) pwr_sClassBinding pwr_g/**/Type/**/_IoUserClassMethods[]
#define pwr_BindIoUserClass(Class) {"Class", pwr_g/**/Class/**/_IoUserMethods}
#define pwr_BindIoUserMethod(Method) {"Method", (pwr_tStatus (*)())Method}
#endif
#define pwr_NullMethod {"", NULL}
#define pwr_NullClass {"", NULL}
typedef enum {
io_eType_Node,
......
/*
* Proview $Id: rt_io_m_ai_ai32up.c,v 1.2 2005-09-01 14:57:55 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ai_ai32up.c -- io methods for ssab cards. */
#if defined(OS_ELN)
# include string
# include stdlib
# include stdio
#else
# include <string.h>
# include <stdlib.h>
# include <stdio.h>
#endif
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define IO_MAXCHAN 32
typedef struct {
char *Address;
DEVICE Device[64];
int ScanCount[IO_MAXCHAN];
} io_sLocal;
static pwr_tStatus AiRangeToCoef(
io_sChannel *chanp)
{
pwr_sClass_ChanAi *cop;
char buf[120];
pwr_tStatus sts;
pwr_tFloat32 PolyCoef1;
pwr_tFloat32 PolyCoef0;
cop = chanp->cop;
if ( cop)
{
cop->CalculateNewCoef = 0;
/* Coef for RawValue to SignalValue conversion */
cop->SigValPolyCoef0 = 0;
cop->SigValPolyCoef1 = cop->ChannelSigValRangeHigh / 30000;
/* Coef for SignalValue to ActualValue conversion */
if ( chanp->ChanClass != pwr_cClass_ChanAit && cop->SensorPolyType == 1)
{
if ( cop->SensorSigValRangeHigh != cop->SensorSigValRangeLow)
{
PolyCoef1 = (cop->ActValRangeHigh - cop->ActValRangeLow)/
(cop->SensorSigValRangeHigh - cop->SensorSigValRangeLow);
PolyCoef0 = cop->ActValRangeHigh - cop->SensorSigValRangeHigh *
PolyCoef1;
cop->SensorPolyCoef1 = cop->SigValPolyCoef1 * PolyCoef1;
cop->SensorPolyCoef0 = PolyCoef0 + PolyCoef1*
cop->SigValPolyCoef0;
}
else
{
sts = gdh_ObjidToName( chanp->ChanObjid, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid SigValueRange in Ai channel %s", buf);
return IO__CHANRANGE;
}
}
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_tStatus sts;
pwr_sClass_Ai_AI32uP *op;
io_sLocal *local;
int i;
io_sChannel *chanp;
op = (pwr_sClass_Ai_AI32uP *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
errh_Info( "Init of ai card '%s'", cp->Name);
sts = ssabai_ini( op->DevName, &local->Address, &local->Device,
ctx->RelativVector);
if ( EVEN(sts))
{
errh_Error( "IO init error of ai card '%s'\n%m", cp->Name, sts);
return sts;
}
/* Caluclate polycoeff */
chanp = cp->chanlist;
for ( i = 0; i < cp->ChanListSize; i++)
{
AiRangeToCoef( chanp);
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_tStatus sts;
io_sLocal *local;
errh_Info( "IO closing ai card '%s'", cp->Name);
local = (io_sLocal *) cp->Local;
sts = ssab_close( local->Device);
if ( EVEN(sts))
errh_Error("IO error deleting device %s\n%m", cp->Name, sts);
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tInt16 data = 0;
pwr_sClass_Ai_AI32uP *op;
int i;
pwr_tFloat32 actvalue;
io_sChannel *chanp;
pwr_sClass_ChanAi *cop;
pwr_sClass_Ai *sop;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ai_AI32uP *) cp->op;
chanp = &cp->chanlist[0];
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( !chanp->cop)
{
chanp++;
continue;
}
cop = (pwr_sClass_ChanAi *) chanp->cop;
sop = (pwr_sClass_Ai *) chanp->sop;
if ( cop->CalculateNewCoef)
AiRangeToCoef( chanp);
if ( cop->ConversionOn)
{
if ( local->ScanCount[i] <= 1)
{
#if defined(OS_ELN)
vaxc$establish(machfailread);
#endif
data = ssabaiup_read( local->Address, i);
if (io_readerr || io_fatal_error)
{
/* Exceptionhandler was called */
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal read error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
chanp++;
continue;
}
/* Convert rawvalue to sigvalue and actualvalue */
sop->RawValue = data;
sop->SigValue = data * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch ( chanp->ChanClass)
{
case pwr_cClass_ChanAi:
io_ConvertAi( cop, data, &actvalue);
break;
case pwr_cClass_ChanAit:
io_ConvertAit( (pwr_sClass_ChanAit *) cop, data, &actvalue);
break;
}
/* Filter */
if ( sop->FilterType == 1 &&
sop->FilterAttribute[0] > 0 &&
sop->FilterAttribute[0] > ctx->ScanTime)
{
actvalue = *(pwr_tFloat32 *)chanp->vbp +
ctx->ScanTime / sop->FilterAttribute[0] *
(actvalue - *(pwr_tFloat32 *)chanp->vbp);
}
*(pwr_tFloat32 *) chanp->vbp = actvalue;
local->ScanCount[i] = cop->ScanInterval + 1;
}
local->ScanCount[i]--;
}
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ai_AI32uP) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_ai_hvai32.c,v 1.2 2005-09-01 14:57:55 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ai_hvai32.c -- io methods for ssab cards. */
#if defined(OS_ELN)
# include string
# include stdlib
# include stdio
#else
# include <string.h>
# include <stdlib.h>
# include <stdio.h>
#endif
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define IO_MAXCHAN 32
typedef struct {
char *Address;
DEVICE Device[64];
int ScanCount[IO_MAXCHAN];
} io_sLocal;
static pwr_tStatus AiRangeToCoef(
io_sChannel *chanp)
{
pwr_sClass_ChanAi *cop;
char buf[120];
pwr_tStatus sts;
pwr_tFloat32 PolyCoef1;
pwr_tFloat32 PolyCoef0;
cop = chanp->cop;
if ( cop)
{
cop->CalculateNewCoef = 0;
/* Coef for RawValue to SignalValue conversion */
cop->SigValPolyCoef0 = cop->ChannelSigValRangeHigh * 1.024;
cop->SigValPolyCoef1 = - cop->ChannelSigValRangeHigh / 2048 * 1.024;
/* Coef for RawValue to ActualValue conversion */
if ( chanp->ChanClass != pwr_cClass_ChanAit && cop->SensorPolyType == 1)
{
if ( cop->SensorSigValRangeHigh != cop->SensorSigValRangeLow)
{
PolyCoef1 = (cop->ActValRangeHigh - cop->ActValRangeLow)/
(cop->SensorSigValRangeHigh - cop->SensorSigValRangeLow);
PolyCoef0 = cop->ActValRangeHigh - cop->SensorSigValRangeHigh *
PolyCoef1;
cop->SensorPolyCoef1 = cop->SigValPolyCoef1 * PolyCoef1;
cop->SensorPolyCoef0 = PolyCoef0 + PolyCoef1*
cop->SigValPolyCoef0;
}
else
{
sts = gdh_ObjidToName( chanp->ChanObjid, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid SigValueRange in Ai channel %s", buf);
return IO__CHANRANGE;
}
}
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_tStatus sts;
pwr_sClass_Ai_HVAI32 *op;
io_sLocal *local;
int i;
io_sChannel *chanp;
op = (pwr_sClass_Ai_HVAI32 *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
errh_Info( "Init of ai card '%s'", cp->Name);
sts = ssabai_ini( op->DevName, &local->Address, &local->Device,
ctx->RelativVector);
/*
ker$create_device( &sts, &devname_desc, ctx->RelativVector,
NULL, NULL, NULL, &local->Address, NULL, NULL, NULL,
&local->Device, 1, NULL);
*/
if ( EVEN(sts))
{
errh_Error( "IO init error of ai card '%s'\n%m", cp->Name, sts);
return sts;
}
/* Caluclate polycoeff */
chanp = cp->chanlist;
for ( i = 0; i < cp->ChanListSize; i++)
{
AiRangeToCoef( chanp);
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_tStatus sts;
io_sLocal *local;
errh_Info( "IO closing ai card '%s'", cp->Name);
local = (io_sLocal *) cp->Local;
sts = ssab_close( local->Device);
if ( EVEN(sts))
errh_Error("IO error deleting device %s\n%m", cp->Name, sts);
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tUInt16 data = 0;
pwr_sClass_Ai_HVAI32 *op;
int i;
pwr_tFloat32 actvalue;
io_sChannel *chanp;
pwr_sClass_ChanAi *cop;
pwr_sClass_Ai *sop;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ai_HVAI32 *) cp->op;
chanp = &cp->chanlist[0];
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( !chanp->cop)
{
chanp++;
continue;
}
cop = (pwr_sClass_ChanAi *) chanp->cop;
sop = (pwr_sClass_Ai *) chanp->sop;
if ( cop->CalculateNewCoef)
AiRangeToCoef( chanp);
if ( cop->ConversionOn)
{
if ( local->ScanCount[i] <= 1)
{
#if defined(OS_ELN)
vaxc$establish(machfailread);
#endif
data = ssabai_read( local->Address, i);
if (io_readerr || io_fatal_error)
{
/* Exceptionhandler was called */
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal read error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
chanp++;
continue;
}
/* Convert rawvalue to sigvalue and actualvalue */
sop->RawValue = data;
switch ( chanp->ChanClass)
{
case pwr_cClass_ChanAi:
io_ConvertAi( cop, (pwr_tInt16) data, &actvalue);
break;
case pwr_cClass_ChanAit:
io_ConvertAit( (pwr_sClass_ChanAit *) cop, (pwr_tInt16) data,
&actvalue);
break;
}
/* Filter */
if ( sop->FilterType == 1 &&
sop->FilterAttribute[0] > 0 &&
sop->FilterAttribute[0] > ctx->ScanTime)
{
actvalue = *(pwr_tFloat32 *)chanp->vbp +
ctx->ScanTime / sop->FilterAttribute[0] *
(actvalue - *(pwr_tFloat32 *)chanp->vbp);
}
*(pwr_tFloat32 *) chanp->vbp = actvalue;
local->ScanCount[i] = cop->ScanInterval + 1;
}
local->ScanCount[i]--;
}
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ai_HVAI32) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_ao_hvao4.c,v 1.3 2005-09-01 14:57:55 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ao_hvao4.c -- io methods for ssab cards. */
#if defined(OS_ELN)
# include string
# include stdlib
# include stdio
#else
# include <string.h>
# include <stdlib.h>
# include <stdio.h>
#endif
#include "pwr.h"
#include "rt_errh.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_write.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define IO_MAXCHAN 8
typedef struct {
char *Address;
DEVICE Device[64];
pwr_tFloat32 OldValue[IO_MAXCHAN];
pwr_tBoolean OldTestOn[IO_MAXCHAN];
int WriteFirst;
pwr_tTime ErrTime;
} io_sLocal;
static pwr_tStatus AoRangeToCoef(
io_sChannel *chanp)
{
pwr_sClass_ChanAo *cop;
char buf[120];
pwr_tStatus sts;
pwr_tFloat32 PolyCoef1;
pwr_tFloat32 PolyCoef0;
cop = chanp->cop;
if ( cop)
{
cop->CalculateNewCoef = 0;
/* Coef for ActualValue to RawValue conversion */
if ( cop->ActValRangeHigh != cop->ActValRangeLow)
{
cop->SigValPolyCoef1 = (cop->SensorSigValRangeHigh - cop->SensorSigValRangeLow)/
(cop->ActValRangeHigh - cop->ActValRangeLow);
cop->SigValPolyCoef0 = cop->SensorSigValRangeHigh - cop->ActValRangeHigh *
cop->SigValPolyCoef1;
}
else
{
sts = gdh_ObjidToName( chanp->ChanObjid, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid ActValueRange in Ao channel %s", buf);
return IO__CHANRANGE;
}
/* Coef for ActualValue to SignalValue conversion */
if ( cop->ChannelSigValRangeHigh != 0)
{
PolyCoef0 = 0;
PolyCoef1 = cop->RawValRangeHigh / cop->ChannelSigValRangeHigh;
cop->OutPolyCoef1 = cop->SigValPolyCoef1 * PolyCoef1;
cop->OutPolyCoef0 = PolyCoef0 + PolyCoef1*
cop->SigValPolyCoef0;
}
else
{
sts = gdh_ObjidToName( chanp->ChanObjid, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid SigValueRange in Ao channel %s", buf);
return IO__CHANRANGE;
}
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_tStatus sts;
pwr_sClass_Ao_HVAO4 *op;
io_sChannel *chanp;
int i;
io_sLocal *local;
op = (pwr_sClass_Ao_HVAO4 *) cp->op;
local = calloc( 1, sizeof(*local));
errh_Info( "Init of ao card '%s'", cp->Name);
sts = ssabao_ini( op->DevName, &local->Address, &local->Device,
ctx->RelativVector);
if ( EVEN(sts))
{
errh_Error( "IO init error of ao card '%s'\n%m", cp->Name, sts);
return sts;
}
/* Write the first 50 loops */
local->WriteFirst = 50;
cp->Local = local;
/* Caluclate polycoeff */
chanp = cp->chanlist;
for ( i = 0; i < cp->ChanListSize; i++)
{
AoRangeToCoef( chanp);
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_tStatus sts;
io_sLocal *local;
local = (io_sLocal *) cp->Local;
errh_Info( "IO closing ao card '%s'", cp->Name);
sts = ssab_close( local->Device);
if ( EVEN(sts))
errh_Error("IO error deleting device %s\n%m", cp->Name, sts);
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_sClass_Ao_HVAO4 *op;
int i;
io_sChannel *chanp;
pwr_sClass_ChanAo *cop;
pwr_sClass_Ao *sop;
pwr_tFloat32 value;
int fixout;
pwr_tUInt16 data;
pwr_tFloat32 rawvalue;
pwr_tTime now;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ao_HVAO4 *) cp->op;
fixout = ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT;
chanp = &cp->chanlist[0];
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( !chanp->cop)
{
chanp++;
continue;
}
cop = (pwr_sClass_ChanAo *) chanp->cop;
sop = (pwr_sClass_Ao *) chanp->sop;
if ( *(pwr_tFloat32 *)chanp->vbp != local->OldValue[i] ||
local->WriteFirst > 0 ||
cop->CalculateNewCoef ||
fixout ||
cop->TestOn || local->OldTestOn[i] != cop->TestOn)
{
if ( fixout)
value = cop->FixedOutValue;
else if ( cop->TestOn)
value = cop->TestValue;
else
value = *(pwr_tFloat32 *) chanp->vbp;
if ( cop->CalculateNewCoef)
AoRangeToCoef( chanp);
/* Convert to rawvalue */
if ( value > cop->ActValRangeHigh)
value = cop->ActValRangeHigh;
else if ( value < cop->ActValRangeLow)
value = cop->ActValRangeLow;
rawvalue = cop->OutPolyCoef1 * value + cop->OutPolyCoef0;
if ( rawvalue > 0)
sop->RawValue = rawvalue + 0.5;
else
sop->RawValue = rawvalue - 0.5;
data = sop->RawValue;
#if defined(OS_ELN)
vaxc$establish(machfailwrite);
#endif
ssabao_write( data, local->Address, i);
if (io_writeerr || io_fatal_error)
{
/* Exceptionhandler was called */
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal write error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
/* Increase error count and check error limits */
clock_gettime(CLOCK_REALTIME, &now);
if ( op->ErrorCount > op->ErrorSoftLimit) {
/* Ignore if some time has expired */
if ( now.tv_sec - local->ErrTime.tv_sec < 600)
op->ErrorCount++;
}
else
op->ErrorCount++;
local->ErrTime = now;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
chanp++;
continue;
}
else
local->OldValue[i] = value;
}
local->OldTestOn[i] = cop->TestOn;
chanp++;
}
if ( local->WriteFirst)
local->WriteFirst--;
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ao_HVAO4) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
This diff is collapsed.
/*
* Proview $Id: rt_io_m_di_dix2.c,v 1.2 2005-09-01 14:57:55 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_di_dix2.c -- io methods for ssab cards. */
#if defined(OS_ELN)
# include string
# include stdlib
# include stdio
#else
# include <string.h>
# include <stdlib.h>
# include <stdio.h>
#endif
#include "pwr.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_filter_di.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
typedef struct {
char *Address;
DEVICE Device[64];
struct {
pwr_sClass_Di *sop[16];
void *Data[16];
pwr_tBoolean Found;
} Filter[2];
} io_sLocal;
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_tStatus sts;
pwr_sClass_Di_DIX2 *op;
io_sLocal *local;
int i, j;
op = (pwr_sClass_Di_DIX2 *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
errh_Info( "Init of di card '%s'", cp->Name);
sts = ssabd_ini( op->DevName, &local->Address, &local->Device,
ctx->RelativVector);
if ( EVEN(sts))
{
errh_Error( "IO init error of di card '%s'\n%m", cp->Name, sts);
return sts;
}
/* Init filter */
for ( i = 0; i < 2; i++)
{
/* The filter handles one 16-bit word */
for ( j = 0; j < 16; j++)
local->Filter[i].sop[j] = cp->chanlist[i*16+j].sop;
io_InitDiFilter( local->Filter[i].sop, &local->Filter[i].Found,
local->Filter[i].Data, ctx->ScanTime);
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_tStatus sts;
io_sLocal *local;
int i;
local = (io_sLocal *) cp->Local;
errh_Info( "IO closing di card '%s'", cp->Name);
sts = ssab_close( local->Device);
if ( EVEN(sts))
errh_Error("IO error deleting device %s\n%m", cp->Name, sts);
/* Free filter data */
for ( i = 0; i < 2; i++)
{
if ( local->Filter[i].Found)
io_CloseDiFilter( local->Filter[i].Data);
}
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tUInt16 data = 0;
pwr_sClass_Di_DIX2 *op;
pwr_tUInt16 invmask;
pwr_tUInt16 convmask;
int i;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Di_DIX2 *) cp->op;
for ( i = 0; i < 2; i++)
{
if ( i == 0)
{
convmask = op->ConvMask1;
invmask = op->InvMask1;
}
else
{
convmask = op->ConvMask2;
invmask = op->InvMask2;
if ( !convmask)
break;
if ( op->MaxNoOfChannels == 16)
break;
}
#if defined(OS_ELN)
vaxc$establish(machfailread);
#endif
data = ssabdi_read( local->Address, i);
if (io_readerr || io_fatal_error)
{
/* Exceptionhandler was called */
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal read error, card '%s', IO i stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
continue;
}
/* Invert */
data = data ^ invmask;
/* Filter ... */
if ( local->Filter[i].Found)
io_DiFilter( local->Filter[i].sop, &data, local->Filter[i].Data);
/* Move data to valuebase */
io_DiUnpackWord( cp, data, convmask, i);
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Di_DIX2) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_do_hvdo32.c,v 1.2 2005-09-01 14:57:55 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_do_hvdo32.c -- io methods for ssab cards. */
#if defined(OS_ELN)
# include string
# include stdlib
# include stdio
#else
# include <string.h>
# include <stdlib.h>
# include <stdio.h>
#endif
#include "pwr.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_filter_po.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_write.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
typedef struct {
char *Address;
DEVICE Device[64];
struct {
pwr_sClass_Po *sop[16];
void *Data[16];
pwr_tBoolean Found;
} Filter[2];
} io_sLocal;
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_tStatus sts;
pwr_sClass_Do_HVDO32 *op;
io_sLocal *local;
int i, j;
op = (pwr_sClass_Do_HVDO32 *) cp->op;
local = calloc( 1, sizeof(*local));
errh_Info( "Init of do card '%s'", cp->Name);
sts = ssabd_ini( op->DevName, &local->Address, &local->Device,
ctx->RelativVector);
if ( EVEN(sts))
{
errh_Error( "IO init error of do card '%s'\n%m", cp->Name, sts);
return sts;
}
/* Init filter for Po signals */
for ( i = 0; i < 2; i++)
{
/* The filter handles one 16-bit word */
for ( j = 0; j < 16; j++)
{
if ( cp->chanlist[i*16+j].SigClass == pwr_cClass_Po)
local->Filter[i].sop[j] = cp->chanlist[i*16+j].sop;
}
io_InitPoFilter( local->Filter[i].sop, &local->Filter[i].Found,
local->Filter[i].Data, ctx->ScanTime);
}
cp->Local = local;
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_tStatus sts;
io_sLocal *local;
int i;
local = (io_sLocal *) cp->Local;
errh_Info( "IO closing do card '%s'", cp->Name);
sts = ssab_close( local->Device);
if ( EVEN(sts))
errh_Error("IO error deleting device %s\n%m", cp->Name, sts);
/* Free filter data */
for ( i = 0; i < 2; i++)
{
if ( local->Filter[i].Found)
io_ClosePoFilter( local->Filter[i].Data);
}
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tUInt16 data = 0;
pwr_sClass_Do_HVDO32 *op;
pwr_tUInt16 invmask;
pwr_tUInt16 testmask;
pwr_tUInt16 testvalue;
int i;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Do_HVDO32 *) cp->op;
#if defined(OS_ELN)
vaxc$establish(machfailwrite);
#endif
for ( i = 0; i < 2; i++)
{
if ( ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT)
{
if ( i == 0)
data = op->FixedOutValue1;
else
data = op->FixedOutValue2;
}
else
io_DoPackWord( cp, &data, i);
if ( i == 0)
{
testmask = op->TestMask1;
invmask = op->InvMask1;
}
else
{
testmask = op->TestMask2;
invmask = op->InvMask2;
if ( op->MaxNoOfChannels == 16)
break;
}
/* Invert */
data = data ^ invmask;
/* Filter Po signals */
if ( local->Filter[i].Found)
io_PoFilter( local->Filter[i].sop, &data, local->Filter[i].Data);
/* Testvalues */
if ( testmask)
{
if ( i == 0)
testvalue = op->TestValue1;
else
testvalue = op->TestValue2;
data = (data & ~ testmask) | (testmask & testvalue);
}
ssabdo_write( data, local->Address, i);
if (io_writeerr || io_fatal_error)
{
/* Exceptionhandler was called */
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal write error, card '%s', IO i stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
continue;
}
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Do_HVDO32) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_rack_ssab.c,v 1.2 2005-09-01 14:57:55 claes Exp $
* 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
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_rack_ssab.c -- io methods for ssab rack objects. */
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_io_base.h"
#include "rt_errh.h"
#include "rt_io_rack_init.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoRackInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp
)
{
/* This method just indicates that this is a Rack object */
errh_Info( "Init of IO rack %s", rp->Name);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Rack_SSAB) = {
pwr_BindIoMethod(IoRackInit),
pwr_NullMethod
};
This diff is collapsed.
/*
* Proview $Id: rt_types.h,v 1.2 2005-09-01 14:57:56 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef rt_types_h
#define rt_types_h
/* co_types.h -- Enum and mask translations */
#if defined __cplusplus
extern "C" {
#endif
typedef struct {
unsigned int num;
char name[40];
} types_sEnumElement;
typedef struct {
pwr_tClassId classid;
char name[40];
types_sEnumElement *elements;
} types_sEnum;
int types_find_enum( pwr_tClassId classid, char *name,
types_sEnumElement **elem_p);
int types_translate_enum( pwr_tClassId classid, char *name, unsigned int num,
char *buf);
int types_find_mask( pwr_tClassId classid, char *name,
types_sEnumElement **elem_p);
#if defined __cplusplus
}
#endif
#endif
This diff is collapsed.
!
! Proview $Id: pwrb_c_ai_ai32up.wb_load,v 1.6 2005-09-01 14:58:00 claes Exp $
! 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
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with the program, if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!
! pwrb_c_ai_ai32up.wb_load -- Defines the class Ai_AI32uP.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group IO,IO_PSS9000
! @Summary Configuration of an analog input card AI32uP
! Configuration of a PSS9000 analog input card AI32uP.
!
! 32 channel input module.
! The Ai_AI32uP object is positioned below a SSAB_Rack object in the node configuration.
! Each used cannel of the card is configured with a ChanAi or ChanAit object, placed below the
! Ai_AI32uP object.
!
! @b Range
! The ranges for raw value and signal value are configured in the channel objects.
!
! RawValueRangeLow -30000
! RawValueRangeHigh 30000
!
! The signal range can be 5 V, 10 V or 20 mA. This is configured with jumpers in the card,
! and in the channel object attributes ChannelSigValRangeLow and ChannelSigValRangeHigh.
!
! @b See hardware specification
! @Link AI32uP http://intern.oxelosund.ssab.se/pss/Hrdvara/PSS-kort-data.htm#AI32uP
!*/
Object Ai_AI32uP $ClassDef 277
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_RtAndDevBodies
Attr Flags |= pwr_mClassDef_IOCard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "Ai_AI32uP"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Device name. Used only in VAX_ELN nodes.
! The device name is the identification of the device in the ELN ebuild file.
!*/
Object DevName $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
!/**
! Error counter, incremented for every failed read operation of the card.
! When the error counter reaches ErrorSoftLimit, a message is sent to the console log.
! When it reaches ErrorHardLimit, all IO handling is aborted.
!*/
Object ErrorCount $Attribute 5
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
EndBody
EndObject
!/**
! Value of the error counter, when a message is sent to the console log.
!*/
Object ErrorSoftLimit $Attribute 6
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Value of the error counter, when all IO handling is aborted.
!*/
Object ErrorHardLimit $Attribute 7
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Maximum number of channels of the card.
!*/
Object MaxNoOfChannels $Attribute 11
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt16"
Attr Flags |= PWR_MASK_CONST
EndBody
EndObject
!/**
! @Summary QBUS address of the card.
! QBUS address of the card.
! The value is set with address switches on the card.
! Note! The value in RegAddress is a decimal value
!
! Card number Octal address Decimal Address
! 1 167000 4189696
! 2 167100 4189760
! 3 167200 4189824
! 4 167300 4189888
! 5 167400 4189952
! 6 167500 4190016
! 7 167600 4190080
! 8 167700 4190144
!
! For VAX_ELN RegAddress is used for documentation only, and usually specified as an octal value.
!*/
Object RegAddress $Attribute 12
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Vector address. Used on VAX_ELN only, and only for documentation.
!*/
Object VectAddress $Attribute 13
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! @Summary Process that handles the card. Plc(1), rt_io_comm(2) or application process(4).
! Process that handles the card.
!
! 1: The card is read by the plc process, and is handled by a specific
! thread in the plc, which is specified in the ThreadObject attribute.
! 2: The card is read by the rt_io_comm process.
! 4: The card is handled by an application program.
!*/
Object Process $Attribute 14
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! @Summary Plc thread that handles the card.
! The PlcThread object of the plc thread that handles the card.
! The card is read with the scantime of the thread.
!*/
Object ThreadObject $Intern 15
Body SysBody
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
!/**
! @Summary A URL to the data sheet for the equipment in this object.
! A URL to the data sheet for the equipment of this object.
! The data sheet can be displayed from the popup menu for this object.
!*/
Object DataSheet $Attribute 16
Body SysBody
Attr TypeRef = "pwrs:Type-$URL"
EndBody
EndObject
EndObject
Object DevBody $ObjBodyDef 2
Object ChannelAllocation $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_NOEDIT
EndBody
EndObject
EndObject
Object Template Ai_AI32uP
Body RtBody
Attr MaxNoOfChannels = 32
Attr ErrorSoftLimit = 15
Attr ErrorHardLimit = 50
Attr Process = 1
Attr DataSheet = "$pwr_lang/ssab_ai_ai32up.pdf"
EndBody
EndObject
Object AnteAdopt $DbCallBack
Body SysBody
Attr MethodName = "Ai_AI32uP-AnteAdopt"
EndBody
EndObject
Object PostUnadopt $DbCallBack
Body SysBody
Attr MethodName = "Ai_AI32uP-PostUnadopt"
EndBody
EndObject
Object PostAdopt $DbCallBack
Body SysBody
Attr MethodName = "Ai_AI32uP-PostAdopt"
EndBody
EndObject
Object ConfiguratorPoson $Menu
Object Pointed $Menu
Object Connect $MenuButton
Body SysBody
Attr ButtonName = "Connect PlcThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "PlcThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "PlcThread"
EndBody
EndObject
EndObject
EndObject
Object IoMethods $RtMethod
Object IoCardInit $Method
Body SysBody
Attr MethodName = "Ai_AI32uP-IoCardInit"
EndBody
EndObject
Object IoCardClose $Method
Body SysBody
Attr MethodName = "Ai_AI32uP-IoCardClose"
EndBody
EndObject
Object IoCardRead $Method
Body SysBody
Attr MethodName = "Ai_AI32uP-IoCardRead"
EndBody
EndObject
EndObject
EndObject
EndSObject
!
! Proview $Id: pwrb_c_ai_hvai32.wb_load,v 1.6 2005-09-01 14:58:00 claes Exp $
! 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
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with the program, if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!
! pwrb_c_ai_hvai32.wb_load -- Defines the class Ai_HVAI32.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group IO,IO_PSS9000
! @Summary Configuration of a analog input card AI32D, AI16D or AI8D.
! Configuration of a PSS9000 analog input card AI32D, AI16D or AI8D.
!
! The Ai_HVAI32 object is positioned below a SSAB_Rack object in the node configuration.
! Each used cannel of the card is configured with a ChanAi or ChanAit object, placed below the
! Ai_HVAI32 object.
!*/
Object Ai_HVAI32 $ClassDef 7
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_RtAndDevBodies
Attr Flags |= pwr_mClassDef_IOCard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "Ai_HVAI32"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Device name. Used only in VAX_ELN nodes.
! The device name is the identification of the device in the ELN ebuild file.
!*/
Object DevName $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
!/**
! Error counter, incremented for every failed read operation of the card.
! When the error counter reaches ErrorSoftLimit, a message is sent to the console log.
! When it reaches ErrorHardLimit, all IO handling is aborted.
!*/
Object ErrorCount $Attribute 5
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
EndBody
EndObject
!/**
! Value of the error counter, when a message is sent to the console log.
!*/
Object ErrorSoftLimit $Attribute 6
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Value of the error counter, when all IO handling is aborted.
!*/
Object ErrorHardLimit $Attribute 7
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Obsolete since V2.7.
!*/
Object DevPolyCoef0 $Attribute 9
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
!/**
! Obsolete since V2.7.
!*/
Object DevPolyCoef1 $Attribute 10
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
!/**
! Maximum number of channels. 32 for AI32D, 16 for AI16D and 8 for AI8D.
!*/
Object MaxNoOfChannels $Attribute 11
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt16"
Attr Flags |= PWR_MASK_CONST
EndBody
EndObject
!/**
! @Summary QBUS address of the card.
! QBUS address of the card.
! The value is set with address switches on the card.
! Note! The value in RegAddress is a decimal value
!
! Card number Octal address
! 1 176400
! 2 176402
! 3 176404
! 4 176406
! 5 176410
! 6 176412
!
! For VAX_ELN RegAddress is used for documentation only, and usually specified as an octal value.
!*/
Object RegAddress $Attribute 12
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Vector address. Used on VAX_ELN only, and only for documentation.
!*/
Object VectAddress $Attribute 13
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! @Summary Process that handles the card. Plc(1), rt_io_comm(2) or application process(4).
! Process that handles the card.
!
! 1: The card is read by the plc process, and is handled by a specific
! thread in the plc, which is specified in the ThreadObject attribute.
! 2: The card is read by the rt_io_comm process.
! 4: The card is handled by an application program.
!*/
Object Process $Attribute 14
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! @Summary Plc thread that handles the card.
! The PlcThread object of the plc thread that handles the card.
! The card read to with the scantime of the thread.
!*/
Object ThreadObject $Intern 15
Body SysBody
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
!/**
! @Summary A URL to the data sheet for the equipment in this object.
! A URL to the data sheet for the equipment of this object.
! The data sheet can be displayed from the popup menu for this object.
!*/
Object DataSheet $Attribute 16
Body SysBody
Attr TypeRef = "pwrs:Type-$URL"
EndBody
EndObject
EndObject
Object DevBody $ObjBodyDef 2
Object ChannelAllocation $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_NOEDIT
EndBody
EndObject
EndObject
Object Template Ai_HVAI32
Body RtBody
Attr MaxNoOfChannels = 32
Attr Process = 2
Attr DataSheet = "$pwr_lang/ssab_ai_hvai32.pdf"
EndBody
EndObject
Object AnteAdopt $DbCallBack
Body SysBody
Attr MethodName = "Ai_HVAI32-AnteAdopt"
EndBody
EndObject
Object PostUnadopt $DbCallBack
Body SysBody
Attr MethodName = "Ai_HVAI32-PostUnadopt"
EndBody
EndObject
Object PostAdopt $DbCallBack
Body SysBody
Attr MethodName = "Ai_HVAI32-PostAdopt"
EndBody
EndObject
Object ConfiguratorPoson $Menu
Object Pointed $Menu
Object Connect $MenuButton
Body SysBody
Attr ButtonName = "Connect PlcThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "PlcThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "PlcThread"
EndBody
EndObject
EndObject
EndObject
Object IoMethods $RtMethod
Object IoCardInit $Method
Body SysBody
Attr MethodName = "Ai_HVAI32-IoCardInit"
EndBody
EndObject
Object IoCardClose $Method
Body SysBody
Attr MethodName = "Ai_HVAI32-IoCardClose"
EndBody
EndObject
Object IoCardRead $Method
Body SysBody
Attr MethodName = "Ai_HVAI32-IoCardRead"
EndBody
EndObject
EndObject
EndObject
EndSObject
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
!
! Proview $Id: pwrb_c_rack_vme.wb_load,v 1.2 2005-09-01 14:58:02 claes Exp $
! 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
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with the program, if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!
! pwrb_c_rack_vme.wb_load -- Defines the class Rack_VME.
!
SObject pwrb:Class
Object Rack_VME $ClassDef 268
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr Flags |= pwr_mClassDef_IO
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "Rack_VME"
EndBody
Object IOSysType $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt16"
Attr Flags |= PWR_MASK_CONST
EndBody
EndObject
Object Description $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object MaxNoOfCards $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt16"
Attr Flags |= PWR_MASK_CONST
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
EndObject
Object Template Rack_VME
Body RtBody
Attr IOSysType = 5
Attr MaxNoOfCards = 65535
EndBody
EndObject
EndObject
EndSObject
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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