FREEDM DGI
VoltVarCtrl.hpp
Go to the documentation of this file.
1 
11 #ifndef VoltVarCtrl_HPP_
12 #define VoltVarCtrl_HPP_
13 
14 #include "CBroker.hpp"
15 #include "CDevice.hpp"
16 #include "CPeerNode.hpp"
17 #include "PeerSets.hpp"
18 #include "IDGIModule.hpp"
19 #include "messages/ModuleMessage.pb.h"
20 
21 // To include vvc headers
22 #include "load_system_data.h"
23 #include "fun_return.h"
24 
25 
26 #include <map>
27 #include <set>
28 #include <string>
29 #include <boost/shared_ptr.hpp>
30 #include <boost/date_time/posix_time/posix_time_types.hpp>
31 
32 namespace freedm {
33 
34 namespace broker {
35 
36 namespace vvc {
37 
44 class VVCAgent
45  : public IDGIModule
46 {
47 public:
48  VVCAgent();
49  ~VVCAgent();
50  int Run();
51 private:
52  void vvc_Manage( const boost::system::error_code& err);
53 
55  void HandleIncomingMessage(boost::shared_ptr<const ModuleMessage> msg, CPeerNode peer);
56  void HandlePeerList(const gm::PeerListMessage & m, CPeerNode peer);
58  std::string m_leader;
59 
60  ModuleMessage VoltageDelta(unsigned int cf, float pm, std::string loc);
61  ModuleMessage LineReadings(std::vector<float> vals);
62  ModuleMessage Gradient(arma::mat grad);
63  ModuleMessage PrepareForSending(const VoltVarMessage& message, std::string recipient);
64  void HandleVoltageDelta(const VoltageDeltaMessage & m, CPeerNode peer);
65  void HandleLineReadings(const LineReadingsMessage & m, CPeerNode peer);
66  void HandleGradient(const GradientMessage & m, CPeerNode peer);
67 
68 
69 
70 
72  void VVCManage(const boost::system::error_code& err);
74  void FirstRound(const boost::system::error_code& err);
75 
77  void ScheduleNextRound();
79  void ReadDevices();
81  //int vvc_main1();
82  void vvc_main();
83 
86  const boost::posix_time::time_duration ROUND_TIME;
88  const boost::posix_time::time_duration REQUEST_TIMEOUT;
89 
94 
96  float m_Gateway;
105 
108 
110  std::string m_Leader;
111 
112 
113 
114 } ; //Class
115 
116 } // namespace vvc
117 
118 } // namespace broker
119 
120 } // namespace freedm
121 
122 
123 
124 #endif
125 
void ScheduleNextRound()
Schedules the LoadManage that runs next round.
Definition: VoltVarCtrl.cpp:281
void vvc_Manage(const boost::system::error_code &err)
CBroker::TimerHandle m_RoundTimer
Timer handle for the round timer.
Definition: VoltVarCtrl.hpp:91
std::string m_Leader
The coordinator of the group.
Definition: VoltVarCtrl.hpp:110
void HandleLineReadings(const LineReadingsMessage &m, CPeerNode peer)
Definition: VoltVarCtrl.cpp:135
ModuleMessage VoltageDelta(unsigned int cf, float pm, std::string loc)
Definition: VoltVarCtrl.cpp:164
void FirstRound(const boost::system::error_code &err)
The code that runs the firtst round of the LB phase.
Definition: VoltVarCtrl.cpp:219
void HandlePeerList(const gm::PeerListMessage &m, CPeerNode peer)
Definition: VoltVarCtrl.cpp:152
void vvc_main()
Updates the node&#39;s state.
Definition: VoltVarCtrl.cpp:324
float m_MigrationStep
The amount to migrate.
Definition: VoltVarCtrl.hpp:102
float m_PredictedGateway
The gateway that we predict will be met by the devices.
Definition: VoltVarCtrl.hpp:100
void HandleGradient(const GradientMessage &m, CPeerNode peer)
Definition: VoltVarCtrl.cpp:141
VVCAgent()
Definition: VoltVarCtrl.cpp:46
void HandleIncomingMessage(boost::shared_ptr< const ModuleMessage > msg, CPeerNode peer)
First handler for an incoming message.
Definition: VoltVarCtrl.cpp:88
float m_NetGeneration
The amount of generation created by attached devices.
Definition: VoltVarCtrl.hpp:98
int Run()
Definition: VoltVarCtrl.cpp:68
const boost::posix_time::time_duration ROUND_TIME
The amount of time it takes to do an VVC round.
Definition: VoltVarCtrl.hpp:86
Base interface for agents/broker modules.
Definition: CPeerNode.hpp:37
CBroker::TimerHandle m_WaitTimer
Timer handle for the request timer.
Definition: VoltVarCtrl.hpp:93
void VVCManage(const boost::system::error_code &err)
The code that the supply nodes use to start doing migrations.
Definition: VoltVarCtrl.cpp:249
Definition: VoltVarCtrl.hpp:44
float m_Gateway
The gateway of this node.
Definition: VoltVarCtrl.hpp:96
ModuleMessage Gradient(arma::mat grad)
Definition: VoltVarCtrl.cpp:187
PeerSet m_peers
Definition: VoltVarCtrl.hpp:57
const boost::posix_time::time_duration REQUEST_TIMEOUT
The time it takes to get a draftrequest response.
Definition: VoltVarCtrl.hpp:88
void HandleVoltageDelta(const VoltageDeltaMessage &m, CPeerNode peer)
Definition: VoltVarCtrl.cpp:128
unsigned int TimerHandle
Definition: CBroker.hpp:66
An interface for an object which can handle recieving incoming messages.
Definition: IDGIModule.hpp:36
bool m_Synchronized
If the system is synchronized with the physical system.
Definition: VoltVarCtrl.hpp:107
ModuleMessage PrepareForSending(const VoltVarMessage &message, std::string recipient)
Definition: VoltVarCtrl.cpp:201
~VVCAgent()
Definition: VoltVarCtrl.cpp:57
General FREEDM Namespace.
Definition: CBroker.cpp:53
ModuleMessage LineReadings(std::vector< float > vals)
Definition: VoltVarCtrl.cpp:174
std::string m_leader
Definition: VoltVarCtrl.hpp:58
std::map< std::string, CPeerNode > PeerSet
Provides a PeerSet type for a module templated on T.
Definition: PeerSets.hpp:35
float m_PowerDifferential
The powerflow used by the physical invariant.
Definition: VoltVarCtrl.hpp:104
void ReadDevices()
Updates the state from the devices.
Definition: VoltVarCtrl.cpp:306