|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, N8 B5 @; n5 }
Teamcenter ITK二次开发源码分享: 创建一个工作流
; L& y# g* n) y( Z5 X
5 c* B) X4 y8 ?7 ^, J- /*HEAD CREATE_A_PROCESS CCC ITK */
: c% ]1 h5 k) ` q# o - #include <stdlib.h>7 d$ R y* S# l# T. p# @. o# g
- #include <TCcore/aom.h>
; `& q+ x& ~, g0 o5 ^; [! C - #include <tc/emh.h>. z& i+ W7 `9 U* X2 k; d/ d
- #include <epm/epm.h>
, [$ ^( Q2 {5 }; l6 Y0 u - #include <tc/tc.h>
! a/ A; J% \+ N; |3 y8 a" D0 _0 { - #include <sa/tcfile.h># b A$ t! s+ ~# e
- #include <itk/mem.h>
* G' b: [( R7 f/ L @' z - 5 i+ C; R! m. ^8 Y$ \* V
- #define EXIT_FAILURE 1 ) Q2 v/ I+ y C+ \1 ]$ C
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))! @8 {0 q+ l8 N( Y
- static void report_error( char *file, int line, char *function, int return_code)
$ ~4 `: o7 Q/ h! V - {/ r; K; \6 c2 f
- if (return_code != ITK_ok); J- b, P0 Y' q& L
- {& s0 u" {! N: {; W2 F
- char *error_message_string;
$ Y8 W# o1 L4 v/ t& F2 b# s - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
- S$ B) M- q8 K& K - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);& T; n3 s- A( u8 C! u1 h+ r
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);* u# M2 K- D; E2 T5 ?2 j
- if(error_message_string) MEM_free(error_message_string);
4 r1 N5 g. |4 o" t- r2 Z - printf("\nExiting program!\n");$ Y& c: ~9 S8 c' |4 g6 R( {/ b
- exit (EXIT_FAILURE); ! g/ U* j( W- B
- }6 B! @- q! N7 x* O
- }9 y V; g- v; N/ y3 c: b; Z
- ! Z- v; ]2 X! L& a9 W
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))! L) A0 R" n$ F4 b, r
- static void check_value( char *function, int value )
, r1 N, r( `& H+ M+ V - {
& Z, [ k# b+ S; m f - if (value == 0). G" T& I0 l$ `) I" j3 j! S
- {- Z/ P0 ]7 n, [" A2 E
- printf ("\t%s is NULL\n", function);$ ]7 X2 N$ e* p$ y; g1 n
- printf("\nExiting program!\n");
& K& Z7 S2 C% {/ E3 v - exit (EXIT_FAILURE);
0 X7 a: u; u! A; w3 b - }2 ~4 @- ^9 e! O5 o* K+ I3 p- m
- }
# {7 p! g/ M/ E" [% b! u9 Q7 E6 n! Z7 F - 4 A f$ E. l4 W
. J4 F5 K8 d3 Y2 T. s- static void do_it(void)
7 V/ d% O. p! D2 z" w - {
- u; b, }! r' ]4 |9 \ - int 3 [7 Q m7 T) \* q$ B% {1 C$ A
- attach_types[1] = {1};0 K7 |- x/ j3 n7 T2 q: p
- tag_t
+ W" N: I2 G6 Q$ S6 r - rev = NULLTAG, ( X% M# D2 H) O& j3 z+ [
- process_template = NULLTAG, $ {/ W8 I% h+ P. N. P; \
- process = NULLTAG;
3 x; y) K6 [% `' y5 O* o - " H6 Q, I" J- v# s; r' H
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
X% v- U; j ~4 b9 Q - EXIT_IF_NULL( rev );2 H8 [0 H" j1 M0 z
- 9 K( t( w3 e) M8 Z% v6 c6 { x
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
& M( n2 Y; M6 ~. o& S v - EXIT_IF_NULL( process_template );
; a+ s% t; r) s) V: _3 x; V - 1 H; s4 Z, y$ Z
8 o4 {6 }1 I/ L! v; d- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
+ z. `* t: k2 t5 d h8 f - attach_types, &process) );6 Y4 [" s1 ?5 ~, E6 n0 l' h. _
0 @! p3 M- j, k8 E' r* [- EXIT_IF_NULL( process );
3 o1 _" _# f5 m* B9 n2 l& G - }+ T4 v' X* O* q
- 0 p- \: t3 v% h8 K' K
- int ITK_user_main(int argc, char* argv[])# A0 {+ d. H" Z0 ~1 i
- {3 L' }% O. O+ G9 o5 h! _( q: S
- int
+ i, I5 I, Z5 r1 p- N$ A$ U/ k - status = 0; ) R3 C+ h9 n- C$ Q# I
- 0 V2 Y7 O) y; U* J$ j2 M c
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
/ u; H5 [6 g, i `. }# T3 { - status = ITK_auto_login();8 P% b. A8 ^3 A% x: y5 u
- 2 R$ a, H' I& g* b" \
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");* X' I) H1 @/ [1 @' w( k3 q
- else
( A1 r1 F5 J) o" o3 l - {
' @. W: c' }9 l' F - printf("\nLogin successful!\n\n");
# S. ]$ S- [1 O4 V" C - ITK_set_journalling(TRUE);
`: d: P8 m9 p0 e - do_it();% e3 J. D% I% I- w
- }
( ]& ^6 M9 D W% t: n - ITK_exit_module(TRUE);, }) Q7 b. o1 }! }, a( a3 k* {
- return status;; g3 Z+ I. {( a- S. ?$ L) W
- }
复制代码 . o( Z6 ?4 ?; b! h2 Y' T2 r. m
" T6 m, w& m$ l
+ R. T0 p, A/ H9 A2 N- k
|
|