|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. q. L6 ~. g/ l( _' ?Teamcenter ITK二次开发源码分享: 创建一个工作流
+ t+ F7 b; ^' g# u6 B: N4 O
( y; Y' s/ w' u, {- /*HEAD CREATE_A_PROCESS CCC ITK */
7 {7 @7 o0 y+ `" E7 H - #include <stdlib.h>/ y3 f0 B3 T4 f& \/ p3 f/ h* ^. }
- #include <TCcore/aom.h>
* ~; v9 E, ~2 c* ~+ b7 x! h - #include <tc/emh.h>
4 E8 ?. F; { ^( g4 ~( H - #include <epm/epm.h>7 e- Z% s7 u8 U1 S4 H% E$ m* u7 r
- #include <tc/tc.h>
& X' J E2 f6 x# v - #include <sa/tcfile.h>
% T. r- r5 {' J- y" n/ X - #include <itk/mem.h>) [. i/ t) R; i" } C) d, {
- + H$ B' k9 Z' Y7 q0 F+ ^% s
- #define EXIT_FAILURE 1
2 G5 ]% ^& U) X2 b4 l) W' v s" K - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
& Q1 N9 W2 @4 |, W: p/ M - static void report_error( char *file, int line, char *function, int return_code)0 n( t: o" y: H
- {0 I8 z$ k1 c1 e8 Y/ f+ n
- if (return_code != ITK_ok)
8 \+ i. D, L$ k, x4 e% C9 U" ?# g, L - {
& U* F* b5 X7 W2 ] - char *error_message_string;7 \) J. k+ v9 ~1 {% s) I O8 u
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
5 X* E; S5 g; l- O; V1 J - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
6 i4 T" s, h6 X! @7 k2 v0 z; Y - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
5 {$ a! F. a4 I T - if(error_message_string) MEM_free(error_message_string);# ?$ Y Y8 X- H' c7 W) D
- printf("\nExiting program!\n");
! A3 H" z: a1 c7 v/ b - exit (EXIT_FAILURE);
3 M% ?' T2 N. D9 K - }! d) S. ]6 b5 o- l
- }
U! H1 V( G1 |- O2 ^, t8 D - 7 Z+ i! Z1 y1 e' O
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
. ?# W) R v6 i - static void check_value( char *function, int value )
- \1 p7 w3 d7 q$ c4 a x3 \ - {9 H6 H6 a- A! a4 {
- if (value == 0)
5 i( h- }$ b/ L4 l% w" B - {# U, g& H3 I- c. f4 h( X3 |( [
- printf ("\t%s is NULL\n", function);
. Z$ e2 t5 n. U' \# k9 C2 G+ K+ \8 i - printf("\nExiting program!\n");
. n. Q) |8 j: V$ ~ - exit (EXIT_FAILURE); $ a3 g/ e* z" x4 ]6 Q- ~
- }
) R/ h- c3 [2 A* { - }
$ y6 U' h0 g. q) L - : @2 h( e5 W: G) C+ I
7 n' ]* e! f6 M- F. e; w3 T- static void do_it(void), h( v( R( `' [! E6 U/ p1 C4 l4 \
- {+ y8 U5 z8 d0 ~9 k; ]
- int
# j$ ~1 \# p) ^( _ C - attach_types[1] = {1};
% v0 ^% ^0 G2 D$ |% i7 @ - tag_t ' f2 r" B" E7 l! Z7 d* B
- rev = NULLTAG,
! j) n/ \! u6 H6 X, F7 a - process_template = NULLTAG,
# w+ |: ~# R; m2 x - process = NULLTAG;
9 q4 ]/ o4 _4 ]$ }& R - 9 ?7 q. G( Q6 i' I
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
3 [2 S6 z! T# t( L - EXIT_IF_NULL( rev );# i# j1 a+ }5 H5 a _3 m
- . N' _( j9 \; A: r1 p+ b" c
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 0 \2 ~# Y5 ]( O7 B/ [0 e! P( Y0 c8 h
- EXIT_IF_NULL( process_template );
2 R E' T9 K& `( n1 [5 j" ]% B - ) F# S6 S* w- z9 k8 u% s& v
y1 a) }2 U; d, r% _- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, i) f0 L3 g5 w8 G5 @
- attach_types, &process) );
7 c( ~, {( k6 i% k: c0 g& e - % g+ M7 n- b! d6 O5 B, p0 H7 e
- EXIT_IF_NULL( process );
" v. k* f+ A L) m! J8 ? G5 v% r - }3 }( T+ s' ~$ b1 Y$ P, O
2 w% x$ r: a+ b: u/ C3 M- int ITK_user_main(int argc, char* argv[])9 J0 L* {2 X0 O* g; G2 \" ^% N
- {
* l* Y. s1 H4 x$ }* P- L& ? - int3 C9 \0 U' p' A! R# T3 y8 H% ~$ Q
- status = 0; ) C$ e$ A4 |, q( @( ~, {* t( J
-
4 C0 V3 b# u% O- n% p1 x - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
8 u- |5 q* Y. R7 h8 v( ] - status = ITK_auto_login();
& e, I; j+ M7 ~, X% c; H/ z -
& M& w, e. i" N3 d+ D - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");5 T! F; \* X; j2 R
- else) j% s x& P, D2 V
- {
! P1 t" \: u Z. P( e- |, l& }' ~ o) P - printf("\nLogin successful!\n\n");
2 q6 z. a$ R6 y+ n) h - ITK_set_journalling(TRUE);$ U' o! r5 q# m. a9 l# R2 {
- do_it();% \4 `, }! ~/ _: F5 p$ v& f
- }" d+ i$ X. R2 o" D( Q* F8 }# y. B
- ITK_exit_module(TRUE);
% N! A0 o. Z8 `- F% t0 G - return status;, d; S3 h( N1 \# \+ m
- }
复制代码 8 C* U, ]1 J z p, ?( l) J) W
: i8 t+ H u! b: E* ]. Z2 y
, E! R0 W+ _% r: g! M7 Q |
|