|
办法1:从2016版本里面复制相应的代码
" k& P2 g; X! D P/ j* f) }- k9 j3 \ h
q# u; x% o! o3 p% w, l3 U" [具体代码如下:
! E; n% e/ y6 _1 `: \% M+ {' C J- treenode agv = param(1);
4 |; x0 n7 ?! h/ d( h - treenode currentCP = param(2);8 u: `( d( O, Z. j2 ^
8 G1 b7 J+ D l# d6 ~- { //************* PickOption Start *************\\' N/ S$ [; r4 J. j! t
- /***popup:AGV_DivertToElevator*/4 u+ }( z7 e- D# E; G2 R: v
- /***tag:Description*//**Divert to Elevator*/9 t0 i0 C& X) A5 `' O/ `0 f
- * V$ A* V, m& D9 l
- int operation = param(3);
" b/ v9 }" y( _# N% W) a( c5 b
& f6 a6 J8 m' F5 I. Z- #define AGV_LABEL_NAME "fs_AGV_Elev_State"3 R& |3 Z: Q9 {7 e. F6 q; _4 k
- if (operation == 0 && !objectexists(label(agv, AGV_LABEL_NAME))
6 S: |. F2 T6 h$ Y8 _* N- ? - && (/** \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 c: C/ h: C6 i- ~7 q4 K& m - // initial trigger execution
& e' p- F; F) H' n0 B6 ^, D - #define ON_ELEVATOR_START 1) B) b5 P6 {: y
- #define ON_ELEVATOR_PICKUP_ARRIVAL 2/ Q O l- S' ~" ?4 D2 r/ T
- #define ON_ELEVATOR_DROPOFF_ARRIVAL 3) t6 ]+ e$ m5 J7 X$ @* `1 S
- #define ON_AGV_AT_CP 4" E* C( T* P6 L' G/ y
- #define ON_BOTH_AT_PICKUP 5
; j8 i, o0 S4 D; ?% L' ?, O4 r) ~ - #define ON_OPEN_DOOR 6
0 X- g. O$ X/ l8 v5 k3 t - #define ON_CLOSE_DOOR 7
! V5 m/ p: ^7 O! h0 k - #define ON_PICKUP_DOOR_OPENED 83 F, f9 R6 P& `: ~ [$ e0 v i1 y
- #define ON_PICKUP_DOOR_CLOSED 9
9 {- w/ E- s' S( P ]9 q - #define ON_DROPOFF_DOOR_OPENED 10
5 X- x, V; M1 _, ~7 i1 F - #define ON_DROPOFF_DOOR_CLOSED 111 ^1 @6 W8 j' K7 J2 `
-
5 U/ v' p8 \7 {. j6 I: n2 u - #define AGV_STATE_START 0
0 E2 ~9 h0 v" i0 J - #define AGV_STATE_AT_ENTRY_CP 1- c) m0 s4 y9 I8 l+ j
- #define AGV_STATE_AT_ELEV_CP 2
3 F: @5 Q4 Z& Y4 B8 g* ~. [' p - #define AGV_STATE_AT_EXIT_CP 3, `0 M0 Q4 q: O/ h3 A2 A( Q
- & K5 T7 d- y4 O- O8 `
- #define ELEV_STATE_NONE 0
; `: J( {; \) r4 H0 \( |3 _: m - #define ELEV_STATE_AT_PICKUP_FLOOR 1) a" [( {: `/ J; D8 G5 R$ E3 @2 K
- #define ELEV_STATE_OPENING_DOOR 2
- `2 N7 v+ Z' T; `+ ? - #define ELEV_STATE_DOOR_OPENED 3+ T4 {* C, Z: ^" X
1 [' t) O! U: P& w8 I7 y- 8 K5 Y1 |$ S- Y- Q0 z
- treenode elevDisp = /** \nDispatcher: *//***tag:Dispatcher*//**/cpconnection(currentCP, "Elevators", 1)/**/;" |+ s+ J1 i0 @) u" V. s4 }
- #define elevator outobject(elevDisp, $iter(1))
; J1 _$ m7 Z( `
* M9 l# ?: M9 |- if (!objectexists(elevDisp))& l/ s5 E7 F- r9 h& ~7 A
- return 0;
' D* M# s8 H/ G1 H0 q7 j
+ o" @- [- Q% A6 w. j, k* g ?4 v- if (/** \nDo Search: *//***tag:DoSearch*//**/1/**/) {7 ?1 [) i8 ^' j8 s
- query(
0 H7 z- j* o+ r0 \8 M - /** \nFull Query: */
6 v R) S i9 w! C, M - /***tag:FullQuery*//**/"SELECT $2 AS Elevator FROM $1 Elevators WHERE $3 ORDER BY $4 ASC LIMIT 1"/**/,
" j: w6 F7 s4 f - nrop(elevDisp),
* z3 L; U8 P* D# i! h# y9 A1 c; n - elevator( a4 n' a# h K5 O2 s
- /** \nWhere*/7 Y+ R+ ^5 T5 C. M, v! V
- /***tagex:WhereParams*/,/** \n*/ /**AND*/ /** */ /**/getstatenum(elevator) == STATE_IDLE /**/
% e, `: ^8 o7 }- k$ e* G - /***/
& u! C+ s( W9 k. T1 I$ Z! L2 f' Z - /** \nOrderBy*/9 l. U! ~' ]& u4 d, X
- /***tagex:OrderByParams*/,/** \n*/ /**/fabs(zloc(elevator) - zloc(agv))/**/ /**ASC*/% D( u1 T" n2 t. H" z- F2 i3 b& `7 H
- /***/);
1 S; ?0 y( x1 U
5 @- a0 S) k9 n0 D# }* G& k" W- if (getquerymatchcount() > 0)
' E$ t5 M8 r; m7 P( Z - elevDisp = getqueryvalue(1, 1); P% U b/ r9 U4 c, ] @
- }
0 y. B6 e5 L/ m1 q6 M. D - if (!objectexists(elevDisp)): n& Y' q7 C1 B- v
- return 0;& t! |' a# ] V" m$ B0 ]+ |
- treenode destCP = agvinfo(agv, AGV_DEST_CP);
$ O& T9 E: C* J( t4 r! b/ \) t
& e4 O1 P- Q8 b& z+ ]$ _9 S9 ]. y- agvredirect(agv, /** \nDivert Point When None Available: *//***tag:WaitDivertPoint*//**/currentCP/**/, REDIRECT_AND_WAIT);. N; A3 C& c5 L( N1 ]! y
- % W" U+ _& i9 p
- // Create the task sequence for the elevator
9 G) W5 o6 ]+ ~2 ~2 c - double destZ = zloc(destCP);
1 _. N' X2 @" ]8 B) Z - treenode ts = createemptytasksequence(elevDisp, 0, 0);( U! I7 A/ I! K2 k4 Y3 [
- inserttask(ts, TASKTYPE_TAG, agv, destCP);
$ v! x5 F+ V, p - // immediately when the elevator starts the task sequence, I call ON_ELEVATOR_START4 u# w2 c+ l1 L4 M5 p
- inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_START, destZ);( w1 |; d; C: y* h1 J, z6 M/ r. a
- // travel to the z location of the current control point( Q+ D2 I9 _8 U/ ]+ m
- inserttask(ts, TASKTYPE_TRAVELTOLOC, 0, 0, 0, 0, zloc(currentCP));
* T; h1 ~* T/ l* W - // then call ON_ELEVATOR_PICKUP_ARRIVAL
) ?" Z5 n9 [ c9 L - inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_PICKUP_ARRIVAL);
4 C2 l C7 E, m( G& p" d- g B - // then wait for the agv to get on/ N9 d. D1 Q) T- K9 s9 b. \
- inserttask(ts, TASKTYPE_UTILIZE, agv);& }1 K3 [# R6 h! Q" ^4 l
- // then travel to the destination z location
/ p' B% L& S. d* _* r/ x - inserttask(ts, TASKTYPE_TRAVELTOLOC, 0, 0, 0, 0, destZ);
' y+ O$ z' X2 ?, {# y - // then call ON_ELEVATOR_DROPOFF_ARRIVAL
6 X ^ P1 s+ j - inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_DROPOFF_ARRIVAL);
8 x3 s1 w9 W+ A1 z. b+ ` - inserttask(ts, TASKTYPE_UTILIZE, agv);: a7 o C" l2 F! K/ s4 f0 @0 A; E
- dispatchtasksequence(ts);
, k' ~# y1 I( [. W G: K/ Q4 ~1 O - } else switch (operation) {
# X7 b/ h2 w5 n0 U - case ON_ELEVATOR_START: {
3 ^) a4 t4 l: a4 z. }7 q - // this is fired when I get a valid elevator
3 I- T( {) Q0 k7 x - treenode elev = param(1);# i* x$ }0 A/ h$ J6 E
- treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);1 p! ?$ N3 p7 a1 D. `# p, [
2 u( _* x& M, \3 c5 t! S6 S# W- // find the closest floor control point
2 L5 u' `5 j( W - int floorCPCon = cpconnection(0, /** \nFloor Control Point Connection:*//***tag:FloorCPs*//**/"Destination"/**/, 0);
. ~0 E9 K5 J# B4 k) H" ] - treenode curFloorCP = findmin(cpnumconnections(elev, floorCPCon),
$ z, S% i; l6 G% z - fabs(zloc(agv) - zloc(cpconnection(elev, floorCPCon, count))),
9 }* u7 h: y4 Q" t+ r - cpconnection(elev, floorCPCon, count));. \! k" q3 h! X9 D" c
- // return if there is none
. M0 y. V& F8 m9 ]% w6 d - if (!objectexists(curFloorCP))
, K1 K$ m% x/ i Y" ]" n. B - return 0;
; R4 G& D0 N3 y - " K$ b. f% U: _- |' q- g$ E2 d
- // get the entry control point
K- f) l) @7 E5 `6 Y9 Z" L& Q6 T2 y - treenode floorCP = curFloorCP;
) L. ~( J: R' v7 A - treenode curFloorEntryCP = /** \nEntry Control Point: *//***tag:EntryCP*//**/cpconnection(floorCP, "EntryCP", 1)/**/;* o7 U0 d$ o! F9 G) M; ?
- if (!objectexists(curFloorEntryCP))( H" G) B3 L, p7 t p' ~2 }4 |
- return 0;8 Y1 E* | F2 M% H" R: F/ \, Z
- treenode floorEntryCP = curFloorEntryCP;3 o- c1 x5 m4 J* s. Y5 r# n
- treenode curFloorElevCP = /** \nElevator Control Point: *//***tag:ElevCP*//**/floorCP/**/;9 Z4 P; I+ {( K! Q& F5 _9 k4 |
- if (!objectexists(curFloorElevCP))
! p. {5 k, P; ]- C. N - return 0;
' l; v7 F8 O9 L9 h$ r
, b' R0 Z+ o" U/ z5 |- double destZ = param(4);
: S. Y3 G! Z1 i; s - // find the floor control point closest to the destination floor
$ v3 n h* y t M - treenode destFloorCP = findmin(cpnumconnections(elev, floorCPCon), , m& S3 f9 n7 O S9 V
- fabs(destZ - zloc(cpconnection(elev, floorCPCon, count))),
d0 I4 u, T# g6 E - cpconnection(elev, floorCPCon, count));
" i; W# Z) }& P* j -
+ K) L: u; e6 [% P - floorCP = destFloorCP;
+ Y! N0 Z2 r: a3 O. z' }3 d7 F - treenode destFloorElevCP = /** \nDest Elevator Control Point: *//***tag:DestElevCP*//**/floorCP/**/;
9 X i( w' r# C% q3 ^ - if (!objectexists(destFloorElevCP))+ E# J3 O8 S1 l. l+ [6 u/ j6 L
- return 0;& V/ c0 l( w3 F# O5 q
- // get the destination exit control point' [$ d- I1 e1 {1 w
- treenode destExitCP = /** \nExit Control Point: *//***tag:ExitCP*//**/cpconnection(floorCP, "ExitCP", 1)/**/;& l6 A4 O% s0 O7 t" `
- if (!objectexists(destExitCP))) [) C4 I/ _ ]& e, P C+ ]
- return 0; k3 S1 F q/ Q8 h0 c4 r; N
- 0 P2 C4 B' i3 Q
- ( [- U; w5 C1 k. o
- // add a listener for the agv. This will call this nodefunction in the ON_AGV_AT_CP section whenever the
! A- s: \# N7 p: @1 F - // agv arrives at a node. I keep a state on the agv's state label, and then increment it each time
* U& o/ y+ s( x" E, V1 G9 j; L. V - // the listener is called so I know which control point he's at, i.e. entry, elev, or exit.
# y P1 r1 q" X. b - agvaddlistener(agv, c, AGV_LISTEN_ARRIVAL | AGV_LISTEN_INTERMEDIATE_DEST,
/ K8 E) \1 c$ D - agv, elev, ON_AGV_AT_CP, AGV_LISTENER_PARAM_NODE);
6 x: m. [; v ^6 H* Q" k4 V -
+ g4 b7 K! g- x" L" _ - // set the data on the state label
9 Y7 E$ v! b2 m4 `4 w ^+ n, p - treenode stateLabel = assertlabel(agv, AGV_LABEL_NAME, DATATYPE_NUMBER);( F& z& F2 [6 Y+ A k
- switch_destroyonreset(stateLabel, 1);( l. w/ g3 z0 O! q% I3 ?5 g1 o
- set(stateLabel, AGV_STATE_START);
3 S/ ~- a0 H- K7 O3 O( P p6 y+ i - set(assertsubnode(stateLabel, "ElevState", DATATYPE_NUMBER), 0);; j# Y2 K/ Q1 R( y) n' y
- nodepoint(assertsubnode(stateLabel, "ElevCP", DATATYPE_COUPLING), curFloorElevCP);
- d; B* \* f$ \4 F# e: }! j - nodepoint(assertsubnode(stateLabel, "DestElevCP", DATATYPE_COUPLING), destFloorElevCP);
3 J, K! e c6 Q9 O& F - nodepoint(assertsubnode(stateLabel, "ExitCP", DATATYPE_COUPLING), destExitCP);
1 k- _3 H, H# m4 r0 H* i - agvredirect(agv, curFloorEntryCP, REDIRECT_AND_WAIT);
. m) H' U h' ]# I9 @ - return 0;! t9 w0 j {/ ?& R. ]* c& P# [$ i7 T8 D
- }1 W& S5 n+ C+ Y, ]- X# c$ I9 q
- case ON_AGV_AT_CP: {
1 R# h' u8 Z% V0 c2 n: w - // this is fired by the agv listener every time the agv arrives at a node.
. W6 F3 W- |: }6 J/ ?# N4 W J - treenode agv = param(1);
# j* z; Z& O" c3 N G, z - treenode elev = param(2);
- `" \( V w4 i" Z7 q4 I& k$ L - treenode stateLabel = label(agv, AGV_LABEL_NAME);
# O: g; N5 ^% ?4 h - // I increment the state label, and then switch on it6 H6 {/ ^& ? K3 i! u' A6 ` F
- inc(stateLabel, 1);$ e9 Z. C' ?7 P+ Q$ o" F, T
- switch (get(stateLabel)) {
% } k5 M5 _' L/ c* A/ c; q - case AGV_STATE_AT_ENTRY_CP: {* j5 T) B. _ l5 C
- // the agv just arrived at the entry cp5 b0 t$ t4 J+ r$ O( Y/ ?
- // so, figure out where the elevator is.
' I# |' n) x# S2 B9 g4 l - int elevState = get(node("ElevState", stateLabel));0 V* w3 t/ G5 ], {( V
- // if he's at the pickup floor with his door closed then open the door.
* Y% n1 _. ^2 ?* |/ e* ` - if (elevState == ELEV_STATE_AT_PICKUP_FLOOR)( f g0 q/ F9 O, g9 [
- nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_PICKUP_DOOR_OPENED);
0 P; o u8 J; Y$ }3 p% W - else if (elevState == ELEV_STATE_DOOR_OPENED) {
9 w2 Q( a" e1 B9 m' \* C - // if his door is alread opened, then move the agv onto the elevator, i.e. to) L& V) N+ x& K! S0 f' s
- // the elevator cp* q* s+ E$ p$ I" o H% |& _$ a
- treenode elevatorCP = tonode(get(node("ElevCP", stateLabel)));
h0 F' ?$ t7 [( o' B$ v3 G9 b - agvredirect(agv, elevatorCP, REDIRECT_AND_WAIT);! H, O. S. Y5 Y% z$ l3 s
- }
2 p0 n2 t& N: m$ c5 h4 B3 ? - break;% B( S& j1 g5 b3 g
- }8 {. J) w, ?2 e+ d
- case AGV_STATE_AT_ELEV_CP: {! d3 I* e6 O3 d; F! |% V5 i
- // once the agv is at the elevator cp, close the door
# k+ w2 {7 J- t6 D1 v m - nodefunction(c, agv, elev, ON_CLOSE_DOOR, ON_PICKUP_DOOR_CLOSED);
) m% }5 z8 K- m+ B; A! Y8 ?5 n - break;+ f* @) c; d) Y! V" N C
- }# p; k1 U S, A2 O
- case AGV_STATE_AT_EXIT_CP: {8 p. o& m; \% g* T# D+ U
- // the agv is at the exit cp1 V _" P. i- P2 I7 P7 O( k) R& l' K
- // destroy the listener node because I'm finished listening" H }4 r+ Y: M! G
- treenode listenerNode = param(4);4 y" e$ q; Y o- Y5 r
- destroyobject(listenerNode);
/ N( _; V; [+ ?: {2 } - int agvWait = /** \nWait On Door Close: *//***tag:WaitFinalDoorClose*//**/0/**/;
7 P/ l" ?! P q0 m& ? - if (!agvWait) {( ~* J- N% R6 ]& Q# t2 O5 W
- // if the agv is supposed to continue on, then tell him to go to his final destination
4 v$ e4 @# V' Z' Z Y - treenode destCP = gettaskinvolved(gettasksequence(elev, 0), 1, 2);
6 `' Z+ n! K J8 ]0 L5 {& }, C - agvredirect(agv, destCP, REDIRECT_AS_FINAL);1 `! J6 X0 P: l% r; }
- }5 R% ?0 U+ Z8 p+ f5 z
- // close the door
: g" c6 l4 }! f. o5 m% o( T7 v - nodefunction(c, agv, elev, ON_CLOSE_DOOR, ON_DROPOFF_DOOR_CLOSED, agvWait);
6 p( K$ o: a4 t1 S - // and I'm finished with the state label so I can destroy it.2 m& y2 H6 _; p8 a" d* C
- destroyobject(stateLabel);7 c) ]2 R! d# \# ~
- break;) `0 r2 k8 w2 |3 O
- }
- T, y$ x/ ~2 G* g - }
2 w4 p: l& D$ B8 V3 y1 T - return 0;
2 w/ E) H! g7 R, f) }" i - }
) o2 Q- [/ z9 |6 y O - case ON_ELEVATOR_PICKUP_ARRIVAL: {0 [: m b4 u# R" G6 O
- // the elevator has arrived at the pick floor
' }1 b# k, U1 U: J! R - treenode elev = param(1);6 H3 ^. z* s% q# h* A
- treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);
' W) t& r8 R/ P: ` | - treenode stateLabel = label(agv, AGV_LABEL_NAME);5 m$ t* u/ J1 Q5 @" W( ~' B4 |
- treenode elevState = node("ElevState", stateLabel);
$ ~' S* F* U7 ` - // set the elevator state to at-pickup-floor
3 u7 l! B! B& S3 c3 ~ - set(elevState, ELEV_STATE_AT_PICKUP_FLOOR);& R1 v7 L d# U$ {& ~/ f- w1 ?5 u
- $ P3 ^7 U8 ?0 _
- int openDoorImmediately = /** \nOpen Elevator Door Immediately: *//***tag:OpenDoorImmediate*//**/0/**/;
. S3 H) n& a3 Y2 F5 @ - 0 t5 Q1 s8 k; `+ K1 Y
- // if the agv is at the entry control point or I open the door immediately, then open it
" m& X `7 {3 C0 r. [ - if (get(stateLabel) == AGV_STATE_AT_ENTRY_CP || openDoorImmediately) {/ A1 P# b, X' V4 I9 y
- set(elevState, ELEV_STATE_OPENING_DOOR);
4 M& w& Z# u; \ - nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_PICKUP_DOOR_OPENED);
E9 R/ F. h9 A' ?- O2 ] - }
6 g5 Y6 C F5 ~1 p - return 0;, p" N/ `# b5 d9 G. `& y4 X
- }
n2 \6 N7 K$ I! Z( U2 b* ` - case ON_OPEN_DOOR: {
1 i/ r$ z- D5 y9 U( f; d) a - treenode agv = param(1);
' \0 L' V; h% i! |, w - treenode elev = param(2);) ?" b7 D+ m' `$ I! @
- int nextStep = param(4);
) U6 b6 z" m9 w - // open the door based on the time to open the door( {* Q: A8 f# i+ A
- double openDoorTime = /** \nDoor Open Delay:*//***tag:DoorOpenTime*//**/5/**/;; C [+ C* }; z* ~& M' O1 t7 C
- delayednodefunction(c, openDoorTime, elev, agv, nextStep);' h: s' z8 Y7 l. J& a. e2 Z
- return 0;% X4 ]+ u6 z2 n9 C6 B$ r: _' V
- }
' w( f. m& w8 M4 @8 k7 T - case ON_CLOSE_DOOR: {
8 Q+ H. f5 D1 s; R - treenode agv = param(1);
8 C" N: n; s) J/ _2 n - treenode elev = param(2);' q$ r' G7 I3 V) w+ Y
- int nextStep = param(4);
1 N9 V# P3 X" S0 @3 t) Z - // close the door base on the time to close the door
, `- l# h9 G- y - double delayTime = /** \nDoor Close Delay:*//***tag:DoorCloseTime*//**/5/**/;0 o, x1 J( w6 s0 {
- delayednodefunction(c, delayTime, elev, agv, nextStep, param(5));
7 J) |. m: U9 z e: d+ n' I - return 0;
5 Q2 ^ V" {6 U+ D9 }6 J9 ^4 c - }3 s9 E- H$ y5 T/ N4 ^
- case ON_PICKUP_DOOR_OPENED: {
9 `* L" p; v6 T7 H6 k8 x - // the elevator door has been opened on the pickup floor
& `6 \- Z( f: z ~; }+ Z - treenode elev = param(1);' W+ J6 E7 A2 e' P3 h3 F
- treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);
" p1 H; y3 u; n/ ]0 p - treenode entryCP = cp(agv);+ V, f# A6 K' b5 r) Z# {5 Q' I) [
- treenode stateLabel = label(agv, AGV_LABEL_NAME);. q/ C( X2 j M2 ]
- treenode elevatorCP = tonode(get(node("ElevCP", stateLabel)));- ^; h- p7 i) `, Z$ ~( q
- treenode elevState = node("ElevState", stateLabel);
& K7 J; i6 F' V9 g* R8 D: E - // set the elevator state1 ]; B3 z0 b. v) e& w/ w, R s
- set(elevState, ELEV_STATE_DOOR_OPENED);
! f: B/ ]2 a5 P$ f - // if the agv is at the entry control point, move him to the elevator control point
1 _3 _4 j$ l! d1 k - if (get(stateLabel) == AGV_STATE_AT_ENTRY_CP)
1 d/ M) v. V3 T) m" L+ g/ }: \ - agvredirect(agv, elevatorCP, REDIRECT_AND_WAIT); t9 R3 B# y# G4 F. f
- return 0;$ Q! L5 }: l- w
- }
9 ] e" A0 e9 w/ W - case ON_PICKUP_DOOR_CLOSED: {% O' _! M" l) u# G: f4 Z1 g
- treenode elev = param(1);
, ~- F& ], r6 L3 C! o, } - treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);; v2 w4 e7 R' C, X/ b& j
- // assign the agv to "no control point"
+ ?1 Q6 D4 @% P. V - agvreassigncp(agv, 0);
- \! T: |' [: `9 C* K/ F- V - // move the agv into the elevator
) J p6 l! J, m0 O - moveobject(agv, elev);
' v# y& y/ b8 \& Z) g - setrot(agv, 0, 0, 0);
: w1 |7 }" D: Y. H# w0 @$ a8 a - // release the elevator to continue to the destination floor
0 M$ N' z. }( ^4 m - freeoperators(elev, agv); X+ A1 Y/ ^0 f V% I, s! e6 v+ U
- return 0;
% }( Y4 a5 C9 S0 B7 l - }) s2 g/ h9 i+ ~ g/ ~
- case ON_ELEVATOR_DROPOFF_ARRIVAL: {
7 H' f( {. R7 Y9 Y. v( A3 G - treenode elev = param(1);
; O. r7 }( W; h8 T: C - treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);/ k, W7 w0 e2 D$ z
- // when the elevator arrives at the destination floor* h- y/ j2 {; R) m2 ]4 Q+ n z0 L
- // move the agv back into the model
9 q) G4 w ]/ v! B2 c( _" W - moveobject(agv, model());
# ~# v Q( l w( M - // reassign it to the destination floor control point
6 t6 N' u( x- i, G, u - agvreassigncp(agv, tonode(get(node("DestElevCP", label(agv, AGV_LABEL_NAME)))));7 R: j# ^8 ~4 \0 w
- // open the elevator door
$ y6 m/ `' a" r9 X+ g- ]! ^4 N; g5 k - nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_DROPOFF_DOOR_OPENED);( W7 b# L3 [; t1 V
- return 0;
* g$ H/ S7 \1 `; i. K2 d9 b$ e - } G. }% _/ F0 R* [; K; b
- case ON_DROPOFF_DOOR_OPENED: { }" Z7 c; k4 { H; u
- treenode elev = param(1);
2 W7 S% A ]* h( i0 }/ M - treenode agv = param(2);
- M; G j- C% }+ _$ p, W+ F - treenode agvLabel = label(agv, AGV_LABEL_NAME);* ^; J( f0 S" U: d& Y* F- T+ ~ j
- // once the elevator door is opened on the destination floor, ( s4 b# O! |4 x) b0 e9 Y! z# |
- // redirect the agv to the exit control point
. K1 S4 h0 C) E) ]( A - agvredirect(agv, tonode(get(node("ExitCP", agvLabel))), REDIRECT_AND_WAIT);
; h# c' l3 J/ t) M) M) | - return 0;
( b0 a( u! b; @8 |( H - }4 w+ X3 y1 K' b1 N, l% m
- case ON_DROPOFF_DOOR_CLOSED: {) Q8 C/ s# }% L' g6 Z3 O
- treenode elev = param(1);/ M( L! z! A) I) _$ R8 F3 O
- treenode agv = param(2);! E) e5 @1 t& i2 j: y2 {" ]9 c7 ~0 d
- int isAGVWaiting = param(4);
l2 Z: R! q/ O* y - // once the door is closed at the destination floor,1 T' ?5 m( m# j% m! M0 s6 _
- // if the agv is waiting, then send him to the final destination3 q8 B% O6 O. M8 V r
- if (isAGVWaiting)9 O* F5 _# c: |! ]- l- m5 _6 t
- agvredirect(agv, gettaskinvolved(gettasksequence(elev, 0), 1, 2), REDIRECT_AS_FINAL);' e1 Z8 D5 h( Z" s9 N, C
- // release the elevator to finish his task sequence
. z8 H# M- ]0 T9 v$ \0 ?; p - freeoperators(elev, agv);% E$ x- o% Q: e! U
- return 0;
% d% O( T. O: Y# @) a$ _- c - }1 I; O6 j3 T( l* ^# W2 M. \/ S! ]
- } I I" j9 M" z$ i1 x$ P
- } //******* PickOption End *******\\! G5 ^* J: x5 S* A. B0 D5 V) N/ h- k
6 \( {1 s8 g c5 ?9 ]
复制代码 : J5 ?' H- A: R
1 `; C3 \' s* o1 |0 h
& Q0 A# S/ M1 v0 L
办法2:使用工艺流程模块完成 |
|