Commit a6966dbf authored by claes's avatar claes

New type DataRef

parent b6f78634
/*
* Proview $Id: cnv_wbltoh.cpp,v 1.7 2005-09-22 14:54:46 claes Exp $
* Proview $Id: cnv_wbltoh.cpp,v 1.8 2005-10-18 05:07:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -965,6 +965,7 @@ int CnvWblToH::check_typename( char *type_volume, char *type_name)
"pwr_tOpSysEnum",
"pwr_tPrivMask",
"pwr_tProString40",
"pwr_tDataRef",
""};
for ( name = valid_names[0]; strcmp(name,"") != 0;
......
/*
* Proview $Id: pwr.h,v 1.18 2005-10-07 05:57:28 claes Exp $
* Proview $Id: pwr.h,v 1.19 2005-10-18 05:07:40 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -466,6 +466,14 @@ typedef struct {
pwr_mAttrRef Flags; //!< Attribute flags.
} pwr_sAttrRef;
/*_*
@aref dataref DataRef
*/
typedef struct {
void *Ptr; //!< Private plc pointer to data object.
pwr_sAttrRef Aref; //!< Attribute reference to data object.
} pwr_tDataRef;
/*_*
@aref constants Constants
*/
......
/*
* Proview $Id: pwr_class.h,v 1.18 2005-10-12 13:07:42 claes Exp $
* Proview $Id: pwr_class.h,v 1.19 2005-10-18 05:07:40 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -146,6 +146,7 @@ typedef enum {
pwr_eTix_CastId = 31, /* Basic type */
pwr_eTix_ProString = 32, /* Basic type */
pwr_eTix_DisableAttr = 33, /* Basic type */
pwr_eTix_DataRef = 34, /* Basic type */
pwr_eTix_
} pwr_eTix;
......@@ -189,6 +190,7 @@ typedef enum {
pwr_eType_CastId = pwr_TypeId(pwr_eTix_CastId),
pwr_eType_ProString = pwr_TypeId(pwr_eTix_ProString),
pwr_eType_DisableAttr = pwr_TypeId(pwr_eTix_DisableAttr),
pwr_eType_DataRef = pwr_TypeId(pwr_eTix_DataRef),
pwr_eType_ = pwr_TypeId(pwr_eTix_)
} pwr_eType;
......
/*
* Proview $Id: wb_print_wbl.cpp,v 1.14 2005-10-07 05:57:29 claes Exp $
* Proview $Id: wb_print_wbl.cpp,v 1.15 2005-10-18 05:12:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -540,6 +540,7 @@ void wb_print_wbl::printParameter(wb_volume& v,
case pwr_eType_Enum:
case pwr_eType_Status:
case pwr_eType_NetStatus:
case pwr_eType_DataRef:
varOffset = varSize * i;
val = valueb + varOffset;
tval = tvalueb + varOffset;
......@@ -747,13 +748,25 @@ bool wb_print_wbl::printValue (wb_volume& v,
sprintf(sval, "\"%s\"", cdh_ArefToString(NULL, (pwr_sAttrRef*)val, 1));
}
}
#if 0
} else {
ConvertObjectName( root, sp, conv_name);
sprintf(sval, "\"%s\"", conv_name);
}
#endif
break;
case pwr_eType_DataRef:
if (cdh_ObjidIsNull(((pwr_tDataRef*)val)->Aref.Objid))
sprintf(sval, "0");
else {
wb_attribute a = v.attribute( &((pwr_tDataRef*)val)->Aref);
if (a)
sprintf(sval, "\"%s\"", a.longName().c_str());
else {
sprintf(sval, "\"%s\"", cdh_ArefToString(NULL, &((pwr_tDataRef*)val)->Aref, 1));
}
}
break;
case pwr_eType_String:
case pwr_eType_ProString: {
......
/*
* Proview $Id: wb_treeimport.cpp,v 1.4 2005-09-06 10:43:32 claes Exp $
* Proview $Id: wb_treeimport.cpp,v 1.5 2005-10-18 05:12:47 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -119,6 +119,20 @@ bool wb_treeimport::importUpdateSubClass( wb_adrep *subattr, char *body, wb_vrep
}
break;
}
case pwr_eType_DataRef: {
pwr_tDataRef *drp = (pwr_tDataRef *)(body + i * subattr->size() / subattr_elements +
adrep->offset());
for ( int j = 0; j < elements; j++) {
if ( drp->Aref.Objid.vid == m_import_source_vid &&
(oix = importTranslate( drp->Aref.Objid.oix))) {
drp->Aref.Objid.vid = vrep->vid();
drp->Aref.Objid.oix = oix;
*modified = true;
}
drp++;
}
break;
}
default:
;
}
......@@ -165,7 +179,7 @@ bool wb_treeimport::importUpdateObject( wb_orep *o, wb_vrep *vrep)
switch ( adrep->type()) {
case pwr_eType_Objid: {
pwr_tOid *oidp = (pwr_tOid *)(body + adrep->offset());
for ( i = 0; i < elements; i++) {
for ( int j = 0; j < elements; j++) {
if ( oidp->vid == m_import_source_vid && (oix = importTranslate( oidp->oix))) {
oidp->vid = vrep->vid();
oidp->oix = oix;
......@@ -177,7 +191,7 @@ bool wb_treeimport::importUpdateObject( wb_orep *o, wb_vrep *vrep)
}
case pwr_eType_AttrRef: {
pwr_sAttrRef *arp = (pwr_sAttrRef *)(body + adrep->offset());
for ( i = 0; i < elements; i++) {
for ( int j = 0; j < elements; j++) {
if ( arp->Objid.vid == m_import_source_vid && (oix = importTranslate( arp->Objid.oix))) {
arp->Objid.vid = vrep->vid();
arp->Objid.oix = oix;
......@@ -187,6 +201,19 @@ bool wb_treeimport::importUpdateObject( wb_orep *o, wb_vrep *vrep)
}
break;
}
case pwr_eType_DataRef: {
pwr_tDataRef *drp = (pwr_tDataRef *)(body + adrep->offset());
for ( int j = 0; j < elements; j++) {
if ( drp->Aref.Objid.vid == m_import_source_vid &&
(oix = importTranslate( drp->Aref.Objid.oix))) {
drp->Aref.Objid.vid = vrep->vid();
drp->Aref.Objid.oix = oix;
modified = true;
}
drp++;
}
break;
}
default:
;
}
......
/*
* Proview $Id: wb_vrepwbl.cpp,v 1.44 2005-09-06 10:43:32 claes Exp $
* Proview $Id: wb_vrepwbl.cpp,v 1.45 2005-10-18 05:13:38 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1128,21 +1128,46 @@ 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, pwr_eBix_rt);
if ( EVEN(sts)) return sts;
ref_wblnode cn = findClass( cid);
if ( cn) {
if ( !cn->o->is_built)
cn->build( 0);
attrref->Objid = oid;
attrref->Offset = 0;
attrref->Size = bdrep->size();
attrref->Body = cdh_TypeObjidToId( bdrep->boid());
attrref->Flags.m = 0;
attrref->Flags.b.Object = 1;
// Get body object
wb_wblnode *n_body = cn->o->fch;
while( n_body) {
if ( n_body->isObjBodyDef() && n_body->o->b.bix == pwr_eBix_rt)
break;
n_body = n_body->o->fws;
}
if ( !n_body)
return LDH__NOSUCHBODY;
delete cdrep;
delete bdrep;
attrref->Objid = oid;
attrref->Offset = 0;
attrref->Size = n_body->o->b.size;
attrref->Body = cdh_TypeObjidToId( n_body->o->m_oid);
attrref->Flags.m = 0;
attrref->Flags.b.Object = 1;
}
else {
wb_cdrep *cdrep = m_merep->cdrep( &sts, cid);
if ( EVEN(sts)) return sts;
wb_bdrep *bdrep = cdrep->bdrep( &sts, pwr_eBix_rt);
if ( EVEN(sts)) return sts;
attrref->Objid = oid;
attrref->Offset = 0;
attrref->Size = bdrep->size();
attrref->Body = cdh_TypeObjidToId( bdrep->boid());
attrref->Flags.m = 0;
attrref->Flags.b.Object = 1;
delete cdrep;
delete bdrep;
}
}
else {
aname.setShadowed(true);
......
/*
* Proview $Id: wb_wblnode.cpp,v 1.49 2005-10-07 11:28:25 claes Exp $
* Proview $Id: wb_wblnode.cpp,v 1.50 2005-10-18 05:14:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -107,6 +107,8 @@ static wbl_sSym datatypes[] =
,{ "pwr_eTdix_ClassDefFlags", pwr_eTdix_ClassDefFlags }
,{ "pwr_eTypeDef_ObjBodyDefFlags", pwr_eTypeDef_ObjBodyDefFlags }
,{ "pwr_eTdix_ObjBodyDefFlags", pwr_eTdix_ObjBodyDefFlags }
,{ "pwr_eType_DataRef", pwr_eType_DataRef }
,{ "pwr_eTix_DataRef", pwr_eTix_DataRef }
,{ 0, 0 }
};
......@@ -2170,6 +2172,18 @@ int wb_wblnode::attrStringToValue( int type_id, char *value_str,
break;
}
case pwr_eType_DataRef:
{
pwr_tDataRef dataref;
sts = m_vrep->nameToAttrRef( value_str, &dataref.Aref);
if (EVEN(sts)) return 0;
dataref.Ptr = 0;
memcpy( buffer_ptr, &dataref, sizeof(dataref));
break;
}
case pwr_eType_Time:
{
pwr_tTime time;
......
/*
* Proview $Id: wb_wnav.cpp,v 1.24 2005-10-07 05:57:29 claes Exp $
* Proview $Id: wb_wnav.cpp,v 1.25 2005-10-18 05:14:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -274,6 +274,16 @@ int wnav_attr_string_to_value( ldh_tSesContext ldhses, int type_id, char *value
memcpy( buffer_ptr, &attrref, sizeof(attrref));
break;
}
case pwr_eType_DataRef:
{
pwr_tDataRef dataref;
dataref.Ptr = 0;
sts = ldh_NameToAttrRef( ldhses, value_str, &dataref.Aref);
if (EVEN(sts)) return WNAV__OBJNOTFOUND;
memcpy( buffer_ptr, &dataref, sizeof(dataref));
break;
}
case pwr_eType_Time:
{
pwr_tTime time;
......@@ -442,6 +452,30 @@ void wnav_attrvalue_to_string( ldh_tSesContext ldhses, int type_id, void *value
*buff = str;
break;
}
case pwr_eType_DataRef:
{
char *name_p;
pwr_tDataRef *dataref;
ldh_sVolumeInfo info;
ldh_GetVolumeInfo( ldh_SessionToVol( ldhses), &info);
dataref = (pwr_tDataRef *) value_ptr;
if ( dataref->Aref.Objid.vid == info.Volume)
sts = ldh_AttrRefToName( ldhses, &dataref->Aref, ldh_eName_Aref, &name_p, len);
else
sts = ldh_AttrRefToName( ldhses, &dataref->Aref, ldh_eName_ArefVol, &name_p, len);
if (EVEN(sts))
{
strcpy( str, "");
*len = 0;
*buff = str;
break;
}
strcpy( str, name_p);
*buff = str;
break;
}
case pwr_eType_Time:
{
sts = time_AtoAscii( (pwr_tTime *) value_ptr, time_eFormat_DateAndTime,
......@@ -1187,6 +1221,7 @@ static void wnav_type_id_to_name( int type_id, char *type_id_name)
case pwr_eType_ObjectIx: strcpy( type_id_name, "ObjectIx"); break;
case pwr_eType_RefId: strcpy( type_id_name, "RefId"); break;
case pwr_eType_DeltaTime: strcpy( type_id_name, "DeltaTime"); break;
case pwr_eType_DataRef: strcpy( type_id_name, "DataRef"); break;
default: strcpy( type_id_name, "");
}
}
......
/*
* Proview $Id: xtt_xnav.cpp,v 1.21 2005-10-07 05:57:28 claes Exp $
* Proview $Id: xtt_xnav.cpp,v 1.22 2005-10-18 05:07:40 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -416,6 +416,16 @@ int xnav_attr_string_to_value( int type_id, char *value_str,
memcpy( buffer_ptr, &attrref, sizeof(attrref));
break;
}
case pwr_eType_DataRef:
{
pwr_tDataRef dataref;
sts = gdh_NameToAttrref ( pwr_cNObjid, value_str, &dataref.Aref);
if (EVEN(sts)) return XNAV__OBJNOTFOUND;
dataref.Ptr = 0;
memcpy( buffer_ptr, &dataref, sizeof(dataref));
break;
}
case pwr_eType_Time:
{
pwr_tTime time;
......@@ -596,7 +606,22 @@ void xnav_attrvalue_to_string( int type_id, pwr_tTid tid, void *value_ptr,
case pwr_eType_AttrRef:
{
attrref = (pwr_sAttrRef *) value_ptr;
sts = gdh_AttrrefToName ( attrref, hiername, sizeof(hiername), cdh_mNName);
sts = gdh_AttrrefToName( attrref, hiername, sizeof(hiername), cdh_mNName);
if (EVEN(sts))
{
strcpy( str, "");
*len = 0;
break;
}
*len = sprintf( str, "%s", hiername);
break;
}
case pwr_eType_DataRef:
{
pwr_tDataRef *dataref;
dataref = (pwr_tDataRef *) value_ptr;
sts = gdh_AttrrefToName( &dataref->Aref, hiername, sizeof(hiername), cdh_mNName);
if (EVEN(sts))
{
strcpy( str, "");
......
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