|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 h: ^6 v$ ~7 m" [: V
Teamcenter ITK二次开发源码分享: 创建一个工作流
+ u G: \% E; c* A6 Q% Q- z
/ H- a: ~ g! P! t7 m- /*HEAD CREATE_A_PROCESS CCC ITK */
' a1 j) c; v( a$ N - #include <stdlib.h>
# h2 A: {2 K$ Y" C) t/ {$ P1 T( A - #include <TCcore/aom.h>
2 h1 @. E0 O3 [ - #include <tc/emh.h>
p$ g1 l r9 C/ \ D - #include <epm/epm.h>
7 X' @; |! g1 Y1 O7 C8 ? - #include <tc/tc.h>% ?8 E) Q5 D7 _! k, d9 h) ~( F$ P' j
- #include <sa/tcfile.h>
. [8 Y7 q" p4 x8 G( T8 N; [- i- O* I" u - #include <itk/mem.h>( G: X9 A0 r* ^. o' R
. T7 b* a3 X. @3 I7 @5 r( _- #define EXIT_FAILURE 1 7 A: J4 ]" a& {5 Y
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
9 y9 r" `1 H1 g7 c, X# H- v9 w - static void report_error( char *file, int line, char *function, int return_code)
8 z/ [* _7 U m i4 p" c - {
j) \. s K: P# j - if (return_code != ITK_ok)% @- g6 [# _) C# Z, Z4 e2 E' S
- {
* E9 M( O' h B" F5 F7 F$ ^ - char *error_message_string;1 ]0 |, s, }- ]
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);( O( e1 ~; K' I, ~
- printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);% m* I6 ~9 i6 y" r9 i( `6 H
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
! F9 `3 {/ Z% j: S - if(error_message_string) MEM_free(error_message_string);
, q& P! w( W" m' P5 `" N2 l - printf("\nExiting program!\n");7 ^) N) g- P% W* _7 Y' M- z
- exit (EXIT_FAILURE); 1 Q& ~2 [6 ~$ ]5 V
- }$ ]! l+ }: x8 D' {
- }
/ T( `& g% ?3 Z; W# s& A - 8 {6 F( V9 C. l6 R1 ?" ^* s
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
) I" R% Z1 l% D9 M( o: P - static void check_value( char *function, int value )
& }7 } |1 Q- E0 t7 ] - {
9 k5 k6 I' @6 f. H3 K# U - if (value == 0)
, b ^- T4 ?+ Z( p - {4 S! w$ q. p e1 D( w% g
- printf ("\t%s is NULL\n", function);' t# ~9 ~+ V* v7 I7 B5 @
- printf("\nExiting program!\n");( v$ ^. R$ q/ @# _1 l7 D: y
- exit (EXIT_FAILURE); ; S `1 Z+ L3 h& O* P; Y
- }) X' Z* ^) p( d2 \) ^
- }$ p, w" ^& E( r! I( |
- $ A a1 y b+ Q2 w4 ` c
4 l: Q) ? _4 W2 Z- static void do_it(void)( N) j6 m$ D& H, h
- {4 w3 L- L+ h$ K
- int
# Y" Y0 E; u% G - attach_types[1] = {1};
3 n M- ]; V( K - tag_t 2 M: J, y7 B- m- B) W- t) {
- rev = NULLTAG, ) p) U) s0 o. y& m! a: O# ^7 v
- process_template = NULLTAG,
! ^$ I* Z4 l% ?+ N- a) I - process = NULLTAG;
- n; M5 z+ | d9 t: z: T - 0 U' N4 b2 {6 e
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );8 S( r' ]9 u; M
- EXIT_IF_NULL( rev );* N4 E6 b% r0 z( g% H& N
( p2 k- \0 B$ e; E- l- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); ) D5 [% a# D \; f' b) |; ^
- EXIT_IF_NULL( process_template );
& i& h, q R r+ Q - 0 s, ^ m! E! h4 t# M" K1 t3 G
- ! T) ]8 j% S% q! h8 U
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
0 M" ~$ B$ P( P3 f! ? - attach_types, &process) );
Q* y3 e' r4 ^4 ?5 _% H. W
" }% a3 g+ @: p, A D d- EXIT_IF_NULL( process );4 P& b+ v/ o/ I$ O* Q) C
- }, H0 |7 W* h+ k+ j( \: Y1 x& Q
- : a/ s8 `; }" p2 S$ u
- int ITK_user_main(int argc, char* argv[]), d9 b1 Z* I0 M0 v1 a
- {
$ ^ V. C7 [% ^8 w; z - int
: d: Q5 m2 a( ]! F* i8 f - status = 0;
' p+ v* M7 M# I" U% h, N) T3 |7 y - 2 e0 k8 w4 F( P' w ^/ @
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
) v$ A% N- G8 K6 V2 b8 B! S U; S - status = ITK_auto_login();! G: A7 ^- r' j" W
- : X3 W0 g1 u0 A) I
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");& x0 c% Y5 ^/ l& V! Z
- else. C: C0 z+ k6 j7 j1 W8 x
- {9 C7 z& \2 V, C! G. D+ C
- printf("\nLogin successful!\n\n");
! c1 @) [/ n* Z: s% M - ITK_set_journalling(TRUE);
0 g0 m/ i9 O) M: P8 O6 `. n - do_it();6 U9 z i/ v9 n/ G. g' s. W- ?0 i
- }
/ G w( K2 u2 P- P5 m. ~8 I o - ITK_exit_module(TRUE);+ i: b! T& ~2 Y8 L+ X1 t |3 \
- return status;4 N8 I5 {! p3 A. P
- }
复制代码 1 ~3 T$ o, T: m2 X& f ?
+ j1 h/ g4 c7 b) L6 ^0 U% \
) r: x2 x; O1 m3 I9 n$ \7 m
|
|