|
办法1:从2016版本里面复制相应的代码
9 n! e* W7 U {4 n8 ~" y! x3 n# h i* N7 \7 X( Z ?% V( |
具体代码如下:" V- c2 b7 F% u0 E
- treenode agv = param(1);
7 f' B9 E8 X! ]8 v; v7 H - treenode currentCP = param(2);) P+ y( M) E; E: b& @9 D7 J# E
1 h0 \, u! ^- e7 B, [ b- { //************* PickOption Start *************\\) g4 V: R: Z! x
- /***popup:AGV_DivertToElevator*/9 e9 E( t, c' Y
- /***tag:Description*//**Divert to Elevator*/
2 r m. a$ ?# n8 O5 {; u+ N
, a" S' G# L2 p; J0 ~* y3 G" b9 ~. E3 M- int operation = param(3);
! k; Z$ v9 t6 ]0 Q5 | - 4 M7 T2 f \$ {0 _ {0 {
- #define AGV_LABEL_NAME "fs_AGV_Elev_State", j" M0 B& D' V, |# s+ x
- if (operation == 0 && !objectexists(label(agv, AGV_LABEL_NAME))8 w+ B o0 C6 O3 B9 x+ ~6 R
- && (/** \nCondition: *//***tag:Condition*//**/fabs(zloc(currentCP) - zloc(agvinfo(agv, AGV_DEST_CP))) > zsize(agv)/**/)) { // if it's a pointer, then do the initial case! ^6 i" [+ ]; Z7 u7 P. _
- // initial trigger execution
$ _* F! u2 M6 a- H6 n - #define ON_ELEVATOR_START 1
7 ]4 R4 \2 r0 d4 } - #define ON_ELEVATOR_PICKUP_ARRIVAL 2
[+ P5 Y+ H/ e! S - #define ON_ELEVATOR_DROPOFF_ARRIVAL 3
+ \% f- E+ o/ v- c - #define ON_AGV_AT_CP 4
) \7 y4 a, J3 ^/ X W- h" N - #define ON_BOTH_AT_PICKUP 5
/ |! o+ k3 u6 E6 H8 i8 T" } - #define ON_OPEN_DOOR 64 O( R2 A' P1 F
- #define ON_CLOSE_DOOR 7
+ l4 I7 h# p' S. `* ^/ K - #define ON_PICKUP_DOOR_OPENED 8; R B7 v7 v( w* ]* }0 t9 B
- #define ON_PICKUP_DOOR_CLOSED 9
! y/ q( E- V* F8 V' m - #define ON_DROPOFF_DOOR_OPENED 10
: K q0 c. i6 F3 ?; M3 c7 ?% g6 K - #define ON_DROPOFF_DOOR_CLOSED 11, O6 I6 F6 `2 I( _. O8 ?( `) o
-
, t! ?. y" E7 n - #define AGV_STATE_START 0* ~: N+ e5 E i! n9 d( J8 M8 x* U
- #define AGV_STATE_AT_ENTRY_CP 1
7 R& x) \+ P& j8 o, I - #define AGV_STATE_AT_ELEV_CP 2+ n* ~3 i. J: u$ e% ?9 ^$ M
- #define AGV_STATE_AT_EXIT_CP 3
& n" d2 L! a, w& P( D -
- \$ `, l6 u2 q! j4 W# K - #define ELEV_STATE_NONE 08 S6 e# ?5 |, T3 Q
- #define ELEV_STATE_AT_PICKUP_FLOOR 1
, S- B% n: Q/ I M) Q - #define ELEV_STATE_OPENING_DOOR 2* {# {# m8 B: K3 E) @& ]$ D7 X9 f
- #define ELEV_STATE_DOOR_OPENED 3, J+ x- p# w5 C9 D8 L+ ~
2 g' k" g; @% |3 ?2 Z) P- ' m6 v- v6 \+ _6 N3 m# V+ \
- treenode elevDisp = /** \nDispatcher: *//***tag:Dispatcher*//**/cpconnection(currentCP, "Elevators", 1)/**/;5 K/ S9 I& r( L( z" D! L; k! B0 g
- #define elevator outobject(elevDisp, $iter(1))
# O. i9 i3 N5 v/ a+ O, [$ n- h: E
9 n3 ~% i* z& H+ ^/ i- if (!objectexists(elevDisp)). q/ R! ` ?1 z6 H0 w& t: i/ ^: X
- return 0;
7 v% n* u( |7 Y! t8 Y# ~$ F, B - - i- d4 j! q+ F% v
- if (/** \nDo Search: *//***tag:DoSearch*//**/1/**/) {/ W2 H8 |( N; @8 W
- query(/ w2 F- a- K6 t$ N6 L; y* [! e0 K
- /** \nFull Query: */0 t4 b: E, }! E4 c: ?! Q5 p
- /***tag:FullQuery*//**/"SELECT $2 AS Elevator FROM $1 Elevators WHERE $3 ORDER BY $4 ASC LIMIT 1"/**/,
+ G" F9 u* ] U8 a) I4 g - nrop(elevDisp),4 w4 t; K8 ^5 o: M
- elevator' Q. J: o- r4 F5 T6 K* |
- /** \nWhere*/
1 s3 |& ^; N+ Q& K - /***tagex:WhereParams*/,/** \n*/ /**AND*/ /** */ /**/getstatenum(elevator) == STATE_IDLE /**/- F% U" n: s2 N% y' _. T
- /***/$ t, q) c: B- W- z% @: s2 `% L* H0 Y
- /** \nOrderBy*/; t' Z8 u: t& M
- /***tagex:OrderByParams*/,/** \n*/ /**/fabs(zloc(elevator) - zloc(agv))/**/ /**ASC*/
5 ?! F# L& i6 @ - /***/);
j& w8 e8 ]! W* O0 v5 I; |6 P/ s
" e0 _1 B. S3 H( v& h- if (getquerymatchcount() > 0)
1 B0 K& f P6 Z! s - elevDisp = getqueryvalue(1, 1);
' E( w: }5 h( ?- g% v9 O8 Z) F4 c - }
6 y4 q& l; o, `7 m; b8 M. F - if (!objectexists(elevDisp))
/ I6 F* N' P. q# n* O- H: u8 B - return 0; h6 A2 y4 j3 S/ w' _. k2 Y
- treenode destCP = agvinfo(agv, AGV_DEST_CP);; a) K: s/ V) B) e% m, k
9 W, o+ `) T0 ~. F2 E4 @- agvredirect(agv, /** \nDivert Point When None Available: *//***tag:WaitDivertPoint*//**/currentCP/**/, REDIRECT_AND_WAIT);
4 u# Q7 V5 n3 `! G2 C1 Y. { - ; w" I3 w. @; ]
- // Create the task sequence for the elevator* s' l3 b5 x/ O2 t9 m: b& o
- double destZ = zloc(destCP);
: f& F; J( K9 }% z+ Q6 d# l2 L- d$ e - treenode ts = createemptytasksequence(elevDisp, 0, 0);
6 v+ G3 `1 J4 s8 O- r - inserttask(ts, TASKTYPE_TAG, agv, destCP);2 I; g: o8 y6 b6 p! r: l
- // immediately when the elevator starts the task sequence, I call ON_ELEVATOR_START H- G+ s& W( V4 j6 }: ?4 a+ ^
- inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_START, destZ);% s( U, w8 ?/ N% F1 q+ Y @! A
- // travel to the z location of the current control point: k2 \. q1 n! C" e1 d3 m( s! `1 s
- inserttask(ts, TASKTYPE_TRAVELTOLOC, 0, 0, 0, 0, zloc(currentCP));
4 d' ]. o: @9 I& s$ L/ N - // then call ON_ELEVATOR_PICKUP_ARRIVAL7 {5 S. f( ^, X# x9 p
- inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_PICKUP_ARRIVAL);( [% ~& H1 q9 K; V: W2 E
- // then wait for the agv to get on
; y {5 D, J( [4 x) ]& G8 P' F" { - inserttask(ts, TASKTYPE_UTILIZE, agv);
i1 q' H7 h! P. }! F1 x2 T - // then travel to the destination z location
, A- I! P) @- Z0 k% p+ q( k$ P - inserttask(ts, TASKTYPE_TRAVELTOLOC, 0, 0, 0, 0, destZ);+ v7 M' R+ W4 |5 Z/ E) S( r
- // then call ON_ELEVATOR_DROPOFF_ARRIVAL
0 |7 m. g1 d0 c5 c m - inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_DROPOFF_ARRIVAL);
4 M- v9 Y- [0 v& d0 y% R5 B - inserttask(ts, TASKTYPE_UTILIZE, agv);
" s; }" i' L/ k: F - dispatchtasksequence(ts);
4 q5 |! ~* d( U3 F$ O - } else switch (operation) {
. U+ k" V7 E" d0 ^3 Z5 N: v - case ON_ELEVATOR_START: {9 v. E" m, O4 b$ ^% z4 L2 x1 f& H
- // this is fired when I get a valid elevator
& S4 K2 ?5 `- X3 o* p7 L - treenode elev = param(1);0 j& C V8 F a+ F/ d
- treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);% a. n6 y# |* l& X
- & {1 c# c' Q* Q4 E
- // find the closest floor control point
( h& ?7 R, J Z1 j6 [$ ]0 z- z - int floorCPCon = cpconnection(0, /** \nFloor Control Point Connection:*//***tag:FloorCPs*//**/"Destination"/**/, 0);# j2 ^6 @$ v( o- f* ]0 k0 h( Z' H
- treenode curFloorCP = findmin(cpnumconnections(elev, floorCPCon), # f/ G* k4 ~! f. G2 b
- fabs(zloc(agv) - zloc(cpconnection(elev, floorCPCon, count))),
6 G6 j9 F, U+ ^# d, B" s. I, C - cpconnection(elev, floorCPCon, count));
1 w7 }7 w6 N1 ]# W3 F5 F - // return if there is none
- I) U6 t% I0 M) H B, c% f( z - if (!objectexists(curFloorCP))0 u' A" \% c$ O4 B
- return 0;# J: s* `* c1 V1 [) i8 m J; W: d
- 8 L; e' p0 o2 L5 h6 @5 j3 Z( @0 B
- // get the entry control point0 Y( Y- G2 O0 Z9 [1 j
- treenode floorCP = curFloorCP;
2 O- A& E( w2 K, {. O; s - treenode curFloorEntryCP = /** \nEntry Control Point: *//***tag:EntryCP*//**/cpconnection(floorCP, "EntryCP", 1)/**/;
0 Y* m, c# j$ R0 W; a - if (!objectexists(curFloorEntryCP))( q) w$ {5 X( r; _4 d9 Y
- return 0;* ]( j4 S% w. f8 _
- treenode floorEntryCP = curFloorEntryCP;
# T% g( m- b7 f7 ]7 B# v( E/ Q r0 C - treenode curFloorElevCP = /** \nElevator Control Point: *//***tag:ElevCP*//**/floorCP/**/;2 Z; e1 H6 r3 j2 B/ a. t8 h- T* Q/ p
- if (!objectexists(curFloorElevCP))) L/ K7 }9 E' u4 ?* s" d
- return 0;
0 f* Z' s3 O: B, b/ @
$ e. H2 t$ d" k0 F s% j+ f' [6 X- double destZ = param(4);1 i* W8 ]3 f3 z
- // find the floor control point closest to the destination floor
6 v- K7 E' U5 |& J( ]5 z! a1 T1 p+ \ - treenode destFloorCP = findmin(cpnumconnections(elev, floorCPCon), `9 y7 ^5 a2 A( Z0 _
- fabs(destZ - zloc(cpconnection(elev, floorCPCon, count))),/ I j6 u# E: E# N/ o
- cpconnection(elev, floorCPCon, count));
" ?& @8 C7 X- Z* u i3 y -
8 s( U1 v; S' O. r - floorCP = destFloorCP;2 t. `3 O( f7 V/ Y% B
- treenode destFloorElevCP = /** \nDest Elevator Control Point: *//***tag:DestElevCP*//**/floorCP/**/;
5 A5 f# ]) W( [' i - if (!objectexists(destFloorElevCP))4 X8 C2 `, s+ x% H- z* e3 b
- return 0;
7 e4 J% N3 L+ l5 h- F! m - // get the destination exit control point; L4 L' F: h }( V8 C
- treenode destExitCP = /** \nExit Control Point: *//***tag:ExitCP*//**/cpconnection(floorCP, "ExitCP", 1)/**/;
: I2 U# H, @% K% x$ B - if (!objectexists(destExitCP))) M) j4 F4 J* j& c4 m% x, m. f: A
- return 0;
2 u2 h6 s& S+ |$ |- M; \ - ) g! \' P+ P1 K$ l- S( J1 Z
! g7 s" r1 \) W* d$ [- // add a listener for the agv. This will call this nodefunction in the ON_AGV_AT_CP section whenever the
. I; @, F* U+ O [' D - // agv arrives at a node. I keep a state on the agv's state label, and then increment it each time
' Q5 N9 U. t( }/ g - // the listener is called so I know which control point he's at, i.e. entry, elev, or exit.
% m1 z" }' b2 ?# ^7 E, m+ k - agvaddlistener(agv, c, AGV_LISTEN_ARRIVAL | AGV_LISTEN_INTERMEDIATE_DEST,
- n- k: M' H A" {5 } - agv, elev, ON_AGV_AT_CP, AGV_LISTENER_PARAM_NODE);
8 K; X0 g) H, x: Z" i' L% L - # Y% v+ ?8 E' m- ?5 N- @
- // set the data on the state label 1 a/ _6 p- [" b: @# J: {5 t8 g0 v
- treenode stateLabel = assertlabel(agv, AGV_LABEL_NAME, DATATYPE_NUMBER);; u* a/ D7 o' ^0 `
- switch_destroyonreset(stateLabel, 1);) o y7 V# z+ |! p) N
- set(stateLabel, AGV_STATE_START);4 p& M7 z: [" f4 h
- set(assertsubnode(stateLabel, "ElevState", DATATYPE_NUMBER), 0);# v- `: q$ }. H+ S0 h; ~
- nodepoint(assertsubnode(stateLabel, "ElevCP", DATATYPE_COUPLING), curFloorElevCP);. ]3 _4 [5 r f/ y z- i6 u
- nodepoint(assertsubnode(stateLabel, "DestElevCP", DATATYPE_COUPLING), destFloorElevCP);0 S: C: s' a' h; A# t
- nodepoint(assertsubnode(stateLabel, "ExitCP", DATATYPE_COUPLING), destExitCP);1 c% E9 X$ @7 I' T6 V/ O
- agvredirect(agv, curFloorEntryCP, REDIRECT_AND_WAIT);& Q! l2 i; }+ Z" E5 X: v8 O
- return 0;+ i& `% ~) J, q `3 T2 e
- }
9 S5 ?2 }. _3 @8 b- Z - case ON_AGV_AT_CP: {- N% @+ y9 ~4 l2 n+ L
- // this is fired by the agv listener every time the agv arrives at a node.
! {' a3 ]; L; d0 j( U - treenode agv = param(1);; h0 c8 \% L b g7 Q
- treenode elev = param(2);
' v+ @/ X: \$ N0 u8 g0 s& c* y - treenode stateLabel = label(agv, AGV_LABEL_NAME);
+ T% p0 z2 ]& q( M% } - // I increment the state label, and then switch on it0 ~ _& p; Y6 L: B) t
- inc(stateLabel, 1);" d0 x# M1 t9 }# l
- switch (get(stateLabel)) {
* Y T% L8 t0 F; l3 h% c4 e - case AGV_STATE_AT_ENTRY_CP: {' z c( k. C" y9 I: @
- // the agv just arrived at the entry cp2 O9 _# H, ^3 I- Q7 u" a9 o: n; l9 q; r- K
- // so, figure out where the elevator is.
- D; L4 N" g/ z2 U3 H5 C - int elevState = get(node("ElevState", stateLabel));0 j) G- t+ Q( \% B' s( K
- // if he's at the pickup floor with his door closed then open the door.
9 @: ]9 ]1 j* G- v1 Z - if (elevState == ELEV_STATE_AT_PICKUP_FLOOR)+ Q3 S7 B. _7 k. N: e& O) m
- nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_PICKUP_DOOR_OPENED);0 N# `3 o) |3 ]) F
- else if (elevState == ELEV_STATE_DOOR_OPENED) {; U2 D# ]9 m1 N" x5 M4 l
- // if his door is alread opened, then move the agv onto the elevator, i.e. to
% ~ M" y5 q2 n& ~ - // the elevator cp2 E, `9 _! U6 @7 g. Q
- treenode elevatorCP = tonode(get(node("ElevCP", stateLabel)));' b( ~9 Q1 X( n3 I: a
- agvredirect(agv, elevatorCP, REDIRECT_AND_WAIT);* ?5 p& m* b* k! X# m0 L; C
- }9 r9 n; u) |; }' j5 a( a1 e
- break;7 e. ~6 W$ V M" J ^
- }% G1 w2 z3 l3 l1 b! `0 A
- case AGV_STATE_AT_ELEV_CP: {
' A( n( u! J( d T - // once the agv is at the elevator cp, close the door
% u8 {: c$ g w/ X! X - nodefunction(c, agv, elev, ON_CLOSE_DOOR, ON_PICKUP_DOOR_CLOSED);
0 W% L. p+ R, r2 H) s1 j/ F - break; R0 X! r3 o; t; ?
- }# S7 Q' }1 x! V/ d9 q6 l" f
- case AGV_STATE_AT_EXIT_CP: {
. m% Y4 U- [8 z3 P - // the agv is at the exit cp
N; ~! f" g5 {- _2 I) k) X: A - // destroy the listener node because I'm finished listening
& D6 }! q9 ?0 x, l) a0 ^4 h - treenode listenerNode = param(4);+ t) p, y; T0 C4 e! C# }' ?
- destroyobject(listenerNode);2 [3 T. F1 x3 k
- int agvWait = /** \nWait On Door Close: *//***tag:WaitFinalDoorClose*//**/0/**/;5 ?5 f2 L6 T( g) A4 M; o! |, |
- if (!agvWait) {
. [& P' D3 |7 P l. v/ g2 P# k k - // if the agv is supposed to continue on, then tell him to go to his final destination
7 c/ G6 N. M0 D; W! R, u - treenode destCP = gettaskinvolved(gettasksequence(elev, 0), 1, 2);
( Q7 E7 g" u4 T2 A3 E7 w* U - agvredirect(agv, destCP, REDIRECT_AS_FINAL);9 G/ Y) H1 ^, k! @) a
- }
6 O& y; ^, _2 n - // close the door
1 c7 Y5 q- r: ^& `& D) N0 Q - nodefunction(c, agv, elev, ON_CLOSE_DOOR, ON_DROPOFF_DOOR_CLOSED, agvWait);
, E5 {, S; z7 }( L/ {' P# O0 k) s - // and I'm finished with the state label so I can destroy it.
, g0 a a8 Q; R* `! ]; g$ e - destroyobject(stateLabel);7 h7 q$ R5 |- W* F2 K+ e
- break;
2 K* J, F r! q6 S2 B - }/ C# } P7 A4 W2 y; ~
- }
+ f y5 J( ^6 O& F9 `( k - return 0;3 x% w# y6 ?: r5 b+ [
- }
P+ T# \6 f2 y) T8 H - case ON_ELEVATOR_PICKUP_ARRIVAL: {
2 r7 Q* Q. Z1 a+ y6 d - // the elevator has arrived at the pick floor. t& C# ?) P% q/ \) q5 C
- treenode elev = param(1);0 A! `: q$ F, N" m
- treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);( A. V" P4 I/ o/ d) ~
- treenode stateLabel = label(agv, AGV_LABEL_NAME);" [; l# O, k6 L; T8 K
- treenode elevState = node("ElevState", stateLabel);, h/ Y+ p. T3 g
- // set the elevator state to at-pickup-floor0 x: T+ }6 S5 M# I% m
- set(elevState, ELEV_STATE_AT_PICKUP_FLOOR);
/ N# S5 u$ F8 [. k# R* Q -
) z( l6 v- N; O+ E - int openDoorImmediately = /** \nOpen Elevator Door Immediately: *//***tag:OpenDoorImmediate*//**/0/**/;
k- V/ k- l; i5 \# ~' s: J" E - 7 O q, T4 s0 T! T3 H l# f5 q
- // if the agv is at the entry control point or I open the door immediately, then open it
% O& y! ~& N0 s @ t - if (get(stateLabel) == AGV_STATE_AT_ENTRY_CP || openDoorImmediately) {
/ a8 ?3 S5 e: x/ D, ` - set(elevState, ELEV_STATE_OPENING_DOOR);9 C0 {/ r5 X9 Y8 q4 Y+ Q
- nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_PICKUP_DOOR_OPENED);4 R/ e, @) V8 n ]. U
- }: Z7 o# b$ T; p; r+ ` n! v
- return 0;: X7 h2 Y, G A3 t
- }
( i$ X/ e. D& ?6 o - case ON_OPEN_DOOR: {) Q# p4 G! v; w! L4 C& j
- treenode agv = param(1);
8 A+ B3 H; l. k- ]8 s5 ~ - treenode elev = param(2); `* p! l6 [# Z$ f ? k3 M
- int nextStep = param(4);
+ q" X0 F: [1 |, l3 G' g - // open the door based on the time to open the door
+ L2 B9 j+ P2 `& h% O, V X9 b - double openDoorTime = /** \nDoor Open Delay:*//***tag:DoorOpenTime*//**/5/**/;7 m4 w5 E s: u/ d0 N
- delayednodefunction(c, openDoorTime, elev, agv, nextStep);/ q7 w! m3 d- d8 B; P2 ]9 ]
- return 0;
6 X0 w' f! Q& K) n - }# O0 A5 U& w! E, u& v5 Y& @/ ~% @0 w
- case ON_CLOSE_DOOR: {5 }7 c% u& f* J; _
- treenode agv = param(1);
( |; G# |; q. m& ^: ] - treenode elev = param(2);0 z v/ v9 Q: S% f
- int nextStep = param(4);4 x) L. r# n* G6 s3 i! R
- // close the door base on the time to close the door/ k# K; P) R9 j3 E' M
- double delayTime = /** \nDoor Close Delay:*//***tag:DoorCloseTime*//**/5/**/;
# t, j- H) l, A- f5 a - delayednodefunction(c, delayTime, elev, agv, nextStep, param(5));
3 C: R0 t; a7 G2 S6 p. Z - return 0;
% ^# Z* r: p2 V+ N8 b; n - } V7 G1 _. k6 I1 u& K& B7 N/ L
- case ON_PICKUP_DOOR_OPENED: {
- j: Q( Z& |6 D- e9 { - // the elevator door has been opened on the pickup floor
7 N: G3 v4 m3 \1 E/ v7 ] - treenode elev = param(1);0 n. A* @7 g6 l$ }/ P; f
- treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);7 J& U9 }; x) `0 N3 O- v% n
- treenode entryCP = cp(agv);
+ x3 X* u- H; q( R - treenode stateLabel = label(agv, AGV_LABEL_NAME);
6 @6 W, Q, H3 T8 | - treenode elevatorCP = tonode(get(node("ElevCP", stateLabel)));% K% z+ p r) {: I8 u9 C1 {
- treenode elevState = node("ElevState", stateLabel);
6 a. U0 U0 X# n* D7 i4 I - // set the elevator state9 Z9 f# {2 C4 Q, w8 i
- set(elevState, ELEV_STATE_DOOR_OPENED);+ Z, J7 I* Q: g
- // if the agv is at the entry control point, move him to the elevator control point
" i0 E" j! T& y S2 k+ T' w% {0 a - if (get(stateLabel) == AGV_STATE_AT_ENTRY_CP)8 p( w# N# c0 D5 b. u
- agvredirect(agv, elevatorCP, REDIRECT_AND_WAIT);
- w1 P% C9 [0 T+ ~ - return 0;+ \. \% k r" ^1 l U
- }
. b9 ~5 J* o5 Z* J - case ON_PICKUP_DOOR_CLOSED: {
# |, k0 p9 ?. ?3 r8 K# r - treenode elev = param(1);
+ i7 g& _% T/ @ - treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);. @. G4 N+ B# Y0 o5 q
- // assign the agv to "no control point"3 i6 e& o5 p" l: H: e: F- |" z
- agvreassigncp(agv, 0);* G0 T G* m% I9 X: X+ O$ s7 h
- // move the agv into the elevator
' C; \$ A2 f1 Q. y6 Y+ N/ J - moveobject(agv, elev);# J4 I+ P3 d0 T: K+ [
- setrot(agv, 0, 0, 0);
" R% Q! J/ F( E$ t. j - // release the elevator to continue to the destination floor
3 B$ w1 B, _( T - freeoperators(elev, agv);- W! i4 s3 L) z" R+ E. ]
- return 0;! p8 ^7 m1 e; G8 n9 Z5 A
- }5 I& y7 \' }& y) G$ f; B/ _, n' k
- case ON_ELEVATOR_DROPOFF_ARRIVAL: {
# H0 j+ y* B+ R: P - treenode elev = param(1);
) y% L6 I' c; \0 \! a* s, H/ ~) x - treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);
, ^( P, P" a+ D; i - // when the elevator arrives at the destination floor. j1 e& C+ a' d! a7 ^8 b, @' f8 z: r
- // move the agv back into the model: o3 f7 N5 i4 D9 Y8 B5 v4 d* s
- moveobject(agv, model());
- G; u5 K/ D6 a* u5 }. ?3 V - // reassign it to the destination floor control point. E7 x0 {0 I4 G; P4 @3 a) U
- agvreassigncp(agv, tonode(get(node("DestElevCP", label(agv, AGV_LABEL_NAME)))));
3 P- W/ T8 {1 d& f3 Q6 C( _* \8 Z' Z% B - // open the elevator door" N+ D# U$ ~4 n0 W h3 J
- nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_DROPOFF_DOOR_OPENED);
3 _ x& n; K: s1 [ - return 0;
* v% b# n+ t5 \" R6 a - }2 o( g" \) r' |$ t5 l0 h7 P
- case ON_DROPOFF_DOOR_OPENED: {
; Q/ u* q7 L, q7 W5 @8 V0 u% v - treenode elev = param(1);
& w8 e, d! ~* u7 F# V - treenode agv = param(2);
: T! B" V* s$ _. @) w* ~0 P. S - treenode agvLabel = label(agv, AGV_LABEL_NAME);
; g5 L8 E; t" g' Y - // once the elevator door is opened on the destination floor, ( t0 ]# j$ a) j! I( c2 O# V! @
- // redirect the agv to the exit control point
8 B! u1 P" D4 t; w - agvredirect(agv, tonode(get(node("ExitCP", agvLabel))), REDIRECT_AND_WAIT);
( i! p+ A4 w5 R3 K - return 0;
& R* f' X2 Y: k& j5 g - }
5 \% C% k2 C* d0 M3 z; X* d - case ON_DROPOFF_DOOR_CLOSED: {1 z/ C- U# s2 a- K/ J5 w
- treenode elev = param(1);
; E9 h" H5 @0 e: O/ q# }9 N - treenode agv = param(2);
: j, Q9 v8 I5 W. I, ] m( Q - int isAGVWaiting = param(4);
" ~! R7 C) N( r( x- S( B - // once the door is closed at the destination floor,
6 \) O9 i l5 j/ a - // if the agv is waiting, then send him to the final destination0 n* ]) o9 ^* y# B
- if (isAGVWaiting)
* w3 @7 L- }, L8 S/ Z, P - agvredirect(agv, gettaskinvolved(gettasksequence(elev, 0), 1, 2), REDIRECT_AS_FINAL);
- l2 F$ P C: D6 |7 \/ b. R! K2 C) r - // release the elevator to finish his task sequence% R0 F. n4 B2 a7 c2 \
- freeoperators(elev, agv);# q& A0 P& J. O- F# t
- return 0;
* Q1 T0 {- m' r( y - }5 F- G- r8 h/ I/ z @& _
- }2 G r% J; O3 X% h5 R" {8 U0 P" x: N
- } //******* PickOption End *******\\$ d$ J1 h* N5 Y# K5 C
* `- J% q4 y: O& I- N
复制代码 - K- }9 t6 S8 N: c7 G
# c6 t! q; m3 Y; I) q# o
8 u) g, r1 C1 _$ ]办法2:使用工艺流程模块完成 |
|