|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
* d% n( U$ R% k) }' Z7 b, U+ U
Teamcenter ITK二次开发源码分享: 创建一个工作流
5 I" q! N% ^9 _$ {& ? y V& k; v1 ]
- /*HEAD CREATE_A_PROCESS CCC ITK */' V* \% _! g4 i5 K$ x o
- #include <stdlib.h>$ @/ Q ~: U3 Z) z, u7 ?4 v" J
- #include <TCcore/aom.h>
/ r G w: c) p! c# f - #include <tc/emh.h>
: n* _, o; i L* v - #include <epm/epm.h>
! p6 |$ m6 B" ]* m0 `+ _4 i - #include <tc/tc.h>
( l( k7 w4 k& P: h - #include <sa/tcfile.h>/ `5 V! U5 D& P
- #include <itk/mem.h>& j9 j1 ~8 ~7 y$ L8 M. n
- ( Y1 |$ ? W2 H5 v2 _9 v
- #define EXIT_FAILURE 1
# b. w" t/ E" {: W2 T - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X))): x: Q/ y- k2 R V/ q3 O( R; E
- static void report_error( char *file, int line, char *function, int return_code)5 H/ I1 S% J& O
- {+ V8 D. f" k# K; R
- if (return_code != ITK_ok)3 c8 \% x4 _% `' K: o
- {9 x: c5 w }% E4 q
- char *error_message_string;
; F& e0 E6 \2 O( b- P! \* ~" M - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
, d5 p2 x9 ]3 ?7 b, m( d - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
1 z) w- [4 ~- G5 O. n! o; f - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
6 B+ j; N$ v3 w4 | - if(error_message_string) MEM_free(error_message_string);
* K" g3 s! ^0 e* O" F - printf("\nExiting program!\n");
, F) N/ k3 `3 n# \# n& Z+ K - exit (EXIT_FAILURE); . Q% J6 Z, F, i/ `6 A
- }
" o; o6 E" D. | - }
" O8 u5 T( l3 m' E0 A8 c& _7 u - 8 F ]: t1 q8 B' d5 \3 f: V
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
q$ s$ j3 d k - static void check_value( char *function, int value )
4 |3 n% c6 A% ^ C7 h/ t5 _ - {
& ]! ~2 u; ^' L* `. l3 m - if (value == 0)' L: |- ~: w! M- L* W
- {) B( b9 r3 X( n; F+ ^; A) c- F& _5 {
- printf ("\t%s is NULL\n", function);
( O/ O/ a6 x7 U# u# g - printf("\nExiting program!\n");
' c! y$ U) e0 O1 R - exit (EXIT_FAILURE);
: R4 k3 j1 L! k' ]( c( ? - }
5 e/ c2 P3 D) h+ F2 }. b( ^4 [ - }! `4 T( B- h; c8 m( w
- ( j/ y# z/ R, \' ~7 Z, x7 l' O& R
- . w' }( o2 a# P' I' ^# P
- static void do_it(void)- J* H- {( X' w9 a: _: U
- {7 r' C+ \& n# z" s4 b4 l. r4 `
- int . ~4 c$ ^% j8 ~& {& c) Q' a% T n
- attach_types[1] = {1};% h ^3 i: }3 S3 e( [1 X# h w
- tag_t , h. {7 B7 x" W4 H: f
- rev = NULLTAG, 9 z1 r. d0 P, \4 {) r
- process_template = NULLTAG,
$ N( A# q7 R6 \0 ^ - process = NULLTAG;
5 L* L: l! H u: i, z z# s) L
( g$ ]) n9 y: t9 ~- a- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );, S, l4 y2 l" M, x7 k d/ G) C
- EXIT_IF_NULL( rev );
1 a& {) {0 Y7 K9 s7 F$ j - : y* s5 t- Q2 g, Y' N- a
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
" t: c1 o0 K9 L5 b M - EXIT_IF_NULL( process_template );
4 o/ @* l/ W5 o" S% E9 a6 g - 3 C4 b3 c: E0 d/ N" S/ b
- 9 p( `# N( A# P* r
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
/ _5 j) p/ f: F - attach_types, &process) );& U; O, L6 }3 Q( E# t4 {
- ; N" t1 d% j8 m6 c2 k/ b) r: c# F
- EXIT_IF_NULL( process );
' m: L: i0 D0 ~$ x0 p: U - }
! m0 P8 F3 k( J" d8 z* N3 b - - |. C" P) L" x7 v& m
- int ITK_user_main(int argc, char* argv[])
A4 M0 a/ V* `& d- C5 z" I: }+ T! q8 C - {
4 K$ ~7 a. k; X; r5 K - int
2 A, @+ I! b& m2 s - status = 0;
' x. l( L+ x/ y9 w6 L! [' U8 v/ q5 _+ v+ x - 1 k1 d4 e$ N7 ]* M I3 M
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );# g/ _ ^) W3 O
- status = ITK_auto_login();
2 c, ^- Q1 X; p1 n - ) r% V' g! X' L* L
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");, M* c# S$ y' ?& L: z9 L' m) T
- else
- T; o9 J# i+ g3 D - {9 }- n+ o( o6 V8 Q
- printf("\nLogin successful!\n\n");' O( u, n5 E: ^7 T3 ]1 @" {
- ITK_set_journalling(TRUE);
# l2 g- S0 u( J$ g% ~1 F7 [. U5 B - do_it();
}! p0 Q9 {2 S: M3 o$ U$ {- d - }
5 q2 J) H/ F6 p( N+ l* Z1 q - ITK_exit_module(TRUE);
! Y: n: M. r; Z* Y" r - return status;
; p+ n6 o- a% Q* s1 a- k0 _7 r - }
复制代码
$ K) [ p* `3 {# h5 s* ~
) e/ {& y2 z4 H5 v8 b
5 V/ y/ ~* J+ J1 F9 g* W |
|