|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! V5 ?- y& h0 A8 n& G" e8 {Teamcenter ITK二次开发源码分享: 创建一个工作流+ ]6 b: D; w- b) m( Q0 w
! J5 ~/ {" [. V0 C& N. g8 Y
- /*HEAD CREATE_A_PROCESS CCC ITK */
0 n" h! u1 C& c# _& ^ - #include <stdlib.h>
; o7 s# k/ n6 u' R6 h- U5 \" Z - #include <TCcore/aom.h>
J. v( H7 B" s" C6 W7 h - #include <tc/emh.h>
* k8 |3 K# x( F1 V! M# a& d - #include <epm/epm.h>
( H& v6 s. K+ @$ {( O. ^ - #include <tc/tc.h> }- N1 z/ B: P6 \: j# b
- #include <sa/tcfile.h>
/ ~' U1 @ H( [7 n. Q6 u6 W - #include <itk/mem.h>8 E/ P# Q+ t$ v
- % k& t0 U8 i& F! x
- #define EXIT_FAILURE 1
! J* @1 ^) z4 ]1 U" F9 [( G7 { - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
2 y2 Z |; a, p% Y- ~, } - static void report_error( char *file, int line, char *function, int return_code)
6 o( p* S; g! h! ~2 l' k* I1 V0 b - {4 R0 E0 T1 F& @0 R& C( K' Y
- if (return_code != ITK_ok)
: h e# c7 L; p. F* g - {
- B8 J8 g& A% Y9 ` - char *error_message_string;5 Q, f' l6 }6 o5 n: E" c; Q+ f
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);3 R! M z' b0 L/ Y! d
- printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);" d4 X3 i1 ]( W/ T
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
4 d6 B( y ~& F - if(error_message_string) MEM_free(error_message_string);# ~" f+ q- s+ Z- q9 @
- printf("\nExiting program!\n");% d$ S+ o3 R' N0 {. V
- exit (EXIT_FAILURE);
8 V5 w' b6 Y& N: @; w( r/ B9 ]7 F - }+ \3 J: k: b' y' b
- }
5 f8 W- `2 G6 t' [ - , f3 c( \! E5 b1 r% N
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
. `% A9 z$ a% ?( t" Z a3 T - static void check_value( char *function, int value )2 G. j) ^$ Z: k. h& M
- {
$ D, K, T. Z& P7 V0 G - if (value == 0); j0 |3 n$ m5 t4 A3 y1 S2 l
- {
& B6 k! m+ l1 o1 k5 n7 g - printf ("\t%s is NULL\n", function);
. [, n7 o/ v- i( _2 n, E) k - printf("\nExiting program!\n");) o/ w I6 O% K: r! _/ l
- exit (EXIT_FAILURE);
: h, k( c# [+ A2 \9 ?2 F' o6 D/ u - }- y p3 J! i" A- ~
- }
+ W8 J0 g6 {2 y - ; D* {/ D- W( i' G. p
1 v& X p* y6 J4 n4 t d& r- static void do_it(void). T% u3 Q' E) `& Z& c# A- y
- {4 F# L# @7 Q2 R# a0 p% w- v
- int
8 K! W/ ?4 t0 \( c" H* p# N) \' ] - attach_types[1] = {1};
2 Z' U% I/ y; _ A - tag_t 4 g* D/ y0 Z5 _ O4 L
- rev = NULLTAG, * `2 |. ^ n/ g$ P6 ?+ J
- process_template = NULLTAG,
D" Z1 K/ h1 S% F3 L - process = NULLTAG;7 p I( ~2 W/ f: O
) c6 P1 ?# o+ L7 d, v0 Z- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );- ^8 S/ @! E. O: n4 u1 V+ Z m% k4 l
- EXIT_IF_NULL( rev );+ B% @! s" Y6 J, D* G g3 B
7 o4 G3 s/ V- a- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
' U5 w, D1 C$ K" ]5 h5 l( b) a- K - EXIT_IF_NULL( process_template );; g4 H: T$ ]; Q5 P- {; V* H$ u8 p, O
. I& T ]6 u) x) ?9 M! e- % |6 K5 u0 z$ N, k6 s3 y8 r
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
0 u3 \9 _+ {$ n0 z - attach_types, &process) );
: |6 C t7 f: k7 n' h - * J# \% O& v' ]# _% W. C- a
- EXIT_IF_NULL( process );) |7 {# w6 b& k0 H! o
- }* p- Q1 R7 [) z) }
/ P t9 s0 R0 M$ q- int ITK_user_main(int argc, char* argv[])" S# b4 v& \6 Z4 U8 @" ~& w/ g
- {
& D! d& h- B6 O) j u9 z - int
& o2 h4 ~" L5 G/ l) b7 x; | - status = 0; " c9 F( [' K6 \3 n; y7 T, I
- % r* p1 n( g2 M
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
6 r3 d6 T' ?3 \0 B - status = ITK_auto_login();
# U2 r) `1 \; v. L2 o: J - ! O/ M" @ Y0 e
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");& G. J% Q- F7 e
- else% z+ D5 ]4 b. Q7 {" Y
- {
! Z2 x, q" g, C! x* O$ p1 q' H0 `8 X - printf("\nLogin successful!\n\n"); @% L v0 U. c! C
- ITK_set_journalling(TRUE);3 x. |. }) O! W+ I2 f' k
- do_it();
+ f8 C1 [& b" Y6 N2 N) w4 t1 M8 M - }' C) t5 ?- ~* m" }, s3 G! q2 r' a
- ITK_exit_module(TRUE);
& S) s8 `$ O1 Y' x w9 W3 J3 h - return status;( K0 w% V! o- ?/ n
- }
复制代码 f3 @8 V/ }, ^* r# g/ p. s& @
* l5 d$ w" l P" S
! z4 i7 y; W' V8 \5 ~/ X |
|