00001 #include "StepLoad.h" 00002 #include <iostream> 00003 using namespace adevs; 00004 using namespace std; 00005 00006 const int StepLoad::base_load = 0; 00007 00008 StepLoad::StepLoad(unsigned which, double fraction, double when, ElectricalData* data): 00009 Atomic<PortValue<BasicEvent*> >(), 00010 which(which), 00011 time_to_drop(when), 00012 fraction(fraction), 00013 data(data) 00014 { 00015 } 00016 00017 double StepLoad::ta() 00018 { 00019 return time_to_drop; 00020 } 00021 00022 void StepLoad::delta_int() 00023 { 00024 time_to_drop = DBL_MAX; 00025 } 00026 00027 void StepLoad::output_func(Bag<PortValue<BasicEvent*> >& yb) 00028 { 00029 double frac = 1.0+fraction; 00030 Complex ybase = data->getAdmittance(which); 00031 cout << real(ybase) << "->" << real(ybase)*frac << endl; 00032 LoadEvent* f = new LoadEvent(which,Complex(real(ybase)*frac,imag(ybase))); 00033 yb.insert(PortValue<BasicEvent*>(base_load,f)); 00034 } 00035 00036 void StepLoad::gc_output(Bag<PortValue<BasicEvent*> >& gb) 00037 { 00038 Bag<PortValue<BasicEvent*> >::iterator iter = gb.begin(); 00039 for (; iter != gb.end(); iter++) delete (*iter).value; 00040 }