|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 @+ A) C8 `. Y6 q$ a* sTeamcenter ITK二次开发源码分享: 创建一个工作流
" Q! Y3 s6 X- H) V: H5 C) A+ m e+ v) q# J- o* e' i/ y2 e
- /*HEAD CREATE_A_PROCESS CCC ITK */2 S+ a! H) c/ l# l: o: r
- #include <stdlib.h>7 l8 D: Q# f& C. i; L& f" v/ u; S
- #include <TCcore/aom.h>
4 s8 s; m6 F+ A/ J$ w" o5 a - #include <tc/emh.h>
8 W) ^8 Z; J+ X2 o* V! G+ q - #include <epm/epm.h>. g/ ~7 H: T, s0 t3 F/ U- F
- #include <tc/tc.h>+ \' j. u+ C/ U, A1 A1 P
- #include <sa/tcfile.h>+ ^+ K) a1 q9 S4 L) R" y8 j
- #include <itk/mem.h>3 [) k. h$ U5 t3 p; s& x G
- - Y# R% m* J: q/ ]# f0 C
- #define EXIT_FAILURE 1
- {7 y- m! W1 X6 Q0 } - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))- Y7 t2 D5 c; I- ?7 ?9 ^" q
- static void report_error( char *file, int line, char *function, int return_code)$ Z- W1 K/ _: ], B
- {9 N6 b. n7 ~; z! j/ c
- if (return_code != ITK_ok)
5 L+ L" L# s9 x - {
, Z2 i7 Y0 n& q2 q8 F& u - char *error_message_string;
2 r4 P- a3 U/ ` - EMH_get_error_string (NULLTAG, return_code, &error_message_string);; ]$ F5 ]1 U% c K. C
- printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
; _' x! {: ]+ h v2 L - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
+ M4 e* V9 B! R6 K. ~6 j - if(error_message_string) MEM_free(error_message_string);. o" O4 B2 K7 U4 X, Z3 z! S9 y* L
- printf("\nExiting program!\n");
! A4 ?! L3 R% g e - exit (EXIT_FAILURE); ) u7 O$ W9 D4 [- o
- }% Q' R! U3 v* h# }
- }
! A t8 v& b0 X+ x" V
& U9 ~; @1 f/ E& J1 _) p) T- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
5 p0 N1 j* m) y, Z! I5 X z - static void check_value( char *function, int value )
3 S! `2 k, M, j `$ P. S - {
! m8 a3 D8 R A% n! y: P - if (value == 0)8 e/ f% p" w1 p, P
- {/ H( k1 m1 p# s% Y/ g3 @
- printf ("\t%s is NULL\n", function);
% Q! b$ b+ Z f! r9 j - printf("\nExiting program!\n");8 p0 M; m* G! g* h
- exit (EXIT_FAILURE); 7 P( ?/ M& _% ?4 J! U, P+ u/ @
- }; ?* N' [; R" D5 n# C
- }. I. W4 y; O o( D, P3 f, r
- ( c8 m, D+ a1 e5 L7 @
- 8 z5 {( |. j9 t: b7 [, x
- static void do_it(void)
/ Q$ d8 K( n2 y) u) I - {
( Q) \3 \1 G2 J4 B9 z0 ^ - int X8 y/ Y" P) j* e1 j1 z
- attach_types[1] = {1};0 Y0 ^9 x7 ~1 B
- tag_t
2 O/ a2 y2 ]8 I% l. h - rev = NULLTAG, * l2 K9 m. T+ g0 ^9 v: y
- process_template = NULLTAG, ! e; ?2 I. D( s4 u" C8 [' O D
- process = NULLTAG;6 y$ ^6 k1 W# }% Y5 a/ w4 P7 A
- 7 L' n6 B# z! b0 h4 t* y# X! N
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );6 T) c' H& _! b# _5 D" ^6 b
- EXIT_IF_NULL( rev );/ W4 t6 n+ M; c G1 }7 m+ ~1 U
- 7 q1 f3 U9 ]6 G1 m2 E" m' I/ o
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); ( p2 u$ c: o! g9 V* m
- EXIT_IF_NULL( process_template );. N6 }$ ?6 `) E# b+ W
- 7 [; \6 D6 S7 ^5 G* D
- ( [, Q, P& J/ _( p: y1 D9 B0 o
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
, p& q% y$ b/ n0 ^2 S- g - attach_types, &process) ); F; c, s* v% k
8 s9 g3 e- [/ ?& c3 C- EXIT_IF_NULL( process );
7 }) a8 {+ @0 z! u3 ?. k - }4 H1 Z! {4 q, G4 E4 a" v
- ; l5 K3 s; _. j [0 z) z/ c
- int ITK_user_main(int argc, char* argv[])
! R; u2 W$ F# {- o9 C& N& P1 I - {
& e) X3 c" @& L) O4 q - int
* u# i K% ^/ Z T+ @+ I - status = 0; 7 j7 e, [6 `; F9 E4 g' A; b
-
, z9 @$ y7 b' E: T3 j# j' e: ]5 T - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );9 Z0 o+ c+ r8 P" m# m, }& L. c T% o8 h
- status = ITK_auto_login();5 K- D- r( ~7 \2 O. r
- . ?$ k! c/ W' D/ A$ _& r2 n
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");- [/ |; C3 t$ @, U+ o
- else2 T) K% n. u; D p* T% D1 t
- {
/ g" |9 L6 `/ E5 X& C - printf("\nLogin successful!\n\n");
/ N+ |. l- y1 y5 y - ITK_set_journalling(TRUE);, N* }' U8 R, q; l- o: Q- D
- do_it();: ?! Q, E+ ^; Q9 o* r% w* ~# e' \& Q
- }9 n" y8 }1 n5 `1 V8 E) z
- ITK_exit_module(TRUE);
3 {; q4 E: ^! Y5 j; Y F- q - return status;
/ L4 m, n1 I3 h* H) Y/ } - }
复制代码
5 _& h# g8 S' \' O; ^8 `+ W' I; g1 d; n! h2 W
: B J3 H7 K) L. j! o, |1 K- D |
|