|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, E0 U6 r! c; G# t* W) \/ e+ ?Teamcenter ITK二次开发源码分享: 创建一个工作流
0 c0 }! V4 b0 n: L" K {0 x- Y" Y1 u; x$ W6 r
- /*HEAD CREATE_A_PROCESS CCC ITK */
& \+ }/ L/ j, z* U8 z - #include <stdlib.h>- R, Z! b3 [, x' V4 o0 K9 o9 W* u' X
- #include <TCcore/aom.h>. V/ G) E5 I. ~1 g
- #include <tc/emh.h>7 ]! p! O) p2 o# d: q
- #include <epm/epm.h>
' w6 |/ I2 Q8 e - #include <tc/tc.h>7 L; V1 r7 K; q, g% q: I4 L
- #include <sa/tcfile.h> @$ _! a9 R( E- V9 ~, U! y( u
- #include <itk/mem.h>
% [ ^! _' [1 W( Y1 Y* ^
7 d% {- _# I$ e6 W+ K# Z- #define EXIT_FAILURE 1
/ y8 Q. D u0 x5 c - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))* e! ~! m( B, f8 T
- static void report_error( char *file, int line, char *function, int return_code)
- Q+ l& z+ v( I) x# `- x - {% A' l+ M' [8 K/ j
- if (return_code != ITK_ok); y8 T- z+ {6 i- Q
- {
' S3 S8 l, b+ L# l% G2 j0 n - char *error_message_string;
% B" K4 q" B1 B& S4 ] - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
5 V* H% O* v2 |" g; W$ K+ r - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);6 h8 e8 j3 w! g2 {' x& M# n' j# E
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);$ V. _; x6 x- B6 J
- if(error_message_string) MEM_free(error_message_string);% m3 d8 P1 e" m( A% m
- printf("\nExiting program!\n");+ j: u0 ?2 h) A, i4 K- Q t3 _* m
- exit (EXIT_FAILURE);
/ E1 C4 D9 C& V! N: Q - }
8 o$ ~$ f8 I4 X( z: m# I - }: R" p; Q" E {6 c( K/ }. o
9 B. Z/ X: x& q" H" q- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
# y9 [9 D1 T/ Y. x5 O, f/ z" J - static void check_value( char *function, int value )
) K0 a5 W, s, D6 B1 L - {
& p1 z4 Q* x" P1 c, Q - if (value == 0)7 K' B. d, ?. i0 W: a
- {
# F( q2 |, g* ]% h - printf ("\t%s is NULL\n", function);9 O3 h8 w. ?: }
- printf("\nExiting program!\n");, L% d. V" b2 k3 {) r
- exit (EXIT_FAILURE); 2 x+ P I7 j2 K( A! f) r
- }. `6 f4 C# ]+ U* D" h
- } Y m2 I5 ~! R: j: |) L5 ~
' d" _# s8 H, {! c2 X
' p2 L4 F0 d7 ]0 L+ L5 h. T- static void do_it(void)
# T2 N% C7 A: O; Z/ g3 Y - {
! ^1 ^5 w( P+ r - int
6 z( n" n# A6 ]" T: ^ - attach_types[1] = {1};
9 d4 z b7 [6 w) B$ r5 h - tag_t
( I, k' J# {0 H( e) i# U6 W2 Q - rev = NULLTAG,
0 i5 U: S, j/ Z1 U8 V - process_template = NULLTAG, & {1 _3 {6 ]' L$ e/ M4 D
- process = NULLTAG;4 K* ?$ J( c, x4 `2 N. M
" X: \" s8 M6 q) S! J. c8 r5 @- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );: d( C& o8 d% Y6 ~" S
- EXIT_IF_NULL( rev );; L9 M, _2 W1 T8 a( H1 n+ C( w
0 N7 r" B3 J+ B" i- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
$ d/ P2 @8 x: b" P# h/ Q - EXIT_IF_NULL( process_template );! y1 r% q7 Q% x
0 Z; w% n9 v" q) l" w9 H# F; [# v- ; D2 E/ h1 r0 d4 e. |" O
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, # @( X9 C, A9 G1 ]) @
- attach_types, &process) );; B8 n7 u+ B8 X1 K) N$ |
$ n# [0 E h- A. V& n$ ~- EXIT_IF_NULL( process );: o! M! x w4 w) ?& q
- }# O2 E6 h% {. p
) S) s3 A5 N' C! D8 @9 r0 A; C* O; Q: L3 d- int ITK_user_main(int argc, char* argv[])- N7 S- x5 K+ O, h4 j- v6 g
- {
3 U7 ^* N5 T1 v- \5 ]5 Z - int
; ?% ` Y7 P3 L: q' ^, P5 H - status = 0;
: b1 `$ [9 Q' y5 z/ H - ) U6 E6 W( q7 Q. M8 p0 H, u7 b
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );# L# ]. D: H1 N# B* Y
- status = ITK_auto_login();
: _( ?3 x* y* F2 y- w - ; k% l5 ^" o$ ], F' D
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
7 A n: [- h# {2 e! z" X4 T* h - else
* ~1 n- I+ d. s4 f - {
2 N _9 j- y/ u% G, ? - printf("\nLogin successful!\n\n");4 {- o; @, J5 Q1 o. e! R- Y
- ITK_set_journalling(TRUE);
/ B4 w; B5 x0 c8 l - do_it();
) O1 m0 [' d& Y& D! @% M - }% ^2 q4 f6 Q+ l% P
- ITK_exit_module(TRUE);8 ]7 n& N/ [3 Q' X
- return status;
5 W1 q; g L& ]/ g2 K( g# h - }
复制代码 % M& ^( Y3 S: W$ V% o/ H$ }7 w" Q
6 Q5 s4 Z, z* [1 {* n4 [2 _3 ~& V
2 ]5 L2 S3 }# o" H* a |* U |
|