|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
: K5 b0 @ U" L3 y* H9 X
Teamcenter ITK二次开发源码分享: 创建一个工作流
5 F$ w% F8 v- o1 i s
- ~; ~" p2 a% f/ _* L; W- /*HEAD CREATE_A_PROCESS CCC ITK */! }5 S+ k7 g& q7 }
- #include <stdlib.h>5 ?8 a" {- a; l* n# a
- #include <TCcore/aom.h>* R$ @# H! |+ g8 g) d. d$ M+ N
- #include <tc/emh.h>2 Z4 t& j3 s: D% x: g9 g& n
- #include <epm/epm.h>
2 g/ @& B g# t$ P* X - #include <tc/tc.h>
4 m9 y K, U( `7 \ - #include <sa/tcfile.h>/ s; G: S. |( }$ _) ]4 Q
- #include <itk/mem.h>
2 [) \) j. R2 O% F Z
/ J4 Y2 i. X0 j. {: {- #define EXIT_FAILURE 1 6 r; \) _( v6 u7 g7 k
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
; G6 O( n: Z& @) y) r* @& l - static void report_error( char *file, int line, char *function, int return_code)2 I; R* I! c; p1 y6 t A
- {
" x1 P P, p W. P - if (return_code != ITK_ok): f( C O% a% A. k% l) G
- {
% k# }2 N p& _6 v - char *error_message_string;
3 l2 J9 r& {" }( r& Z! O. K) B! ? - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
1 R/ f, ^# P6 x0 q; l i1 y - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
9 ]$ K/ x( |: a: S/ X* g - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);0 U% E: R D8 D1 i
- if(error_message_string) MEM_free(error_message_string);
5 |4 h+ I5 A- O5 v; {# m: E" _ - printf("\nExiting program!\n");
9 C! I7 n6 _- U7 J' u - exit (EXIT_FAILURE);
: N4 S3 [* c6 O( E: M, n7 O - }
7 P) z9 K S/ n: T - }! y5 c5 E% a) X: x
- 6 x+ I* y: @) i& d' I( i* r( n
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
, ~" {: F0 {, f& U7 ^6 E - static void check_value( char *function, int value )
& j, M" Z: K8 k - {
" X' f+ |3 t' K- s9 N1 G - if (value == 0)# z/ d4 n- T9 J; ?$ S9 s0 U
- {& ?0 t# y& J, D7 n1 g, j# p0 [, ]% U
- printf ("\t%s is NULL\n", function);9 z! d/ t! Z! g( |6 d
- printf("\nExiting program!\n");
% a6 |. ~7 B0 a1 I# \$ ] - exit (EXIT_FAILURE); * b2 J7 J! u& x# B2 W
- }+ I- z' f* ~3 T0 U" P6 c. b
- }
8 t1 r4 u4 d2 T. o3 p* ^; v" x5 ^
7 M; W5 h1 E$ s
5 `9 @9 ?' c) `% }- static void do_it(void)+ `! v3 [$ I o# m5 R7 X8 G
- {
5 a# S+ G% }. P$ M/ E! n4 @! X - int
- P( ]2 z6 I) u& F/ W Q - attach_types[1] = {1};
! s7 m# C; r; H, y q - tag_t
$ {/ C, K2 Y7 s- b: Y - rev = NULLTAG, 6 a/ h: o4 C& I" w d" z
- process_template = NULLTAG,
3 [% R- ~& v- P# p1 k& J - process = NULLTAG;3 A, |; k. N0 K2 H y) z& ]
+ m+ q5 ^& g( S- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) ); r7 r/ M; [7 D. h
- EXIT_IF_NULL( rev );
w w7 Q/ }' n9 p - 9 ]3 |# F! o4 ]5 T
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); ; h" x7 @+ p, A9 M/ J/ r) q
- EXIT_IF_NULL( process_template );
2 w+ x7 I; N! ?. ]4 D h# s5 l - $ @% H0 }0 s ~
7 W4 o% G: u3 J8 l9 ]! h) T6 W- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, ) q+ _, H, [, b' Z* i
- attach_types, &process) );: T4 l+ B& A2 `0 h
3 {" ?) z- L7 E t0 T- EXIT_IF_NULL( process );
" c1 _- I/ o+ p( g5 d- J - }0 ]- K* h% J( h# j. t4 c
! ]* m$ a) z- z. ~2 z, k- int ITK_user_main(int argc, char* argv[])
0 v2 y/ }4 s6 b, G$ p* B - {0 a4 g& C9 L! z/ H
- int( k W1 C+ A ?
- status = 0;
! {% f( F' D: B' e3 l -
. P+ V# c9 w9 G% h1 x: w( Q0 e - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );" S, Q F" Z5 a% T+ ^9 M
- status = ITK_auto_login();" K T# a8 A, _) k( }
- " v1 U, p+ A g4 O- D$ o4 T
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");4 e4 `( p; ^9 z2 h {9 E; \
- else
% @, x& k* {& y9 g. ^7 S; C) w - {
% U6 @, e& q0 ^9 T# K! p2 V - printf("\nLogin successful!\n\n");
! l/ G5 T& I' Z0 x0 j2 r9 K/ t - ITK_set_journalling(TRUE);, m- O' p$ t0 } u1 A/ R8 d
- do_it(); E' N4 g( Y/ R7 C, e
- }
" J2 S% z4 W2 G9 _4 ~) l+ z% e - ITK_exit_module(TRUE);% u! k( s, A( |: h7 q7 r
- return status;( u, [- E) B* }1 L O
- }
复制代码 8 {$ P3 i9 Z6 `
2 Q/ z `) N; S$ H/ R: r& N% c3 q- i P6 z
|
|