全球FlexSim系统仿真中文论坛

搜索
查看: 6116|回复: 2
打印 上一主题 下一主题

2018.2.0版中AGV如何乘升降机?

[复制链接]
跳转到指定楼层
1#
Pureua 发表于 2018-11-4 16:20:35 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
请教一下,2018.2.0版中AGV模块,路径点逻辑里没有乘升降机的选项,如何实现这个操作?6 ]" U- F- J4 D+ y* k: A$ X$ J

& d3 Z! E5 Q/ W7 Q; V$ P

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
3#
 楼主| Pureua 发表于 2018-11-5 09:25:46 | 只看该作者
慧娴亚伦 发表于 2018-11-4 19:12
- B7 u( W; U: {; r9 m: |7 z( t& s2 c办法1:从2016版本里面复制相应的代码9 l0 u* Q/ C: q* r3 g6 s  W
: O3 w0 X) Y* A& w$ p' ]
具体代码如下:
& k. R% r" v+ H9 ~6 f
好的,非常感谢陈老师的解答~
2#
慧娴亚伦 发表于 2018-11-4 19:12:47 | 只看该作者
办法1:从2016版本里面复制相应的代码/ P" r/ @5 v9 K) P) `, X; c% X

/ [4 J# E" O2 {& Y) X( v具体代码如下:
3 a6 e1 W* K0 E1 y3 h! A+ ~! d
  1. treenode agv = param(1);- w* @4 |8 Y+ W5 m
  2. treenode currentCP = param(2);
    8 F- E8 T: i1 Y( l, N

  3. $ z8 V; D8 D9 @0 ]
  4. { //************* PickOption Start *************\\
    # _9 T  j! c$ B
  5. /***popup:AGV_DivertToElevator*/; n% `9 ]8 l) F( J% ~: G$ x
  6. /***tag:Description*//**Divert to Elevator*/1 i/ f9 }* ~' K" F

  7. 8 L* n& e5 p! ?$ `
  8. int operation = param(3);! H1 K0 F- r' H4 f3 V+ b

  9. 0 b& T! q' U& X
  10. #define AGV_LABEL_NAME "fs_AGV_Elev_State"
    4 Y0 ~+ n5 ~! z
  11. if (operation == 0 && !objectexists(label(agv, AGV_LABEL_NAME))- @, _2 G, x/ |# p& E8 T+ L! {
  12.                 && (/** \nCondition: *//***tag:Condition*//**/fabs(zloc(currentCP) - zloc(agvinfo(agv, AGV_DEST_CP))) > zsize(agv)/**/)) { // if it's a pointer, then do the initial case
    3 b/ }" Y. A/ w0 |; f
  13.         // initial trigger execution4 \$ m& W3 I  O9 j
  14.         #define ON_ELEVATOR_START 1
    0 n7 Y$ U) V  M
  15.         #define ON_ELEVATOR_PICKUP_ARRIVAL 2
    ; r. Z  b& Z, B3 ^
  16.         #define ON_ELEVATOR_DROPOFF_ARRIVAL 3
    , y2 B8 S  j# k4 ~! S
  17.         #define ON_AGV_AT_CP 4
    1 a+ d  O7 t3 x& ~; C  q+ c$ k2 c
  18.         #define ON_BOTH_AT_PICKUP 55 u% L8 h8 ?: R; j2 y8 _! t3 d
  19.         #define ON_OPEN_DOOR 6
    3 |# w- J# p* W
  20.         #define ON_CLOSE_DOOR 7
    8 I" ^% T$ E4 C. ^9 n
  21.         #define ON_PICKUP_DOOR_OPENED 8* ~7 m1 e( P  \
  22.         #define ON_PICKUP_DOOR_CLOSED 95 L  y! q+ Z6 _1 e
  23.         #define ON_DROPOFF_DOOR_OPENED 10, |& d- U* i* E0 K5 b  O- p
  24.         #define ON_DROPOFF_DOOR_CLOSED 11
    & i8 G# @- r2 j! P/ \- T9 G
  25.        
    7 t. ^: S5 w7 A  _
  26.         #define AGV_STATE_START 0
    4 x" n1 x! A& b
  27.         #define AGV_STATE_AT_ENTRY_CP 1
    5 @* }- ?* y+ a; _  H/ D7 W4 D
  28.         #define AGV_STATE_AT_ELEV_CP 2
    - V6 E) C5 l+ `
  29.         #define AGV_STATE_AT_EXIT_CP 3
    7 ^4 ~, u# [6 ?$ K! P9 R- t6 ?
  30.         2 n% q- o" r' T0 d$ W1 ]
  31.         #define ELEV_STATE_NONE 0. a* G6 ]: y) t8 i8 p
  32.         #define ELEV_STATE_AT_PICKUP_FLOOR 1* j# h( c6 K9 S: h
  33.         #define ELEV_STATE_OPENING_DOOR 2* s" X$ a2 \  T( @, P( b( ]
  34.         #define ELEV_STATE_DOOR_OPENED 31 G8 D  D- C% U1 ?

  35. " {; @, u  b  `( B+ E5 w
  36. ' d- T) j' x% H+ r6 u# I
  37.         treenode elevDisp = /** \nDispatcher: *//***tag:Dispatcher*//**/cpconnection(currentCP, "Elevators", 1)/**/;$ [/ J. _& J* {6 H( P
  38.         #define elevator outobject(elevDisp, $iter(1))
    $ H* }) T- B! s: t1 b

  39. # R5 V7 h: n* H
  40.         if (!objectexists(elevDisp))( Q0 X" }+ C1 m
  41.                 return 0;
    ( \( X. r; k5 _

  42. " g% s$ |1 n1 h7 v0 ~2 O
  43.         if (/** \nDo Search: *//***tag:DoSearch*//**/1/**/) {5 \1 m6 N2 p$ I4 Y4 C
  44.                 query(. K. _2 g, u) M: N! Z9 e2 q
  45.                         /** \nFull Query: */
    1 [7 a$ r) `; S8 |) @  p# z
  46.                         /***tag:FullQuery*//**/"SELECT $2 AS Elevator FROM $1 Elevators WHERE $3 ORDER BY $4 ASC LIMIT 1"/**/,
    0 F/ ^) ]- S% U; t5 B1 ]
  47.                         nrop(elevDisp),# a( P. `1 s. D; M5 Y6 a
  48.                         elevator8 f' J! n8 d9 Z
  49.                         /** \nWhere*/
    " I( K, O# F$ ~  v
  50.                         /***tagex:WhereParams*/,/** \n*/ /**AND*/ /** */ /**/getstatenum(elevator) == STATE_IDLE /**/
    # V& k/ `- {( m# Z8 U
  51.                         /***/
    ( _4 i8 P/ l4 S* r8 h
  52.                         /** \nOrderBy*/# T' b& O) A7 g: h
  53.                         /***tagex:OrderByParams*/,/** \n*/ /**/fabs(zloc(elevator) - zloc(agv))/**/ /**ASC*/  K* c* J0 b6 p- K5 H" t- v
  54.                         /***/);' v; Q& I  \! h. D

  55. 0 M( j1 T: G+ V
  56.                 if (getquerymatchcount() > 0)
    $ j$ l3 f1 G/ U' N
  57.                         elevDisp = getqueryvalue(1, 1);
    7 B5 ^; A+ v, }5 y1 P
  58.         }
    $ A2 b" Z2 h6 q6 {
  59.         if (!objectexists(elevDisp)); k# C. ?  v1 Z" e
  60.                 return 0;
    ) r2 w( q( u, x4 w, M! X' U
  61.         treenode destCP = agvinfo(agv, AGV_DEST_CP);
    ( W3 n0 W! y* X0 f, b
  62. * [! c( U+ m1 J4 y
  63.         agvredirect(agv, /** \nDivert Point When None Available: *//***tag:WaitDivertPoint*//**/currentCP/**/, REDIRECT_AND_WAIT);( t9 N  u& I' c8 h6 |
  64. 1 T8 n$ R8 L. H! d3 h* i- L
  65.         // Create the task sequence for the elevator. j2 n0 a  s) x+ _
  66.         double destZ = zloc(destCP);8 p) a  ]- c* z. U7 i
  67.         treenode ts = createemptytasksequence(elevDisp, 0, 0);: c( x4 N6 C" `  P
  68.         inserttask(ts, TASKTYPE_TAG, agv, destCP);
    ; M! s7 [, z& T, ^. _4 }. w
  69.         // immediately when the elevator starts the task sequence, I call ON_ELEVATOR_START
    7 T' E9 x+ K8 i; {
  70.         inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_START, destZ);
    7 @+ Q% Q2 R+ @8 @( X" y7 u4 I2 M0 J
  71.         // travel to the z location of the current control point) s; L# K) K3 f) Z1 L
  72.         inserttask(ts, TASKTYPE_TRAVELTOLOC, 0, 0, 0, 0, zloc(currentCP));
      [8 q, c1 @2 n# ?9 D( H6 P9 s; [
  73.         // then call ON_ELEVATOR_PICKUP_ARRIVAL
    0 v4 U4 W2 s" f) m7 Q6 Z
  74.         inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_PICKUP_ARRIVAL);
    ! t7 H: j9 h8 p# \
  75.         // then wait for the agv to get on8 J! g: D. @' I
  76.         inserttask(ts, TASKTYPE_UTILIZE, agv);' U/ ^4 _5 Z  W! a* L; X7 y$ c
  77.         // then travel to the destination z location' l6 c2 [0 J8 F6 m5 n* m1 @
  78.         inserttask(ts, TASKTYPE_TRAVELTOLOC, 0, 0, 0, 0, destZ);
    9 b" E. l, y* P8 g5 u( z% x
  79.         // then call ON_ELEVATOR_DROPOFF_ARRIVAL! w1 l6 k5 |7 c' I
  80.         inserttask(ts, TASKTYPE_NODEFUNCTION, c, 0, 0, ON_ELEVATOR_DROPOFF_ARRIVAL);& f; S) D1 x7 O2 U# M0 h
  81.         inserttask(ts, TASKTYPE_UTILIZE, agv);6 O9 `% L5 b) @) a+ S
  82.         dispatchtasksequence(ts);. S+ E& c0 c& b/ B; N/ @, f
  83. } else switch (operation) {
    * m* H+ c$ q  A  L% y- E' O1 T- g6 c
  84.         case ON_ELEVATOR_START: {
    ; x$ _+ q. O$ E* t! Q/ B5 C
  85.                 // this is fired when I get a valid elevator
    & X+ z0 L1 R9 t* W# h9 a! k
  86.                 treenode elev = param(1);
    9 r  s0 D, j. F
  87.                 treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);+ o( u4 c4 e  B) G: s, n5 E8 a

  88. 5 S3 k0 p9 T" G0 [  j
  89.                 // find the closest floor control point
      N" ]6 t' z4 y1 X) z* J+ F
  90.                 int floorCPCon = cpconnection(0, /** \nFloor Control Point Connection:*//***tag:FloorCPs*//**/"Destination"/**/, 0);
    1 V( u1 t- N# u' K8 C
  91.                 treenode curFloorCP = findmin(cpnumconnections(elev, floorCPCon), ) t5 T3 n4 c! _' o5 s2 T
  92.                                                         fabs(zloc(agv) - zloc(cpconnection(elev, floorCPCon, count))),
    4 [- S* ~2 C* A4 f& T: s  H
  93.                                                         cpconnection(elev, floorCPCon, count));0 ?$ \  l; P- x( x, ]8 b* P2 Y
  94.                 // return if there is none6 b6 a; A& w9 b/ q
  95.                 if (!objectexists(curFloorCP))
    $ Q# k1 J% q) e5 S
  96.                         return 0;! e* B& v& c+ v5 ~3 D# [# }/ P
  97. 8 q9 g. E" g' c4 i) M- B
  98.                 // get the entry control point
    0 q; y( B7 q. W6 v9 Z: P8 k4 A
  99.                 treenode floorCP = curFloorCP;  j! g, w/ ~5 |2 N9 Z
  100.                 treenode curFloorEntryCP = /** \nEntry Control Point: *//***tag:EntryCP*//**/cpconnection(floorCP, "EntryCP", 1)/**/;
    % e" K% i. Q9 n' z- K; E% [; V, C
  101.                 if (!objectexists(curFloorEntryCP))
    / C3 J0 q* b$ V/ u+ f4 K1 _
  102.                         return 0;: U; [: C* S+ }9 `. e& f
  103.                 treenode floorEntryCP = curFloorEntryCP;
    5 R% T8 O9 O/ g0 q5 E
  104.                 treenode curFloorElevCP = /** \nElevator Control Point: *//***tag:ElevCP*//**/floorCP/**/;
    ' a% ^3 h% C' u$ r5 S
  105.                 if (!objectexists(curFloorElevCP))
    , G) w; T4 U& U3 J3 Z
  106.                         return 0;
    , Q5 `" _7 j. C+ z8 S
  107. ' v1 p; @5 p  `  c3 `/ \
  108.                 double destZ = param(4);: r; z/ z# l7 U8 S  F/ J
  109.                 // find the floor control point closest to the destination floor( [' S, K( D  M" x# @: F9 y1 I
  110.                 treenode destFloorCP = findmin(cpnumconnections(elev, floorCPCon),
    # Y" h( f' L+ u
  111.                                                         fabs(destZ - zloc(cpconnection(elev, floorCPCon, count))),1 K: t4 |( W& t
  112.                                                         cpconnection(elev, floorCPCon, count));0 s$ ?: }+ q1 G$ x7 a
  113.                                                        
    1 v- Q/ u: V1 l3 F
  114.                 floorCP = destFloorCP;
    # V0 F6 }+ M3 d5 d2 d
  115.                 treenode destFloorElevCP = /** \nDest Elevator Control Point: *//***tag:DestElevCP*//**/floorCP/**/;$ T$ t& [5 M% a0 x+ Q6 S
  116.                 if (!objectexists(destFloorElevCP))6 d1 s9 l  S  d4 U8 _
  117.                         return 0;! A. W2 z# y# W3 Q! N% J
  118.                 // get the destination exit control point
    0 |6 m, L/ Q: f  ^, M
  119.                 treenode destExitCP = /** \nExit Control Point: *//***tag:ExitCP*//**/cpconnection(floorCP, "ExitCP", 1)/**/;
    0 d. r  a' O9 O0 W' `
  120.                 if (!objectexists(destExitCP))
    ! c- m  c! p: H
  121.                         return 0;' Y( J3 V8 F2 M! [$ t- l4 F4 _

  122. . f4 \* ?/ ^$ s7 Q; A5 f6 ^
  123. . _4 Q5 k( |6 n" H- K
  124.                 // add a listener for the agv. This will call this nodefunction in the ON_AGV_AT_CP section whenever the 1 P6 y$ C9 @/ f+ _8 O& q5 m  m
  125.                 // agv arrives at a node. I keep a state on the agv's state label, and then increment it each time
    / L2 c1 q1 D6 ?* D  B. Q. E
  126.                 // the listener is called so I know which control point he's at, i.e. entry, elev, or exit./ f0 d' F% F/ e6 y* _' J
  127.                 agvaddlistener(agv, c, AGV_LISTEN_ARRIVAL | AGV_LISTEN_INTERMEDIATE_DEST,
    ) b1 l1 K' y5 l. |7 o# ]9 b
  128.                         agv, elev, ON_AGV_AT_CP, AGV_LISTENER_PARAM_NODE);" k& T  d& c! N2 @6 `
  129.                 , n$ D, G( @& u! y
  130.                 // set the data on the state label
    4 p  O% R7 z6 ~6 g. {4 S
  131.                 treenode stateLabel = assertlabel(agv, AGV_LABEL_NAME, DATATYPE_NUMBER);% P+ r$ m. @, m- K7 k
  132.                 switch_destroyonreset(stateLabel, 1);
      {: X6 _, D* J
  133.                 set(stateLabel, AGV_STATE_START);
    + j) g4 n7 `+ U7 i( y! k  w+ ~" f. G, e' e
  134.                 set(assertsubnode(stateLabel, "ElevState", DATATYPE_NUMBER), 0);( Z- K$ c3 s7 \5 V1 z
  135.                 nodepoint(assertsubnode(stateLabel, "ElevCP", DATATYPE_COUPLING), curFloorElevCP);4 F3 W) d, s+ b) J" ^
  136.                 nodepoint(assertsubnode(stateLabel, "DestElevCP", DATATYPE_COUPLING), destFloorElevCP);
    2 ~- ~" q9 v4 ^
  137.                 nodepoint(assertsubnode(stateLabel, "ExitCP", DATATYPE_COUPLING), destExitCP);) J+ t2 D$ t7 L3 e+ Y
  138.                 agvredirect(agv, curFloorEntryCP, REDIRECT_AND_WAIT);  X* ~, V% O9 o! d6 Z
  139.                 return 0;
    # [. v/ \" D, A
  140.         }5 r2 s; F& S. w$ [- l5 N( c* I
  141.         case ON_AGV_AT_CP: {4 X2 l+ f  r' b! e
  142.                 // this is fired by the agv listener every time the agv arrives at a node.
    5 v5 O( y% r' Y- I$ ?
  143.                 treenode agv = param(1);
    : G+ ~# l. L! h* d6 E) l
  144.                 treenode elev = param(2);
    % s% a+ r7 _, B
  145.                 treenode stateLabel = label(agv, AGV_LABEL_NAME);
    6 M/ T& t' j) x3 `, `% `+ F  ^
  146.                 // I increment the state label, and then switch on it9 P' R) c1 m, x) n% [& F
  147.                 inc(stateLabel, 1);
    * p# z7 s, t( _* J
  148.                 switch (get(stateLabel)) {
    + s( N& k  p0 J! ]
  149.                         case AGV_STATE_AT_ENTRY_CP: {
    : @; Z! S- z6 t. H, ^; m
  150.                                 // the agv just arrived at the entry cp
    ! ^, |" m: B7 N1 W( }/ D
  151.                                 // so, figure out where the elevator is.
    : c7 \8 y- h. g: p, L. r3 P
  152.                                 int elevState = get(node("ElevState", stateLabel));
    ; o" b( a5 }( Z0 G# @5 m* e1 _+ a
  153.                                 // if he's at the pickup floor with his door closed then open the door.
    * a, e: `& k7 R# k& s
  154.                                 if (elevState == ELEV_STATE_AT_PICKUP_FLOOR)
    0 R6 L4 o* J* H
  155.                                         nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_PICKUP_DOOR_OPENED);  G+ n; Q* j7 L5 ~8 n6 U0 k
  156.                                 else if (elevState == ELEV_STATE_DOOR_OPENED) {
    6 e" f/ r  m" K9 z
  157.                                         // if his door is alread opened, then move the agv onto the elevator, i.e. to+ u7 D: a* U) R. R$ P/ g1 q
  158.                                         // the elevator cp
    / Y$ Q1 `" e2 T% [7 {3 M
  159.                                         treenode elevatorCP = tonode(get(node("ElevCP", stateLabel)));
    7 v, P7 c4 Y) J( N7 V4 t9 U
  160.                                         agvredirect(agv, elevatorCP, REDIRECT_AND_WAIT);
    ! J# ]( J: e9 y' _; r1 `! A
  161.                                 }
    ; v/ X7 M6 Q' |2 l0 q, Q( }
  162.                                 break;" |& ~% K8 {/ R" B4 H- a
  163.                         }% O0 i9 k! F. A5 `, i$ I# O  ?
  164.                         case AGV_STATE_AT_ELEV_CP: {
    $ U# P! ?+ r# r6 b2 [: I( v( r
  165.                                 // once the agv is at the elevator cp, close the door+ p; c8 t% ~& I7 v
  166.                                 nodefunction(c, agv, elev, ON_CLOSE_DOOR, ON_PICKUP_DOOR_CLOSED);
    + E7 |) u2 L1 z# k$ Z. Q! @+ b7 e
  167.                                 break;
    # a3 ]" z! C" N7 V. q
  168.                         }6 u0 \, X- @/ e7 A
  169.                         case AGV_STATE_AT_EXIT_CP: {
    , Z- O" p) p: W
  170.                                 // the agv is at the exit cp
      y, S3 Q7 A5 S* j. u
  171.                                 // destroy the listener node because I'm finished listening
    5 r+ _8 W/ Q! ^
  172.                                 treenode listenerNode = param(4);& J4 b" j* P# w" m0 m$ R6 }! `* ]9 y
  173.                                 destroyobject(listenerNode);
    8 F) f$ E9 q% ^
  174.                                 int agvWait = /** \nWait On Door Close: *//***tag:WaitFinalDoorClose*//**/0/**/;
    # L* _- _! d1 \! F1 {
  175.                                 if (!agvWait) {4 `6 [- B3 I7 |
  176.                                         // if the agv is supposed to continue on, then tell him to go to his final destination4 @, C; M* [% p1 h- H, u' s
  177.                                         treenode destCP = gettaskinvolved(gettasksequence(elev, 0), 1, 2);
    + [8 t2 d6 G- t$ w' z- I: X
  178.                                         agvredirect(agv, destCP, REDIRECT_AS_FINAL);
    4 Y+ ]3 G8 w6 K4 p# z
  179.                                 }4 s; f- o. U* i, U4 R+ `: P
  180.                                 // close the door
    , o9 S5 Y) ]$ f+ K4 @
  181.                                 nodefunction(c, agv, elev, ON_CLOSE_DOOR, ON_DROPOFF_DOOR_CLOSED, agvWait);5 @" [, m0 C" _  i
  182.                                 // and I'm finished with the state label so I can destroy it." e# y  q+ U) z3 j. C
  183.                                 destroyobject(stateLabel);$ _( w) H& |8 j& C% S; s  @/ \! s! h
  184.                                 break;
    ; x3 Q, z. w2 y' _8 T2 Q+ h
  185.                         }( f3 Y# k7 |  D# }& F
  186.                 }  j" T  v1 N; G- v
  187.                 return 0;
    1 P* Y5 P: n# K4 f7 e
  188.         }
    - `# g$ T9 I! y
  189.         case ON_ELEVATOR_PICKUP_ARRIVAL: {
    ) {! d2 ?4 W4 i- O4 `7 l
  190.                 // the elevator has arrived at the pick floor$ _) P: d6 i( o9 B8 x' `7 O
  191.                 treenode elev = param(1);
    ) P0 \4 @* w$ S2 _4 }
  192.                 treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);# {$ o0 l8 |3 V) |8 Q/ H( U
  193.                 treenode stateLabel = label(agv, AGV_LABEL_NAME);! a" h6 S- n1 F$ {8 a' m1 ^
  194.                 treenode elevState = node("ElevState", stateLabel);
    + B& P5 |/ r4 z  O- U
  195.                 // set the elevator state to at-pickup-floor
    9 {# b/ e6 R# y9 v- v8 i: O
  196.                 set(elevState, ELEV_STATE_AT_PICKUP_FLOOR);  B  i, K8 L9 `4 [# c( x3 U
  197.        
    : m0 Z8 S3 b  v' l. ~; g( ]0 Y
  198.                 int openDoorImmediately = /** \nOpen Elevator Door Immediately: *//***tag:OpenDoorImmediate*//**/0/**/;6 k2 n) k- f6 Y& I+ t
  199.                 # J2 z$ w) U8 }6 R+ Z
  200.                 // if the agv is at the entry control point or I open the door immediately, then open it
    ' E: Z+ D# v% q2 v/ [! o- [3 P* c
  201.                 if (get(stateLabel) == AGV_STATE_AT_ENTRY_CP || openDoorImmediately) {& c/ ^9 x+ _# P6 M; i
  202.                         set(elevState, ELEV_STATE_OPENING_DOOR);: {' Z7 W; b) M+ h) I, S
  203.                         nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_PICKUP_DOOR_OPENED);6 d6 ], }# Z7 C& a/ r4 R* \
  204.                 }
    8 Q  n+ f$ `& z, L6 l5 Z4 \8 O. r
  205.                 return 0;
    # \- Z9 ~" Q( P# ^5 [1 g1 M
  206.         }4 E9 Y& }0 S9 Z& t) t4 N6 m: A
  207.         case ON_OPEN_DOOR: {5 g6 F  u0 N3 [$ U; E2 J  S  u
  208.                 treenode agv = param(1);
    ; D9 R, x' Q* f: a3 S6 t+ o$ b
  209.                 treenode elev = param(2);
    2 w0 M& {! P7 I
  210.                 int nextStep = param(4);, n% u, i# I4 g  O) L
  211.                 // open the door based on the time to open the door
    * A. v. N6 {# Q* k# g9 U
  212.                 double openDoorTime = /** \nDoor Open Delay:*//***tag:DoorOpenTime*//**/5/**/;
    / t$ X5 O: q, G( y& t
  213.                 delayednodefunction(c, openDoorTime, elev, agv, nextStep);) t- K8 `( F, E' ?, M% V
  214.                 return 0;, a2 ?$ i  Q: }( S. s( ^4 ~" P5 R
  215.         }* r+ r& ]7 L2 F! b. h( ]
  216.         case ON_CLOSE_DOOR: {
    6 _' b/ E5 [$ Y- \( t. L3 c/ h4 i
  217.                 treenode agv = param(1);
    # Y- b) ^; L8 d' |$ L
  218.                 treenode elev = param(2);/ Q6 E, R) B1 `& Z6 f7 a$ v: e
  219.                 int nextStep = param(4);" B0 u0 r' E* k, K* q
  220.                 // close the door base on the time to close the door
    - d% {; I- I+ R; t7 B
  221.                 double delayTime = /** \nDoor Close Delay:*//***tag:DoorCloseTime*//**/5/**/;0 M0 U( Y( W% p* Y: H8 N
  222.                 delayednodefunction(c, delayTime, elev, agv, nextStep, param(5));
    # F0 t& o, t5 ]/ `( ]
  223.                 return 0;3 {. F4 i6 T" j5 A3 V4 w( c
  224.         }
    6 s1 E4 `" ?9 Q; s/ J7 y
  225.         case ON_PICKUP_DOOR_OPENED: {
    4 }2 ]+ d: p! B3 a! t% Y
  226.                 // the elevator door has been opened on the pickup floor
    8 ?1 e/ y4 q( X% a
  227.                 treenode elev = param(1);
    ; r) S1 `; f, Z$ i4 b% O1 y: d9 X
  228.                 treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);3 E- r5 b# u- l' N
  229.                 treenode entryCP = cp(agv);; [, T' o) s# m( p8 Z/ J# V/ a0 a
  230.                 treenode stateLabel = label(agv, AGV_LABEL_NAME);, E0 \2 {, L) x  K9 d6 X
  231.                 treenode elevatorCP = tonode(get(node("ElevCP", stateLabel)));
    6 A+ O! y. M1 h8 W
  232.                 treenode elevState = node("ElevState", stateLabel);. `' s( B: y! X1 b& D+ ^5 S) V+ [! H: J
  233.                 // set the elevator state
    2 n1 V) J+ s5 w" j- X/ G; [
  234.                 set(elevState, ELEV_STATE_DOOR_OPENED);9 e) [8 ~9 Z* p9 ?* p
  235.                 // if the agv is at the entry control point, move him to the elevator control point' }8 d& M" b: R" A, _
  236.                 if (get(stateLabel) == AGV_STATE_AT_ENTRY_CP)
      g+ O) |# T, M/ m# ]
  237.                         agvredirect(agv, elevatorCP, REDIRECT_AND_WAIT);8 J5 n4 v8 R- j, d' O9 |) e, [
  238.                 return 0;/ M4 p& K. r/ p
  239.         }1 ]9 P' j8 x, ^; G0 u* F
  240.         case ON_PICKUP_DOOR_CLOSED: {' L0 s2 p1 _! _) W1 w2 O
  241.                 treenode elev = param(1);
    0 {- o, X- X+ V  D8 a
  242.                 treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);* ~4 g- h" @& v# {
  243.                 // assign the agv to "no control point"
    . s3 u* B; _. `' i8 J* I* b
  244.                 agvreassigncp(agv, 0);
      d, r8 l: l8 j
  245.                 // move the agv into the elevator
    - r+ L- T! Z' f/ V
  246.                 moveobject(agv, elev);
    7 \: Z2 h0 A2 q+ I2 r6 T
  247.                 setrot(agv, 0, 0, 0);5 I( ^# ~/ R" U& E3 m
  248.                 // release the elevator to continue to the destination floor8 q, |3 ]; @& }" G
  249.                 freeoperators(elev, agv);. f# ~! K2 d  w# D) @
  250.                 return 0;
    * z) x$ b% o6 S' K# Y$ K7 n: y
  251.         }9 F, H- j" c7 L
  252.         case ON_ELEVATOR_DROPOFF_ARRIVAL: {
    ( |( u1 O' C4 v: K' d$ A
  253.                 treenode elev = param(1);. c9 b9 C" c& G* L9 I( E
  254.                 treenode agv = gettaskinvolved(gettasksequence(elev, 0), 1, 1);
    " N. e( E) ~: Y5 W) U8 ?  [
  255.                 // when the elevator arrives at the destination floor6 k, Z( r* S2 {* M! e4 t& F7 h; k
  256.                 // move the agv back into the model% E' F6 b* R! [' y! Z1 j
  257.                 moveobject(agv, model());# j0 [* a  f0 \( F/ L! o
  258.                 // reassign it to the destination floor control point. i% l; A1 `/ A8 D; ]% }% P# ?
  259.                 agvreassigncp(agv, tonode(get(node("DestElevCP", label(agv, AGV_LABEL_NAME)))));
    6 f5 H# p& ^$ v) x3 v+ Y* h$ U
  260.                 // open the elevator door, L6 B/ l" Z) m; \/ `" e) K* Z& Y1 a# {# F! a
  261.                 nodefunction(c, agv, elev, ON_OPEN_DOOR, ON_DROPOFF_DOOR_OPENED);
    4 G2 p; R: d- h) Q
  262.                 return 0;
    # @. ?+ A$ G0 n1 S! b6 u
  263.         }
    " C/ u# F; Y4 L. P. R# V
  264.         case ON_DROPOFF_DOOR_OPENED: {
    9 l: O- ?  `- B! N9 s" y+ t! v
  265.                 treenode elev = param(1);
    ! Y% y. I  S% b5 @" S9 X, ?4 z
  266.                 treenode agv = param(2);& O( Z: [0 }: o: Q7 n
  267.                 treenode agvLabel = label(agv, AGV_LABEL_NAME);" ~# G1 }. U& E5 e
  268.                 // once the elevator door is opened on the destination floor,
    ' c) N: P9 j1 C, y1 r* n
  269.                 // redirect the agv to the exit control point# Z4 U: P8 |+ n
  270.                 agvredirect(agv, tonode(get(node("ExitCP", agvLabel))), REDIRECT_AND_WAIT);
    9 D, A' P- V4 K1 ~1 X5 T
  271.                 return 0;
    : T# c/ D$ Z4 Q- X- V
  272.         }
    8 ?# Z' |7 m; I4 {
  273.         case ON_DROPOFF_DOOR_CLOSED: {0 k' K4 V8 v- V
  274.                 treenode elev = param(1);8 w6 w3 |1 T5 @' a
  275.                 treenode agv = param(2);: x+ i  x* \- V
  276.                 int isAGVWaiting = param(4);
    / ], N* Z( i2 c, m
  277.                 // once the door is closed at the destination floor,
    3 V7 \  W; w' m, d" @2 b, y) |
  278.                 // if the agv is waiting, then send him to the final destination
    $ l2 ?+ U8 g6 o' j: M+ l( o5 U5 Z
  279.                 if (isAGVWaiting)
    4 P' d7 P1 g/ k" c! o9 w. F9 T) m
  280.                         agvredirect(agv, gettaskinvolved(gettasksequence(elev, 0), 1, 2), REDIRECT_AS_FINAL);4 l2 I  N6 P) Y' z0 `: C
  281.                 // release the elevator to finish his task sequence- T  Z" X2 C$ h8 w& d9 |6 K
  282.                 freeoperators(elev, agv);
    % w3 m8 J& u5 A! H+ e
  283.                 return 0;
    & a! O# w7 o) g" u$ H- `2 {& R
  284.         }8 u" Z# L5 [6 p( M+ N! {0 ~
  285. }/ K, _+ J  l6 R' N* _- I5 u8 b
  286. } //******* PickOption End *******\\( Z: P" \. X# e. Y& g8 L3 r* C
  287. / W4 g  m/ @; m* w
复制代码
# J) R) I  a: B. [: O0 [, x, j. U8 B0 i

9 P+ d1 l  D7 F- [: l  u$ t5 _( ]/ u# m9 p- G: U" i6 D+ U
办法2:使用工艺流程模块完成
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|全球FlexSim系统仿真中文论坛 ( 京ICP备14043114号-2 )

GMT+8, 2025-6-30 18:09 , Processed in 0.077599 second(s), 15 queries .

Powered by Discuz! X3.3© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表