예제 #1
0
bool wb_recix::add_object_ctree( wb_object &o) {

  add( o.longName().c_str(), o.oid().oix);
  for ( wb_object ch = o.first(); ch; ch = ch.after())
    add_object_tree( ch);
  return true;
}
예제 #2
0
static void process( wb_session& session, wb_object& o)
{
  pwr_sPlcNode plcnode;

  if ( o.cid() == pwr_cClass_csub) {
    printf ( "Object: %s\n", o.longName().c_str());

    wb_attribute a = session.attribute( o.oid(), "DevBody", "PlcNode");
    if ( !a) exit(0);

    a.value( &plcnode);

    printf( "subwindow:  %d, woid: %u,%u\n", plcnode.subwindow, 
	    plcnode.subwind_oid[0].vid, plcnode.subwind_oid[0].oix);

    wb_object c = o.first();
    if ( c && c.cid() == pwr_cClass_windowplc) {
      plcnode.subwind_oid[0].vid = c.oid().vid;
      plcnode.subwind_oid[0].oix = c.oid().oix;

      printf( "subwindow:  %d, woid: %u,%u\n", plcnode.subwindow, 
	      plcnode.subwind_oid[0].vid, plcnode.subwind_oid[0].oix);

      session.writeAttribute( a, &plcnode, sizeof(plcnode)); 
      if ( !a) cout << "** Write error" << endl;
    }
  }

  for ( wb_object c = o.first(); c.oddSts(); c = c.after()) {
    process( session, c);
  }
}
예제 #3
0
pwr_tStatus wb_volume::triggPostCreate(wb_object& o)
{
  pwr_tStatus sts;
  char *methodName;
  wb_tMethod method;
  
  // Call object method, or inherited method
  for ( wb_cdef cd = cdef(o.cid()); cd; cd = cd.super()) {
    wb_cdrep *cdrep = cd;
    
    cdrep->dbCallBack(&sts, ldh_eDbCallBack_PostCreate, &methodName, 0);

    if (ODD(sts)) {
      m_vrep->erep()->method(&sts, methodName, &method);
      if (EVEN(sts)) return LDH__SUCCESS;

      wb_object father = o.parent();
      if (father) {
	sts = ((wb_tMethodPostCreate) (method))((ldh_tSesContext)this, o.oid(), father.oid(),
						father.cid());
      }
      else
	sts = ((wb_tMethodPostCreate) (method))((ldh_tSesContext)this, o.oid(), pwr_cNObjid,
						pwr_cNClassId);
      return sts;
    }
  }

  return LDH__SUCCESS;
}
예제 #4
0
pwr_tStatus wb_volume::triggPostMove(wb_object& o)
{
  pwr_tStatus sts;
  char *methodName;
  wb_tMethod method;
  
  wb_cdrep *cdrep = m_vrep->merep()->cdrep(&sts, o.cid());
  if (EVEN(sts)) return sts;

  cdrep->dbCallBack(&sts, ldh_eDbCallBack_PostMove, &methodName, 0);
  delete cdrep;
  if (EVEN(sts)) return LDH__SUCCESS;

  m_vrep->erep()->method(&sts, methodName, &method);
  if (EVEN(sts)) return LDH__SUCCESS;

  wb_object father = o.parent();
  if (father) {
    sts = ((wb_tMethodPostMove) (method))((ldh_tSesContext)this, o.oid(), father.oid(),
					   father.cid());
  }
  else
    sts = ((wb_tMethodPostMove) (method))((ldh_tSesContext)this, o.oid(), pwr_cNObjid,
					   pwr_cNClassId);
  return sts;
}
예제 #5
0
pwr_tStatus wb_volume::triggAnteMove(wb_object& o, wb_object& father, wb_object& old_father)
{
  pwr_tStatus sts;
  char *methodName;
  wb_tMethod method;
  pwr_tOid foid;
  pwr_tOid old_foid;
  
  wb_cdrep *cdrep = m_vrep->merep()->cdrep(&sts, o.cid());
  if (EVEN(sts)) return sts;

  cdrep->dbCallBack(&sts, ldh_eDbCallBack_AnteMove, &methodName, 0);
  delete cdrep;
  if (EVEN(sts)) return LDH__SUCCESS;

  m_vrep->erep()->method(&sts, methodName, &method);
  if (EVEN(sts)) return LDH__SUCCESS;

  if (father)
    foid = father.oid();
  else
    foid = pwr_cNObjid;

  if (old_father)
    old_foid = old_father.oid();
  else
    old_foid = pwr_cNObjid;

  sts = ((wb_tMethodAnteMove) (method))((ldh_tSesContext)this, o.oid(), foid,
					 old_foid);
  return sts;
}
예제 #6
0
bool wb_session::deleteFamily(wb_object o, bool storeix)
{
  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  if (!isLocal(o)) {
    m_sts = LDH__OTHERVOLUME;
    return false;
  }

  pwr_tStatus sts;
  wb_object parent = o.parent();
  sts = triggAnteUnadopt(parent, o);

  ldh_sEvent* ep = m_srep->eventStart(o.oid(), ldh_eEvent_ObjectDeleted);
  m_srep->eventOldFamily(ep, o);

  sts = triggPostUnadopt(parent, o);

  if (storeix)
    m_srep->recix_add(o);
  bool rsts = m_vrep->deleteFamily(&m_sts, (wb_orep*)o);
  m_srep->update();
  m_srep->eventSend(ep);
  return rsts;
}
예제 #7
0
pwr_tStatus wb_volume::triggAnteAdopt(wb_object& father, pwr_tCid cid)
{
  pwr_tStatus sts;
  char *methodName;
  wb_tMethod method;
  pwr_tOid foid;
  
  if (!father)
    return LDH__SUCCESS;

  wb_cdrep *cdrep = m_vrep->merep()->cdrep(&sts, father.cid());
  if (EVEN(sts)) return sts;

  cdrep->dbCallBack(&sts, ldh_eDbCallBack_AnteAdopt, &methodName, 0);
  delete cdrep;
  if (EVEN(sts)) return LDH__SUCCESS;

  m_vrep->erep()->method(&sts, methodName, &method);
  if (EVEN(sts)) return LDH__SUCCESS;

  if (!father)
    foid = pwr_cNObjid;
  else
    foid = father.oid();

  sts = ((wb_tMethodAnteAdopt) (method))((ldh_tSesContext)this, foid, cid);
  return sts;
}
예제 #8
0
bool wb_session::moveObject(wb_object o, wb_destination d)
{
  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  validateDestination(d, o.cid());
  if (evenSts())
    return false;

  // Check that object is not ancestor to destination
  wb_object dest = object(d.oid());
  while (dest) {
    if (cdh_ObjidIsEqual(dest.oid(), o.oid()))
      throw wb_error(LDH__BADDEST);
    dest = dest.parent();
  }

  wb_object parent;
  switch (d.code()) {
  case ldh_eDest_IntoFirst:
  case ldh_eDest_IntoLast:
    parent = object(d.oid());
    break;
  case ldh_eDest_After:
  case ldh_eDest_Before:
    parent = object(d.oid()).parent();
    break;
  default:
    throw wb_error(LDH__NODEST);
  }

  wb_object old_parent = o.parent();
  m_sts = triggAnteMove(o, parent, old_parent);
  if (evenSts())
    return false;
  m_sts = triggAnteUnadopt(old_parent, o);
  if (evenSts())
    return false;
  m_sts = triggAnteAdopt(parent, o.cid());
  if (evenSts())
    return false;

  ldh_sEvent* ep = m_srep->eventStart(o.oid(), ldh_eEvent_ObjectMoved);
  m_srep->eventOldFamily(ep, o);

  bool rsts = m_vrep->moveObject(&m_sts, (wb_orep*)o, d);
  m_srep->update();

  triggPostMove(o);
  triggPostUnadopt(old_parent, o);
  triggPostAdopt(parent, o);

  m_srep->eventNewFamily(ep, o);
  m_srep->eventSend(ep);

  return rsts;
}
예제 #9
0
bool wb_volume::isAncestor(wb_object& ancestor, wb_object& o)
{
  if (ancestor.oid().vid != o.oid().vid)
    return false;

  wb_object p = o.parent();
  while (p) {
    if (p.oid().oix == ancestor.oid().oix)
      return true;
    p = p.parent();
  }
  return false;
}
예제 #10
0
pwr_tStatus wb_volume::syntaxCheckObject(wb_object& o, int *errorcount, int *warningcount)
{
  pwr_tStatus sts, csts;
  wb_object first, after;
  wb_attribute a(o.sts(), o);
  
  sts = triggSyntaxCheck(a, errorcount, warningcount);
  if (EVEN(sts)) return sts;

  // Get any attribute objects
  wb_cdef cd = cdef(o);
  if ( !cd) return cd.sts();

  wb_bdef bdef = cd.bdef(pwr_eBix_rt);
  wb_adef adef;
  if ( bdef) {
    for (adef = bdef.adef(); adef; adef = adef.next()) {
      if ( !(adef.flags() & PWR_MASK_CLASS))
	continue;

      if ( adef.flags() & PWR_MASK_ARRAY) {
	for ( int i = 0; i < adef.nElement(); i++) {
	  wb_attribute a( adef.sts(), o, adef, i);
	  
	  csts = syntaxCheckAttr( a, errorcount, warningcount);
	  if ( EVEN(csts)) sts = csts;
	}
      }
      else {
	wb_attribute a( adef.sts(), o, adef);
	
	if ( adef.flags() & PWR_MASK_DISABLEATTR && a.disabled())
	  continue;

	csts = syntaxCheckAttr( a, errorcount, warningcount);
	if ( EVEN(csts)) sts = csts;
      }
    }
  }


  for ( wb_object c = o.first(); c; c = c.after()) {
    if ( c.cid() == pwr_eClass_LibHier)
      continue;
    csts = syntaxCheckObject(c, errorcount, warningcount);
    if ( EVEN(csts))
      sts = csts;
  }

  return sts;
}
예제 #11
0
void wb_volume::aref(pwr_tCid cid, wb_object o, pwr_sAttrRef *arp)
{
  tree_sTable *catt_tt = m_vrep->merep()->buildCatt(&m_sts);

  merep_sClassAttrKey key;
  merep_sClassAttr *item;

  key.subCid = cid;
  key.hostCid = o.cid();
  key.idx = 0;
  item = (merep_sClassAttr *) tree_Find(&m_sts, catt_tt, &key);
  if (item == NULL) {
    m_sts = LDH__CLASSLIST;
    return;
  }

  wb_cdrep *cd = m_vrep->merep()->cdrep(&m_sts, cid);
  if (evenSts()) return;

  int bd_size;
  wb_bdrep *bd = cd->bdrep(&m_sts, pwr_eBix_rt);
  if (oddSts()) {
    bd_size = bd->size();
    delete bd;
  }
  else
    bd_size = 0;
  delete cd;
  
  *arp = pwr_cNAttrRef;
  arp->Objid = o.oid();
  arp->Flags.b.ObjectAttr = 1;
  arp->Offset = item->offset[0];
  arp->Size = bd_size;
  arp->Body = cdh_cidToBid( cid, pwr_eBix_rt);

  if (item->flags[0] & PWR_MASK_DISABLEATTR) {
    wb_attribute a = attribute(arp);
    if (a.disabled()) {
      pwr_sAttrRef aref = *arp;
      nextObjectAref(cid, &aref, arp);
    }
  }
}
예제 #12
0
bool wb_recix::add_object_tree( wb_object &o) {

  clear();

  wb_object p = o.parent();
  if ( p)
    strcpy( m_srcroot, p.longName().c_str());

  add( o.longName().c_str(), o.oid().oix);
  for ( wb_object ch = o.first(); ch; ch = ch.after())
    add_object_ctree( ch);


  // for (  ix_iterator it = m_ix.begin(); it != m_ix.end(); it++) {
  //   cout << " Object: " << it->second << "  " << it->first << endl;
  // }  

  return true;
}
예제 #13
0
pwr_tStatus wb_volume::triggPostRename(wb_object& o)
{
  pwr_tStatus sts;
  char *methodName;
  wb_tMethod method;
  
  wb_cdrep *cdrep = m_vrep->merep()->cdrep(&sts, o.cid());
  if (EVEN(sts)) return sts;

  cdrep->dbCallBack(&sts, ldh_eDbCallBack_PostRename, &methodName, 0);
  delete cdrep;
  if (EVEN(sts)) return LDH__SUCCESS;

  m_vrep->erep()->method(&sts, methodName, &method);
  if (EVEN(sts)) return LDH__SUCCESS;

  sts = ((wb_tMethodPostRename) (method))((ldh_tSesContext)this, o.oid());
  return sts;
}
예제 #14
0
//
// printHierarchy
//
void wb_print_wbl::printHierarchy(wb_volume& v, wb_object& o)
{
  if (v.object() == o)
    indent(1) << "SObject " << v.name() << ":" << endl;
  else
    indent(1) << "SObject " << o.parent().longName() << endl;
  
  printObject(v, o);
  
  indent(-1) << "EndSObject" << endl;
}
예제 #15
0
static bool CheckChildCid( wb_object &o, pwr_tCid cid) 
{
  for ( wb_object child = o.first(); child; child = child.after()) {
    if ( child.cid() == cid) {
      return true;
    }
    if ( CheckChildCid( child, cid))
      return true;	 
  }
  return false;
}
예제 #16
0
void wb_srep::eventOldFamily( ldh_sEvent *ep, wb_object o)
{

  if ( !m_thisSessionCb)
    return;

  if (ep == NULL)
    return;

  wb_object parent = o.parent();
  if ( parent)
    ep->OldParent = parent.oid();

  wb_object before = o.before();
  if ( before)
    ep->OldLsibling = before.oid();

  wb_object after = o.after();
  if ( after)
    ep->OldRsibling = after.oid();
}
예제 #17
0
void wb_srep::eventNewFamily( ldh_sEvent *ep, wb_object o)
{

  if ( !m_thisSessionCb)
    return;

  if ( !ep)
    return;

  wb_object parent = o.parent();
  if ( parent)
    ep->NewParent = parent.oid();

  wb_object before = o.before();
  if ( before)
    ep->NewLsibling = before.oid();

  wb_object after = o.after();
  if ( after)
    ep->NewRsibling = after.oid();
  
}
예제 #18
0
pwr_tStatus wb_volume::triggAnteUnadopt(wb_object& father, wb_object& o)
{
  pwr_tStatus sts;
  char *methodName;
  wb_tMethod method;
  
  if (!father)
    return LDH__SUCCESS;

  wb_cdrep *cdrep = m_vrep->merep()->cdrep(&sts, father.cid());
  if (EVEN(sts)) return sts;

  cdrep->dbCallBack(&sts, ldh_eDbCallBack_AnteUnadopt, &methodName, 0);
  delete cdrep;
  if (EVEN(sts)) return LDH__SUCCESS;

  m_vrep->erep()->method(&sts, methodName, &method);
  if (EVEN(sts)) return LDH__SUCCESS;

  sts = ((wb_tMethodAnteUnadopt) (method))((ldh_tSesContext)this, father.oid(), o.oid(),
					    o.cid());
  return sts;
}
예제 #19
0
bool wb_session::renameObject(wb_object o, wb_name name)
{
  m_sts = LDH__SUCCESS;

  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  bool ok = m_vrep->renameObject(&m_sts, (wb_orep*)o, name);
  if (!ok)
    return ok;

  triggPostRename(o);

  m_srep->update();
  ldh_sEvent* ep = m_srep->eventStart(o.oid(), ldh_eEvent_ObjectRenamed);
  m_srep->eventSend(ep);
  return ok;
}
예제 #20
0
//
// printObject
//
void wb_print_wbl::printObject(wb_volume& v, wb_object& o, bool recursive)
{
  wb_object to = o;
  wb_object templ;
  cdh_uObjid	uid;
  unsigned int idx;
  wb_cdef cdef = v.cdef(o);
  if ( !cdef) {
    m_os << "! %WBDUMP-E-Error Failed to get object class" << endl;
    m_errCnt++;
    // return;
    cdef = v.cdef( pwr_eClass_ClassLost);
  }
  const char* cname = cdef.name();
  char *block;
  int size;

  if ( o.docBlock( &block, &size) && strcmp( block, "") != 0) {
    indent(0) << "!/**" << endl;
    indent(0) << "! ";
    for ( char *s = block; *s; s++) {
      if ( *s == '\n') {
	m_os << *s;
	indent(0) << "! ";
	continue;
      }
      m_os << *s;
    }
    m_os << endl;
    indent(0) << "!*/" << endl;
  }

  indent(1) << "Object " << o.name() << " " << cname;

  if (m_idxFlag) {
    switch (cdef.cid()) {
    case pwr_eClass_ClassDef:
      uid.pwr = o.oid();
      idx = uid.c.cix;
      break;
    case pwr_eClass_TypeDef:
      uid.pwr = o.oid();
      idx = uid.t.tix;
      break;
    case pwr_eClass_ObjBodyDef:
      uid.pwr = o.oid();
      idx = uid.c.bix;
      break;
    case pwr_eClass_Param:
    case pwr_eClass_Input:
    case pwr_eClass_Output:
    case pwr_eClass_Intern:
    case pwr_eClass_Buffer:
    case pwr_eClass_ObjXRef:
      uid.pwr = o.oid();
      idx = uid.c.aix;
      break;
    default:
      idx = (unsigned long) o.oix();
    }
    m_os << " " << idx;
  }
  if ( m_timeFlag) {
    // Get oh time
    char timestr[40];
    pwr_tTime ohtime = o.ohTime();
    time_AtoAscii( &ohtime, time_eFormat_DateAndTime, timestr, sizeof(timestr));

    m_os << " " << timestr;
  }
  m_os << endl;

  wb_object co = v.object(cdh_ClassIdToObjid(cdef.cid()));
  wb_name t("Template");
  
  templ = co.child(t);
  if (!templ) {
    m_errCnt++;
    m_os << "Template not found for class " << cdef.name() << endl;
    return;
  }

  if ( v.cid() == pwr_eClass_ClassVolume &&
       strcmp( o.name(), "Template") == 0)
    m_isTemplateObject = true;
  else
    m_isTemplateObject = false;
  
 
  printBody(v, o, templ, cdef, pwr_eBix_rt);
  printBody(v, o, templ, cdef, pwr_eBix_dev);

  if (recursive) {
    if ( !(m_noFoCodeFlag && isFoCodeObject( v, o))) {
      for (to = o.first(); to; to = to.after())
	printObject(v, to);
    }
  }    

  indent(-1) << "EndObject" << endl;
}
예제 #21
0
//
// printBody
//
void wb_print_wbl::printBody(wb_volume& v, 
                             wb_object& o, 
                             wb_object& templ,
                             wb_cdef& cdef,
                             pwr_eBix bix)
{
  wb_adef adef;
  wb_attribute attr;
  wb_attribute tattr;
  const char* bname;
  char timestr[40] = " ";
  int force = 0;
    
  wb_bdef bdef = cdef.bdef(bix);
    

  if (!bdef)
    return;

  bname = bdef.name();

  wb_bdef tbdef = templ.bdef(bix);
  if (!tbdef) {
    m_errCnt++;
    m_os << "Couldn't find template body def for object " << o.name() << endl;
    return;
  }
    
  if ( m_timeFlag) {
    // Get body time
    pwr_tTime btime;
    switch ( bix) {
    case pwr_eBix_rt:
      btime = o.rbTime();

      // Bugcheck in 4.2 btime can be corrupt
      if ( btime.tv_nsec < 0 || btime.tv_nsec >= 1000000000)
	break;

      strcpy( timestr, " ");
      time_AtoAscii( &btime, time_eFormat_DateAndTime, &timestr[1], sizeof(timestr)-1);
      break;
    case pwr_eBix_dev:
      btime = o.dbTime();
      strcpy( timestr, " ");
      time_AtoAscii( &btime, time_eFormat_DateAndTime, &timestr[1], sizeof(timestr)-1);
      break;
    default: ;
    }
  }

  indent(1) << "Body " << bdef.name() << timestr << endl;
  for (adef = bdef.adef(); adef; adef = adef.next()) {
    if ( cdef.cid() == pwr_eClass_Param && strcmp( adef.name(), "Size") == 0) {
      // Print Size for Pointers that is not private
      wb_attribute flags_attr = o.attribute(bname, "Flags");
      pwr_tMask *flagsp = (pwr_tMask *)flags_attr.value();
      if (*flagsp & PWR_MASK_POINTER && !(*flagsp & PWR_MASK_PRIVATE))
	force = 1;
    }

    attr = o.attribute(bname, adef.name());
    tattr = templ.attribute(bname, adef.name());
    //    if (tattr == attr)
    //  continue;
    printAttribute(v, attr, tattr, adef, force);
  }

  indent(-1) << "EndBody" << endl;
    
  return;
}
예제 #22
0
wb_destination::wb_destination(wb_object &o, ldh_eDest code) :
  m_oid(o.oid()), m_code(code)
{    
}
예제 #23
0
wb_object wb_session::copyObject(wb_object o, wb_destination d, wb_name name)
{
  wb_orep* orep = 0;

  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  validateDestination(d, o.cid());
  if (evenSts())
    throw wb_error(sts());

  wb_object parent;
  switch (d.code()) {
  case ldh_eDest_IntoFirst:
  case ldh_eDest_IntoLast:
    parent = object(d.oid());
    break;
  case ldh_eDest_After:
  case ldh_eDest_Before:
    parent = object(d.oid()).parent();
    break;
  default:
    throw wb_error(LDH__NODEST);
  }

  m_sts = triggAnteCreate(parent, o.cid());
  if (evenSts())
    throw wb_error(sts());
  m_sts = triggAnteAdopt(parent, o.cid());
  if (evenSts())
    throw wb_error(sts());

  if (m_vrep->vid() == o.vid()) {
    orep = m_vrep->copyObject(&m_sts, (wb_orep*)o, d, name);
    if (evenSts())
      throw wb_error(sts());

    orep->ref();
  } else {
    wb_cdef c = cdef(o.cid());

    orep = m_vrep->createObject(&m_sts, c, d, name);
    orep->ref();
    wb_attribute rba(o.sts(), (wb_orep*)o, "RtBody");
    if (rba) {
      void* p = rba.value();
      wb_attribute rban(m_sts, orep, "RtBody");
      writeAttribute(rban, p);
    }
    wb_attribute dba(o.sts(), (wb_orep*)o, "DevBody");
    if (dba) {
      void* p = dba.value();
      wb_attribute dban(m_sts, orep, "DevBody");
      writeAttribute(dban, p);
    }
    wb_attribute sba(o.sts(), (wb_orep*)o, "SysBody");
    if (sba) {
      void* p = sba.value();
      wb_attribute sban(m_sts, orep, "SysBody");
      writeAttribute(sban, p);
    }
  }
  m_srep->update();

  wb_object onew = wb_object(m_sts, orep);
  orep->unref();
  ldh_sEvent* ep = m_srep->eventStart(onew.oid(), ldh_eEvent_ObjectCreated);
  m_srep->eventNewFamily(ep, onew);
  triggPostCreate(onew);
  triggPostAdopt(parent, onew);
  m_srep->eventSend(ep);

  return onew;
}
예제 #24
0
wb_object::wb_object(const wb_object& x) : wb_status(x.sts()), m_orep(x.m_orep)
{
  if (m_orep)
    m_orep->ref();
}