在groovy出现下述程序,但在gasnode groovy里显示错误,请帮助解决 % X% N4 N( X5 f7 ^7 q7 _) Y/ B# R8 L
, h, ]1 M/ d4 C% R% }+ z6 I+ V
@Parameter (displayName = "Measured Pressure", usageName = "measured pressure") ' a1 Q$ [+ a1 d, h: @ public double getMeasured pressure() {. R5 `5 l1 f# B6 Y
return measured pressure9 z* n! |/ B: ?+ g" x7 H" o
}! \- q* @+ d/ f6 `9 H2 w3 G
public void setMeasured pressure(double newValue) {% R0 S6 O$ T; b$ u! }
measured pressure = newValue ) f6 j9 P" x4 S( U+ d }& M* q" n0 M; {0 y* T
public double measured pressure = 0 ) X- L( S6 V9 I7 G- B 8 {+ S0 i, _6 Q0 Z( ^- t' | /**' p7 j0 h: E: B$ L1 [! t
*. B5 r0 ^) i4 A
* This value is used to automatically generate agent identifiers./ {- W) b9 D) F; F
* @field serialVersionUID; Q2 s1 S4 ~! Z3 G% B% |
* ; P5 Z0 G# X" n$ O, W$ r' h" y7 { */* t m) E- d5 G8 N
private static final long serialVersionUID = 1L1 T. y, r3 q+ c) d% O
: p1 ^ Y+ c, f$ k# h1 ^' I! a$ Q8 i
/** 2 y' ?9 e) j3 C7 } *4 m0 ~. }1 z2 J6 K1 G
* This value is used to automatically generate agent identifiers. : m7 v% j" _0 F% Q; ]4 s * @field agentIDCounter 9 I/ D5 x5 c: U' T8 B; B * 2 z1 V- j+ F" p" L8 \ */0 v! ?' d. H8 }- g7 A' V
protected static long agentIDCounter = 1 * `' Z8 X/ V% H" Z, G3 I6 a7 k. h2 p' _
/** # M' j3 L) {; D6 M, e * . S9 H3 z& O! Q% G; `2 F * This value is the agent's identifier.5 Y8 E- x! `/ q/ X
* @field agentID) T5 c0 v; K" I! s
* ! x4 B; s4 g+ ]1 m( X1 Y */+ k2 N+ H3 J: x" C1 T' I; ^/ C, G
protected String agentID = "GasNode " + (agentIDCounter++)4 A' q4 V3 c2 h @+ K4 {, p( q& H9 m: A; `
, Q. M- U+ r! ~* _; S5 G. w e /**3 W0 U8 T1 P6 A! s' C
*! W k9 C. v+ t9 D5 G( T
* This is the step behavior.- ~) b! Z' ?) Y4 c' K
* @method step% D# ]1 D4 j5 j# S; k
* # Z3 }5 A* U3 |# I" c+ S% e */8 C) Q$ W0 c( \3 W8 j
@Watch(; I3 `9 o( h, C! h! k; Y$ R% L& |' W
watcheeClassName = 'infrastructuredemo.GasNode', % X/ ?' W" o3 y; ?6 ~0 ?/ I. m watcheeFieldNames = 'pressure',4 N# x9 a1 e, P$ [" E
query = 'linked_from', + h! F' ^* Y! {) q0 W, x whenToTrigger = WatcherTriggerSchedule.LATER, 6 j8 g5 o3 o* C; _" q* `# J8 \ scheduleTriggerDelta = 10d4 U6 E, z& ~0 f! ]3 p# i
) # E- ?2 @ x" i0 v+ t public def step(infrastructuredemo.GasNode watchedAgent) {0 Q( n: g3 O8 Q5 `
7 K/ f- j8 K( q6 N9 V3 K& e( U // Define the return value variable. / R( ?* c, \' Z8 s* X5 B* j def returnValue 2 v; E. B4 l6 m% i/ A: { 0 z% R, I! D* w3 f: s9 v // Note the simulation time.1 R) T6 {4 y1 N+ d) i
def time = GetTickCountInTimeUnits()5 C$ R; o: S2 A6 m& M( L
# B/ T' g/ N# G5 b1 `
1 `7 U5 y% ~5 V/ i# |- ~ // This is an agent decision. 9 u! p, [/ ?( P2 Y6 O/ D% b if (watchedNode.pressure<200) {# E8 A e0 P" u1 a; _9 ]
+ J: ~$ n6 P6 K% I! ^
// This is a task.+ q" t5 u2 J. I
setPressure(watchedAgent.pressure)9 ^+ Z, `; T+ y( i
注意,在函数step中 ' G6 A5 h, V: O& T+ \& A7 c public def step(infrastructuredemo.GasNode watchedAgent) { 3 _3 A# Y, P/ d //这里是watchedAgent / ~3 F" n7 b* D* E6 D 但是在语句中,你填的是watchedNode $ B7 b" Q/ i) t6 h, q* T( F // This is an agent decision., }1 V& d. g. ]8 C: ]9 r
if (watchedNode.pressure<200) { . `6 k+ b, t# g! z/ P setPressure(watchedAgent.pressure), h- h. Z, N L( T; U) E
变量名称须统一,可以都改为watchedAgent