示例#1
0
static pwr_tStatus AnteCreate(
    ldh_tSesContext Session, pwr_tObjid Father, pwr_tClassId Class)
{
  pwr_tCid cid;
  pwr_tStatus sts;
  pwr_tOid oid;

  // ClassHier should be child to a $Node object
  if (Father.oix == 0)
    return PWRS__POSSECURITY;

  sts = ldh_GetObjectClass(Session, Father, &cid);
  if (EVEN(sts))
    return sts;

  if (cid != pwr_eClass_Node)
    return PWRS__POSSECURITY;

  // There should only be one security object
  sts = ldh_GetClassList(Session, pwr_eClass_Security, &oid);
  if (ODD(sts))
    return PWRS__SECURITYALREX;

  return PWRS__SUCCESS;
}
示例#2
0
int gsx_check_subwindow( 
	vldh_t_node	object,
	unsigned long	*subwindow_nr,
	foe_eFuncAccess	*function_access
)
{
	ldh_tSesContext		ldhses;
	pwr_tObjid		next_objdid;
	pwr_tClassId		cid;
	int			found, sts;

	ldhses = (object->hn.wind)->hw.ldhses; 

	/* Order */
	if ( object->ln.cid == pwr_cClass_order)
	{
	  if ( *subwindow_nr == 2 )
	  {
	    /* Check if this order has a COrder as a child */	
	    found = 0;
	    sts = ldh_GetChild( ldhses,	object->ln.oid, &next_objdid);
	    while ( ODD(sts) )
	    {
	      /* Find out if this is a COrder */
	      sts = ldh_GetObjectClass( ldhses,	next_objdid, &cid);

	      if ( cid == pwr_cClass_corder)
	      {
	        found = 1;
	      }
	      sts = ldh_GetNextSibling( ldhses,	next_objdid, &next_objdid);
	    }
	    if ( !found )
	    {
	      /* Subwindow should be a Activity window */
	      *subwindow_nr = 1; 
	    }
	  }
	  *function_access = foe_eFuncAccess_Edit;
	}
	else if ( object->ln.cid == pwr_cClass_Func)
	  *function_access = foe_eFuncAccess_View;
	else
	  *function_access = foe_eFuncAccess_Edit;

	return GSX__SUCCESS;
}
示例#3
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;
}
示例#4
0
static pwr_tStatus Connect (
  ldh_sMenuCall *ip
) {
  pwr_tStatus	    	sts;
  pwr_sMenuButton   	mb;
  pwr_sAttrRef	    	PattrRef;
  pwr_sAttrRef 		aref = ip->Selected[0];


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

  if ( strcmp( mb.MethodArguments[1], "") != 0) {
    char arg_cid_str[20][32];
    int arg_cid_cnt;
    int i;
    int cid_ok = 0;
    pwr_tCid		cid;
    pwr_tCid		arg_cid;

    // arg 1 holds the allowed class or classes to connect to
    arg_cid_cnt = dcli_parse( mb.MethodArguments[1], ",", "", (char *) arg_cid_str, 
		sizeof( arg_cid_str) / sizeof( arg_cid_str[0]),
		sizeof( arg_cid_str[0]), 0);


    sts = ldh_GetAttrRefTid( ip->PointedSession, &ip->Selected[0], &cid);
    if ( EVEN(sts)) return 0;

    for ( i = 0; i < arg_cid_cnt; i++) {
      sts = ldh_ClassNameToId( ip->PointedSession, &arg_cid, arg_cid_str[i]);
      if ( EVEN(sts)) return 0;

      if ( cid == arg_cid) {
	cid_ok = 1;
	break;
      }
    }
    if ( !cid_ok)
      return 0;
  }

  if ( strcmp( mb.MethodArguments[2], "") != 0)
    // Body in MethodArguments 2, probably DevBody
    sts = ldh_SetObjectPar( ip->PointedSession, ip->Pointed.Objid, mb.MethodArguments[2],
		mb.MethodArguments[0], (char *) &ip->Selected[0], sizeof(ip->Selected[0]));
  else {
    char *name_p;
    pwr_tAName name;
    int size;
    pwr_tCid cid;

    // If Selected is a Template object in a classvolume, replace with 
    // symbol $IoConnect
    if ( cdh_IsClassVolume( aref.Objid.vid)) {
      sts = ldh_ObjidToName( ip->PointedSession, aref.Objid, ldh_eName_Object, 
			     name, sizeof(name), &size);
      if ( ODD(sts) &&  strcmp( name, "Template") == 0) {
	sts = ldh_GetObjectClass( ip->PointedSession, aref.Objid, &cid);
	if ( EVEN(sts)) return sts;

	aref.Objid.vid = ldh_cIoConnectVolume;
	aref.Objid.oix = cid;
      }
    }

    // Assume RtBody or SysBody
    sts = ldh_AttrRefToName(ip->PointedSession, &ip->Pointed, ldh_eName_VolPath,
			    &name_p, &size);
    if ( ODD(sts)) {
      strcpy( name, name_p);
      strcat( name, ".");
      strcat( name, mb.MethodArguments[0]);

      sts = ldh_NameToAttrRef( ip->PointedSession, name, &PattrRef);
      if (ODD(sts))
	sts = ldh_WriteAttribute(ip->PointedSession, &PattrRef, &aref,
			     sizeof(aref));
    }
  }

    
  char msg[500];
  if ( ODD(sts)) {
    pwr_tAName name;
    char *name_p;
    int len;

    sts = ldh_AttrRefToName( ip->PointedSession, &aref, ldh_eName_Hierarchy, 
			     &name_p, &len);
    if ( EVEN(sts))
      cdh_ObjidToString( name, aref.Objid, 1);
    else
      strcpy( name, name_p);
    sprintf( msg, "%s connected to:   %s", mb.MethodArguments[0], name);
    ip->wtt->message( 'I', msg);
  }
  else {
    msg_GetMsg( sts, msg, sizeof(msg));
    ip->wtt->message( 'E', msg);
  }
  return PWRS__SUCCESS;
}
示例#5
0
pwr_tStatus wsx_CheckVolume( 
	ldh_tSesContext	sesctx,
	pwr_tObjid	objid,
	int		*errorcount,
	int		*warningcount	
)
{
	pwr_tStatus sts;
	pwr_tUInt32 *opsys_ptr;
	pwr_tUInt32 opsys;
	pwr_tUInt32 opsys_sum;
	int size;
	int i;
	pwr_tClassId cid;
	pwr_tClassId	class_vect[2];
	int node_object_count;  
	
	sts = ldh_GetObjectClass ( sesctx, objid, &cid);
	if ( EVEN(sts)) return sts;

	/* Check number of $Node objects in the volume */
	class_vect[0] = pwr_cClass_Node;
	class_vect[1] = 0;
	node_object_count = 0;
	sts = trv_get_objects_hier_class_name( sesctx, pwr_cNObjid,
		class_vect, NULL,
		&wsx_object_count,
		&node_object_count, 0, 0, 0, 0);
	if (EVEN(sts)) return sts;

#if 0
	/* Dynamic size of valuebase objects !!! */
	int di_object_count;  
	int do_object_count;  
	int dv_object_count;  
	int ai_object_count;  
	int ao_object_count;  
	int av_object_count;  
	int co_object_count;  

	pwr_sClass_di_value_base *di_valuebase;
	pwr_sClass_do_value_base *do_valuebase;
	pwr_sClass_dv_value_base *dv_valuebase;
	pwr_sClass_ai_value_base *ai_valuebase;
	pwr_sClass_ao_value_base *ao_valuebase;
	pwr_sClass_av_value_base *av_valuebase;
	pwr_sClass_co_value_base *co_valuebase;


	/* Check number of signals objects in the volume */
	class_vect[0] = pwr_cClass_Di;
	class_vect[1] = 0;
	di_object_count = 0;
	sts = trv_get_objects_hier_class_name( sesctx, pwr_cNObjid,
		class_vect, NULL,
		&wsx_object_count,
		&di_object_count, 0, 0, 0, 0);
	if (EVEN(sts)) return sts;
	if ( di_object_count > 
	    sizeof( di_valuebase->DIValue) / sizeof( di_valuebase->DIValue[0]))
  	  wsx_error_msg( sesctx, WSX__DICOUNT, objid, errorcount, warningcount);

	class_vect[0] = pwr_cClass_Do;
	class_vect[1] = 0;
	do_object_count = 0;
	sts = trv_get_objects_hier_class_name( sesctx, pwr_cNObjid,
		class_vect, NULL,
		&wsx_object_count,
		&do_object_count, 0, 0, 0, 0);
	if (EVEN(sts)) return sts;
	if ( do_object_count > 
	    sizeof( do_valuebase->DOValue) / sizeof( do_valuebase->DOValue[0]))
  	  wsx_error_msg( sesctx, WSX__DOCOUNT, objid, errorcount, warningcount);

	class_vect[0] = pwr_cClass_Dv;
	class_vect[1] = 0;
	dv_object_count = 0;
	sts = trv_get_objects_hier_class_name( sesctx, pwr_cNObjid,
		class_vect, NULL,
		&wsx_object_count,
		&dv_object_count, 0, 0, 0, 0);
	if (EVEN(sts)) return sts;
	if ( dv_object_count > 
	    sizeof( dv_valuebase->DVValue) / sizeof( dv_valuebase->DVValue[0]))
  	  wsx_error_msg( sesctx, WSX__DVCOUNT, objid, errorcount, warningcount);

	class_vect[0] = pwr_cClass_Ai;
	class_vect[1] = 0;
	ai_object_count = 0;
	sts = trv_get_objects_hier_class_name( sesctx, pwr_cNObjid,
		class_vect, NULL,
		&wsx_object_count,
		&ai_object_count, 0, 0, 0, 0);
	if (EVEN(sts)) return sts;
	if ( ai_object_count > 
	    sizeof( ai_valuebase->AIValue) / sizeof( ai_valuebase->AIValue[0]))
  	  wsx_error_msg( sesctx, WSX__AICOUNT, objid, errorcount, warningcount);

	class_vect[0] = pwr_cClass_Ao;
	class_vect[1] = 0;
	ao_object_count = 0;
	sts = trv_get_objects_hier_class_name( sesctx, pwr_cNObjid,
		class_vect, NULL,
		&wsx_object_count,
		&ao_object_count, 0, 0, 0, 0);
	if (EVEN(sts)) return sts;
	if ( ao_object_count > 
	    sizeof( ao_valuebase->AOValue) / sizeof( ao_valuebase->AOValue[0]))
  	  wsx_error_msg( sesctx, WSX__AOCOUNT, objid, errorcount, warningcount);

	class_vect[0] = pwr_cClass_Av;
	class_vect[1] = 0;
	av_object_count = 0;
	sts = trv_get_objects_hier_class_name( sesctx, pwr_cNObjid,
		class_vect, NULL,
		&wsx_object_count,
		&av_object_count, 0, 0, 0, 0);
	if (EVEN(sts)) return sts;
	if ( av_object_count > 
	    sizeof( av_valuebase->AVValue) / sizeof( av_valuebase->AVValue[0]))
  	  wsx_error_msg( sesctx, WSX__AVCOUNT, objid, errorcount, warningcount);

	class_vect[0] = pwr_cClass_Co;
	class_vect[1] = 0;
	co_object_count = 0;
	sts = trv_get_objects_hier_class_name( sesctx, pwr_cNObjid,
		class_vect, NULL,
		&wsx_object_count,
		&co_object_count, 0, 0, 0, 0);
	if (EVEN(sts)) return sts;
	if ( co_object_count > 
	    sizeof( co_valuebase->COValue) / sizeof( co_valuebase->COValue[0]))
  	  wsx_error_msg( sesctx, WSX__COCOUNT, objid, errorcount, warningcount);
#endif
	switch (cid)
 	{
	  case pwr_cClass_RootVolume:
	  case pwr_cClass_SubVolume:

	    if ( cid == pwr_cClass_RootVolume)
	    {
	      if ( node_object_count != 1)
  	        wsx_error_msg( sesctx, WSX__NODECOUNT, cdh_ObjidToAref(objid), errorcount, warningcount);
	    }
	    else
	    {
	      if ( node_object_count != 0)
  	        wsx_error_msg( sesctx, WSX__NODECOUNT, cdh_ObjidToAref(objid), errorcount, warningcount);
	    }

	    /* Check OperatingSystem */
	    sts = ldh_GetObjectPar( sesctx,
  			objid,
			"SysBody",
			"OperatingSystem",
			(char **)&opsys_ptr, &size);
	    if ( EVEN(sts)) return sts;

	    opsys_sum = 0;
	    for ( i = 0;; i++)
	    {
    	      opsys = 1 << i;
	      opsys_sum |= opsys;
  	      if ( opsys >= pwr_mOpSys_)
  	        break;
	    }

  	    if ( *opsys_ptr & ~opsys_sum)
  	      wsx_error_msg( sesctx, WSX__OSINVALID, cdh_ObjidToAref(objid), errorcount, warningcount);

  	    free( (char *) opsys_ptr);
	    break;

	  default:
	    if ( node_object_count != 0)
  	      wsx_error_msg( sesctx, WSX__NODECOUNT, cdh_ObjidToAref(objid), errorcount, warningcount);
	}
	return WSX__SUCCESS;
}
示例#6
0
pwr_tStatus wsx_CheckCoCard( 
	ldh_tSesContext	sesctx,
	pwr_tAttrRef	aref,
	int		*errorcount,
	int		*warningcount	
)
{
	int		sts;
	int		size;
	char		*buf_ptr;
	pwr_tUInt16	chan_max;
	int		chan_count;
	pwr_tObjid	chan_objid;
	pwr_tClassId	cid;

	
	/* Check ErrorSoftLimit */
	sts = ldh_GetAttrObjectPar( sesctx,
			&aref, 
			"RtBody",
			"ErrorSoftLimit",
			(char **)&buf_ptr, &size);
	if (EVEN(sts)) return sts;
	if ( *(int *) buf_ptr == 0)
	  wsx_error_msg( sesctx, WSX__CARDERRSOFTLIM, aref, errorcount, warningcount);
	free((char *) buf_ptr);
	
	/* Check ErrorHardLimit */
	sts = ldh_GetAttrObjectPar( sesctx,
			&aref, 
			"RtBody",
			"ErrorHardLimit",
			(char **)&buf_ptr, &size);
	if (EVEN(sts)) return sts;
	if ( *(int *) buf_ptr == 0)
	  wsx_error_msg( sesctx, WSX__CARDERRHARDLIM, aref, errorcount, warningcount);
	free((char *) buf_ptr);

	/* Get MaxNoOfChannels */
	sts = ldh_GetAttrObjectPar( sesctx,
			&aref, 
			"RtBody",
			"MaxNoOfCounters",
			(char **)&buf_ptr, &size);
	if (EVEN(sts)) return sts;
	
	chan_max = *(pwr_tUInt16 *) buf_ptr;
	free((char *) buf_ptr);

	chan_count = 0;
	sts = ldh_GetChild( sesctx, aref.Objid, &chan_objid);
	while (ODD(sts))
	{
	  sts = ldh_GetObjectClass ( sesctx, chan_objid, &cid);
	  if ( EVEN(sts)) return sts;
	  switch ( cid)
	  {
	    case pwr_cClass_ChanCo:
	      chan_count++;
	      break;
	    default:
	      wsx_error_msg( sesctx, WSX__MISPLACED, aref, errorcount, warningcount);
	  }
	  sts = ldh_GetNextSibling( sesctx, chan_objid, &chan_objid);
	}
	if ( chan_count > chan_max)
	  wsx_error_msg( sesctx, WSX__CHANCOUNT, aref, errorcount, warningcount);
	
	return WSX__SUCCESS;
}
示例#7
0
pwr_tStatus wsx_CheckCard( 
	ldh_tSesContext	sesctx,
	pwr_tAttrRef	aref,
	int		*errorcount,
	int		*warningcount,
	wsx_mCardOption options
)
{
	int		sts;
	int		size;
	char		*buf_ptr;
	pwr_tUInt16	chan_max;
	int		chan_number_array[256];
	int		chan_count;
	pwr_tUInt16 	number;
	pwr_tObjid	chan_objid;
	pwr_tClassId	cid;

	/* Check ErrorSoftLimit */
	sts = ldh_GetAttrObjectPar( sesctx,
			&aref, 
			"RtBody",
			"ErrorSoftLimit",
			(char **)&buf_ptr, &size);
	if (EVEN(sts)) return sts;
	if ( *(int *) buf_ptr == 0)
	  wsx_error_msg( sesctx, WSX__CARDERRSOFTLIM, aref, errorcount, warningcount);
	free((char *) buf_ptr);
	
	/* Check ErrorHardLimit */
	sts = ldh_GetAttrObjectPar( sesctx,
			&aref, 
			"RtBody",
			"ErrorHardLimit",
			(char **)&buf_ptr, &size);
	if (EVEN(sts)) return sts;
	if ( *(int *) buf_ptr == 0)
	  wsx_error_msg( sesctx, WSX__CARDERRHARDLIM, aref, errorcount, warningcount);
	free((char *) buf_ptr);

	/* Get MaxNoOfChannels */
	sts = ldh_GetAttrObjectPar( sesctx,
			&aref, 
			"RtBody",
			"MaxNoOfChannels",
			(char **)&buf_ptr, &size);
	if (EVEN(sts)) return sts;
	
	chan_max = *(pwr_tUInt16 *) buf_ptr;
	free((char *) buf_ptr);

	if ( chan_max > 256)
	{
	  wsx_error_msg( sesctx, WSX__MAXCHAN, aref, errorcount, warningcount);
	  return WSX__SUCCESS;
	}
	/* Check that Number in channel-objects are unique within the card */
	memset( chan_number_array, 0, sizeof( chan_number_array));
	chan_count = 0;
	sts = ldh_GetChild( sesctx, aref.Objid, &chan_objid);
	while (ODD(sts))
	{
	  sts = ldh_GetObjectClass ( sesctx, chan_objid, &cid);
	  if ( EVEN(sts)) return sts;
	  switch ( cid)
	  {
	    case pwr_cClass_ChanDi:
	    case pwr_cClass_ChanDo:
	    case pwr_cClass_ChanAi:
	    case pwr_cClass_ChanAit:
	    case pwr_cClass_ChanAo:
	      chan_count++;
	      sts = ldh_GetObjectPar( sesctx,
			chan_objid, 
			"RtBody",
			"Number",
			(char **)&buf_ptr, &size);
	      if (EVEN(sts)) return sts;
	      number = * (pwr_tUInt16 *) buf_ptr;
	      free((char *) buf_ptr);
	      /* Check than number is within limits */
	      if ( number >= chan_max)
	      {
	        wsx_error_msg( sesctx, WSX__NUMRANGE, cdh_ObjidToAref(chan_objid), 
			       errorcount, warningcount);
	        break;
	      }
	      if ( chan_number_array[ number])
	        /* Number is occupied */
	        wsx_error_msg( sesctx, WSX__NUMNOTUNIQUE, cdh_ObjidToAref(chan_objid), 
			       errorcount, warningcount);
	      else
	        chan_number_array[ number] = 1;
	      break;
	    default:
	      wsx_error_msg( sesctx, WSX__MISPLACED, aref, errorcount, warningcount);
	  }
	  sts = ldh_GetNextSibling( sesctx, chan_objid, &chan_objid);
	}
	if ( chan_count > chan_max)
	  wsx_error_msg( sesctx, WSX__CHANCOUNT, aref, errorcount, warningcount);
	
	return WSX__SUCCESS;
}
示例#8
0
static pwr_tStatus generate_viewer_data(device_sCtx* ctx)
{
  pwr_tOid controller;
  pwr_tCid ccid;
  FILE* fp;
  FILE* ofp;
  pwr_tFileName fname;
  char line[500];
  char elemv[3][200];
  int nr;
  char device_text[200];
  char device_name[80];
  char ip_address[80];
  char mac_address[80];
  unsigned int vendor_id = 0;
  unsigned int device_id = 0;
  char* s;
  pwr_tStatus sts;
  pwr_tOid oid;
  char* ethernet_device;
  int size;

  sts = ldh_GetParent(ctx->ldhses, ctx->aref.Objid, &controller);
  if (EVEN(sts))
    return sts;

  sts = ldh_GetObjectClass(ctx->ldhses, controller, &ccid);
  if (ODD(sts) && ccid == pwr_cClass_PnControllerSoftingPNAK) {
    sts = ldh_GetObjectPar(ctx->ldhses, controller, "RtBody", "EthernetDevice",
        (char**)&ethernet_device, &size);
    if (EVEN(sts))
      return sts;

    str_trim(ethernet_device, ethernet_device);
    str_ToLower(ethernet_device, ethernet_device);
    sprintf(fname, "$pwrp_load/pwr_pnviewer_%s.dat", ethernet_device);
    free(ethernet_device);
    dcli_translate_filename(fname, fname);
    ofp = fopen(fname, "w");
    if (!ofp)
      return 0;

    for (sts = ldh_GetChild(ctx->ldhses, controller, &oid); ODD(sts);
         sts = ldh_GetNextSibling(ctx->ldhses, oid, &oid)) {
      sprintf(fname, "$pwrp_load/pwr_pn_%s.xml", cdh_ObjidToFnString(0, oid));
      dcli_translate_filename(fname, fname);

      fp = fopen(fname, "r");
      if (!fp)
        return 0;

      while (dcli_read_line(line, sizeof(line), fp)) {
        str_trim(line, line);
        nr = dcli_parse(line, "=", "", (char*)elemv,
            sizeof(elemv) / sizeof(elemv[0]), sizeof(elemv[0]), 0);
        if (nr != 2)
          continue;

        if (streq(elemv[0], "DeviceText")) {
          strncpy(device_text, elemv[1], sizeof(device_text));
        } else if (streq(elemv[0], "VendorId")) {
          sscanf(elemv[1], "%d", &vendor_id);
        } else if (streq(elemv[0], "DeviceId")) {
          sscanf(elemv[1], "%d", &device_id);
        } else if (streq(elemv[0], "DeviceName")) {
          strncpy(device_name, elemv[1], sizeof(device_name));
        } else if (streq(elemv[0], "IP_Address")) {
          strncpy(ip_address, elemv[1], sizeof(ip_address));
        } else if (streq(elemv[0], "MAC_Address")) {
          strncpy(mac_address, elemv[1], sizeof(mac_address));
          if ((s = strchr(mac_address, '/')))
            *s = 0;
          str_trim(mac_address, mac_address);
          break;
        }
      }
      fclose(fp);

      fprintf(ofp, "\"%s\" \"%s\" \"%s\" \"%s\" %d %d\n", device_text,
          device_name, ip_address, mac_address, vendor_id, device_id);
    }
    fclose(ofp);
  }
  return 1;
}
示例#9
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;
}
示例#10
0
/*************************************************************************
*
* Name:		trace_getm8()
*
* Type		int
*
* Type		Parameter	IOGF	Description
* tra_ctx	tractx		I	trace context
* tra_t_tranode	*tranode_ptr 	I	pointer to the tranode to fill up.
* int		*nb_ptr		IO	pointer to the nb of tra nodes to create.
*					irrelevant for this method
*
* Description:
* Tracemethod for a aanalyseobject which refers to a parameter to another 
* object trough the connection between the analyse node and this other object.
* Notice: This method does not create an additionnal tranode. So nb_ptr  
* is irrelevant.
**************************************************************************/
pwr_tStatus trace_get_attr_con( 	WGre		*gre, 
					vldh_t_con	con,
					const char     	*debug_par,
					char		*object_str, 
					char		*attr_str,
					flow_eTraceType	*trace_type)
{
  vldh_t_node	conn_node;
  pwr_tStatus	sts;
  pwr_tClassId	cid;
  ldh_sParDef 	*bodydef;
  int 		i ,rows;
  int		found;
  pwr_eType	par_type;
  pwr_tObjid	objdid;

  /* Get the object and parameter that is connected to the source object */
  sts = gcg_get_connected_parameter( con->hc.source_node, 
		con->lc.source_point, &conn_node,
		object_str, attr_str);
  if ( EVEN(sts)) return sts;

  /* Get the trace type */
  sts = ldh_NameToObjid( conn_node->hn.wind->hw.ldhses,
		&objdid, object_str);
  sts = ldh_GetObjectClass( conn_node->hn.wind->hw.ldhses,
		objdid, &cid);
  sts = ldh_GetObjectBodyDef( conn_node->hn.wind->hw.ldhses,
	      cid, "RtBody", 1, &bodydef, &rows);
  if( EVEN(sts) ) return sts;

  found = 0;
  for ( i = 0; i < rows; i++)
  {
    if ( strcmp(bodydef[i].ParName, attr_str) == 0) 
    {
      found = 1;
      break;
    }
  }

  if ( !found )
  {
    free((char *) bodydef);
    return  TRA__NOPAR;
  }

  par_type = bodydef[i].Par->Param.Info.Type;
  switch( par_type) {
    case pwr_eType_Boolean:
      *trace_type = flow_eTraceType_Boolean;
      break;
    case pwr_eType_Int32:
      *trace_type = flow_eTraceType_Int32;
      break;
    case pwr_eType_Float32:
      *trace_type = flow_eTraceType_Float32;
      break;
    default:
      *trace_type = flow_eTraceType_Int32;
      break;
  }

  return TRA__SUCCESS;
}
示例#11
0
int	gsx_check_connection( 
	WFoe		*foe,
	vldh_t_node	sourceobject,
	unsigned long	sourcepoint,
	vldh_t_node	destobject,
	unsigned long	destpoint,
	pwr_tClassId	*conclass,
	pwr_tClassId	user_conclass
)
{
	vldh_t_node		dummyobject;
	goen_conpoint_type	graph_pointer;
	unsigned long		par_type;
	unsigned long		par_inverted;
	unsigned long		source_par_index;
	unsigned long		dest_par_index;
	unsigned long		dummy_par_index;
	ldh_sParDef 		*bodydef;
	int			rows, sts, size;
        pwr_eType		source_type;
        pwr_eType		dest_type;
	pwr_tUInt32		source_pointer_flag;
	pwr_tUInt32		dest_pointer_flag;
	ldh_tSesContext		ldhses;
	pwr_tClassId		dest_class;
	pwr_tClassId		source_class;
	pwr_tClassId		dummyclass;
	pwr_tClassId		bodyclass;
	pwr_sGraphPlcConnection *graphbody;

	ldhses = (sourceobject->hn.wind)->hw.ldhses; 

	if ( user_conclass != 0)
	{
	  /* Get graphbody for the class */
	  sts = ldh_GetClassBody(ldhses, user_conclass, "GraphPlcCon", 
		&bodyclass, (char **)&graphbody, &size);
	  if ( EVEN(sts) ) return sts;

	  if ( !(graphbody->attributes & GOEN_CON_SIGNAL))
	  {
	    /* This is not a signal transfering connection, no syntax... */
	    return GSX__SUCCESS;
	  }
	}

	/* Check that the points datatype correspond */
 
	/* Get parameter info */
	sts = goen_get_parinfo( foe->gre, sourceobject->ln.cid, 
			ldhses,
			sourceobject->ln.mask, 
			strlen( sourceobject->hn.name),
			sourcepoint, 
			&graph_pointer,	&par_inverted, &par_type, 
			&source_par_index, sourceobject);
	if ( EVEN(sts) ) return( sts);
	sts = goen_get_parinfo( foe->gre, destobject->ln.cid, 
			(destobject->hn.wind)->hw.ldhses, 
			destobject->ln.mask, 
			strlen( destobject->hn.name),
			destpoint, 
			&graph_pointer,	&par_inverted, &par_type, 
			&dest_par_index, destobject);
	if ( EVEN(sts) ) return( sts);

	source_class = sourceobject->ln.cid;
	dest_class = destobject->ln.cid;

        /* 
	SG 08.03.91 
	Determine the type of connection to use in function of 
        the type of parameter
        */

	/* If one class is a point let the other determine the contype */
	if ( source_class == pwr_cClass_Point ||
	     source_class == pwr_cClass_Backup)
	{
	  dummyclass = dest_class;
	  dest_class = source_class;	
	  source_class = dummyclass;	
	  dummyobject = destobject;
	  destobject = sourceobject;
	  sourceobject = dummyobject;
	  dummy_par_index = dest_par_index;
	  dest_par_index = source_par_index;
	  source_par_index = dummy_par_index;
	}

	/* Grafcet, if both objects is of grafcet type, connections should
	  be GRAFCET_CONN */

	if ( (source_class == pwr_cClass_order && dest_class == pwr_cClass_trans) ||	
	     (dest_class == pwr_cClass_order && source_class == pwr_cClass_trans) )
	{
	  /* Trans and Order -> Logic connection */
	  *conclass = BOOLEAN_CONN;
	  return GSX__SUCCESS;
	}
	else if ( (
	  (source_class == pwr_cClass_order) ||	
	  (source_class == pwr_cClass_trans) ||	
	  (source_class == pwr_cClass_step) ||	
	  (source_class == pwr_cClass_initstep) ||	
	  (source_class == pwr_cClass_ssbegin) ||	
	  (source_class == pwr_cClass_ssend) ||	
	  (source_class == pwr_cClass_substep) 	
	  	) && (
	  (dest_class == pwr_cClass_order) ||	
	  (dest_class == pwr_cClass_trans) ||	
	  (dest_class == pwr_cClass_step) ||	
	  (dest_class == pwr_cClass_initstep) ||	
	  (dest_class == pwr_cClass_ssbegin) ||	
	  (dest_class == pwr_cClass_ssend) ||	
	  (dest_class == pwr_cClass_substep)  )) 
	{
	  vldh_t_conpoint	*pointlist;
	  unsigned long		point_count;
	  vldh_t_node		next_node;
	  unsigned long		next_point;
	  vldh_t_node		trans_object, other_object;
	  unsigned long		trans_point, other_point;
	  pwr_tClassId		other_class;
	  int			transcount, stepcount;
	  int			k;
	  pwr_tClassId		cid;


	  if ((dest_class == pwr_cClass_trans) ||
	      (source_class == pwr_cClass_trans))
	  {
	    if (dest_class == pwr_cClass_trans)
	    {
	      trans_object = destobject;
	      trans_point = destpoint;	     
	      other_object = sourceobject;
	      other_point = sourcepoint;
	      other_class = source_class;
	    }
	    else
	    {
	      trans_object = sourceobject;
	      trans_point = sourcepoint;	     
	      other_object = destobject;
	      other_point = destpoint;
	      other_class = dest_class;
	    }

	    if ( trans_point == 0)
	    {
	      if ((other_class == pwr_cClass_step) ||	
	          (other_class == pwr_cClass_initstep) ||	
	          (other_class == pwr_cClass_ssbegin) ||	
	          (other_class == pwr_cClass_ssend) ||	
	          (other_class == pwr_cClass_substep))
	      {
	        /* Check if there is more steps connected to the step */
	        stepcount = 0;
	        transcount = 0;
	        gcg_get_conpoint_nodes( other_object, other_point, 
			&point_count, &pointlist,
			GOEN_CON_SIGNAL | GOEN_CON_OUTPUTTOINPUT);
	        if ( point_count <= 1 )
	        {
	          /* Check if there is more steps connected to the trans */
	          gcg_get_conpoint_nodes( trans_object, trans_point, 
			&point_count, &pointlist,
			GOEN_CON_SIGNAL | GOEN_CON_OUTPUTTOINPUT);
	        }
	        if ( point_count > 1 )
	        {
	          for ( k = 1; k < (int)point_count; k++)
	          {
	            next_node = (pointlist + k)->node;
	            next_point = (pointlist + k)->conpoint;
	            /* Check class of connected nodes */
	            sts = ldh_GetObjectClass( ldhses, next_node->ln.oid, &cid);
	            if (EVEN(sts)) return sts;

	            if ( 
		      ((cid == pwr_cClass_step) &&
			( next_point == 2 )) ||
		      ((cid == pwr_cClass_initstep) && 
			( next_point == 2 )) ||
		      ((cid == pwr_cClass_substep) && 
			( next_point == 2 )) ||
		      ((cid == pwr_cClass_ssbegin) && 
			( next_point == 1 )) )
	            {
	              stepcount++;
	            }
	            else if (cid == pwr_cClass_trans )
	            {
	              transcount++;
	            }
	          }
	        }
	      }
	      if ( stepcount > 0)
	        *conclass = TRANSCONV_CONN;
	      else if ( transcount > 0)
	        *conclass = STEPDIV_CONN;
	      else
	        *conclass = GRAFCET_CONN;
	    }
	    else if ( trans_point == 2)
	    {
	      if ((other_class == pwr_cClass_step) ||	
	          (other_class == pwr_cClass_initstep) ||	
	          (other_class == pwr_cClass_ssbegin) ||	
	          (other_class == pwr_cClass_ssend) ||	
	          (other_class == pwr_cClass_substep))
	      {
	        /* Check if there is more steps connected to the trans */
	        stepcount = 0;
	        transcount = 0;
	        gcg_get_conpoint_nodes( trans_object, trans_point, 
			&point_count, &pointlist,
			GOEN_CON_SIGNAL | GOEN_CON_OUTPUTTOINPUT);
	        if ( point_count <= 1 )
	        {
	          if ( point_count > 0)
 	            free((char *) pointlist);
	          /* Check if there is more steps connected to the step */
	          gcg_get_conpoint_nodes( other_object, other_point, 
			&point_count, &pointlist,
			GOEN_CON_SIGNAL | GOEN_CON_OUTPUTTOINPUT);
	        }
	        if ( point_count > 1 )
	        {
	          for ( k = 1; k < (int)point_count; k++)
	          {
	            next_node = (pointlist + k)->node;
	            next_point = (pointlist + k)->conpoint;
	            /* Check class of connected nodes */
	            sts = ldh_GetObjectClass( ldhses, next_node->ln.oid, &cid);
	            if (EVEN(sts)) return sts;

	            if ( 
		      ((cid == pwr_cClass_step) &&
			( next_point == 0 )) ||
		      ((cid == pwr_cClass_initstep) && 
			( next_point == 0 )) ||
		      ((cid == pwr_cClass_substep) && 
			( next_point == 0 )) ||
		      ((cid == pwr_cClass_ssbegin) && 
			( next_point == 0 )) )
	            {
	              stepcount++;
	            }
	            else if (cid == pwr_cClass_trans)
	            {
	              transcount++;
	            }
	          }
	        }
	        if ( point_count > 0)
 	          free((char *) pointlist);
	      }
	      if ( stepcount > 0)
	        *conclass = TRANSDIV_CONN;
	      else if ( transcount > 0)
	        *conclass = STEPCONV_CONN;
	      else
	        *conclass = GRAFCET_CONN;
	    }
	    else 
	      *conclass = GRAFCET_CONN;

	    /* Check that all connections are of the same class */
            if ( *conclass != GRAFCET_CONN)
	    {
	      vldh_t_con 	*conlist;
	      vldh_t_con 	con;
	      unsigned long	con_count;
	      int		i;
	      vldh_t_node	src, dest;
	      unsigned long	dpoint, spoint;
	
	      sts = vldh_get_conpoint_cons( destobject, destpoint, &con_count,
			&conlist);
	      if ( EVEN(sts)) return sts;
	      if ( con_count)
	      {
	        con = *conlist;
	        for ( i = 0; i < (int)con_count; i++)
	        {
	          con = *(conlist + i);
	          if ( con->lc.cid != *conclass)
	          {
	            /* Exchange this connection */
	            src = con->hc.source_node;
	            dest = con->hc.dest_node;
	            spoint = con->lc.source_point;
	            dpoint = con->lc.dest_point;
	            goec_con_delete( foe->gre, con);
	            vldh_con_delete(con);
	            sts = foe->gre->create_con( *conclass, 
			src, spoint, dest, dpoint, foe->con_drawtype);
	          }
	        }
	        free( (char *)conlist);
	      }

	      sts = vldh_get_conpoint_cons( sourceobject, sourcepoint, 
			&con_count, &conlist);
	      if ( EVEN(sts)) return sts;
	      if ( con_count)
	      {
	        con = *conlist;
	        for ( i = 0; i < (int)con_count; i++)
	        {
	          con = *(conlist + i);
	          if ( con->lc.cid != *conclass)
	          {
	            /* Exchange this connection */
	            src = con->hc.source_node;
	            dest = con->hc.dest_node;
	            spoint = con->lc.source_point;
	            dpoint = con->lc.dest_point;
	            goec_con_delete( foe->gre, con);
	            vldh_con_delete(con);
	            sts = foe->gre->create_con( *conclass, 
			src, spoint, dest, dpoint, foe->con_drawtype);
	          }
	        }
	        free( (char *)conlist);
	      }
	    }
	  }
	  else
	    *conclass = GRAFCET_CONN;
	  return GSX__SUCCESS;
	}
	
        /* Get the type of the source attribute */
	sts = ldh_GetObjectBodyDef (
			ldhses,
			sourceobject->ln.cid, "RtBody", 1, 
			&bodydef, &rows);
	if ( EVEN(sts) )
	{
	  /* This is a development object */
	  sts = ldh_GetObjectBodyDef (
			ldhses,
			sourceobject->ln.cid, "DevBody", 1, 
			&bodydef, &rows);
	  if ( EVEN(sts) ) return sts;
	}

        /* Determine the type of connection */        
        
	switch (bodydef[source_par_index].ParClass )  {
        case pwr_eClass_Input:
          source_type = bodydef[source_par_index].Par->Input.Info.Type ;
          source_pointer_flag = PWR_MASK_POINTER & 
		bodydef[source_par_index].Par->Input.Info.Flags;
	  break;
        case pwr_eClass_Output:
          source_type = bodydef[source_par_index].Par->Output.Info.Type ;
          source_pointer_flag = PWR_MASK_POINTER & 
		bodydef[source_par_index].Par->Output.Info.Flags;
	  break;
        default: 
          printf ("gsx_check_connection ... error ParClass not tested ");
          return 0;
        };

        /* Get the type of the destination attribute */
	sts = ldh_GetObjectBodyDef (
			ldhses,
			destobject->ln.cid, "RtBody", 1, 
			&bodydef, &rows);
	if ( EVEN(sts) )
	{
	  /* This is a development object */
	  sts = ldh_GetObjectBodyDef (
			ldhses,
			destobject->ln.cid, "DevBody", 1, 
			&bodydef, &rows);
	  if ( EVEN(sts) ) return sts;
	}

        /* Determine the type of connection */        
        
	switch (bodydef[dest_par_index].ParClass )  {
        case pwr_eClass_Input:
          dest_type = bodydef[dest_par_index].Par->Input.Info.Type ;
          dest_pointer_flag = PWR_MASK_POINTER & 
		bodydef[dest_par_index].Par->Input.Info.Flags;
	  break;
        case pwr_eClass_Output:
          dest_type = bodydef[dest_par_index].Par->Output.Info.Type ;
          dest_pointer_flag = PWR_MASK_POINTER & 
		bodydef[dest_par_index].Par->Output.Info.Flags;
	  break;
        default: 
          printf ("gsx_check_connection ... error ParClass not tested ");
          return 0;
        };
        free ((char *) bodydef );

	if ( !( dest_class == pwr_cClass_Point ||	
	        dest_class == pwr_cClass_Backup))
	{
	  /* source and destination has to be of the same type */
	  if ( source_pointer_flag != dest_pointer_flag)
	    return GSX__CONTYPE;
	  else if ( source_type != dest_type)
	    return GSX__CONTYPE;
	}
	if ( source_pointer_flag)
	  *conclass = DATA_CONN;
	else
	{
	  switch ( source_type ) 
	  {
            case pwr_eType_Float32: 
	      *conclass = FLOAT_CONN;
              break;
            case pwr_eType_Boolean:
	      *conclass = BOOLEAN_CONN;
              break;
            case pwr_eType_Int32:
	      *conclass = INT32_CONN;
              break;
            default: 
	      *conclass = DEFAULT_CONN;
          }
	}
	return GSX__SUCCESS;
}
示例#12
0
//
// History log
//
static pwr_tStatus History( ldh_sMenuCall *ip) 
{
  pwr_tStatus sts;
  pwr_tOName oname;
  char item[300];
  int size;
  pwr_sMenuButton   mb;
  pwr_tCmd cmd;
  char categories[80];
  int showitem = 0;
  pwr_tCid cid;
  char *s;

  sts = ldh_ObjidToName(ip->PointedSession, ip->Pointed.Objid, 
			ldh_eName_VolPath, oname, sizeof(oname), &size); 
  if (EVEN(sts)) return sts;

  sts = ldh_GetObjectClass(ip->PointedSession, ip->Pointed.Objid, &cid);
  if (EVEN(sts)) return sts;

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

  switch ( cid) {
  case pwr_cClass_XttGraph: {
    char *action;

    // Get action attribute
    sts = ldh_GetObjectPar( ip->PointedSession, ip->Pointed.Objid, "RtBody",
			  "Action", &action, &size);
    if ( EVEN(sts)) return sts;
    strncpy( item, action, sizeof(item));
    free( action);

    if ( (s = strstr( item, ".pwg")))
      *s = 0;
    else
      return 1;

    strncpy( categories, mb.MethodArguments[0], sizeof(categories));
    showitem = 1;
    break;
  }
  case pwr_cClass_NodeConfig: {
    char *nodename;

    // Get NodeName attribute
    sts = ldh_GetObjectPar( ip->PointedSession, ip->Pointed.Objid, "RtBody",
			  "NodeName", &nodename, &size);
    if ( EVEN(sts)) return sts;
    strncpy( item, nodename, sizeof(item));
    free( nodename);

    strncpy( categories, mb.MethodArguments[0], sizeof(categories));
    showitem = 1;
    break;
  }
  case pwr_cClass_RootVolumeConfig:
  case pwr_cClass_ClassVolumeConfig:
  case pwr_cClass_SubVolumeConfig:
  case pwr_cClass_SharedVolumeConfig: {
    pwr_tObjName vname;

    // Get object name attribute
    sts = ldh_ObjidToName(ip->PointedSession, ip->Pointed.Objid, 
			  ldh_eName_Object, vname, sizeof(vname), &size);
    if ( EVEN(sts)) return sts;
    strncpy( item, vname, sizeof(item));

    strncpy( categories, mb.MethodArguments[0], sizeof(categories));
    showitem = 1;
    break;
  }
  default:
    // Item is object name
    strncpy( item, oname, sizeof(item));

    strncpy( categories, mb.MethodArguments[0], sizeof(categories));
    if (strcmp(mb.MethodArguments[1], "Descendants") == 0) {
      strncat( item, "*", sizeof(item));
      showitem = 1;
    }
  }

  snprintf( cmd, sizeof(cmd), "open history/item=\"%s\"/categories=\"%s\"", item, categories);
  if ( showitem)
    strncat( cmd, "/showitem", sizeof(cmd));

  ip->wnav->command( cmd);
  return 1;
}
示例#13
0
int Graph::generate_web(ldh_tSesContext ldhses, pwr_tOid opplaceweb_oid)
{
#if LDH
  int sts;
  int size;
  pwr_tClassId classid;
  pwr_tObjid webgraph_objid;
  pwr_tObjid weblink_objid;
  char* value_p;
  pwr_tString80 title;
  pwr_tString80 text;
  pwr_tString80 file_name;
  pwr_tString80 pwrhost;
  pwr_tBoolean enable_login;
  pwr_tBoolean enable_alarmlist;
  pwr_tBoolean enable_eventlog;
  pwr_tBoolean enable_navigator;
  pwr_tString256 load_archives;
  char style_sheet[80];
  char start_URL[80];
  char name[80];
  char graph_name[80];
  char graph_text[80];
  char link_URL[80];
  char link_text[80];
  char* s;
  std::ofstream fp_login;
  std::ofstream fp_start;
  std::ofstream fp_menu;
  std::ofstream fp_ow;
  std::ofstream fp_ows;
  char fname[120];
  char menu_file_name[80];
  char codebase[200];
  pwr_tEnum web_target;
  char target_str[80];
  char sname[80];
  char arlist[400];
  pwr_tOName opplaceweb_name;
  pwr_tOid nodeobject_oid;
  pwr_tAName nodeobject_name;

  ge_get_systemname(sname);

  // Get codebase for applets from global config file
  cnf_get_value("appletCodebase", codebase, sizeof(codebase));

  // Get OpPlaceWeb data
  sts = ldh_ObjidToName(ldhses, opplaceweb_oid, ldh_eName_Hierarchy,
      opplaceweb_name, sizeof(opplaceweb_name), &size);
  if (EVEN(sts))
    return sts;

  // Attribute FileName
  sts = ldh_GetObjectPar(
      ldhses, opplaceweb_oid, "RtBody", "FileName", &value_p, &size);
  if (EVEN(sts))
    return sts;
  if (streq(value_p, ""))
    strcpy(file_name, "index.html");
  else
    strcpy(file_name, value_p);
  free(value_p);

  // Attribute Title
  sts = ldh_GetObjectPar(
      ldhses, opplaceweb_oid, "RtBody", "Title", &value_p, &size);
  if (EVEN(sts))
    return sts;
  strcpy(title, value_p);
  free(value_p);

  // Attribute Text
  sts = ldh_GetObjectPar(
      ldhses, opplaceweb_oid, "RtBody", "Text", &value_p, &size);
  if (EVEN(sts))
    return sts;
  strcpy(text, value_p);
  free(value_p);

  // Attribute PwrHost
  sts = ldh_GetObjectPar(
      ldhses, opplaceweb_oid, "RtBody", "PwrHost", &value_p, &size);
  if (EVEN(sts))
    return sts;
  strcpy(pwrhost, value_p);
  free(value_p);
  str_trim(pwrhost, pwrhost);

  // Attribute EnableLogin
  sts = ldh_GetObjectPar(
      ldhses, opplaceweb_oid, "RtBody", "EnableLogin", &value_p, &size);
  if (EVEN(sts))
    return sts;
  enable_login = *(pwr_tBoolean*)value_p;
  free(value_p);

  // Attribute EnableAlarmList
  sts = ldh_GetObjectPar(
      ldhses, opplaceweb_oid, "RtBody", "EnableAlarmList", &value_p, &size);
  if (EVEN(sts))
    return sts;
  enable_alarmlist = *(pwr_tBoolean*)value_p;
  free(value_p);

  // Attribute EnableEventLog
  sts = ldh_GetObjectPar(
      ldhses, opplaceweb_oid, "RtBody", "EnableEventLog", &value_p, &size);
  if (EVEN(sts))
    return sts;
  enable_eventlog = *(pwr_tBoolean*)value_p;
  free(value_p);

  // Attribute EnableNavigator
  sts = ldh_GetObjectPar(
      ldhses, opplaceweb_oid, "RtBody", "EnableNavigator", &value_p, &size);
  if (EVEN(sts))
    return sts;
  enable_navigator = *(pwr_tBoolean*)value_p;
  free(value_p);

  // Attribute StyleSheet
  sts = ldh_GetObjectPar(
      ldhses, opplaceweb_oid, "RtBody", "StyleSheet", &value_p, &size);
  if (EVEN(sts))
    return sts;
  strcpy(style_sheet, value_p);
  free(value_p);

  // Attribute StartURL
  sts = ldh_GetObjectPar(
      ldhses, opplaceweb_oid, "RtBody", "StartURL", &value_p, &size);
  if (EVEN(sts))
    return sts;
  strcpy(start_URL, value_p);
  free(value_p);

  // Attribute LoadArchives
  sts = ldh_GetObjectPar(
      ldhses, opplaceweb_oid, "RtBody", "LoadArchives", &value_p, &size);
  if (EVEN(sts))
    return sts;
  strcpy(load_archives, (char*)value_p);
  free(value_p);

  strcpy(arlist, "pwr_rt_client.jar,pwr_jop.jar,pwr_jopg.jar");
  // strcat( arlist ",pwr_bcomp.jar,pwr_bcompfc.jar,pwr_abb.jar");
  str_trim(load_archives, load_archives);
  if (!streq(load_archives, "")) {
    strcat(arlist, ",");
    strcat(arlist, load_archives);
  }

  // Login applet as default start URL
  if (streq(start_URL, "") && enable_login)
    strcpy(start_URL, "pwr_login.html");

  // pwr_css as default css
  if (streq(style_sheet, ""))
    strcpy(style_sheet, "pwr_css.css");

  // Parse the name of the start page
  if ((s = strrchr(file_name, '/')) || (s = strrchr(file_name, '<'))
      || (s = strrchr(file_name, ':')))
    strcpy(name, s + 1);
  else
    strcpy(name, file_name);

  if ((s = strrchr(name, '.')))
    *s = 0;

  strcpy(menu_file_name, name);
  strcat(menu_file_name, "_menu_as.html");

  // Generate html-file for login applet
  strcpy(fname, "$pwrp_web/pwr_login.html");
  dcli_translate_filename(fname, fname);

  // If OpPlaceWeb is positioned under the node object, use $node syntax
  sts = ldh_GetClassList(ldhses, pwr_eClass_Node, &nodeobject_oid);
  if (EVEN(sts))
    return sts;

  sts = ldh_ObjidToName(ldhses, nodeobject_oid, ldh_eName_Hierarchy,
      nodeobject_name, sizeof(nodeobject_name), &size);
  if (EVEN(sts))
    return sts;

  if (str_StartsWith(opplaceweb_name, nodeobject_name)) {
    pwr_tAName tmp;
    strcpy(tmp, &opplaceweb_name[strlen(nodeobject_name)]);
    strcpy(opplaceweb_name, "$node");
    strcat(opplaceweb_name, tmp);
  }

  fp_login.open(fname);

  fp_login
      << "<!--     Generated by Ge         -->\n"
      << "<!--     Do not edit this file   -->\n"
      << "</html>\n"
      << "  <head>\n"
      << "    <title>Login</title>\n"
      << "  </head>\n"
      << "  <body>\n"
      << "\n"
      << "    <object classid=\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\""
      << '\n'
      << "      width=300 height=120  codebase=\"" << codebase << "\">\n"
      << "      <param name = code value=jpwr.jop.JopLoginApplet.class >"
      << '\n'
      << "      <param name =\"archive\" "
         "value=\"pwr_rt_client.jar,pwr_jop.jar,pwr_jopg.jar\">"
      << '\n'
      << "      <param name=\"type\" "
         "value=\"application/x-java-applet;version=1.3\">"
      << '\n'
      << "      <param name=\"scriptable\" value=\"false\">\n"
      << "  </body>\n"
      << "</html>\n";
  fp_login.close();

  // Generate html-file for start page applet style
  sprintf(fname, "$pwrp_web/%s_as.html", name);
  dcli_translate_filename(fname, fname);

  fp_start.open(fname);

  fp_start << "<! Generated by Ge >\n"
           << "<html>\n"
           << "  <head>\n"
           << "    <title>" << title << "</title>\n"
           << "  </head>\n"
           << "\n"
           << "  <frameset cols=\"20%,80%\">\n"
           << "    <frame name=\"left\" src=\"" << menu_file_name << "\">"
           << '\n';
  if (!streq(start_URL, ""))
    fp_start << "    <frame name=\"right\" src=\"" << start_URL << "\">"
             << '\n';
  else
    fp_start << "    <frame NAME=\"right\">\n";
  fp_start << "  </frameset>\n"
           << "\n"
           << "</html>\n";
  fp_start.close();

  // Generate menu file

  sprintf(fname, "$pwrp_web/%s", menu_file_name);
  dcli_translate_filename(fname, fname);

  fp_menu.open(fname);

  fp_menu << "<html>\n"
          << "  <head>\n"
          << "    <link rel=\"stylesheet\" type=\"text/css\" href=\""
          << style_sheet << "\">\n"
          << "    <title>Menu</title>\n"
          << "  </head>\n"
          << "  <body>\n"
          << "    <h1>" << title << "</h1><br>\n"
          << "    <h2>" << text << "</h2>\n"
          << "    <hr>\n"
          << "\n";

  if (enable_login) {
    fp_menu << "    <a href=\"pwr_login.html\" target=\"right\">Login</a><br>"
            << '\n';
  }

  if (enable_navigator) {
    fp_menu << "    <a "
               "href=\"javascript:open_applet('pwr_navigator.html','Navigator',"
               "1,400,600)\">Navigator</a><br>"
            << '\n';
  }

  if (enable_alarmlist) {
    fp_menu << "    <a "
               "href=\"javascript:open_applet('pwr_events.html','"
               "AlarmandEventlist',1,600,600)\">Alarm and Event list</a><br>"
            << '\n';
  }

  if (enable_login || enable_navigator) {
    fp_menu << "    <hr>\n";
  }

  // Get all WebGraph objects
  sts = ldh_GetChild(ldhses, opplaceweb_oid, &webgraph_objid);
  while (ODD(sts)) {
    sts = ldh_GetObjectClass(ldhses, webgraph_objid, &classid);
    if (EVEN(sts))
      return sts;

    if (classid == pwr_cClass_WebGraph) {
      // Attribute Name
      sts = ldh_GetObjectPar(
          ldhses, webgraph_objid, "RtBody", "Name", &value_p, &size);
      if (EVEN(sts))
        return sts;
      str_ToLower(graph_name, value_p);
      free(value_p);

      // Attribute WebTarget
      sts = ldh_GetObjectPar(
          ldhses, webgraph_objid, "RtBody", "WebTarget", &value_p, &size);
      if (EVEN(sts))
        return sts;
      web_target = *(pwr_tEnum*)value_p;
      free(value_p);

      if ((s = strrchr(graph_name, '.')))
        *s = 0;

      // Attribute Text
      sts = ldh_GetObjectPar(
          ldhses, webgraph_objid, "RtBody", "Text", &value_p, &size);
      if (EVEN(sts))
        return sts;
      strcpy(graph_text, value_p);
      free(value_p);

      switch (web_target) {
      case graph_eWebTarget_ParentWindow:
        strcpy(target_str, "_parent");
        fp_menu << "    <a href=\"" << graph_name << ".html\" target=\""
                << target_str << "\">" << graph_text << "</a><br>\n";
        break;
      case graph_eWebTarget_SeparateWindow: {
        int width, height;
        int resize = 0;

        strcpy(target_str, "_blank");
        sts = graph_get_applet_size(graph_name, &width, &height);
        if (EVEN(sts)) {
          width = height = 700;
          resize = 1;
        }

        fp_menu << "    <a href=\"javascript:open_applet('" << graph_name
                << ".html','" << graph_text << "'," << resize << ","
                << width + 20 << "," << height + 20 << ")\">" << graph_text
                << "</a><br>\n";
        break;
      }
      default:
        strcpy(target_str, "right");
        fp_menu << "    <a href=\"" << graph_name << ".html\" target=\""
                << target_str << "\">" << graph_text << "</a><br>\n";
      }
    }
    sts = ldh_GetNextSibling(ldhses, webgraph_objid, &webgraph_objid);
  }

  fp_menu << "    <hr>\n"
          << "\n";

  // Get all WebLink objects
  sts = ldh_GetChild(ldhses, opplaceweb_oid, &weblink_objid);
  while (ODD(sts)) {
    sts = ldh_GetObjectClass(ldhses, weblink_objid, &classid);
    if (EVEN(sts))
      return sts;

    if (classid == pwr_cClass_WebLink) {
      // Attribute URL
      sts = ldh_GetObjectPar(
          ldhses, weblink_objid, "RtBody", "URL", &value_p, &size);
      if (EVEN(sts))
        return sts;
      strcpy(link_URL, value_p);
      free(value_p);

      // Attribute Text
      sts = ldh_GetObjectPar(
          ldhses, weblink_objid, "RtBody", "Text", &value_p, &size);
      if (EVEN(sts))
        return sts;
      strcpy(link_text, value_p);
      free(value_p);

      // Attribute WebTarget
      sts = ldh_GetObjectPar(
          ldhses, weblink_objid, "RtBody", "WebTarget", &value_p, &size);
      if (EVEN(sts))
        return sts;
      web_target = *(pwr_tEnum*)value_p;
      free(value_p);

      switch (web_target) {
      case graph_eWebTarget_ParentWindow:
        strcpy(target_str, "_parent");
        break;
      case graph_eWebTarget_SeparateWindow:
        strcpy(target_str, "_blank");
        break;
      default:
        strcpy(target_str, "right");
      }

      fp_menu << "    <a href=\"" << link_URL << "\" target=\"" << target_str
              << "\">" << link_text << "</a><br>\n";
    }
    sts = ldh_GetNextSibling(ldhses, weblink_objid, &weblink_objid);
  }

  fp_menu << "  </body>\n"
          << "</html>\n";

  // Function for opening a window without menues and toolbar
  fp_menu << "<script language=\"JavaScript\">\n"
          << "function open_applet(url,name,resizable,width,height)\n"
          << "{\n"
          << "  var win = window.open(url, name, "
             "'resizable='+resizable+',menubar=no,scrollbars=no,location=no,"
             "toolbar=no,width='+width+',height='+height+',directories=no');"
          << '\n'
          << "}\n"
          << "</script>\n";
  fp_menu.close();

  // Generate html-file for opwindow applet

  sprintf(fname, "$pwrp_web/%s_opwin_menu.html", name);
  dcli_translate_filename(fname, fname);

  fp_ow.open(fname);

  fp_ow << "<!--     Generated by Ge         -->\n"
        << "<!--     Do not edit this file   -->\n"
        << "</html>\n"
        << "  <head>\n"
        << "    <title>" << title << "</title>\n"
        << "  </head>\n"
        << "  <body>\n"
        << "<!--[if !IE]> -->\n"
        << "    <object classid=\"java:jpwr.jop.JopOpWindowApplet.class\""
        << '\n'
        << "      type=\"application/x-java-applet\"\n"
        << "      archive=\"" << arlist << ",pwrp_" << sname << "_web.jar\""
        << '\n'
        << "      width=100% height=100% >\n"
        << "      <param name = \"code\" "
           "value=\"jpwr.jop.JopOpWindowApplet.class\" >"
        << '\n'
        << "      <param name =\"archive\" value=\"" << arlist << ",pwrp_"
        << sname << "_web.jar\">\n"
        << "      <param name=\"persistState\" value=\"false\" />\n"
        << "      <param name=\"scriptable\" value=\"false\">\n"
        << "      <param name=\"pwrplace\" value=\"" << opplaceweb_name << "\">"
        << '\n';
  if (!streq(pwrhost, ""))
    fp_ow << "      <param name=\"pwrhost\" value=\"" << pwrhost << "\">"
          << '\n';
  fp_ow << "     </object>\n"
        << "<!--<![endif]--> \n"
        << "<!--[if IE]>\n"
        << "    <object classid=\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\""
        << '\n'
        << "      width=100% height=100%  codebase=\"" << codebase << "\">"
        << '\n'
        << "      <param name = code value=jpwr.jop.JopOpWindowApplet.class >"
        << '\n'
        << "      <param name =\"archive\" value=\"" << arlist << ",pwrp_"
        << sname << "_web.jar\">\n"
        << "      <param name=\"type\" "
           "value=\"application/x-java-applet;version=1.3\">"
        << '\n'
        << "      <param name=\"scriptable\" value=\"false\">\n"
        << "      <param name=\"pwrplace\" value=\"" << opplaceweb_name << "\">"
        << '\n';
  if (!streq(pwrhost, ""))
    fp_ow << "      <param name=\"pwrhost\" value=\"" << pwrhost << "\">"
          << '\n';
  fp_ow << "     </object>\n"
        << "<![endif]-->\n"
        << "  </body>\n"
        << "</html>\n";
  fp_ow.close();

  // Generate html-file for start page for opwindow applet

  sprintf(fname, "$pwrp_web/%s.html", name);
  dcli_translate_filename(fname, fname);

  fp_ows.open(fname);

  fp_ows << "<!--     Generated by Ge         -->\n"
         << "<!--     Do not edit this file   -->\n"
         << "<html>\n"
         << "  <head>\n"
         << "    <title>" << title << "</title>\n"
         << "  </head>\n"
         << "  <frameset cols=\"242,*\">\n"
         << "    <frame name=\"left\" src=\"" << name << "_opwin_menu.html\">"
         << '\n'
         << "    <frame name=\"right\" src=\"xtt_help_index.html\">\n"
         << "  </frameset>\n"
         << "</html>\n";

  fp_ows.close();

  printf("-- Web startpage generated $pwrp_web/%s.html\n", name);
#endif
  return 1;
}