|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
; O9 m7 E, h0 l, A- Z( v; r8 R: o7 T
Teamcenter ITK二次开发源码分享: 创建一个工作流
& t1 m8 M7 p# b' h
$ W0 m* A H8 m7 T" [6 ^- /*HEAD CREATE_A_PROCESS CCC ITK */& a/ R- y+ j0 F. i: i, ^
- #include <stdlib.h>4 @: t* r) n9 k$ `0 o
- #include <TCcore/aom.h>+ ~- {- M6 }* U6 N, F
- #include <tc/emh.h>. }5 [5 R$ f/ l. I; M3 d6 M2 X' O
- #include <epm/epm.h>
$ k" {& s: g) u* Y/ ~6 l+ K - #include <tc/tc.h>; Q2 D5 v4 U# n! P( C, ~
- #include <sa/tcfile.h>
8 u, O5 j+ j! F3 c4 h0 S; ~ - #include <itk/mem.h>
) n* C. d# @" K, m+ h - ( M/ J4 G' o; D& ], S
- #define EXIT_FAILURE 1
% T( b4 ~* `$ Z* x9 u - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))1 ?. P9 {5 t6 e% L' a) I; ~7 |
- static void report_error( char *file, int line, char *function, int return_code)
' g# ?8 o1 P) I! T! j( i! S - {3 I( u h6 d: O9 G4 c% O
- if (return_code != ITK_ok)
2 j$ |6 m) e3 W4 ? - {
4 |; H6 x9 _6 u5 y# t+ K6 t - char *error_message_string;
' {0 K6 M3 m! [) [% \1 W; Q' T - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
+ n9 c. p( R# s) A _ - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);( _5 V. i9 y5 P% J- m
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
7 y. @2 `8 P z6 d/ o# W- ] - if(error_message_string) MEM_free(error_message_string);. N" e' o2 o" z0 p: W% U" b
- printf("\nExiting program!\n");
# s& N/ }; `6 B - exit (EXIT_FAILURE);
; e& @" r* P# K8 ]; r7 z/ R& l - }& p, s9 L# O! b# Y3 C* C
- }) H4 R* B; h, {5 S' L8 c
- # _+ F% y. N* S# {, `& L* z
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
7 R3 D! d7 S1 ]/ [ - static void check_value( char *function, int value )" n% Z) m% V+ a- b& m F, L- R' L
- {
/ }: a! v9 N& o6 e! F - if (value == 0)' t/ r0 Z3 |! @7 D1 ]- x
- {
0 D% q2 g$ T5 Z1 A - printf ("\t%s is NULL\n", function);) M; [ r/ |' q/ e& O3 {& @
- printf("\nExiting program!\n");
8 f/ k: U x- w) f, v2 x. L - exit (EXIT_FAILURE);
1 T! w6 K) ]6 B$ p) D - }
% ^) V9 A( C5 r# R - }
1 P3 T: c$ t' k m$ c; h
) a+ A7 W( U! I- 8 {2 ]' Q4 L8 j6 b1 X
- static void do_it(void) Q; Q; @6 i* `9 ^- q% X. g
- {8 p) y; a$ L$ O. `6 R s$ \
- int
! Y: y+ a% \% b" [2 O - attach_types[1] = {1};
4 W! O$ t1 ~" g- {, m1 w3 k - tag_t
; `& ~0 {& @" Q2 G, I! I- a; e3 c - rev = NULLTAG, & K% u# S* m/ I ^/ M
- process_template = NULLTAG,
6 d; W% u/ w9 r r f4 \ - process = NULLTAG;
+ c7 _1 V& ~4 W
% h$ ~" V( b0 Z8 W- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
% S* z0 g$ W9 v& q) k- s% q- W - EXIT_IF_NULL( rev );
" F6 ~( }' |: z
" Z% y! y: y* A& f- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
2 n1 z1 B2 L, U% [( B& ~ C& N - EXIT_IF_NULL( process_template );
( `- W5 W5 M9 o/ P2 } - ! x$ \' a4 k6 Z5 }
8 w0 [* G+ `8 s+ D% ^- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
3 \6 F3 p" ]2 H, W8 d! l# X: u - attach_types, &process) );8 l6 o: h) Z4 f( W* p" t
+ f& M t$ _) U- EXIT_IF_NULL( process );' K! H. }8 Y: X0 X# p) O' y
- }
( @/ H7 \0 }; {- V8 ? - 2 z2 w; W+ r) Z5 ^, R# g
- int ITK_user_main(int argc, char* argv[])7 b5 Q& B$ F! n2 j0 t# z
- {
# q1 d& y: y. l6 O) b - int2 O& Z% B+ H \ f- S
- status = 0;
+ b8 D' u, P1 E1 n: L -
$ Z- h9 j7 Z+ r- P - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );7 ^4 o* i* s( `" D3 O. q4 W
- status = ITK_auto_login();5 F/ E' B8 k3 e1 H4 Y$ m R" w; q
- * u; I: I" s3 {( @
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");1 y0 N, U# \& @8 g: i: d2 B
- else
f' i) o+ ]8 l# H s5 O - {6 `( r) U @/ r! m' B/ o
- printf("\nLogin successful!\n\n");
% v; j) Q b3 m7 u# A7 g$ A - ITK_set_journalling(TRUE);
" `3 b6 M4 _+ x" D$ t& G - do_it();
2 ?4 C) Q8 C3 ?% ~) z0 w - }* S+ S; e4 m9 F
- ITK_exit_module(TRUE);! D8 Y/ y1 ~& w! v2 E# }, M
- return status;# d5 C7 _. ?1 k1 N, Y
- }
复制代码 & ?# X6 F, T& E; d8 s, j$ ^1 r
. S6 J8 k* h; Y- u
$ ^# ~" p9 b) x |
|