/*====================================================================*\ FILE : UtilMfgWcell.c PURPOSE : Utility functions to create elements of a workcell HISTORY.. DATE BUILD AUTHOR MODIFICATIONS 24-Oct-96 H-01-14 Bojan $$1 Created. 12-Nov-96 H-01-16 Bojan $$2 Minor changes 20-Nov-96 H-01-17 mgs $$3 Removed old style headers 23-Nov-96 H-01-18 mgs $$4 Added argument to ProElementtreePrint() 20-Jan-97 H-01-24 Igor $$5 Removed TestMfg.h from includes 15-Sep-97 H-03-22 Pavel $$6 replace Pro/D on Pro/E \*====================================================================*/ #ifndef lint static char UtilMfgWcell_h [] = "@(#)UtilMfgWcell.c 1.4 11/26/96"; #endif /*--------------------------------------------------------------------*\ System includes \*--------------------------------------------------------------------*/ #include /*--------------------------------------------------------------------*\ Pro/Toolkit includes \*--------------------------------------------------------------------*/ #include "ProToolkit.h" #include "ProNcseq.h" #include "ProElement.h" #include "ProModelitem.h" #include "ProNcseqElem.h" #include "ProFeature.h" #include "ProSelection.h" #include "ProMdl.h" #include "ProParamval.h" #include "ProToolElem.h" #include "ProWcell.h" #include "ProElement.h" #include "ProElemId.h" #include "ProElempath.h" #include "ProFeature.h" #include "ProFeatType.h" #include "ProSolid.h" #include "ProCsys.h" /*--------------------------------------------------------------------*\ Application includes \*--------------------------------------------------------------------*/ #include "TestConsts.h" #include "UtilString.h" #include "UtilGeom.h" #include "TestError.h" #include "UtilTree.h" #include "MfgMenu.h" #include "TestMfgNew.h" /*--------------------------------------------------------------------*\ Application macros \*--------------------------------------------------------------------*/ #define PARAM_FIELD_WIDTH 21 /*--------------------------------------------------------------------*\ Application data types \*--------------------------------------------------------------------*/ /*====================================================================*\ Function: ProTempCreateWkcell Purpose : Create Workcell \*====================================================================*/ ProError ProTempCreateWkcell( Workcell wcell, ProFeature *p_wc_feature) { ProElement wc_elem_tree = (ProElement)NULL; /* Workcell element tree. */ ProElement wc_elem = (ProElement)NULL; /* Individual element. */ ProValue value = (ProValue)NULL; ProValueData value_data; ProSelection selection; ProErrorlist errors; ProError status = PRO_TK_NO_ERROR; char name[PRO_LINE_SIZE]; int i = 0; /* Set up the top level element values and sizes. */ static ElemTable workcell_elem_table[] = { { PRO_E_FEATURE_TYPE, PRO_VALUE_TYPE_INT }, { PRO_E_WCELL_TYPE, PRO_VALUE_TYPE_INT }, { PRO_E_NUM_AXES, PRO_VALUE_TYPE_INT }, { PRO_E_FEAT_NAME, PRO_VALUE_TYPE_WSTRING}}; int wc_elem_type_size = sizeof(workcell_elem_table)/ sizeof(ElemTable); /*--------------------------------------------------------------------*\ Allocate space for workcell element tree \*--------------------------------------------------------------------*/ if (status == PRO_TK_NO_ERROR) { status = ProElementAlloc ( PRO_E_FEATURE_TREE, &wc_elem_tree ); TEST_CALL_REPORT("ProElementAlloc()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); } fprintf(stderr, "wcell.type: %d\n", wcell.type); fprintf(stderr, "wcell.n_axis: %d\n", wcell.n_axis); fprintf(stderr, "wcell.wname: %s\n", pro_wstr_to_str(name, wcell.wname)); /*--------------------------------------------------------------------*\ Set all of the top level elements \*--------------------------------------------------------------------*/ for (i =0; i < wc_elem_type_size; i++) { if (status == PRO_TK_NO_ERROR) { status = ProElementAlloc(workcell_elem_table[i].elem_type,&wc_elem); TEST_CALL_REPORT("ProElementAlloc()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); } switch (workcell_elem_table[i].elem_type) { case PRO_E_FEATURE_TYPE: value_data.v.i = PRO_FEAT_WORKCELL; break; case PRO_E_WCELL_TYPE: value_data.v.i = wcell.type; break; case PRO_E_NUM_AXES: value_data.v.i = wcell.n_axis; break; case PRO_E_FEAT_NAME: value_data.v.w = (wchar_t*) malloc (sizeof(ProName)); if (value_data.v.w) ProUtilWstrcpy(value_data.v.w, wcell.wname); break; default: fprintf(stderr, "Error setting element type\n"); return (PRO_TK_GENERAL_ERROR); break; } value_data.type = workcell_elem_table[i].val_type; if (status == PRO_TK_NO_ERROR) { status = ProValueAlloc ( &value ); TEST_CALL_REPORT("ProValueAlloc()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); } if (status == PRO_TK_NO_ERROR) { status = ProValueDataSet (value, &value_data); TEST_CALL_REPORT("ProValueDataSet()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); } if ( status == PRO_TK_NO_ERROR ) { status = ProElementValueSet ( wc_elem, value ); TEST_CALL_REPORT("ProElementValueSet()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); } if ( status == PRO_TK_NO_ERROR ) { status = ProElemtreeElementAdd (wc_elem_tree, NULL, wc_elem ); TEST_CALL_REPORT("ProElemtreeElementAdd()","ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); } } status = ProUtilElementtreePrint(wc_elem_tree, PRO_TEST_INFO_WINDOW, NULL); /* status = ProElementAlloc( PRO_E_TOOLING, &wc_elem ); TEST_CALL_REPORT("ProElementAlloc()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); status = ProTestCreateTools( tool_id_default, p_param_file, bitmask, tool_type, wc_elem ); status = ProFeatinputElemAdd((ProFeatinputPtr) wc_input, wc_elem); TEST_CALL_REPORT("ProFeatinputElemAdd()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); */ status = ProTestCreateSelection(PRO_TK_NOT_USED, PRO_TYPE_UNUSED, &selection); if (status == PRO_TK_NO_ERROR) { status = ProFeatureCreate( selection, wc_elem_tree, NULL, 0, p_wc_feature, &errors); TEST_CALL_REPORT("ProFeatureCreate()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); } status = ProElementFree(&wc_elem_tree); TEST_CALL_REPORT("ProElementFree()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); return(status); }