コード例 #1
0
ファイル: wb_goen.cpp プロジェクト: Strongc/proview
//
//	Returns location point of a node.
//	The location point is the point in the node that should be positioned
//	on a gridpoint in the neted window.
//	The returned koordinates are relative the lower left corner of the node.
//
int	goen_get_location_point( 
				WGre		 	*grectx,
				pwr_tClassId		cid,
				ldh_tSesContext		ldhses,
				unsigned int		*mask,
				unsigned long		node_width,
				goen_point_type		*location_point,
				vldh_t_node			node
				)
{
  int			sts, size, graphmethod;
  pwr_tClassId		bodyclass;
  pwr_sGraphPlcNode 	*graphbody;

  /* Get graphbody for the class */
  sts = ldh_GetClassBody(ldhses, cid, "GraphPlcNode", 
			 &bodyclass, (char **)&graphbody, &size);
  if ( EVEN(sts)) return sts;
  graphmethod = graphbody->graphmethod;
  if ( graphmethod >= GOEN_MAX_GRAPHMETHOD ) return GOEN__BADMETHOD;

  sts = (goen_get_location_point_m[graphbody->graphmethod]) 
    ( grectx, graphbody, mask, node_width, location_point, node);
  return sts;
}
コード例 #2
0
ファイル: wb_goen.cpp プロジェクト: Strongc/proview
//
//  Gets info of a corresponding parameter to a connectionpoint.
//
int	goen_get_parameter( 
			   pwr_tClassId		cid,
			   ldh_tSesContext		ldhses,
			   unsigned int		*mask,
			   unsigned long		con_point,
			   unsigned long		*par_type,
			   unsigned long		*par_inverted,
			   unsigned long		*par_index
			   )
{
  int			sts, size, graphmethod;
  pwr_tClassId		bodyclass;
  pwr_sGraphPlcNode 	*graphbody;

  /* Get graphbody for the class */
  sts = ldh_GetClassBody(ldhses, cid, "GraphPlcNode", 
			 &bodyclass, (char **)&graphbody, &size);
  if ( EVEN(sts)) return sts;

  graphmethod = graphbody->graphmethod;
  if ( graphmethod >= GOEN_MAX_GRAPHMETHOD ) return GOEN__BADMETHOD;

  sts = ( goen_get_parameter_m[graphmethod])
    ( graphbody, cid, ldhses, con_point, mask, 
      par_type, par_inverted, par_index);
  return sts;
}
コード例 #3
0
ファイル: wb_goen.cpp プロジェクト: Strongc/proview
//
//	Create a nodetype of the specified objecttype, mask and graphical
//	method.
//	The routine calls the graphical method for creating a nodetype
//	of this class.
//
int goen_create_nodetype( 
			 flow_tCtx	         ctx,
			 pwr_tClassId	 cid,
			 ldh_tSesContext	 ldhses,
			 unsigned int 	 *mask,
			 unsigned long	 subwindowmark,
			 unsigned long	 node_width,
			 flow_tNode           *node_class,
			 vldh_t_node		 node
			 )
{
  int			sts, size, graphmethod;
  pwr_tClassId		bodyclass;
  pwr_sGraphPlcNode 	*graphbody;

  /* Get graphbody for the class */
  sts = ldh_GetClassBody(ldhses, cid, "GraphPlcNode", 
			 &bodyclass, (char **)&graphbody, &size);
  if( EVEN(sts) ) return sts;

  graphmethod = graphbody->graphmethod;
  if ( graphmethod >= GOEN_MAX_GRAPHMETHOD ) return GOEN__BADMETHOD;

  sts = (goen_create_nodetype_m[graphmethod]) ( graphbody, cid, ldhses, ctx, 
						mask, subwindowmark, 
						node_width, node_class, node);

  return sts;
}
コード例 #4
0
int trace_get_attributes( 	WGre		*gre, 
				vldh_t_node	node, 
				char		*object_str, 
				char		*attr_str,
				flow_eTraceType	*trace_type,
				int		*inverted)
{
  int			sts, size; 
  pwr_tClassId		bodyclass;
  pwr_sGraphPlcNode 	*graphbody;

  sts = ldh_GetClassBody( node->hn.wind->hw.ldhses,
		node->ln.cid, "GraphPlcNode", 
		&bodyclass, (char **)&graphbody, &size);
  if (EVEN(sts)) return sts;

  if ( graphbody->tracemethod  >= TRA_MAX_TRACEMETHOD) 
    return TRA__BADMETHOD;

  sts = (trace_get_attr_m[graphbody->tracemethod])( gre, node, 
		graphbody->debugpar, object_str, attr_str, trace_type, inverted);
  return sts;
}
コード例 #5
0
ファイル: wb_goen.cpp プロジェクト: Strongc/proview
/*************************************************************************
 *
 * Name:		goen_create_contype()
 *
 * Type		int
 *
 * Type		Parameter	IOGF	Description
 * Widget	widget		I	neted widget.
 * unsigned long	conclass	I	connection class.
 * unsigned long	ldhses		I	ldh session.
 * goe_t_colors	*colors		I	array of loaded colors.
 * goe_t_fonts	*fonts		I	array of loaded fonts.
 * goen_t_cursors *cursors	I	array of loaded cursors.
 * unsigned long  *con_type_id	O	created neted connections type id.
 *
 * Description:
 *	Create a neted connection type.
 *	The attributes of the connection is described in grapbody in the 
 *	class object.
 *
 *	Parameters:
 *
 *    unsigned long 	con_type	index for where the connection type
 *					id is stored in the window object.
 *    int		arrows		no, one or two arrows.
 *    float		linewidth	widht of the connection line.
 *    float		dashes		length of dashes.
 *    int 		fillpattern	fillpattern for line.
 *    int		color		color.
 *    int		curvature	drawing method for the connection.
 *    float		corners		radius of corners.
 *
 *	Values:
 *
 *    arrows:
 *	GOEN_ARROW_NONE	0		No arrow
 *	GOEN_ARROW_END	1		One arrow at end of connection
 *	GOEN_ARROW_BOTH	2		Two arrows
 *    fillpattern:
 *	GOEN_UNFILL	0		No fillpattern	
 *	GOEN_FILL1	1		Some fillpattern...
 *    color:
 *	GOE_K_BLACK	0		black
 *	GOE_K_BLUE      1		blue
 *	GOE_K_RED	2		red
 *	GOE_K_GREEN     3		greem
 *    curvature:
 *	GOEN_ROUTECON	0		Routed connection
 *	GOEN_JAGGED	1		Streight line connection
 *	GOEN_RECTILINEAR 2		Rectilinear connectionstyle
 *	GOEN_STRANSDIV 	3		Simultaneus transition divergence
 *	GOEN_STRANSCONV 4		Simultaneus transition convergence
 *	GOEN_STEPDIV 	5		Step divergence
 *	GOEN_STEPCONV 	6		Step convergence
 *
 **************************************************************************/
