#!/bin/bash if [ -z "$1" ] ; then echo "GenMOOSApp: usage: $0 [app-name] [prefix]" exit 0 fi if [ -z "$2" ] ; then echo "GenMOOSApp: usage: $0 [app-name] [prefix]" exit 0 fi mkdir $2$1 cd $2$1 cat >> CMakeLists.txt <> ${1}.h <> ${1}Main.cpp < 1) sMissionFile = argv[1]; ${1} ${1}; ${1}.Run("${2}${1}", sMissionFile); return(0); } EOF cat >> $2${1}.moos <> ${1}.cpp < #include "${1}.h" #include "MBUtils.h" using namespace std; //--------------------------------------------------------- // Constructor ${1}::${1}() { } //--------------------------------------------------------- // Destructor ${1}::~${1}() { } //--------------------------------------------------------- // Procedure: OnNewMail bool ${1}::OnNewMail(MOOSMSG_LIST &NewMail) { MOOSMSG_LIST::iterator p; for(p=NewMail.begin(); p!=NewMail.end(); p++) { CMOOSMsg &msg = *p; string key = msg.GetKey(); double dval = msg.GetDouble(); string sval = msg.GetString(); double mtime = msg.GetTime(); bool mdbl = msg.IsDouble(); bool mstr = msg.IsString(); string msrc = msg.GetSource(); // if(key == "FOOBAR") // handleNewFOOBAR(sval); } return(true); } //--------------------------------------------------------- // Procedure: OnConnectToServer bool ${1}::OnConnectToServer() { // register for variables here // possibly look at the mission file? // m_MissionReader.GetConfigurationParam("Name", ); // m_Comms.Register("VARNAME", is_float(int)); RegisterVariables(); return(true); } //------------------------------------------------------------ // Procedure: RegisterVariables void ${1}::RegisterVariables() { m_Comms.Register("FOO_BAR", 0); } //--------------------------------------------------------- // Procedure: Iterate() bool ${1}::Iterate() { // happens AppTick times per second return(true); } //--------------------------------------------------------- // Procedure: OnStartUp() bool ${1}::OnStartUp() { // happens before connection is open RegisterVariables(); return(true); } EOF echo "$2${1} generated"