|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
* O/ l$ C, h) D' d- G* `
Teamcenter ITK二次开发源码分享: 创建一个工作流( j# y" }# B# t, H( S0 ?$ B# N
v- l0 h" u, i4 j
- /*HEAD CREATE_A_PROCESS CCC ITK */! Z$ u# m# C7 h' a
- #include <stdlib.h> {! I8 o$ B% s# u) [& H& T5 V) F
- #include <TCcore/aom.h>
( s, M1 z) i: k' s' ]9 W - #include <tc/emh.h>, }2 v& l4 u' {6 M2 N( x6 x' v( x
- #include <epm/epm.h>
$ b! L$ [( Z; d4 s0 a8 Q! r0 X: K, g - #include <tc/tc.h>
# r/ H- Q- G( L0 d0 \9 ?! ^. i9 Z - #include <sa/tcfile.h>+ @/ `9 g$ G4 g+ D, m! i
- #include <itk/mem.h> U. H1 N) o5 A. w* D
- O# \3 J/ z% S7 A- #define EXIT_FAILURE 1
, M( c! E" I k; f4 Y - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))) R) h- B& K7 C- J }8 ]
- static void report_error( char *file, int line, char *function, int return_code), H* U+ L( |3 F$ t
- {* F% g! Z! t R
- if (return_code != ITK_ok)# }( Z: b5 s# J' a- [ O' F
- {
1 @% y9 Y( {$ n7 e2 Q: v9 | - char *error_message_string;7 v. G/ b& [( R0 F) x
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
* i9 a3 ~5 P i$ s( R+ M; o7 } - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);& |* w1 T z" P& d/ T
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
% n& u) f5 l. ~, X - if(error_message_string) MEM_free(error_message_string);
6 \ q! v1 j+ ]$ K - printf("\nExiting program!\n");3 q( B5 f% F% m. d: u$ d2 c8 h
- exit (EXIT_FAILURE); , k! o1 |3 R. V( d
- }
7 }; p' }# t" w - }
7 X2 K% e+ B+ h4 o w
& z! Y+ }0 g2 \2 p0 R- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
H/ i& K9 K3 O: f - static void check_value( char *function, int value )+ P2 i8 e3 e5 k- o2 `9 T
- {& d. ]7 V% Q# l! m8 A A# D
- if (value == 0)
% |1 f6 v, o: }) ^* X$ x: ~3 Z: } - {3 Z" ~: x0 r* p5 ]% s5 i* l* C
- printf ("\t%s is NULL\n", function);
. `; o( B; i* ?8 c6 Q1 [ D7 I8 n! n - printf("\nExiting program!\n");( T; H% B- y, d5 \/ b* A0 d
- exit (EXIT_FAILURE); & ^6 O* @$ h n) l
- }) i9 L+ D5 C2 Y' n# P" i8 N
- }
4 r0 j" Z* ?& t+ m1 G - 6 ?3 I# W4 i+ _) @
- 2 d8 b3 j6 m* y; i* w
- static void do_it(void)3 o! U, {- ~0 O5 O* W. W1 a( F2 x2 t
- {
8 m! T: c* D# @9 w - int
! M7 g1 G' W3 [6 |) u# b/ A - attach_types[1] = {1};; `$ V, ~, |5 W6 D f
- tag_t
f; [& C3 C6 q0 S) Q" d6 a2 ^6 x - rev = NULLTAG,
% k S# U9 F; B# b5 s) C3 g - process_template = NULLTAG, " m( v/ m4 C: _9 P
- process = NULLTAG;/ J* k( P' O a9 b; p
- ! U3 [% c0 |" T% X, Y- c, {
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) ); D1 F1 \, d# K: J
- EXIT_IF_NULL( rev );9 q6 D6 e- p( B# ^1 [5 Q4 K
- , V9 N$ W. y, W2 P) P- u
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
! W3 `9 K$ N4 K- d7 t. H- D - EXIT_IF_NULL( process_template );
4 @6 p# i9 {+ E! |' ]4 _+ P9 B - 4 `. L8 |7 L# x2 t, ^& @
; H! c4 }+ {- q+ `; X$ \3 c- j, y- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, 9 }+ f. i! [! U" i0 ]/ O9 l
- attach_types, &process) );
' q3 S& F$ ^' k+ g& U - 8 s% d9 \" z8 \4 F0 l0 m$ T$ ?
- EXIT_IF_NULL( process );3 k! `7 b. k: z4 {, O" V* u
- }
* Y' G- R2 _* N# R$ t9 L7 v
' J' U( Z* T/ r# y: \- int ITK_user_main(int argc, char* argv[])+ w! O- r7 I& b! h* c/ U
- {
, S# a S6 m6 q" |+ n$ J) k9 | - int
) d- S7 n }! [5 B: a - status = 0; 8 S% i4 q4 F6 T# P
- $ W' ?2 Z/ {5 c7 h1 t6 q0 g
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
8 c; F. f8 p) ?4 D+ Y - status = ITK_auto_login();
1 M$ I# H+ c$ d( E -
* Q6 i4 m8 z/ c6 S( S - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");3 \* `8 P3 Y/ T& l/ p
- else9 Q, q' y$ j) a F( B) w. n* z
- {1 S: g) I% c! k- L% ], Q' J/ U0 }
- printf("\nLogin successful!\n\n");
& p( }. r, {2 J3 h# X) I6 [) K - ITK_set_journalling(TRUE);+ l1 }& }7 I5 ] ?
- do_it(); ]+ Z5 x8 |* }$ Z% q7 E9 O: w
- }
- s8 e! P% w) T0 R. v$ k# O - ITK_exit_module(TRUE);
9 B2 e; I3 Q- B' q& Y9 A( d" e - return status;
0 D# |& f3 ^) d) c% @7 J - }
复制代码
% N' m0 V9 ^# ?0 D: Q2 X9 x) B0 i8 A; _1 d; l, P. }' J
& n7 h! Q2 r6 |* V9 w
|
|