|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- w, e0 |( y+ PTeamcenter ITK二次开发源码分享: 创建一个工作流* A5 ~( k+ f* N3 }/ ?
. x7 V; P R3 Z
- /*HEAD CREATE_A_PROCESS CCC ITK */( s0 W5 y# M5 D. C
- #include <stdlib.h>
1 ?& [- b: R1 z2 l( j9 _, O) W - #include <TCcore/aom.h>
" ~+ u( i4 I8 W, Y4 k" H E - #include <tc/emh.h>
: s0 L) |. O7 }2 ] k/ Y, ` - #include <epm/epm.h>
' m9 q8 D/ |4 X3 d: Q% B! I" n* P - #include <tc/tc.h>
c8 Q+ V! F1 R' r6 ]. ?* n! f - #include <sa/tcfile.h>
. J" \* s( M4 S C! n0 A - #include <itk/mem.h>; `5 W, T& m1 p* \' S9 F( p
0 Y# m" l: {/ k) C6 g2 ]9 ]- #define EXIT_FAILURE 1 9 c- S' G0 d4 h* h- M
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
1 G5 D0 h, S0 T* h) K3 k3 c3 P z - static void report_error( char *file, int line, char *function, int return_code)
. K. V* F8 b# Z; p - {* b* ~6 l j. _7 ~
- if (return_code != ITK_ok)
$ N! ^: J+ D) p; P - {) k# ]: @& d- H# v* q$ U
- char *error_message_string;/ `( u+ Y) m/ n. E
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);$ N4 N- C) ^) i6 x; K
- printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);. r/ K0 u) o7 |7 s/ l6 [9 q
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
6 O9 t$ K0 a$ \' a* M - if(error_message_string) MEM_free(error_message_string);
* _8 X, G* {5 x& ]5 H) ]8 K& z - printf("\nExiting program!\n");% Y# p6 p; {1 w
- exit (EXIT_FAILURE);
9 Q2 i; z& v- k) d1 q - }$ a; `" o& {$ ^# w" f% Q0 U
- }7 T. p) t& ?' |3 `- o
- 5 I u- p: B& E
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))1 R/ M5 r: j3 a C- y
- static void check_value( char *function, int value )
; n& w8 i1 U- ]/ m( b* Q1 L, ~$ A( M - {! D' B/ a# m0 j$ E
- if (value == 0)& `- I P0 [% b3 d: J4 R0 s
- {
v2 a. n; n" v. j" `+ [, S8 k - printf ("\t%s is NULL\n", function);( C8 g; g; U3 P: x6 f: E5 E
- printf("\nExiting program!\n");/ v C* H1 q8 u. O" S" K" k3 Y' o n
- exit (EXIT_FAILURE);
" M/ j) ^4 p/ m E - }
+ ]: h6 R9 M! F$ g - }. Z: T6 G9 k$ M# ]/ B o2 }+ S
; I. l5 E! N4 B+ \+ k5 e5 w- : u% j% s8 M5 A
- static void do_it(void)
( w& r& {) N, x8 x- ^, E f - {
: x; ~7 b$ q8 B ]2 T5 v+ ^: i - int
+ k) k/ T0 Y1 r9 v - attach_types[1] = {1};
! ^* Q D8 f, z: h! g - tag_t
# J# x3 s7 o/ h5 n. W - rev = NULLTAG,
7 S: I- \* f! B4 l& z2 W - process_template = NULLTAG,
* G" m8 H; N1 c$ \- M - process = NULLTAG;
& s" K. T7 t, B4 o9 @
& {7 y0 L: C! K& t4 g- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
8 ]+ ^; A8 f5 A; J2 c# H' g, S0 J - EXIT_IF_NULL( rev );
3 c% U3 {- l( n |) U$ r6 r
; X' _4 t! c( h& |+ x1 O2 z/ v7 q- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
; d- g' u* I4 U$ r7 v7 P - EXIT_IF_NULL( process_template );( g6 z1 r% {. Q6 @) B9 |- L
) g' v$ v! u9 ]) y. t
% b. Q" h- Q. }$ m9 V3 J& m- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, 1 F6 G; ^# p$ U# J: n
- attach_types, &process) );
2 H" ?7 u; r, Y$ B% n - % S% H9 z- P6 k$ j" I
- EXIT_IF_NULL( process );; _; Z1 W+ h! a* g) H
- }) Z5 {9 J. b; }$ ], @
- $ ~4 f& M, M3 V5 A* g
- int ITK_user_main(int argc, char* argv[])- c% U( L* ]: w: |9 k
- {
: f. v( B& i! f% |. E1 c e - int& f. }% [$ ~4 B4 @
- status = 0; % \4 I3 l; R1 J9 g' K0 u. p! t
-
1 V8 o: W* J) }/ ~ - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );% s7 F4 P Y3 E* a
- status = ITK_auto_login();% Z: [, I) n; C: N6 \2 T
-
0 e) a+ r# m8 D. G- ` - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
* O+ K$ s# m6 j, o/ F - else
* I2 l. l( ]: r- @" L# a" \' g) B - {
: F) o E } ^9 Z4 L! p. Q: ~ - printf("\nLogin successful!\n\n");
; ?, @+ a& X0 k( K" { - ITK_set_journalling(TRUE);- q. L0 D- C+ a' g9 w2 N
- do_it();
1 {3 @ q# L$ B- ~+ k/ p: a. E - }
4 ]0 T3 E: x f' o p2 o: C/ ?( H - ITK_exit_module(TRUE);2 R% E7 c$ J- j. Y
- return status;
! V6 K) }% U! r4 U2 ?0 ^* { - }
复制代码
- } t* a/ B/ A* b' K( r! v9 y1 B. x6 \$ v
+ C' p& R3 @. }
|
|