|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 M, {! ~5 X* m- ]8 K
Teamcenter ITK二次开发源码分享: 创建一个工作流
2 Y; y6 d8 m- `9 K, d) _0 D% \" y& B. h, x4 K* `- W
- /*HEAD CREATE_A_PROCESS CCC ITK *// N5 k. x7 @6 K" p3 v! `
- #include <stdlib.h>
, \- i1 P3 }- U+ ]2 | - #include <TCcore/aom.h>& [, N' R h# N( |/ Z; C# \
- #include <tc/emh.h>
/ L% _9 T& U D" E0 S - #include <epm/epm.h>2 M* d4 W( a& ?! E y
- #include <tc/tc.h>* P& F8 p. z( A0 K7 w
- #include <sa/tcfile.h>
+ H% e5 {% z( f R - #include <itk/mem.h>
& w) Y& ?0 ?/ h8 I! y - . E9 {# k4 G# s: D1 `/ T, [% X
- #define EXIT_FAILURE 1
; q2 j+ R* r1 [0 Y1 J1 J. G S - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
5 I7 X7 R- G' a0 I- g. {( ` - static void report_error( char *file, int line, char *function, int return_code)7 v1 h- A3 ~2 @/ e6 c
- {: X: f0 r3 J& r2 r1 l
- if (return_code != ITK_ok)# N0 A9 ~/ Y& L% r# T) P" z
- {
8 G% C. A( e& K. Y+ [ - char *error_message_string;
- D7 U" _% c5 n5 }3 b5 e - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
! z. v l0 ^; A. R7 D- r& ~ - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);: F9 @2 L9 R8 `) g" r! x: a
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);( [4 b1 m2 X( c* Q `% E
- if(error_message_string) MEM_free(error_message_string);
+ y. J( G4 z6 ^' y O - printf("\nExiting program!\n");; d' A5 D" m- |$ c
- exit (EXIT_FAILURE);
3 @: N3 i: {: D7 \ - }- s/ B& @2 R) E% b
- }
% i' L$ v1 f1 B - 5 [" t/ q$ r. N* M
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))3 L0 l. r D9 n; \1 H
- static void check_value( char *function, int value )
2 f) a" e1 |7 @2 ?' B" P - {
8 F- w& q8 f/ u& B% i( | - if (value == 0). J/ ]; g. p5 f8 n9 v: q7 ?
- {% v( B. @+ [ d
- printf ("\t%s is NULL\n", function);3 Y( E& T7 c" k4 V2 c( _: o
- printf("\nExiting program!\n");
& u* ?- d% m) ~5 o7 [+ _* Z/ ] - exit (EXIT_FAILURE); * L8 H; z: x; i' R
- }/ |# a: G) \. q( n
- }! y* V5 Q& }; y$ d3 ?
0 v6 {. C' S2 D- 0 g$ P3 I& T% z6 e* F
- static void do_it(void)) e! V3 k) U- Z7 w' v7 E
- {+ E4 D% ~5 H) X4 U) T
- int 5 @+ V+ Z! o6 S" y! C
- attach_types[1] = {1};5 C9 w6 z( k% ~& P7 a6 |
- tag_t
9 l+ d: u+ j3 W - rev = NULLTAG,
6 w( Y! _# W0 s1 _+ ?# X - process_template = NULLTAG,
4 z8 F! u" m! {! i& O% c - process = NULLTAG;, _8 [! `- I& V1 k6 ?9 F
- ( `( I' E# D! g" F: f7 O# M2 J
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
( a: o1 ^. k( F. w - EXIT_IF_NULL( rev );! X* P2 g( U! a9 k
- : x; ^& f1 }* c: Y* h4 B3 h( J" Y+ i( E
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
" S; Y2 g! k) o - EXIT_IF_NULL( process_template );7 b7 v ^9 f0 o8 S3 v+ N
+ A+ h8 M6 y1 h8 B& y+ d
7 g5 ^: U; o" f7 I9 U. p: |, W- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, 4 c4 V9 W3 `+ C; }! _: C0 w4 O
- attach_types, &process) );
& t0 R0 B! O" ]* h9 j: e& u. t
4 S V- S- G& ?. Y- EXIT_IF_NULL( process );8 ?7 ?' B7 ]0 ^2 Z- `/ G: u+ L
- }
( R3 z( ?+ J/ L0 @! h9 W5 @1 }7 t - . i7 U- h+ @8 L$ |
- int ITK_user_main(int argc, char* argv[]): M9 G+ m. p0 g2 [& v/ Y
- {$ \" k2 H: l6 K3 X9 B3 c+ H
- int7 h6 ~5 e& y+ r& J1 d2 r
- status = 0; - w- Z, K1 S' y/ \. f# e" d, N
- 2 C% Y2 O9 ^& ? R
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );7 u% d- d; ~& P/ b, J; Y6 M
- status = ITK_auto_login();
8 W2 m2 q" G, I7 b - 1 v) j+ B& ]9 z5 G/ p3 ]* @" R
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");% `! w4 T9 b- k1 _5 o& y! C
- else0 }1 @ i! C( E9 y. u+ y% I
- { L! T$ a+ {9 G4 t1 a9 i# J
- printf("\nLogin successful!\n\n");: X5 M: r# o7 o0 Z
- ITK_set_journalling(TRUE);
# w, y! E" f( _! C5 @& U - do_it();
& n# a' B3 R% R# r! h, e - }
/ _4 X! e" p5 G- |* J - ITK_exit_module(TRUE);( Z5 \8 A2 n0 Z1 Q V
- return status;4 w% W, @2 [8 o, Y5 C/ l9 l
- }
复制代码
" k3 t3 v8 N! O0 ?4 a) \9 p0 i, k6 d$ B
4 g* f( }! Z6 J4 P3 T |
|