Commit 9a8d1b1a authored by claes's avatar claes

Newattribute flag handled and template object updated

parent 1010e4f0
/* /*
* Proview $Id: wb_wblnode.cpp,v 1.57 2007-04-25 07:29:02 claes Exp $ * Proview $Id: wb_wblnode.cpp,v 1.58 2007-09-19 15:19:10 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
...@@ -248,6 +248,8 @@ static wbl_sSym classes[] = ...@@ -248,6 +248,8 @@ static wbl_sSym classes[] =
,{ "pwr_eCix_RtMethod", pwr_eCix_RtMethod } ,{ "pwr_eCix_RtMethod", pwr_eCix_RtMethod }
,{ "pwr_eClass_Hier", pwr_eClass_Hier } ,{ "pwr_eClass_Hier", pwr_eClass_Hier }
,{ "pwr_eCix_Hier", pwr_eCix_Hier } ,{ "pwr_eCix_Hier", pwr_eCix_Hier }
,{ "pwr_eClass_ClassLost", pwr_eClass_ClassLost }
,{ "pwr_eCix_ClassLost", pwr_eCix_ClassLost }
,{ 0, 0 } ,{ 0, 0 }
}; };
...@@ -772,38 +774,74 @@ void wb_wblnode::postBuild() ...@@ -772,38 +774,74 @@ void wb_wblnode::postBuild()
((pwr_sGraphPlcNode *)o->rbody)->default_mask[1] = mask; ((pwr_sGraphPlcNode *)o->rbody)->default_mask[1] = mask;
} }
} }
else if ( isTemplate() && o->templ.created) { else if ( isTemplate()) {
// New template object, insert template values of attribute objects into body if ( o->templ.created) {
size_t size; // New template object, insert template values of attribute objects into body
void *body; size_t size;
void *body;
ch = o->fth->o->fch; ch = o->fth->o->fch;
while ( ch) { while ( ch) {
if ( ch->isObjBodyDef() && ch->o->b.bix == pwr_eBix_rt) { if ( ch->isObjBodyDef() && ch->o->b.bix == pwr_eBix_rt) {
wb_wblnode *attr = ch->o->fch; wb_wblnode *attr = ch->o->fch;
while ( attr) { while ( attr) {
if ( attr->isAttribute()) { if ( attr->isAttribute()) {
if ( cdh_tidIsCid( attr->o->a.tid)) { if ( cdh_tidIsCid( attr->o->a.tid)) {
// Copy template for this object to offset of the attribute // Copy template for this object to offset of the attribute
if ( m_vrep->getTemplateBody( attr->o->a.tid, pwr_eBix_sys, &size, &body)) { if ( m_vrep->getTemplateBody( attr->o->a.tid, pwr_eBix_sys, &size, &body)) {
if ( size * attr->o->a.elements != attr->o->a.size || if ( size * attr->o->a.elements != attr->o->a.size ||
attr->o->a.offset + size * attr->o->a.elements > o->rbody_size) attr->o->a.offset + size * attr->o->a.elements > o->rbody_size)
m_vrep->error( "AttrObject size mismatch", getFileName(), line_number); m_vrep->error( "AttrObject size mismatch", getFileName(), line_number);
else else
for ( int i = 0; i < attr->o->a.elements; i++) for ( int i = 0; i < attr->o->a.elements; i++)
memcpy( (char *)o->rbody + attr->o->a.offset + i * size, body, size); memcpy( (char *)o->rbody + attr->o->a.offset + i * size, body, size);
free( body); free( body);
}
} }
} }
attr = attr->o->fws;
} }
attr = attr->o->fws;
break;
} }
ch = ch->o->fws;
}
}
else {
// Check if any new attribute is created
size_t size;
void *body;
ch = o->fth->o->fch;
while ( ch) {
if ( ch->isObjBodyDef() && ch->o->b.bix == pwr_eBix_rt) {
wb_wblnode *attr = ch->o->fch;
while ( attr) {
if ( attr->isAttribute()) {
if ( cdh_tidIsCid( attr->o->a.tid) &&
((pwr_sParam *)attr->o->rbody)->Info.Flags & PWR_MASK_NEWATTRIBUTE) {
// Copy template for this object to offset of the attribute
if ( m_vrep->getTemplateBody( attr->o->a.tid, pwr_eBix_sys, &size, &body)) {
if ( size * attr->o->a.elements != attr->o->a.size ||
attr->o->a.offset + size * attr->o->a.elements > o->rbody_size)
m_vrep->error( "AttrObject size mismatch", getFileName(), line_number);
else
for ( int i = 0; i < attr->o->a.elements; i++)
memcpy( (char *)o->rbody + attr->o->a.offset + i * size, body, size);
free( body);
}
((pwr_sParam *)attr->o->rbody)->Info.Flags &= ~PWR_MASK_NEWATTRIBUTE;
}
}
attr = attr->o->fws;
}
break; break;
} }
ch = ch->o->fws; ch = ch->o->fws;
}
} }
} }
} }
......
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