|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
X8 x# [: k h" V5 ]; I$ \
Teamcenter ITK二次开发源码分享: 创建一个工作流6 `; _: _& `& I0 q
: j% L7 H0 t( d; R& ?! q- /*HEAD CREATE_A_PROCESS CCC ITK */) j s0 c! {2 E& h& U
- #include <stdlib.h>
' U# F8 p3 L; R x" z4 ` N - #include <TCcore/aom.h> [! f* D4 ~3 X
- #include <tc/emh.h># e A/ j. X& r. G
- #include <epm/epm.h>& Y$ {& Y& c& p, B7 o
- #include <tc/tc.h>
1 P$ \' u- l- I0 ~- Z - #include <sa/tcfile.h>
- f( W* o; }. T3 b - #include <itk/mem.h>
% O4 G8 W4 x. O5 g/ I
- C" b! {# q$ L. [7 n9 h- #define EXIT_FAILURE 1
9 h1 ]' x+ q" ^- Q+ [ - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))( h- I7 Q7 v5 b( M4 Y' E! G* B
- static void report_error( char *file, int line, char *function, int return_code), `; u i/ E* ?7 g* q
- {& n/ ~$ A k+ l, {# s- t6 N
- if (return_code != ITK_ok). [8 [2 ^% W! X2 Q4 ?# k
- {
$ B: ^, H8 J, r \/ H- ^ - char *error_message_string;7 s* g# l2 c1 |! M. [% j( I6 ^" c
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
- U9 D, W. W" z3 g! [) x7 x3 C - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
6 V0 p1 o' _& g6 f2 t k X. D - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
6 }: P" _9 c7 I |2 `5 Y' T- [ - if(error_message_string) MEM_free(error_message_string);1 Z' v( P7 c n2 g
- printf("\nExiting program!\n");# O8 b1 P7 w- S7 ?; _2 L+ }
- exit (EXIT_FAILURE);
* ], t) O7 o+ k2 Q% ? - }
7 u2 o, a; `! w8 d" q: Z' M3 F3 o - }8 S: |& T9 [) W+ o
; _7 h6 m2 X5 |- #define EXIT_IF_NULL(X) (check_value(#X, (X)))/ Z! m, ?" `1 f @
- static void check_value( char *function, int value )
, m9 _% S6 R3 K3 I) X: V - {
. ?! Z! E. H, j3 M. y - if (value == 0)6 U0 I; {7 ?- G* `
- {# |1 q9 |! R8 S z& m/ H& @" E
- printf ("\t%s is NULL\n", function);
) g/ `* n, h% b' ~8 S, T - printf("\nExiting program!\n");
- g9 N8 P2 ~- q3 [( C - exit (EXIT_FAILURE); ! J0 B" Q$ E2 K
- }
+ e& I1 x& z) i - }; w8 @4 {, ]: m0 t: n M
- ) h. s) {& V; f& J7 ~5 f, w2 }! s
- 1 Q( G3 E% _+ O( y0 |8 f% N6 o# c
- static void do_it(void)# k+ {+ q% O2 g4 T" a
- {7 L4 g, |' K, H) Y, F
- int
2 M# `. a3 L& X - attach_types[1] = {1};, }0 L7 |9 G, k3 q$ c
- tag_t
# k& S( J1 \$ ] - rev = NULLTAG, / e; W: c) P: w; f
- process_template = NULLTAG,
- q5 M( `" c0 S! S - process = NULLTAG;; ]1 G9 ?9 d( c# r a) M
8 x6 u3 b8 q' R' b3 o) b/ W- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
3 O) y2 G- m1 V8 H - EXIT_IF_NULL( rev );
4 s+ {, L9 l7 O" ^+ Z& ^
$ n9 w$ Y. N$ Z1 M6 |! U( e- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); - B f- R# [' W5 w/ Q+ h
- EXIT_IF_NULL( process_template );
: r( K/ K E3 u. n1 X+ d; F& |
7 O, d6 ^0 O1 ?/ g
! R9 H5 x3 k3 x0 I- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
4 }1 Q5 h1 m: q6 |+ F- W - attach_types, &process) );
# }+ t* f. V4 |* X, P
1 g" M* q1 g4 P7 l0 n- EXIT_IF_NULL( process );
/ P3 Z8 Y% X0 t: i/ K - } U. G4 w3 e' J
- ! C t" k. L7 i/ A6 L: \4 r
- int ITK_user_main(int argc, char* argv[])! k9 `$ `8 ]9 Y0 n A, o/ _
- {5 I Z/ k t: p3 D
- int
& ^% p6 }7 g/ u* P( x - status = 0; " |" r. ]' T) w8 V
- 0 M& @4 M/ O+ [- w1 k5 {1 o
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );$ h M% H$ ^" e
- status = ITK_auto_login();
/ \/ k) m3 u; ?% L3 S - & h4 W7 r0 k. D" ~
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
/ p0 `4 j, A+ T8 I1 H8 P# i& c, }8 v - else' g& L$ j( O8 T* {' D
- {
7 |/ \2 D& Q( {/ f - printf("\nLogin successful!\n\n");
9 `9 r% u( |. L& k - ITK_set_journalling(TRUE);
& b: }2 y% U3 t( W7 ` - do_it();
) p, ]- F4 m2 u: j9 }/ H - } v1 m) [' H; H. M3 B8 E
- ITK_exit_module(TRUE);" w; V& R& b! \. [
- return status;
- J0 W9 {& }: a& q: g+ Q- z - }
复制代码 & p$ `0 M8 A' n- V9 v, P" E
6 a/ ]% i" L9 {' B% O. h$ {: O9 ?3 U. G; W# t& C" j' n M: F6 c
|
|