int trace_create_analyse( WGre *gre, double x, double y, vldh_t_node source, int source_conpoint) { static int idx = 0; vldh_t_conobject dummy_con; flow_tTraceObj object_str; flow_tTraceAttr attr_str; flow_eTraceType trace_type; flow_tNode n1; flow_tCon c1; char name[80]; int sts; if ( gre->trace_started) { /* Create a trace object */ sprintf( name, "Trace%d", idx++); dummy_con.hc.source_node = source; dummy_con.lc.source_point = source_conpoint; sts = trace_get_attr_con( gre, &dummy_con, "", object_str, attr_str, &trace_type); if (EVEN(sts)) return sts; flow_CreateNode( gre->flow_ctx, name, gre->trace_analyse_nc, x, y, NULL, &n1); flow_SetTraceAttr( n1, object_str, attr_str, trace_type, 0); flow_CreateCon( gre->flow_ctx, name, gre->trace_con_cc, source->hn.node_id, n1, source_conpoint, 0, NULL, &c1, 0, NULL, NULL, &sts); if ( EVEN(sts)) return sts; } return TRA__SUCCESS; }
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; }
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; }
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; }
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; }