Exemplo n.º 1
0
int goen_create_nodetype_m7( 
    pwr_sGraphPlcNode	*graphbody,
    pwr_tClassId	cid,
    ldh_tSesContext	ldhses,
    flow_tCtx		ctx,
    unsigned int 	*mask,
    unsigned long	subwindowmark,
    unsigned long	node_width,
    flow_tNodeClass	*node_class,
    vldh_t_node		node)
{
  int		inputpoints, outputpoints;
  unsigned long	pointmask;
  unsigned int	*inmask_pointer;
  unsigned int	*outmask_pointer;
  unsigned int	*invertmask_pointer;
  int 		inputs;
  int 		interns;
  int		outputs;
  int		sts;
  char		annot_str[3][80];
  int		annot_nr[3];
  int		annot_count;
  double	annot_width[3];
  double	annot_height;
  float		f_width_left;

  flow_tNodeClass nc_pid;
  char		name[80];
  int		size;
  int		conpoint_nr;
  int		rows;
  static int	idx = 0;
  ldh_sParDef 	*bodydef;
  flow_tObject	cp;
  char		trace_attr[80];
  int		trace_type;


  sts = ldh_ClassIdToName(ldhses, cid, name, sizeof(name), &size);
  if ( EVEN(sts) ) return sts;
  sprintf( &name[strlen(name)], "%d", idx++);

  /* Get number of annotations and the width of the annotations */
  sts = WGre::get_annotations( node,
		(char *)annot_str, annot_nr, &annot_count,
		sizeof( annot_str)/sizeof(annot_str[0]), sizeof( annot_str[0]));
  if ( EVEN(sts)) return sts;

  if ( annot_count > 0)
  {
    flow_MeasureAnnotText( ctx, annot_str[0],
	     	flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
		&annot_width[0], &annot_height, &rows);
  }
  else
    annot_width[0] = 0;
  if ( annot_count > 1)
  {
    flow_MeasureAnnotText( ctx, annot_str[1],
	     	flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
		&annot_width[1], &annot_height, &rows);
  }


  /* Get the runtime paramteers for this class */
  sts = ldh_GetObjectBodyDef(ldhses, cid, "RtBody", 1, 
			&bodydef, &rows);
  if ( EVEN(sts) ) return sts;

  /* Get how many parameters there are */
  inputs = graphbody->parameters[PAR_INPUT];
  interns = graphbody->parameters[PAR_INTERN];
  outputs = graphbody->parameters[PAR_OUTPUT];

  inmask_pointer = mask++;
  outmask_pointer = mask++;
  invertmask_pointer = mask;

  /* Check if input in mask (first bit) */
  pointmask = 1;
  inputpoints = 0;
  inputpoints = ((*inmask_pointer & 1 || *inmask_pointer & 2) != 0);
  // inputpoints += ((*inmask_pointer & pointmask) != 0);

  /* Check if output in mask (first bit) */
  pointmask = 1;
  outputpoints = 0;
  outputpoints += ((*outmask_pointer & pointmask) != 0);
	
  f_classnamewidth = f_strlength * 
		(strlen( graphbody->graphname) + 2);
  f_height  = f_repeat;
  if ( annot_count <= 1)	
    f_width = co_max( f_strlength * 2 + annot_width[0], f_defwidth) 
			+ f_classnamewidth;
  else
  {
    f_width = co_max( f_strlength * 4 + annot_width[0] + annot_width[1], 
			f_defwidth + f_strlength * 2) + f_classnamewidth;
    f_width_left = f_strlength * 2 + annot_width[1];
  }

  if ( *node_class)
    nc_pid = *node_class;
  else
    flow_CreateNodeClass(ctx, name, flow_eNodeGroup_Common, 
			 &nc_pid);

  /* Draw the rectangle for gate		*/
  flow_AddRect( nc_pid, 0, -f_yoffs, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);


	/* Draw the separator */

  if ( subwindowmark == 0 )
  {
    flow_AddLine( nc_pid, f_classnamewidth, -f_yoffs, f_classnamewidth, 
		f_height - f_yoffs, flow_eDrawType_Line, 2);
  }
  else
  {
    flow_AddLine( nc_pid, f_classnamewidth, -f_yoffs, f_classnamewidth, 
		f_height - f_yoffs, flow_eDrawType_LineGray, 4);
  }

  if ( annot_count >= 2)
  {
    flow_AddLine( nc_pid, f_width - f_width_left, -f_yoffs, 
		f_width - f_width_left, f_height - f_yoffs, flow_eDrawType_Line, 2);
  }

  flow_AddText( nc_pid, graphbody->graphname, f_strlength, 
		f_height/2 + f_strheight/2 - f_yoffs, 
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);

  /* Draw the leadnames and lines */
  conpoint_nr = 0;
  if ( inputpoints != 0 )
  {
    if ( !(((*inmask_pointer & 1 ) && (*invertmask_pointer & 1)) ||
           ((*inmask_pointer & 2 ) && (*invertmask_pointer & 2))))
    {
      flow_AddLine( nc_pid, -f_pinlength, f_height/2 - f_yoffs, 
		0, f_height/2 - f_yoffs, flow_eDrawType_Line, 2);
    }	  
    else
    {
      flow_AddLine( nc_pid, -f_pinlength, f_height/2 - f_yoffs, 
		-f_circle, f_height/2 - f_yoffs,
		flow_eDrawType_Line, 2);
      flow_AddArc( nc_pid, -f_circle, 
		f_height/2 - f_circle / 2 - f_yoffs, 
		0, f_height/2 + f_circle / 2 - f_yoffs, 0, 360, 
		flow_eDrawType_Line, 2);
    }
    flow_AddConPoint( nc_pid, -f_pinlength, 
		f_height/2 - f_yoffs, 
		conpoint_nr++,
		flow_eDirection_Left);
  }

  if (outputpoints != 0)
  {
    flow_AddLine( nc_pid, f_width, f_height/2 - f_yoffs, 
		f_width+f_pinlength, f_height/2 - f_yoffs,
		flow_eDrawType_Line, 2);
    flow_CreateConPoint( ctx, f_width + f_pinlength, 
		f_height/2 - f_yoffs, 
		conpoint_nr++,
		flow_eDirection_Right, &cp);
    flow_NodeClassAdd( nc_pid, cp);

    switch ( cid) {
    case pwr_cClass_GetAattr:
    case pwr_cClass_GetIattr:
    case pwr_cClass_GetDattr:
    case pwr_cClass_GetDp:
    case pwr_cClass_GetAp:
    case pwr_cClass_GetIp:
    case pwr_cClass_GetBiInt32:
    case pwr_cClass_GetBiFloat32:
    case pwr_cClass_GetBiString80:
    case pwr_cClass_GetBoInt32:
    case pwr_cClass_GetBoFloat32:
    case pwr_cClass_GetBoString80:
      /* Use objects trace attribute */
      strcpy( trace_attr, "$object");
      break;
    default:
      strcpy( trace_attr, bodydef[inputs+interns].Par->Output.Info.PgmName);
    }
    switch (bodydef[inputs+interns].Par->Output.Info.Type) {
    case pwr_eType_Float32:
      trace_type = flow_eTraceType_Float32;
      break;
    case pwr_eType_Int32:
      trace_type = flow_eTraceType_Int32;
      break;
    case pwr_eType_Boolean:
      trace_type = flow_eTraceType_Boolean;
      break;
    default:
      trace_type = flow_eTraceType_Int32;
    }
    flow_SetTraceAttr( cp, NULL, trace_attr, (flow_eTraceType)trace_type, 0);
  }

  f_namelength = f_strlength*6;

  flow_AddAnnot( nc_pid, 
	f_classnamewidth + f_strlength,
	f_height/2 + f_strheight/2 - f_yoffs,
	0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_1);

  if ( annot_count >= 2)
  {
    flow_AddAnnot( nc_pid, 
	f_width - f_width_left + f_strlength,
	f_height/2 + f_strheight/2 - f_yoffs,
	1, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
  }

  /* Add execute order display */
  flow_AddFilledRect( nc_pid, f_width - GOEN_DISPLAYNODEWIDTH, -f_yoffs, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineGray, flow_mDisplayLevel_2);
  flow_AddAnnot( nc_pid, 
	f_width - GOEN_DISPLAYNODEWIDTH + f_strlength,
	(GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0 - f_yoffs,
	 GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_2);

  *node_class = nc_pid;
  free((char *) bodydef);
  return GOEN__SUCCESS;
}
Exemplo n.º 2
0
int goen_create_nodetype_m3( 
    pwr_sGraphPlcNode	*graphbody,
    pwr_tClassId	cid,
    ldh_tSesContext	ldhses,
    flow_tCtx		ctx,
    unsigned int 	*mask,
    unsigned long	subwindowmark,
    unsigned long	node_width,
    flow_tNodeClass	*node_class,
    vldh_t_node		node)
{
	int		sts, size;
	int		parvalue_size;
	char		*parvalue;
	double		width;
	double		height;
	unsigned long	*text_attribute_ptr;
	unsigned long	*frame_attribute_ptr;
	unsigned long	text_attribute;
	unsigned long	frame_attribute;
	float		*frame_width_ptr;
	float		frame_width;
	float		*frame_height_ptr;
	float		frame_height;
	char		name[80];
	flow_tNodeClass	nc;
	flow_eDrawType	line_type;
	flow_eDrawType	text_type;
	int		text_size;
	int		line_width;
	flow_eAnnotType	annot_type;
	int		annot_rows;
	int 		graph_index = graphbody->graphindex;
        static int	idx = 0;

	sts = ldh_ClassIdToName(ldhses, cid, name, sizeof(name), &size);
  	if ( EVEN(sts) ) return sts;
        sprintf( &name[strlen(name)], "%d", idx++);

	/* Get the text in the parameter Text */
	sts = ldh_GetObjectPar(
			(node->hn.wind)->hw.ldhses,  
			node->ln.oid, 
			"DevBody",
			"Text",
			(char **)&parvalue, &parvalue_size); 
	if ( EVEN(sts)) return sts;

	sts = ldh_GetObjectPar(
			(node->hn.wind)->hw.ldhses,  
			node->ln.oid, 
			"DevBody",
			"TextAttribute",
			(char **)&text_attribute_ptr, &size); 
	if ( ODD(sts))
	{
	  text_attribute = *text_attribute_ptr;
	  free((char *) text_attribute_ptr);
	}
	else 
	  text_attribute = 0;

	sts = ldh_GetObjectPar(
			(node->hn.wind)->hw.ldhses,  
			node->ln.oid, 
			"DevBody",
			"FrameAttribute",
			(char **)&frame_attribute_ptr, &size); 
	if ( ODD(sts))
	{
	  frame_attribute = *frame_attribute_ptr;
	  free((char *) frame_attribute_ptr);
	}
	else 
	  frame_attribute = 0;

	sts = ldh_GetObjectPar(
			(node->hn.wind)->hw.ldhses,  
			node->ln.oid, 
			"DevBody",
			"FrameWidth",
			(char **)&frame_width_ptr, &size); 
	if ( ODD(sts))
	{
	  frame_width = *frame_width_ptr;
	  free((char *) frame_width_ptr);
	}
	else 
	  frame_width = 0.0;

	sts = ldh_GetObjectPar(
			(node->hn.wind)->hw.ldhses,  
			node->ln.oid, 
			"DevBody",
			"FrameHeight",
			(char **)&frame_height_ptr, &size); 
	if ( ODD(sts))
	{
	  frame_height = *frame_height_ptr;
	  free((char *) frame_height_ptr);
	}
	else 
	  frame_height = 0.0;

	switch ( text_attribute)
	{
	  case 0:
	    text_size =  GOEN_F_TEXTSIZE;
	    text_type = flow_eDrawType_TextHelveticaBold;
	    break;
	  case 1:
	    text_size =  GOEN_F_TEXTSIZE;
	    text_type = flow_eDrawType_TextHelvetica;
	    break;
	  case 2:
	    text_size = 5;
	    text_type = flow_eDrawType_TextHelveticaBold;
	    break;
	  case 3:
	    text_size = 8;
	    text_type = flow_eDrawType_TextHelveticaBold;
	    break;
	  default:
	    text_size = GOEN_F_TEXTSIZE;
	    text_type = flow_eDrawType_TextHelveticaBold;
	    break;
	}	
	switch ( frame_attribute)
	{
	  case 0:
	    line_type = flow_eDrawType_LineGray;
	    line_width = 3;
	    break;
	  case 1:
	    line_type = flow_eDrawType_Line;
	    line_width = 2;
	    break;
	  case 2:
	    line_type = flow_eDrawType_LineErase;
	    line_width = 1;
	    break;
	  default:
	    line_type = flow_eDrawType_LineGray;
	    line_width = GOEN_F_TEXTSIZE;
	    break;
	}
	/* Make an empty text and invisible object visible */		
	if ( (*parvalue == 0) && (frame_attribute == 2))
	{
	  line_type = flow_eDrawType_LineGray;
	  line_width = 3;
	}

        if ( parvalue_size <= 80)
	  annot_type = flow_eAnnotType_OneLine;
        else
	  annot_type = flow_eAnnotType_MultiLine;

	if ( graph_index == 2)
	  annot_type = flow_eAnnotType_HelpText;

        flow_MeasureAnnotText( ctx, parvalue,
	     	text_type, text_size, annot_type,
		&width, &height, &annot_rows);
	free((char *) parvalue);	

        if ( annot_rows == 0)
	  annot_rows = 1;

	f_height = (floor( (height + f_delta*2)/ GOEN_F_GRID) + 1) * GOEN_F_GRID - f_delta*2;
	f_width = co_max( width + f_strlength *2, f_defwidth) - f_delta*2;
	if ( (height < GOEN_F_GRID-f_delta*2) && (f_height > GOEN_F_GRID))
	  f_height = GOEN_F_GRID - f_delta*2; 

	if ( frame_height > f_height)
	  f_height = frame_height;
	if ( frame_width > f_width)
	  f_width = frame_width;


	flow_CreateNodeClass( ctx, name, flow_eNodeGroup_Common, 
		&nc);

	if ( graph_index == 3) {
          flow_AddFilledTriangle( nc, f_delta, -f_yoffs, GOEN_F_GRID, 
		GOEN_F_GRID, flow_eDrawType_LineRed, flow_mDisplayLevel_1);
          flow_AddTriangle( nc, f_delta, -f_yoffs, GOEN_F_GRID, 
		GOEN_F_GRID, flow_eDrawType_Line, line_width, flow_mDisplayLevel_1);
	}

	if ( ! (frame_width == 0.0 && frame_height == 0.0))
	{
	  /* Draw a rectangle that is 'hot' only on the lines */
	  /* Draw the rectangle for the fram */
	  flow_AddLine( nc, f_delta, -f_yoffs, f_width, -f_yoffs, line_type, line_width);
	  flow_AddLine( nc, f_width, -f_yoffs, f_width, f_height - f_yoffs, line_type, line_width);
	  flow_AddLine( nc, f_width, f_height - f_yoffs, f_delta, f_height - f_yoffs, line_type, line_width);
	  flow_AddLine( nc, f_delta, f_height - f_yoffs, 0, -f_yoffs, line_type, line_width);
	}
	else
	{
	  /* Draw a rectangle that is sensitive all over... */
          flow_AddRect( nc, f_delta, -f_yoffs, f_width, 
		f_height, line_type, line_width, flow_mDisplayLevel_1);
	}

	if ( annot_type == flow_eAnnotType_HelpText)
	  flow_AddAnnot( nc, f_strlength, 0, 0, text_type, text_size, 
			 annot_type, flow_mDisplayLevel_1);
	else
	  flow_AddAnnot( nc, f_strlength, (f_height - height)/2 +
			 height/annot_rows - f_yoffs, 0, text_type, text_size, 
			 annot_type, flow_mDisplayLevel_1);
        flow_AddConPoint( nc, f_width+f_delta, f_height / 2 - f_yoffs, 0, flow_eDirection_Right);

	*node_class = nc;
	return GOEN__SUCCESS;
}
Exemplo n.º 3
0
int goen_create_nodetype_m1( 
    pwr_sGraphPlcNode	*graphbody,
    pwr_tClassId	cid,
    ldh_tSesContext	ldhses,
    flow_tCtx		ctx,
    unsigned int 	*mask,
    unsigned long	subwindowmark,
    unsigned long	node_width,
    flow_tNodeClass	*node_class,
    vldh_t_node		node)
{
  int  i;
  int	ipoints;
  int	inputpoints, outputpoints;
  unsigned long    pointmask;
  unsigned int     *inmask_pointer;
  unsigned int     *outmask_pointer;
  unsigned int     *invertmask_pointer;
  int 		i_innr;
  int 		i_internnr;
  int			i_outnr;
  int			sts;
  char		annot_str[3][80];
  int		annot_nr[3];
  int		annot_count;
  double	annot_width[3];
  double	annot_height;
  float		f_width_left;
  float		classname_width;
  flow_tNodeClass	nc_pid;
  char		name[80];
  int		size;
  int		conpoint_nr;
  int		rows;
  static int	idx = 0;
  ldh_sParDef 	*bodydef;
  flow_tObject	cp;

  sts = ldh_ClassIdToName(ldhses, cid, name, sizeof(name), &size);
  if ( EVEN(sts) ) return sts;
  sprintf( &name[strlen(name)], "%d", idx++);

  /* Get number of annotations and the width of the annotations */
  sts = WGre::get_annotations( node,
		(char *)annot_str, annot_nr, &annot_count,
		sizeof( annot_str)/sizeof(annot_str[0]), sizeof( annot_str[0]));
  if ( EVEN(sts)) return sts;

  if ( annot_count > 0)
  {
    flow_MeasureAnnotText( ctx, annot_str[0],
	     	flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
		&annot_width[0], &annot_height, &rows);
  }
  if ( annot_count > 1)
  {
    flow_MeasureAnnotText( ctx, annot_str[1],
	     	flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
		&annot_width[1], &annot_height, &rows);
  }

  /* Get the runtime paramteers for this class */
  sts = ldh_GetObjectBodyDef(ldhses, cid, "RtBody", 1, 
			&bodydef, &rows);
  if ( EVEN(sts) ) return sts;

  /* Get how many parameters there are */
  i_innr = graphbody->parameters[PAR_INPUT];
  i_internnr = graphbody->parameters[PAR_INTERN];
  i_outnr = graphbody->parameters[PAR_OUTPUT];

  inmask_pointer = mask++;
  outmask_pointer = mask++;
  invertmask_pointer = mask;
  /* Count number of inputpoints in mask  */
  pointmask = 1;
  inputpoints = 0;
  for ( i = 0; i < i_innr; i++)  
  {
    inputpoints += ((*inmask_pointer & pointmask) != 0);
    pointmask <<= 1;
  }
  /* Count number of outputpoints in mask  */
  pointmask = 1;
  outputpoints = 0;
  for ( i = 0; i < i_outnr; i++)  
  {
    outputpoints += ((*outmask_pointer & pointmask) != 0);
    pointmask <<= 1;
  }
	
  f_height  = f_header/2 + f_header/2 +
	       co_max((co_max(inputpoints,outputpoints)-1), 1) * f_repeat;

  classname_width = strlen( graphbody->graphname) * f_strlength;
  if ( annot_count <= 1)
  {
    f_width = co_max( f_strlength * 2 + co_max( classname_width, annot_width[0]),
			f_defwidth + f_strlength * 2);
    f_width_left = 0;
  }
  else
  {
    f_width = co_max( f_strlength * 4 + co_max( classname_width, annot_width[0])
			 + annot_width[1], f_defwidth + f_strlength * 2);
    f_width_left = f_strlength * 2 + annot_width[1];
  }

  f_namepos = f_width/2.0 - classname_width/2 - f_width_left/2;

  flow_CreateNodeClass(ctx, name, flow_eNodeGroup_Common, 
		&nc_pid);

  /* Draw the rectangle for gate		*/
  flow_AddRect( nc_pid, 0, -f_yoffs, f_width, f_height, flow_eDrawType_Line, 2, flow_mDisplayLevel_1);

  /* Draw the separator line for header and footer			      */

  if ( subwindowmark != 0 )
  {
    flow_AddLine( nc_pid, 0, f_header - f_yoffs, f_width, 
		f_header - f_yoffs, flow_eDrawType_LineGray, 4);
  }

  if ( annot_count >= 2)
  {
    flow_AddLine( nc_pid, f_width - f_width_left, -f_yoffs, f_width - f_width_left,
		f_height - f_yoffs, flow_eDrawType_Line, 1);
  }


  /* Draw the class name */
  flow_AddText( nc_pid, graphbody->graphname, f_namepos,
		f_header * .75 - f_yoffs,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);

  /* Draw the leadnames and lines					      */

  conpoint_nr = 0;
  pointmask = 1;
  ipoints = 0;
  for (i = 0; i <i_innr ;i++) 
  {
    if ( (*inmask_pointer & pointmask) != 0)
    {
      if ( (*invertmask_pointer & pointmask) == 0)
      {
        flow_AddLine( nc_pid, 0, f_header/2 + f_repeat * ipoints - f_yoffs, 
		-f_pinlength, f_header/2 + f_repeat * ipoints - f_yoffs,
		flow_eDrawType_Line, 2);
      }
      else
      {
        flow_AddLine( nc_pid, -f_pinlength, f_header/2 + f_repeat * ipoints - f_yoffs, 
		-f_circle, f_header/2 + f_repeat * ipoints - f_yoffs,
		flow_eDrawType_Line, 2);
        flow_AddArc( nc_pid, -f_circle, 
		f_header/2 + f_repeat * ipoints - f_circle / 2 - f_yoffs, 
		0, f_header/2 + f_repeat * ipoints + f_circle / 2 - f_yoffs, 
		0, 360, flow_eDrawType_Line, 2);
      }
      flow_AddConPoint( nc_pid, -f_pinlength, 
		f_header/2 + f_repeat * ipoints - f_yoffs, 
		conpoint_nr++,
		flow_eDirection_Left);
      ipoints++;
    }
    pointmask <<= 1;
  }
  pointmask = 1;
  ipoints = 0;
  for (i = i_innr + i_internnr; i < i_innr + i_internnr + i_outnr ; i++)
  {
    if ( (*outmask_pointer & pointmask) != 0)
    {
      flow_AddLine( nc_pid, f_width, f_header/2 + f_repeat * ipoints - f_yoffs, 
		f_width+f_pinlength, f_header/2 + f_repeat * ipoints - f_yoffs,
		flow_eDrawType_Line, 2);
      flow_CreateConPoint( ctx, f_width + f_pinlength, 
		f_header/2 + f_repeat * ipoints - f_yoffs, 
		conpoint_nr++,
		flow_eDirection_Right, &cp);
      flow_NodeClassAdd( nc_pid, cp);
      if (bodydef[i].Par->Output.Info.Type == pwr_eType_Float32)
        flow_SetTraceAttr( cp, NULL, bodydef[i].ParName, 
		flow_eTraceType_Float32, 0);
      else if (bodydef[i].Par->Output.Info.Type == pwr_eType_Int32)
        flow_SetTraceAttr( cp, NULL, bodydef[i].ParName, 
		flow_eTraceType_Int32, 0);
      else if (bodydef[i].Par->Output.Info.Type == pwr_eType_Boolean)
        flow_SetTraceAttr( cp, NULL, bodydef[i].ParName, 
		flow_eTraceType_Boolean, 0);
      ipoints++;
    }
    pointmask <<= 1;
  }

  flow_AddAnnot( nc_pid, 
	(f_width - f_width_left - annot_width[0])/2,
	f_height - f_header * 0.25 - f_yoffs,
	0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_1);

  if ( annot_count >= 2)
  {
    flow_AddAnnot( nc_pid, 
	f_width - f_width_left + f_strlength,
	f_height - f_header * 0.75 - f_yoffs,
	1, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
  }

  /* Add execute order display */
  flow_AddFilledRect( nc_pid, f_width - GOEN_DISPLAYNODEWIDTH, -f_yoffs, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineGray, flow_mDisplayLevel_2);
  flow_AddAnnot( nc_pid, 
	f_width - GOEN_DISPLAYNODEWIDTH + f_strlength,
	(GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0 - f_yoffs,
	 GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_2);

  *node_class = nc_pid;

  free( (char *)bodydef);
  return GOEN__SUCCESS;
}
Exemplo n.º 4
0
int goen_create_nodetype_m5( 
    pwr_sGraphPlcNode	*graphbody,
    pwr_tClassId	cid,
    ldh_tSesContext	ldhses,
    flow_tCtx		ctx,
    unsigned int 	*mask,
    unsigned long	subwindowmark,
    unsigned long	node_width,
    flow_tNodeClass	*node_class,
    vldh_t_node		node)
{
	int		inputpoints, outputpoints;
	unsigned long    pointmask;
	unsigned int     *inmask_pointer;
	unsigned int     *outmask_pointer;
	int 		inputs;
	int 		interns;
	int		ouputs;
	int		sts;
	char		annot_str[3][80];
	int		annot_nr[3];
	int		annot_count;
	double		annot_width[3];
	double		annot_height;
	float		f_ordertypewidth   = 0.04;
	float		f_backcheckwidth   = 0.01;
  	flow_tNodeClass	nc;
  	char		name[80];
  	int		size;
  	int		conpoint_num;
	int		rows;
	static int	idx = 0;


  	sts = ldh_ClassIdToName(ldhses, cid, name, sizeof(name), &size);
  	if ( EVEN(sts) ) return sts;
	sprintf( &name[strlen(name)], "%d", idx++);


	/* Get number of annotations and the width of the annotations */
	sts = WGre::get_annotations( node,
		(char *)annot_str, annot_nr, &annot_count,
		sizeof( annot_str)/sizeof(annot_str[0]), sizeof( annot_str[0]));
	if ( EVEN(sts)) return sts;

	if ( annot_count > 0)
  	{
    	  flow_MeasureAnnotText( ctx, annot_str[0],
	     	flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
		&annot_width[0], &annot_height, &rows);
  	}
	if ( annot_count > 1)
  	{
    	  flow_MeasureAnnotText( ctx, annot_str[1],
	     	flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
		&annot_width[1], &annot_height, &rows);
  	}
	if ( annot_count > 2)
  	{
    	  flow_MeasureAnnotText( ctx, annot_str[2],
	     	flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
		&annot_width[2], &annot_height, &rows);
  	}
	
	/* Get how many parameters there are */
	inputs = graphbody->parameters[PAR_INPUT];
	interns = graphbody->parameters[PAR_INTERN];
	ouputs = graphbody->parameters[PAR_OUTPUT];

	inmask_pointer = mask++;
	outmask_pointer = mask;

	/* Check if condition input in mask (second bit) */
	pointmask = 2;
	inputpoints = 1;
	inputpoints += ((*inmask_pointer & pointmask) != 0);

	/* Check if output in mask (first bit) */
	pointmask = 1;
	outputpoints = 0;
	outputpoints += ((*outmask_pointer & pointmask) != 0);

	f_height  = f_repeat;
	f_ordertypewidth =
	        co_max( f_ordertypewidth, annot_width[1] + f_strlength);
	f_backcheckwidth =
		co_max( f_backcheckwidth, annot_width[2] + 2 * f_strlength);
	f_width = f_ordertypewidth +
		  co_max( f_defwidth, annot_width[0] + 2 * f_strlength) +
		  f_backcheckwidth;

	flow_CreateNodeClass(ctx, name, flow_eNodeGroup_Common, 
		&nc);

	/* Draw the rectangle for gate	*/
	flow_AddRect( nc, 0, -f_yoffs, f_width, f_height, flow_eDrawType_Line, 2, flow_mDisplayLevel_1);

	if ( (subwindowmark & 2) == 0 )
	{
          flow_AddLine(nc, f_ordertypewidth, -f_yoffs, 
		f_ordertypewidth, f_height - f_yoffs, flow_eDrawType_Line, 1);
	}
	else
	{
          flow_AddLine(nc, f_ordertypewidth, -f_yoffs, 
		f_ordertypewidth, f_height - f_yoffs, flow_eDrawType_LineGray, 5);
	}
	if ( (subwindowmark & 1) == 0 )
	{
          flow_AddLine( nc, f_width - f_backcheckwidth,  -f_yoffs, 
		f_width - f_backcheckwidth, f_height - f_yoffs, flow_eDrawType_Line, 1);
	}
	else
	{
          flow_AddLine( nc, f_width - f_backcheckwidth,  -f_yoffs, 
		f_width - f_backcheckwidth, f_height - f_yoffs, flow_eDrawType_LineGray, 5);
	}



	conpoint_num = 0;
        flow_AddLine( nc, -f_pinlength, f_height / 2 - f_yoffs, 
		0, f_height / 2 - f_yoffs, flow_eDrawType_Line, 2);
        flow_AddConPoint(nc, -f_pinlength, f_height /2 - f_yoffs, 
		conpoint_num++, flow_eDirection_Left);

	if ( inputpoints == 2 )
	{
	  /* Draw condition pin */
          flow_AddLine( nc, f_repeat, - f_pinlength - f_yoffs, 
		f_repeat,  -f_yoffs, flow_eDrawType_Line, 2);
          flow_AddConPoint(nc, f_repeat, - f_pinlength - f_yoffs, 
		conpoint_num++, flow_eDirection_Down);
	}	

	if (outputpoints != 0)
	{
          flow_AddLine( nc, f_width, f_height / 2 - f_yoffs, 
		f_width + f_pinlength, f_height /2 - f_yoffs, flow_eDrawType_Line, 2);
          flow_AddConPoint( nc, f_width + f_pinlength, f_height /2 - f_yoffs, 
		conpoint_num++, flow_eDirection_Right);
	}

	f_node_width = node_width;
        flow_AddAnnot( nc, 
		f_ordertypewidth + f_strlength,
		f_height - f_strheight / 2 - f_yoffs,
		0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
		flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
        flow_AddAnnot( nc, 
		f_strlength / 2,
		f_height - f_strheight / 2 - f_yoffs,
		1, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
		flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
        flow_AddAnnot( nc, 
		f_width - f_backcheckwidth + f_strlength,
		f_height - f_strheight / 2 - f_yoffs,
		2, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
		flow_eAnnotType_OneLine, flow_mDisplayLevel_1);

  	/* Add execute order display */
  	flow_AddFilledRect( nc, f_width - GOEN_DISPLAYNODEWIDTH, -f_yoffs, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineErase, flow_mDisplayLevel_2);
  	flow_AddRect( nc, f_width - GOEN_DISPLAYNODEWIDTH, -f_yoffs, 
		      GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		      flow_eDrawType_LineRed, 1, flow_mDisplayLevel_2);
  	flow_AddAnnot( nc, 
	  f_width - GOEN_DISPLAYNODEWIDTH + f_strlength,
	  (GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0 - f_yoffs,
	  GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	  flow_eAnnotType_OneLine, flow_mDisplayLevel_2);

	*node_class = nc;
	return GOEN__SUCCESS;
}
Exemplo n.º 5
0
int goen_create_nodetype_m15( 
    pwr_sGraphPlcNode	*graphbody,
    pwr_tClassId	cid,
    ldh_tSesContext	ldhses,
    flow_tCtx		ctx,
    unsigned int 	*mask,
    unsigned long	subwindowmark,
    unsigned long	node_width,
    flow_tNodeClass	*node_class,
    vldh_t_node		node)
{
  int  		i;
  int		inputpoints, outputpoints;
  unsigned long   pointmask;
  unsigned int   *inmask_pointer;
  unsigned int   *outmask_pointer;
  unsigned int   *invertmask_pointer;
  int 		inputs;
  int 		interns;
  int		outputs;
  int		sts, size;
  int		first_input, second_input;
  ldh_sParDef 	*bodydef;
  int 		rows;
  int		inputcount;
  char		annot_str[3][80];
  int		annot_nr[3];
  int		annot_count;
  double	annot_width[3];
  double	annot_height;
  float		f_width_left;
  float		annot2_width;
  float		annot3_width;
  char		annot3_found;
  flow_tNodeClass nc_pid;
  char		name[80];
  int		conpoint_nr;
  int		annot_rows;
  static int	idx = 0;
  flow_tObject	cp;

  sts = ldh_ClassIdToName(ldhses, cid, name, sizeof(name), &size);
  if ( EVEN(sts) ) return sts;
  sprintf( &name[strlen(name)], "%d", idx++);

  /* Get the runtime paramteers for this class */
  sts = ldh_GetObjectBodyDef(ldhses, cid, "RtBody", 1, 
			&bodydef, &rows);
  if ( EVEN(sts) ) return sts;

  /* Get number of annotations and the width of the annotations */
  sts = WGre::get_annotations( node,
		(char *)annot_str, annot_nr, &annot_count,
		sizeof( annot_str)/sizeof(annot_str[0]), sizeof( annot_str[0]));
  if ( EVEN(sts)) return sts;

  if ( annot_count > 0)
  {
    flow_MeasureAnnotText( ctx, annot_str[0],
	     	flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
		&annot_width[0], &annot_height, &annot_rows);
  }
  if ( annot_count > 1)
  {
    flow_MeasureAnnotText( ctx, annot_str[1],
	     	flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
		&annot_width[1], &annot_height, &annot_rows);
  }
  if ( annot_count > 2)
  {
    flow_MeasureAnnotText( ctx, annot_str[2],
	     	flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
		&annot_width[2], &annot_height, &annot_rows);
  }

  /* Find the widths for annotation 2 and 3 */
  annot3_found = 0;
  annot2_width = 0;
  for ( i = 1; i < annot_count; i++)
  {
    if ( annot_nr[i] == 2)
      annot2_width = annot_width[i];
    if ( annot_nr[i] == 3)
    {
      annot3_width = annot_width[i];
      annot3_found = 1;
    }
  }

  /* Get how many parameters there are */
  inputs = graphbody->parameters[PAR_INPUT];
  interns = graphbody->parameters[PAR_INTERN];
  outputs = graphbody->parameters[PAR_OUTPUT];

  inmask_pointer = mask++;
  outmask_pointer = mask++;
  invertmask_pointer = mask;

  /* Check if first input in mask (first bit) */
  pointmask = 1;
  first_input =  ((*inmask_pointer & pointmask) != 0);
  pointmask = 2;
  second_input = ((*inmask_pointer & pointmask) != 0);
  inputpoints = first_input + second_input;

  /* Check if output in mask (first bit) */
  pointmask = 1;
  outputpoints = 0;
  outputpoints += ((*outmask_pointer & pointmask) != 0);
	
  f_classnamewidth = f_strlength * 
		(strlen( graphbody->graphname) + 2);
  f_height  = f_repeat * 2;

  if ( !annot3_found)	
    f_width = co_max( f_strlength * 2 + co_max( annot_width[0], annot2_width),
			 f_defwidth) 
			+ f_classnamewidth;
  else
  {
    f_width = co_max( f_strlength * 4 + co_max( annot_width[0], annot2_width) 
		+ annot3_width, 
		f_defwidth + f_strlength * 2) + f_classnamewidth;
    f_width_left = f_strlength * 2 + annot3_width;
  }

  flow_CreateNodeClass(ctx, name, flow_eNodeGroup_Common, 
		&nc_pid);

  /* Draw the rectangle for gate		*/
  flow_AddRect( nc_pid, 0, -f_yoffs, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);

  if ( subwindowmark == 0 )
  {
    flow_AddLine( nc_pid, f_classnamewidth, -f_yoffs, f_classnamewidth, 
		f_height - f_yoffs, flow_eDrawType_Line, 2);
  }
  else
  {
    flow_AddLine( nc_pid, f_classnamewidth, -f_yoffs, f_classnamewidth, 
		f_height - f_yoffs, flow_eDrawType_LineGray, 4);
  }
  if ( annot3_found)
  {
    /* Draw line for second annotation */
    flow_AddLine( nc_pid, f_width - f_width_left, -f_yoffs, 
		f_width - f_width_left, f_height - f_yoffs, flow_eDrawType_Line, 2);
  }

  flow_AddText( nc_pid, graphbody->graphname, f_strlength, 
		f_height/4 + f_strheight/2 - f_yoffs,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);

  /* Draw the leadnames and lines */
  conpoint_nr = 0;
  if ( first_input )
  {
    if ( (*invertmask_pointer & 1) == 0)
    {
      flow_AddLine( nc_pid, -f_pinlength, f_height/4 - f_yoffs, 
		0, f_height/4 - f_yoffs, flow_eDrawType_Line, 2);
    }	  
    else
    {
      flow_AddLine( nc_pid, -f_pinlength, f_height/4 - f_yoffs, 
		-f_circle, f_height/4 - f_yoffs, flow_eDrawType_Line, 2);
      flow_AddArc( nc_pid, -f_circle, 
		f_height/4 - f_circle / 2 - f_yoffs, 
		0, f_height/4 + f_circle / 2 - f_yoffs, 0, 360, 
		flow_eDrawType_Line, 2);
    }
    flow_AddConPoint( nc_pid, -f_pinlength, 
		f_height/4 - f_yoffs, 
		conpoint_nr++,
		flow_eDirection_Left);
  }

  if ( second_input )
  {
    /* Get the graphname of second input parameter */
    inputcount = 0;
    for ( i = 0; i < rows; i++)
    {
      if ( bodydef[i].ParClass == pwr_eClass_Input) 
      {
        inputcount++;
        if (inputcount == 2)
          /* This is the second input */
          break;
      }
    }

    flow_AddText( nc_pid, bodydef[i].Par->Input.Graph.GraphName, 
		f_strlength, f_height*3/4 + f_strheight/2 - f_yoffs, 
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);

    if ( (*invertmask_pointer & 2) == 0)
    {
      flow_AddLine( nc_pid, -f_pinlength, f_height*3/4 - f_yoffs, 
		0, f_height*3/4 - f_yoffs, flow_eDrawType_Line, 2);
    }	  
    else
    {
      flow_AddLine( nc_pid, -f_pinlength, f_height*3/4 - f_yoffs, 
		-f_circle, f_height*3/4 - f_yoffs,
		flow_eDrawType_Line, 2);
      flow_AddArc( nc_pid, -f_circle, 
		f_height*3/4 - f_circle / 2 - f_yoffs, 
		0, f_height*3/4 + f_circle / 2 - f_yoffs, 0, 360, 
		flow_eDrawType_Line, 2);
    }
    flow_AddConPoint( nc_pid, -f_pinlength, 
		f_height*3/4 - f_yoffs, 
		conpoint_nr++,
		flow_eDirection_Left);
  }

  if (outputpoints != 0)
  {
    flow_AddLine( nc_pid, f_width, f_height/4 - f_yoffs, 
		f_width+f_pinlength, f_height/4 - f_yoffs,
		flow_eDrawType_Line, 2);
    flow_CreateConPoint( ctx, f_width + f_pinlength, 
		f_height/4 - f_yoffs, 
		conpoint_nr++,
		flow_eDirection_Right, &cp);
    flow_NodeClassAdd( nc_pid, cp);
    if (bodydef[inputs+interns].Par->Output.Info.Type == pwr_eType_Float32)
      flow_SetTraceAttr( cp, NULL,
		bodydef[inputs+interns].Par->Output.Info.PgmName, 
		flow_eTraceType_Float32, 0);
    else if (bodydef[inputs+interns].Par->Output.Info.Type == pwr_eType_Int32)
      flow_SetTraceAttr( cp, NULL,
		bodydef[inputs+interns].Par->Output.Info.PgmName, 
		flow_eTraceType_Int32, 0);
    else if (bodydef[inputs+interns].Par->Output.Info.Type == pwr_eType_Boolean)
      flow_SetTraceAttr( cp, NULL, 
		bodydef[inputs+interns].Par->Output.Info.PgmName, 
		flow_eTraceType_Boolean, 0);
  }

  f_namelength = f_strlength*6;
  f_node_width = node_width;
  flow_AddAnnot( nc_pid, 
	f_classnamewidth + f_strlength,
	f_height/4 + f_strheight/2 - f_yoffs,
	0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
  flow_AddAnnot( nc_pid, 
	f_classnamewidth + f_strlength,
	f_height/4 + f_strheight/2 + GOEN_F_GRID - f_yoffs,
	1, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_1);

  if ( annot3_found )
  {
    flow_AddAnnot( nc_pid, 
	f_width - f_width_left + f_strlength,
	GOEN_F_GRID/2 + f_strheight/2 - f_yoffs,
	2, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
  }

  /* Add execute order display */
  flow_AddFilledRect( nc_pid, f_width - GOEN_DISPLAYNODEWIDTH, -f_yoffs, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineGray, flow_mDisplayLevel_2);
  flow_AddAnnot( nc_pid, 
	f_width - GOEN_DISPLAYNODEWIDTH + f_strlength,
	(GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0 - f_yoffs,
	 GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_2);

  free((char *) bodydef);
  *node_class = nc_pid;
  return GOEN__SUCCESS;
}
Exemplo n.º 6
0
int goen_create_nodetype_m4( 
    pwr_sGraphPlcNode	*graphbody,
    pwr_tClassId	cid,
    ldh_tSesContext	ldhses,
    flow_tCtx		ctx,
    unsigned int 	*mask,
    unsigned long	subwindowmark,
    unsigned long	node_width,
    flow_tNodeClass	*node_class,
    vldh_t_node		node)
{
  int		graph_index;
  int		annot_count;
  int		sts;
  char		annot_str[3][80];
  int		annot_nr[3];
  float		f_width, f_height;
  char		name[80];
  int		size;
  flow_tNodeClass	nc;
  static int	idx = 0;
	
  sts = ldh_ClassIdToName(ldhses, cid, name, sizeof(name), &size);
  if ( EVEN(sts) ) return sts;
  sprintf( &name[strlen(name)], "%d", idx++);

  /* Get graph index for this class */
  graph_index = graphbody->graphindex;	

  /* Get number of annotations and the width of the annotations */
  sts = WGre::get_annotations( node,
		(char *)annot_str, annot_nr, &annot_count,
		sizeof( annot_str)/sizeof(annot_str[0]), sizeof( annot_str[0]));
  if ( EVEN(sts)) return sts;

  flow_CreateNodeClass( ctx, name, flow_eNodeGroup_Common, &nc);

  switch ( graph_index)
  {
    case goen_eGraphIndex_Step:
    {
      f_width = GOEN_F_GRID * 2.5;
      f_height = GOEN_F_GRID * 2.5;

      flow_AddRect( nc, -f_width/2, -f_height/2, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);
      flow_AddLine( nc, 0, -f_height/2 - f_pinlength, 
		0, -f_height/2, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, 0, -f_height/2 - f_pinlength, 
		0, flow_eDirection_Down);
      flow_AddLine( nc, f_width/2, 0, 
		f_width/2 + f_pinlength, 0, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, f_width/2 + f_pinlength, 0, 
		1, flow_eDirection_Right);
      flow_AddLine( nc, 0, f_height/2, 
		0, f_height/2 + f_pinlength, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, 0, f_height/2 + f_pinlength, 
		2, flow_eDirection_Up);
      flow_AddAnnot( nc, -f_width/2 + f_strlength, 0,
		0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
		flow_eAnnotType_OneLine, flow_mDisplayLevel_1);

      /* Add execute order display */
      flow_AddFilledRect( nc, f_width/2 - GOEN_DISPLAYNODEWIDTH, -f_height/2, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineGray, flow_mDisplayLevel_2);
      flow_AddAnnot( nc, 
	f_width/2 - GOEN_DISPLAYNODEWIDTH + f_strlength,
	(GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0 - f_height/2,
	 GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_2);
      break;
    }
    case goen_eGraphIndex_InitStep:
    {
      float f_delta = GOEN_F_GRID / 4;

      f_width = GOEN_F_GRID * 2.5;
      f_height = GOEN_F_GRID * 2.5;
      flow_AddRect( nc, -f_width/2, -f_height/2, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);
      flow_AddRect( nc, -f_width/2 + f_delta, -f_height/2 + f_delta, 
		f_width - 2 * f_delta, f_height - 2 * f_delta, 
		flow_eDrawType_Line, 1, flow_mDisplayLevel_1);
      flow_AddLine( nc, 0, -f_height/2 - f_pinlength, 
		0, -f_height/2, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, 0, -f_height/2 - f_pinlength, 
		0, flow_eDirection_Down);
      flow_AddLine( nc, f_width/2, 0, 
		f_width/2 + f_pinlength, 0, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, f_width/2 + f_pinlength, 0, 
		1, flow_eDirection_Right);
      flow_AddLine( nc, 0, f_height/2, 
		0, f_height/2 + f_pinlength, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, 0, f_height/2 + f_pinlength, 
		2, flow_eDirection_Up);
      flow_AddAnnot( nc, -f_width/2 + f_strlength, 0, 
		0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
		flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
      /* Add execute order display */
      flow_AddFilledRect( nc, f_width/2 - GOEN_DISPLAYNODEWIDTH, -f_height/2, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineGray, flow_mDisplayLevel_2);
      flow_AddAnnot( nc, 
	f_width/2 - GOEN_DISPLAYNODEWIDTH + f_strlength,
	(GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0 - f_height/2,
	 GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_2);
      break;
    }
    case goen_eGraphIndex_SubStep:
    {
      float f_delta = GOEN_F_GRID / 4;

      f_width = GOEN_F_GRID * 2.5;
      f_height = GOEN_F_GRID * 2.5;
      if ( subwindowmark & 1)
        flow_AddLine( nc, -f_width/2, -f_height/2 + f_delta, 
		f_width/2, -f_height/2 + f_delta, flow_eDrawType_LineGray, 6);
      else
        flow_AddLine( nc, -f_width/2, -f_height/2 + f_delta, 
		f_width/2, -f_height/2 + f_delta, flow_eDrawType_Line, 6);
      flow_AddRect( nc, -f_width/2, -f_height/2, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);

      flow_AddLine( nc, 0, -f_height/2 - f_pinlength, 
		0, -f_height/2, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, 0, -f_height/2 - f_pinlength, 
		0, flow_eDirection_Down);
      flow_AddLine( nc, f_width/2, 0, 
		f_width/2 + f_pinlength, 0, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, f_width/2 + f_pinlength, 0, 
		1, flow_eDirection_Right);
      flow_AddLine( nc, 0, f_height/2, 
		0, f_height/2 + f_pinlength, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, 0, f_height/2 + f_pinlength, 
		2, flow_eDirection_Up);
      flow_AddAnnot( nc, -f_width/2 + f_strlength, 0, 
		0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
		flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
      /* Add execute order display */
      flow_AddFilledRect( nc, f_width/2 - GOEN_DISPLAYNODEWIDTH, -f_height/2, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineGray, flow_mDisplayLevel_2);
      flow_AddAnnot( nc, 
	f_width/2 - GOEN_DISPLAYNODEWIDTH + f_strlength,
	(GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0 - f_height/2,
	 GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_2);
      break;
    }
    case goen_eGraphIndex_SSEnd:
    {
      f_width = GOEN_F_GRID * 2.5;
      f_height = GOEN_F_GRID * 2.5;
      flow_AddRect( nc, -f_width/2, -f_height/2, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);
      flow_AddLine( nc, 0, -f_height/2 - f_pinlength, 
		0, -f_height/2, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, 0, -f_height/2 - f_pinlength, 
		0, flow_eDirection_Down);
      flow_AddLine( nc, f_width/2, 0, 
		f_width/2 + f_pinlength, 0, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, f_width/2 + f_pinlength, 0, 
		1, flow_eDirection_Right);
      flow_AddAnnot( nc, -f_width/2 + f_strlength, 0,
		0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
		flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
      /* Add execute order display */
      flow_AddFilledRect( nc, f_width/2 - GOEN_DISPLAYNODEWIDTH, -f_height/2, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineGray, flow_mDisplayLevel_2);
      flow_AddAnnot( nc, 
	f_width/2 - GOEN_DISPLAYNODEWIDTH + f_strlength,
	(GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0 - f_height/2,
	 GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_2);
      break;
    }
    case goen_eGraphIndex_SSBegin:
    {
      f_width = GOEN_F_GRID * 2.5;
      f_height = GOEN_F_GRID * 2.5;
      flow_AddRect( nc, -f_width/2, -f_height/2, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);
      flow_AddLine( nc, f_width/2, 0, 
		f_width/2 + f_pinlength, 0, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, f_width/2 + f_pinlength, 0, 
		0, flow_eDirection_Right);
      flow_AddLine( nc, 0, f_height/2, 
		0, f_height/2 + f_pinlength, flow_eDrawType_Line, 2);
      flow_AddConPoint(nc, 0, f_height/2 + f_pinlength, 
		1, flow_eDirection_Up);
      flow_AddAnnot( nc, -f_width/2 + f_strlength, 0,
		0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
		flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
      /* Add execute order display */
      flow_AddFilledRect( nc, f_width/2 - GOEN_DISPLAYNODEWIDTH, -f_height/2, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineGray, flow_mDisplayLevel_2);
      flow_AddAnnot( nc, 
	f_width/2 - GOEN_DISPLAYNODEWIDTH + f_strlength,
	(GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0 - f_height/2,
	 GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_2);
      break;
    }
    case goen_eGraphIndex_Trans:
    {
      float f_delta = GOEN_F_GRID / 5;

      f_width = GOEN_F_GRID * 1.6;
      if ( subwindowmark & 1)
        flow_AddLine( nc, -f_width/2, f_delta, 
		f_width/2, f_delta, flow_eDrawType_LineGray, 6);

      flow_AddLine( nc, -f_width/2, 0, f_width/2, 0, flow_eDrawType_Line, 4);
      flow_AddLine( nc, 0, - f_pinlength, 0, 0, flow_eDrawType_Line, 2);
      flow_AddConPoint( nc, 0, - f_pinlength, 
		0, flow_eDirection_Down);
      flow_AddLine( nc, 0, 0, 0, f_pinlength, flow_eDrawType_Line, 2);
      flow_AddConPoint( nc, 0, f_pinlength, 
		2, flow_eDirection_Up);
      flow_AddConPoint( nc, -f_width/2, 0, 
		1, flow_eDirection_Left);
      flow_AddAnnot( nc, f_strlength, - f_strheight/2, 
		0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
		flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
      /* Add execute order display */
      flow_AddFilledRect( nc, f_width/2 - GOEN_DISPLAYNODEWIDTH, 0, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineGray, flow_mDisplayLevel_2);
      flow_AddAnnot( nc, 
	f_width/2 - GOEN_DISPLAYNODEWIDTH + f_strlength,
	(GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0,
	 GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_2);
      break;
    }
    case goen_eGraphIndex_Point:
    {
      float f_radius = GOEN_F_GRID / 5;

      flow_AddArc( nc, -f_radius/2, -f_radius/2, f_radius/2, f_radius/2,
		0, 360, flow_eDrawType_Line, 2);
      flow_AddConPoint( nc, 0, 0,
		0, flow_eDirection_Center);
      break;
    }
    case goen_eGraphIndex_OrderAct:
    {
      f_width = GOEN_F_GRID * 4;
      f_height = GOEN_F_GRID; 

      flow_AddRect( nc, 0, -f_height/2, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);
      flow_AddLine( nc, f_width, 0, f_width + f_pinlength, 0, flow_eDrawType_Line, 2);
      flow_AddConPoint( nc, f_width + f_pinlength, 0,
		0, flow_eDirection_Right);
      flow_AddText( nc, "OrderAct", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      break;
    }
    case goen_eGraphIndex_SetCond:
    {
      f_width = GOEN_F_GRID * 4;
      f_height = GOEN_F_GRID; 

      flow_AddRect( nc, 0, -f_height/2, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);
      flow_AddLine( nc, -f_pinlength, 0, 0, 0, flow_eDrawType_Line, 2);
      flow_AddConPoint( nc, -f_pinlength, 0,
		0, flow_eDirection_Left);
      flow_AddText( nc, "SetCond", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);

      /* Add execute order display */
      flow_AddFilledRect( nc, f_width - GOEN_DISPLAYNODEWIDTH, -f_height/2, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineGray, flow_mDisplayLevel_2);
      flow_AddAnnot( nc, 
	f_width - GOEN_DISPLAYNODEWIDTH + f_strlength,
	(GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0 - f_height/2,
	 GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_2);
      break;
    }
    case goen_eGraphIndex_ShowPlcAttr:
    {
      float f_yoffs = GOEN_F_GRID / 2;
      float f_repeat = GOEN_F_GRID;
      f_width = GOEN_F_GRID * 9;
      f_height = GOEN_F_GRID * 3; 

      flow_AddRect( nc, 0, -f_yoffs, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);
      flow_AddLine( nc, 0, f_repeat - f_yoffs, f_width, f_repeat - f_yoffs, 
		flow_eDrawType_Line, 2);
      flow_AddLine( nc, 0, f_repeat * 2 - f_yoffs, f_width, f_repeat * 2 - f_yoffs, 
		flow_eDrawType_Line, 2);
      flow_AddAnnot( nc, f_repeat*2.7, f_repeat - f_strheight*0.25 - f_yoffs, 
		0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
		flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
      flow_AddAnnot( nc, f_repeat*2.7, f_repeat*2 - f_strheight*0.25 - f_yoffs, 
		1, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
		flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
      flow_AddAnnot( nc, f_repeat*2.7, f_repeat*3 - f_strheight*0.25 - f_yoffs, 
		2, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
		flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
      flow_AddText( nc, "Volume", f_strlength/3, f_repeat - f_strheight*0.3 - f_yoffs, 
		flow_eDrawType_TextHelvetica, 1);
      flow_AddText( nc, "ScanTime", f_strlength/3, f_repeat*2 - f_strheight*0.3 - f_yoffs, 
		flow_eDrawType_TextHelvetica, 1);
      flow_AddText( nc, "Reset", f_strlength/3, f_repeat*3 - f_strheight*0.3 - f_yoffs, 
		flow_eDrawType_TextHelvetica, 1);
      break;
    }
    case goen_eGraphIndex_GetAgeneric:
    case goen_eGraphIndex_GetDgeneric:
    case goen_eGraphIndex_GetSgeneric:
    case goen_eGraphIndex_GetIgeneric:
    case goen_eGraphIndex_GetATgeneric:
    case goen_eGraphIndex_GetDTgeneric:
    {
      f_width = GOEN_F_GRID * 4;
      f_height = GOEN_F_GRID; 

      flow_AddRect( nc, 0, -f_height/2, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);
      flow_AddLine( nc, f_width, 0, f_width + f_pinlength, 0, flow_eDrawType_Line, 2);
      flow_AddConPoint( nc, f_width + f_pinlength, 0,
		0, flow_eDirection_Right);
      if ( graph_index == goen_eGraphIndex_GetAgeneric)
        flow_AddText( nc, "GetA", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      else if ( graph_index == goen_eGraphIndex_GetSgeneric)
        flow_AddText( nc, "GetS", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      else if ( graph_index == goen_eGraphIndex_GetIgeneric)
        flow_AddText( nc, "GetI", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      else if ( graph_index == goen_eGraphIndex_GetATgeneric)
        flow_AddText( nc, "GetAT", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      else if ( graph_index == goen_eGraphIndex_GetDTgeneric)
        flow_AddText( nc, "GetDT", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      else
        flow_AddText( nc, "GetD", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      break;
    }
    case goen_eGraphIndex_StoAgeneric:
    case goen_eGraphIndex_StoDgeneric:
    case goen_eGraphIndex_StoSgeneric:
    case goen_eGraphIndex_StoIgeneric:
    case goen_eGraphIndex_StoATgeneric:
    case goen_eGraphIndex_StoDTgeneric:
    {
      f_width = GOEN_F_GRID * 4;
      f_height = GOEN_F_GRID; 

      flow_AddRect( nc, 0, -f_height/2, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);
      flow_AddLine( nc, -f_pinlength, 0, 0, 0, flow_eDrawType_Line, 2);
      flow_AddConPoint( nc, -f_pinlength, 0,
		0, flow_eDirection_Left);
      if ( graph_index == goen_eGraphIndex_StoAgeneric)
        flow_AddText( nc, "StoA", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      else if ( graph_index == goen_eGraphIndex_StoSgeneric)
        flow_AddText( nc, "StoS", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      else if ( graph_index == goen_eGraphIndex_StoIgeneric)
        flow_AddText( nc, "StoI", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      else if ( graph_index == goen_eGraphIndex_StoATgeneric)
        flow_AddText( nc, "StoAT", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      else if ( graph_index == goen_eGraphIndex_StoDTgeneric)
        flow_AddText( nc, "StoDT", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      else
        flow_AddText( nc, "StoD", f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      break;
    }
    case goen_eGraphIndex_FirstScan:
    case goen_eGraphIndex_True:
    case goen_eGraphIndex_False:
    {
      char text[80];
      int w;

      switch ( graph_index) {
      case goen_eGraphIndex_FirstScan:    w=4; strcpy( text, "FirstScan"); break;
      case goen_eGraphIndex_True:         w=2; strcpy( text, "True"); break;
      case goen_eGraphIndex_False:        w=2; strcpy( text, "False"); break;
      default: ;
      }

      f_width = GOEN_F_GRID * w;
      f_height = GOEN_F_GRID; 

      flow_AddRect( nc, 0, -f_height/2, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);
      flow_AddLine( nc, f_width, 0, f_width + f_pinlength, 0, flow_eDrawType_Line, 2);
      flow_AddConPoint( nc, f_width + f_pinlength, 0,
		0, flow_eDirection_Right);
      flow_AddText( nc, text, f_strlength, 0.5 * f_strheight,
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
      break;
    }
  }
  *node_class = nc;
  return GOEN__SUCCESS;
}
Exemplo n.º 7
0
int goen_create_nodetype_m14( 
    pwr_sGraphPlcNode	*graphbody,
    pwr_tClassId	cid,
    ldh_tSesContext	ldhses,
    flow_tCtx		ctx,
    unsigned int 	*mask,
    unsigned long	subwindowmark,
    unsigned long	node_width,
    flow_tNodeClass	*node_class,
    vldh_t_node		node)
{
  int  		i, sts, size;
  int		i_inpoints;
  int		i_outpoints;
  int		inputpoints, outputpoints;
  unsigned long	inpointmask;
  unsigned long	outpointmask;
  unsigned int	*inmask_pointer;
  unsigned int	*outmask_pointer;
  unsigned int	*invertmask_pointer;
  ldh_sParDef 	*bodydef;
  int 		rows;
  char		*parvalue;
  double	code_width;
  double	code_height;
  flow_tNodeClass nc_pid;
  char		name[80];
  int		conpoint_nr;
  int		annot_rows;
  static int	idx = 0;
  flow_tObject	cp;

  sts = ldh_ClassIdToName(ldhses, cid, name, sizeof(name), &size);
  if ( EVEN(sts) ) return sts;
  sprintf( &name[strlen(name)], "%d", idx++);

  /* Get the text in the parameter Code */
  sts = ldh_GetObjectPar(
			(node->hn.wind)->hw.ldhses,  
			node->ln.oid, 
			"DevBody",
			"Code",
			&parvalue, &size); 
  if ( EVEN(sts)) return sts;

  flow_MeasureAnnotText( ctx, parvalue,
	     	flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_MultiLine,
		&code_width, &code_height, &annot_rows);
  free( parvalue);	

  /* Get the runtime paramteers for this class */
  sts = ldh_GetObjectBodyDef(ldhses, cid, "RtBody", 1, 
			&bodydef, &rows);
  if ( EVEN(sts) ) return sts;

  inmask_pointer = mask++;
  outmask_pointer = mask++;
  invertmask_pointer = mask;

  /* Count number of inputpoints and outputpoints in mask  */
  inpointmask = 1;
  outpointmask = 1;
  inputpoints = 0;
  outputpoints = 0;
  for ( i = 0; i < rows; i++)  
  {
    if ( bodydef[i].ParClass == pwr_eClass_Input)
    {
      inputpoints += ((*inmask_pointer & inpointmask) != 0);
      inpointmask <<= 1;
    }
    if ( bodydef[i].ParClass == pwr_eClass_Output)
    {
      outputpoints += ((*outmask_pointer & outpointmask) != 0);
      outpointmask <<= 1;
    }
  }

  f_height  = (co_max(inputpoints,outputpoints) + 2)*f_repeat
			+ (floor( code_height / GOEN_F_GRID) + 1) * GOEN_F_GRID;
  f_width = co_max( f_strlength * (2 + node_width), f_defwidth);
  f_width = co_max( f_width, code_width + f_strlength *2);
  f_namepos = f_width/2.0 - strlen( graphbody->graphname)*
			      f_strlength/2.0;

  flow_CreateNodeClass(ctx, name, flow_eNodeGroup_Common, 
		&nc_pid);

  /* Draw the rectangle for gate */
  flow_AddRect( nc_pid, 0, -f_yoffs, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);

  /* Draw the separator line for header and footer			      */
  flow_AddLine( nc_pid, 0, f_height - f_repeat - f_yoffs, f_width, 
		f_height - f_repeat - f_yoffs, flow_eDrawType_Line, 2);

  flow_AddLine( nc_pid, 0, 
	(co_max(inputpoints,outputpoints) + 1)*f_repeat - f_yoffs, 
	f_width, 
	(co_max(inputpoints,outputpoints) + 1)*f_repeat - f_yoffs, 
	flow_eDrawType_Line, 2);

  if ( subwindowmark == 0 )
  {
    flow_AddLine( nc_pid, 0, f_repeat - f_yoffs, f_width, 
		f_repeat - f_yoffs, flow_eDrawType_Line, 2);
  }
  else
  {
    flow_AddLine( nc_pid, 0, f_repeat - f_yoffs, f_width,
		f_repeat - f_yoffs, flow_eDrawType_LineGray, 4);
  }


  /* Draw the objname */
  flow_AddText( nc_pid, graphbody->graphname, f_namepos, 
		f_repeat/2 + f_strheight/2 - f_yoffs, 
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);

  /* Draw the leadnames and lines */

  conpoint_nr = 0;
  inpointmask = 1;
  i_inpoints = 0;
  outpointmask = 1;
  i_outpoints = 0;
  for (i = 0; i < rows ; i++)
  {
    if ( bodydef[i].ParClass == pwr_eClass_Input)
    {
      if ( (*inmask_pointer & inpointmask) != 0)
      {
        flow_AddText( nc_pid, bodydef[i].Par->Input.Graph.GraphName,
		f_nameoffin, 
		f_repeat * (1.5 + i_inpoints) + f_strheight/2 - f_yoffs, 
		flow_eDrawType_TextHelvetica, 2);

        if ( (*invertmask_pointer & inpointmask) == 0)
	{
          flow_AddLine( nc_pid, 0, f_repeat*(1.5 + i_inpoints) - f_yoffs, 
		-f_pinlength, f_repeat*(1.5+i_inpoints) - f_yoffs,
		flow_eDrawType_Line, 2);
	}
	else
	{
          flow_AddLine( nc_pid, -f_pinlength, f_repeat*(1.5 + i_inpoints) - f_yoffs, 
		-f_circle, f_repeat*(1.5+i_inpoints) - f_yoffs,
		flow_eDrawType_Line, 2);
          flow_AddArc( nc_pid, -f_circle, 
		f_repeat*(1.5+i_inpoints) - f_circle / 2 - f_yoffs, 
		0, f_repeat*(1.5+i_inpoints) + f_circle / 2 - f_yoffs, 0, 360, 
		flow_eDrawType_Line, 2);
	}
        flow_AddConPoint( nc_pid, -f_pinlength, 
		f_repeat * ( 1.5 + i_inpoints) - f_yoffs, 
		conpoint_nr++,
		flow_eDirection_Left);
	i_inpoints++;
      }
      inpointmask <<= 1;
    }
    if ( bodydef[i].ParClass == pwr_eClass_Output)
    {
      if ( (*outmask_pointer & outpointmask) != 0)
      {
        f_namelength = strlen( bodydef[i].Par->Output.Graph.GraphName) *
		   f_strlength;

        if ( bodydef[i].ParClass == pwr_eClass_Output) 
        {
          flow_AddText( nc_pid, bodydef[i].Par->Output.Graph.GraphName, 
		f_width-f_nameoffout-f_namelength, 
		f_repeat * (1.5 + i_outpoints) + f_strheight/2 - f_yoffs,
		flow_eDrawType_TextHelvetica, 2);

        }
        flow_AddLine( nc_pid, f_width, f_repeat*(1.5 + i_outpoints) - f_yoffs, 
		f_width+f_pinlength, f_repeat*(1.5+i_outpoints) - f_yoffs,
		flow_eDrawType_Line, 2);
        flow_CreateConPoint( ctx, f_width + f_pinlength, 
		f_repeat * ( i_outpoints + 1.5) - f_yoffs, 
		conpoint_nr++,
		flow_eDirection_Right, &cp);
        flow_NodeClassAdd( nc_pid, cp);
        if (bodydef[i].Par->Output.Info.Type == pwr_eType_Float32)
          flow_SetTraceAttr( cp, NULL, bodydef[i].ParName, 
		flow_eTraceType_Float32, 0);
        else if (bodydef[i].Par->Output.Info.Type == pwr_eType_Int32)
          flow_SetTraceAttr( cp, NULL, bodydef[i].ParName, 
		flow_eTraceType_Int32, 0);
        else if (bodydef[i].Par->Output.Info.Type == pwr_eType_Boolean)
          flow_SetTraceAttr( cp, NULL, bodydef[i].ParName, 
		flow_eTraceType_Boolean, 0);
	i_outpoints++;
      }
      outpointmask <<= 1;
    }
  }

  f_namelength = f_strlength*6;
  f_node_width = node_width;
  if ( node_width == 0 )
    f_node_width = 6;
  flow_AddAnnot( nc_pid, 
	f_strlength,
	f_height - (f_repeat - f_strheight)/2 - f_yoffs,
	2, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_1);
  flow_AddAnnot( nc_pid, 
	f_strlength,
	f_height - (f_repeat - f_strheight)/2 - f_repeat - code_height +
	code_height/annot_rows - f_yoffs,
	0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_MultiLine, flow_mDisplayLevel_1);

  /* Add execute order display */
  flow_AddFilledRect( nc_pid, f_width - GOEN_DISPLAYNODEWIDTH, -f_yoffs, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineGray, flow_mDisplayLevel_2);
  flow_AddAnnot( nc_pid, 
	f_width - GOEN_DISPLAYNODEWIDTH + f_strlength,
	(GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0 - f_yoffs,
	 GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_2);

  free( (char *)bodydef);
  *node_class = nc_pid;
  return GOEN__SUCCESS;
}
Exemplo n.º 8
0
int goen_create_nodetype_m16( 
    pwr_sGraphPlcNode	*graphbody,
    pwr_tClassId	cid,
    ldh_tSesContext	ldhses,
    flow_tCtx		ctx,
    unsigned int 	*mask,
    unsigned long	subwindowmark,
    unsigned long	node_width,
    flow_tNodeClass	*node_class,
    vldh_t_node		node)
{
  int  i, sts;
  int	i_inpoints, i_inpoints_top, i_inpoints_bottom;
  int	i_outpoints, i_outpoints_top, i_outpoints_bottom;
  int	inputpoints, outputpoints, inputpoints_top, inputpoints_bottom,
		outputpoints_top, outputpoints_bottom;
  int	points_at_top, points_at_bottom, points_at_left, points_at_right;
  unsigned long    inpointmask;
  unsigned long    outpointmask;
  unsigned int     *inmask_pointer;
  unsigned int     *outmask_pointer;
  unsigned int     *invertmask_pointer;
  ldh_sParDef 	*bodydef;
  int 		rows;

  flow_tNodeClass nc_pid;
  char		name[80];
  int		size;
  int		conpoint_nr;
  static int	idx = 0;


  sts = ldh_ClassIdToName(ldhses, cid, name, sizeof(name), &size);
  if ( EVEN(sts) ) return sts;
  sprintf( &name[strlen(name)], "%d", idx++);

  /* Get the runtime paramters for this class */
  sts = ldh_GetObjectBodyDef(ldhses, cid, "RtBody", 1, 
			&bodydef, &rows);
  if ( EVEN(sts) ) return sts;

  inmask_pointer = mask++;
  outmask_pointer = mask++;
  invertmask_pointer = mask;

  /* Count number of inputpoints and outputpoints in mask  */
  inpointmask = 1;
  outpointmask = 1;
  inputpoints = 0;
  outputpoints = 0;
  inputpoints_top = 0;
  outputpoints_top = 0;
  inputpoints_bottom = 0;
  outputpoints_bottom = 0;
  for ( i = 0; i < rows; i++)  
  {
    if ( bodydef[i].ParClass == pwr_eClass_Input)
    {
      if ( bodydef[i].Par->Input.Graph.InputType == 1)
	inputpoints_top += ((*inmask_pointer & inpointmask) != 0);
      else if ( bodydef[i].Par->Input.Graph.InputType == 2)
        inputpoints_bottom += ((*inmask_pointer & inpointmask) != 0);
      else    
	inputpoints += ((*inmask_pointer & inpointmask) != 0);
      inpointmask <<= 1;
    }
    if ( bodydef[i].ParClass == pwr_eClass_Output)
    {
      if ( bodydef[i].Par->Input.Graph.InputType == 1)
        outputpoints_top += ((*outmask_pointer & outpointmask) != 0);
      else if ( bodydef[i].Par->Input.Graph.InputType == 2)
        outputpoints_bottom += ((*outmask_pointer & outpointmask) != 0);
      else    
        outputpoints += ((*outmask_pointer & outpointmask) != 0);
      outpointmask <<= 1;
    }
  }
	
  points_at_top = ((inputpoints_top + outputpoints_top) != 0);
  points_at_bottom = ((inputpoints_bottom + outputpoints_bottom) != 0);
  points_at_left = (inputpoints != 0);
  points_at_right = (outputpoints != 0);

  f_height  = 3 * f_repeat +
	       (co_max(inputpoints,outputpoints)-1)*f_repeat;

  f_width = co_max( f_strlength * (2 + node_width), f_defwidth);
  f_namepos = f_width/2.0 - strlen( graphbody->graphname)*
			      f_strlength/2.0;

  flow_CreateNodeClass(ctx, name, flow_eNodeGroup_Common, 
		&nc_pid);

  /* Draw the rectangle for gate  */

  if ( graphbody->graphindex == 1)
  {
    /* Draw the rectangle for gate */
    flow_AddRect( nc_pid, 0, -f_yoffs, f_width, f_height, 
		flow_eDrawType_LineErase, 2, flow_mDisplayLevel_1);
    if ( f_height > 2 * f_corner)
    {
      flow_AddLine( nc_pid, 0, f_corner - f_yoffs, 
		0, f_height - f_corner - f_yoffs,
		flow_eDrawType_Line, 2);
    }
    flow_AddArc( nc_pid, 0, f_height - 2*f_corner - f_yoffs,
		2*f_corner, f_height - f_yoffs,
		180, 90, flow_eDrawType_Line, 2);
    flow_AddLine( nc_pid, f_corner, f_height - f_yoffs, 
		f_width - f_corner, f_height - f_yoffs,
		flow_eDrawType_Line, 2);
    flow_AddArc( nc_pid, f_width - 2*f_corner, f_height - 2*f_corner - f_yoffs,
		f_width, f_height - f_yoffs,
		270, 90, flow_eDrawType_Line, 2);
    if ( f_height > 2 * f_corner)
    {
      flow_AddLine( nc_pid, f_width, f_corner - f_yoffs, 
		f_width, f_height - f_corner - f_yoffs,
		flow_eDrawType_Line, 2);
    }
    flow_AddArc( nc_pid, f_width - 2*f_corner, -f_yoffs,
		f_width, 2*f_corner - f_yoffs,
		0, 90, flow_eDrawType_Line, 2);
    flow_AddLine( nc_pid, f_corner, -f_yoffs, 
		f_width - f_corner, -f_yoffs,
		flow_eDrawType_Line, 2);
    flow_AddArc( nc_pid, 0, -f_yoffs,
		2*f_corner, 2*f_corner - f_yoffs,
		90, 90, flow_eDrawType_Line, 2);
  }
  else
  {
    flow_AddRect( nc_pid, 0, -f_yoffs, f_width, f_height, 
		flow_eDrawType_Line, 2, flow_mDisplayLevel_1);
  }

  /* Draw the separator line for header and footer			      */

  if ( subwindowmark == 0 )
  {
    flow_AddLine( nc_pid, 0, f_repeat - f_yoffs, f_width, 
		f_repeat - f_yoffs, flow_eDrawType_Line, 2);
  }
  else
  {
    flow_AddLine( nc_pid, 0, f_repeat - f_yoffs, f_width, 
		f_repeat - f_yoffs, flow_eDrawType_LineGray, 4);
  }

  /* Draw the objname */
  flow_AddText( nc_pid, graphbody->graphname, f_namepos, 
		f_repeat/2 + f_strheight/2 - f_yoffs, 
		flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);

  /* Draw the leadnames and lines					      */

  conpoint_nr = 0;
  inpointmask = 1;
  i_inpoints = 0;
  i_inpoints_top = 0;
  i_inpoints_bottom = 0;
  outpointmask = 1;
  i_outpoints = 0;
  i_outpoints_top = 0;
  i_outpoints_bottom = 0;
  for (i = 0; i < rows ; i++)
  {
    if ( bodydef[i].ParClass == pwr_eClass_Input)
    {
      if ( (*inmask_pointer & inpointmask) != 0)
      {
        if ( bodydef[i].Par->Input.Graph.InputType == 2)
	{
          flow_AddLine( nc_pid, 
		f_repeat * ( i_inpoints_bottom + i_outpoints_bottom + 1),
		f_height - f_yoffs,
		f_repeat * ( i_inpoints_bottom + i_outpoints_bottom + 1),
		f_height + f_pinlength - f_yoffs,
		flow_eDrawType_Line, 2);
          flow_AddConPoint( nc_pid,
		f_repeat * ( i_inpoints_bottom + i_outpoints_bottom + 1), 
		f_height + f_pinlength - f_yoffs,
		conpoint_nr++,
		flow_eDirection_Up);
	  i_inpoints_bottom++;
        }
        else if ( bodydef[i].Par->Input.Graph.InputType != 1)
	{
          flow_AddText( nc_pid, bodydef[i].Par->Output.Graph.GraphName, 
		f_nameoffin, 
		f_repeat * (1.5 + i_inpoints) + f_strheight/2 - f_yoffs,
		flow_eDrawType_TextHelvetica, 2);

          if ( (*invertmask_pointer & inpointmask) == 0)
	  {
            flow_AddLine( nc_pid, 0, f_repeat*(1.5 + i_inpoints) - f_yoffs, 
		-f_pinlength, f_repeat*(1.5+i_inpoints) - f_yoffs,
		flow_eDrawType_Line, 2);
	  }
	  else
	  {
            flow_AddLine( nc_pid, 
		f_repeat * ( i_inpoints_top + i_outpoints_top + 1), 
		-f_pinlength - f_yoffs,
		f_repeat * ( i_inpoints_top + i_outpoints_top + 1), 
		-f_yoffs,
		flow_eDrawType_Line, 2);
            flow_AddArc( nc_pid, -f_circle, 
		f_repeat*(1.5+i_inpoints) - f_circle / 2 - f_yoffs, 
		0, f_repeat*(1.5+i_inpoints) + f_circle / 2 - f_yoffs, 0, 360, 
		flow_eDrawType_Line, 2);
	  }
          flow_AddConPoint( nc_pid, -f_pinlength, 
		f_repeat * ( 1.5 + i_inpoints) - f_yoffs, 
		conpoint_nr++,
		flow_eDirection_Left);
	  i_inpoints++;
	}
        else	  
	{
          flow_AddLine( nc_pid, 
		f_repeat * ( i_inpoints_top + i_outpoints_top + 1), 
		-f_pinlength - f_yoffs,
		f_repeat * ( i_inpoints_top + i_outpoints_top + 1), 
		-f_yoffs,
		flow_eDrawType_Line, 2);
          flow_AddConPoint( nc_pid,
		f_repeat * ( i_inpoints_top + i_outpoints_top + 1),
		-f_pinlength - f_yoffs,
		conpoint_nr++,
		flow_eDirection_Down);
          i_inpoints_top++;
        }
      }
      inpointmask <<= 1;
    }
    if ( bodydef[i].ParClass == pwr_eClass_Output)
    {
      if ( (*outmask_pointer & outpointmask) != 0)
      {
        if ( bodydef[i].Par->Output.Graph.InputType == 2)
	{
          flow_AddLine( nc_pid,
		f_repeat * ( i_inpoints_bottom + i_outpoints_bottom + 1),
		f_height - f_yoffs,
		f_repeat * ( i_inpoints_bottom + i_outpoints_bottom + 1),
		f_height + f_pinlength - f_yoffs,
		flow_eDrawType_Line, 2);
          flow_AddConPoint( nc_pid,
		f_repeat * ( i_inpoints_bottom + i_outpoints_bottom + 1),
		f_height + f_pinlength -f_yoffs,
		conpoint_nr++,
		flow_eDirection_Up);
	  i_inpoints_bottom++;
	}
        else if ( bodydef[i].Par->Output.Graph.InputType != 1)
	{
          f_namelength = strlen( bodydef[i].Par->Output.Graph.GraphName) *
		   f_strlength;
          flow_AddText( nc_pid, bodydef[i].Par->Output.Graph.GraphName, 
		f_width - f_nameoffout - f_namelength,
		f_repeat * (1.5 + i_outpoints) + f_strheight/2 - f_yoffs,
		flow_eDrawType_TextHelvetica, 2);
          flow_AddLine( nc_pid, f_width, f_repeat*(1.5 + i_outpoints) - f_yoffs, 
		f_width+f_pinlength, f_repeat*(1.5+i_outpoints) - f_yoffs,
		flow_eDrawType_Line, 2);
          flow_AddConPoint( nc_pid, f_width + f_pinlength, 
		f_repeat * ( i_outpoints + 1.5) - f_yoffs, 
		conpoint_nr++,
		flow_eDirection_Right);
	  i_outpoints++;
        }
	else	 
        {
          flow_AddLine( nc_pid,
		f_repeat * ( i_inpoints_top + i_outpoints_top + 1),
		-f_pinlength - f_yoffs,
		f_repeat * ( i_inpoints_top + i_outpoints_top + 1),
		-f_yoffs,
		flow_eDrawType_Line, 2);
          flow_AddConPoint( nc_pid,
		f_repeat * ( i_inpoints_top + i_outpoints_top + 1),
		-f_pinlength - f_yoffs,
		conpoint_nr++,
		flow_eDirection_Down);
	  i_inpoints_top++;
        }
      }
      outpointmask <<= 1;
    }
  }

  f_namelength = f_strlength*6;
  f_node_width = node_width;
  if ( node_width == 0 )
    f_node_width = 6;

  flow_AddAnnot( nc_pid, 
	f_strlength,
	f_height - (f_repeat - f_strheight)/2.0 - f_yoffs,
	0, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_1);

  /* Add execute order display */
  flow_AddFilledRect( nc_pid, f_width - GOEN_DISPLAYNODEWIDTH, -f_yoffs, 
		GOEN_DISPLAYNODEWIDTH, GOEN_DISPLAYNODEHEIGHT, 
		flow_eDrawType_LineGray, flow_mDisplayLevel_2);
  flow_AddAnnot( nc_pid, 
	f_width - GOEN_DISPLAYNODEWIDTH + f_strlength,
	(GOEN_DISPLAYNODEHEIGHT + f_strheight)/2.0 - f_yoffs,
	 GOEN_DISPLAYNODE_ANNOT, flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, 
	flow_eAnnotType_OneLine, flow_mDisplayLevel_2);

  free((char *) bodydef);
  *node_class = nc_pid;
  return GOEN__SUCCESS;
}