Commit 3f706cce authored by claes's avatar claes

*** empty log message ***

parent 617a312c
......@@ -41,6 +41,47 @@ SObject pwrs:Class
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! @Summary A XttGraph object that will open a graph for this hierarchy.
! A XttGraph object that will open a graph that contains data for
! this hierarchy. This graph can be opened from the popup menu for
! this object.
!*/
Object DefGraph $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
!/**
! @Summary A trend object that displays trends for this hierarchy.
! A DsTrend or PlotGroup object that contains trend for this hierarchy.
! The trend can be opened from the popup menu for this object.
!*/
Object DefTrend $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
!/**
! @Summary A help topic for this hierarchy.
! A help topic in the xtt help file that contains help for this hierarchy.
! The help can be displayed from the popup menu for this object.
!*/
Object HelpTopic $Attribute 4
Body SysBody
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
!/**
! @Summary A URL to the data sheet for the equipment in this hierarchy.
! A URL to the data sheet for the equipment in this hierarchy.
! The data sheet can be displayed from the popup menu for this object.
!*/
Object DataSheet $Attribute 5
Body SysBody
Attr TypeRef = "pwrs:Type-$URL"
EndBody
EndObject
EndObject
EndObject
EndSObject
......@@ -41,6 +41,7 @@ extern "C" {
#include "wb_env.h"
#include "wb_erep.h"
#include "wb_vrepwbl.h"
#include "wb_vrepdbs.h"
/* Fallback resources */
......@@ -199,8 +200,33 @@ void pwr_wtt_open_volume( void *wttctx, char *filename, wow_eFileSelType file_ty
wtt->time_to_exit_cb = pwr_time_to_exit;
}
}
else if ( file_type == wow_eFileSelType_Dbs)
else if ( file_type == wow_eFileSelType_Dbs) {
printf( "Wb opening loadfile %s...\n", filename);
// Load volume as extern
wb_erep *erep = (wb_erep *)(*(wb_env *)wbctx);
wb_vrepdbs *vrep = new wb_vrepdbs( erep, filename);
try {
vrep->load();
erep->addExtern( &sts, vrep);
}
catch ( wb_error& e) {
cout << "** Error opening volume, " << e.what() << endl;
return;
}
// Attach extern volume
wb_volume *vol = new wb_volume(vrep);
pwr_tVid volume = vrep->vid();
Wtt *wtt = new Wtt( 0, toplevel, filename, "Navigator", wbctx, volume, vol, 0, &sts);
if (ODD(sts)) {
appl_count++;
wtt->close_cb = pwr_wtt_close;
wtt->open_volume_cb = pwr_wtt_open_volume;
wtt->time_to_exit_cb = pwr_time_to_exit;
}
}
else
printf( "Unknown file type\n");
}
......
......@@ -4,8 +4,6 @@
#include "wb_attrname.h"
#include "pwr.h"
static const char* s_emptyString = "";
wb_attribute::wb_attribute() : wb_status(LDH__NOSUCHATTR), m_orep(0), m_adrep(0),
......@@ -152,7 +150,7 @@ wb_attribute& wb_attribute::operator=(const wb_attribute& x)
return *this;
}
void wb_attribute::check()
void wb_attribute::check() const
{
if ( evenSts())
throw wb_error( m_sts);
......@@ -304,20 +302,28 @@ wb_attribute wb_attribute::prev()
return a;
}
const char* wb_attribute::name() const
const char *wb_attribute::name() const
{
if (m_adrep)
return m_adrep->name();
else
return s_emptyString;
check();
return m_orep->name();
}
// Fix, no index and no subclass !!!
wb_name wb_attribute::longName()
{
if (m_adrep)
return m_adrep->longName();
else
return wb_name();
check();
if ( !m_adrep)
return m_orep->longName();
char str[512];
strcpy( str, m_orep->longName().name());
strcat( str, ".");
strcat( str, m_adrep->name());
wb_name n = wb_name( str);
return n;
}
void wb_attribute::name(const char *name)
......
......@@ -84,7 +84,7 @@ public:
wb_attribute prev();
const char* name() const; // get attribute name
const char *name() const;
wb_name longName();
void name(const char *name);
void name(wb_name *name);
......@@ -93,7 +93,7 @@ public:
pwr_tStatus sts() { return m_sts;}
private:
void check();
void check() const;
void init();
};
......
......@@ -3,9 +3,11 @@
#include "wb_name.h"
class wb_attrname : public wb_name
{
public:
wb_attrname() : wb_name() {}
wb_attrname(const char *);
};
......
......@@ -41,7 +41,8 @@ wb_cdrep::wb_cdrep( wb_mvrep *mvrep, wb_name name) : m_nRef(0)
char str[80];
strcpy( str, "Class-");
strcat( str, name.object());
m_orep = (wb_orepdbs *) mvrep->object( &m_sts, str);
wb_name n = wb_name( str);
m_orep = (wb_orepdbs *) mvrep->object( &m_sts, n);
if ( EVEN(m_sts)) throw wb_error( m_sts);
m_orep->ref();
......@@ -112,18 +113,29 @@ wb_bdrep *wb_cdrep::bdrep( pwr_tStatus *sts, int bix)
wb_adrep *wb_cdrep::adrep( pwr_tStatus *sts, const char *aname)
{
wb_name n = wb_name( aname);
if ( n.evenSts()) {
*sts = n.sts();
return 0;
}
wb_orepdbs *orep_attr;
wb_orepdbs *old;
wb_orepdbs *orep = (wb_orepdbs *)m_orep->first( sts);
while ( ODD(*sts)) {
orep->ref();
if ( orep->cid() == pwr_eClass_ObjBodyDef) {
orep_attr = (wb_orepdbs *)orep->m_vrep->child( sts, orep, aname);
orep_attr = (wb_orepdbs *)orep->m_vrep->child( sts, orep, n);
if ( ODD(*sts)) {
wb_adrep *adrep = new wb_adrep( *orep);
wb_adrep *adrep = new wb_adrep( *orep_attr);
orep->unref();
return adrep;
}
}
orep_attr = (wb_orepdbs *)orep_attr->after( sts);
old = orep;
orep = (wb_orepdbs *)orep->after( sts);
old->unref();
}
*sts = LDH__NOSUCHATTR;
return 0;
}
......
......@@ -443,6 +443,10 @@ wb_orep *wb_erep::object(pwr_tStatus *sts, pwr_tOid oid)
wb_orep *wb_erep::object(pwr_tStatus *sts, const char *name)
{
wb_name n = wb_name(name);
if ( n.evenSts()) {
*sts = n.sts();
return 0;
}
wb_vrep *vrep = volume( sts, n.volume());
if ( EVEN(*sts)) return 0;
......
......@@ -98,6 +98,7 @@ wb_cdrep *wb_merep::cdrep( pwr_tStatus *sts, wb_name name)
}
catch ( wb_error& e) {
// Not found in this volume, try next
continue;
}
}
......
......@@ -139,7 +139,7 @@ public:
char *normName( int ntype) const throw (wb_error) { check(); return m_nrep->normName( ntype);}
bool volumeIsEqual( const char *n) const throw (wb_error) { check(); return m_nrep->volumeIsEqual( n);}
bool objectIsEqual( const char *n) const throw (wb_error) { check(); return m_nrep->objectIsEqual( n);}
bool segmentIsEqual( char *n, int idx = 0) const throw (wb_error) { check(); return m_nrep->segmentIsEqual( n, idx);}
bool segmentIsEqual( const char *n, int idx = 0) const throw (wb_error) { check(); return m_nrep->segmentIsEqual( n, idx);}
bool attributeIsEqual( const char *n, int idx = 0) const throw (wb_error) { check(); return m_nrep->attributeIsEqual( n, idx);}
// Id representation
......@@ -153,7 +153,7 @@ public:
// bool bodyName();
static char *unatName( char *name) { return wb_nrep::unatName( name);}
static bool checkObjectName( char *name) { return wb_nrep::checkObjectName( name);}
static bool checkObjectName( const char *name) { return wb_nrep::checkObjectName( name);}
private:
void check() const { if ( evenSts()) throw wb_error(m_sts);}
};
......
......@@ -70,7 +70,7 @@ pwr_tOid wb_orepwbl::aoid() const
const char * wb_orepwbl::name() const
{
return m_wblnode->name;
return m_wblnode->name();
}
wb_name wb_orepwbl::longName()
......
......@@ -40,7 +40,8 @@ wb_tdrep::wb_tdrep( wb_mvrep *mvrep, wb_name name) : m_nRef(0)
char str[80];
strcpy( str, "Type-");
strcat( str, name.object());
m_orep = (wb_orepdbs *) mvrep->object( &m_sts, str);
wb_name n = wb_name( str);
m_orep = (wb_orepdbs *) mvrep->object( &m_sts, n);
if ( EVEN(m_sts)) throw wb_error( m_sts);
m_orep->ref();
......
......@@ -82,21 +82,21 @@ void wb_vrepwbl::info()
for ( iterator_tid_list it = m_tid_list.begin();
it != m_tid_list.end(); it++)
cout << "Tid_list : " << it->first << " " << it->second->name <<
cout << "Tid_list : " << it->first << " " << it->second->name() <<
" size: " << it->second->ty_size << " elem: " << it->second->ty_elements << endl;
for ( iterator_class_list it = m_class_list.begin();
it != m_class_list.end(); it++)
cout << "Class_list : " << it->first << " " << it->second->name <<
cout << "Class_list : " << it->first << " " << it->second->name() <<
" line: " << it->second->line_number << endl;
for ( iterator_cid_list it = m_cid_list.begin();
it != m_cid_list.end(); it++)
cout << "Cid_list : " << it->first << " " << it->second->name <<
cout << "Cid_list : " << it->first << " " << it->second->name() <<
" line: " << it->second->line_number << endl;
// for ( int i = 0; i < file_cnt; i++)
// rootAST[i]->info(0);
if ( root_object)
root_object->info(0);
}
bool
......@@ -179,9 +179,11 @@ int wb_vrepwbl::load( const char *fname)
// if ( root_object)
// root_object->info_link( 0);
cout << "-- Starting build pass" << endl;
if ( root_object)
root_object->build( 1);
// info();
return 1;
}
......@@ -216,7 +218,8 @@ ref_wblnode wb_vrepwbl::findClass( const char *name)
ref_wblnode wb_vrepwbl::findType( const char *name)
{
wb_name wname( name);
wb_name wname = wb_name( name);
if ( wname.evenSts()) return 0;
if ( wname.hasVolume() && !wname.volumeIsEqual(volume_name))
return 0;
......@@ -252,7 +255,9 @@ int wb_vrepwbl::getTypeInfo( const char *name, pwr_tTid *tid, pwr_eType *type, i
{
bool type_extern = false;
char tname[80];
wb_name wname( name);
wb_name wname = wb_name(name);
if ( wname.evenSts() || !wname.hasObject())
return 0;
strcpy( tname, wname.object());
......@@ -544,7 +549,8 @@ int wb_vrepwbl::getAttrInfo( const char *attr, cdh_eBix bix, pwr_tCid cid, int *
int a_elements;
pwr_eType a_type;
wb_attrname aname( attr);
wb_attrname aname = wb_attrname(attr);
if ( aname.evenSts()) return 0;
if ( getAttrInfoRec( &aname, bix, cid, &a_size, &a_offset,
......@@ -716,7 +722,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_attrname *attr, cdh_eBix bix, pwr_tCid cid, i
// Find attribute
wb_wblnode *n_attr = n_body->o_fch;
while( n_attr) {
if ( n_attr->isAttribute() && attr->attributeIsEqual( n_attr->name, level))
if ( n_attr->isAttribute() && attr->attributeIsEqual( n_attr->name(), level))
break;
n_attr = n_attr->o_fws;
}
......@@ -793,7 +799,6 @@ int wb_vrepwbl::nameToOid( const char *name, pwr_tOid *oid)
int wb_vrepwbl::nameToAttrRef( const char *name, pwr_sAttrRef *attrref)
{
wb_name aname = wb_name( name);
pwr_tOid oid;
pwr_tStatus sts;
int a_size;
......@@ -809,6 +814,9 @@ int wb_vrepwbl::nameToAttrRef( const char *name, pwr_sAttrRef *attrref)
return 0;
}
wb_name aname = wb_name(name);
if ( aname.evenSts()) return 0;
ref_wblnode n = find( aname.name( cdh_mName_volume | cdh_mName_path | cdh_mName_object));
if ( n) {
if ( !n->is_built)
......@@ -834,7 +842,25 @@ int wb_vrepwbl::nameToAttrRef( const char *name, pwr_sAttrRef *attrref)
}
}
if ( !aname.hasAttribute()) {
// No attribute given, attrref to whole RtBody
wb_cdrep *cdrep = m_merep->cdrep( &sts, cid);
if ( EVEN(sts)) return sts;
wb_bdrep *bdrep = cdrep->bdrep( &sts, cdh_eBix_rt);
if ( EVEN(sts)) return sts;
attrref->Objid = oid;
attrref->Offset = 0;
attrref->Size = bdrep->size();
attrref->Body = cdh_TypeObjidToId( bdrep->boid());
delete cdrep;
delete bdrep;
}
else {
wb_attrname an = wb_attrname( aname.name( cdh_mName_attribute));
if ( an.evenSts()) return an.sts();
// Try rtbody
bix = cdh_eBix_rt;
......@@ -850,8 +876,8 @@ int wb_vrepwbl::nameToAttrRef( const char *name, pwr_sAttrRef *attrref)
attrref->Objid = oid;
attrref->Offset = a_offset;
attrref->Size = a_size;
attrref->Body = 0; // Fix
attrref->Body = a_tid;
}
return LDH__SUCCESS;
}
......@@ -1019,7 +1045,7 @@ int wb_vrepwbl::load_files( const char *file_spec)
bool wb_vrepwbl::registerObject( pwr_tOix oix, ref_wblnode node)
{
#if 0
cout << "RegObj: " << oix << " " << node->name << endl;
cout << "RegObj: " << oix << " " << node->name() << endl;
ref_wblnode n = findObject( oix);
if ( n)
......@@ -1062,7 +1088,7 @@ void wb_vrepwbl::registerVolume( const char *name, pwr_tCid cid, pwr_tVid vid, r
ref_wblnode wb_vrepwbl::find( const char *name)
{
wb_name oname(name);
wb_name oname = wb_name(name);
if ( oname.evenSts() || (oname.hasVolume() && !oname.volumeIsEqual(volume_name)))
return 0;
......@@ -1219,7 +1245,7 @@ void wb_vrepwbl::objectName(wb_orep *o, char *str)
}
for ( int i = cnt - 1; i >= 0; i--) {
strcat( str, vect[i]->name);
strcat( str, vect[i]->name());
if ( i == cnt - 1)
strcat( str, ":");
else if ( i != 0)
......
......@@ -329,7 +329,7 @@ ref_wblnode wb_wblnode::find( wb_name *oname, int level)
{
switch ( getType()) {
case tokens.OBJECT:
if ( oname->segmentIsEqual(name, level)) {
if ( oname->segmentIsEqual( name(), level)) {
if ( !oname->hasSegment(level+1))
return this;
else if ( o_fch)
......@@ -342,7 +342,7 @@ ref_wblnode wb_wblnode::find( wb_name *oname, int level)
else
return 0;
case tokens.VOLUME:
if ( oname->volumeIsEqual(name) && !oname->hasSegment(0))
if ( oname->volumeIsEqual( name()) && !oname->hasSegment(0))
return this;
else if ( o_fch)
return o_fch->find( oname, 0);
......@@ -358,7 +358,7 @@ void wb_wblnode::info_link( int level)
{
for ( int i = 0; i < level; i++)
cout << " ";
cout << name << " " << cname << " " << m_oid.oix << endl;
cout << name() << " " << cname << " " << m_oid.oix << " " << m_oid.vid << endl;
if ( o_fch)
o_fch->info_link( level + 1);
if ( o_fws)
......@@ -396,6 +396,10 @@ void wb_wblnode::build( bool recursive)
return;
}
else {
static int tot_size = 0;
tot_size += rbody_size + dbody_size;
// cout << name() << ": " << tot_size << " " << rbody_size << " " << dbody_size << endl;
m_vrep->getTemplateBody( m_cid, cdh_eBix_rt, &rbody_size, &rbody);
m_vrep->getTemplateBody( m_cid, cdh_eBix_dev, &dbody_size, &dbody);
}
......@@ -403,12 +407,21 @@ void wb_wblnode::build( bool recursive)
ref_wblnode first_child;
first_child = getFirstChild();
if ( first_child)
if ( first_child) {
if ( node_type == wbl_eNodeType_No) // Avoid infinite loop
is_built = 1;
first_child->buildBody( this);
if ( node_type == wbl_eNodeType_No)
is_built = 0;
}
if ( o_fch)
if ( o_fch && ( recursive || isClassDef())) {
if ( node_type == wbl_eNodeType_No)
is_built = 1;
o_fch->build( 1);
if ( node_type == wbl_eNodeType_No)
is_built = 0;
}
if ( isClassDef()) {
m_oid.oix = cdh_cixToOix( m_oid.oix, 0, 0);
if ( !m_vrep->registerObject( m_oid.oix, this))
......@@ -501,6 +514,8 @@ void wb_wblnode::build( bool recursive)
is_built = 1;
}
if ( recursive && o_fch)
o_fch->build( recursive);
if ( recursive && o_fws)
o_fws->build( recursive);
}
......@@ -653,11 +668,11 @@ void wb_wblnode::buildBody( ref_wblnode object)
switch ( getType()) {
case tokens.BODY:
if ( cdh_NoCaseStrcmp( name, "SysBody") == 0)
if ( cdh_NoCaseStrcmp( name(), "SysBody") == 0)
bix = cdh_eBix_sys;
else if ( cdh_NoCaseStrcmp( name, "RtBody") == 0)
else if ( cdh_NoCaseStrcmp( name(), "RtBody") == 0)
bix = cdh_eBix_rt;
else if ( cdh_NoCaseStrcmp( name, "DevBody") == 0)
else if ( cdh_NoCaseStrcmp( name(), "DevBody") == 0)
bix = cdh_eBix_dev;
else {
// Body exception
......@@ -685,17 +700,24 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix)
ref_wblnode second_child;
ref_wblnode next_sibling;
int oper;
char value[200];
char value[2048];
int size, offset, elements;
pwr_tTypeId tid;
pwr_eType type;
char buf[2048];
int int_val, current_int_val;
bool add_newline = false;
switch ( getType()) {
case tokens.ATTRIBUTE:
{
first_child = getFirstChild();
if ( first_child) {
if ( !first_child) {
// Attr exception
m_vrep->error( "Attribute syntax", getFileName(), line_number);
goto error_continue;
}
switch ( oper = first_child->getType()) {
case tokens.OREQ:
case tokens.EQ:
......@@ -703,17 +725,262 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix)
default:
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
goto error_continue;
}
second_child = first_child->getNextSibling();
if ( second_child) {
strcpy( value, second_child->name);
if ( !m_vrep->getAttrInfo( name, (cdh_eBix) bix, object->m_cid, &size, &offset,
if ( !m_vrep->getAttrInfo( name(), (cdh_eBix) bix, object->m_cid, &size, &offset,
&tid, &elements, &type)) {
// This might be string special syntax
wb_attrname n = wb_attrname( name());
if ( n.hasAttrIndex() &&
m_vrep->getAttrInfo( n.attribute(), (cdh_eBix) bix, object->m_cid, &size,
&offset, &tid, &elements, &type) &&
elements == 1 &&
(type == pwr_eType_String || type == pwr_eType_Text)) {
// Index in string attribute marks a new row
int index = n.attrIndex();
if ( index > 0) {
add_newline = true;
index--;
}
offset += index;
size = size - index;
}
else {
// Attr exception
m_vrep->error( "Unknown attribute", getFileName(), line_number);
goto error_continue;
}
}
second_child = first_child->getNextSibling();
if ( !second_child) {
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
goto error_continue;
}
if ( ((bix == cdh_eBix_rt || bix == cdh_eBix_sys) &&
object->rbody_size == 0) ||
(bix == cdh_eBix_dev && object->dbody_size == 0)) {
m_vrep->error( "Attribute body", getFileName(), line_number);
return;
}
if ( ((bix == cdh_eBix_rt || bix == cdh_eBix_sys) &&
offset + size > object->rbody_size) ||
( bix == cdh_eBix_rt &&
offset + size > object->rbody_size)) {
m_vrep->error( "Mismatch in attribute offset", getFileName(), line_number);
return;
}
if ( !add_newline)
strncpy( value, second_child->name(), sizeof(value));
else {
strncpy( &value[1], second_child->name(), sizeof(value)-1);
value[0] = '\n';
}
// printf( "Attr %s %s %d %d %s\n", object->name, name, size, offset, value);
if ( size == sizeof(int_val) && convconst( &int_val, value)) {
if ( oper == tokens.EQ) {
if ( bix == cdh_eBix_rt || bix == cdh_eBix_sys)
memcpy( (char *)((unsigned int) object->rbody + offset),
&int_val, size);
else if ( bix == cdh_eBix_dev)
memcpy( (char *)((unsigned int) object->dbody + offset),
&int_val, size);
}
else if ( oper == tokens.OREQ) {
if ( bix == cdh_eBix_rt || bix == cdh_eBix_sys) {
current_int_val = *(int *) ((unsigned int) object->rbody + offset);
int_val |= current_int_val;
memcpy( (char *)((unsigned int) object->rbody + offset),
&int_val, size);
}
else if ( bix == cdh_eBix_dev) {
current_int_val = *(int *) ((unsigned int) object->dbody + offset);
int_val |= current_int_val;
memcpy( (char *)((unsigned int) object->dbody + offset),
&int_val, size);
}
}
}
else if ( attrStringToValue( type, value, buf, sizeof( buf), size)) {
if ( bix == cdh_eBix_rt || bix == cdh_eBix_sys)
memcpy( (char *)((unsigned int) object->rbody + offset),
buf, size);
else if ( bix == cdh_eBix_dev)
memcpy( (char *)((unsigned int) object->dbody + offset),
buf, size);
}
else {
// Attr conversion exception
m_vrep->error( "Unable to convert string to value", getFileName(), line_number);
}
error_continue:
break;
}
case tokens.BUFFER:
{
buildBuff( object, bix, 0, 0, 0);
break;
}
default:
;
}
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->buildAttr( object, bix);
}
void wb_wblnode::buildBuff( ref_wblnode object, int bix, pwr_tCid buffer_cid,
int buffer_offset, int buffer_size)
{
ref_wblnode first_child;
int size, offset, elements;
pwr_tStatus sts;
pwr_tCid host_cid;
if ( buffer_cid != 0) {
// Buffer in buffer... Fix
host_cid = buffer_cid;
}
else
host_cid = object->m_cid;
wb_cdrep *cdrep = m_vrep->merep()->cdrep( &sts, host_cid);
if ( EVEN(sts)) {
m_vrep->error( "Unknown class of buffer owner", getFileName(), line_number);
return;
}
wb_attrname aname = wb_attrname( name());
wb_adrep *adrep = cdrep->adrep( &sts, aname.attribute());
if ( EVEN(sts)) {
m_vrep->error( "Unknown Buffer", getFileName(), line_number);
delete cdrep;
return;
}
pwr_tCid cid = adrep->bufferClass();
size = adrep->size();
offset = adrep->offset();
elements = adrep->nElement();
delete cdrep;
delete adrep;
first_child = getFirstChild();
if ( first_child && first_child->getType() == tokens.INDEX) {
int index;
int nr = sscanf( first_child->name(), "%d", &index);
if ( nr != 1) {
m_vrep->error( "Buffer index syntax error", getFileName(), line_number);
return;
}
if ( index >= elements) {
m_vrep->error( "Buffer index exceeded", getFileName(), line_number);
return;
}
size = size / elements;
offset += index * size;
}
if ( buffer_cid != 0)
offset += buffer_offset;
if ( first_child)
first_child->buildBuffAttr( object, bix, cid, offset, size);
}
void wb_wblnode::buildBuffAttr( ref_wblnode object, int bix, pwr_tCid buffer_cid,
int buffer_offset, int buffer_size)
{
ref_wblnode first_child;
ref_wblnode second_child;
ref_wblnode next_sibling;
int oper;
char value[2048];
int size, offset, elements;
pwr_tTypeId tid;
pwr_eType type;
char buf[2048];
int int_val, current_int_val;
wb_cdrep *cdrep;
wb_adrep *adrep;
wb_attrname aname;
switch ( getType()) {
case tokens.ATTRIBUTE:
{
first_child = getFirstChild();
if ( !first_child) {
// Attr exception
m_vrep->error( "Attribute syntax", getFileName(), line_number);
goto error_continue;
}
switch ( oper = first_child->getType()) {
case tokens.OREQ:
case tokens.EQ:
break;
default:
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
goto error_continue;
}
pwr_tStatus sts;
cdrep = m_vrep->merep()->cdrep( &sts, buffer_cid);
if ( EVEN(sts)) {
m_vrep->error( "Error in buffer class", getFileName(), line_number);
goto error_continue;
}
aname = wb_attrname( name());
// Backward compability with V3.4 : classid was named class
// This section can be removed in later versions
if ( strcmp( name(), "class") == 0 &&
(strcmp( cdrep->name(), "$PlcProgram") == 0 ||
strcmp( cdrep->name(), "$PlcWindow") == 0 ||
strcmp( cdrep->name(), "$PlcNode") == 0 ||
strcmp( cdrep->name(), "$PlcConnection") == 0))
adrep = cdrep->adrep( &sts, "classid");
else
// end of compability section
adrep = cdrep->adrep( &sts, aname.attribute());
if ( EVEN(sts)) {
m_vrep->error( "Unknown buffer attribute", getFileName(), line_number);
delete cdrep;
goto error_continue;
}
size = adrep->size();
offset = adrep->offset() + buffer_offset;
tid = adrep->tid();
elements = adrep->nElement();
type = adrep->type();
if ( aname.hasAttrIndex()) {
int index = aname.attrIndex();
if ( index >= elements) {
m_vrep->error( "Max attribute index exceeded", getFileName(), line_number);
goto error_continue;
}
offset += index * size / elements;
}
delete cdrep;
delete adrep;
second_child = first_child->getNextSibling();
if ( !second_child) {
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
goto error_continue;
}
if ( ((bix == cdh_eBix_rt || bix == cdh_eBix_sys) &&
object->rbody_size == 0) ||
(bix == cdh_eBix_dev && object->dbody_size == 0)) {
......@@ -729,6 +996,8 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix)
return;
}
strcpy( value, second_child->name());
// printf( "Attr %s %s %d %d %s\n", object->name, name, size, offset, value);
if ( size/elements == sizeof(int_val) && convconst( &int_val, value)) {
if ( oper == tokens.EQ) {
......@@ -766,27 +1035,20 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix)
// Attr conversion exception
m_vrep->error( "Unable to convert string to value", getFileName(), line_number);
}
error_continue:
break;
}
}
else {
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
}
}
else {
// Attr exception
m_vrep->error( "Attribute syntax", getFileName(), line_number);
}
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->buildAttr( object, bix);
case tokens.BUFFER:
{
buildBuff( object, bix, buffer_cid, buffer_offset, buffer_size);
break;
}
default:
;
}
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->buildAttr( object, bix);
}
next_sibling->buildBuffAttr( object, bix, buffer_cid, buffer_offset, buffer_size);
}
void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father)
......@@ -821,7 +1083,7 @@ void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father)
break;
case tokens.SOBJECT:
{
ref_wblnode snode = m_vrep->find( name);
ref_wblnode snode = m_vrep->find( name());
if ( !snode) {
// SObject exception
m_vrep->error( "SObject syntax", getFileName(), line_number);
......@@ -855,10 +1117,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
switch ( getType()) {
case tokens.OBJECT:
{
string objectname = getText();
strcpy( name, objectname.c_str());
if ( !wb_name::checkObjectName( name)) {
if ( !wb_name::checkObjectName( name())) {
m_vrep->error( "Bad object name", getFileName(), line_number);
}
......@@ -959,7 +1218,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
if ( isClassDef()) {
c_cid = cdh_cixToCid( m_vrep->vid(), m_oid.oix);
c_cix = m_oid.oix;
m_vrep->registerClass( name, c_cid, this);
m_vrep->registerClass( name(), c_cid, this);
// Find Template object
ref_wblnode child = first_child;
......@@ -987,7 +1246,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
last_child->setNextSibling( (RefAST)c_template);
else
setFirstChild( (RefAST)c_template);
strcpy( c_template->cname, name);
strcpy( c_template->cname, name());
// c_template->m_oid.oix = m_vrep->nextOix();
c_template->m_cid = c_cid;
c_template->node_type = wbl_eNodeType_Template;
......@@ -995,11 +1254,11 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
}
else if ( isType()) {
m_tid = cdh_tixToTid( m_vrep->vid(), 0, m_oid.oix);
m_vrep->registerType( name, m_tid, this);
m_vrep->registerType( name(), m_tid, this);
}
else if ( isTypeDef()) {
m_tid = cdh_tixToTid( m_vrep->vid(), 1, m_oid.oix);
m_vrep->registerType( name, m_tid, this);
m_vrep->registerType( name(), m_tid, this);
}
else if ( isObjBodyDef()) {
b_bix = m_oid.oix;
......@@ -1012,8 +1271,6 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
{
pwr_tVid vid;
int sts;
string objectname = getText();
strcpy( name, objectname.c_str());
// Get class
if ( first_child) {
......@@ -1055,7 +1312,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
m_vrep->error( "Volume class is missing", getFileName(), line_number);
}
// Register volume
m_vrep->registerVolume( name, m_cid, vid, this);
m_vrep->registerVolume( name(), m_cid, vid, this);
break;
}
......@@ -1066,18 +1323,19 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
case tokens.INT:
case tokens.NUM_FLOAT:
{
string objectname = getText();
strcpy( name, objectname.c_str());
break;
}
case tokens.STRING_LITERAL:
case tokens.CHAR_LITERAL:
{
// Remove quotes
string objectname = getText();
const char *name_p = objectname.c_str();
strcpy( name, &name_p[1]);
name[strlen(name)-1] = 0;
char str[1032];
string text = getText();
const char *text_p = text.c_str();
strncpy( str, &text_p[1], sizeof(str));
str[strlen(str)-1] = 0;
string new_text(str);
setText(new_text);
break;
}
default:
......@@ -1101,9 +1359,10 @@ void wb_wblnode::iterObject( wb_dbs *dbs)
pwr_tOid bwsoid = o_bws ? o_bws->m_oid : pwr_cNOid;
pwr_tOid fchoid = o_fch ? o_fch->m_oid : pwr_cNOid;
pwr_tOid lchoid = o_lch ? o_lch->m_oid : pwr_cNOid;
wb_name n = wb_name(name);
wb_name n = wb_name(name());
dbs->installObject( m_oid, m_cid, fthoid, fwsoid, bwsoid, fchoid, lchoid, name, n.normName(cdh_mName_object),
dbs->installObject( m_oid, m_cid, fthoid, fwsoid, bwsoid, fchoid, lchoid,
(char *)name(), n.normName(cdh_mName_object),
getFileTime(), getFileTime(), getFileTime(), rbody_size, dbody_size);
if ( o_fch)
......
......@@ -48,7 +48,6 @@ public:
line_number(0), file(0), is_built(0), c_cid(0), c_cix(0), c_template(0),
b_bix(0), a_tid(0), a_size(0), a_offset(0), a_elements(0), a_flags(0)
{
strcpy( name, "");
strcpy( cname, "");
}
wb_wblnode(antlr::RefToken t) :
......@@ -90,7 +89,8 @@ public:
// Test
static int last = 0;
if ( (line_number % 1000) == 0 && line_number != last) {
printf( "Line: %d\n", line_number);
printf( "-- Processing line: %d\r", line_number);
fflush(stdout);
last = line_number;
}
}
......@@ -169,6 +169,10 @@ public:
void buildTemplate( ref_wblnode classdef);
void buildBody( ref_wblnode object);
void buildAttr( ref_wblnode object, int bix);
void buildBuff( ref_wblnode object, int bix, pwr_tCid buffer_cid,
int buffer_offset, int buffer_size);
void buildBuffAttr( ref_wblnode object, int bix, pwr_tCid buffer_cid,
int buffer_offset, int buffer_size);
void link( wb_vrepwbl *vol, ref_wblnode father_node);
void info_link( int level);
ref_wblnode find( wb_name *oname, int level);
......@@ -202,8 +206,7 @@ public:
pwr_tCid m_cid;
pwr_tTid m_tid;
pwr_tOid m_oid;
char name[200];
// char *name() { return getText().c_str();}
const char *name() { return getText().c_str();}
char cname[32];
wb_vrepwbl *m_vrep;
wb_wblnode *o_fth;
......
......@@ -3452,6 +3452,7 @@ static int wnav_create_func( void *client_data,
wb_erep *erep = *(wb_env *)wnav->wbctx;
wb_vrepwbl *wbl = new wb_vrepwbl(erep);
wbl->load( filestr);
printf( "-- Loadfile loaded, snapshot creation started...\n");
wbl->createSnapshot( outstr);
delete wbl;
}
......
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