Commit 0c879344 authored by Claes Sjofors's avatar Claes Sjofors

IO digital channel for di or do added

parent f62e469f
...@@ -852,26 +852,10 @@ static pwr_tStatus mb_init_channels( io_tCtx ctx, io_sAgent *ap, io_sRack *rp) ...@@ -852,26 +852,10 @@ static pwr_tStatus mb_init_channels( io_tCtx ctx, io_sAgent *ap, io_sRack *rp)
io_sServerModuleLocal *local_card; io_sServerModuleLocal *local_card;
io_sCard *cardp; io_sCard *cardp;
io_sServerLocal *local; io_sServerLocal *local;
short input_counter;
short output_counter;
short card_input_counter;
short card_output_counter;
pwr_sClass_Modbus_TCP_Server *op; pwr_sClass_Modbus_TCP_Server *op;
pwr_sClass_Modbus_TCP_ServerModule *mp;
char name[196]; char name[196];
pwr_tStatus sts; pwr_tStatus sts;
pwr_tCid cid;
io_sChannel *chanp;
int i, latent_input_counter, latent_output_counter;
pwr_tInt32 chan_size;
pwr_sClass_ChanDi *chan_di;
pwr_sClass_ChanDo *chan_do;
pwr_sClass_ChanAi *chan_ai;
pwr_sClass_ChanAit *chan_ait;
pwr_sClass_ChanIi *chan_ii;
pwr_sClass_ChanAo *chan_ao;
pwr_sClass_ChanIo *chan_io;
sts = gdh_ObjidToName(rp->Objid, (char *) &name, sizeof(name), cdh_mNName); sts = gdh_ObjidToName(rp->Objid, (char *) &name, sizeof(name), cdh_mNName);
...@@ -901,159 +885,6 @@ static pwr_tStatus mb_init_channels( io_tCtx ctx, io_sAgent *ap, io_sRack *rp) ...@@ -901,159 +885,6 @@ static pwr_tStatus mb_init_channels( io_tCtx ctx, io_sAgent *ap, io_sRack *rp)
local_card->output_area = (void *) &(op->Outputs) + output_area_offset + local_card->output_area = (void *) &(op->Outputs) + output_area_offset +
output_area_chansize; output_area_chansize;
#if 0
input_counter = 0;
output_counter = 0;
card_input_counter = 0;
card_output_counter = 0;
latent_input_counter = 0;
latent_output_counter = 0;
input_counter = input_counter + card_input_counter + latent_input_counter;
output_counter = output_counter + card_output_counter + latent_output_counter;
local_card->input_area = (void *) &(op->Inputs) + input_counter;
local_card->output_area = (void *) &(op->Outputs) + output_counter;
card_input_counter = 0;
card_output_counter = 0;
latent_input_counter = 0;
latent_output_counter = 0;
/* From v4.1.3 we can have subclasses, find the super class */
cid = cardp->Class;
while ( ODD( gdh_GetSuperClass( cid, &cid, cardp->Objid))) ;
switch (cid) {
case pwr_cClass_Modbus_TCP_ServerModule:
mp = (pwr_sClass_Modbus_TCP_ServerModule *) cardp->op;
mp->Status = pwr_eModbusModule_StatusEnum_StatusUnknown;
for (i = 0; i < cardp->ChanListSize; i++) {
chanp = &cardp->chanlist[i];
if ( is_diag( &chanp->ChanAref)) {
chanp->udata |= PB_UDATA_DIAG;
switch (chanp->ChanClass) {
case pwr_cClass_ChanIi:
chanp->offset = ((pwr_sClass_ChanIi *)chanp->cop)->Number;
chanp->size = GetChanSize( ((pwr_sClass_ChanIi *)chanp->cop)->Representation);
break;
default:
errh_Error( "Diagnostic channel class, card %s", cardp->Name);
}
continue;
}
if (chanp->ChanClass != pwr_cClass_ChanDi) {
card_input_counter += latent_input_counter;
latent_input_counter = 0;
}
if (chanp->ChanClass != pwr_cClass_ChanDo) {
card_output_counter += latent_output_counter;
latent_output_counter = 0;
}
switch (chanp->ChanClass) {
case pwr_cClass_ChanDi:
chan_di = (pwr_sClass_ChanDi *) chanp->cop;
if (chan_di->Number == 0) {
card_input_counter += latent_input_counter;
latent_input_counter = 0;
}
chanp->offset = card_input_counter;
chanp->mask = 1 << chan_di->Number;
if (chan_di->Representation == pwr_eDataRepEnum_Bit16)
chanp->mask = swap16(chanp->mask);
if (chan_di->Representation == pwr_eDataRepEnum_Bit32)
chanp->mask = swap32((unsigned short) chanp->mask);
if (chan_di->Number == 0) latent_input_counter = GetChanSize(chan_di->Representation);
if (local_card->di_size == 0)
local_card->di_offset = chanp->offset;
if (chan_di->Number == 0 || local_card->di_size == 0)
local_card->di_size += GetChanSize(chan_di->Representation);
// printf("Di channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_di->Number, chanp->offset);
break;
case pwr_cClass_ChanAi:
chan_ai = (pwr_sClass_ChanAi *) chanp->cop;
chanp->offset = card_input_counter;
chan_size = GetChanSize(chan_ai->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_input_counter += chan_size;
io_AiRangeToCoef(chanp);
// printf("Ai channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_ai->Number, chanp->offset);
break;
case pwr_cClass_ChanAit:
chan_ait = (pwr_sClass_ChanAit *) chanp->cop;
chanp->offset = card_input_counter;
chan_size = GetChanSize(chan_ait->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_input_counter += chan_size;
io_AiRangeToCoef(chanp);
break;
case pwr_cClass_ChanIi:
chan_ii = (pwr_sClass_ChanIi *) chanp->cop;
chanp->offset = card_input_counter;
chan_size = GetChanSize(chan_ii->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_input_counter += chan_size;
// printf("Ii channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_ii->Number, chanp->offset);
break;
case pwr_cClass_ChanDo:
chan_do = (pwr_sClass_ChanDo *) chanp->cop;
if (chan_do->Number == 0) {
card_output_counter += latent_output_counter;
latent_output_counter = 0;
}
chanp->offset = card_output_counter;
chan_size = GetChanSize(chan_do->Representation);
chanp->mask = 1 << chan_do->Number;
if (chan_do->Representation == pwr_eDataRepEnum_Bit16)
chanp->mask = swap16(chanp->mask);
if (chan_do->Representation == pwr_eDataRepEnum_Bit32)
chanp->mask = swap32((unsigned short) chanp->mask);
if (chan_do->Number == 0) latent_output_counter = GetChanSize(chan_do->Representation);
if (local_card->do_size == 0)
local_card->do_offset = chanp->offset;
if (chan_do->Number == 0 || local_card->do_size == 0)
local_card->do_size += GetChanSize(chan_do->Representation);
// printf("Do channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_do->Number, chanp->offset);
break;
case pwr_cClass_ChanAo:
chan_ao = (pwr_sClass_ChanAo *) chanp->cop;
chanp->offset = card_output_counter;
chan_size = GetChanSize(chan_ao->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_output_counter += chan_size;
io_AoRangeToCoef(chanp);
// printf("Ao channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_ao->Number, chanp->offset);
break;
case pwr_cClass_ChanIo:
chan_io = (pwr_sClass_ChanIo *) chanp->cop;
chanp->offset = card_output_counter;
chan_size = GetChanSize(chan_io->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_output_counter += chan_size;
// printf("Io channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_io->Number, chanp->offset);
break;
}
} /* End - for ... */
break;
} /* End - switch ... */
#endif
io_bus_card_init( ctx, cardp, &input_area_offset, &input_area_chansize, io_bus_card_init( ctx, cardp, &input_area_offset, &input_area_chansize,
&output_area_offset, &output_area_chansize, &output_area_offset, &output_area_chansize,
...@@ -1065,11 +896,6 @@ static pwr_tStatus mb_init_channels( io_tCtx ctx, io_sAgent *ap, io_sRack *rp) ...@@ -1065,11 +896,6 @@ static pwr_tStatus mb_init_channels( io_tCtx ctx, io_sAgent *ap, io_sRack *rp)
local_card->output_size = output_area_offset + output_area_chansize - local_card->output_size = output_area_offset + output_area_chansize -
prev_output_area_offset; prev_output_area_offset;
#if 0
local_card->input_size = card_input_counter + latent_input_counter;
local_card->output_size = card_output_counter + latent_output_counter;
#endif
prev_input_area_offset = input_area_offset + input_area_chansize; prev_input_area_offset = input_area_offset + input_area_chansize;
prev_output_area_offset = output_area_offset + output_area_chansize; prev_output_area_offset = output_area_offset + output_area_chansize;
...@@ -1079,10 +905,6 @@ static pwr_tStatus mb_init_channels( io_tCtx ctx, io_sAgent *ap, io_sRack *rp) ...@@ -1079,10 +905,6 @@ static pwr_tStatus mb_init_channels( io_tCtx ctx, io_sAgent *ap, io_sRack *rp)
local->input_size = input_area_offset + input_area_chansize; local->input_size = input_area_offset + input_area_chansize;
local->output_size = output_area_offset + output_area_chansize; local->output_size = output_area_offset + output_area_chansize;
#if 0
local->input_size = input_counter + card_input_counter + latent_input_counter;
local->output_size = output_counter + card_output_counter + latent_output_counter;
#endif
return IO__SUCCESS; return IO__SUCCESS;
} }
......
...@@ -726,6 +726,12 @@ static pwr_tStatus IoRackInit ( ...@@ -726,6 +726,12 @@ static pwr_tStatus IoRackInit (
case pwr_cClass_ChanDo: case pwr_cClass_ChanDo:
no_do++; no_do++;
break; break;
case pwr_cClass_ChanD:
if ( ((pwr_sClass_ChanD *)chanp->cop)->Type == pwr_eDChanTypeEnum_Di)
no_di++;
else
no_do++;
break;
} }
} }
local_card->msg[0].input_size = input_area_offset + input_area_chansize - local_card->msg[0].input_size = input_area_offset + input_area_chansize -
...@@ -772,6 +778,11 @@ static pwr_tStatus IoRackInit ( ...@@ -772,6 +778,11 @@ static pwr_tStatus IoRackInit (
case pwr_cClass_ChanDo: case pwr_cClass_ChanDo:
no_do++; no_do++;
break; break;
case pwr_cClass_ChanD:
if ( ((pwr_sClass_ChanD *)chanp->cop)->Type == pwr_eDChanTypeEnum_Di)
no_di++;
else
no_do++;
} }
} }
local_card->msg[0].input_size = input_area_offset + input_area_chansize - local_card->msg[0].input_size = input_area_offset + input_area_chansize -
......
...@@ -433,6 +433,7 @@ pwr_tStatus io_init_di_signals( ...@@ -433,6 +433,7 @@ pwr_tStatus io_init_di_signals(
pwr_sClass_DiArea *area_op; pwr_sClass_DiArea *area_op;
pwr_sClass_Di *sig_op; pwr_sClass_Di *sig_op;
pwr_sClass_ChanDi *chan_op; pwr_sClass_ChanDi *chan_op;
pwr_sClass_ChanD *chan_opd;
pwr_sAttrRef sig_aref; pwr_sAttrRef sig_aref;
pwr_tAName buf; pwr_tAName buf;
pwr_tUInt32 sig_count = 0; pwr_tUInt32 sig_count = 0;
...@@ -464,6 +465,14 @@ pwr_tStatus io_init_di_signals( ...@@ -464,6 +465,14 @@ pwr_tStatus io_init_di_signals(
sts = gdh_GetNextAttrRef( pwr_cClass_ChanDi, &sig_aref, &sig_aref); sts = gdh_GetNextAttrRef( pwr_cClass_ChanDi, &sig_aref, &sig_aref);
} }
sts = gdh_GetClassListAttrRef( pwr_cClass_ChanD, &sig_aref);
while (ODD(sts)) {
sts = gdh_AttrRefToPointer( &sig_aref, (void *) &chan_opd);
if ( ODD(sts) && chan_opd->Type == pwr_eDChanTypeEnum_Di)
chan_opd->SigChanCon.Objid = pwr_cNObjid;
sts = gdh_GetNextAttrRef( pwr_cClass_ChanD, &sig_aref, &sig_aref);
}
sts = gdh_GetClassListAttrRef( pwr_cClass_Di, &sig_aref); sts = gdh_GetClassListAttrRef( pwr_cClass_Di, &sig_aref);
while (ODD(sts)) { while (ODD(sts)) {
sts = gdh_AttrrefToName( &sig_aref, buf, sizeof(buf), cdh_mNName); sts = gdh_AttrrefToName( &sig_aref, buf, sizeof(buf), cdh_mNName);
...@@ -480,7 +489,7 @@ pwr_tStatus io_init_di_signals( ...@@ -480,7 +489,7 @@ pwr_tStatus io_init_di_signals(
else { else {
sts = gdh_GetAttrRefTid( &sig_op->SigChanCon, &class); sts = gdh_GetAttrRefTid( &sig_op->SigChanCon, &class);
if (EVEN(sts) || if (EVEN(sts) ||
(class != pwr_cClass_ChanDi)) { (!(class == pwr_cClass_ChanDi || class == pwr_cClass_ChanD))) {
errh_Error("IO init: Signal SigChanCon error '%s'", buf); errh_Error("IO init: Signal SigChanCon error '%s'", buf);
} }
else { else {
...@@ -489,12 +498,25 @@ pwr_tStatus io_init_di_signals( ...@@ -489,12 +498,25 @@ pwr_tStatus io_init_di_signals(
errh_Error("IO init: Signal SigChanCon error '%s'", buf); errh_Error("IO init: Signal SigChanCon error '%s'", buf);
} }
else { else {
if ( cdh_ObjidIsNotNull( chan_op->SigChanCon.Objid)) { if ( class == pwr_cClass_Di) {
pwr_tAName oldsig; if ( cdh_ObjidIsNotNull( chan_op->SigChanCon.Objid)) {
sts = gdh_AttrrefToName( &chan_op->SigChanCon, oldsig, sizeof(oldsig), cdh_mNName); pwr_tAName oldsig;
errh_Error( "IO init: Double signal connection '%s' and '%s'", buf, oldsig); sts = gdh_AttrrefToName( &chan_op->SigChanCon, oldsig, sizeof(oldsig), cdh_mNName);
errh_Error( "IO init: Double signal connection '%s' and '%s'", buf, oldsig);
}
chan_op->SigChanCon = sig_aref;
}
else {
if ( ((pwr_sClass_ChanD *)chan_op)->Type != pwr_eDChanTypeEnum_Di)
errh_Error( "IO init: ChanD type is not Di '%s'", buf);
else if ( cdh_ObjidIsNotNull( ((pwr_sClass_ChanD *)chan_op)->SigChanCon.Objid)) {
pwr_tAName oldsig;
sts = gdh_AttrrefToName( &((pwr_sClass_ChanD *)chan_op)->SigChanCon, oldsig, sizeof(oldsig),
cdh_mNName);
errh_Error( "IO init: Double signal connection '%s' and '%s'", buf, oldsig);
}
((pwr_sClass_ChanD *)chan_op)->SigChanCon = sig_aref;
} }
chan_op->SigChanCon = sig_aref;
} }
} }
} }
...@@ -528,6 +550,7 @@ pwr_tStatus io_init_do_signals( ...@@ -528,6 +550,7 @@ pwr_tStatus io_init_do_signals(
pwr_sClass_DoArea *area_op; pwr_sClass_DoArea *area_op;
pwr_sClass_Do *sig_op; pwr_sClass_Do *sig_op;
pwr_sClass_ChanDo *chan_op; pwr_sClass_ChanDo *chan_op;
pwr_sClass_ChanD *chan_opd;
pwr_sAttrRef sig_aref; pwr_sAttrRef sig_aref;
pwr_tAName buf; pwr_tAName buf;
pwr_tUInt32 sig_count = 0; pwr_tUInt32 sig_count = 0;
...@@ -559,6 +582,14 @@ pwr_tStatus io_init_do_signals( ...@@ -559,6 +582,14 @@ pwr_tStatus io_init_do_signals(
sts = gdh_GetNextAttrRef( pwr_cClass_ChanDo, &sig_aref, &sig_aref); sts = gdh_GetNextAttrRef( pwr_cClass_ChanDo, &sig_aref, &sig_aref);
} }
sts = gdh_GetClassListAttrRef( pwr_cClass_ChanD, &sig_aref);
while (ODD(sts)) {
sts = gdh_AttrRefToPointer( &sig_aref, (void *) &chan_opd);
if ( ODD(sts) && chan_opd->Type == pwr_eDChanTypeEnum_Do)
chan_opd->SigChanCon.Objid = pwr_cNObjid;
sts = gdh_GetNextAttrRef( pwr_cClass_ChanD, &sig_aref, &sig_aref);
}
sts = gdh_GetClassListAttrRef( pwr_cClass_Do, &sig_aref); sts = gdh_GetClassListAttrRef( pwr_cClass_Do, &sig_aref);
while (ODD(sts)) { while (ODD(sts)) {
...@@ -576,7 +607,7 @@ pwr_tStatus io_init_do_signals( ...@@ -576,7 +607,7 @@ pwr_tStatus io_init_do_signals(
else { else {
sts = gdh_GetAttrRefTid( &sig_op->SigChanCon, &class); sts = gdh_GetAttrRefTid( &sig_op->SigChanCon, &class);
if (EVEN(sts) || if (EVEN(sts) ||
(class != pwr_cClass_ChanDo)) { (!(class == pwr_cClass_ChanDo || class == pwr_cClass_ChanD))) {
errh_Error("IO init: Signal SigChanCon error '%s'", buf); errh_Error("IO init: Signal SigChanCon error '%s'", buf);
} }
else { else {
...@@ -585,12 +616,25 @@ pwr_tStatus io_init_do_signals( ...@@ -585,12 +616,25 @@ pwr_tStatus io_init_do_signals(
errh_Error("IO init: Signal SigChanCon error '%s'", buf); errh_Error("IO init: Signal SigChanCon error '%s'", buf);
} }
else { else {
if ( cdh_ObjidIsNotNull( chan_op->SigChanCon.Objid)) { if ( class == pwr_cClass_ChanDo) {
pwr_tAName oldsig; if ( cdh_ObjidIsNotNull( chan_op->SigChanCon.Objid)) {
sts = gdh_AttrrefToName( &chan_op->SigChanCon, oldsig, sizeof(oldsig), cdh_mNName); pwr_tAName oldsig;
errh_Error( "IO init: Double signal connection '%s' and '%s'", buf, oldsig); sts = gdh_AttrrefToName( &chan_op->SigChanCon, oldsig, sizeof(oldsig), cdh_mNName);
errh_Error( "IO init: Double signal connection '%s' and '%s'", buf, oldsig);
}
chan_op->SigChanCon = sig_aref;
} }
chan_op->SigChanCon = sig_aref; else {
if ( ((pwr_sClass_ChanD *)chan_op)->Type != pwr_eDChanTypeEnum_Do)
errh_Error( "IO init: ChanD type is not Do '%s'", buf);
else if ( cdh_ObjidIsNotNull( ((pwr_sClass_ChanD *)chan_op)->SigChanCon.Objid)) {
pwr_tAName oldsig;
sts = gdh_AttrrefToName( &((pwr_sClass_ChanD *)chan_op)->SigChanCon, oldsig, sizeof(oldsig),
cdh_mNName);
errh_Error( "IO init: Double signal connection '%s' and '%s'", buf, oldsig);
}
((pwr_sClass_ChanD *)chan_op)->SigChanCon = sig_aref;
}
} }
} }
} }
...@@ -1811,6 +1855,10 @@ static pwr_tStatus io_handle_channels( ...@@ -1811,6 +1855,10 @@ static pwr_tStatus io_handle_channels(
sigchancon = ((pwr_sClass_ChanDo *) chan_op)->SigChanCon; sigchancon = ((pwr_sClass_ChanDo *) chan_op)->SigChanCon;
number = *chan_cnt; number = *chan_cnt;
break; break;
case pwr_cClass_ChanD:
sigchancon = ((pwr_sClass_ChanD *) chan_op)->SigChanCon;
number = *chan_cnt;
break;
case pwr_cClass_ChanIi: case pwr_cClass_ChanIi:
sigchancon = ((pwr_sClass_ChanIi *) chan_op)->SigChanCon; sigchancon = ((pwr_sClass_ChanIi *) chan_op)->SigChanCon;
number = *chan_cnt; number = *chan_cnt;
...@@ -2081,6 +2129,7 @@ static pwr_tStatus io_init_card( ...@@ -2081,6 +2129,7 @@ static pwr_tStatus io_init_card(
case pwr_cClass_ChanAo: case pwr_cClass_ChanAo:
case pwr_cClass_ChanDo: case pwr_cClass_ChanDo:
case pwr_cClass_ChanDi: case pwr_cClass_ChanDi:
case pwr_cClass_ChanD:
case pwr_cClass_ChanIi: case pwr_cClass_ChanIi:
case pwr_cClass_ChanIo: case pwr_cClass_ChanIo:
case pwr_cClass_ChanCo: case pwr_cClass_ChanCo:
...@@ -2108,6 +2157,7 @@ static pwr_tStatus io_init_card( ...@@ -2108,6 +2157,7 @@ static pwr_tStatus io_init_card(
case pwr_cClass_ChanAo: case pwr_cClass_ChanAo:
case pwr_cClass_ChanDi: case pwr_cClass_ChanDi:
case pwr_cClass_ChanDo: case pwr_cClass_ChanDo:
case pwr_cClass_ChanD:
case pwr_cClass_ChanIi: case pwr_cClass_ChanIi:
case pwr_cClass_ChanIo: case pwr_cClass_ChanIo:
case pwr_cClass_ChanCo: case pwr_cClass_ChanCo:
...@@ -2132,6 +2182,7 @@ static pwr_tStatus io_init_card( ...@@ -2132,6 +2182,7 @@ static pwr_tStatus io_init_card(
case pwr_cClass_ChanAo: case pwr_cClass_ChanAo:
case pwr_cClass_ChanDi: case pwr_cClass_ChanDi:
case pwr_cClass_ChanDo: case pwr_cClass_ChanDo:
case pwr_cClass_ChanD:
case pwr_cClass_ChanIi: case pwr_cClass_ChanIi:
case pwr_cClass_ChanIo: case pwr_cClass_ChanIo:
case pwr_cClass_ChanCo: case pwr_cClass_ChanCo:
...@@ -2237,6 +2288,10 @@ static pwr_tStatus io_init_card( ...@@ -2237,6 +2288,10 @@ static pwr_tStatus io_init_card(
sigchancon = ((pwr_sClass_ChanDi *) chan_op)->SigChanCon; sigchancon = ((pwr_sClass_ChanDi *) chan_op)->SigChanCon;
number = ((pwr_sClass_ChanDi *) chan_op)->Number; number = ((pwr_sClass_ChanDi *) chan_op)->Number;
break; break;
case pwr_cClass_ChanD:
sigchancon = ((pwr_sClass_ChanD *) chan_op)->SigChanCon;
number = ((pwr_sClass_ChanD *) chan_op)->Number;
break;
case pwr_cClass_ChanIi: case pwr_cClass_ChanIi:
sigchancon = ((pwr_sClass_ChanIi *) chan_op)->SigChanCon; sigchancon = ((pwr_sClass_ChanIi *) chan_op)->SigChanCon;
number = ((pwr_sClass_ChanIi *) chan_op)->Number; number = ((pwr_sClass_ChanIi *) chan_op)->Number;
...@@ -2454,6 +2509,9 @@ static pwr_tStatus io_init_card( ...@@ -2454,6 +2509,9 @@ static pwr_tStatus io_init_card(
case pwr_cClass_ChanDo: case pwr_cClass_ChanDo:
csize = sizeof( pwr_sClass_ChanDo); csize = sizeof( pwr_sClass_ChanDo);
break; break;
case pwr_cClass_ChanD:
csize = sizeof( pwr_sClass_ChanD);
break;
case pwr_cClass_ChanIi: case pwr_cClass_ChanIi:
csize = sizeof( pwr_sClass_ChanIi); csize = sizeof( pwr_sClass_ChanIi);
break; break;
...@@ -2493,6 +2551,9 @@ static pwr_tStatus io_init_card( ...@@ -2493,6 +2551,9 @@ static pwr_tStatus io_init_card(
case pwr_cClass_ChanDo: case pwr_cClass_ChanDo:
csize = sizeof( pwr_sClass_ChanDo); csize = sizeof( pwr_sClass_ChanDo);
break; break;
case pwr_cClass_ChanD:
csize = sizeof( pwr_sClass_ChanD);
break;
case pwr_cClass_ChanIi: case pwr_cClass_ChanIi:
csize = sizeof( pwr_sClass_ChanIi); csize = sizeof( pwr_sClass_ChanIi);
break; break;
......
...@@ -403,6 +403,48 @@ pwr_tStatus io_bus_card_init( io_tCtx ctx, ...@@ -403,6 +403,48 @@ pwr_tStatus io_bus_card_init( io_tCtx ctx,
chanp->mask = 0; chanp->mask = 0;
break; break;
} }
case pwr_cClass_ChanD: {
pwr_sClass_ChanD *chan_d = (pwr_sClass_ChanD *) chanp->cop;
if ( chan_d->Type == pwr_eDChanTypeEnum_Di) {
/* Di type */
if (chan_d->Number == 0) {
*input_area_offset += *input_area_chansize;
*input_area_chansize = GetChanSize( chan_d->Representation);
}
if ( !chanp->sop)
continue;
chanp->offset = *input_area_offset;
chanp->mask = 1 << chan_d->Number;
if ( byte_order == pwr_eByteOrderingEnum_BigEndian) {
if ( chan_d->Representation == pwr_eDataRepEnum_Bit16)
chanp->mask = swap16( (unsigned short)chanp->mask);
else if ( chan_d->Representation == pwr_eDataRepEnum_Bit32)
chanp->mask = swap32( chanp->mask);
}
}
else {
/* Do type */
if (chan_d->Number == 0) {
*output_area_offset += *output_area_chansize;
*output_area_chansize = GetChanSize( chan_d->Representation);
}
if ( !chanp->sop)
continue;
chanp->offset = *output_area_offset;
chanp->mask = 1 << chan_d->Number;
if ( byte_order == pwr_eByteOrderingEnum_BigEndian) {
if ( chan_d->Representation == pwr_eDataRepEnum_Bit16)
chanp->mask = swap16( (unsigned short)chanp->mask);
else if ( chan_d->Representation == pwr_eDataRepEnum_Bit32)
chanp->mask = swap32( chanp->mask);
}
}
break;
}
} }
} }
return IO__SUCCESS; return IO__SUCCESS;
...@@ -422,6 +464,7 @@ void io_bus_card_read( io_tCtx ctx, ...@@ -422,6 +464,7 @@ void io_bus_card_read( io_tCtx ctx,
{ {
io_sChannel *chanp; io_sChannel *chanp;
pwr_sClass_ChanDi *chan_di; pwr_sClass_ChanDi *chan_di;
pwr_sClass_ChanD *chan_d;
pwr_sClass_Di *sig_di; pwr_sClass_Di *sig_di;
pwr_sClass_ChanAi *chan_ai; pwr_sClass_ChanAi *chan_ai;
pwr_sClass_Ai *sig_ai; pwr_sClass_Ai *sig_ai;
...@@ -478,6 +521,37 @@ void io_bus_card_read( io_tCtx ctx, ...@@ -478,6 +521,37 @@ void io_bus_card_read( io_tCtx ctx,
} }
break; break;
case pwr_cClass_ChanD:
chan_d = (pwr_sClass_ChanD *) chanp->cop;
if ( chan_d->Type == pwr_eDChanTypeEnum_Di) {
sig_di = (pwr_sClass_Di *) chanp->sop;
if (chan_d && sig_di && chan_d->ConversionOn) {
switch (chan_d->Representation) {
case pwr_eDataRepEnum_Bit8:
udata8p = input_area + cp->offset + chanp->offset;
* (pwr_tUInt16 *) (chanp->vbp) = chan_d->InvertOn ? ((*udata8p & chanp->mask) == 0) :
((*udata8p & chanp->mask) != 0);
break;
case pwr_eDataRepEnum_Bit16:
udata16p = input_area + cp->offset + chanp->offset;
* (pwr_tUInt16 *) (chanp->vbp) = chan_d->InvertOn ? ((*udata16p & chanp->mask) == 0) :
((*udata16p & chanp->mask) != 0);
break;
case pwr_eDataRepEnum_Bit32:
udata32p = input_area + cp->offset + chanp->offset;
* (pwr_tUInt16 *) (chanp->vbp) = chan_d->InvertOn ? ((*udata32p & chanp->mask) == 0) :
((*udata32p & chanp->mask) != 0);
break;
}
}
}
break;
// Channel type is Ai (analog input) // Channel type is Ai (analog input)
case pwr_cClass_ChanAi: case pwr_cClass_ChanAi:
...@@ -887,6 +961,7 @@ void io_bus_card_write( io_tCtx ctx, ...@@ -887,6 +961,7 @@ void io_bus_card_write( io_tCtx ctx,
io_sChannel *chanp; io_sChannel *chanp;
pwr_sClass_ChanDo *chan_do; pwr_sClass_ChanDo *chan_do;
pwr_sClass_ChanD *chan_d;
pwr_sClass_Do *sig_do; pwr_sClass_Do *sig_do;
pwr_sClass_ChanAo *chan_ao; pwr_sClass_ChanAo *chan_ao;
pwr_sClass_Ao *sig_ao; pwr_sClass_Ao *sig_ao;
...@@ -961,6 +1036,52 @@ void io_bus_card_write( io_tCtx ctx, ...@@ -961,6 +1036,52 @@ void io_bus_card_write( io_tCtx ctx,
break; break;
case pwr_cClass_ChanD:
chan_d = (pwr_sClass_ChanD *) chanp->cop;
if ( chan_d->Type == pwr_eDChanTypeEnum_Do) {
sig_do = (pwr_sClass_Do *) chanp->sop;
if (chan_d && sig_do) {
if (fixout)
do_actval = chan_d->FixedOutValue;
else if (chan_d->TestOn != 0)
do_actval = chan_d->TestValue;
else
do_actval = *(pwr_tInt32 *) chanp->vbp;
switch (chan_d->Representation) {
case pwr_eDataRepEnum_Bit8:
udata8p = output_area + cp->offset + chanp->offset;
if (do_actval ^ chan_d->InvertOn)
*udata8p |= chanp->mask;
else
*udata8p &= ~chanp->mask;
break;
case pwr_eDataRepEnum_Bit16:
udata16p = output_area + cp->offset + chanp->offset;
if (do_actval ^ chan_d->InvertOn)
*udata16p |= chanp->mask;
else
*udata16p &= ~chanp->mask;
break;
case pwr_eDataRepEnum_Bit32:
udata32p = output_area + cp->offset + chanp->offset;
if (do_actval ^ chan_d->InvertOn)
*udata32p |= chanp->mask;
else
*udata32p &= ~chanp->mask;
break;
}
}
}
break;
// Channel type is Ao (analog output) // Channel type is Ao (analog output)
case pwr_cClass_ChanAo: case pwr_cClass_ChanAo:
......
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2011 SSAB Oxelosund AB.
!
! This file is part of Proview.
!
! 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 Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_chand.wb_load -- Defines the class ChanD.
!
! Digital input or output channel.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group IO,Channels,NodeConfiguration
! @Summary Configures a digital input or output channel
! Configures a digital input or ouput channel channel.
!
! Digital channel representing an input or output channel,
! It channel should only be used in IO Module objects where
! digital channels can be used as either digital inputs or
! digital outputs. In other cases ChanDi and ChanDo should be
! used instead.
!
!*/
Object ChanD $ClassDef 590
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 = "ChanD"
EndBody
!/**
! Optional text, for example to describe the channel or
! its employment.
!*/
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Name of a signal object, i.e. Di or Do object, connected with
! the channel object.
!*/
Object SigChanCon $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$AttrRef"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
!/**
! The identity of the channel. Optional, for example Di0
! to denote the first channel, physical cable marking,
! etc.
!*/
Object Identity $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
!/**
! Specifies if channel is an input or output channel.
!*/
Object Type $Attribute 4
Body SysBody
Attr TypeRef = "pwrb:Type-DChanTypeEnum"
EndBody
EndObject
!/**
! The Number attribute is used to associate the ChanDi
! object to a fixed channel on the card named by
! SigChanCon. The physical channels of the card are
! numbered in the interval {0,1, ... , (MaxNoOfChannels-1)},
! where MaxNoOfChannels is an attribute in the card
! object.
! The channels of the card are numbered according to the
! instructions of the card manufacturer.
!*/
Object Number $Attribute 5
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Specifies if the ActualValue should be updated or not.
! FALSE means no updating; TRUE means ActualValue will be
! updated at the period T0 , where T0 is equal to
! ScanTime of the fastest running PLC program of the
! node.
! There is today no sense in assigning a value to the
! attribute in the development environment, as no
! attention is paid to it in the target environment.
! Instead, this is done by means of the attribute
! ConvMask1 in the card object.
!
! However, the value of ConversionOn can be changed via
! the more info form of the object in the target
! environment.
!*/
Object ConversionOn $Attribute 6
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
!/**
! Specifies if the digital value for an input channel
! should be inverted before storing in ActualValue or not.
! FALSE means that the digital value should not be inverted;
! TRUE means that it should be inverted.
!
! There is today no sense in assigning a value to the
! attribute in the development environment, as no
! attention is paid to it in the target environment.
! Instead, this is done by means of the attribute
! InvMask1 in the card object.
! However, the value of InvertOn can be changed via the
! more info form of the object in the target environment.
!*/
Object InvertOn $Attribute 7
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
!/**
! Specifies if the output will be based on ActualValue or
! TestValue. FALSE means that the output should be based
! on ActualValue; TRUE means that TestValue should be
! used.
! There is today no sense in assigning a value to the
! attribute in the development environment, as no
! attention is paid to it in the target environment.
! Instead, this is done by means of the attribute
! TestMask1 in the card object.
!
! However, the value of TestOn can be changed via the
! more info form of the object in the target environment.
!*/
Object TestOn $Attribute 8
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
EndBody
EndObject
!/**
! The output signal is based on the TestValue instead of
! ActualValue when TestOn is TRUE.
!
! There is today no sense in assigning a value to the
! attribute in the development environment, as no
! attention is paid to it in the target environment.
! Instead, this is done by means of the attribute
! TestValue1 in the card object.
! However, the value of TestValue can be changed via the
! more info form of the object in the target environment.
!*/
Object TestValue $Attribute 9
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
EndBody
EndObject
!/**
! Action value. The output signal is equal to
! FixedOutValue when EmergBreakTrue is TRUE and
! EmergBreakSelect = 2 . The EmergBreak-attributes belong
! to the $Node object.
! There is today no sense in assigning a value to the
! attribute in the development environment, as no
! attention is paid to it in the target environment.
! Instead, this is done by means of the attribute
! FixedOutValue1 in the card object.
!
! However, the value of FixedOutValue can be changed via
! the more info form of the object in the target
! environment.
!*/
Object FixedOutValue $Attribute 10
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
!/**
! Specifies the data representation of the raw value.
!*/
Object Representation $Attribute 11
Body SysBody
Attr TypeRef = "pwrb:Type-DataRepEnum"
EndBody
EndObject
EndObject
Object Template ChanD
Body RtBody
Attr ConversionOn = 1
EndBody
EndObject
Object PostCreate $DbCallBack
Body SysBody
Attr MethodName = "ChanDi-PostCreate"
EndBody
EndObject
Object RtXtt $RtMenu
Object Signal $MenuRef
Body SysBody
Attr ButtonName = "Signal"
Attr RefAttribute = "SigChanCon"
EndBody
EndObject
EndObject
EndObject
EndSObject
...@@ -265,10 +265,10 @@ SObject pwrb:Class ...@@ -265,10 +265,10 @@ SObject pwrb:Class
Attr ButtonName = "Connect Channel" Attr ButtonName = "Connect Channel"
Attr MethodName = "$AttrRef-Connect" Attr MethodName = "$AttrRef-Connect"
Attr MethodArguments[0] = "SigChanCon" Attr MethodArguments[0] = "SigChanCon"
Attr MethodArguments[1] = "ChanDi" Attr MethodArguments[1] = "ChanDi,ChanD"
Attr FilterName = "$AttrRef-IsOkConnect" Attr FilterName = "$AttrRef-IsOkConnect"
Attr FilterArguments[0] = "SigChanCon" Attr FilterArguments[0] = "SigChanCon"
Attr FilterArguments[1] = "ChanDi" Attr FilterArguments[1] = "ChanDi,ChanD"
EndBody EndBody
EndObject EndObject
Object ConnectGraph $MenuButton Object ConnectGraph $MenuButton
......
...@@ -221,10 +221,10 @@ SObject pwrb:Class ...@@ -221,10 +221,10 @@ SObject pwrb:Class
Attr ButtonName = "Connect Channel" Attr ButtonName = "Connect Channel"
Attr MethodName = "$AttrRef-Connect" Attr MethodName = "$AttrRef-Connect"
Attr MethodArguments[0] = "SigChanCon" Attr MethodArguments[0] = "SigChanCon"
Attr MethodArguments[1] = "ChanDo" Attr MethodArguments[1] = "ChanDo,ChanD"
Attr FilterName = "$AttrRef-IsOkConnect" Attr FilterName = "$AttrRef-IsOkConnect"
Attr FilterArguments[0] = "SigChanCon" Attr FilterArguments[0] = "SigChanCon"
Attr FilterArguments[1] = "ChanDo" Attr FilterArguments[1] = "ChanDo,ChanD"
EndBody EndBody
EndObject EndObject
Object ConnectGraph $MenuButton Object ConnectGraph $MenuButton
......
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2011 SSAB Oxelosund AB.
!
! This file is part of Proview.
!
! 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 Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_td_dchantypeenum.wb_load -- Defines the enum type DChanType
!
SObject pwrb:Type
!/**
! @Version 1.0
! @Group Types
! Enumeration for digital input or output channel.
!*/
Object DChanTypeEnum $TypeDef 63
Body SysBody
Attr TypeRef = "pwrs:Type-$Enum"
Attr PgmName = "DChanTypeEnum"
EndBody
!/**
! Digital input.
!*/
Object Di $Value
Body SysBody
Attr PgmName = "Di"
Attr Text = "Di"
Attr Value = 0
EndBody
EndObject
!/**
! Digital output.
!*/
Object Do $Value
Body SysBody
Attr PgmName = "Do"
Attr Text = "Do"
Attr Value = 1
EndBody
EndObject
EndObject
EndSObject
...@@ -254,6 +254,7 @@ palette NavigatorPalette ...@@ -254,6 +254,7 @@ palette NavigatorPalette
class ChanBi class ChanBi
class ChanBo class ChanBo
class ChanCo class ChanCo
class ChanD
class ChanDi class ChanDi
class ChanDo class ChanDo
class ChanIi class ChanIi
......
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