MOOS 0.2375
|
00001 00002 #include "Simulator.h" 00003 #include <math.h> 00004 00005 //default constructor 00006 CSimulator::CSimulator() 00007 { 00008 } 00009 00010 //default (virtual) destructor 00011 CSimulator::~CSimulator() 00012 { 00013 } 00014 00027 bool CSimulator::OnNewMail(MOOSMSG_LIST &NewMail) 00028 { 00029 return true; 00030 } 00031 00037 bool CSimulator::OnConnectToServer() 00038 { 00039 return true; 00040 } 00041 00044 bool CSimulator::Iterate() 00045 { 00046 static int k = 0; 00047 if(k++%10==0) 00048 { 00049 //simulate some brownian motion 00050 static double dfHeading = 0; 00051 dfHeading+=MOOSWhiteNoise(0.1); 00052 00053 //publish the data (2nd param is a double so it will be forever double data...) 00054 m_Comms.Notify("Heading",dfHeading,MOOSTime()); 00055 } 00056 if(k%35==0) 00057 { 00058 00059 static double dfVolts = 100; 00060 dfVolts-=fabs(MOOSWhiteNoise(0.1)); 00061 std::string sStatus = MOOSFormat("Status=%s,BatteryVoltage=%.2f,Bilge = %s", 00062 dfVolts>50.0? "Good":"Bad", 00063 dfVolts, 00064 k%100>50?"On":"Off"); 00065 00066 //publish the data (2nd param is a std::string so it will be forever string data...) 00067 m_Comms.Notify("VehicleStatus",sStatus,MOOSTime()); 00068 } 00069 return true; 00070 } 00071 00075 bool CSimulator::OnStartUp() 00076 { 00077 return true; 00078 }