00001 #ifndef _GridFriendlyLoad_h_
00002 #define _GridFriendlyLoad_h_
00003 #include "events.h"
00004 #include "Sensor.h"
00005 #include "ElectricalData.h"
00006 #include <list>
00007 #include <map>
00008
00014 class GridFriendlyLoad:
00015 public adevs::Atomic<adevs::PortValue<BasicEvent*> >
00016 {
00017 public:
00019 static const int sensor_input;
00021 static const int base_load;
00026 GridFriendlyLoad(int BusID, double gfl_fraction,
00027 ElectricalData* init_data);
00029 int getBusID() const { return BusID; }
00030 void delta_int();
00032 void delta_ext(double e, const adevs::Bag<adevs::PortValue<BasicEvent*> >& xb);
00033 void delta_conf(const adevs::Bag<adevs::PortValue<BasicEvent*> >& xb);
00035 void output_func(adevs::Bag<adevs::PortValue<BasicEvent*> >& yb);
00036 double ta();
00038 void gc_output(adevs::Bag<adevs::PortValue<BasicEvent*> >& gc);
00039 private:
00040 const int BusID;
00041 Complex ybase;
00042 const double gfl_fraction;
00043 enum { ON, SHED, RESTORE, OFF } phase;
00044 double trestore;
00045 };
00046
00050 class GridFriendlySensor:
00051 public Sensor
00052 {
00053 public:
00061 GridFriendlySensor(GridFriendlyLoad* actuator);
00063 void trip(ElectricalSensorInterface* evars);
00065 double distFromTrip(ElectricalSensorInterface* evars);
00066 private:
00067 static const double trip_freq, hys_freq;
00068 const int BusID;
00069 bool tripped;
00070 };
00071
00075 class GridFriendlyNetwork:
00076 public adevs::Network<adevs::PortValue<BasicEvent*> >
00077 {
00078 public:
00080 static const int sensor_trip;
00082 static const int load_change;
00084 static const int base_load;
00089 GridFriendlyNetwork(ElectricalData* data, double frac_of_load = 0.0);
00094 void getSensors(std::list<Sensor*>& sensors);
00098 void route(const adevs::PortValue<BasicEvent*>& value,
00099 adevs::Devs<adevs::PortValue<BasicEvent*> >* model,
00100 adevs::Bag<adevs::Event<adevs::PortValue<BasicEvent*> > >& r);
00104 void getComponents(adevs::Set<adevs::Devs<adevs::PortValue<BasicEvent*> >* >& c);
00106 ~GridFriendlyNetwork();
00107 private:
00108 std::map<GridFriendlyLoad*,GridFriendlyLoad*> loads;
00109 };
00110
00111 #endif