-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSendParamsBehavior.java
More file actions
70 lines (60 loc) · 2.1 KB
/
SendParamsBehavior.java
File metadata and controls
70 lines (60 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.masim.meteoAgents;
import java.io.IOException;
import com.masim.core.MeasureAgent;
import com.masim.core.ParamInfo;
import com.masim.ui.Console;
import com.masim.utils.SimProcessState;
import com.masim.utils.SimulationFramework;
import jade.core.AID;
import jade.core.Agent;
import jade.core.behaviours.TickerBehaviour;
import jade.lang.acl.ACLMessage;
public class SendParamsBehavior extends TickerBehaviour {
Agent _agnt;
double currentVal=0;
protected SendParamsBehavior(Agent agnt){
super(agnt,SimulationFramework.SIMSPEED);
_agnt=agnt;
}
@Override
protected void onTick() {
String name="";
if(SimulationFramework.getCurrentSimProcessState()== SimProcessState.Started){
/*ACLMessage runStep=_agnt.receive();
if(runStep!=null){*/
MeasureAgent msa=(MeasureAgent)_agnt;
if( msa.getMeasuredParam().getName().equalsIgnoreCase("Hu")){
int t=SimulationFramework.getCurrentEnv().T;
currentVal=SimulationFramework.getCurrentEnv().hu_V.getData().get(t);
name="Hu";
}
if( msa.getMeasuredParam().getName().equalsIgnoreCase("Temp")){
int t=SimulationFramework.getCurrentEnv().T;
currentVal=SimulationFramework.getCurrentEnv().temp_V.getData().get(t);
name="Temp";
}
if( msa.getMeasuredParam().getName().equalsIgnoreCase("WS")){
int t=SimulationFramework.getCurrentEnv().T;
currentVal=SimulationFramework.getCurrentEnv().ws_V.getData().get(t);
name="ws";
}
ParamInfo prmInfo= new ParamInfo();
prmInfo.setValue(currentVal);
prmInfo.setName(name);
ACLMessage predictionMsg= new ACLMessage(ACLMessage.INFORM);
try {
predictionMsg.setContentObject(prmInfo);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
predictionMsg.addReceiver(new AID("PM10",AID.ISLOCALNAME));
_agnt.send(predictionMsg);
ACLMessage reply=_agnt.receive();
if(reply!=null){
//Console.logMSG(_agnt.getName()+" : <CONFIRMATION>");
}
//}
}
}
}