|
办法1:从2016版本里面复制相应的代码6 y9 i" i6 r- J% T6 ^4 \7 Y+ J
! A, F1 M8 u8 `+ x& A3 T
具体代码如下:
* U" A% D4 L7 h: b% Z" L9 T$ w- treenode agv = param(1);2 c: M' {: _( e9 C3 w+ a, u+ L) a
- treenode currentCP = param(2);1 n* L1 K% q/ R6 S5 L
- ! |$ u8 C9 b/ v6 h- H
- { //************* PickOption Start *************\\
! c& p" p; D: m! S2 V0 c - /***popup:AGV_DivertToElevator*/
8 d6 v/ M4 @ C4 |& V9 N: v2 Z1 v - /***tag:Description*//**Divert to Elevator*/! M; E1 o, d# z0 n" ^9 C- l
- : Z' c- G2 L7 M1 o6 V
- int operation = param(3);3 e- T5 F$ G, E, ?
7 a! S ?" |5 f# k! t! v& ]- #define AGV_LABEL_NAME "fs_AGV_Elev_State"
9 c. t4 M; g D$ A - if (operation == 0 && !objectexists(label(agv, AGV_LABEL_NAME))
- s3 B' s$ u! Y% L6 I - && (/** \nCondition: *//***tag:Condition*//**/fabs(zloc(currentCP) - zloc(agvinfo(agv, AGV_DEST_CP))) > zsize(agv)/**/)) { // if it's a pointer, then do the initial case
7 F2 C% w9 }4 K$ r - // initial trigger execution
3 `& [/ G/ D0 J9 a& w9 U3 n* N: } - #define ON_ELEVATOR_START 1
# S9 L4 K/ z# \# J - #define ON_ELEVATOR_PICKUP_ARRIVAL 2
& ?2 `0 }' i6 F. u5 L! N* ^ - #define ON_ELEVATOR_DROPOFF_ARRIVAL 35 D. N7 R. X3 ~+ X. f
- #define ON_AGV_AT_CP 4$ x) ~5 w! s0 K9 e% C9 v
- #define ON_BOTH_AT_PICKUP 5
! j7 D5 @: v6 p( B - #define ON_OPEN_DOOR 62 H5 ^- U' @- L- o7 T
- #define ON_CLOSE_DOOR 7
# `* c( k. @" @) x+ ]/ m# O7 | - #define ON_PICKUP_DOOR_OPENED 8$ T+ V* F% Z4 f# }0 V8 d' ?
- #define ON_PICKUP_DOOR_CLOSED 9% y% y2 G4 B; h7 a$ m6 B- K1 h
- #define ON_DROPOFF_DOOR_OPENED 10+ {5 `% |, T9 f4 \; Y6 Y9 X6 |
- #define ON_DROPOFF_DOOR_CLOSED 11
8 } e4 Q( d* M+ E -
6 U$ ^ R7 |$ P7 j; F - #define AGV_STATE_START 0- F4 }+ n# y; I$ _
- #define AGV_STATE_AT_ENTRY_CP 12 K% H- \ o) m8 } x
- #define AGV_STATE_AT_ELEV_CP 23 S! C8 o4 x% X' F
- #define AGV_STATE_AT_EXIT_CP 3, Y6 [) }; @. Y2 W1 w( u
-
: [% m# ]1 |" c0 T. I( l( p! s" a - #define ELEV_STATE_NONE 0
# u+ ^/ T: k0 ~. w1 _$ X9 m: A - #define ELEV_STATE_AT_PICKUP_FLOOR 1 \5 y- o K" k. E6 {8 d
- #define ELEV_STATE_OPENING_DOOR 2, s" y3 I5 F. Y! f
- #define ELEV_STATE_DOOR_OPENED 3
/ J8 w) [. F) \$ q) D - 3 A1 }7 B; `$ o w
) d; a2 m" i! ~: o) ~: t- treenode elevDisp = /** \nDispatcher: *//***tag:Dispatcher*//**/cpconnection(currentCP, "Elevators", 1)/**/;; P+ m5 F5 V6 Q
- #define elevator outobject(elevDisp, $iter(1))
" W1 W9 p% w) Y5 j e
% \: ?: N. g: |: R0 `: p- if (!objectexists(elevDisp))
" G# O& j" M q5 L - return 0;
, j* f; k/ e- E
2 p" i, z: u9 x4 G6 I- if (/** \nDo Search: *//***tag:DoSearch*//**/1/**/) {
# x. R9 g8 r4 m" q6 \ - query(- }. g0 W( z" o4 f/ o/ ?/ E
- /** \nFull Query: */ E- u" T7 @4 w+ o' M. M0 d6 ?, U
- /***tag:FullQuery*//**/"SELECT $2 AS Elevator FROM $1 Elevators WHERE $3 ORDER BY $4 ASC LIMIT 1"/**/,
/ A2 {% u" u# o& J7 ?! V9 _* Z3 z - nrop(elevDisp),
9 M# T5 l9 X8 ~ - elevator
8 q d2 p) c1 N8 n. L. @. z d - /** \nWhere*/1 _+ a, E* Q/ s% _
- /***tagex:WhereParams*/,/** \n*/ /**AND*/ /** */ /**/getstatenum(elevator) == STATE_IDLE /**/
( d: O7 ^9 L# r: d( K. P - /***/
! P& l* x! B( a' b - /** \nOrderBy*/
: x- r7 q1 n! ?' X4 N - /***tagex:OrderByParams*/,/** \n*/ /**/fabs(zloc(elevator) - zloc(agv))/**/ /**ASC*/- i4 h# I( p# l; X
- /***/);4 Q c1 i/ L7 H& Q: A# `: v- _
& U- e/ h' P/ T" `+ s5 u/ R- if (getquerymatchcount() > 0)8 u7 r- O4 W9 J
- elevDisp = getqueryvalue(1, 1);$ N1 H( G" }% x8 G( [
- }
% v# A) T" @ H$ V - if (!objectexists(elevDisp))
6 ^4 W* f9 k& F' V6 p% I - return 0;
+ h- z$ n) f2 e% X - treenode destCP = agvinfo(agv, AGV_DEST_CP);
& I& `( e6 S( s- z9 }$ I. d - " c6 s7 [' Q( ?/ ]+ }. P
- agvredirect(agv, /** \nDivert Point When None Available: *//***tag:WaitDivertPoint*//**/currentCP/**/, REDIRECT_AND_WAIT);
3 h/ Q0 s+ w# w1 h - ) P7 z, {2 R- q5 M$ M( G
- // Create the task sequence for the elevator/ S$ O, d, t9 ~
- double destZ = zloc(destCP);& N3 }5 I5 `( S4 u3 i
- treenode ts = createemptytasksequence(elevDisp, 0, 0);, h d( }7 Y. p1 {5 J- m/ z
- inserttask(ts, TASKTYPE_TAG, agv, destCP);- z! ]+ e/ g' e+ X+ T0 Y
- // immediately when the elevator starts the task sequence, I call ON_ELEVATOR_START
& a+ O' c+ D+ y/ U& W; i& ]5 j - inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_START, destZ);
9 S+ k6 k9 c% o& e8 I - // travel to the z location of the current control point! M4 v4 @ Y5 R; ~0 L
- inserttask(ts, TASKTYPE_TRAVELTOLOC, 0, 0, 0, 0, zloc(currentCP));7 t% \4 D6 O' G$ T# `% Q! l( o* N
- // then call ON_ELEVATOR_PICKUP_ARRIVAL- W8 u( j& _: G9 D
- inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_PICKUP_ARRIVAL);/ z, D; o& K2 z* g( g0 H! G
- // then wait for the agv to get on3 o. |8 i7 u8 P( ]9 o
- inserttask(ts, TASKTYPE_UTILIZE, agv);( X6 H' |5 H( u5 `6 R( e
- // then travel to the destination z location3 K, r1 b3 B/ T- _- T5 F
- inserttask(ts, TASKTYPE_TRAVELTOLOC, 0, 0, 0, 0, destZ);
% W" _& i1 h6 Q) x& O - // then call ON_ELEVATOR_DROPOFF_ARRIVAL
+ ^6 m+ W! ?& G0 f - inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_DROPOFF_ARRIVAL);
+ n6 }* f" ^0 H" T8 z& y - inserttask(ts, TASKTYPE_UTILIZE, agv);+ H$ q$ I) A8 E6 Y( O$ q
- dispatchtasksequence(ts);, N3 y9 X, W/ S) g, z8 K7 ?1 b
- } else switch (operation) {0 _! G( I* z- [# Z2 E/ ^* D
- case ON_ELEVATOR_START: {
9 y2 L& ~! b2 h7 ]; E$ x - // this is fired when I get a valid elevator+ ^/ f- V5 \* P6 j' I+ _" M
- treenode elev = param(1);
0 v3 j/ [/ G- `0 J g% }- G - treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);+ d4 o. a7 B0 L! W R$ x5 X
1 _3 Z* X5 }. ?) C- // find the closest floor control point
) \$ U1 p. l3 S0 [! A* P2 j' m3 f - int floorCPCon = cpconnection(0, /** \nFloor Control Point Connection:*//***tag:FloorCPs*//**/"Destination"/**/, 0);
6 g" o8 k b. G0 ~4 D - treenode curFloorCP = findmin(cpnumconnections(elev, floorCPCon), 2 s5 v& \7 n: Q Q7 r
- fabs(zloc(agv) - zloc(cpconnection(elev, floorCPCon, count))),1 O5 @; ^8 O5 P0 Q: Q- a5 {8 P) |% E
- cpconnection(elev, floorCPCon, count));
$ Z; M( F7 W/ [. Y3 {1 b3 e8 _ - // return if there is none1 e/ M; t4 h' \
- if (!objectexists(curFloorCP))
- f/ A- `& F9 @' F8 ^6 v - return 0;
* X* v- v+ k2 v$ g! ]
6 Q. N) f b, W: T- // get the entry control point
2 o7 m" u6 j% l9 R3 l( v% M/ x. y - treenode floorCP = curFloorCP;% A# o8 j H, S+ T- z3 P9 w
- treenode curFloorEntryCP = /** \nEntry Control Point: *//***tag:EntryCP*//**/cpconnection(floorCP, "EntryCP", 1)/**/;
, R4 l+ C; {+ c+ w+ N( Q - if (!objectexists(curFloorEntryCP))
. t) Y/ M% v/ [3 \( P# t - return 0;
1 p4 V# X& h" Q. D4 K, i" v - treenode floorEntryCP = curFloorEntryCP;8 R2 A- L z8 Y, |% V+ W
- treenode curFloorElevCP = /** \nElevator Control Point: *//***tag:ElevCP*//**/floorCP/**/;, Z( ]4 n3 w; c; o* k
- if (!objectexists(curFloorElevCP))
) A0 B5 h/ j. e - return 0;$ P& P! j6 t$ ?' a5 S% _" Q% y6 j
! v1 u- }' e/ d9 Y. x- double destZ = param(4);: v. n! U% y3 O3 l$ s! O5 P
- // find the floor control point closest to the destination floor
* G4 x0 f' I; P2 p8 U - treenode destFloorCP = findmin(cpnumconnections(elev, floorCPCon),
- i& C- l# ?1 j - fabs(destZ - zloc(cpconnection(elev, floorCPCon, count))),
1 d! `! D/ W3 s4 s - cpconnection(elev, floorCPCon, count));
- _4 V4 M% G" Y' N$ w' h( A1 L -
) ?6 m! V$ D3 M! D* z! @ - floorCP = destFloorCP;
" ^4 R8 z# L4 L P3 j - treenode destFloorElevCP = /** \nDest Elevator Control Point: *//***tag:DestElevCP*//**/floorCP/**/;- G# d4 [% |' H8 `4 }
- if (!objectexists(destFloorElevCP))6 q9 l" P9 P/ |1 ^1 e0 l) Y- F* s
- return 0;, J7 n3 N! O2 I8 V* |( Z
- // get the destination exit control point. A. [( ^: p7 {4 u& ?8 \5 x
- treenode destExitCP = /** \nExit Control Point: *//***tag:ExitCP*//**/cpconnection(floorCP, "ExitCP", 1)/**/;
8 W) [/ c M& u - if (!objectexists(destExitCP))5 N4 V( K) i. k1 V' ^* q0 }; O
- return 0;
0 \/ C: i) p2 Y" Q8 C - w: ~9 t1 O9 v/ S. `0 a
- $ R! i ^; w: A% I. |8 h( D: T
- // add a listener for the agv. This will call this nodefunction in the ON_AGV_AT_CP section whenever the
( W( E5 j# S8 F7 | - // agv arrives at a node. I keep a state on the agv's state label, and then increment it each time6 f. b3 z; }9 ~
- // the listener is called so I know which control point he's at, i.e. entry, elev, or exit.
8 C1 U7 F( ]! X- g0 q - agvaddlistener(agv, c, AGV_LISTEN_ARRIVAL | AGV_LISTEN_INTERMEDIATE_DEST,! h }! N" u/ e4 z: P$ ]; b- c) ]
- agv, elev, ON_AGV_AT_CP, AGV_LISTENER_PARAM_NODE);
9 r$ ` N: T& \( e0 L -
0 e5 `- }. @; v- t: r - // set the data on the state label
# U" E+ t# M0 r; W# c - treenode stateLabel = assertlabel(agv, AGV_LABEL_NAME, DATATYPE_NUMBER);$ W0 I( V4 o: R. V6 ]! R. S
- switch_destroyonreset(stateLabel, 1);
0 W6 A( m" ^+ k+ ~& R - set(stateLabel, AGV_STATE_START);1 ~# c1 a- V# z: x' p2 o3 S$ k
- set(assertsubnode(stateLabel, "ElevState", DATATYPE_NUMBER), 0);- i7 j/ P# l' _# D: M) `( Z
- nodepoint(assertsubnode(stateLabel, "ElevCP", DATATYPE_COUPLING), curFloorElevCP);" x* |5 D& J4 Q2 _' I& g
- nodepoint(assertsubnode(stateLabel, "DestElevCP", DATATYPE_COUPLING), destFloorElevCP);2 ]7 I/ V+ b7 n4 ?
- nodepoint(assertsubnode(stateLabel, "ExitCP", DATATYPE_COUPLING), destExitCP);
7 R! g/ F- X) [; ^8 a" q - agvredirect(agv, curFloorEntryCP, REDIRECT_AND_WAIT);
, a, z; }8 I9 F2 I - return 0;. ]: {3 n% v5 K( v4 d1 X& O
- }2 y( n( j' N" K5 O! j, ?
- case ON_AGV_AT_CP: { Y: f J7 M5 I& ?1 _1 I
- // this is fired by the agv listener every time the agv arrives at a node.
, j# I5 g8 m& Y* C7 B; V - treenode agv = param(1);
! H9 ?5 `/ K* a% w0 n - treenode elev = param(2);
0 i! T+ r% Q. O0 f" |! W7 k5 U) k - treenode stateLabel = label(agv, AGV_LABEL_NAME);
2 ]) J* _/ w* y# T6 }0 r - // I increment the state label, and then switch on it
" O G; s0 N k/ ^& r - inc(stateLabel, 1);
0 e# G, {) M. ~! v8 C) V: A - switch (get(stateLabel)) {6 i @! J$ O2 h |: _. Q* }" G' J5 i) s
- case AGV_STATE_AT_ENTRY_CP: {
3 r- _: V2 J7 Z/ I - // the agv just arrived at the entry cp/ w$ F2 H$ y* r. e
- // so, figure out where the elevator is.
- R- r/ ^, J T( v7 k - int elevState = get(node("ElevState", stateLabel));& T4 j/ C$ o: |! m( d6 Z1 N
- // if he's at the pickup floor with his door closed then open the door.
! Q7 s; ? {( ?% m4 {/ H - if (elevState == ELEV_STATE_AT_PICKUP_FLOOR)
% i1 I6 M1 e' f) L - nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_PICKUP_DOOR_OPENED);
7 F8 E$ \9 k. O7 x I1 V - else if (elevState == ELEV_STATE_DOOR_OPENED) {' j( J) f- i R" Z
- // if his door is alread opened, then move the agv onto the elevator, i.e. to$ r8 ^! {& }8 c4 r
- // the elevator cp
) a; v* \# J7 n# N& Y - treenode elevatorCP = tonode(get(node("ElevCP", stateLabel)));
) e# t8 y. Q" m3 J9 w - agvredirect(agv, elevatorCP, REDIRECT_AND_WAIT);4 G1 J) P; u4 ?8 n
- }! u. i( R7 T8 h) }
- break;
' z/ T. R x5 g' V/ C1 Q - } Y- t# }. `! l$ r k2 I- x* g
- case AGV_STATE_AT_ELEV_CP: {
b& ?& R e( \ - // once the agv is at the elevator cp, close the door7 q% Z' Z: |2 ^5 {5 E
- nodefunction(c, agv, elev, ON_CLOSE_DOOR, ON_PICKUP_DOOR_CLOSED);: C3 Q9 J+ Y! s5 q7 T) M+ P& [; s
- break;
/ s9 T& q* g. x' t9 o, b m1 k - }
: p0 ~# a3 b3 \" l& e7 [ - case AGV_STATE_AT_EXIT_CP: {
X6 @# g# L6 Q6 m a - // the agv is at the exit cp9 z1 g$ v$ ]( L6 \
- // destroy the listener node because I'm finished listening
1 o6 b& o2 K& h! k& H - treenode listenerNode = param(4);
& V+ Y' b3 b: k* A8 u1 l( e D - destroyobject(listenerNode);+ O t/ Q, e. ~( m& ?2 [
- int agvWait = /** \nWait On Door Close: *//***tag:WaitFinalDoorClose*//**/0/**/;
, W/ k# f8 r- q4 N) A' C$ H - if (!agvWait) {
7 }/ F/ H) \) F6 L1 T: T - // if the agv is supposed to continue on, then tell him to go to his final destination. A4 V. S2 O* O! X, X$ N3 d6 @
- treenode destCP = gettaskinvolved(gettasksequence(elev, 0), 1, 2);
1 h0 q0 J4 w+ | - agvredirect(agv, destCP, REDIRECT_AS_FINAL);4 p0 a! g5 A" k; u0 V! P: T" ^
- }
- J# F9 l, M1 Q# Y - // close the door
L5 G6 D/ N, i0 z - nodefunction(c, agv, elev, ON_CLOSE_DOOR, ON_DROPOFF_DOOR_CLOSED, agvWait);
- G' p$ F$ }& @) o p( ] - // and I'm finished with the state label so I can destroy it.6 D0 M; r4 c0 j
- destroyobject(stateLabel);
5 W1 l, s/ t) \6 Y* V - break;+ l: z0 t, u" C8 v$ R: ~1 `9 n: }! c
- }
n: }. V9 R( a% k' u6 ]' v) ?9 j3 ] - }- W0 K s9 S# n% v
- return 0;+ C+ a# s. A0 ~/ C3 \4 A, S) K
- }$ P# a8 u+ ^) N4 J3 {6 w; e
- case ON_ELEVATOR_PICKUP_ARRIVAL: {5 T# n- Y2 S6 `* }3 Z0 L( T' L, ~1 z
- // the elevator has arrived at the pick floor
8 R8 @+ f/ H A8 U - treenode elev = param(1);& r! Q. j! l$ L- m2 j8 x1 h% @
- treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);# \4 x A x6 u; _* E5 O \
- treenode stateLabel = label(agv, AGV_LABEL_NAME);; z+ c8 L% a8 W$ }3 E
- treenode elevState = node("ElevState", stateLabel);6 r! h/ w( n* w, a2 b! C0 s
- // set the elevator state to at-pickup-floor
7 B3 n0 R; G# w+ {. |8 | - set(elevState, ELEV_STATE_AT_PICKUP_FLOOR);
- ~: M' N0 @5 {9 _ -
7 H @ o: ]5 S4 U - int openDoorImmediately = /** \nOpen Elevator Door Immediately: *//***tag:OpenDoorImmediate*//**/0/**/;
F# \( t* D9 M3 X0 n* K, g - : l2 a; q2 m; z2 W5 G d0 J
- // if the agv is at the entry control point or I open the door immediately, then open it
5 }) s! Q% U4 l/ ]+ B7 T$ D. X9 h* e - if (get(stateLabel) == AGV_STATE_AT_ENTRY_CP || openDoorImmediately) {
/ o2 w/ d1 B& b( W3 J8 r - set(elevState, ELEV_STATE_OPENING_DOOR);. u. l) x4 V- F4 G
- nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_PICKUP_DOOR_OPENED);
% t2 K- {0 M+ e) B {+ Q - }' A1 @, E8 E& Y/ U2 U
- return 0;
+ v9 k: k1 c+ ?# @7 @ b" ~$ U - }
4 U: U2 D) u9 G) i - case ON_OPEN_DOOR: {( l. q Z6 X P) Z7 a6 D3 v
- treenode agv = param(1);
5 _- a# G" G3 B ], y# p( X2 U - treenode elev = param(2);
7 N$ e0 `. x' N; f7 z - int nextStep = param(4);2 L& A& {4 o8 r* s8 L/ P
- // open the door based on the time to open the door) f4 L' z) }# v! h+ ^# M1 m
- double openDoorTime = /** \nDoor Open Delay:*//***tag:DoorOpenTime*//**/5/**/;4 `5 M, V: F S6 o: N
- delayednodefunction(c, openDoorTime, elev, agv, nextStep);
* q% A9 _, F$ D: v6 T* k5 z$ h0 k/ m - return 0;
8 f1 V4 x. D# s2 p - }
* i5 G R3 w+ B- D H - case ON_CLOSE_DOOR: {7 i# D; {( b& t7 C. ]( g
- treenode agv = param(1);
* c8 M1 m' W. O2 Y$ g! @ - treenode elev = param(2);
# @ r! i9 D. L' e" g7 S - int nextStep = param(4);
3 t# X1 h# K/ ~ - // close the door base on the time to close the door! z) n! \: T0 Z9 B1 H3 W2 o" J
- double delayTime = /** \nDoor Close Delay:*//***tag:DoorCloseTime*//**/5/**/;$ P6 D8 _# d1 \
- delayednodefunction(c, delayTime, elev, agv, nextStep, param(5));
! `6 p+ s. R# \2 G j; a - return 0;
: ?1 t5 P6 o! F; P+ o1 ? - }
/ E/ p4 Z! V: k; a( P) K - case ON_PICKUP_DOOR_OPENED: { A+ d+ q6 D% u* ^
- // the elevator door has been opened on the pickup floor: u/ k" t& k3 x# W, p; m
- treenode elev = param(1);
% B! z" U3 S" Z! N8 F# A - treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);
4 u; T6 j9 h' e - treenode entryCP = cp(agv);
/ ~: o, v' x# Z2 v4 h - treenode stateLabel = label(agv, AGV_LABEL_NAME);
# {( s% j0 K4 n6 e0 ? - treenode elevatorCP = tonode(get(node("ElevCP", stateLabel)));1 p& N- b( |5 B" h
- treenode elevState = node("ElevState", stateLabel);
! N2 m8 D. z1 O0 V. |. w$ x2 I v' ~ - // set the elevator state
& b* d I9 B) |" C6 b2 @ - set(elevState, ELEV_STATE_DOOR_OPENED);, N) C" U6 ], [% \! e
- // if the agv is at the entry control point, move him to the elevator control point
6 O8 y/ @* Z1 r2 T7 H" w' R8 r8 K - if (get(stateLabel) == AGV_STATE_AT_ENTRY_CP)
, g Y4 {! E/ S5 b) c - agvredirect(agv, elevatorCP, REDIRECT_AND_WAIT);/ m+ L& P4 b' {) @
- return 0;
. w2 X. T: \$ Z, p/ D% j - }
! ^- Z0 Q' X( X0 T5 V - case ON_PICKUP_DOOR_CLOSED: { [/ S$ @6 w- L8 s; O2 h$ w+ |
- treenode elev = param(1);
' t) Q$ d/ ^& J6 l `( Y u( _! I - treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);% P! `0 W; P$ m7 o
- // assign the agv to "no control point"0 b+ z8 ]$ l4 D3 s$ D- H! |5 E; Q" [
- agvreassigncp(agv, 0);6 l2 @) ~2 @+ K
- // move the agv into the elevator
+ E3 ]/ K1 S0 q0 C% Z, l8 q% [ - moveobject(agv, elev);; P, y ^, |5 V: M
- setrot(agv, 0, 0, 0);3 @1 E) v* U1 S" w
- // release the elevator to continue to the destination floor
4 F: c9 J' O0 m - freeoperators(elev, agv);
( K* P8 X" p: J @& D9 L4 H - return 0;
) J3 p8 n1 u; G; [9 y$ X - }
' N- y3 n7 S/ w4 W1 f, K0 m - case ON_ELEVATOR_DROPOFF_ARRIVAL: {& g! P O# v, s, w) Z& S
- treenode elev = param(1);
! W3 F) x" f. ~ - treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);
: F( e7 \! d5 S% ^$ t& ?+ m - // when the elevator arrives at the destination floor% z) a4 L4 W! x/ g
- // move the agv back into the model! ]+ l6 y: S$ L& t' E1 h
- moveobject(agv, model());
. }8 S& l- w" b1 }0 @! N - // reassign it to the destination floor control point1 l7 Z7 @4 \2 J ~/ _
- agvreassigncp(agv, tonode(get(node("DestElevCP", label(agv, AGV_LABEL_NAME)))));
5 b1 R6 x3 p; ?) `) j - // open the elevator door
1 ?6 I+ Q5 |) c# T - nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_DROPOFF_DOOR_OPENED);
4 E/ _" S% W8 f# A4 m5 L - return 0;
3 f o& \' J; f1 a - }
: @. Q. P9 P& w* X( J- i" X - case ON_DROPOFF_DOOR_OPENED: {
3 d; C! s4 W8 m$ j) w& i - treenode elev = param(1);
7 `+ H! T! Y7 u; | - treenode agv = param(2);
0 U+ D& f# \* m' k1 h. K: ^ r# q2 l - treenode agvLabel = label(agv, AGV_LABEL_NAME);
$ K: k+ g2 V4 ~5 o. Q! _) _) N - // once the elevator door is opened on the destination floor, , p! D' ]! M4 ~) ~1 t& n j. q$ d
- // redirect the agv to the exit control point
6 J& |. a/ a: p - agvredirect(agv, tonode(get(node("ExitCP", agvLabel))), REDIRECT_AND_WAIT);
6 R. q2 e1 k5 z3 j) F1 ~' j - return 0;
2 S" e6 F& A/ u, W; N - }& m% S) [" _" L0 p0 b
- case ON_DROPOFF_DOOR_CLOSED: {
/ D0 N2 C0 v( k9 q4 }5 O - treenode elev = param(1);
$ u! s q* {* f. ^" ~2 A - treenode agv = param(2);
' D7 b+ d5 C7 I% J - int isAGVWaiting = param(4);# i/ {3 j$ G% p
- // once the door is closed at the destination floor,
! a6 ]- h9 \9 T1 P! d - // if the agv is waiting, then send him to the final destination
/ l* Z" z# r% X5 C - if (isAGVWaiting)
" A7 n: q: x" D. y) Z# P) _ - agvredirect(agv, gettaskinvolved(gettasksequence(elev, 0), 1, 2), REDIRECT_AS_FINAL);
/ W! p, R+ }5 n" s! R - // release the elevator to finish his task sequence( I" ]6 x" B! Z2 @6 x
- freeoperators(elev, agv);
: S8 `* b# k; e2 @+ M+ \ - return 0;/ G8 I4 G$ q' q- m
- }% R+ |# ~! s+ _. C
- }2 ~! v5 m9 m" Z
- } //******* PickOption End *******\\
3 U2 Z i1 b- a - ; S- V- ^# k) k9 Q/ X1 J& U* i
复制代码
% g8 M7 Y4 [" V" z* f( O
2 N) A& I4 n% G, B" z; r* d/ O$ y" U" k$ k0 k7 D. [
办法2:使用工艺流程模块完成 |
|