|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
{( K; {8 P8 {* X
Teamcenter ITK二次开发源码分享: 创建一个工作流
; z/ m& [( ] \9 {! O
5 B; u/ B: f0 h! v% V- /*HEAD CREATE_A_PROCESS CCC ITK */
, R# q. p1 `4 \( z$ N% N( M# F - #include <stdlib.h>
4 z0 V. [' r- \; q - #include <TCcore/aom.h>
/ [2 m$ B0 A7 `& O! t) l" g, u( ]# Y# e( r - #include <tc/emh.h>2 k! D' d8 r/ Z
- #include <epm/epm.h>
! D+ b% \& @% w) U. c. ?! s - #include <tc/tc.h>
d. ~8 u7 c5 Z1 |; ^4 T [ - #include <sa/tcfile.h>
# u# y5 T! I; u+ M; {, d - #include <itk/mem.h>5 E/ | R0 O6 K, C% U# E
- + D1 t) k# l w: n% k( K
- #define EXIT_FAILURE 1
8 ^( j2 M- w# M( u; e - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
) Z/ t" E& {, V - static void report_error( char *file, int line, char *function, int return_code)
2 D; `6 J! m( P$ o+ z - {
$ i2 d( n! v* B - if (return_code != ITK_ok)
5 ?3 `% a' t: O' | - {; y$ _$ i; f% L% G. F& n
- char *error_message_string;, s% q$ O' O- f# \
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
2 d( @: {. t/ m6 C3 \8 l1 I6 y6 V - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string); q% h+ \% j. b R
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
2 \* E( P ^- }) E3 r - if(error_message_string) MEM_free(error_message_string);
' W ^9 j9 e$ a) L5 z - printf("\nExiting program!\n");, x2 g; f# z8 y( m7 D
- exit (EXIT_FAILURE); & r5 g5 r/ E" K- ~% h8 D
- }
# w9 r2 z; }4 d+ Y* g - }
3 Y( c1 T2 i# A6 Y
, n) C) z- I8 k5 i) Q& N3 g- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
1 J. X. Q. X y& p7 T) j - static void check_value( char *function, int value )
9 T- O5 }+ g+ f( \) H! ] - {
: E$ `8 X7 t" T8 o+ n% n - if (value == 0)
3 h& k. S! w3 I6 g1 G- } - {- ?; J U) U4 S; i$ f# {+ k
- printf ("\t%s is NULL\n", function);) A2 Q: T# Y3 S4 o- m
- printf("\nExiting program!\n"); q2 L* U e1 @9 ~- c4 H: p7 L
- exit (EXIT_FAILURE);
0 n, v5 x( w9 z' }5 _ - }; a B' d& o! Z, m7 T
- }
# M& l2 k3 M7 p A* s; _
5 T- r, ~- k& m+ r) ]- % M1 Q, x% g6 H' i
- static void do_it(void)
2 Z3 _4 x6 [; f2 ~& T, X4 x - {
) y: s! S0 } W% f& {5 X; C- J8 h - int % {, Z$ S9 H2 [- V d+ e
- attach_types[1] = {1};
0 h+ D- a% E; H6 E6 d. R0 v+ K - tag_t
, }9 R8 C! ^1 D7 l1 D. U - rev = NULLTAG,
. }1 Q+ W) t4 K; {8 Q5 @ - process_template = NULLTAG,
# K: H1 d( k8 g - process = NULLTAG;
& R& }+ T+ }$ s/ H) w - ) u3 v& C- U; m' S" Y" h3 D9 V
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );3 p. u" M6 d. k/ }9 Z7 L
- EXIT_IF_NULL( rev );4 |& p$ x$ h# ~1 A5 T
- [( v, ]! n5 C& @& Z6 J- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
$ ]8 Q% ]3 \7 m; K - EXIT_IF_NULL( process_template );
7 F+ a6 J3 m; |* q5 d" F, M
3 j+ n& {& }, ~4 |
- t& t6 O5 F$ }% y9 g0 S- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
+ w# f0 y; ~* z- l6 R; d - attach_types, &process) );
" }0 Z W8 `5 t - 8 \7 c0 s! ~1 R. r* K
- EXIT_IF_NULL( process );
/ M8 ^* @# d" P6 f: c6 e; J" ?7 u - }7 m# F% [- p2 Z; h/ Y) C
" P! i9 ] w/ Y; ]- int ITK_user_main(int argc, char* argv[])8 Z/ ]. |6 w9 @% }. w- t) u) U( i5 @
- {
( o+ G4 L B I: ~ - int
- P# F+ o$ e8 c7 V, y9 N - status = 0; ( J& Q) }4 r" M1 t; `3 _
- 2 S: X1 {2 X! l {) J
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );! r2 l+ `$ r! w
- status = ITK_auto_login();; C# b C3 [/ k- Z- l
- ) S+ r; Q, h7 i# r- v
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
L) {5 w# \( M3 z4 U; x; T - else- ^# |. y4 ~1 `$ @
- {
( O& ]: }: D9 j4 e+ w: P5 h. v - printf("\nLogin successful!\n\n");3 l) R/ _! B o" w4 J( r' ]
- ITK_set_journalling(TRUE);
8 q% m5 N# w) H4 T5 U* ?, |; g - do_it();" J- z# ?: D4 D' U# E
- }
) A) b0 n. S! Y, a. [ - ITK_exit_module(TRUE);! s( R/ |& y9 _1 m" v
- return status;
; s" c( W+ V. o0 S/ p/ Y- Q - }
复制代码 4 h4 h- V; O3 n5 P6 t9 \8 F
: } ]$ P/ R2 H ?" l0 T+ ? z, c
! U9 P' {- e' i5 E |
|