|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 H( e, q: g" b! ]9 q/ X$ jTeamcenter ITK二次开发源码分享: 创建一个工作流
2 {& ]7 T* V" J3 f; s
" O* V! u" ]8 I& }8 D9 B7 S' [6 _$ D, @+ h- /*HEAD CREATE_A_PROCESS CCC ITK */4 K: h/ \9 k4 ?" o$ t& @
- #include <stdlib.h>
& U$ z( X# m6 [7 t" _# i - #include <TCcore/aom.h>
2 V2 b! e) a- I3 k7 c3 ~! e% @ - #include <tc/emh.h>
0 F; D1 h/ _) T9 Y% \/ u4 m - #include <epm/epm.h>
- r& ^- O6 P% a$ J - #include <tc/tc.h># G% f- Z1 P1 f1 `0 P
- #include <sa/tcfile.h>) K& \1 g' m# \# h0 l3 V3 C
- #include <itk/mem.h>
+ O2 h4 _1 I6 M - # v* ^6 d) J, ^' p+ a) ^2 g, ~
- #define EXIT_FAILURE 1 # U+ l9 p7 {' p8 `: `: {$ G
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))9 E6 Z) N7 s: r: y; x# [
- static void report_error( char *file, int line, char *function, int return_code)2 Y- ?% k3 F9 C
- {
1 F3 O7 N/ T* O" y8 X- ~5 E - if (return_code != ITK_ok)$ `# q Y/ D3 |& D* X/ h
- {
' f% j& ?" `' m2 n - char *error_message_string;
+ t2 ~' a8 K5 U7 ^" F1 N9 A7 g2 c - EMH_get_error_string (NULLTAG, return_code, &error_message_string);# [' y7 ?0 X' z
- printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
7 e8 g+ E4 a) r - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
0 {9 ^% H# q, M# _ - if(error_message_string) MEM_free(error_message_string);
; c7 w; O6 j2 E1 q) k/ J" x1 Z! k - printf("\nExiting program!\n");9 w5 q2 [* {. m' o: ~2 O
- exit (EXIT_FAILURE); 4 H% b# V% S: V1 V# a( S& `% `3 h
- }% u: l5 q' t; Q% |4 u8 [* r9 ?
- }# F& a2 u0 D; `) C# J6 _0 o9 r6 [
- ; F$ F5 ?) X( f5 o4 @
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))0 z6 H% b' X8 V2 b6 I8 y
- static void check_value( char *function, int value )
* ? Q( q& G8 ?4 I7 g1 n1 ?" Y - {% R/ M) X: C7 H1 y- f
- if (value == 0)
# k, s+ @: A; h: d, C - {
- I1 }. y n% ]- ]/ y - printf ("\t%s is NULL\n", function);
+ ~6 j! y, [* p2 J9 f6 K - printf("\nExiting program!\n");+ S5 O* M9 ]0 s5 E: b
- exit (EXIT_FAILURE); 4 y r2 b" ~; _ d4 ]2 g
- }
1 ~2 g' q" v( `6 {3 n+ o6 { - }/ M% ?! q; G- K) X+ Q; c2 D1 N
- + d* S$ \4 S6 C7 U m
; c/ F, ]- s4 i0 m0 `- static void do_it(void)
* j w2 n2 Z f" i7 B9 a0 T - {5 j5 Z9 I5 S, ^5 y g0 G9 M
- int
6 @$ Q3 P7 Z/ N" S: V - attach_types[1] = {1};+ C! W |# n2 r; \1 ? g- Z9 y
- tag_t & S' g& y7 {0 m- r
- rev = NULLTAG, ; \; H- T6 J+ t$ M" K
- process_template = NULLTAG,
( _$ u9 j: }- c( @ - process = NULLTAG; ]% Z K1 Y- \8 @
- - l2 V) K# F% @/ `( }! G2 h& l
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );" J% T: a$ ?2 f
- EXIT_IF_NULL( rev );" n# M1 l4 v! c; t
- 0 M( z5 z' r" O8 n$ n
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); - F# a) d% J) b1 G" T9 t; m# D4 ?
- EXIT_IF_NULL( process_template );. _/ B( `' T; k$ L9 k; O+ F
( z3 c% F+ K) X6 W3 j) d" h2 \- . x1 @5 q6 x; ~" ^( }4 k
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, , U# i# I2 |: v* u3 g& M2 q. Q2 ~
- attach_types, &process) );7 {5 ^0 [: t; t: N: Y! c1 Q
; u% f# W7 T" k9 S( t+ n- EXIT_IF_NULL( process );9 l5 M+ F0 C& Z% {
- }
/ V/ u8 K$ k: E9 I" V5 Y - ( ^9 D4 o- @5 c& e, p5 u; t
- int ITK_user_main(int argc, char* argv[])
; G& u3 O9 t0 L7 ? - {8 H4 y1 t2 F8 ]2 t/ M7 k8 A- E
- int0 O( N1 I! K+ g5 X6 c# M* i$ C
- status = 0; % E5 g) N I) ?: @2 |/ g9 i% e9 x
- & S7 C9 l( z) i+ s: A
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );+ ^5 ?) ?" ^5 h6 _$ N' W
- status = ITK_auto_login();: T7 H( |9 I+ M ?
- * ^8 y3 {7 H* q) g9 Q
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
6 H$ A( O: o4 P - else8 x7 D8 R" d _
- {/ g9 o8 e5 Z& Y3 J ?3 Q
- printf("\nLogin successful!\n\n");/ |5 F, x* v1 f
- ITK_set_journalling(TRUE);- k) d/ `3 s: Z# z
- do_it();' l9 G" C" ]! [2 B6 {# X
- }; `! E! X; B- E0 F* j5 O
- ITK_exit_module(TRUE);
) e" P- G6 t) _ - return status;
; V2 Z% w, g7 w! q7 p - }
复制代码 5 M% V" b- E% d& @9 @
) ~" y F/ W! {" F- X2 o; L. _. w4 Q* O" p
|
|