flexiblepower / powermatcher

PowerMatcher - The Java implementation of the PowerMatcher, including the API, the core, a couple of examples, a remote implementation using websockets and a visualisation of the configuration.
http://www.powermatcher.org
Apache License 2.0
43 stars 25 forks source link

Question: Confusion about the 'ObjectiveAgent' class #205

Closed sjtu-jason closed 8 years ago

sjtu-jason commented 8 years ago

I have downloaded the codes from the 'development' branch here and made some try. However, the 'ObjectiveAgent' class doesn't work. The value of the 'currentStatus.isConnected()' at row 145 in this class is always false.

Would you please tell me the reason?

alex254 commented 8 years ago

Did you follow these steps?

Setting up IDE:

1) http://fpai-ci.sensorlab.tno.nl/builds/powermatcher-documentation/master/html/SettingUpTheIDE.html

and setting up a simple cluster:

2) http://fpai-ci.sensorlab.tno.nl/builds/powermatcher-documentation/master/html/SimplePMCluster.html

If this works adding objective agent shouldnt be too hard...

sjtu-jason commented 8 years ago

Thank you for your response. Yes, I did follow the steps. The 'freezer' and 'PVPanelAgent' are both able to run smoothly with their initial Settings. But the 'ObjectiveAgent' doesn't work with the initial Setting. It shows: 'INFO n.p.examples.ObjectiveAgent - Not connection'.

alex254 commented 8 years ago

hmm weird, I tested mine just now and it is working... can you run PM in debug mode?

set a breakpoint here: https://github.com/flexiblepower/powermatcher/blob/development/net.powermatcher.examples/src/net/powermatcher/examples/ObjectiveAgent.java#L85

and set up a cluster where you connect auctioneer -> concentrator -> freezer and then objectiveagent -> auctioneer

When you add obj agent it should jump in activate method and you should be able to reach L85..

sjtu-jason commented 8 years ago

I haven't learnt how to run PM in debug mode, would you please tell me how? Thank you.

In spite of this, I set up a cluster as you said, and get the information 'INFO n.p.examples.ObjectiveAgent - Objective agent activated' from the Eclipse's Console column, so there is no doubt that the ObjectiveAgent is activated.

Actually, the problem is about the line #146 of the code which you mentioned. The value of the 'currentStatus.isConnected()' is always false. I don't know why...

alex254 commented 8 years ago

in your IDE open net.powermatcher.examples, there you can see examples.bndrun

when you open this file, you should have started osgi here with run (top right corner) you can also start it in debug mode...

sjtu-jason commented 8 years ago

Thank you very much. I know the debug mode now.

When I add objective agent, it reaches Line 85 as you said.

But I don't know why the value of the 'currentStatus.isConnected()' in Line 146 is always false. And how to set it true?

alex254 commented 8 years ago

hmm I see the problem; I need to look into this...might be a bug :) in that case tx :P

sjtu-jason commented 8 years ago

Thank you. Looking forward to your reply :)

wilcowijbrandi commented 8 years ago

I've taken a quick look. I'm not sure if line 46 and 47 are correct: @Component(designateFactory = ObjectiveAgent.Config.class, immediate = true, provide = { ObservableAgent.class })

Maybe try to add AgentEndpoint.class to the annotation (you probably also need to import that class): @Component(designateFactory = ObjectiveAgent.Config.class, immediate = true, provide = { AgentEndpoint.class, ObservableAgent.class })

sjtu-jason commented 8 years ago

Thank you very much for your help! The 'Objective Agent' class now works.

wilcowijbrandi commented 8 years ago

Good to hear problem is resolved! Thank you for reporting it. I have commit a fix to the powermatcher-2.1RC branch.