|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
$ C0 R ~/ U, S3 R( e$ B9 {Teamcenter ITK二次开发源码分享: 创建一个工作流
5 L6 l# Q! \7 c' ?5 z4 ]) v2 `3 A/ p$ k! m" O w" X1 n
- /*HEAD CREATE_A_PROCESS CCC ITK */
2 s; N& r3 x: n - #include <stdlib.h>- s2 A- s- Y0 q& |
- #include <TCcore/aom.h>
( T2 t* J+ x" a# Y - #include <tc/emh.h>
" i2 G& l! `( u - #include <epm/epm.h>) f9 Y5 B0 R' z2 ?" N7 C4 A1 t$ g) X
- #include <tc/tc.h>
; X8 r6 z0 [% l/ @ - #include <sa/tcfile.h>% C) C( j# X, y, h
- #include <itk/mem.h>
* S- h% j- o6 _4 |- _+ i; A3 s - 0 [% T7 X2 k% ~6 ]/ c, O
- #define EXIT_FAILURE 1 4 O2 u3 i( s% ] a$ {1 e
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))3 p( R8 [2 V ?: Z1 P" A/ E4 E
- static void report_error( char *file, int line, char *function, int return_code)/ O! A: ?8 w- Z. h/ _4 c6 e
- {1 [$ W1 |# r8 f3 C% M0 k
- if (return_code != ITK_ok). \- b/ F7 I+ u9 p: \ j# Z
- {
" X* Y2 W" {. F% B" S; o - char *error_message_string;. ]! M G* i5 R( x; v$ |: \& P
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);* q q9 q$ a# I5 i' T/ `" M- }0 d) g2 j
- printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
0 \" i1 I$ X2 Y8 K. K' N - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);) x, z2 Z5 |! N* p, ]5 K; i" B) Q
- if(error_message_string) MEM_free(error_message_string);. |0 ^. X: ]# n# A8 U5 ?' ^
- printf("\nExiting program!\n");
/ n$ P. K/ C" G$ { - exit (EXIT_FAILURE);
# n) O6 C3 y" F1 Y; e0 A - }! u: H- U( R2 n/ k6 O8 @8 W6 l
- }
) J$ `7 ^4 r* j! L - 3 k# q- `/ H. Z. G* v, p) I
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))' t/ p; p7 Q, i
- static void check_value( char *function, int value )
% e6 U8 n# M- F' y( }& `, C - {5 R I+ `+ \$ S* k6 E" E+ Q
- if (value == 0)4 P* }$ D# f& d
- {
% {, J6 T8 i' M8 e9 K9 ~* D - printf ("\t%s is NULL\n", function);
$ G/ H7 b/ b4 f ]- V% j1 b - printf("\nExiting program!\n");" V s: U# {+ t- H T2 u
- exit (EXIT_FAILURE);
' D0 Z- Q8 L6 N/ |" r - }
. `2 Z6 c! A! f2 W7 X3 S) \ - }
& p1 d$ R/ ?. E
6 b* P2 e1 Q C0 X) h+ F( C
3 R. c3 V0 V! F. m5 }- static void do_it(void)$ f+ R% H! K& v# T" W
- {
7 G1 Y4 M6 q) q1 @( p - int
T' R7 d# X- ^" G - attach_types[1] = {1};
g/ X0 S5 x- ]. i( ] - tag_t
( ?6 U5 C8 _) K - rev = NULLTAG, . O% j6 |9 x2 L( |5 d# A. ]
- process_template = NULLTAG,
* ^7 g; v! ~+ f9 ?7 i1 K% W7 s# s - process = NULLTAG;
- z0 L4 O, w6 }+ X4 P- ?
, Q. ]; I/ Q6 X: J2 I1 v9 d3 B- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );9 `# j4 i+ [5 y; c
- EXIT_IF_NULL( rev );0 t* \7 M( L% @. B/ o7 \3 Q
* n: C: t3 Z" `, |/ e ~' |$ s, f- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); , O, W; ^# A5 r3 \# k) ?' b) \
- EXIT_IF_NULL( process_template );7 H/ S- P; _. o; t
- 7 |" P5 P( M! @1 n6 c; J% _5 x
- : y$ m9 C3 x$ J; I- m9 I `2 M
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, 2 r# u! \& Q$ C/ Q: l% G
- attach_types, &process) );. N) q2 Y5 p0 A# M& K
5 l& ^' n p& }% O8 V9 `8 ]7 I, H- EXIT_IF_NULL( process );
3 g: s5 z4 q' V8 t7 L. i# ` - }2 f- F# `+ G2 X6 H
8 g6 p6 [% n- q) M, T9 H2 ?2 h2 E- int ITK_user_main(int argc, char* argv[])
* F: c) X6 j- H - {* A7 S, ~& a9 W8 _
- int
4 \0 C% H$ s# r( b* w - status = 0; # W2 |- C {, ]3 G0 }* i+ I; U
- 4 N2 P! U7 T7 l
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
& y) l" A Q+ i9 m0 i& u x, ? - status = ITK_auto_login();
! T0 ~0 K2 V* M/ `/ { -
, D! w9 K4 m1 V, @3 X7 w( ]2 M - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");( x" D- _4 E% R) v# I d7 I
- else
" b7 }* K. @6 D - {' {( P8 ]- e) a* x$ L8 _
- printf("\nLogin successful!\n\n");* v; l, J5 W% ]/ L3 @2 ?2 i/ c
- ITK_set_journalling(TRUE);
4 [' S; S# j" ], C! g0 E4 W - do_it();
+ C6 v2 d! t5 I - }
0 Z/ O) G9 X* e - ITK_exit_module(TRUE);
9 \) s2 A# g5 X' G( @$ i( T% } - return status;' j" b6 K' ^( h) d. x7 o6 ~
- }
复制代码
; }+ g6 ~! k( b+ d% ?3 @% }- N& S5 J9 Y3 w$ I: z
- k7 x- r7 B/ B2 ~" h e |
|