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,96 +1457,113 @@ static pwr_tStatus io_init_card( ...@@ -1451,96 +1457,113 @@ 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;
} }
sts = gdh_GetAttrRefTid( &sigchancon, &sigclass); if ( sig_found) {
if ( EVEN(sts)) { sts = gdh_GetAttrRefTid( &sigchancon, &sigclass);
sts = gdh_DLUnrefObjectInfo( chandlid); if ( EVEN(sts))
sts = gdh_GetNextSibling( chan, &chan); sig_found = 0;
continue;
} }
sts = gdh_DLRefObjectInfoAttrref( &sigchancon, (void *) &sig_op, &sigdlid); if ( sig_found) {
if ( EVEN(sts)) { sts = gdh_DLRefObjectInfoAttrref( &sigchancon, (void *) &sig_op, &sigdlid);
sts = gdh_DLUnrefObjectInfo( chandlid); if ( EVEN(sts))
sts = gdh_GetNextSibling( chan, &chan); sig_found = 0;
continue;
} }
if ( fix_channels && !sig_found) {
sts = gdh_DLUnrefObjectInfo( chandlid);
sts = gdh_GetNextSibling( chan, &chan);
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->sop = sig_op;
chanp->SigDlid = sigdlid;
chanp->SigAref = sigchancon;
chanp->ChanClass = class; chanp->ChanClass = class;
chanp->SigClass = sigclass; if ( sig_found) {
switch( sigclass) { chanp->sop = sig_op;
case pwr_cClass_Di: chanp->SigDlid = sigdlid;
chanp->vbp = gdh_TranslateRtdbPointer( chanp->SigAref = sigchancon;
(pwr_tUInt32) ((pwr_sClass_Di *)sig_op)->ActualValue); chanp->SigClass = sigclass;
break; switch( sigclass) {
case pwr_cClass_Do: case pwr_cClass_Di:
chanp->vbp = gdh_TranslateRtdbPointer( chanp->vbp = gdh_TranslateRtdbPointer(
(pwr_tUInt32) ((pwr_sClass_Do *)sig_op)->ActualValue); (pwr_tUInt32) ((pwr_sClass_Di *)sig_op)->ActualValue);
break; break;
case pwr_cClass_Po: case pwr_cClass_Do:
chanp->vbp = gdh_TranslateRtdbPointer( chanp->vbp = gdh_TranslateRtdbPointer(
(pwr_tUInt32) ((pwr_sClass_Po *)sig_op)->ActualValue); (pwr_tUInt32) ((pwr_sClass_Do *)sig_op)->ActualValue);
break; break;
case pwr_cClass_Ai: case pwr_cClass_Po:
chanp->vbp = gdh_TranslateRtdbPointer( chanp->vbp = gdh_TranslateRtdbPointer(
(pwr_tUInt32) ((pwr_sClass_Ai *)sig_op)->ActualValue); (pwr_tUInt32) ((pwr_sClass_Po *)sig_op)->ActualValue);
break; break;
case pwr_cClass_Ao: case pwr_cClass_Ai:
chanp->vbp = gdh_TranslateRtdbPointer( chanp->vbp = gdh_TranslateRtdbPointer(
(pwr_tUInt32) ((pwr_sClass_Ao *)sig_op)->ActualValue); (pwr_tUInt32) ((pwr_sClass_Ai *)sig_op)->ActualValue);
break; break;
case pwr_cClass_Ii: case pwr_cClass_Ao:
chanp->vbp = gdh_TranslateRtdbPointer( chanp->vbp = gdh_TranslateRtdbPointer(
(pwr_tUInt32) ((pwr_sClass_Ii *)sig_op)->ActualValue); (pwr_tUInt32) ((pwr_sClass_Ao *)sig_op)->ActualValue);
break; break;
case pwr_cClass_Io: case pwr_cClass_Ii:
chanp->vbp = gdh_TranslateRtdbPointer( chanp->vbp = gdh_TranslateRtdbPointer(
(pwr_tUInt32) ((pwr_sClass_Io *)sig_op)->ActualValue); (pwr_tUInt32) ((pwr_sClass_Ii *)sig_op)->ActualValue);
break; break;
case pwr_cClass_Co: case pwr_cClass_Io:
chanp->vbp = gdh_TranslateRtdbPointer( chanp->vbp = gdh_TranslateRtdbPointer(
(pwr_tUInt32) ((pwr_sClass_Co *)sig_op)->RawValue); (pwr_tUInt32) ((pwr_sClass_Io *)sig_op)->ActualValue);
chanp->abs_vbp = gdh_TranslateRtdbPointer( break;
(pwr_tUInt32) ((pwr_sClass_Co *)sig_op)->AbsValue); case pwr_cClass_Co:
break; chanp->vbp = gdh_TranslateRtdbPointer(
default: (pwr_tUInt32) ((pwr_sClass_Co *)sig_op)->RawValue);
errh_Error( chanp->abs_vbp = gdh_TranslateRtdbPointer(
"IO init error: unknown signal class card %, chan nr %d", (pwr_tUInt32) ((pwr_sClass_Co *)sig_op)->AbsValue);
cp->Name, number); break;
sts = gdh_DLUnrefObjectInfo( chandlid); default:
sts = gdh_DLUnrefObjectInfo( sigdlid); errh_Error(
memset( chanp, 0, sizeof(*chanp)); "IO init error: unknown signal class card %, chan nr %d",
} cp->Name, number);
sts = gdh_DLUnrefObjectInfo( chandlid);
/* If the signal has a Sup-object as a child, this will be inserted sts = gdh_DLUnrefObjectInfo( sigdlid);
in the suplist */ memset( chanp, 0, sizeof(*chanp));
/* if ( process != io_mProcess_Plc) */ }
io_ConnectToSupLst( ctx->SupCtx, sigclass, sigchancon.Objid, sig_op);
/* If the signal has a Sup-object as a child, this will be inserted
in the suplist */
/* if ( process != io_mProcess_Plc) */
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