|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
o: v e+ e6 x% o+ H3 V" T: a! NTeamcenter ITK二次开发源码分享: 创建一个工作流
( H8 C2 D% f3 s: O2 ]
/ X9 A# E8 _8 P% G- /*HEAD CREATE_A_PROCESS CCC ITK */5 ^( i Y8 f; [$ b4 W$ y! S' J8 A
- #include <stdlib.h>
h" N1 P+ |/ O# D0 A% t$ n - #include <TCcore/aom.h>- `, q# S v* g# i% p' n
- #include <tc/emh.h>
6 y, S {. a+ { M' y - #include <epm/epm.h>
' z* _/ m2 r/ m. W - #include <tc/tc.h>
5 }, R1 Z- D$ f/ V! W - #include <sa/tcfile.h>
! G: S, O! H) n9 A' g - #include <itk/mem.h>. R! U5 o+ e8 X0 R% M4 L$ S
6 m/ z2 o! P2 S! {& H/ [- #define EXIT_FAILURE 1
2 ^$ l! R8 h4 E. B - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))& L! f- K3 [+ q* c
- static void report_error( char *file, int line, char *function, int return_code)* \, K4 K0 C8 Q7 d0 E; l! {
- {8 i0 R- U2 B; Y+ c4 C2 l6 Q
- if (return_code != ITK_ok)
3 r m" h- |' a* j* c - {+ |" c$ O! |9 c0 s2 k/ H: B
- char *error_message_string;
# Y/ P9 L, \) I( x - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
) R& G7 S8 _$ J7 D" v1 q% B - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
+ ]; o* Y2 {2 D1 g5 e1 w - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
R+ T9 j! P- r+ X6 L% J6 c I4 d - if(error_message_string) MEM_free(error_message_string);
! u+ M0 S5 C9 [. I) l" b0 ], l: x - printf("\nExiting program!\n");% b/ @; _8 s) {3 {5 s& G8 ]/ p% g# d
- exit (EXIT_FAILURE);
% T5 K# \5 u6 q2 l - }, s5 k* y) a: P; d0 d
- }8 }: D8 Z. F4 C4 K* L a
- % n- m' S6 E' U: O7 h9 v
- #define EXIT_IF_NULL(X) (check_value(#X, (X))); z% @) G m6 O/ ^8 P4 M- @
- static void check_value( char *function, int value ) x: n+ [5 U$ F
- {7 I; [) Z) m. H' F/ L, [
- if (value == 0)
G# L% n4 I" E3 x( m - {
2 m. b5 f* r0 s0 a7 F - printf ("\t%s is NULL\n", function);; h. R. Y; i4 l0 w
- printf("\nExiting program!\n");7 V: y4 H5 [. L' {; }0 x7 V6 S
- exit (EXIT_FAILURE); 2 u# d; w: R2 k a
- }3 P! f" D7 F r2 u! L
- }
+ r6 ~ }. J+ ]" h+ [
. c# k3 E; N. F9 W% p- & k" X& N7 A0 @# K/ _
- static void do_it(void)$ U5 j- _' C, }' I
- {
5 ^# c! }. q& M! { - int
# `. {5 S9 t+ w5 r9 y - attach_types[1] = {1};
! h, o/ k" G& ?2 c( R( F: Z - tag_t 4 \2 |& Q" k4 \" Y, H
- rev = NULLTAG,
# A6 E; H9 N, K6 _0 g% c; h; V - process_template = NULLTAG, . c$ I z, P* V
- process = NULLTAG;8 W. R9 _' d) n6 Z6 Z
- 5 G, V- W. M/ x9 S% Q- v' Z# u
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
- s1 _' n1 u" @. @- b' B! e - EXIT_IF_NULL( rev );
+ i( \% Q! r4 _* J2 L3 K4 I$ ~
8 n( X' U& [0 i; j* s- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 4 u( Z1 Y% B( z1 r0 ~
- EXIT_IF_NULL( process_template );1 x) M) `4 Q7 i0 C# Z, d
- # E! m0 P' i7 J8 \* ^" F
1 T( b# V* S [. w7 {& A, t- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
3 s0 U6 X# w, s& ?* y/ P/ s - attach_types, &process) );
7 V8 c) [$ ~+ w& _
% x! a: u1 D, @8 U& [. f" ?- EXIT_IF_NULL( process );
" Q4 C! x0 D# K1 ~ - }. [' K9 q6 y. \. f( S4 H3 `& i
9 B1 p7 l' |' ~4 M7 K# I2 I- int ITK_user_main(int argc, char* argv[])$ C1 y2 Y" f- I D! U! S* G3 v
- {7 p: c5 p* k H
- int; n( e) h/ K4 U$ F
- status = 0;
0 o' d+ g7 ^: o$ f* C- H1 C - t) a/ q9 Q/ o% h& W: k2 ]8 b `
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
$ r+ c, r; `" b) }4 e4 v, g. ~. f - status = ITK_auto_login();" d' O8 X! u4 H8 j3 @2 I
-
& k4 [6 v* o+ U& w* V8 b5 H- Y - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
) I' g! `. F* A7 ~" T - else7 L: t' s' i* L( e6 v! i5 _% Z
- {: S' E' f% V* S! N, q* y4 u1 v' S
- printf("\nLogin successful!\n\n");
9 X6 N! G! e* s - ITK_set_journalling(TRUE);
( f7 Z3 g" F3 s9 G$ P# L - do_it();9 ]; \6 Q1 S0 `1 f
- }
3 U0 S/ L% ~$ f+ q - ITK_exit_module(TRUE);
4 A0 a! n- a0 b( P4 [/ v+ N+ J - return status;
2 T7 l8 l+ _3 S: n) P2 r - }
复制代码
1 ]8 t: U( J! Z2 t! y: A
6 j( G; X6 H8 E- Z7 o% D, R1 m# j$ z& ^9 p
|
|