. K* c) y; t+ z: O' h# k' i* W /** F7 V a. {( f; m
* ( k6 Q+ l& {( H4 T3 o2 N z * This is the step behavior. 8 {8 I! L8 S' h2 m7 [ * @method step ) m5 L& t1 \ g# ^ *, ]* \, `+ [/ b. d4 a7 s& c
*/0 U% D6 i+ j+ a& b- @
@ScheduledMethod(5 c, ^( q7 Y+ _! N: c! Q1 J
start = 1d,: V, u1 o* y" e# h; v
interval = 1d, * g7 l! N {* v shuffle = false ) p- R6 {# u9 G1 E )& C S; T4 J( ?- `0 w
public void step() { ) J0 w3 x/ ?) I: Q 5 f* E& [3 ^$ D: O$ i" e // Note the simulation time. / f+ {7 {. O/ h% S7 B def time = GetTickCountInTimeUnits()2 C8 S3 F) w1 o* a/ j( p7 }
0 M0 v$ j) z) U0 r // This is a task. : {: G8 S9 w3 E2 w measurePressure=pressure+ RandomDraw(-20.0, 20.0) $ s: @) Y+ A, w \, ?+ a // End the method. : R% G: k: i9 j& Y return ( a7 N' c4 _% {8 q / B3 Z* |* E+ A8 Q4 z! u }
注意,在函数step中& L4 g$ x2 _; @& l" H. w
public def step(infrastructuredemo.GasNode watchedAgent) {+ { W r8 V f. Y& e0 b7 k* Y/ ^
//这里是watchedAgent/ G) Q7 j4 X; r, y' A
但是在语句中,你填的是watchedNode: F4 Q" O- p8 {! n5 C
// This is an agent decision. 5 i E; D8 v9 a9 H1 }2 V$ U if (watchedNode.pressure<200) { . X3 A8 o% ^6 ^/ a
setPressure(watchedAgent.pressure)& y% P, d. M# I& J" D5 B
变量名称须统一,可以都改为watchedAgent