设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6317|回复: 3

[求助] 不能在waituntil的statement中访问table

  [复制链接]
发表于 2010-9-27 10:51:09 | 显示全部楼层 |阅读模式
我写的一个程序想实现在IObuffer中的MU按时刻表exit,若需要exit的时候IObuffer中没有MU,那一旦IObuffer中有MU就立即exit。IObuffer的名字是zhuZhan,程序如下:
$ g2 _# u( Q2 D3 l# q7 y" Dis       
7 @" o) Q0 S# j# @" Mdo       
3 G% N# z3 ?9 S( d        waituntil EventController.simTime = Schedule[now_depart_num];4 ]8 ~5 r+ g! M& w' ?. Y1 E: r
        if zhuZhan.empty = false- y- ^3 [1 h" T! p
        then . o. u+ t# q# f- Q
                zhuZhan[1].move();( X8 K$ a$ f2 u2 j) S: \% g
                now_depart_num = now_depart_num + 1;               
6 g/ v6 x  H0 h. @5 R$ N1 j        else: Q: n+ f7 {; v- e
                waituntil zhuZhan.empty = false;/ A6 A1 |% F- @
                zhuZhan[1].move();1 i0 c3 _) e" v; l) d& O! |
                now_depart_num = now_depart_num + 1;
! @8 j% X1 x3 ]        end;                                        8 n! T" X7 x  r7 U& W
end;7 P8 M. |/ S& h6 x3 I1 [

. j  s0 z' @" N) W+ ^! I但是一直说有错误,提示信息是:access to tables is not allowed within a waituntil statement.
. t$ n) Y9 o9 E" {0 P7 e若是增加一个局部变量,如下:4 _/ A/ p/ s+ {
is 3 T" b3 J# t5 t8 v8 v
              depart_time : time;
& n1 m/ x- U5 ^0 P6 kdo
  R7 ?- z9 ^" W+ C              depart_time := schedule[now_depart_num];
3 x5 \3 }6 C) `: W              waituntil EventController.simTime = depart_time; ' S$ n5 k4 u$ G3 G( ~, o
              。。。3 D4 @, u" f; P9 |
又会出现syntax error near line 5 at <;>!8 e0 P, }/ |% z1 ]& n! T) U  K8 i
) x( Y% s4 \5 K# t! O
各位大侠帮帮忙,或者教我怎么改程序的错误,或者教教我用别的方法实现我的目的,谢谢了!
发表于 2010-9-27 15:54:06 | 显示全部楼层
waituntil 有很多限制条件,监控variable是可以的,表格好像是不行的。另外,这个命令对程序的performance有很大影响,能不用就尽量不要用。有一个技巧,通过不断循环的方式来实现时间点的控制。
: _/ m- p  Z! z4 G# s# d; W* D4 E4 R
now_depart_num := 1;: {! H$ e. P! S9 L6 X
begin_time := 0;8 k' H$ B& M# T0 e9 ~" m
while 1 = 1 loop, E) c, S# g5 q- `& b
depart_time := schedule[now_depart_num];3 k7 ?% X9 ~  E* o
wait depart_time - begin_time;
) Q1 K: N0 W; i; K ....
0 P5 h( D' t& b( Z
/ p& @8 n: G* d  j begin_time := depart_time;* d6 j$ u8 l, |
now_depart_num := now_depart_num + 1;
4 j' r) i3 b' A+ Z* Zend;
 楼主| 发表于 2010-9-27 19:31:24 | 显示全部楼层
回复 2# SimChen谢谢楼上热心指导,只是我还是没有太明白,尤其是begin_time在程序中是起什么作用的?它是怎么从0变成now_depart_time的?
发表于 2010-9-29 13:28:22 | 显示全部楼层
我尽量用你的变量定义,增加了一个begin_time3 M$ M. L# s- s8 A9 Z: ^
depart_time和begin_time的差就是要等待的时间,也就是表格相邻两行定义的时间' U* i7 ]3 {& ~4 D2 F1 y" C
每次等待以后把now_depart_num增加1,表格就往下走一行。% T7 v5 b% u+ q4 c- u
/ s& B3 Y) O  ]5 b- U) ?
另外,这个程序原则上由Init调用,所以起始时间是0,然后每次等待后上一个终止点就是下一个起始点。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2026-9-16 00:30 , Processed in 0.016416 second(s), 14 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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