|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. A* k. `+ n/ E6 C& E6 nTeamcenter ITK二次开发源码分享: 创建一个工作流
1 E4 ]1 d* h7 y }! d4 w
" O# h* f2 @1 ~" O" A& c8 d- /*HEAD CREATE_A_PROCESS CCC ITK */3 K% A9 t! D0 p' M! C
- #include <stdlib.h>2 @; [5 z! @, |5 B9 S; O- I
- #include <TCcore/aom.h>2 m# W2 r2 u% Q6 Y0 l+ I- F
- #include <tc/emh.h>; n' H9 I S* t5 ]* W) r6 ^8 I: G
- #include <epm/epm.h># W+ ?0 u7 S. Z. F+ W
- #include <tc/tc.h>
% P; S, N" x2 Q$ U$ ~, a/ X0 R - #include <sa/tcfile.h>) a" s8 w6 `% _. z7 A3 j
- #include <itk/mem.h>/ k+ m& M. n& Q% a; J+ O! N
- ' J# ~; D3 z v+ a0 r
- #define EXIT_FAILURE 1 ) ]+ D3 O. `: t9 }) ]- Q2 v
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
# X4 x+ k# L- w/ _8 x: i$ L+ ^ j - static void report_error( char *file, int line, char *function, int return_code)
' W* c$ E- _ m, n4 }8 V$ V" Y4 r - {
, E; E( v. E; K, b( L0 t6 c5 J! u - if (return_code != ITK_ok)
( p' j3 U& R& T+ Z+ J2 c( `9 ? - {+ x- U% a0 I E( X2 b9 [2 f
- char *error_message_string;
$ i5 |1 j2 _" v* s - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
7 G& y! i2 h! p' O- T9 K2 m - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);1 \# O2 q, T& L+ e0 t* R6 z
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);0 G2 L: i# F$ k; L+ X5 N, K# v
- if(error_message_string) MEM_free(error_message_string);
' x( W! P% H2 z- M; Y# b+ E - printf("\nExiting program!\n");/ @( S" Q0 T6 ~7 \6 S& v2 e
- exit (EXIT_FAILURE);
; Q; X0 {" H: c1 r8 a( A2 | - }
D' u* y B5 A. s7 q - }
. F: j: v; ?% _ - 0 C# c% e2 h7 C6 V
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))$ n7 Z e* G& d/ m; s$ x7 K
- static void check_value( char *function, int value )
- t1 B& H( v& L! ` - {
( c) c; H; @+ C* _' R. M! v7 n, ^3 O% B - if (value == 0)
/ v7 l) \5 E, m! A. i5 D, _ - {0 L% U' @- D0 t; D
- printf ("\t%s is NULL\n", function);
$ C! B8 C6 |3 @& X3 F) `9 C - printf("\nExiting program!\n");
3 N( S6 `8 t) q/ Z/ ~ - exit (EXIT_FAILURE);
1 Z3 ~6 V9 X) P; Z* f5 f1 T8 p - } Q$ D- c3 G) l! d+ X7 f" L0 V
- }6 n7 B [( I. _
9 @0 ]- i# T1 ~8 W% k# h
8 U8 g/ x, T6 X- static void do_it(void)
5 t, _3 Y; N6 t4 O/ |" y" _ - {( ]4 Y' m, c# m$ K! E7 {/ S6 }
- int # W4 I# \0 p3 a$ R0 A! @9 L
- attach_types[1] = {1};
! M1 b# b( ?8 H - tag_t
) H* g" _. @/ `4 B1 h* _4 I; y1 n - rev = NULLTAG, ) f ?. Z" F* w6 z. u
- process_template = NULLTAG,
9 B; E: N+ W4 R7 V/ t( c - process = NULLTAG;
0 s: R# f. {0 a* I - 9 q9 X: H. s! N9 `; m0 w7 j o& i
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
1 ^+ s/ }/ S5 Y% e0 n. U8 Y" m7 r - EXIT_IF_NULL( rev );
7 J5 Z4 j" ?+ f* s$ ]% o
0 ~ p' B2 @; @8 G0 A" ?9 f4 f- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); ) E( R4 P5 R& {5 @
- EXIT_IF_NULL( process_template );5 p& k+ K2 X/ M$ X4 r2 A- b
- ; Z; P; z% `9 J' [
- + r) k3 E) r1 T2 R. A' N4 w5 {: G! a
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, ) H8 P( v4 C4 M- Q# v
- attach_types, &process) );
# _5 J: c$ }: l7 K. r. p' P
' P) _( N; M$ ^4 l- EXIT_IF_NULL( process );7 e* x& Z/ S5 X) p
- }. H; E% U i" V* x
- ( \" y1 ?) `5 _! n4 E b
- int ITK_user_main(int argc, char* argv[])
2 g) C7 T& _/ |7 L1 m8 `( O - {
% N$ G" t, S- u$ G4 k' H' p - int
( p5 U! @/ ?1 h1 a - status = 0;
$ X9 I/ i; e4 W! t* K' b4 O - 0 M" A# E ]) ]9 o% c( q
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
/ R: Y( n4 l4 v) O - status = ITK_auto_login();
9 T; u: K; U; h1 x3 w6 ` - ! A; d5 R' c) \/ F8 o8 d
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");3 ` y+ m7 R, F1 Y- `
- else
q2 ~. R1 w7 N8 N" ` - {2 k1 z# d2 u( T2 S9 T
- printf("\nLogin successful!\n\n");* k9 h, q/ \" q1 k. ?
- ITK_set_journalling(TRUE);
! u- X$ z* _$ t- L/ ~6 x* \ - do_it();
$ A0 }) `* G( o% j* f/ E2 G1 w! r6 _ - }
( J) A1 i( N7 o2 z- A6 U; `) s - ITK_exit_module(TRUE);0 T1 x3 ^# x% a0 T
- return status;1 u! S0 c/ t7 J, s! d7 G; L, e
- }
复制代码
/ E' v7 n% S# V( k- A0 ^0 @
- y3 Q5 j, Q" P- x
" f4 N0 S2 r; A3 N2 D( _: k |
|