int goen_create_contype(
			flow_tCtx	        ctx,
			pwr_tClassId	conclass,
			ldh_tSesContext	ldhses,
			flow_tConClass      *con_class
			)
{
  pwr_tClassId			bodyclass;
  pwr_sGraphPlcConnection 	*graphbody;
  int				sts, size;
  char				name[80];
  flow_eDrawType			line_type;
  flow_eConType			con_type;
  int				line_width;
  double				arrow_width = 0;
  double				arrow_length = 0;
  double				round_corner_amount;
  flow_eCorner			corner_type;

  if ( conclass == 0) {
    /* Fix for syref connections */
    flow_CreateConClass(ctx, "RefCon", 
			flow_eConType_Reference, flow_eCorner_Right,
			flow_eDrawType_Line, 2, 0, 0, 0, flow_eConGroup_Common,
			con_class);
    return 1;
  }
  /* Get graphbody for the class */
  sts = ldh_GetClassBody(ldhses, conclass, "GraphPlcCon", 
			 &bodyclass, (char **)&graphbody, &size);
  if( EVEN(sts) ) return sts;

  sts = ldh_ClassIdToName( ldhses, conclass, name, sizeof(name), &size);
  if( EVEN(sts) ) return sts;

  if (graphbody->arrows != 0) {
    con_type = flow_eConType_StraightOneArrow;
    arrow_width = 0.03;
    arrow_length = 0.045;
  }
  else if ( graphbody->curvature == GOEN_ROUTECON ||
	    graphbody->curvature == GOEN_RECTILINEAR)
    con_type = flow_eConType_Routed;
  else if ( graphbody->curvature == GOEN_STRANSDIV)
    con_type = flow_eConType_TransDiv;
  else if ( graphbody->curvature == GOEN_STRANSCONV)
    con_type = flow_eConType_TransConv;
  else if ( graphbody->curvature == GOEN_STEPDIV)
    con_type = flow_eConType_StepDiv;
  else if ( graphbody->curvature == GOEN_STEPCONV)
    con_type = flow_eConType_StepConv;
  else if ( graphbody->curvature == GOEN_JAGGED)
    con_type = flow_eConType_Straight;
  else
    con_type = flow_eConType_Straight;

  line_width = (int)(graphbody->linewidth * 400 + 0.5);
  if ( graphbody->dashes > 0)
    line_type = flow_eDrawType_LineDashed;
  else if ( graphbody->fillpattern > 0)
    line_type = flow_eDrawType_LineGray;
  else
    line_type = flow_eDrawType_Line;
	
  if ( graphbody->corners > 0.0) {
    corner_type = flow_eCorner_Rounded;
    round_corner_amount = 0.025;
  }
  else {
    corner_type = flow_eCorner_Right;
    round_corner_amount = 0;
  }

  flow_CreateConClass(ctx, name,
		      con_type, corner_type, 
		      line_type, line_width, arrow_width, arrow_length, 
		      round_corner_amount, flow_eConGroup_Common,
		      con_class);
  return GOEN__SUCCESS;
}
コード例 #6
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;
}