|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
' x/ ]$ T+ c; l) zTeamcenter ITK二次开发源码分享: 创建一个工作流
/ ?, S: \: ], I u
: F8 w$ B" ~6 p% I9 z- /*HEAD CREATE_A_PROCESS CCC ITK */
$ M" I1 f+ X" r; `! A/ A8 E - #include <stdlib.h>
. ~% k! O; N. L, s8 W }4 L- j5 l - #include <TCcore/aom.h>
% q6 s x+ |% x3 f - #include <tc/emh.h>
+ l7 {; A2 w1 q! d3 E$ S2 T - #include <epm/epm.h>" Y/ z6 W+ s, Z0 D: [
- #include <tc/tc.h>
* Z3 B' D9 U2 |$ k5 i, A8 W - #include <sa/tcfile.h>/ A) C1 s0 O9 A8 w) Y. s! ~
- #include <itk/mem.h>
* q% ?5 M4 B% W6 w% `2 x+ Y - , L, s; M: y* R9 G/ i) {
- #define EXIT_FAILURE 1 1 C! T4 i3 ]' V; m9 h- I0 ^: `! y
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
- O; k v" J# a7 f1 t9 X - static void report_error( char *file, int line, char *function, int return_code)! _2 `* u8 ~1 u) R
- {
$ J/ v4 s. t O( a, ] - if (return_code != ITK_ok)
7 Y$ }, Z. f( @# @9 ]& J - {
; W" [' O. P% t# m8 t - char *error_message_string;
! F& X+ O( B) I) x- t - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
/ G2 ?% v* _+ _5 ]: }- i - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);& v4 X2 ?9 Q& Y4 P* B
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);! d4 i- a P. h) I! J; s2 o
- if(error_message_string) MEM_free(error_message_string);
" L4 e& y, z7 | |$ _ - printf("\nExiting program!\n");( S2 g3 O5 n2 Z" j% h( i% s
- exit (EXIT_FAILURE); & e4 z3 z% w3 u/ W: @* ^
- }0 \' K( |) F3 x$ u- Y, [
- }4 i! ]1 L: [$ i9 C4 C
- , s# _- w9 S7 G- |
- #define EXIT_IF_NULL(X) (check_value(#X, (X))), V5 X2 K, _5 U5 G1 H) a
- static void check_value( char *function, int value )
' b# v: s) i# ` - {
) \- |: }, _4 N# ] - if (value == 0)1 h: r" o' X% z
- {
% c* O0 _$ I0 |0 j - printf ("\t%s is NULL\n", function);
& _( n9 v* }& O9 O1 O# W- @) U# V - printf("\nExiting program!\n");: X! e. Y0 L: D' D/ I# b
- exit (EXIT_FAILURE);
! u* ^, P; O1 N6 B0 ~ - }
+ v( U; M1 D7 _" o+ R. [ - }: e% L* d/ I+ f6 U9 `9 t
- 9 O* b8 J7 V8 ?; X
- 4 i$ z" A3 D7 S* n7 Q/ C, ^
- static void do_it(void)1 i: a* h! @: y n& O- `) q
- {8 }2 t# e7 G# ^# ^$ _
- int
* q& v0 G4 M% k5 | - attach_types[1] = {1};
) L* ^6 b) M8 w$ @7 B - tag_t + [- Y. d$ w' ] G+ L' R. R( T
- rev = NULLTAG, * _6 f; }9 p0 \5 |) e
- process_template = NULLTAG,
`3 \( ^# v2 p, R! h - process = NULLTAG;
" t' V: {, U3 G0 N% H6 A9 ` - 1 ^# y: _3 l. V: _9 x& P
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
) C8 I+ [: i/ m$ |8 X' Q - EXIT_IF_NULL( rev );9 }+ |0 M8 Y+ {8 k5 |$ O0 P
- # ^ c0 N, i% {/ e2 } ]
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
6 @, M! O9 U$ R; a$ t6 k - EXIT_IF_NULL( process_template );+ l8 V# H6 [ w- w
8 S; h$ {4 @6 h$ h, J* w/ E7 t
# U8 I# l: b5 \" h) N* {- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
- x) V/ v# T: ?% D - attach_types, &process) );% q% J# V7 O- O5 l) |' x4 \
; w# X3 \! c: o1 @" Q1 ?. G+ q1 r8 F- EXIT_IF_NULL( process );
* l1 D1 f+ K) H1 E8 ]! M. b* c - }
5 `. k# w+ |: [
) o O, K0 @! w( Y' J- int ITK_user_main(int argc, char* argv[])8 S; U* a1 Y. K
- {0 F0 o5 P2 I5 y7 j: [) D+ \; {- v
- int% N |2 f S0 r) m
- status = 0;
6 X3 y4 L: ^; j/ |: r# K9 q( r - , C3 A/ @7 x7 N* D& o t. S: X, W" r
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );* f4 q% `3 y/ Z- D* u+ h4 e v
- status = ITK_auto_login();
, R/ _5 `9 g3 l) L -
3 b+ G8 }4 ?% ~) y k& @- L - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");: }5 G6 s$ Y/ y% G( l" S/ N# B7 ~
- else
/ K- k- t9 I' t: I8 } - {
3 T! n2 I% \. g: G" S1 C - printf("\nLogin successful!\n\n");. Q7 n# q0 E) e3 Y* _% H% b U$ o
- ITK_set_journalling(TRUE);. v7 q) c" C) a
- do_it();6 a+ Y1 o8 x, t& s* I- G
- }
! j" j% {1 x$ j - ITK_exit_module(TRUE);" Q% ~- _3 o/ n0 \% ]& }4 X
- return status;
7 N- M9 M7 i# i, t: L) R8 z" ] - }
复制代码 ' v$ t( J+ B p. l" I
8 l' X8 {3 J& j# {" E8 d y2 R" @
" x7 n0 s: @% f9 Y5 b0 Z" J4 W
|
|