00001 #include "BusFreqListener.h"
00002 using namespace std;
00003 using namespace adevs;
00004
00005 BusFreqListener::BusFreqListener(ElectricalModel* model, double cint, string model_name):
00006 EventListener<PortValue<BasicEvent*> >(),
00007 cint(cint),
00008 fout(string(model_name+"_all_freq.dat").c_str()),
00009 t_last_record(0.0),
00010 src(model)
00011 {
00012 }
00013
00014 void BusFreqListener::stateChange(Atomic<PortValue<BasicEvent*> >* model, double t)
00015 {
00016 if (t - t_last_record >= cint)
00017 {
00018 t_last_record = t;
00019 fout << t << " ";
00020 for (unsigned i = 0; i < src->getElectricalData()->getNodeCount(); i++)
00021 {
00022 fout << 60.0*src->getBusFreq(i) << " ";
00023 }
00024 fout << endl;
00025 }
00026 }
00027
00028 BusFreqListener::~BusFreqListener()
00029 {
00030 fout.close();
00031 }
00032