|
办法1:从2016版本里面复制相应的代码
. A7 K. b1 v `2 g! Q
1 A+ |) W# P* j( J* i7 p) ^具体代码如下:
2 R$ h U; @% g7 o/ @# N- treenode agv = param(1);. e0 G1 `" @# ]! j/ W5 E6 u2 M& L6 s
- treenode currentCP = param(2);1 |" a' W" ~8 i, u: f, p9 }
+ \9 i4 g% d0 B' z# W/ _7 d& i- { //************* PickOption Start *************\\& i( l; E3 G9 w$ i9 m% x1 l
- /***popup:AGV_DivertToElevator*/8 {4 q q: l4 P2 {5 W! ]7 I5 B
- /***tag:Description*//**Divert to Elevator*/+ n' z5 }( Q+ c. b9 Y' x! J
- 9 i# l# G, G o* F
- int operation = param(3);
5 q+ L- M& ?, z- G; G
3 w5 h w9 v! Y( t3 V- #define AGV_LABEL_NAME "fs_AGV_Elev_State"
- U1 b6 u. H; u; Y/ J7 v - if (operation == 0 && !objectexists(label(agv, AGV_LABEL_NAME))/ H! X2 ]$ O( ~9 W
- && (/** \nCondition: *//***tag:Condition*//**/fabs(zloc(currentCP) - zloc(agvinfo(agv, AGV_DEST_CP))) > zsize(agv)/**/)) { // if it's a pointer, then do the initial case- b; g5 l$ M) c" H* Q
- // initial trigger execution, d) x; f0 g/ r
- #define ON_ELEVATOR_START 1. X& s" R2 @, f5 T1 q4 S8 V
- #define ON_ELEVATOR_PICKUP_ARRIVAL 2
+ v9 {4 p" o* A% m% O - #define ON_ELEVATOR_DROPOFF_ARRIVAL 3% f& J0 L. w1 A. B/ L
- #define ON_AGV_AT_CP 4
, x; \. u- ^9 A - #define ON_BOTH_AT_PICKUP 5- N0 D' Q- b8 U8 l0 o% J( N
- #define ON_OPEN_DOOR 68 k( X/ o6 o' F: A1 u+ q
- #define ON_CLOSE_DOOR 70 ^3 N+ B% W* a* z8 Q
- #define ON_PICKUP_DOOR_OPENED 80 W: }/ j) i5 [) ^- m
- #define ON_PICKUP_DOOR_CLOSED 93 E2 f% F$ m( H: G: {# B6 F2 L
- #define ON_DROPOFF_DOOR_OPENED 10; r+ g" a" w5 \, M( E# r
- #define ON_DROPOFF_DOOR_CLOSED 11* w1 f$ g" h* V5 v( {+ l
-
. J+ D- s1 F8 T0 `; a - #define AGV_STATE_START 05 I- n: E5 W) b' N
- #define AGV_STATE_AT_ENTRY_CP 1
# B l6 j5 P1 G4 Z8 s( |- Q - #define AGV_STATE_AT_ELEV_CP 2, X k; @0 b9 t. c' N5 b
- #define AGV_STATE_AT_EXIT_CP 33 l, k7 e$ C( C# y* F" W
- 6 K# i+ i$ @6 q& q6 j
- #define ELEV_STATE_NONE 0
{) a" q) x+ D$ N- \ - #define ELEV_STATE_AT_PICKUP_FLOOR 1
( k9 `% `6 I/ P8 c+ B - #define ELEV_STATE_OPENING_DOOR 2( E7 G- M4 q2 D' S
- #define ELEV_STATE_DOOR_OPENED 3
/ X( }& L! t( B: n
% {7 ~ d" g. e. ^2 B1 _0 C- |- ! U, i6 w1 |; u) u) ?
- treenode elevDisp = /** \nDispatcher: *//***tag:Dispatcher*//**/cpconnection(currentCP, "Elevators", 1)/**/;. h$ t1 P& D7 r9 c
- #define elevator outobject(elevDisp, $iter(1))
6 n+ k, g1 \) {* s6 d0 O3 B
9 w# @* C0 V; V" C; o2 o' V: G- if (!objectexists(elevDisp))
. R$ F' Z7 v- b- o - return 0;
& {% M5 I7 [! {7 H1 p* w7 V2 e - 4 l6 m# ?, a! |8 U
- if (/** \nDo Search: *//***tag:DoSearch*//**/1/**/) {5 W' z: O* }0 J: c" [" o
- query(& t0 U' e! m% n2 |7 w
- /** \nFull Query: */
; p% r' Y U: G8 W+ c& G - /***tag:FullQuery*//**/"SELECT $2 AS Elevator FROM $1 Elevators WHERE $3 ORDER BY $4 ASC LIMIT 1"/**/,
8 b6 V+ {$ o+ K9 i/ z6 }9 Z: ~ - nrop(elevDisp),2 I+ _# ^+ p+ [" u! ? j4 ]2 a
- elevator5 V; k/ i3 K% N6 N8 l$ q! @
- /** \nWhere*/, V% }' M5 D! j; Z% t% D
- /***tagex:WhereParams*/,/** \n*/ /**AND*/ /** */ /**/getstatenum(elevator) == STATE_IDLE /**/) D( } l3 D* r* K0 h4 G( [
- /***/
k' f2 G$ w9 v, M - /** \nOrderBy*/
& c* _/ M& g- p) x3 m' N/ Q - /***tagex:OrderByParams*/,/** \n*/ /**/fabs(zloc(elevator) - zloc(agv))/**/ /**ASC*/5 G) z8 [1 z9 t! H: P# {. ~! F% F
- /***/);* L- Q) i$ X5 `. K' R
6 T0 q$ h/ W1 l5 L/ h( `2 K- v- if (getquerymatchcount() > 0) A# d8 E8 p" [8 L8 G4 m# S% s: J
- elevDisp = getqueryvalue(1, 1);
8 T1 S5 p8 C6 n9 @7 b - }
! n6 Y: {. [7 d( o7 t U - if (!objectexists(elevDisp))0 R6 N' h( b$ X# P: q0 ~; @5 C
- return 0;, ~5 w$ B: |- K$ `6 ?: e$ \* Z
- treenode destCP = agvinfo(agv, AGV_DEST_CP);
3 P h! J$ }' o9 S/ Q' y, B - G" o+ M& F+ C1 N H
- agvredirect(agv, /** \nDivert Point When None Available: *//***tag:WaitDivertPoint*//**/currentCP/**/, REDIRECT_AND_WAIT);+ I! Q4 j* p+ z& {
- & Z. N* Z j/ Q W7 \7 B; Q: U
- // Create the task sequence for the elevator
4 Q$ W$ Z) V# R( Z5 X - double destZ = zloc(destCP);2 o- _2 m# j7 d! m
- treenode ts = createemptytasksequence(elevDisp, 0, 0);: P0 u. F6 E" F2 P) Z. u- A
- inserttask(ts, TASKTYPE_TAG, agv, destCP);
O# [4 i' i5 p - // immediately when the elevator starts the task sequence, I call ON_ELEVATOR_START6 P4 t i: S& e
- inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_START, destZ);( T/ J$ g- C3 P1 k+ N- Y% h
- // travel to the z location of the current control point; ^, A9 y6 j8 ]
- inserttask(ts, TASKTYPE_TRAVELTOLOC, 0, 0, 0, 0, zloc(currentCP));
: W6 F3 M7 _& r) `8 G; ~2 ~ - // then call ON_ELEVATOR_PICKUP_ARRIVAL
b& e% {; A! M! { - inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_PICKUP_ARRIVAL);, F- j8 O+ _0 K% P" i: j
- // then wait for the agv to get on
" Y7 x, Y: Z! \ - inserttask(ts, TASKTYPE_UTILIZE, agv);+ Z6 R, s" j0 i* M* G) N" V# o2 T0 ?
- // then travel to the destination z location( v/ |& |4 W7 @6 U7 ]" z; c
- inserttask(ts, TASKTYPE_TRAVELTOLOC, 0, 0, 0, 0, destZ);
E1 S. R/ g$ ]* m8 } - // then call ON_ELEVATOR_DROPOFF_ARRIVAL( Q+ C+ x9 O6 N$ x3 \8 C1 F
- inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_DROPOFF_ARRIVAL);
5 Z; w, ]6 B% j% D- V! _0 n - inserttask(ts, TASKTYPE_UTILIZE, agv);, I" w. h# y( T9 n- A, J$ W' k
- dispatchtasksequence(ts);7 w0 d% X+ R0 H) `/ T$ t
- } else switch (operation) {2 o: _, v0 ]* ]- \
- case ON_ELEVATOR_START: {8 U/ q$ D T9 i
- // this is fired when I get a valid elevator
0 O5 l) n: `/ ^ ]% l& S - treenode elev = param(1);
$ w: O9 H$ E3 t5 o( V+ ? - treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);# G9 g5 T5 U$ W/ X3 |+ z
- 6 \2 F! F2 y+ _+ K8 \9 o% z
- // find the closest floor control point( t. I0 q3 [$ R2 N O! o/ |
- int floorCPCon = cpconnection(0, /** \nFloor Control Point Connection:*//***tag:FloorCPs*//**/"Destination"/**/, 0);; X3 x+ w7 [. C) P5 l
- treenode curFloorCP = findmin(cpnumconnections(elev, floorCPCon),
m Z6 C' F" T* d$ k3 U" q- K - fabs(zloc(agv) - zloc(cpconnection(elev, floorCPCon, count))),* G: i' a! j. {2 k1 V( m
- cpconnection(elev, floorCPCon, count));
' r- P7 |3 A6 v5 I* M2 R* E - // return if there is none
$ y* e7 ~" c) a' |. b* K( p) ~% c - if (!objectexists(curFloorCP))
7 U, P& L! g( C5 Z \4 x* b - return 0;
& r' M% H$ m+ F8 d
w/ w- N6 K5 y9 ?6 y- // get the entry control point
, z" \8 K. h1 V2 }4 L3 i# n - treenode floorCP = curFloorCP;
! W1 m1 O& \7 M+ \ L, [0 m - treenode curFloorEntryCP = /** \nEntry Control Point: *//***tag:EntryCP*//**/cpconnection(floorCP, "EntryCP", 1)/**/;& E X9 P- a% ]
- if (!objectexists(curFloorEntryCP))! D. H, }! @2 _/ O" o# c- t) {+ z
- return 0;$ S8 Q# \' n: ]- z8 O
- treenode floorEntryCP = curFloorEntryCP;
& q; Q, V. I9 U. n" F: m! f# X' W - treenode curFloorElevCP = /** \nElevator Control Point: *//***tag:ElevCP*//**/floorCP/**/;' y7 r7 A! t7 P0 B* {$ u- l1 N5 ?
- if (!objectexists(curFloorElevCP))
$ z A) S8 J0 m: ?/ n - return 0;1 }/ x+ x$ ], g+ p) ?
* I5 K& h9 _( o" l5 m3 _0 g, P- double destZ = param(4);- A& V* c8 q# X9 J3 q a
- // find the floor control point closest to the destination floor
! r3 I: F/ A; k7 I - treenode destFloorCP = findmin(cpnumconnections(elev, floorCPCon), 5 ?7 Y2 U' M! S1 G1 T1 `
- fabs(destZ - zloc(cpconnection(elev, floorCPCon, count))),# Z+ z; R% i; N# ]
- cpconnection(elev, floorCPCon, count));5 G) W" Q7 m8 x- b0 P
- * z! S, _& v- e: k9 ?
- floorCP = destFloorCP;
9 Y" y+ y% w4 h U' C - treenode destFloorElevCP = /** \nDest Elevator Control Point: *//***tag:DestElevCP*//**/floorCP/**/;0 ^, a& r7 Y$ q- V& x1 i+ ^
- if (!objectexists(destFloorElevCP))
$ O' K, Y5 O& Y+ J$ ~) m) t - return 0;
, q3 l8 e6 ~3 U; v& Z6 `- p3 j - // get the destination exit control point
6 P; ]5 L. y9 A# w% Z' V - treenode destExitCP = /** \nExit Control Point: *//***tag:ExitCP*//**/cpconnection(floorCP, "ExitCP", 1)/**/;
2 |7 R: m( ?- U. {' ^ - if (!objectexists(destExitCP))2 |% v* Y9 [/ b+ f. F3 `6 k( }5 u
- return 0;
! R* _& I3 D. p( q2 _# ~0 E% [, J - 7 W7 V+ n) ?! u! F
7 `9 h9 b0 K+ a7 Y q- // add a listener for the agv. This will call this nodefunction in the ON_AGV_AT_CP section whenever the 6 i, |2 H! V* q3 r' [' Z! R/ _' Q
- // agv arrives at a node. I keep a state on the agv's state label, and then increment it each time! ~9 C* K/ O. n% Y: _
- // the listener is called so I know which control point he's at, i.e. entry, elev, or exit.
\5 z$ f# K; G7 I - agvaddlistener(agv, c, AGV_LISTEN_ARRIVAL | AGV_LISTEN_INTERMEDIATE_DEST,: q( Y* p: u4 m8 L& E
- agv, elev, ON_AGV_AT_CP, AGV_LISTENER_PARAM_NODE);$ x8 S5 ^8 c h0 J
- & _ A6 C: i+ [; r) v' Y3 B
- // set the data on the state label
- F- k3 V) i8 W6 C9 N! ^2 f - treenode stateLabel = assertlabel(agv, AGV_LABEL_NAME, DATATYPE_NUMBER);$ d& y* N1 q% B/ p* U- I
- switch_destroyonreset(stateLabel, 1);6 N) o! x$ f" a* b
- set(stateLabel, AGV_STATE_START);
: a. Y1 A" Q6 g" K) g( L2 g7 }' I - set(assertsubnode(stateLabel, "ElevState", DATATYPE_NUMBER), 0);
6 ]0 E$ m" h+ _ - nodepoint(assertsubnode(stateLabel, "ElevCP", DATATYPE_COUPLING), curFloorElevCP);
9 b% {3 n( q# {) o' H$ l" _! n - nodepoint(assertsubnode(stateLabel, "DestElevCP", DATATYPE_COUPLING), destFloorElevCP);
' Y8 M' @/ D+ ?( c/ Q' k' B - nodepoint(assertsubnode(stateLabel, "ExitCP", DATATYPE_COUPLING), destExitCP);
! c9 L$ i5 z9 j1 Q* Q( B. F; } - agvredirect(agv, curFloorEntryCP, REDIRECT_AND_WAIT);. a7 `( H, X# k v9 R
- return 0;3 k9 M% _7 S; h. J
- }
/ V+ ^& o8 }/ U - case ON_AGV_AT_CP: {5 d) R9 l# r0 o& v! u
- // this is fired by the agv listener every time the agv arrives at a node.
) q) |% t. R: _ H1 p - treenode agv = param(1);
9 S h" c5 [4 g' j C* x - treenode elev = param(2);) E* @6 \' k' Q, ^
- treenode stateLabel = label(agv, AGV_LABEL_NAME);
_, e- E2 ?3 O) o7 Q3 Z - // I increment the state label, and then switch on it
' z1 l: ]5 N9 y M8 n. t - inc(stateLabel, 1);0 x* ]# d7 c- W9 G2 K7 X
- switch (get(stateLabel)) {2 ?" a# D' c1 |+ V2 L9 z% s
- case AGV_STATE_AT_ENTRY_CP: {
/ }% o% u) k S7 k4 B, a - // the agv just arrived at the entry cp
. w7 J( ^2 u4 w/ T" E9 q- u6 | - // so, figure out where the elevator is.
( b% h9 Z0 k* S - int elevState = get(node("ElevState", stateLabel));* o- L* ?. v' y8 R# z/ h
- // if he's at the pickup floor with his door closed then open the door.
$ \$ y* n' o' \* B2 X5 F+ | - if (elevState == ELEV_STATE_AT_PICKUP_FLOOR)( f7 E0 A5 T: x" t ]
- nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_PICKUP_DOOR_OPENED);( t2 [: u- h: W8 v1 l+ M
- else if (elevState == ELEV_STATE_DOOR_OPENED) {
$ @' V9 `- F8 Q6 S/ K! c - // if his door is alread opened, then move the agv onto the elevator, i.e. to8 v. F3 Q% e, }( L$ Y
- // the elevator cp
( D! N/ _ j$ T. p0 e, d, l" N' |6 S& D - treenode elevatorCP = tonode(get(node("ElevCP", stateLabel)));
, X8 n8 X: ~& I, B! u - agvredirect(agv, elevatorCP, REDIRECT_AND_WAIT);
6 h# g3 a4 {- M9 h- y - }
. E. ?* M; Z [ {' Q/ c - break;7 C/ S% Y9 i0 X& @) q9 C# V
- }
# a/ T. ~& n. ?8 D - case AGV_STATE_AT_ELEV_CP: {
/ [# Z3 J+ @0 `5 s6 Y - // once the agv is at the elevator cp, close the door) f- I$ p' \5 r6 T
- nodefunction(c, agv, elev, ON_CLOSE_DOOR, ON_PICKUP_DOOR_CLOSED);
1 l+ E$ e& N4 H( F0 j( I2 t - break;& n3 ?8 Y3 J2 N; \9 e T2 Y
- }
- U9 [7 {/ Q5 s - case AGV_STATE_AT_EXIT_CP: {
+ w( ~ Y0 C; \4 @7 `) b+ v - // the agv is at the exit cp9 _0 \& o+ o. c, I& y/ D7 m* H
- // destroy the listener node because I'm finished listening. F5 {0 o) D9 |( C) Z
- treenode listenerNode = param(4);! |( d% O* @% [* ~
- destroyobject(listenerNode);
. [% S8 ` M" ~1 g8 K - int agvWait = /** \nWait On Door Close: *//***tag:WaitFinalDoorClose*//**/0/**/;
% I& k/ s! t2 H2 k - if (!agvWait) {
0 T, Z0 @1 V- n. @ - // if the agv is supposed to continue on, then tell him to go to his final destination
7 a; E- k( x" w+ g: e D0 S9 R) b" Q- L - treenode destCP = gettaskinvolved(gettasksequence(elev, 0), 1, 2);2 m9 n# k( q Y1 O$ M0 F
- agvredirect(agv, destCP, REDIRECT_AS_FINAL);
$ c) |7 ]/ y4 q" W% ?$ ^' D - }1 C8 G1 W* k C4 o/ |0 J
- // close the door! H; z9 H% b/ K, k" c/ y
- nodefunction(c, agv, elev, ON_CLOSE_DOOR, ON_DROPOFF_DOOR_CLOSED, agvWait);
5 a8 a2 O/ U- L - // and I'm finished with the state label so I can destroy it., G& X' E5 k/ s6 ~
- destroyobject(stateLabel);
* }& ~" I% V4 b - break;
. E0 Q( C, X) b+ m* ^1 t' b - }
' Q; |" _: `6 A1 a - }- [& O% P3 d! r5 _
- return 0;* |( o* G5 U3 T1 t) D
- }% `9 i5 r! U; d
- case ON_ELEVATOR_PICKUP_ARRIVAL: {
5 i+ X( L; ]8 c3 a6 u - // the elevator has arrived at the pick floor
: b% M7 j4 q2 m" }' F+ s - treenode elev = param(1);
1 b6 C- p% y- ` - treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);$ I9 \( r" f5 }6 K) S* {/ {
- treenode stateLabel = label(agv, AGV_LABEL_NAME);9 f* h3 I& S, {. v' m7 S3 }% C8 H5 |
- treenode elevState = node("ElevState", stateLabel);
; f' t5 N8 {* b3 g X+ ~ - // set the elevator state to at-pickup-floor
9 I1 F: d, `5 |) G/ S& X# D - set(elevState, ELEV_STATE_AT_PICKUP_FLOOR);" k& T& _2 B# Y! o8 {" g) }; V
-
( F+ l7 F; `4 @+ h! r - int openDoorImmediately = /** \nOpen Elevator Door Immediately: *//***tag:OpenDoorImmediate*//**/0/**/;
' g* z+ l% {) i - # _+ A! x1 ^8 S0 Y w7 l
- // if the agv is at the entry control point or I open the door immediately, then open it% X: K" B$ t5 e7 C
- if (get(stateLabel) == AGV_STATE_AT_ENTRY_CP || openDoorImmediately) {
0 D# m* L( o8 u" L! p P# s6 I, Z - set(elevState, ELEV_STATE_OPENING_DOOR);7 L0 \5 w. @' j. |$ q% l# N
- nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_PICKUP_DOOR_OPENED);
8 J- L, U2 R3 k6 ~5 s - }
7 D7 t: N: k6 H1 g6 ~* h" m. Z - return 0;
4 M( n6 q' l5 T* S5 B3 Q - }/ D* c0 Q: |9 k4 A1 W
- case ON_OPEN_DOOR: {
- K( b; F: @$ t - treenode agv = param(1);
# ~4 H- }1 g7 o: V& B; y& j6 y# J - treenode elev = param(2);
$ x$ X3 d$ L1 \, r - int nextStep = param(4);
3 A7 f9 s1 K) B4 ?: ~ - // open the door based on the time to open the door$ c8 _3 Y. k2 _- k. {' ~; ^
- double openDoorTime = /** \nDoor Open Delay:*//***tag:DoorOpenTime*//**/5/**/;( y( \5 Z8 O7 x) f; R, Q
- delayednodefunction(c, openDoorTime, elev, agv, nextStep);& c* v6 J3 @, U* r
- return 0;
$ X/ x; @* N' p/ q. ~6 y - }( V* t. r8 ^- z& z
- case ON_CLOSE_DOOR: {$ V$ ]! @; F7 g' h4 K' {
- treenode agv = param(1);
* y" X/ S. |8 n/ E - treenode elev = param(2);( O0 R# v5 P% V
- int nextStep = param(4);: F5 c5 ~% [: u. _& C
- // close the door base on the time to close the door
% c9 O5 }9 B1 H" U$ |- }- o, P- h - double delayTime = /** \nDoor Close Delay:*//***tag:DoorCloseTime*//**/5/**/;
" I/ q) ?' k( C# t( ^' v9 Q) \ - delayednodefunction(c, delayTime, elev, agv, nextStep, param(5));
; F N# m* d1 Z1 Q* J' X: g3 g. n - return 0;+ _& t( Q% d) V
- }- a4 D0 u3 ~1 a+ R. U1 \
- case ON_PICKUP_DOOR_OPENED: {0 a* S6 O( V/ N7 x
- // the elevator door has been opened on the pickup floor- V* b% h; e# v+ U! y
- treenode elev = param(1);
/ ^" j7 X. W7 R2 ^' l) K - treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);: L* A6 L+ q; x" z5 E
- treenode entryCP = cp(agv);% v8 `6 u" b4 N9 A
- treenode stateLabel = label(agv, AGV_LABEL_NAME);8 Z$ [- [1 e1 ^
- treenode elevatorCP = tonode(get(node("ElevCP", stateLabel)));. p; e9 u7 I& |- Q9 d
- treenode elevState = node("ElevState", stateLabel);! T; I J# _ v$ v0 o7 K' K
- // set the elevator state0 z9 {' Q4 l- q) \
- set(elevState, ELEV_STATE_DOOR_OPENED);
3 D+ |/ R8 ]4 V" V; \2 B - // if the agv is at the entry control point, move him to the elevator control point2 O U& {: d6 J7 u- A5 i
- if (get(stateLabel) == AGV_STATE_AT_ENTRY_CP)* x2 h4 N# A2 o7 D
- agvredirect(agv, elevatorCP, REDIRECT_AND_WAIT);
& f( O# U/ s% c: D, E' M8 Y! E9 E/ F - return 0;
+ j! r% A0 V6 d9 j - }1 b' z& l/ F& t( S8 |* o
- case ON_PICKUP_DOOR_CLOSED: {
* W! x; {9 a/ J) u! P2 M - treenode elev = param(1);. k5 Y2 i: D% ~# f; _3 H( F8 S
- treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);0 Y3 j0 \* d6 `/ O, c q% o$ ?: `
- // assign the agv to "no control point"3 E. H* ]3 I; L0 c
- agvreassigncp(agv, 0);4 l/ P) p2 h+ M6 R+ P9 a! H+ m j
- // move the agv into the elevator
4 W! W# W$ S6 Y - moveobject(agv, elev);
4 @4 \$ \: g! b' ~1 Q - setrot(agv, 0, 0, 0);
/ L4 A; w7 B2 \+ X6 [( |5 N - // release the elevator to continue to the destination floor: P7 s' ? m; a7 K* S
- freeoperators(elev, agv);
% X% r8 m! [$ q - return 0;
6 S3 }% A! O( f! t6 @; v: ? - }
7 A% J& Y7 D# }8 h2 t1 u& L. Q7 c3 D - case ON_ELEVATOR_DROPOFF_ARRIVAL: {
) v& P3 n) I# b& r! ?& V) u - treenode elev = param(1); h: q S( a5 w, n: R5 A
- treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1); X! e; d; u& Y
- // when the elevator arrives at the destination floor8 r3 ^& Z1 L/ Q6 E
- // move the agv back into the model
1 {, u4 E4 e2 x3 U6 T - moveobject(agv, model());
, H" \4 I# N$ R1 O9 l4 a. _ - // reassign it to the destination floor control point
6 v& L" [& q& H5 ? - agvreassigncp(agv, tonode(get(node("DestElevCP", label(agv, AGV_LABEL_NAME)))));4 G! b T- y" t9 \9 U- U
- // open the elevator door- v( E2 h/ O" R$ N( i! p
- nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_DROPOFF_DOOR_OPENED);
6 \% A8 S" ~ T& @" K1 n8 k - return 0;6 m2 ~9 c" H0 F" }% I+ @
- }" X* a! j. `' n! i" I: _; y" F1 Q
- case ON_DROPOFF_DOOR_OPENED: {
$ q4 ]' T8 A" v+ }1 f5 _3 z! j - treenode elev = param(1);
. H. c( h S p7 _8 W - treenode agv = param(2);/ s' w3 q3 j5 Q' u7 X6 U; y
- treenode agvLabel = label(agv, AGV_LABEL_NAME);& I0 V& N9 L8 A
- // once the elevator door is opened on the destination floor,
1 t9 r5 v7 [4 L. q - // redirect the agv to the exit control point
# B$ O. `3 A' \3 ?$ I - agvredirect(agv, tonode(get(node("ExitCP", agvLabel))), REDIRECT_AND_WAIT);1 Y( Q% I! [& r* _+ N" m/ C
- return 0;: C' ?. L- G: I+ N- u) C$ G' e
- }8 L F) z! j1 S' i3 v% `6 y* F! [
- case ON_DROPOFF_DOOR_CLOSED: {
) E. ^) H" T b7 l% ]4 ~; M - treenode elev = param(1);7 H4 E& z9 T e/ V
- treenode agv = param(2);- p+ [- P# V6 ]" _6 B4 [$ @+ F
- int isAGVWaiting = param(4);
0 L, y. ]" ^) X# Q, g0 r5 _) U - // once the door is closed at the destination floor,
% J7 Q- O* T O( h - // if the agv is waiting, then send him to the final destination
: a8 k! |& @' F6 U$ [ - if (isAGVWaiting)
; _. x1 f! T4 h, ? - agvredirect(agv, gettaskinvolved(gettasksequence(elev, 0), 1, 2), REDIRECT_AS_FINAL);& S6 u2 P7 W+ }& e4 D
- // release the elevator to finish his task sequence
' ^2 I) q' W- G - freeoperators(elev, agv);" u( K1 s6 c w
- return 0;# h, L* d2 S+ y
- }9 V0 f+ s5 P7 H, \: G. A4 r: E
- }
, E1 K& a: E$ y/ I x9 ~8 \ - } //******* PickOption End *******\\
6 K+ ?% ?: y7 h3 s
4 Q" D u8 K3 ~% j( D2 ~
复制代码 8 E# d# ?, _6 j( H+ K
2 T: }$ @) I8 [: T& }$ T/ K/ u: s$ q& x5 k& Z1 ?
办法2:使用工艺流程模块完成 |
|