|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
) e( y1 s+ N5 I% Y1 t% |& R, P* _
Teamcenter ITK二次开发源码分享: 创建一个工作流& F" C7 U# v& s' @- M
" [/ M. ]5 b, s& N0 o- ?1 f
- /*HEAD CREATE_A_PROCESS CCC ITK */# K8 T, U# U( C7 S& W) v
- #include <stdlib.h>
# L* x! a. }5 h7 M( Z - #include <TCcore/aom.h>- q2 x; X3 s7 E( G% b( e/ D4 w
- #include <tc/emh.h>
/ \& a& @$ O. K" F' U2 @ - #include <epm/epm.h>
6 S3 e' ]( [9 Y" p. R2 h$ f4 [7 w% v5 V8 f - #include <tc/tc.h>
$ u1 e7 Z4 a5 @9 r) o9 q/ | - #include <sa/tcfile.h>
. Q" e, c9 D, E5 O! m8 z - #include <itk/mem.h>8 ^2 Y% P+ K- X! l8 z" f
- 2 y# ~9 S' }* F5 w: j
- #define EXIT_FAILURE 1 / F6 }" l2 k, t- X" g2 j
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
# ]: a( X! a! E; r$ U4 Z - static void report_error( char *file, int line, char *function, int return_code)+ d$ I( ^/ z8 p7 p, X+ T! v
- {. ]/ r/ W8 n g; Y5 G C3 Q: D4 O* G
- if (return_code != ITK_ok)* T% g* U1 g; \5 ]9 G& }# l/ H' [ {
- {
/ N' ~+ O, k: k: E- n - char *error_message_string;; R' H- }! {' S
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
$ d: x& [" ]/ [ - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);* g1 s* i1 P3 ?* G
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);: M$ B# V2 _( e! C' e
- if(error_message_string) MEM_free(error_message_string);! @$ |) V- z& f' @! ^
- printf("\nExiting program!\n");7 z3 \ `4 f# h6 L+ K
- exit (EXIT_FAILURE);
}, {8 h: x* t, g3 x* P - }
1 \5 A' [3 N- e n - }: n4 U9 p& g6 g' [- b# j* f- W$ p
# \+ N g; i6 C- #define EXIT_IF_NULL(X) (check_value(#X, (X)))% H7 q/ x8 } n7 V0 `
- static void check_value( char *function, int value )
b' B: v! l! t% s - {
+ B% g. ?, ^$ o3 |+ E - if (value == 0)5 H6 Z( d$ B. _4 m
- {
. j! v- B! |+ y4 i% w: D - printf ("\t%s is NULL\n", function);$ \. M) n" ~: m$ X) x$ W
- printf("\nExiting program!\n");
4 `0 |0 m1 A* C1 k - exit (EXIT_FAILURE); + W/ N- X% U& ?1 A L8 |7 S' Y2 D$ m
- }
% O- ~/ C W x8 J( l% P* c7 P - }- K7 \1 K1 H3 H: w; s4 w
- 1 r3 M1 L7 F' }0 \3 x8 U6 B7 F$ m
* G) n0 T. E- r) n& x: W: `. Q2 I- static void do_it(void)
+ w# s' i0 a4 v l% C( n. P - {; t9 b( ~ n. b+ H
- int
9 J1 I: L, U! r8 j- g, U; x5 g - attach_types[1] = {1};3 a7 L: d. T, T
- tag_t
( n' H5 h* h: I1 p& ~+ l - rev = NULLTAG, ! L" R; E7 r+ G5 J8 S
- process_template = NULLTAG,
+ c; C5 b* l. Y. r/ j8 H B9 `, a - process = NULLTAG;0 r3 ~7 [# `. M+ s: J
& n8 l% a1 R% [8 d1 W! z, N5 P- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );. f6 c2 e+ {# N/ B1 N+ Q B
- EXIT_IF_NULL( rev );
& |5 C5 I6 |6 u5 N
& n; U6 ^% |- ~; b- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
* `# d1 j8 b9 i" i- N l0 `- D - EXIT_IF_NULL( process_template );
( ^! J/ c/ S0 T, P4 v - ! v% A- n; `4 k+ G- I
4 f' j8 p/ i6 ]* w% K. S0 y- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, ; m! Y1 m- @8 R: ]) J
- attach_types, &process) );5 j& x* C' M' h% c, Q
% c3 |+ g! z7 E/ Q8 o6 O- EXIT_IF_NULL( process );
/ \% S5 Y- v1 Q# W0 z: @ - }
7 u8 o% r( v: a- n- X5 m4 \ - ' P. w% m: {) Y3 B
- int ITK_user_main(int argc, char* argv[])
; o+ s; C9 L4 H - {' _' W9 j$ J0 F+ ^/ g. O
- int; W4 U1 N1 j3 }( j1 B6 G5 ?
- status = 0; 4 g- F: r* `4 r; O4 A3 g
- ) h6 p+ G' j4 O- Y# Y" L
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );& u. g- e2 x3 h3 h& x' t
- status = ITK_auto_login();
! m* f9 P! U- v -
/ K" S& O9 D6 f+ P1 k" z, ~ - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
3 @9 L: c- O$ n5 A, u4 a - else
5 d/ J. b6 _( {5 o, l$ y1 P( b - {* r+ `& l! W/ u6 `) x9 g
- printf("\nLogin successful!\n\n");
6 S5 i& ?3 ?5 K, N. ~ - ITK_set_journalling(TRUE);
/ P# n6 r1 S0 v% x4 I G - do_it();' ~. s; ^' B+ c: K- i0 I' w
- }
$ q! S. m- Z, J# E - ITK_exit_module(TRUE);
: C# _! B t! x% Y/ D( k- s/ b1 B* o - return status;
# m: ]; B* D6 t5 [0 O" m8 U7 l i' p) _ - }
复制代码
. l$ Q) m; J1 b* J/ c% X& R f3 p* w" F8 L) g9 ^% H) K- L
# v3 x* i9 a7 C# {" k |
|