|
solarpowerlog trunk
|
00001 /* 00002 * CInverterDummy.cpp 00003 * 00004 * Created on: 17.07.2011 00005 * Author: coldtobi 00006 */ 00007 00008 #ifdef HAVE_CONFIG_H 00009 #include "config.h" 00010 #include "porting.h" 00011 #endif 00012 00013 #ifdef HAVE_INV_DUMMY 00014 00015 #include "Inverters/DummyInverter/CInverterDummy.h" 00016 #include "configuration/CConfigHelper.h" 00017 #include "Inverters/Capabilites.h" 00018 #include "patterns/IValue.h" 00019 #include "interfaces/CCapability.h" 00020 #include "patterns/CValue.h" 00021 #include "patterns/ICommand.h" 00022 00023 CInverterDummy::CInverterDummy(const string &name, 00024 const string &configurationpath) : 00025 IInverterBase(name, configurationpath, "inverter") 00026 { 00027 CConfigHelper cfghlp(configurationpath); 00028 std::string s; 00029 00030 // Complete your initializtion here. 00031 // For example, add capabilities: 00032 IValue *v; 00033 CCapability *c; 00034 s = CAPA_INVERTER_MANUFACTOR_NAME; 00035 v = IValue::Factory(CAPA_INVERTER_MANUFACTOR_TYPE); 00036 ((CValue<string>*) v)->Set("Dummy Inverter"); 00037 c = new CCapability(s, v, this); 00038 AddCapability(s, c); 00039 00040 // add a bootstrap event to get called again ;-) 00041 ICommand *cmd = new ICommand(CMD_INIT, this); 00042 Registry::GetMainScheduler()->ScheduleWork(cmd); 00043 00044 LOGDEBUG(logger,"Inverter configuration:"); 00045 LOGDEBUG(logger,"class CInverterDummy "); 00046 cfghlp.GetConfig("comms", s, (string) "unset"); 00047 LOGDEBUG(logger,"Communication: " << s); 00048 } 00049 00050 CInverterDummy::~CInverterDummy() 00051 { 00052 // TODO Auto-generated destructor stub 00053 } 00054 00055 00056 void CInverterDummy::ExecuteCommand(const ICommand *Command) 00057 { 00058 // ICommandTarget hook -- will be called with any new command which is due.. 00059 00060 LOGINFO(this->logger, 00061 "CInverterDummy " << this->name << " command received! GetCmd:" << 00062 Command->getCmd()); 00063 LOGINFO(this->logger, "Data:"); 00064 Command->DumpData(this->logger); 00065 00066 // Probably you want to have a big switch-case here, covering all your CMD_xxx 00067 } 00068 00069 #endif /* HAVE_INV_DUMMY */