Commit a5da491b authored by claes's avatar claes

Insert all channels in io data structure for profibus io

parent ec39c855
/* /*
* Proview $Id: rt_io_base.c,v 1.20 2006-06-29 10:57:16 claes Exp $ * Proview $Id: rt_io_base.c,v 1.21 2006-06-30 12:17:12 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
...@@ -1314,6 +1314,10 @@ static pwr_tStatus io_init_card( ...@@ -1314,6 +1314,10 @@ static pwr_tStatus io_init_card(
pwr_tObjid thread; pwr_tObjid thread;
int ok; int ok;
int child_found = 0; int child_found = 0;
int fix_channels = 1;
int chan_cnt = 0;
int sig_found;
int idx;
sts = gdh_GetObjectClass( objid, &class); sts = gdh_GetObjectClass( objid, &class);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
...@@ -1357,8 +1361,10 @@ static pwr_tStatus io_init_card( ...@@ -1357,8 +1361,10 @@ static pwr_tStatus io_init_card(
strcpy( attrname, cname); strcpy( attrname, cname);
strcat( attrname, ".MaxNoOfCounters"); strcat( attrname, ".MaxNoOfCounters");
sts = gdh_GetObjectInfo( attrname, &maxchan, sizeof(maxchan)); sts = gdh_GetObjectInfo( attrname, &maxchan, sizeof(maxchan));
if ( EVEN(sts)) if ( EVEN(sts)) {
maxchan = IO_CHANLIST_SIZE; maxchan = IO_CHANLIST_SIZE;
fix_channels = 0;
}
} }
cp = calloc( 1, sizeof(io_sCard)); cp = calloc( 1, sizeof(io_sCard));
...@@ -1451,46 +1457,63 @@ static pwr_tStatus io_init_card( ...@@ -1451,46 +1457,63 @@ static pwr_tStatus io_init_card(
} }
child_found = 1; child_found = 1;
if ( (int) number > maxchan-1) { chan_cnt++;
if ( !fix_channels && chan_cnt > maxchan) {
errh_Error( "IO init error: max number of channels exceeded %s, chan nr %d",
cp->Name, chan_cnt);
sts = gdh_DLUnrefObjectInfo( chandlid);
break;
}
if ( fix_channels && (int) number > maxchan-1) {
/* Number out of range */ /* Number out of range */
errh_Error( errh_Error( "IO init error: number out of range %s, chan nr %d",
"IO init error: number out of range %s, chan nr %d",
cp->Name, number); cp->Name, number);
sts = gdh_DLUnrefObjectInfo( chandlid); sts = gdh_DLUnrefObjectInfo( chandlid);
sts = gdh_GetNextSibling( chan, &chan); sts = gdh_GetNextSibling( chan, &chan);
continue; continue;
} }
/* Find signal */ /* Find signal */
sig_found = 1;
if ( cdh_ObjidIsNull( sigchancon.Objid)) { if ( cdh_ObjidIsNull( sigchancon.Objid)) {
/* Not connected */ /* Not connected */
sts = gdh_DLUnrefObjectInfo( chandlid); sig_found = 0;
sts = gdh_GetNextSibling( chan, &chan);
continue;
} }
if ( sig_found) {
sts = gdh_GetAttrRefTid( &sigchancon, &sigclass); sts = gdh_GetAttrRefTid( &sigchancon, &sigclass);
if ( EVEN(sts)) { if ( EVEN(sts))
sts = gdh_DLUnrefObjectInfo( chandlid); sig_found = 0;
sts = gdh_GetNextSibling( chan, &chan);
continue;
} }
if ( sig_found) {
sts = gdh_DLRefObjectInfoAttrref( &sigchancon, (void *) &sig_op, &sigdlid); sts = gdh_DLRefObjectInfoAttrref( &sigchancon, (void *) &sig_op, &sigdlid);
if ( EVEN(sts)) { if ( EVEN(sts))
sig_found = 0;
}
if ( fix_channels && !sig_found) {
sts = gdh_DLUnrefObjectInfo( chandlid); sts = gdh_DLUnrefObjectInfo( chandlid);
sts = gdh_GetNextSibling( chan, &chan); sts = gdh_GetNextSibling( chan, &chan);
continue; continue;
} }
if ( fix_channels)
idx = number;
else
idx = chan_cnt - 1;
/* Insert */ /* Insert */
chanp = &cp->chanlist[number]; chanp = &cp->chanlist[idx];
chanp->cop = chan_op; chanp->cop = chan_op;
chanp->ChanDlid = chandlid; chanp->ChanDlid = chandlid;
chanp->ChanAref = cdh_ObjidToAref(chan); chanp->ChanAref = cdh_ObjidToAref(chan);
chanp->ChanClass = class;
if ( sig_found) {
chanp->sop = sig_op; chanp->sop = sig_op;
chanp->SigDlid = sigdlid; chanp->SigDlid = sigdlid;
chanp->SigAref = sigchancon; chanp->SigAref = sigchancon;
chanp->ChanClass = class;
chanp->SigClass = sigclass; chanp->SigClass = sigclass;
switch( sigclass) { switch( sigclass) {
case pwr_cClass_Di: case pwr_cClass_Di:
...@@ -1540,7 +1563,7 @@ static pwr_tStatus io_init_card( ...@@ -1540,7 +1563,7 @@ static pwr_tStatus io_init_card(
in the suplist */ in the suplist */
/* if ( process != io_mProcess_Plc) */ /* if ( process != io_mProcess_Plc) */
io_ConnectToSupLst( ctx->SupCtx, sigclass, sigchancon.Objid, sig_op); io_ConnectToSupLst( ctx->SupCtx, sigclass, sigchancon.Objid, sig_op);
}
sts = gdh_GetNextSibling( chan, &chan); sts = gdh_GetNextSibling( chan, &chan);
} }
...@@ -1549,10 +1572,8 @@ static pwr_tStatus io_init_card( ...@@ -1549,10 +1572,8 @@ static pwr_tStatus io_init_card(
gdh_sAttrDef *bd; gdh_sAttrDef *bd;
int rows; int rows;
int csize; int csize;
int chan_cnt = 0;
int i, j; int i, j;
int elem; int elem;
int sig_found;
sts = gdh_GetObjectBodyDef( cp->Class, &bd, &rows, pwr_cNObjid); sts = gdh_GetObjectBodyDef( cp->Class, &bd, &rows, pwr_cNObjid);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
...@@ -1645,6 +1666,7 @@ static pwr_tStatus io_init_card( ...@@ -1645,6 +1666,7 @@ static pwr_tStatus io_init_card(
if ( !sig_found) { if ( !sig_found) {
sig_op = 0; sig_op = 0;
sigdlid = pwr_cNDlid; sigdlid = pwr_cNDlid;
sigclass = 0;
} }
/* Insert */ /* Insert */
if ( elem > 1) if ( elem > 1)
......
/* /*
* Proview $Id: rt_io_base.h,v 1.7 2006-02-08 13:53:57 claes Exp $ * Proview $Id: rt_io_base.h,v 1.8 2006-06-30 12:17:12 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
...@@ -48,7 +48,7 @@ typedef struct io_sCtx *io_tCtx; ...@@ -48,7 +48,7 @@ typedef struct io_sCtx *io_tCtx;
#define NULL (void *) 0 #define NULL (void *) 0
#endif #endif
#define IO_CHANLIST_SIZE 32 #define IO_CHANLIST_SIZE 50
#define FIXOUT 2 #define FIXOUT 2
#define IO_REBOOT 1 /* Reboot the machine */ #define IO_REBOOT 1 /* Reboot the machine */
......
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