예제 #1
0
static int IsOkMoveObject (
  ldh_sMenuCall *ip,
  pwr_sMenuButton *mbp
) {
  pwr_tStatus	    sts	    = LDH__SUCCESS;
  pwr_tStatus	    retsts  = LDH__SUCCESS;
  ldh_eDest	    Dest;
  int		    i;
  
  if (mbp->MethodArguments[0][0] != '\0') {
    if (strcmp(mbp->MethodArguments[0], "Before") == 0)
      Dest = ldh_eDest_Before;
    else if (strcmp(mbp->MethodArguments[0], "After") == 0)
      Dest = ldh_eDest_After;
    else if (strcmp(mbp->MethodArguments[0], "First") == 0)
      Dest = ldh_eDest_IntoFirst;
    else if (strcmp(mbp->MethodArguments[0], "Last") == 0)
      Dest = ldh_eDest_IntoLast;
    else
      Dest = ldh_eDest__;
  }

  for (i = 0;; i++) {
    if (cdh_ObjidIsNull(ip->Selected[i].Objid))
      break;
    sts = ldh_IsOkMoveObject(ip->PointedSession, ip->Selected[i].Objid,
      ip->Pointed.Objid, Dest); 
    if (EVEN(sts))
      retsts = sts;
  }

  return ODD(retsts);
}
예제 #2
0
pwr_tStatus EvEve::set_view(pwr_tOid view)
{
  pwr_tStatus sts;

  sts = ala->set_view( view);
  if ( ODD(sts)) {
    pwr_tString80 name;

    if ( cdh_ObjidIsNull( view)) {
      strcpy( name, "Event List");
    }
    else {
      pwr_tAttrRef name_ar, ar;

      ar = cdh_ObjidToAref( view);
      sts = gdh_ArefANameToAref( &ar, "Name", &name_ar);
      if (EVEN(sts)) return sts;

      sts = gdh_GetObjectInfoAttrref( &name_ar, name, sizeof(name));
      if (EVEN(sts)) return sts;
    }
    set_title_ala( name);
  }
  return sts;
}
예제 #3
0
static void
printname(pwr_tOid poid, pwr_tObjName name, pwr_tOid oid)
{
  pwr_tStatus sts;
  sOentry     *oep;
  count_name++;
    
  if (cdh_ObjidIsNull(poid) || poid.oix == 0) {
    printf("N [%10.10d.%10.10d] %d:%s\n", oid.vid, oid.oix, strlen(name), name);
  }
  
  oep = (sOentry *)tree_Find(&sts, oid_th, &oid);
  if (EVEN(sts)) {
    printf("Name: object not found %d.%d, %s\n", oid.vid, oid.oix, name);
  } else {
    oep->flags.b.inName = 1;
    if (strcmp(name, oep->o.normname) != 0) {
      printf("name: \"%s\" [%d] not same as: \"%s\"\n", oep->o.name, oep->o.oid.oix, name);
    }
#if 0
    if (memcmp(name, oep->o.normname, sizeof(name)) != 0) {
      printf("name memcmp: \"%s\" [%d] not same as: \"%s\"\n", oep->o.name, oep->o.oid.oix, name);
    }
#endif
    if (cdh_ObjidIsNotEqual(poid, oep->o.poid)) {
      printf("name: \"%s\" [%d] poid: [%d] is not same as: [%d]n", oep->o.name, oep->o.oid.oix, oep->o.poid.oix, poid.oix);
    }    
  }
}
예제 #4
0
static int IsOkCopyObjectTree (
  ldh_sMenuCall *ip,
  pwr_sMenuButton *mbp
) {
  pwr_tStatus	    sts	    = LDH__SUCCESS;
  pwr_tStatus	    retsts  = LDH__SUCCESS;
  ldh_eDest	    Dest;
  int		    i;
  pwr_tBoolean	    Self    = 0;
  pwr_tObjid	    DestObject;
  
  if (mbp->MethodArguments[0][0] != '\0') {
    if (strcmp(mbp->MethodArguments[0], "Before") == 0)
      Dest = ldh_eDest_Before;
    else if (strcmp(mbp->MethodArguments[0], "After") == 0)
      Dest = ldh_eDest_After;
    else if (strcmp(mbp->MethodArguments[0], "First") == 0)
      Dest = ldh_eDest_IntoFirst;
    else if (strcmp(mbp->MethodArguments[0], "Last") == 0)
      Dest = ldh_eDest_IntoLast;
    else
      Dest = ldh_eDest__;
  }

  for (i = 0; i < (int)ip->SelectCount; i++) {
    if (cdh_ObjidIsEqual(ip->Selected[i].Objid, ip->Pointed.Objid))
      Self = 1;
    if (cdh_ObjidIsNull(ip->Selected[i].Objid))
      break;
  }

  if (!Self)
    DestObject = ip->Pointed.Objid;

  for (i = 0; i < (int)ip->SelectCount; i++) {
    if (cdh_ObjidIsNull(ip->Selected[i].Objid))
      break;
    if (Self)
      DestObject = ip->Selected[i].Objid;
    sts = ldh_IsOkCopyObject(ip->PointedSession, ip->Selected[i].Objid,
      DestObject, Dest); 
    if (EVEN(sts))
      retsts = sts;
  }

  return ODD(retsts);
}
예제 #5
0
void EvEve::init()
{
  if ( !list_copied && ala->browbase && copy_list_cb) {
    list_copied = 1;
    (copy_list_cb)( parent_ctx, ala);
    if ( !cdh_ObjidIsNull(view))
      set_view( view);
  }
}
예제 #6
0
void EvEve::eve_init_cb( void *ctx)
{
  EvEve *ev = (EvEve *)ctx;

  if ( !ev->list_copied && ev->copy_list_cb) {
    ev->list_copied = 1;
    (ev->copy_list_cb)( ev->parent_ctx, ev->ala);
    if ( !cdh_ObjidIsNull(ev->view))
      ev->set_view( ev->view);
  }
}
예제 #7
0
int XNav::check_object_methodfilter( pwr_sAttrRef attrref, 
				     xmenu_eItemType item_type, 
				     xmenu_mUtility caller, 
				     unsigned int priv, char *method_name)
{
  pwr_tStatus 	sts;
  int 		i;
  int		sel_cnt;
  int		idx;

  if (mcp == NULL)
    mcp = (xmenu_sMenuCall *)calloc(1, sizeof(xmenu_sMenuCall));

  mcp->ItemList = xmenu_lMenuItem;
  mcp->EditorContext = (void *)this;
  mcp->PointedSet = xmenu_eMenuSet_Object;

  mcp->Pointed = attrref;
  mcp->Caller = caller;
  mcp->ItemType = item_type;
  mcp->Priv = priv;
  mcp->SelectedSet = xmenu_eMenuSet_None;
  mcp->SelectedSet = xmenu_eMenuSet_Object;

  sel_cnt = 1;
  if ( mcp->Selected)
    free( mcp->Selected);
  mcp->Selected = (pwr_sAttrRef *) calloc( sel_cnt + 1, sizeof (pwr_sAttrRef));
  mcp->Selected[0] = attrref;
  mcp->Selected[sel_cnt].Objid = pwr_cNObjid;
  mcp->SelectCount = sel_cnt;

  sts = GetMenu( mcp);  
  if (EVEN(sts) || mcp->ItemList[0].Level == 0) {
    return 0;
  }

  // Find index of method
  idx = -1;
  for ( i = 0; i <= (int) mcp->ItemCount; i++) {
    if ( cdh_ObjidIsNull( mcp->ItemList[i].CurrentObject.Objid) &&
	 mcp->ItemList[i].Flags.f.Sensitive &&
	 cdh_NoCaseStrcmp( mcp->ItemList[i].Name, method_name) == 0) {
      idx = i;
      break;
    }
  }
  if ( idx == -1)
    return 0;

  mcp->ChosenItem = idx;
  sts = CheckMenuMethodFilter( mcp, mcp->ChosenItem);
  return sts;
}
예제 #8
0
pwr_tStatus wsx_CheckAttrRef( ldh_tSesContext	sesctx,
			      pwr_tAttrRef	aref,
			      const pwr_tObjName attribute,
			      pwr_tCid		*cid_vect,
			      int		null_is_ok,
			      int		*errorcount,
			      int		*warningcount)
{
  pwr_tAttrRef value;
  wb_session *sp = (wb_session *)sesctx;

  wb_attribute a = sp->attribute( &aref);
  if ( !a) return a.sts();

  wb_attribute a_attr( a, 0, attribute);
  if ( !a_attr) return a_attr.sts();
    
  a_attr.value( &value);
  if ( !a_attr) return a_attr.sts();

  if ( !null_is_ok && cdh_ObjidIsNull( value.Objid)) {
    char msg[80];
    sprintf ( msg, "Attribute reference is null in \"%s\"", attribute);
    wsx_error_msg_str( sesctx, msg, aref, 'E', errorcount, warningcount);
  }
  if ( cdh_ObjidIsNotNull( value.Objid)) {
    wb_attribute a_value = sp->attribute( &value);
    if ( !a_value) {
      char msg[80];
      sprintf ( msg, "Undefined attribute reference in \"%s\"", attribute);
      wsx_error_msg_str( sesctx, msg, aref, 'E', errorcount, warningcount);
    }
    else if ( cid_vect) {
      // Check attribute reference class
      bool found = false;
      for ( int i = 0; cid_vect[i]; i++) {
	if ( cid_vect[i] == a_value.tid()) {
	  found = true;
	  break;
	}
      }
      if ( !found) {
	char msg[80];
	sprintf ( msg, "Invalid class of attribute reference in \"%s\"", attribute);
	wsx_error_msg_str( sesctx, msg, aref, 'E', errorcount, warningcount);
      }
    }
  }
  return WSX__SUCCESS;
}
예제 #9
0
static void DeleteObjectsYesCb (
  void *Ctx,				
  void *CallbackData
) {
  ldh_sMenuCall	  *mc	  = (ldh_sMenuCall *)CallbackData;
  int		  i;

  for (i = 0; mc->SelectCount; i++) {	/* count number of selected objects */
    if (cdh_ObjidIsNull(mc->Selected[i].Objid))
      break;
    ldh_DeleteObjectTree(mc->PointedSession, mc->Selected[i].Objid, 0);
  }
  free((char *) mc->Selected);
  free((char *) mc);
}
예제 #10
0
static pwr_tStatus MoveObject (
  ldh_sMenuCall *ip
) {
  pwr_tStatus	    retsts  = LDH__SUCCESS;
  pwr_tStatus	    sts	    = LDH__SUCCESS;
  pwr_sMenuButton   mb;
  int		    i;
  int		    j;
  ldh_eDest	    Dest;
  
  sts = ldh_ReadObjectBody(ip->PointedSession, ip->ItemList[ip->ChosenItem].MenuObject,
    "SysBody", &mb, sizeof(pwr_sMenuButton));

  if (mb.MethodArguments[0][0] != '\0') {
    if (strcmp(mb.MethodArguments[0], "Before") == 0)
      Dest = ldh_eDest_Before;
    else if (strcmp(mb.MethodArguments[0], "After") == 0)
      Dest = ldh_eDest_After;
    else if (strcmp(mb.MethodArguments[0], "First") == 0)
      Dest = ldh_eDest_IntoFirst;
    else if (strcmp(mb.MethodArguments[0], "Last") == 0)
      Dest = ldh_eDest_IntoLast;
    else
      Dest = ldh_eDest__;
  }

  for (i = 0;; i++) {	/* count number of selected objects */
    if (cdh_ObjidIsNull(ip->Selected[i].Objid))
      break;
  }

  if (Dest == ldh_eDest_After || Dest == ldh_eDest_IntoFirst) {
    for (j = i - 1; j >= 0; j--) {
      sts = ldh_MoveObject(ip->PointedSession, ip->Selected[j].Objid,
	ip->Pointed.Objid, Dest); 
      if (EVEN(sts)) retsts = sts;
    }
  } else {
    for (j = 0; j < i; j++) {
      sts = ldh_MoveObject(ip->PointedSession, ip->Selected[j].Objid,
	ip->Pointed.Objid, Dest); 
      if (EVEN(sts)) retsts = sts;
    }
  }
  return retsts;
}
예제 #11
0
static pwr_tStatus AnteCreate (
    ldh_tSesContext   Session,
    pwr_tObjid	    Father,
    pwr_tClassId	    Class
) {
    pwr_tCid cid;
    pwr_tStatus sts;

    if ( cdh_ObjidIsNull( Father))
        return PWRS__POSOBJBODYDEF;

    // Check that the father is of class ClassDef
    sts = ldh_GetObjectClass( Session, Father, &cid);
    if ( EVEN(sts) || cid != pwr_eClass_ClassDef)
        return PWRS__POSOBJBODYDEF;
    return PWRS__SUCCESS;
}
예제 #12
0
pwr_tStatus wsx_error_msg_str(
    ldh_tSesContext	sesctx,
    const char 		*str,
    pwr_tAttrRef	aref,
    int			severity,
    int			*errorcount,
    int			*warningcount
)
{
  int		status, size;
  pwr_tAName	name;
  char		*namep;
  FILE 		*logfile;
  char 		msg[200];

  logfile = NULL;

  snprintf( msg, sizeof(msg), "%%WSX-%c-MSG, %s", severity, str);
  if (logfile != NULL)
    fprintf(logfile, "%s\n", msg);
  else
    printf("%s\n", msg);
  
  
  if ( cdh_ObjidIsNull( aref.Objid))
    MsgWindow::message( severity, msg, "", 0);
  else {
    /* Get the full hierarchy name for the node */
    status = ldh_AttrRefToName( sesctx, &aref,
				cdh_mNName, &namep, &size);
    if( EVEN(status)) return status;
    
    strncpy( name, namep, sizeof(name));
    if (logfile != NULL)
      fprintf(logfile, "        in object  %s\n", name);
    else
      printf("        in object  %s\n", name);
    MsgWindow::message( severity, msg, "   in object", name, aref.Objid);
  }
  if ( severity == 'E' || severity == 'F')
    (*errorcount)++;
  else if ( severity == 'W')
    (*warningcount)++;

  return WSX__SUCCESS;
}
예제 #13
0
pwr_tStatus wsx_error_msg( 
    ldh_tSesContext	sesctx,
    pwr_tStatus 	sts,
    pwr_tAttrRef	aref,
    int			*errorcount,
    int			*warningcount
)
{
  static char 	msg[256];
  int		status, size;
  pwr_tAName	name;
  char		*namep;
  FILE 		*logfile;
  
  logfile = NULL;
  
  if (EVEN(sts)) {
    
    msg_GetMsg( sts, msg, sizeof(msg));
    
    if (logfile != NULL)
      fprintf(logfile, "%s\n", msg);
    else
      printf("%s\n", msg);
    if ( cdh_ObjidIsNull( aref.Objid))
      MsgWindow::message( co_error(sts), 0, 0);
    else {
      /* Get the full hierarchy name for the node */
      status = ldh_AttrRefToName( sesctx, &aref,
				  cdh_mNName, &namep, &size);
      if( EVEN(status)) return status;
      
      strncpy( name, namep, sizeof(name));
      if (logfile != NULL)
	fprintf(logfile, "        in object  %s\n", name);
      else
	printf("        in object  %s\n", name);
      MsgWindow::message( co_error(sts), "   in object", name, aref.Objid);
    }
    if ( (sts & 2) && !(sts & 1))
      (*errorcount)++;
    else if ( !(sts & 2) && !(sts & 1))
      (*warningcount)++;
  }
  return WSX__SUCCESS;
}
예제 #14
0
void
cvolcm_DeleteObject (
  qcom_sGet		*get
)
{
  pwr_tStatus		sts;
  gdb_sObject		*op;
  gdb_sObject		*pop;
  gdb_sObject		*sop;
  pwr_tObjid		soid;
  gdb_sVolume		*vp;
  net_sDeleteObject	*dop = (net_sDeleteObject *) get->data;

  gdb_AssumeUnlocked;

  gdb_ScopeLock {
    pop = hash_Search(&sts, gdbroot->oid_ht, &dop->par.oid);
    op = hash_Search(&sts, gdbroot->oid_ht, &dop->notify.oid);
    if (op != NULL) {
      pwr_Assert(cdh_ObjidIsEqual(op->g.f.poid, dop->par.oid)); 
      vp = pool_Address(NULL, gdbroot->pool, op->l.vr);
      cvol_FreeObject(&sts, vp, op, vol_mLink_cacheDelete);
    }

    if (pop == NULL) break;

    pop->g.soid = dop->par.soid;
    if (cdh_ObjidIsNull(pop->g.soid)) {
      pop->g.flags.b.isParent = 0;
    }

    soid = dop->par.oid;
    soid.oix = dop->sib.blink;
    sop = hash_Search(&sts, gdbroot->oid_ht, &soid);
    if (sop != NULL)
      sop->g.sib.flink = dop->sib.newflink;

    soid.oix = dop->sib.flink;
    sop = hash_Search(&sts, gdbroot->oid_ht, &soid);
    if (sop != NULL)
      sop->g.sib.blink = dop->sib.newblink;
  } gdb_ScopeUnlock;
}
예제 #15
0
static pwr_tStatus SyntaxCheck( ldh_tSesContext Session,
                                pwr_tAttrRef Object,
                                int *ErrorCount,
                                int *WarningCount)
{
    wb_session *sp = (wb_session *)Session;
    pwr_tOid mount_oid;

    // Check Object attribute
    wb_attribute a = sp->attribute( Object.Objid, "SysBody", "Object");
    if (!a) return a.sts();

    a.value( &mount_oid);
    if ( !a) return a.sts();

    if ( cdh_ObjidIsNull( mount_oid)) {
        wsx_error_msg_str( Session, "Mounted object is missing", Object, 'E', ErrorCount, WarningCount);
    }
    return PWRS__SUCCESS;
}
예제 #16
0
파일: rt_gdb.c 프로젝트: hfuhuang/proview
gdb_sMountServer *
gdb_AddMountServer (
  pwr_tStatus		*sts,
  pwr_tObjid		soid,
  pwr_tBitMask		flags
)
{
  gdb_sMountServer	*msp;

  gdb_AssumeLocked;

  // pwr_Assert(cdh_ObjidIsNotNull(soid));
  if (cdh_ObjidIsNull(soid)) return NULL;

  msp = hash_Search(sts, gdbroot->ms_ht, &soid);
  if (msp != NULL) {
    if (flags & gdb_mAdd_failIfAdded)
      pwr_Return(NULL, sts, GDB__DUPLADD);
    else
      pwr_Return(msp, sts, GDB__ALRADD);
  }

  msp = pool_Alloc(sts, gdbroot->pool, sizeof(*msp));
  if (msp == NULL) return NULL;

  msp->oid = soid;

  pool_Qinit(NULL, gdbroot->pool, &msp->ms_htl);
  pool_Qinit(NULL, gdbroot->pool, &msp->ms_ll);
  pool_Qinit(NULL, gdbroot->pool, &msp->nodms_ll);
  pool_Qinit(NULL, gdbroot->pool, &msp->volms_ll);
  pool_Qinit(NULL, gdbroot->pool, &msp->cli_lh);

  msp = hash_Insert(sts, gdbroot->ms_ht, msp);
  if (msp == NULL) errh_Bugcheck(GDH__WEIRD, "adding new mount server");

  pool_QinsertPred(NULL, gdbroot->pool, &msp->ms_ll, &gdbroot->db->ms_lh);

  return msp;
}
예제 #17
0
void EvEve::view_shift() 
{
  pwr_sClass_OpPlace *opp;
  pwr_tStatus sts;

  sts = gdh_ObjidToPointer( user, (pwr_tAddress *) &opp);
  if ( EVEN(sts)) return;

  if ( cdh_ObjidIsNull(ala->current_view)) {
    set_view( opp->AlarmViews[0]);
  }
  else {
    for ( unsigned int i = 0; i < sizeof(opp->AlarmViews)/sizeof(opp->AlarmViews[0]); i++) {
      if ( cdh_ObjidIsEqual( ala->current_view, opp->AlarmViews[i])) {
	if ( i == sizeof(opp->AlarmViews)/sizeof(opp->AlarmViews[0]) - 1)
	  set_view( pwr_cNObjid);
	else
	  set_view( opp->AlarmViews[i+1]);
	break;
      }	   
    }
  }
}
예제 #18
0
static pwr_tStatus CopyObjectTree (
  ldh_sMenuCall	    *ip
) {
  pwr_tStatus	    sts	  = LDH__SUCCESS;
  pwr_sMenuButton   mb;
  ldh_eDest	    Dest;
  pwr_tBoolean	    Self  = 0;
  int		    i;
  
  sts = ldh_ReadObjectBody(ip->PointedSession, ip->ItemList[ip->ChosenItem].MenuObject,
    "SysBody", &mb, sizeof(pwr_sMenuButton));

  if (mb.MethodArguments[0][0] != '\0') {
    if (strcmp(mb.MethodArguments[0], "Before") == 0)
      Dest = ldh_eDest_Before;
    else if (strcmp(mb.MethodArguments[0], "After") == 0)
      Dest = ldh_eDest_After;
    else if (strcmp(mb.MethodArguments[0], "First") == 0)
      Dest = ldh_eDest_IntoFirst;
    else if (strcmp(mb.MethodArguments[0], "Last") == 0)
      Dest = ldh_eDest_IntoLast;
    else
      Dest = ldh_eDest__;
  }

  for (i = 0; i < (int)ip->SelectCount; i++) {
    if (cdh_ObjidIsEqual(ip->Selected[i].Objid, ip->Pointed.Objid))
      Self = 1;
    if (cdh_ObjidIsNull(ip->Selected[i].Objid))
      break;
  }

  sts = ldh_CopyObjectTrees(ip->PointedSession, ip->Selected,
			    ip->Pointed.Objid, Dest, Self, 0, 0, 0); 
  return sts;
}
예제 #19
0
EvAlaGtk::EvAlaGtk( void *ev_parent_ctx,
		    GtkWidget	*ev_parent_wid,
		    char *ala_name,
		    pwr_tObjid ev_user,
		    int ev_eventname_seg,
		    int ev_width,
		    int ev_height,
		    int ev_x,
		    int ev_y,
		    pwr_tObjid ev_view,
		    unsigned int ev_options,
		    void *widget,
		    pwr_tStatus *status) :
  EvAla( ev_parent_ctx, ala_name, ev_user, ev_eventname_seg, 
	 ev_width, ev_height, ev_x, ev_y, ev_view, ev_options, status),
  parent_wid(ev_parent_wid), toplevel(0)
{
  pwr_tStatus sts;
  pwr_sClass_OpPlace *opp;
  pwr_tFileName fname;
  int ala_width = 700;
  int ala_height = 300;

  *status = 1;

  if ( ev_width != 0 && ev_height != 0) {
    ala_width = ev_width;
    ala_height = ev_height;
  }

  // Check user object
  if ( cdh_ObjidIsNull( user)) {
    *status = XNAV__NOUSER;
    return;
  }

  sts = gdh_ObjidToPointer( user, (pwr_tAddress *) &opp);
  if ( EVEN(sts)) {
    *status = XNAV__NOUSER;
    return;
  }
  ala_size = opp->MaxNoOfAlarms;
  // create_aliaslist( opp);

  // Ala Window

  if ( !(options & ev_mAlaOptions_Embedded)) {
    toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
						 "default-height", ala_height,
						 "default-width", ala_width,
						 "title", CoWowGtk::translate_utf8(ala_name),
						 NULL);
    parent_wid_ala = toplevel;
    g_signal_connect( parent_wid_ala, "delete_event", G_CALLBACK(ala_delete_event), this);
    g_signal_connect( parent_wid_ala, "destroy", G_CALLBACK(ala_destroy_event), this);
    g_signal_connect( parent_wid_ala, "focus-in-event", G_CALLBACK(ala_action_inputfocus), this);

    CoWowGtk::SetWindowIcon( parent_wid_ala);
  }
  else
    parent_wid_ala = (GtkWidget *)widget;

  ala_vbox = gtk_vbox_new( FALSE, 0);

  // Menu
  // Accelerators
  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(parent_wid_ala), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget *file_print = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Print"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_print), 
				 gtk_image_new_from_stock( "gtk-print", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_print, "activate", G_CALLBACK(ala_activate_print), this);

  GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close), 
				 gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_close, "activate", G_CALLBACK(ala_activate_exit), this);
  gtk_widget_add_accelerator( file_close, "activate", accel_g,
			      'w', GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_File"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Functions entry
  GtkWidget *functions_ack_last = gtk_menu_item_new_with_mnemonic( 
								  CoWowGtk::translate_utf8("_Acknowledge"));
  g_signal_connect( functions_ack_last, "activate", 
		    G_CALLBACK(ala_activate_ack_last), this);
  gtk_widget_add_accelerator( functions_ack_last, "activate", accel_g,
			      'k', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_ack_all = gtk_menu_item_new_with_mnemonic( 
								 CoWowGtk::translate_utf8("A_cknowledge All"));
  g_signal_connect( functions_ack_all, "activate", 
		    G_CALLBACK(ala_activate_ack_all), this);

  GtkWidget *functions_open_plc = gtk_menu_item_new_with_mnemonic( 
								  CoWowGtk::translate_utf8("Open _Program"));
  g_signal_connect( functions_open_plc, "activate", 
		    G_CALLBACK(ala_activate_open_plc), this);
  gtk_widget_add_accelerator( functions_open_plc, "activate", accel_g,
			      'l', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_display_object = gtk_menu_item_new_with_mnemonic( 
									CoWowGtk::translate_utf8("_Display object in Navigator"));
  g_signal_connect( functions_display_object, "activate", 
		    G_CALLBACK(ala_activate_display_in_xnav), this);
  gtk_widget_add_accelerator( functions_display_object, "activate", accel_g,
			      'd', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkMenu *func_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_ack_last);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_ack_all);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_plc);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_display_object);

  GtkWidget *functions = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Functions"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));

  // View entry
  GtkWidget *view_shift_view = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("S_hift View"));
  g_signal_connect( view_shift_view, "activate", 
		    G_CALLBACK(ala_activate_shift_view), this);
  gtk_widget_add_accelerator( view_shift_view, "activate", accel_g,
			      'n', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_in = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _In"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_in), 
				 gtk_image_new_from_stock( "gtk-zoom-in", GTK_ICON_SIZE_MENU));
  g_signal_connect( view_zoom_in, "activate", 
		    G_CALLBACK(ala_activate_zoom_in), this);
  gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
			      'i', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_out = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Out"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_out), 
				 gtk_image_new_from_stock( "gtk-zoom-out", GTK_ICON_SIZE_MENU));
  g_signal_connect( view_zoom_out, "activate", 
		    G_CALLBACK(ala_activate_zoom_out), this);
  gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
			      'o', GdkModifierType(GDK_CONTROL_MASK),
			      GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_reset = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Reset"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_reset), 
				 gtk_image_new_from_stock( "gtk-zoom-100", GTK_ICON_SIZE_MENU));
  g_signal_connect( view_zoom_reset, "activate", 
		    G_CALLBACK(ala_activate_zoom_reset), this);
  gtk_widget_add_accelerator( view_zoom_reset, "activate", accel_g,
			      'b', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *view_disp_hundredth = gtk_check_menu_item_new_with_mnemonic( 
									 CoWowGtk::translate_utf8("_Display hundredth"));
  g_signal_connect( view_disp_hundredth, "activate", 
		    G_CALLBACK(ala_activate_disp_hundredth), this);

  GtkWidget *view_hide_object = gtk_check_menu_item_new_with_mnemonic( 
								      CoWowGtk::translate_utf8("_Hide Event Name"));
  g_signal_connect( view_hide_object, "activate", 
		    G_CALLBACK(ala_activate_hide_object), this);

  GtkWidget *view_hide_text = gtk_check_menu_item_new_with_mnemonic( 
								    CoWowGtk::translate_utf8("Hide _Event Text"));
  g_signal_connect( view_hide_text, "activate", 
		    G_CALLBACK(ala_activate_hide_text), this);

  // Submenu Select View
  GtkWidget *view_select_flat = gtk_menu_item_new_with_mnemonic( "_Flat");
  g_signal_connect( view_select_flat, "activate", 
		    G_CALLBACK(ala_activate_select_flat), this);


  GtkWidget *view_select = gtk_menu_item_new_with_mnemonic( "_Select View");
  GtkMenu *view_select_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_select_menu), view_select_flat);

  for ( unsigned int i = 0; i < sizeof(opp->AlarmViews)/sizeof(opp->AlarmViews[0]); i++) {
    pwr_sClass_AlarmView *viewp;

    if ( cdh_ObjidIsNull( opp->AlarmViews[i]))
      break;
      
    sts = gdh_ObjidToPointer( opp->AlarmViews[i], (void **)&viewp);
    if ( ODD(sts)) {
      alarm_views[i] = opp->AlarmViews[i];
      GtkWidget *view_select_view = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8(viewp->Name));
      switch ( i) {
      case 0: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view1), this); break;
      case 1: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view2), this); break;
      case 2: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view3), this); break;
      case 3: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view4), this); break;
      case 4: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view5), this); break;
      case 5: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view6), this); break;
      case 6: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view7), this); break;
      case 7: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view8), this); break;
      case 8: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view9), this); break;
      case 9: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view10), this); break;
      case 10: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view11), this); break;
      case 11: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view12), this); break;
      case 12: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view13), this); break;
      case 13: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view14), this); break;
      case 14: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view15), this); break;
      case 15: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view16), this); break;
      case 16: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view17), this); break;
      case 17: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view18), this); break;
      case 18: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view19), this); break;
      case 19: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view20), this); break;
      case 20: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view21), this); break;
      case 21: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view22), this); break;
      case 22: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view23), this); break;
      case 23: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view24), this); break;
      case 24: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view25), this); break;
      }
      gtk_menu_shell_append(GTK_MENU_SHELL(view_select_menu), view_select_view);
    }
  }

    gtk_menu_item_set_submenu(GTK_MENU_ITEM(view_select),
			      GTK_WIDGET(view_select_menu));

    GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_shift_view);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_select);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_disp_hundredth);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_hide_object);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_hide_text);

    GtkWidget *view = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_View"));
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));

    // Help entry
    GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic( 
                              CoWowGtk::translate_utf8("_Help"));
    gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help), 
				   gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
    g_signal_connect(help_help, "activate", G_CALLBACK(ala_activate_help), this);
    gtk_widget_add_accelerator( help_help, "activate", accel_g,
				'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

    GtkWidget *help_helpevent = gtk_menu_item_new_with_mnemonic( 
                                         CoWowGtk::translate_utf8("Help Selected Event"));
    g_signal_connect( help_helpevent, "activate", 
		      G_CALLBACK(ala_activate_helpevent), this);

    GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
    gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_helpevent);

    GtkWidget *help = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Help"));
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

    // Create ala evlist
    ala = new EvListGtk( this, ala_vbox, ev_eType_AlarmList, ala_size, eventname_seg, 
			 &ala_widget, ala_init_cb);
    ala->start_trace_cb = &ala_start_trace_cb;
    ala->display_in_xnav_cb =&ala_display_in_xnav_cb;
    ala->name_to_alias_cb = &ala_name_to_alias_cb;
    ala->popup_menu_cb = &ala_popup_menu_cb;
    ala->sound_cb = &ala_sound_cb;
    ala->help_event_cb = &help_event_cb;
    ala->selection_changed_cb = &ala_selection_changed_cb;
  
    // Toolbar
    GtkToolbar *tools = (GtkToolbar *) g_object_new(GTK_TYPE_TOOLBAR, NULL);

    GtkWidget *tools_ack = gtk_button_new();
    dcli_translate_filename( fname, "$pwr_exe/xtt_acknowledge.png");
    gtk_container_add( GTK_CONTAINER( tools_ack), gtk_image_new_from_file( fname));
    g_signal_connect(tools_ack, "clicked", G_CALLBACK(ala_activate_ack_last), this);
    g_object_set( tools_ack, "can-focus", FALSE, NULL);
    gtk_toolbar_append_widget( tools, tools_ack, CoWowGtk::translate_utf8("Acknowledge"), "");
    
    GtkWidget *tools_zoom_in = gtk_button_new();
    dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_in.png");
    gtk_container_add( GTK_CONTAINER(tools_zoom_in), 
		       gtk_image_new_from_file( fname));
    g_signal_connect(tools_zoom_in, "clicked", G_CALLBACK(ala_activate_zoom_in), this);
    g_object_set( tools_zoom_in, "can-focus", FALSE, NULL);
    gtk_toolbar_append_widget( tools, tools_zoom_in,CoWowGtk::translate_utf8("Zoom in"), "");

    GtkWidget *tools_zoom_out = gtk_button_new();
    dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_out.png");
    gtk_container_add( GTK_CONTAINER(tools_zoom_out), 
		       gtk_image_new_from_file( fname));
    g_signal_connect(tools_zoom_out, "clicked", G_CALLBACK(ala_activate_zoom_out), this);
    g_object_set( tools_zoom_out, "can-focus", FALSE, NULL);
    gtk_toolbar_append_widget( tools, tools_zoom_out,CoWowGtk::translate_utf8("Zoom out"), "");
    
    GtkWidget *tools_zoom_reset = gtk_button_new();
    dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_reset.png");
    gtk_container_add( GTK_CONTAINER(tools_zoom_reset), 
		       gtk_image_new_from_file( fname));
    g_signal_connect(tools_zoom_reset, "clicked", G_CALLBACK(ala_activate_zoom_reset), this);
    g_object_set( tools_zoom_reset, "can-focus", FALSE, NULL);
    gtk_toolbar_append_widget( tools, tools_zoom_reset,CoWowGtk::translate_utf8("Zoom reset"), "");
    
    ala_methodtoolbar = new XttMethodToolbarGtk(0, 0, ~0, "");
    GtkToolbar *tools_meth = (GtkToolbar *) ((XttMethodToolbarGtk *)ala_methodtoolbar)->build();

    ala_methodtoolbar->m_xnav = (XNav *)((Ev *)parent_ctx)->parent_ctx;
    ala_methodtoolbar->m_parent_ctx = ala;
    ala_methodtoolbar->get_select_cb = ala->get_select;

    ala_sup_methodtoolbar = new XttMethodToolbarGtk(0, 0, mt_mMethod_OpenPlc | mt_mMethod_RtNavigator, 
						    " for supervisory object");
    GtkToolbar *tools_sup = (GtkToolbar *) ((XttMethodToolbarGtk *)ala_sup_methodtoolbar)->build();
    ala_sup_methodtoolbar->m_xnav = (XNav *)((Ev *)parent_ctx)->parent_ctx;
    ala_sup_methodtoolbar->m_parent_ctx = ala;
    ala_sup_methodtoolbar->get_select_cb = ala->get_select_supobject;

    GtkWidget *ala_toolsbox = gtk_hbox_new( FALSE, 0);
    gtk_box_pack_start( GTK_BOX(ala_toolsbox), GTK_WIDGET(tools), FALSE, FALSE, 0);
    gtk_box_pack_start( GTK_BOX(ala_toolsbox), GTK_WIDGET(gtk_separator_tool_item_new()), FALSE, FALSE, 4);
    gtk_box_pack_start( GTK_BOX(ala_toolsbox), GTK_WIDGET(tools_sup), FALSE, FALSE, 0);
    gtk_box_pack_start( GTK_BOX(ala_toolsbox), GTK_WIDGET(gtk_separator_tool_item_new()), FALSE, FALSE, 4);
    gtk_box_pack_start( GTK_BOX(ala_toolsbox), GTK_WIDGET(tools_meth), FALSE, FALSE, 0);

    gtk_box_pack_start( GTK_BOX(ala_vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
    gtk_box_pack_start( GTK_BOX(ala_vbox), GTK_WIDGET(ala_toolsbox), FALSE, FALSE, 0);
    gtk_box_pack_end( GTK_BOX(ala_vbox), GTK_WIDGET(ala_widget), TRUE, TRUE, 0);

    if ( !(options & ev_mAlaOptions_Embedded)) {
      gtk_container_add( GTK_CONTAINER(parent_wid_ala), ala_vbox);
    }
    // gtk_widget_show_all( parent_wid_ala);

    ala_methodtoolbar->set_sensitive();
    ala_sup_methodtoolbar->set_sensitive();
    // }


  if ( !(options & ev_mAlaOptions_Embedded)) {
    gtk_widget_show_all( parent_wid_ala);
    if ( !(x == 0 && y == 0)) {
      // Set position
      gtk_window_move( GTK_WINDOW(parent_wid_ala), x, y);
    }
  }
  else
    gtk_widget_set_size_request( ala_vbox, ala_width, ala_height);

  ala_displayed = 1;


  wow = new CoWowGtk( parent_wid_ala);

  *status = 1;
}
예제 #20
0
파일: rt_ivol.c 프로젝트: Strongc/proview
static gdb_sVolume *
mountVolume (
  pwr_tStatus           *sts,
  gdb_sObject		*op
)
{
  gdb_sVolume		*vp;
  gdb_sMountServer	*msp;
  void			*p;
  pwr_tObjid		soid = pwr_cNObjid;
  gdb_sObject		*vop;
  co_mFormat            fm;
  pwr_tTime		time;
  

  if (op->g.oid.vid != gdbroot->db->vid)
    errh_Bugcheck(GDH__WEIRD, "only root volumes can mount");

  p = pool_Address(sts, gdbroot->rtdb, op->u.n.body);
  if (p == NULL) return NULL;

  switch (op->g.cid) {
  case pwr_eClass_MountObject:
    soid = ((pwr_sMountObject *)p)->Object;
    if ( cdh_ObjidIsNull(soid)) {
      *sts = GDH__NOMOUNTOBJECT;
      return NULL;
    }
    vp = vol_MountVolume(sts, soid.vid);
    break;
  case pwr_eClass_MountVolume:
    soid.vid = ((pwr_sMountVolume *)p)->Volume;
    if ( soid.vid == 0) {
      *sts = GDH__NOMOUNTOBJECT;
      return NULL;
    }
    vp = vol_MountVolume(sts, soid.vid);
    break;
  case pwr_eClass_CreateVolume:
    soid.vid = ((pwr_sCreateVolume *)p)->Volume;
    time_GetTime(&time);
    vp = gdb_LoadVolume(sts, soid.vid, op->g.f.name.orig,
                        pwr_eClass_DynamicVolume, gdbroot->db->nid, 
                        time, gdb_mLoad_build, co_GetOwnFormat(&fm));

    /* Create the volume object.  */

    vop = loadObject(sts, vp, vp->g.name.orig, soid, pwr_eClass_DynamicVolume,
      sizeof(pwr_sDynamicVolume), pwr_cNObjid, net_mGo__, pwr_cNObjid); 
    if (vop == NULL) errh_Bugcheck(*sts, "");
    break;
  }

  if (vp == NULL) return NULL;

  pwr_Assert(cdh_ObjidIsEqual(op->g.soid, soid));

  if (!op->u.n.flags.b.inMountClientList) {
    msp = vol_AddMountClient(sts, op);
    if (msp == NULL) return NULL;
  }

  return vp;
}
예제 #21
0
static pwr_tStatus InitTrendList( trend_tCtx ctx)
{
  pwr_tStatus	    sts;
  pwr_tUInt32	    dummy;
  pwr_tTypeId	    type;
  int		    tix;
  pwr_tAttrRef	    aref;
  pwr_tAttrRef	    oaref;
  pwr_tAName   	    name;
  pwr_tDisableAttr  disabled;

  /* Init DsTrend objects */
  /* Scan through typelist and insert valid objects in list and initiate */
  /* the DsTrend objects. */

  for ( sts = gdh_GetClassListAttrRef(pwr_cClass_DsTrend, &aref); 
	ODD(sts); 
	sts = gdh_GetNextAttrRef( pwr_cClass_DsTrend, &aref, &aref) ) {
    trend_sListEntry    *ep;
    pwr_sClass_DsTrend  *o;

    sts = gdh_AttrrefToName( &aref, name, sizeof(name), cdh_mNName);  
    if (EVEN(sts))
      continue;

    /* Check if parent object is disabled */
    sts = gdh_AttrArefToObjectAref( &aref, &oaref);
    if ( ODD(sts)) {
      sts = gdh_ArefDisabled( &oaref, &disabled);
      if ( ODD(sts) && disabled)
	continue;
    }

    ep = calloc(1, sizeof(*ep));
    if (ep == NULL) {
      errh_CErrLog(DS__ERRALLOC, NULL);
      errh_SetStatus( PWR__SRVTERM);
      exit(DS__ERRALLOC);
    }

    sts = gdh_RefObjectInfo(name, (pwr_tAddress *)&ep->o, 
		      &ep->o_subid, sizeof(*ep->o));
    if (EVEN(sts)) {
      errh_Error("Couldn't get subscription for '%s'\n%m", name, sts);
      free(ep);
      continue;
    }
    o = ep->o;       

   /* Set init values */
    o->BufferStatus[0] = 1;
    o->BufferStatus[1] = 1;
    o->NoOfBuffers = 2;
    o->NoOfBufElement = 239;

    /* Initiate DsTrend object, sampled attribute must be on local node */	  

    sts = gdh_DLRefObjectInfoAttrref((pwr_sAttrRef *)&o->DataName, 
		  (pwr_tAddress *)&o->DataPointer, &o->DataSubId);
    if (EVEN(sts)) {
      if ( sts == GDH__RTDBNULL && IsDisabled( &o->DataName))
	  continue;

      errh_Error("Couldn't get direct link to %s's attribute DataName\n%m", name, sts);
      gdh_UnrefObjectInfo(ep->o_subid);
      free(ep);
      continue;
    }

    sts = gdh_GetAttributeCharAttrref((pwr_sAttrRef *)&o->DataName,
					&type, &dummy, &dummy, &dummy);
    if (EVEN(sts)) {
      errh_Error("Couldn't get datatype for %s's attribute DataName\n%m", name, sts);
      gdh_UnrefObjectInfo(ep->o_subid);
      free(ep);
      continue;
    }
    tix = cdh_TypeIdToIndex(type);

    if (!IsValidType(tix)) {
      errh_Error("No valid datatype for %s's attribute DataName\n%m", name, DS__ERRTYPE);
      gdh_UnrefObjectInfo(ep->o_subid);
      free(ep);
      continue;
    }
      
    o->DataType = tix;
    if ( o->Multiple == 0)
      o->Multiple = 1;
    o->NoOfSample = (o->StorageTime * ctx->scantime) / o->Multiple;

    if(o->NoOfSample > o->NoOfBufElement)
      o->NoOfSample = o->NoOfBufElement;

    o->ScanTime = ctx->scantime;

    ep->next = ctx->o_list;
    ctx->o_list = ep;
  }

  /* Init DsTrendCurve objects */

  /* Scan through typelist and insert valid objects in list and initiate
     the DsTrend objects.  */

  for (sts = gdh_GetClassListAttrRef(pwr_cClass_DsTrendCurve, &aref); 
       ODD(sts); 
       sts = gdh_GetNextAttrRef( pwr_cClass_DsTrendCurve, &aref, &aref) ) {
    trend_sListEntryTC  *ep;
    pwr_sClass_DsTrendCurve  *o;
    int i;
    int found;

    sts = gdh_AttrrefToName( &aref, name, sizeof(name), cdh_mNName);  
    if (EVEN(sts))
      continue;

    /* Check if parent object is disabled */
    sts = gdh_AttrArefToObjectAref( &aref, &oaref);
    if ( ODD(sts)) {
      sts = gdh_ArefDisabled( &oaref, &disabled);
      if ( ODD(sts) && disabled)
	continue;
    }

    ep = calloc(1, sizeof(*ep));
    if (ep == NULL) {
      errh_CErrLog(DS__ERRALLOC, NULL);
      errh_SetStatus( PWR__SRVTERM);
      exit(DS__ERRALLOC);
    }

    ep->first_scan = 1;

    sts = gdh_RefObjectInfo(name, (pwr_tAddress *)&ep->o, 
		      &ep->o_subid, sizeof(*ep->o));
    if (EVEN(sts)) {
      errh_Error("Couldn't get subscription for '%s'\n%m", name, sts);
      free(ep);
      continue;
    }
    o = ep->o;       

    if ( o->Function & 1) {
      /* Data stored by user */
      gdh_UnrefObjectInfo(ep->o_subid);
      free(ep);
      continue;
    }

    ep->multiple = (int) (o->ScanTime / ctx->scantime_tc + 0.5);
    o->NoOfSample = (int) (o->StorageTime / ctx->scantime_tc * ep->multiple + 0.5);

    /* Initiate DsTrendCuve object, sampled attribute must be on local node */	  

    found = 0;
    for ( i = 0; i < 10; i++) {
      if ( cdh_ObjidIsNull( o->Attribute[i].Objid))
	continue;

      /* Link to attribute */
      sts = gdh_DLRefObjectInfoAttrref((pwr_sAttrRef *)&o->Attribute[i], 
				       (pwr_tAddress *)&ep->datap[i], &ep->data_subid[i]);
      if (EVEN(sts)) {
	if ( sts == GDH__RTDBNULL && IsDisabled( &o->Attribute[i]))
	  continue;
	
	errh_Error("Couldn't get direct link to %s's attribute %d, %m", name, i+1, sts);
	ep->datap[i] = 0;
	continue;
      }
     
      sts = gdh_GetAttributeCharAttrref((pwr_sAttrRef *)&o->Attribute[i],
					&type, &dummy, &dummy, &dummy);
      if (EVEN(sts)) {
	errh_Error("Couldn't get datatype for %s's attribute DataName\n%m", name, sts);
	gdh_UnrefObjectInfo(ep->data_subid[i]);
	ep->datap[i] = 0;
	continue;
      }
      tix = cdh_TypeIdToIndex(type);
      ep->data_size[i] = cdh_TypeToSize( type);

      if (!IsValidType(tix)) {
	errh_Error("No valid datatype for %s's attribute DataName\n%m", name, DS__ERRTYPE);
	gdh_UnrefObjectInfo(ep->data_subid[i]);
	ep->datap[i] = 0;
	continue;
      }
      
      o->AttributeType[i] = type;

      /* Link to buffer */
      sts = gdh_DLRefObjectInfoAttrref((pwr_sAttrRef *)&o->Buffers[i], 
				       (pwr_tAddress *)&ep->buffheadp[i], &ep->buff_subid[i]);
      if (EVEN(sts)) {
	errh_Error("Couldn't get direct link to %s's buffer %d, %m", name, i+1, sts);
	gdh_UnrefObjectInfo(ep->data_subid[i]);
	ep->datap[i] = 0;
	continue;
      }
      ep->buffp[i] = (char *)ep->buffheadp[i] + pwr_AlignLW(sizeof(pwr_sClass_CircBuffHeader));

      /* Get buffer size */
      sts = gdh_GetAttributeCharAttrref( &o->Buffers[i], 0, &ep->buff_size[i], 0, 0);
      if ( EVEN(sts)) return sts;

      ep->buff_size[i] -= pwr_AlignLW(sizeof(pwr_sClass_CircBuffHeader));

      found = 1;
    }
    if ( !found) {
      errh_Error("No valid attributes for %s", name);
      gdh_UnrefObjectInfo(ep->o_subid);
      free(ep);
      continue;
    }

    /* Link to time buffer */
    if ( cdh_ObjidIsNotNull( o->TimeBuffer.Objid)) {
      sts = gdh_DLRefObjectInfoAttrref((pwr_sAttrRef *)&o->TimeBuffer, 
				       (pwr_tAddress *)&ep->timeheadp, &ep->timebuff_subid);
      if (EVEN(sts)) {
	errh_Error("Couldn't get direct link to %s's time buffer, %m", name, sts);
	ep->timeheadp = 0;
	ep->timebuffp = 0;
      }
      else
 	ep->timebuffp = (char *)ep->timeheadp + pwr_AlignLW(sizeof(pwr_sClass_CircBuffHeader));
	
      if ( o->TimeResolution == pwr_eTimeResolutionEnum_Nanosecond)
	ep->time_size = 8;
      else
	ep->time_size = 4;

      /* Get buffer size */
      sts = gdh_GetAttributeCharAttrref( &o->TimeBuffer, 0, &ep->timebuff_size, 0, 0);
      if ( EVEN(sts)) return sts;

      ep->timebuff_size -= pwr_AlignLW(sizeof(pwr_sClass_CircBuffHeader));
    }

    /* Calculate number of samples */
    for ( i = 0; i < 10; i++) {
      if ( !ep->datap[i])
	continue;

      if ( o->NoOfSample > ep->buff_size[i] / ep->data_size[i])
	o->NoOfSample = ep->buff_size[i] / ep->data_size[i];
    }
    if ( ep->timebuffp) {
      if ( o->NoOfSample > ep->timebuff_size / ep->time_size)
	o->NoOfSample = ep->timebuff_size / ep->time_size;
    }
    for ( i = 0; i < 10; i++) {
      if ( !ep->datap[i])
	continue;

      ep->buffheadp[i]->Size = o->NoOfSample;
      ep->buffheadp[i]->ElementSize = ep->data_size[i];
    }
    if ( ep->timebuffp) {
      ep->timeheadp->Size = o->NoOfSample;
      ep->timeheadp->ElementSize = ep->time_size;
    }
     
    ep->next = ctx->o_list_tc;
    ctx->o_list_tc = ep;
  }

  if ( ctx->o_list == NULL && ctx->o_list_tc == NULL)
    return DS__NOOBJECT;
  else
    return DS__SUCCESS;
}
예제 #22
0
//
// printValue
//
bool wb_print_wbl::printValue (wb_volume& v,
                               wb_adef& adef,
                               void *val,
                               int varSize,
                               char **svalp) 
{
  unsigned long sts;
  char timbuf[24];
  static char sval[512];
  bool retval = true;
  pwr_tOid oid;
  wb_object o;
  

  sval[0] = '\0';

  if (adef.flags() & PWR_MASK_POINTER) {
    sprintf(sval, "%u", *(unsigned int *) val);
    *svalp = sval;
    return TRUE;
  }

  switch (adef.type()) {
  case pwr_eType_Boolean:
    sprintf(sval, "%d", *(pwr_tBoolean *) val);
    break;
  case pwr_eType_Float32:
    if ( *(pwr_tFloat32 *)val == FLT_MIN)
      strcpy( sval, "FLT_MIN");
    else if ( *(pwr_tFloat32 *)val == FLT_MAX)
      strcpy( sval, "FLT_MAX");
    else
      sprintf(sval, "%.*e", FLT_DIG, *(pwr_tFloat32 *) val);
    break;
  case pwr_eType_Float64:
    sprintf(sval, "%.*e", DBL_DIG, *(pwr_tFloat64 *) val);
    break;
  case pwr_eType_Char:
    if (*(pwr_tChar *) val == 0)
      sprintf(sval, "\"\"");
    else
      sprintf(sval, "\"%c\"", *(pwr_tChar *) val);
    break;
  case pwr_eType_Int8:
    sprintf(sval, "%d", *(pwr_tInt8 *) val);
    break;
  case pwr_eType_Int16:
    sprintf(sval, "%d", *(pwr_tInt16 *) val);
    break;
  case pwr_eType_Int32:
    if ( *(pwr_tInt32 *)val == INT_MIN)
      strcpy( sval, "INT_MIN");
    else if ( *(pwr_tInt32 *)val == INT_MAX)
      strcpy( sval, "INT_MAX");
    else
      sprintf(sval, "%d", *(pwr_tInt32 *) val);
    break;
  case pwr_eType_Int64:
    sprintf(sval, pwr_dFormatInt64, *(pwr_tInt64 *) val);
    break;
  case pwr_eType_UInt8:
    sprintf(sval, "%u", *(pwr_tUInt8 *) val);
    break;
  case pwr_eType_UInt16:
    sprintf(sval, "%u", *(pwr_tUInt16 *) val);
    break;
  case pwr_eType_UInt32:
  case pwr_eType_DisableAttr:
    sprintf(sval, "%u", *(pwr_tUInt32 *) val);
    break;
  case pwr_eType_UInt64:
    sprintf(sval, pwr_dFormatUInt64, *(pwr_tUInt64 *) val);
    break;
  case pwr_eType_Mask:
    sprintf(sval, "%u", *(pwr_tUInt32 *) val);
    break;
  case pwr_eType_Enum:
    sprintf(sval, "%u", *(pwr_tUInt32 *) val);
    break;
  case pwr_eType_RefId:
    sprintf(sval, "0");
    break;
  case pwr_eType_Objid:
    if (cdh_ObjidIsNull(*(pwr_tOid *) val))
      sprintf(sval, "\"_O0.0.0.0:0\"");
    else {
      o = v.object(*(pwr_tOid *)val);
      if (o) {
	if ( o.oid().vid >= cdh_cUserVolMin && o.oid().vid != v.vid() && !m_keepName)
	  // Other user volume. Loadfile might not be created yet at load time.
	  sprintf(sval, "\"%s\"", cdh_ObjidToString(NULL, *(pwr_tObjid *)val, 1));
	else
	  sprintf(sval, "\"%s\"", o.longName().c_str());	  
      }
      else 
        sprintf(sval, "\"%s\"", cdh_ObjidToString(NULL, *(pwr_tObjid *)val, 1));
    }    
    break;
  case pwr_eType_ObjectIx:
    if ( *(pwr_tObjectIx *) val == 0)
      sprintf(sval, "0");
    else
      sprintf(sval, "\"%s\"", cdh_ObjectIxToString(NULL, *(pwr_tObjectIx *) val,1));
    break;
  case pwr_eType_VolumeId:
    if ( *(pwr_tVolumeId *) val == 0)
      sprintf(sval, "0");
    else
      sprintf(sval, "\"%s\"", cdh_VolumeIdToString(NULL, *(pwr_tVolumeId *) val,1,0));
    break;
  case pwr_eType_ClassId:
    if (*(pwr_tClassId *) val == 0)
      sprintf(sval, "0");
    else {
      wb_cdef cdef = v.cdef(*(pwr_tCid *)val);
      if (cdef)
        sprintf(sval, "\"%s\"", cdef.longName().c_str());
      else {
        sprintf(sval, "Unknown class, identity: %d", (*(pwr_tClassId *) val));
        m_errCnt++;
        retval = false;
      }
            
    }
    break;
  case pwr_eType_TypeId: /** @todo Modify when wb_tdef is OK q*/
  case pwr_eType_CastId:
    if (*(pwr_tTypeId *) val == 0)
      sprintf(sval, "0");
    else {
      oid = cdh_TypeIdToObjid(*(pwr_tTid *)val);
      o = v.object(oid);
      if (o)
        sprintf(sval, "\"%s\"", o.longName().c_str());
      else {
        sprintf(sval, "Unknown type, identity: %d", (*(pwr_tTypeId *) val));
        m_errCnt++;
        retval = false;
      }
    }    
    break;
  case pwr_eType_AttrRef: /** @todo */
    if (cdh_ObjidIsNull(((pwr_sAttrRef*)val)->Objid))
      sprintf(sval, "\"_O0.0.0.0:0\"");
    else {
      try {
	wb_attribute a = v.attribute((pwr_sAttrRef*)val);
	if (a)
	  sprintf(sval, "\"%s\"", a.longName().c_str());
	else {
	  sprintf(sval, "\"%s\"", cdh_ArefToString(NULL, (pwr_sAttrRef*)val, 1));
	}
      } catch ( wb_error &e) {
	if ( ldh_isSymbolicVid( ((pwr_sAttrRef *)val)->Objid.vid))
	  sprintf(sval, "\"%s\"", cdh_ArefToString(NULL, (pwr_sAttrRef*)val, 1));
	else {
	  sprintf(sval, "Unknown attribute reference");
	  m_errCnt++;
	  retval = FALSE;
	}
      }
    }
#if 0      
    } else {
예제 #23
0
파일: rt_subc.c 프로젝트: hfuhuang/proview
void
subc_ActivateList (
    pool_sQlink		*lh,
    pwr_tObjid		oid
)
{
    pwr_tStatus		sts;
    tree_sTable		*add;
#if 0
    tree_sTable		*remove;
    sRemove		*rep;
#endif
    net_sSubSpec		*specp;
    qcom_sQid		tgt;
    pool_sQlink		*my_lh;
    pwr_tUInt32		my_subc_lc;
    gdb_sNode		*np;
    gdb_sNode		*old_np;
    sub_sClient		*cp;
    pool_sQlink		*cl;
    sAdd			*aep;


    /* Test each client. If existing object, fill in nid field
       and move the client to the appropriate nodes's subc_lh list. Turn
       on timeouts. Put request in subadd message buffer.

       We must do it all in one pass, since a user can come in during
       a cache query for a later subcli and cancel the subscription
       for an earlier subcli.  */

    add = tree_CreateTable(&sts, sizeof(pwr_tNodeId), offsetof(sAdd, nid),
                           sizeof(sAdd), 10, tree_Comp_nid);
#if 0
    remove = tree_CreateTable(&sts, sizeof(pwr_tNodeId), offsetof(sRemove, nid),
                              sizeof(sRemove), 10, tree_eComp_nid);
#endif

    /* Move all objects to a new, temporary root */

    my_lh = pool_Qalloc(NULL, gdbroot->pool);
    my_subc_lc = 0;

    for (cl = pool_Qsucc(NULL, gdbroot->pool, lh); cl != lh;) {
        cp = pool_Qitem(cl, sub_sClient, subc_ll);
        cl = pool_Qsucc(NULL, gdbroot->pool, cl);

        if (cdh_ObjidIsNull(oid) || cdh_ObjidIsEqual(oid, cp->aref.Objid)) {
            pool_Qremove(NULL, gdbroot->pool, &cp->subc_ll);
            pool_QinsertPred(NULL, gdbroot->pool, &cp->subc_ll, my_lh);
            my_subc_lc++;
        }
    }

    /* Now start testing clients from 'my_lh', and move them to other lists
       Make sure the clients are still there after the test.  */

    for (cl = pool_Qsucc(NULL, gdbroot->pool, my_lh); cl != my_lh; ) {
        cp = pool_Qitem(cl, sub_sClient, subc_ll);
        cl = pool_Qsucc(NULL, gdbroot->pool, cl);

        np = testClient(&sts, cp);

        /* If an error is returned the client doesn't exist anymore. Some
           other user removed it while TestSubcli had the database unlocked.
           Just go on with the next client...  */

        if (np == NULL) continue;

        /* Move the client to the list for the node where the object resides.
           nid = pwr_cNNodeId is used for all objects we don't know.  */

        old_np = hash_Search(&sts, gdbroot->nid_ht, &cp->nid);
        if (old_np == NULL) errh_Bugcheck(GDH__WEIRD, "");

        pool_Qremove(NULL, gdbroot->pool, &cp->subc_ll);
        old_np->subc_lc--;
        pool_QinsertPred(NULL, gdbroot->pool, &cp->subc_ll, &np->subc_lh);
        np->subc_lc++;
        cp->nid = np->nid;

        /* If the object's nid changed, then take the appropriate actions.  */

        if (np != old_np) {
            if (np->nid != pwr_cNNodeId) {  /* Object is known.  */

                activateTimeoutWatch(cp);

                aep = tree_Insert(&sts, add, &np->nid);
                if (aep == NULL) errh_Bugcheck(GDH__WEIRD, "");

                if (aep->msg == NULL) {
                    aep->cnt = MIN(my_subc_lc, net_cSubMaxAdd);
                    aep->msg = malloc(sizeof(net_sSubAdd) + sizeof(net_sSubSpec) * aep->cnt);
                    aep->msg->count = 0;
                } /* If there was no message allocated */

                specp		    = &aep->msg->spec[aep->msg->count];
                specp->sid	    = cp->sid;
                specp->dt	    = cp->dt;
                specp->sub_by_name  = cp->sub_by_name;
                specp->aref	    = cp->cclass != pool_cNRef ? cp->raref : cp->aref;

                if (++aep->msg->count >= aep->cnt) {

                    /* The message buffer is full and must be sent.  */

                    tgt = np->handler;
                    pwr_Assert(tgt.nid != pwr_cNNodeId);

                    gdb_Unlock;

                    net_Put(NULL, &tgt, aep->msg, net_eMsg_subAdd, 0, pwr_Offset(aep->msg, spec[aep->msg->count]), 0);

                    gdb_Lock;

                    aep->msg->count = 0;

                }

            } else {	/* The object became unknown... */

                cancelTimeoutWatch(cp);
                subc_SetOld(cp);	/* Data gets old immediately */

#if 0
                /** @todo Maybe we should unlock the cached class? */
                if (cp->cclass != pwr_cNRefId) {
                    ccp = pool_Address(NULL, gdbroot->pool, cp->cclass);
                    if (ccp == NULL) errh_Bugcheck(GDH__WEIRD, "Cached class address");
                    cmvolc_UnlockClass(NULL, ccp);
                    cp->cclass = pwr_cNRefId;
                }
#endif

#if 0
                if (old_np->nid != pwr_cNNodeId) {
                    rep = tree_Insert(&sts, remove, &old_np->nid);
                    if (rep == NULL) errh_Bugcheck(GDH__WEIRD, "");

                    if (rep->msg == NULL) {
                        rep->nid = old_np->nid;
                        rep->cnt = MIN(my_subc_lc, net_cSubMaxRemove);
                        rep->msg = malloc(sizeof(net_sSubRemove) + sizeof(rep->msg->sid[0]) * rep->cnt);
                        rep->msg->count = 0;
                    }

                    rep->msg->sid[rep->msg->count++] = cp->sid;

                    if (rep->msg->count >= net_cSubMaxRemove) {
                        np = hash_Search(&sts, gdbroot->nid_ht, &old_np->nid);
                        if (np == NULL) errh_Bugcheck(sts, "");
                        tgt.nid = rep->nid;
                        pwr_Assert(tgt.nid != pwr_cNNodeId);

                        gdb_Unlock;

                        net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0);

                        gdb_Lock;

                        rep->msg->count = 0;

                    }
                }
#endif
            }
        }
    }

    pool_Free(NULL, gdbroot->pool, my_lh);

    /* Now walk through the addmsg & remmsg and send all unsent messages.  */

    gdb_Unlock;

#if 0
    for (rep = tree_Minimum(remove); rep != NULL; rep = tree_Successor(remove, rep)) {
        if (rep->msg != NULL) {
            if (rep->msg->count > 0) {
                tgt.nid = rep->nid;
                pwr_Assert(tgt.nid != pwr_cNNodeId);
                net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0);
            }
            free(rep->msg);
        }
    }
#endif
    for (aep = tree_Minimum(&sts, add); aep != NULL; aep = tree_Successor(&sts, add, aep)) {
        if (aep->msg != NULL) {
            if (aep->msg->count > 0) {

                np = hash_Search(&sts, gdbroot->nid_ht, &aep->nid);
                if (np == NULL) errh_Bugcheck(GDH__WEIRD, "");

                tgt = np->handler;
                pwr_Assert(tgt.nid != pwr_cNNodeId);
                net_Put(NULL, &tgt, aep->msg, net_eMsg_subAdd, 0, pwr_Offset(aep->msg, spec[aep->msg->count]), 0);
            }
            free(aep->msg);
        }
    }

    gdb_Lock;

    tree_DeleteTable(&sts, add);
#if 0
    tree_DeleteTable(remove);
#endif
}
예제 #24
0
pwr_tStatus wsx_CheckSigChanCon( 
	ldh_tSesContext	sesctx,
	pwr_tAttrRef	aref,
	int		*errorcount,
	int		*warningcount	
)
{
	int	sts;
	int	size;
	pwr_tAttrRef	*con_ptr;
	int		class_error;
	pwr_tClassId	cid;
	pwr_tClassId	con_class;

	sts = ldh_GetAttrRefTid ( sesctx, &aref, &cid);
	if ( EVEN(sts)) return sts;
	
	/* Check SigChanCon */
	sts = ldh_GetAttrObjectPar( sesctx,
			&aref, 
			"RtBody",
			"SigChanCon",
			(char **)&con_ptr, &size);
	if (EVEN(sts)) return sts;

	if ( cdh_ObjidIsNull(con_ptr->Objid)) {
	  wsx_error_msg( sesctx, WSX__SIGCHANCON, aref, errorcount, warningcount);
	  free((char *) con_ptr);
	  return WSX__SUCCESS;
	}
	
	/* Check object class of connected object */
	sts = ldh_GetAttrRefTid ( sesctx, con_ptr, &con_class);
	if ( EVEN(sts)) {
	  wsx_error_msg( sesctx, WSX__SIGCHANCON, aref, errorcount, warningcount);
	  free((char *) con_ptr);
	  return WSX__SUCCESS;
	}
	class_error = 0;
	switch ( cid) {
	case pwr_cClass_Di:
	  if ( con_class != pwr_cClass_ChanDi)
	    class_error = 1;
	  break;
	case pwr_cClass_Do:
	  if ( con_class != pwr_cClass_ChanDo)
	    class_error = 1;
	  break;
	case pwr_cClass_Po:
	  if ( con_class != pwr_cClass_ChanDo)
	    class_error = 1;
	  break;
	case pwr_cClass_Ai:
	  if ( !(con_class == pwr_cClass_ChanAi ||
		 con_class == pwr_cClass_ChanAit))
	    class_error = 1;
	  break;
	case pwr_cClass_Ao:
	  if ( con_class != pwr_cClass_ChanAo)
	    class_error = 1;
	  break;
	case pwr_cClass_Co:
	  if ( con_class != pwr_cClass_ChanCo)
	    class_error = 1;
	  break;
	case pwr_cClass_Io:
	  if ( con_class != pwr_cClass_ChanIo)
	    class_error = 1;
	  break;
	case pwr_cClass_Ii:
	  if ( con_class != pwr_cClass_ChanIi)
	    class_error = 1;
	  break;
	case pwr_cClass_Bi:
	  if ( con_class != pwr_cClass_ChanBi)
	    class_error = 1;
	  break;
	case pwr_cClass_Bo:
	  if ( con_class != pwr_cClass_ChanBo)
	    class_error = 1;
	  break;
	}

	if ( class_error) {
	  wsx_error_msg( sesctx, WSX__SIGCHANCONCLASS, aref, errorcount, warningcount);
	  free((char *) con_ptr);
	  return WSX__SUCCESS;
	}

	free((char *) con_ptr);
	return WSX__SUCCESS;
}
예제 #25
0
pwr_tStatus wsx_CheckIoDevice( 
	ldh_tSesContext	sesctx,
	pwr_tAttrRef	aref,
	int		*errorcount,
	int		*warningcount,
	wsx_mCardOption options
)
{
  wb_session *sp = (wb_session *)sesctx;
  pwr_tMask process;
  pwr_tOid thread;

  wb_attribute a = sp->attribute( &aref);
  if ( !a) return a.sts();

  // Check Process
  wb_attribute process_a( a, 0, "Process");
  if ( !process_a) return process_a.sts();
    
  process_a.value( &process);
  if ( !process_a) return process_a.sts();
  if ( process == 0)
    wsx_error_msg_str( sesctx, "Process is not specified", aref, 'W', errorcount, warningcount);
  else if ( process == 1) {

    // Check thread object
    wb_attribute thread_a( a, 0, "ThreadObject");
    if ( !thread_a) return thread_a.sts();
    
    thread_a.value( &thread);
    if ( !thread_a) return thread_a.sts();
    if ( cdh_ObjidIsNull( thread))
      wsx_error_msg_str( sesctx, "ThreadObject is not specified", aref, 'E', errorcount, warningcount);
    else {
      wb_object thread_o = sp->object( thread);
      if ( !thread_o)
	wsx_error_msg_str( sesctx, "Undefined ThreadObject", aref, 'E', errorcount, warningcount);
      else if ( thread_o.cid() != pwr_cClass_PlcThread)
	wsx_error_msg_str( sesctx, "Error in ThreadObject class", aref, 'E', errorcount, warningcount);
    }
  }

  if ( options & wsx_mCardOption_ErrorLimits) {
    pwr_tUInt32 limit;

    // Check SoftLimit
    wb_attribute softlimit_a( a, 0, "ErrorSoftLimit");
    if ( !softlimit_a) return softlimit_a.sts();
    
    softlimit_a.value( &limit);
    if ( !softlimit_a) return softlimit_a.sts();
    if ( limit == 0)
      wsx_error_msg_str( sesctx, "ErrorSoftLimit is not specified", aref, 'W', errorcount, warningcount);

    // Check HardLimit
    wb_attribute hardlimit_a( a, 0, "ErrorHardLimit");
    if ( !hardlimit_a) return hardlimit_a.sts();
    
    hardlimit_a.value( &limit);
    if ( !hardlimit_a) return hardlimit_a.sts();
    if ( limit == 0)
      wsx_error_msg_str( sesctx, "ErrorHardLimit is not specified", aref, 'E', errorcount, warningcount);

  }
  return WSX__SUCCESS;
}
예제 #26
0
int pndevice_save_cb(void* sctx)
{
  device_sCtx* ctx = (device_sCtx*)sctx;
  pwr_tStatus sts;
  pwr_tOName name;
  int size;
  pwr_tOid oid;
  pwr_tStatus rsts = PB__SUCCESS;

  // Syntax check
  if (ctx->attr->attrnav->device_num == 0) {
    MsgWindow::message('E', "Device type not selected");
    return PB__SYNTAX;
  }

  for (unsigned int i = 1; i < ctx->attr->attrnav->dev_data.slot_data.size();
       i++) {
    if (ctx->attr->attrnav->dev_data.slot_data[i]->module_enum_number == 0
        && ctx->attr->attrnav->dev_data.slot_data[i]->module_class != 0) {
      // Module class selected but not module type
      char msg[20];

      sprintf(msg, "Slot %d", i);
      MsgWindow::message('E', "Module type not selected, ", msg);
      rsts = PB__MODULETYPE;
    }
    if (ctx->attr->attrnav->dev_data.slot_data[i]->module_class == 0
        && ctx->attr->attrnav->dev_data.slot_data[i]->module_enum_number != 0) {
      // Module type selected but not module class
      char msg[20];

      sprintf(msg, "Slot %d", i);
      MsgWindow::message('E', "Module class not selected, ", msg);
      rsts = PB__MODULECLASS;
    }
  }

  // Save configuration
  ((WNav*)ctx->editor_ctx)->set_nodraw();

  sts = ldh_ObjidToName(ctx->ldhses, ctx->aref.Objid, ldh_eName_Hierarchy, name,
      sizeof(name), &size);
  if (EVEN(sts))
    goto return_now;

  // Check that Slot attribute corresponds to the and module_oid
  for (unsigned int i = 1; i < ctx->attr->attrnav->dev_data.slot_data.size();
       i++)
    ctx->attr->attrnav->dev_data.slot_data[i]->module_oid = pwr_cNOid;

  for (sts = ldh_GetChild(ctx->ldhses, ctx->aref.Objid, &oid); ODD(sts);
       sts = ldh_GetNextSibling(ctx->ldhses, oid, &oid)) {
    unsigned int *slotnumberp, slotnumber;

    sts = ldh_GetObjectPar(
        ctx->ldhses, oid, "RtBody", "Slot", (char**)&slotnumberp, &size);
    if (EVEN(sts)) {
      MsgWindow::message(
          'E', "Not a Profinet module object", msgw_ePop_Yes, oid);
      continue;
    }
    slotnumber = *slotnumberp;
    free(slotnumberp);

    if (slotnumber >= ctx->attr->attrnav->dev_data.slot_data.size()) {
      MsgWindow::message('E', "Slot too large", msgw_ePop_Yes, oid);
      continue;
    }

    if (cdh_ObjidIsNotNull(
            ctx->attr->attrnav->dev_data.slot_data[slotnumber]->module_oid)) {
      MsgWindow::message('E', "Slot already used", msgw_ePop_Yes, oid);
      continue;
    }

    if (ctx->attr->attrnav->dev_data.slot_data[slotnumber]->module_class
        == pwr_cNCid)
      // Should be removed
      continue;

    ctx->attr->attrnav->dev_data.slot_data[slotnumber]->module_oid = oid;
  }

  // Remove modules that wasn't configured any more
  pwr_tOid moid[100];
  int mcnt;
  int found;
  mcnt = 0;
  for (sts = ldh_GetChild(ctx->ldhses, ctx->aref.Objid, &oid); ODD(sts);
       sts = ldh_GetNextSibling(ctx->ldhses, oid, &oid)) {
    found = 0;
    for (unsigned int i = 0; i < ctx->attr->attrnav->dev_data.slot_data.size();
         i++) {
      if (cdh_ObjidIsEqual(
              ctx->attr->attrnav->dev_data.slot_data[i]->module_oid, oid)) {
        found = 1;
        break;
      }
    }
    if (!found) {
      moid[mcnt++] = oid;
      if (mcnt > (int)(sizeof(moid) / sizeof(moid[0])))
        break;
    }
  }

  for (int i = 0; i < mcnt; i++)
    sts = ldh_DeleteObjectTree(ctx->ldhses, moid[i], 0);

  // Create new module objects
  for (unsigned int i = 0; i < ctx->attr->attrnav->dev_data.slot_data.size();
       i++) {
    GsdmlSlotData* slot = ctx->attr->attrnav->dev_data.slot_data[i];

    if (cdh_ObjidIsNull(slot->module_oid) && slot->module_class != pwr_cNCid) {
      char mname[20];
      sprintf(mname, "M%d", i);

      if (i == 1)
        sts = ldh_CreateObject(ctx->ldhses, &slot->module_oid, mname,
            slot->module_class, ctx->aref.Objid, ldh_eDest_IntoFirst);
      else {
        // Find sibling
        pwr_tOid dest_oid = pwr_cNOid;
        int dest_found = 0;
        for (int j = i - 1; j > 0; j--) {
          if (cdh_ObjidIsNotNull(
                  ctx->attr->attrnav->dev_data.slot_data[j]->module_oid)) {
            dest_oid = ctx->attr->attrnav->dev_data.slot_data[j]->module_oid;
            dest_found = 1;
            break;
          }
        }
        if (!dest_found)
          sts = ldh_CreateObject(ctx->ldhses, &slot->module_oid, mname,
              slot->module_class, ctx->aref.Objid, ldh_eDest_IntoFirst);
        else
          sts = ldh_CreateObject(ctx->ldhses, &slot->module_oid, mname,
              slot->module_class, dest_oid, ldh_eDest_After);
      }
      if (EVEN(sts)) {
        MsgWindow::message('E', "Error creating module object", mname);
        sts = 0;
        goto return_now;
      }

      pwr_tAttrRef aaref;
      pwr_tAttrRef modulearef = cdh_ObjidToAref(slot->module_oid);

      // Set Slot
      pwr_tUInt32 slotnumber = i;
      sts = ldh_ArefANameToAref(ctx->ldhses, &modulearef, "Slot", &aaref);
      if (EVEN(sts))
        goto return_now;

      sts = ldh_WriteAttribute(
          ctx->ldhses, &aaref, &slotnumber, sizeof(slotnumber));
      if (EVEN(sts))
        goto return_now;
    }
  }

  for (unsigned int i = 0; i < ctx->attr->attrnav->dev_data.slot_data.size();
       i++) {
    GsdmlSlotData* slot = ctx->attr->attrnav->dev_data.slot_data[i];

    if (i == 0) {
      std::vector<ChanItem> input_vect;
      std::vector<ChanItem> output_vect;

      sts = pndevice_check_io(ctx,
          ctx->attr->attrnav->device_item->VirtualSubmoduleList, input_vect,
          output_vect);
      if (sts == PB__CREATECHAN) {
        char msg[20];
        sprintf(msg, "Slot %d", i);
        MsgWindow::message(
            'W', "Unexpected datatype, channel not created, ", msg);
      }
    } else {
      if (slot->module_class == pwr_cClass_PnModule) {
        std::vector<ChanItem> input_vect;
        std::vector<ChanItem> output_vect;
        gsdml_UseableModules* um
            = ctx->gsdml->ApplicationProcess->DeviceAccessPointList
                  ->DeviceAccessPointItem[ctx->attr->attrnav->device_num - 1]
                  ->UseableModules;

        if (!um)
          continue;
        gsdml_ModuleItem* mi
            = (gsdml_ModuleItem*)um->ModuleItemRef[slot->module_enum_number - 1]
                  ->Body.ModuleItemTarget.p;

        sts = pndevice_check_io(
            ctx, mi->VirtualSubmoduleList, input_vect, output_vect);
        if (sts == PB__CREATECHAN) {
          char msg[20];
          sprintf(msg, "Slot %d", i);
          MsgWindow::message(
              'W', "Unexpected datatype, channel not created, ", msg);
        }

        // Create the channels
        if (EVEN(ldh_GetChild(ctx->ldhses, slot->module_oid, &oid))) {
          unsigned int chan_cnt = 0;
          for (unsigned int j = 0; j < input_vect.size(); j++) {
            char name[80];
            sprintf(name, "Ch%02u", chan_cnt++);
            sts = ldh_CreateObject(ctx->ldhses, &oid, name, input_vect[j].cid,
                slot->module_oid, ldh_eDest_IntoLast);
            if (EVEN(sts))
              goto return_now;

            pwr_tAttrRef aaref;
            pwr_tAttrRef chanaref = cdh_ObjidToAref(oid);

            // Set Representation
            pwr_tEnum representation = input_vect[j].representation;
            sts = ldh_ArefANameToAref(
                ctx->ldhses, &chanaref, "Representation", &aaref);
            if (EVEN(sts))
              goto return_now;

            sts = ldh_WriteAttribute(
                ctx->ldhses, &aaref, &representation, sizeof(representation));
            if (EVEN(sts))
              goto return_now;

            // Set Number
            pwr_tUInt16 number = input_vect[j].number;
            sts = ldh_ArefANameToAref(ctx->ldhses, &chanaref, "Number", &aaref);
            if (EVEN(sts))
              goto return_now;

            sts = ldh_WriteAttribute(
                ctx->ldhses, &aaref, &number, sizeof(number));
            if (EVEN(sts))
              goto return_now;

            // Set Description
            pwr_tString80 description;
            strncpy(
                description, input_vect[j].description, sizeof(description));
            sts = ldh_ArefANameToAref(
                ctx->ldhses, &chanaref, "Description", &aaref);
            if (EVEN(sts))
              goto return_now;

            sts = ldh_WriteAttribute(
                ctx->ldhses, &aaref, description, sizeof(description));
            if (EVEN(sts))
              goto return_now;
          }
          for (unsigned int j = 0; j < output_vect.size(); j++) {
            char name[80];
            sprintf(name, "Ch%02u", chan_cnt++);
            sts = ldh_CreateObject(ctx->ldhses, &oid, name, output_vect[j].cid,
                slot->module_oid, ldh_eDest_IntoLast);
            if (EVEN(sts))
              goto return_now;

            pwr_tAttrRef aaref;
            pwr_tAttrRef chanaref = cdh_ObjidToAref(oid);

            // Set Representation
            pwr_tEnum representation = output_vect[j].representation;
            sts = ldh_ArefANameToAref(
                ctx->ldhses, &chanaref, "Representation", &aaref);
            if (EVEN(sts))
              goto return_now;

            sts = ldh_WriteAttribute(
                ctx->ldhses, &aaref, &representation, sizeof(representation));
            if (EVEN(sts))
              goto return_now;

            // Set Number
            pwr_tUInt16 number = output_vect[j].number;
            sts = ldh_ArefANameToAref(ctx->ldhses, &chanaref, "Number", &aaref);
            if (EVEN(sts))
              goto return_now;

            sts = ldh_WriteAttribute(
                ctx->ldhses, &aaref, &number, sizeof(number));
            if (EVEN(sts))
              goto return_now;

            // Set Description
            pwr_tString80 description;
            strncpy(
                description, output_vect[j].description, sizeof(description));
            sts = ldh_ArefANameToAref(
                ctx->ldhses, &chanaref, "Description", &aaref);
            if (EVEN(sts))
              goto return_now;

            sts = ldh_WriteAttribute(
                ctx->ldhses, &aaref, description, sizeof(description));
            if (EVEN(sts))
              goto return_now;
          }
        }
      } else {
        // Remove existing channels
        std::vector<pwr_tOid> chanvect;
        pwr_tCid cid;

        for (sts = ldh_GetChild(ctx->ldhses, slot->module_oid, &oid); ODD(sts);
             sts = ldh_GetNextSibling(ctx->ldhses, oid, &oid)) {
          sts = ldh_GetObjectClass(ctx->ldhses, oid, &cid);
          if (EVEN(sts))
            goto return_now;

          switch (cid) {
          case pwr_cClass_ChanDi:
          case pwr_cClass_ChanDo:
          case pwr_cClass_ChanAi:
          case pwr_cClass_ChanAo:
          case pwr_cClass_ChanIi:
          case pwr_cClass_ChanIo:
            chanvect.push_back(oid);
            break;
          default:;
          }
        }
        for (unsigned int i = 0; i < chanvect.size(); i++) {
          sts = ldh_DeleteObject(ctx->ldhses, chanvect[i]);
          if (EVEN(sts))
            goto return_now;
        }
      }
    }
  }

  // Write data of all devices for profinet viewer
  // Data is device name, IP and MAC address
  sts = generate_viewer_data(ctx);

  sts = rsts;

return_now:
  ((WNav*)ctx->editor_ctx)->reset_nodraw();
  return sts;
}
예제 #27
0
int XNav::getAllMenuItems( xmenu_sMenuCall	*ip,
			   xmenu_sMenuItem	**Item,
			   pwr_tObjid		objid,
			   pwr_tUInt32		Level,
			   int			*nItems,
			   int			AddSeparator,
			   pwr_sAttrRef		*CurrentObject)
{
  int                   sts;
  pwr_tCid	        classid;
  pwr_tObjid            child;
  pwr_sMenuButton	*mbp;
  pwr_sMenuCascade	*mcp;
  pwr_sMenuRef		*mrp;
  pwr_tStatus           (*filter)( xmenu_sMenuCall *);
  int                   sensitive;
  int                   i;


  Level++;
  memset(*Item, 0, sizeof(**Item));

  if(AddSeparator) {
    (*Item)->Level = Level;
    (*Item)->Item = xmenu_eMenuItem_Separator;
    (*Item)->MenuObject = pwr_cNObjid;
    (*Item)++;
    (*nItems)++;
  } 
  else {
    sts = gdh_GetObjectClass( objid, &classid);
    if ( EVEN(sts)) return sts;

    if ( classid == pwr_eClass_MenuButton) {
      sts = gdh_ObjidToPointer( objid, (void **) &mbp);
      if ( EVEN(sts)) return sts;

      
      ip->ChosenItem = *nItems;
      for ( i = 0; i < 5; i++) {
        strcpy( (*Item)->FilterArguments[i], mbp->FilterArguments[i]);
      }

      // Call any filter method
      (*Item)->CurrentObject = *CurrentObject;
      sensitive = 1;
      if ( strcmp( mbp->FilterName, "") != 0) {
        sts = GetMethod( mbp->FilterName, &filter);
        if ( ODD(sts)) {
          sts = (filter) ( ip);
	  if ( sts == XNAV__INSENSITIVE) 
            sensitive = 0;
        }
      }
      else
        sts = XNAV__SUCCESS;

      if ( ODD(sts)) {
        (*Item)->Level = Level;
        (*Item)->Item = xmenu_eMenuItem_Button;
        (*Item)->MenuObject = objid;

        (*Item)->Flags.f.Sensitive = sensitive;
        if (strcmp( mbp->MethodName, "")  == 0)
          (*Item)->Flags.f.Sensitive = 0;

        strcpy((*Item)->Name, mbp->ButtonName);
        strcpy( (*Item)->Method, mbp->MethodName);
        strcpy( (*Item)->Filter, mbp->FilterName);
        for ( i = 0; i < 5; i++) {
          strcpy( (*Item)->MethodArguments[i], mbp->MethodArguments[i]);
        }
        (*Item)++;
        (*nItems)++;
      }
    } 
    else if ( classid == pwr_eClass_MenuSeparator) {
      (*Item)->Level = Level;
      (*Item)->Item = xmenu_eMenuItem_Separator;
      (*Item)->MenuObject = objid;
      (*Item)++;
      (*nItems)++;
    } 
    else if ( classid == pwr_eClass_MenuCascade) {
      sts = gdh_ObjidToPointer( objid, (void **) &mcp);
      if ( EVEN(sts)) return sts;

      // Call any filter method
      (*Item)->CurrentObject = *CurrentObject;
      if ( strcmp( mcp->FilterName, "") != 0) {
        sts = GetMethod( mcp->FilterName, &filter);
        if ( ODD(sts)) {
          sts = (filter) ( ip);
        }
      }
      else
        sts = XNAV__SUCCESS;

      if ( ODD(sts)) {
        (*Item)->Level = Level;
        (*Item)->Item = xmenu_eMenuItem_Cascade;
        (*Item)->Flags.f.Sensitive = 1;
        strcpy((*Item)->Name, mcp->ButtonName);
        (*Item)->MenuObject = objid;
        (*Item)++;
        (*nItems)++;
     
        sts = gdh_GetChild( objid, &child);
        while( ODD(sts)) {
          sts = getAllMenuItems(ip, Item, child, Level, nItems, 0, CurrentObject);
          if ( EVEN(sts)) return sts;
          sts = gdh_GetNextSibling( child, &child);
        }
      }
    }
    else if ( classid == pwr_eClass_MenuRef && 
	      cdh_ObjidIsNull( CurrentObject->Objid)) {
      pwr_tAName aname;
      pwr_sAttrRef currentar;
      pwr_tCid current_cid;
      pwr_tTid a_tid;
      pwr_tUInt32 a_size, a_offs, a_elem;

      sts = gdh_ObjidToPointer( objid, (void **) &mrp);
      if ( EVEN(sts)) return sts;

      // Call any filter method
      (*Item)->CurrentObject = *CurrentObject;
      if ( strcmp( mrp->FilterName, "") != 0) {
        sts = GetMethod( mrp->FilterName, &filter);
        if ( ODD(sts)) {
          sts = (filter) ( ip);
        }
      }
      else
        sts = XNAV__SUCCESS;

      if ( ODD(sts)) {
	int create_object_button = 0;

	if ( strcmp( mrp->RefAttribute, "_SelfObject") == 0) {
	  // Object entry for attributes
	  char *s;

	  sts = gdh_AttrrefToName( &ip->Pointed, aname, sizeof(aname), cdh_mName_volumeStrict);
	  if ( EVEN(sts)) return sts;
	  if ( (s = strrchr( aname, '.')))
	    *s = 0;

	  sts = gdh_NameToAttrref( pwr_cNOid, aname, &currentar);
	  if ( EVEN(sts)) return sts;
	}
	else {
	  sts = gdh_AttrrefToName( &ip->Pointed, aname, sizeof(aname), cdh_mName_volumeStrict);
	  if ( EVEN(sts)) return sts;
	  strcat( aname, ".");
	  strcat( aname, mrp->RefAttribute);
	  
	  sts = gdh_GetAttributeCharacteristics( aname, &a_tid, &a_size,
						 &a_offs, &a_elem);
	  if ( ODD(sts)) {
	    switch ( a_tid) {
	    case pwr_eType_AttrRef:
	      sts = gdh_GetObjectInfo( aname, &currentar, sizeof(currentar));
	      break;
	    case pwr_eType_Objid: {
	      pwr_tOid oid;
	      
	      currentar = pwr_cNAttrRef;
	      sts = gdh_GetObjectInfo( aname, &oid, sizeof(oid));
	      currentar = cdh_ObjidToAref( oid);
	      break;
	    }
	    default:
	      sts = 0;
	  }
	  }
	  create_object_button = 0;
	}
	if ( ODD(sts) && cdh_ObjidIsNotNull( currentar.Objid)) {
	  (*Item)->Level = Level;
	  (*Item)->Item = xmenu_eMenuItem_Ref;
	  (*Item)->Flags.f.Sensitive = 1;
	  strcpy((*Item)->Name, mrp->ButtonName);
	  (*Item)->MenuObject = objid;
	  (*Item)++;
	  (*nItems)++;

	  // Create a label with current object name
	  sts = gdh_AttrrefToName( &currentar, aname, sizeof(aname), 
				   cdh_mNName);
	  if ( ODD(sts) && create_object_button) {
	    (*Item)->Level = Level;
	    (*Item)->Item = xmenu_eMenuItem_Button;
	    (*Item)->MenuObject = pwr_cNObjid;
	    strncpy((*Item)->Name, aname, sizeof((*Item)->Name));
	    (*Item)->Name[sizeof((*Item)->Name)-1] = 0;
	    (*Item)->MenuObject = pwr_cNObjid;
	    (*Item)->CurrentObject = currentar;
	    (*Item)->Flags.f.Sensitive = 1;
	    strcpy( (*Item)->Method, "$Object-OpenObject");
	    (*Item)++;
	    (*nItems)++;
	  }

	  sts = gdh_GetAttrRefTid( &currentar, &current_cid);
	  if ( EVEN(sts)) return sts;

	  xmenu_eItemType item_type = ip->ItemType;
	  if ( currentar.Flags.b.Object)
	    ip->ItemType =  xmenu_eItemType_Object;
	  else
	    ip->ItemType =  xmenu_eItemType_AttrObject;

	  sts = GetObjectMenu(ip, current_cid, Item, Level, nItems, 0, &currentar);
	  if ( EVEN(sts)) return sts;

	  ip->ItemType = item_type;
        }
      }
    }
  }
  return XNAV__SUCCESS;
}
예제 #28
0
XttFast::XttFast( void *parent_ctx,
		  char *name,
		  pwr_sAttrRef *fast_arp,
		  int *sts) :
  xnav(parent_ctx), fast_cnt(0), timerid(0), close_cb(0), help_cb(0), first_scan(1),
  axis_configured(false)
{
  pwr_sAttrRef aref = pwr_cNAttrRef;
  pwr_tAName fast_name;
  pwr_tAName attr_name;
  pwr_sClass_DsFastCurve fp;
  int i, j;
    
  *sts = XNAV__SUCCESS;

  // Get current status of the fast objects
  i = 0;
  aref = *fast_arp;
  if ( cdh_ObjidIsNull( aref.Objid)) {
    *sts = XNAV__FASTCONFIG;
    return;
  }

  *sts = gdh_AttrrefToName( &aref, fast_name, sizeof(fast_name), 
			  cdh_mNName);
  if (EVEN(*sts)) return;

  *sts = gdh_GetObjectInfo( fast_name, &fp, sizeof(fp));
  if ( EVEN(*sts)) return;

  max_points = fp.NoOfPoints;
  fast_function = fp.Function;

  strcpy( attr_name, fast_name);
  strcat( attr_name, ".TriggTime");
  gdh_NameToAttrref( pwr_cNObjid, attr_name, &trigg_time_attr);

  if ( fast_function & fast_mFunction_BeforeTrigg) {
    strcpy( attr_name, fast_name);
    strcat( attr_name, ".TriggIndex");
    gdh_NameToAttrref( pwr_cNObjid, attr_name, &trigg_index_attr);

    strcpy( attr_name, fast_name);
    strcat( attr_name, ".FirstIndex");
    gdh_NameToAttrref( pwr_cNObjid, attr_name, &first_index_attr);

    strcpy( attr_name, fast_name);
    strcat( attr_name, ".LastIndex");
    gdh_NameToAttrref( pwr_cNObjid, attr_name, &last_index_attr);
  }

  // Create data for time axis
  gcd = new GeCurveData( curve_eDataType_DsTrend);
  gcd->x_data[0] = (double *) malloc( 8 * max_points);
  strcpy( gcd->x_name, "Time");
  gcd->x_axis_type[0] = curve_eAxis_x;
  memcpy( &time_buff, &fp.TimeBuffer, sizeof(time_buff));

  fast_cnt = 0;
  for ( i = 0; i < FAST_CURVES; i++) {
    if ( fp.CurveValid[i]) {
      gcd->y_data[fast_cnt] = (double *) calloc( 1, 8 * max_points);
      gcd->y_axis_type[fast_cnt] = curve_eAxis_y;
      memcpy( &buff[fast_cnt], &fp.Buffers[i], sizeof(buff[0]));
      type[fast_cnt] = (pwr_eType) fp.AttributeType[i];
      fast_idx[i] = fast_cnt;
      curve_idx[fast_cnt] = i;

      *sts = gdh_AttrrefToName( &fp.Attribute[i], attr_name, 
			    sizeof(attr_name), cdh_mNName);
      if (EVEN(*sts)) continue;
      strcpy( gcd->y_name[fast_cnt], attr_name);
      fast_cnt++;
    }
  }

  if ( !fast_cnt) {
    *sts = XNAV__NOVALIDCURVE;
    free(gcd);
    gcd = 0;
    return;
  }

  // Subscribe to object
  strcpy( attr_name, fast_name);
  strcat( attr_name, ".New");
  *sts = gdh_RefObjectInfo( attr_name, (pwr_tAddress *)&new_p, 
			    &new_subid, sizeof(pwr_tBoolean));
  if ( EVEN(*sts)) return;

  for ( i = 0; i < fast_cnt; i++) {
    switch( type[i]) {
      case pwr_eType_Float32:
      case pwr_eType_Int32:
      case pwr_eType_UInt32:
        element_size[i] = 4;
        break;
      case pwr_eType_Float64:
      case pwr_eType_Int64:
      case pwr_eType_UInt64:
        element_size[i] = 8;
        break;
      case pwr_eType_Int16:
      case pwr_eType_UInt16:
        element_size[i] = 2;
        break;
      case pwr_eType_Int8:
      case pwr_eType_UInt8:
        element_size[i] = 1;
        break;
      default:
        element_size[i] = 4;
    }
    gcd->rows[i] = max_points;
  }
  gcd->cols = fast_cnt;

  axis_configured = true;
  for ( i = 0; i < FAST_CURVES; i++) {
    if ( fp.CurveValid[i]) {
      j = fast_idx[i];
      if ( fp.YMinValue[i] != fp.YMaxValue[i])
	gcd->scale( gcd->y_axis_type[j], gcd->y_value_type[j],
		    fp.YMinValue[i],  fp.YMaxValue[i],
		    &gcd->y_min_value_axis[j], &gcd->y_max_value_axis[j],
		    &gcd->y_trend_lines[j], &gcd->y_axis_lines[j], &gcd->y_axis_linelongq[j], 
		    &gcd->y_axis_valueq[j], gcd->y_format[j], &gcd->y_axis_width[j], 1, 1);
      else
	axis_configured = false;
    }
  }


  if ( fp.Active)
    first_scan = 0;
  fast_scan( this);
  gcd->select_color( 0);

  if ( strcmp( fp.Title, "") != 0)
    strcpy( title, fp.Title);
  else
    cdh_StrncpyCutOff( title, name, sizeof(title), 1);

  // timerid = XtAppAddTimeOut(
  //	XtWidgetToApplicationContext(parent_widget), 1000,
  //	(XtTimerCallbackProc)fast_scan, this);
}
예제 #29
0
static pwr_tStatus Connect (
  ldh_sMenuCall *ip
) {
  pwr_tStatus sts;
  pwr_sMenuButton mb;
  pwr_sAttrRef PattrRef;
  pwr_sAttrRef PattrXref;
  pwr_sAttrRef SattrRef;
  pwr_sAttrRef SattrXref;
  pwr_sAttrRef TattrRef;
  pwr_tUInt32 Pdim;
  pwr_tUInt32 Sdim;
  pwr_sAttrXRef PattrDef;
  pwr_sAttrXRef SattrDef;
  int i;

  sts = ldh_ReadObjectBody(ip->PointedSession,
    ip->ItemList[ip->ChosenItem].MenuObject,
    "SysBody", &mb, sizeof(pwr_sMenuButton));
  if (EVEN(sts)) return sts;

  sts = ldh_GetAttrRef(ip->PointedSession, ip->Pointed.Objid,
    mb.MethodArguments[0], &PattrRef);
  if (EVEN(sts)) return sts;
  sts = ldh_GetAttrRef(ip->PointedSession, ip->Selected[0].Objid,
    mb.MethodArguments[1], &SattrRef);
  if (EVEN(sts)) return sts;

  sts = ldh_GetAttrXRefDef(ip->PointedSession, &PattrRef, &PattrDef);
  if (EVEN(sts)) return sts;
  sts = ldh_GetAttrXRefDef(ip->PointedSession, &SattrRef, &SattrDef);
  if (EVEN(sts)) return sts;

  if (strncmp(PattrDef.Identity, SattrDef.Identity, sizeof(SattrDef.Identity)) != 0)
    return PWRS__IDXREF;

  if (strncmp(PattrDef.Source, SattrDef.Target, sizeof(PattrDef.Source)) != 0)
    return PWRS__STXREF;

  if (strncmp(PattrDef.Target, SattrDef.Source, sizeof(SattrDef.Source)) != 0)
    return PWRS__STXREF;

  Pdim = PattrRef.Size / sizeof(pwr_sAttrRef);
  Sdim = SattrRef.Size / sizeof(pwr_sAttrRef);

  TattrRef = PattrRef;
  TattrRef.Size = sizeof(pwr_sAttrRef);
  for (i = 0; i < (int)Pdim; i++, TattrRef.Offset += sizeof(pwr_sAttrRef)) {
    /* find Sobject */
    sts = ldh_ReadAttribute(ip->PointedSession, &TattrRef, &PattrXref,
      sizeof(pwr_sAttrRef));
    if (EVEN(sts)) return sts;
    if (!cdh_ObjidIsEqual(PattrXref.Objid, ip->Selected[0].Objid))
      continue;
    sts = ldh_ReadAttribute(ip->PointedSession, &PattrXref, &SattrXref,
      sizeof(pwr_sAttrRef));
    if (EVEN(sts)) return sts;
    if (memcmp(&SattrXref, &TattrRef, sizeof(pwr_sAttrRef)) == 0)
      return PWRS__ALRCONN;
  }

  TattrRef = PattrRef;
  TattrRef.Size = sizeof(pwr_sAttrRef);
  for (i = 0; i < (int)Pdim; i++, TattrRef.Offset += sizeof(pwr_sAttrRef)) {
    /* find free slot */
    sts = ldh_ReadAttribute(ip->PointedSession, &TattrRef, &PattrXref,
      sizeof(pwr_sAttrRef));
    if (EVEN(sts)) return sts;
    if (cdh_ObjidIsNull(PattrXref.Objid))
      break;
  }
  if (i >= (int)Pdim) {
    return PWRS__PALRCONN;
  } else {
    PattrRef = TattrRef;
  }

  TattrRef = SattrRef;
  TattrRef.Size = sizeof(pwr_sAttrRef);
  for (i = 0; i < (int)Sdim; i++, TattrRef.Offset += sizeof(pwr_sAttrRef)) {
    /* find free slot */
    sts = ldh_ReadAttribute(ip->PointedSession, &TattrRef, &SattrXref,
      sizeof(pwr_sAttrRef));
    if (EVEN(sts)) return sts;
    if (cdh_ObjidIsNull(SattrXref.Objid))
      break;
  }
  if (i >= (int)Sdim) {
    return PWRS__SALRCONN;
  } else {
    SattrRef = TattrRef;
  }

  sts = ldh_WriteAttribute(ip->PointedSession, &SattrRef, &PattrRef,
    sizeof(pwr_sAttrRef));
  sts = ldh_WriteAttribute(ip->PointedSession, &PattrRef, &SattrRef,
    sizeof(pwr_sAttrRef));
  return PWRS__SUCCESS;
}
예제 #30
0
static void
printohead(pwr_tOid oid, db_sObject *op)
{
  count_ohead++;

  sOentry     *oep;
  pwr_tStatus  sts;
    
  if (cdh_ObjidIsNull(oid))
    printf("** Error: object is null!\n");

  if (cdh_ObjidIsNotEqual(oid, op->oid))
    printf("Ohead: oid not equal %s oid: %d.%d != %d.%d\n", op->name, oid.vid, oid.oix, op->oid.vid, op->oid.oix);

//  printf("O  [%10.10d.%10.10d]   [%10.10d.%10.10d] P [%10.10d.%10.10d] %d:%s\n B [%10.10d.%10.10d] A [%10.10d.%10.10d] F [%10.10d.%10.10d] L [%10.10d.%10.10d] \n", oid.vid, oid.oix, op->oid.vid, op->oid.oix, op->poid.vid, op->poid.oix, strlen(op->name), op->name, op->boid.vid, op->boid.oix, op->aoid.vid, op->aoid.oix, op->foid.vid, op->foid.oix, op->loid.vid, op->loid.oix);
  if (cdh_ObjidIsNull(op->poid) || op->poid.oix == 0) {
    printf("P [%6.6d] B [%6.6d] O [%6.6d] A [%6.6d] F [%6.6d] L [%6.6d]\n", op->poid.oix, op->boid.oix, op->oid.oix, op->aoid.oix, op->foid.oix, op->loid.oix);
  }
  
  oep = (sOentry *)tree_Insert(&sts, oid_th, &oid);
  if (sts == TREE__INSERTED) {
    oep->flags.b.inOhead = 1;
    oep->o = *op;
  } else if (!oep->flags.b.inOhead) {
    oep->flags.b.inOhead = 1;
    oep->o = *op;
  }

  if (cdh_ObjidIsNotNull(op->poid)) {
    oep->poep = (sOentry *)tree_Insert(&sts, oid_th, &op->poid);
    if (sts == TREE__FOUND && oep->poep->flags.b.inOhead) {
      oep->flags.b.pOk = 1;
      if (oep == oep->poep->foep) {
        oep->poep->flags.b.fOk = 1;
      }
      if (oep == oep->poep->loep) {
        oep->poep->flags.b.lOk = 1;
      }
    } else {
      
    }
  } else {
    oep->flags.b.pOk = 1;
    printf("This should be the volume object: %s, [%d.%d]\n", oep->o.name, oep->o.oid.vid, oep->o.oid.oix);
  }
  
  
  if (cdh_ObjidIsNotNull(op->boid)) {
    oep->boep = (sOentry *)tree_Insert(&sts, oid_th, &op->boid);
    if (sts == TREE__FOUND && oep->boep->flags.b.inOhead) {
      oep->flags.b.bOk = 1;
      if (oep->boep->flags.b.aOk) {
        printf("Flags: %s [%d] b-object [%d] allready connected to a-object\n", oep->o.name, oep->o.oid.oix, oep->boep->o.oid.oix);
      }
      if (oep->boep->aoep != NULL && oep->boep->aoep != oep) {
        printf("aoep: %s [%d] b-object [%d] allready connected to a-object [%d]\n", oep->o.name, oep->o.oid.oix, oep->boep->o.oid.oix, oep->boep->aoep->o.oid.oix);
      } else {
        oep->boep->aoep = oep;
        oep->boep->flags.b.aOk = 1;
      }
    }
    
  } else {
    oep->flags.b.bOk = 1;
    // todo! check I am first child
  }
  
  
  if (cdh_ObjidIsNotNull(op->aoid)) {
    oep->aoep = (sOentry *)tree_Insert(&sts, oid_th, &op->aoid);
    if (sts == TREE__FOUND && oep->aoep->flags.b.inOhead) {
      oep->flags.b.aOk = 1;
      if (oep->aoep->flags.b.bOk) {
        printf("Flags: %s [%d] a-object [%d] allready connected to b-object\n", oep->o.name, oep->o.oid.oix, oep->aoep->o.oid.oix);
      }
      if (oep->aoep->boep != NULL && oep->aoep->boep != oep) {
        printf("boep: %s [%d] a-object [%d] allready connected to b-object [%d]\n", oep->o.name, oep->o.oid.oix, oep->aoep->o.oid.oix, oep->aoep->boep->o.oid.oix);
      } else {
        oep->aoep->boep = oep;
        oep->aoep->flags.b.bOk = 1;
      }
    }
  } else {
    oep->flags.b.aOk = 1;
    // todo! check I am last child
  }
  
  
  if (cdh_ObjidIsNotNull(op->foid)) {
    oep->foep = (sOentry *)tree_Insert(&sts, oid_th, &op->foid);
    if (sts == TREE__FOUND && oep->foep->flags.b.inOhead) {
      oep->flags.b.fOk = 1;
      if (oep->foep->flags.b.pOk) {
        printf("Flags: %s [%d] f-object [%d] allready connected to p-object\n", oep->o.name, oep->o.oid.oix, oep->foep->o.oid.oix);
      }
      if (oep->foep->poep != NULL && oep->foep->poep != oep) {
        printf("foep: %s [%d] f-object [%d] allready connected to p-object [%d]\n", oep->o.name, oep->o.oid.oix, oep->foep->o.oid.oix, oep->foep->poep->o.oid.oix);
      } else {
        oep->foep->poep = oep;
        oep->foep->flags.b.pOk = 1;
      }
    }
  } else {
    oep->flags.b.fOk = 1;
  }
  
  
  if (cdh_ObjidIsNotNull(op->loid)) {    
    oep->loep = (sOentry *)tree_Insert(&sts, oid_th, &op->loid);
    if (sts == TREE__FOUND && oep->loep->flags.b.inOhead) {
      oep->flags.b.lOk = 1;
      if (oep->loep->flags.b.pOk) {
        if (oep->foep == oep->loep) {
          if (cdh_ObjidIsNotEqual(oep->foep->o.oid, oep->loep->o.oid))
            printf("Object: %s [%d] has only one child %d == %d\n", oep->o.name, oep->o.oid.oix, oep->foep->o.oid.oix, oep->loep->o.oid.oix);
        } else {
          printf("Flags: %s [%d] l-object [%d] allready connected to p-object\n", oep->o.name, oep->o.oid.oix, oep->loep->o.oid.oix);
        }
      }
      if (oep->loep->poep != NULL && oep->loep->poep != oep) {
        printf("loep: %s [%d] l-object [%d] allready connected to p-object [%d]\n", oep->o.name, oep->o.oid.oix, oep->loep->o.oid.oix, oep->loep->poep->o.oid.oix);
      } else {
        oep->loep->poep = oep;
        oep->loep->flags.b.pOk = 1;
      }
    }
  } else {
    oep->flags.b.lOk = 1;
  }
}