|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# k# h0 Y0 F0 d* v4 b/ b; M7 y
Teamcenter ITK二次开发源码分享: 创建一个工作流
# o9 y- `" m+ t7 b; l6 | p/ d- j7 Z& T6 g
- /*HEAD CREATE_A_PROCESS CCC ITK */0 K# y6 h% b; s$ V3 b) X
- #include <stdlib.h>! e7 f$ h4 {7 M
- #include <TCcore/aom.h>
$ s# Y( C7 u! W: ?/ q1 p, c - #include <tc/emh.h>1 \( ?; f- b4 Z/ _, s
- #include <epm/epm.h>
# G5 b$ t4 S) Z- G L# V0 B. Z - #include <tc/tc.h>! q" M) n' o# g# A; `
- #include <sa/tcfile.h>
" ~7 B; r4 E$ t - #include <itk/mem.h>
* l2 A; s- [5 \- ]9 s% Z! z: B
4 a# h2 v8 |* r- #define EXIT_FAILURE 1 % }8 D4 Z% n ^" Y" q: L7 y
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
; k+ l" D6 V; r+ F' i% K - static void report_error( char *file, int line, char *function, int return_code)' P0 X, v. O% g# V
- {: ]5 |0 o* [( [4 g/ ?/ q @
- if (return_code != ITK_ok)
" d- }0 J2 e; K* z* ]. O j - {2 ?1 z, F0 D; w' F( E
- char *error_message_string;
! ^8 c) f& W9 c - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
r% b8 K6 s. x6 ?( \* Z6 s - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);! A/ [$ {0 v h2 I( v
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);: [+ |- D4 d8 @
- if(error_message_string) MEM_free(error_message_string);0 } `8 ?- q2 l4 y* e
- printf("\nExiting program!\n");
( a5 [$ x/ z% H8 {+ | c - exit (EXIT_FAILURE);
5 k! L5 W% [; ?, F# q$ U: f( i - }
: O2 o8 E7 t" P/ q - }
4 Z+ A% ]% W$ A0 R" ] - 4 e/ o; t7 u: a. k/ E
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))9 P- M1 d5 {. G2 u8 @2 ]% O3 q: r% e
- static void check_value( char *function, int value )
0 A2 R. F$ r8 Q - {
; u+ u n& Y, z) Z0 n+ b - if (value == 0)
% ]3 O4 K+ T; F1 G - {1 D5 u& U3 q8 F: k; `0 X% x
- printf ("\t%s is NULL\n", function);
' \8 ~' T: X' A, x - printf("\nExiting program!\n");/ E& b' ]+ b. S" G8 o$ `$ M$ o
- exit (EXIT_FAILURE); + z6 ]6 y2 ]9 ?6 T
- }: g6 g' F' n5 h; Y" F
- }
\1 z- z. F- G- [, h f' i9 c5 R
) A @0 f" m8 z8 c2 I1 Z; K! |- % p; G. [( O' `/ n) `6 \5 |
- static void do_it(void)
3 q9 D, ~- c ]; K3 l - {: ~0 J! P T3 \- h( e; ]
- int 9 }5 F+ s& B! \! w+ e+ N& \' ]
- attach_types[1] = {1};
U% G: Y: A, }' ]; ?4 K" H - tag_t & } [6 o" ~9 _% P
- rev = NULLTAG, " f' Z" a4 ~4 ]4 b7 b7 R
- process_template = NULLTAG, 9 U# [# ~0 b5 W5 x2 k9 y! v9 r
- process = NULLTAG;0 u$ K, b, p$ u
. m9 c, \" [/ F4 ]# w8 w- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );9 S, O4 E3 W9 ~* O( O% [
- EXIT_IF_NULL( rev );. h+ Z: m9 @3 {5 w
- & l0 T2 ]5 K7 h' w" V
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
B& D/ p6 M" b/ a - EXIT_IF_NULL( process_template );
; l# k0 X. c0 B% o( ]: t3 t8 p
3 i" a! O* R% k; q
6 K2 }8 y) _ x) d( c6 s- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, 0 e7 z& V* T7 z. N1 D
- attach_types, &process) );! N3 D9 b9 W+ u( k
4 R, c2 p1 X' m3 j- EXIT_IF_NULL( process );
$ k( @6 d; t: [* n$ W - }4 z, q' V4 M6 }. ?1 \4 o3 y
$ {/ k" j7 R4 C& c G) ~- [6 t- int ITK_user_main(int argc, char* argv[])
. y# N5 Z; K- T5 d1 s" }7 e - {
% c) r3 p& c) ?: S - int
" b+ K1 `$ G; f; `" o w - status = 0; * t' z% v! x0 _7 B
-
& b( z, e g! B: ? - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
- n+ K3 c$ O$ W - status = ITK_auto_login();
# z5 N% y7 B! e8 q9 x - / N8 E+ h! `" m& m# U
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
( ?1 j2 t5 Z) ~% }9 p: |8 a - else4 h6 [3 r4 U% j/ e z
- {& K3 q" E8 i y2 `$ w
- printf("\nLogin successful!\n\n");
$ P1 o( V% c& g- N9 Y8 _ - ITK_set_journalling(TRUE);
) Z2 X5 _) }$ y# e1 P% n; U/ ]+ h$ b; @ - do_it();
[) J, g* M+ c. o2 M- f - }
5 w- q, Z, B/ P6 Q; y1 M! _ - ITK_exit_module(TRUE);
0 x/ h0 N' x( N; f - return status;
8 \" T+ k! L5 S \1 x - }
复制代码
6 F( I. Q" [3 R) N6 o) h1 A) u$ F5 z; Z- v$ J1 f, G
$ x1 `8 o. r! i8 r1 `2 R
|
|