创建工程并增加了json支持
This commit is contained in:
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"list": "cpp"
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
#=======================================================================
|
||||
# FILE: moos-ivp-extend/CMakeLists.txt
|
||||
# DATE: 2012/07/24
|
||||
# INFO: Top-level CMakeLists.txt file for the moos-ivp-extend project
|
||||
# NAME: Maintained by Mike Benjamin - Original setup by Christian Convey
|
||||
# Chris Gagner, and tips borrowed from Dave Billin
|
||||
#=======================================================================
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT( IVP_EXTEND )
|
||||
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (MOOSIVP_SOURCE_TREE_BASE "/home/zjk/project/lib/moos-ivp")
|
||||
|
||||
#=======================================================================
|
||||
# Set the output directories for the binary and library files
|
||||
#=======================================================================
|
||||
|
||||
GET_FILENAME_COMPONENT(IVP_EXTEND_BIN_DIR "${CMAKE_SOURCE_DIR}/bin" ABSOLUTE )
|
||||
GET_FILENAME_COMPONENT(IVP_EXTEND_LIB_DIR "${CMAKE_SOURCE_DIR}/lib" ABSOLUTE )
|
||||
|
||||
SET( LIBRARY_OUTPUT_PATH "${IVP_EXTEND_LIB_DIR}" CACHE PATH "" )
|
||||
SET( ARCHIVE_OUTPUT_DIRECTORY "${IVP_EXTEND_LIB_DIR}" CACHE PATH "" )
|
||||
SET( LIBRARY_OUTPUT_DIRECTORY "${IVP_EXTEND_LIB_DIR}" CACHE PATH "" )
|
||||
|
||||
SET( EXECUTABLE_OUTPUT_PATH "${IVP_EXTEND_BIN_DIR}" CACHE PATH "" )
|
||||
SET( RUNTIME_OUTPUT_DIRECTORY "${IVP_EXTEND_BIN_DIR}" CACHE PATH "" )
|
||||
|
||||
#=======================================================================
|
||||
# Find MOOS
|
||||
#=======================================================================
|
||||
find_package(MOOS 10.0)
|
||||
INCLUDE_DIRECTORIES(${MOOS_INCLUDE_DIRS})
|
||||
|
||||
#=======================================================================
|
||||
# Find the "moos-ivp" base directory
|
||||
#=======================================================================
|
||||
|
||||
# Search for the moos-ivp folder
|
||||
find_path( MOOSIVP_SOURCE_TREE_BASE
|
||||
NAMES build-ivp.sh build-moos.sh configure-ivp.sh
|
||||
PATHS "../moos-ivp" "../../moos-ivp" "../../moos-ivp/trunk/" "../moos-ivp/trunk/"
|
||||
DOC "Base directory of the MOOS-IvP source tree"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
if (NOT MOOSIVP_SOURCE_TREE_BASE)
|
||||
message("Please set MOOSIVP_SOURCE_TREE_BASE to ")
|
||||
message("the location of the \"moos-ivp\" folder ")
|
||||
return()
|
||||
endif()
|
||||
|
||||
#======================================================================
|
||||
# Specify where to find IvP's headers and libraries...
|
||||
#======================================================================
|
||||
|
||||
FILE(GLOB IVP_INCLUDE_DIRS ${MOOSIVP_SOURCE_TREE_BASE}/ivp/src/lib_* )
|
||||
INCLUDE_DIRECTORIES(${IVP_INCLUDE_DIRS})
|
||||
|
||||
FILE(GLOB IVP_LIBRARY_DIRS ${MOOSIVP_SOURCE_TREE_BASE}/lib )
|
||||
LINK_DIRECTORIES(${IVP_LIBRARY_DIRS})
|
||||
|
||||
#======================================================================
|
||||
# Specify Compiler Flags
|
||||
#======================================================================
|
||||
IF( ${WIN32} )
|
||||
#---------------------------------------------
|
||||
# Windows Compiler Flags
|
||||
#---------------------------------------------
|
||||
IF(MSVC)
|
||||
# Flags for Microsoft Visual Studio
|
||||
SET( WALL_ON OFF CACHE BOOL
|
||||
"tell me about all compiler warnings (-Wall) ")
|
||||
IF(WALL_ON)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
ENDIF(WALL_ON)
|
||||
ELSE(MSVC)
|
||||
# Other Windows compilers go here
|
||||
ENDIF(MSVC)
|
||||
|
||||
ELSE( ${WIN32} )
|
||||
#---------------------------------------------
|
||||
# Linux and Apple Compiler Flags
|
||||
#---------------------------------------------
|
||||
# Force -fPIC because gcc complains when we don't use it with x86_64 code.
|
||||
# Note sure why: -fPIC should only be needed for shared objects, and
|
||||
# AFAIK, CMake gets that right when building shared objects. -CJC
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -g -Wdeprecated-declarations")
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# Flags for the GNU C++ Compiler
|
||||
SET( WALL_ON OFF CACHE BOOL
|
||||
"tell me about all compiler warnings (-Wall) ")
|
||||
IF(WALL_ON)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" -C++11)
|
||||
ENDIF( WALL_ON)
|
||||
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
ENDIF( ${WIN32} )
|
||||
|
||||
#=======================================================================
|
||||
# Add Subdirectories
|
||||
#=======================================================================
|
||||
ADD_SUBDIRECTORY( src )
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
INVOCATION_ABS_DIR=`pwd`
|
||||
BUILD_TYPE="None"
|
||||
CMD_LINE_ARGS=""
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# Part 1: Check for and handle command-line arguments
|
||||
#-------------------------------------------------------------------
|
||||
for ARGI; do
|
||||
if [ "${ARGI}" = "--help" -o "${ARGI}" = "-h" ] ; then
|
||||
printf "%s [SWITCHES] \n" $0
|
||||
printf "Switches: \n"
|
||||
printf " --help, -h \n"
|
||||
printf " --debug, -d \n"
|
||||
printf " --release, -r \n"
|
||||
printf "Notes: \n"
|
||||
printf " (1) All other command line args will be passed as args \n"
|
||||
printf " to \"make\" when it is eventually invoked. \n"
|
||||
printf " (2) For example -k will continue making when/if a failure \n"
|
||||
printf " is encountered in building one of the subdirectories. \n"
|
||||
printf " (3) For example -j2 will utilize a 2nd core in the build \n"
|
||||
printf " if your machine has two cores. -j4 etc for quad core. \n"
|
||||
exit 0;
|
||||
elif [ "${ARGI}" = "--debug" -o "${ARGI}" = "-d" ] ; then
|
||||
BUILD_TYPE="Debug"
|
||||
elif [ "${ARGI}" = "--release" -o "${ARGI}" = "-r" ] ; then
|
||||
BUILD_TYPE="Release"
|
||||
else
|
||||
CMD_LINE_ARGS=$CMD_LINE_ARGS" "$ARGI
|
||||
fi
|
||||
done
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# Part 2: Invoke the call to make in the build directory
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ../
|
||||
|
||||
make ${CMD_LINE_ARGS}
|
||||
cd ${INVOCATION_ABS_DIR}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -rf build/*
|
||||
rm -rf lib/*
|
||||
rm -rf bin/p*
|
||||
rm -f .DS_Store
|
||||
rm -f missions/*/.LastOpenedMOOSLogDirectory
|
||||
|
||||
find . -name '.DS_Store' -print -exec rm -rfv {} \;
|
||||
find . -name '*~' -print -exec rm -rfv {} \;
|
||||
find . -name '#*' -print -exec rm -rfv {} \;
|
||||
find . -name '*.moos++' -print -exec rm -rfv {} \;
|
||||
|
||||
find . -name 'MOOSLog*' -print -exec rm -rfv {} \;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
To Run this mission, make sure that the following two bin
|
||||
directories are in your path:
|
||||
|
||||
moos-ivp/ivp/bin/
|
||||
moos-ivp-extend/bin/
|
||||
|
||||
Then launch the mission by:
|
||||
|
||||
pAntler alder.moos
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//-------- FILE: alder.bhv -------------
|
||||
|
||||
initialize DEPLOY = false
|
||||
initialize RETURN = false
|
||||
|
||||
//----------------------------------------------
|
||||
Behavior = BHV_SimpleWaypoint
|
||||
{
|
||||
name = waypt_to_point
|
||||
pwt = 100
|
||||
condition = RETURN = false
|
||||
condition = DEPLOY = true
|
||||
endflag = RETURN = true
|
||||
|
||||
speed = 2.0 // meters per second
|
||||
radius = 8.0
|
||||
ptx = 100
|
||||
pty = -50
|
||||
}
|
||||
|
||||
//----------------------------------------------
|
||||
Behavior = BHV_Waypoint
|
||||
{
|
||||
name = waypt_return
|
||||
pwt = 100
|
||||
condition = (RETURN = true)
|
||||
condition = (DEPLOY = true)
|
||||
|
||||
speed = 2.0
|
||||
radius = 8.0
|
||||
point = 0,0
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
// Level 2 Configuration file: M. Benjamin
|
||||
|
||||
ServerHost = localhost
|
||||
ServerPort = 9000
|
||||
Simulator = true
|
||||
|
||||
Community = alder
|
||||
|
||||
MOOSTimeWarp = 1
|
||||
|
||||
LatOrigin = 43.825300
|
||||
LongOrigin = -70.330400
|
||||
|
||||
//------------------------------------------
|
||||
// Antler configuration block
|
||||
ProcessConfig = ANTLER
|
||||
{
|
||||
MSBetweenLaunches = 200
|
||||
|
||||
Run = MOOSDB @ NewConsole = false
|
||||
Run = uSimMarine @ NewConsole = false
|
||||
Run = pNodeReporter @ NewConsole = false
|
||||
Run = pMarinePID @ NewConsole = false
|
||||
Run = pMarineViewer @ NewConsole = false
|
||||
Run = uProcessWatch @ NewConsole = false
|
||||
Run = pHelmIvP @ NewConsole = false
|
||||
Run = pOdometry @ NewConsole = false
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
// uSimMarine config block
|
||||
|
||||
ProcessConfig = uSimMarine
|
||||
{
|
||||
AppTick = 10
|
||||
CommsTick = 10
|
||||
|
||||
START_X = 0
|
||||
START_Y = 0
|
||||
START_SPEED = 0
|
||||
START_HEADING = 180
|
||||
|
||||
PREFIX = NAV
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// uProcessWatch config block
|
||||
|
||||
ProcessConfig = uProcessWatch
|
||||
{
|
||||
AppTick = 4
|
||||
CommsTick = 4
|
||||
|
||||
term_report_interval = 0.8
|
||||
|
||||
summary_wait = 5
|
||||
|
||||
nowatch = uXMS*
|
||||
nowatch = uPokeDB*
|
||||
nowatch = uTermCommand*
|
||||
watch_all = true
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// pHelmIvP config block
|
||||
|
||||
ProcessConfig = pHelmIvP
|
||||
{
|
||||
AppTick = 4
|
||||
CommsTick = 4
|
||||
|
||||
Behaviors = alder.bhv
|
||||
Verbose = quiet
|
||||
Domain = course:0:359:360
|
||||
Domain = speed:0:4:21
|
||||
|
||||
IVP_BEHAVIOR_DIR = ../../lib
|
||||
//IVP_BEHAVIOR_DIR = /Users/mikerb/Research/moos-ivp-extend/trunk/lib
|
||||
|
||||
ok_skew = any
|
||||
start_in_drive = false
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
// pMarinePID config block
|
||||
|
||||
ProcessConfig = pMarinePID
|
||||
{
|
||||
AppTick = 20
|
||||
CommsTick = 20
|
||||
|
||||
VERBOSE = true
|
||||
DEPTH_CONTROL = false
|
||||
|
||||
// Yaw PID controller
|
||||
YAW_PID_KP = 0.5
|
||||
YAW_PID_KD = 0.0
|
||||
YAW_PID_KI = 0.0
|
||||
YAW_PID_INTEGRAL_LIMIT = 0.07
|
||||
|
||||
// Speed PID controller
|
||||
SPEED_PID_KP = 1.0
|
||||
SPEED_PID_KD = 0.0
|
||||
SPEED_PID_KI = 0.0
|
||||
SPEED_PID_INTEGRAL_LIMIT = 0.07
|
||||
|
||||
//MAXIMUMS
|
||||
MAXRUDDER = 100
|
||||
MAXTHRUST = 100
|
||||
|
||||
// A non-zero SPEED_FACTOR overrides use of SPEED_PID
|
||||
// Will set DESIRED_THRUST = DESIRED_SPEED * SPEED_FACTOR
|
||||
SPEED_FACTOR = 20
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
// pMarineViewer config block
|
||||
|
||||
ProcessConfig = pMarineViewer
|
||||
{
|
||||
AppTick = 4
|
||||
CommsTick = 4
|
||||
|
||||
TIFF_FILE = forrest19.tif
|
||||
set_pan_x = -90
|
||||
set_pan_y = -280
|
||||
zoom = 0.65
|
||||
vehicle_shape_scale = 1.5
|
||||
hash_delta = 50
|
||||
hash_shade = 0.4
|
||||
hash_viewable = true
|
||||
|
||||
scope = ODOMETRY_DIST
|
||||
|
||||
// Appcast configuration
|
||||
appcast_height = 75
|
||||
appcast_width = 30
|
||||
appcast_viewable = true
|
||||
appcast_color_scheme = indigo
|
||||
nodes_font_size = medium
|
||||
procs_font_size = medium
|
||||
appcast_font_size = small
|
||||
|
||||
BUTTON_ONE = DEPLOY # DEPLOY=true
|
||||
BUTTON_ONE = MOOS_MANUAL_OVERIDE=false # RETURN=false
|
||||
BUTTON_TWO = RETURN # RETURN=true
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
// pNodeReporter config block
|
||||
|
||||
ProcessConfig = pNodeReporter
|
||||
{
|
||||
AppTick = 2
|
||||
CommsTick = 2
|
||||
VESSEL_TYPE = KAYAK
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
//-------- FILE: alder.bhv -------------
|
||||
|
||||
initialize DEPLOY = false
|
||||
initialize RETURN = false
|
||||
|
||||
//----------------------------------------------
|
||||
Behavior = BHV_SimpleWaypoint
|
||||
{
|
||||
name = waypt_to_point
|
||||
pwt = 100
|
||||
condition = RETURN = false
|
||||
condition = DEPLOY = true
|
||||
endflag = RETURN = true
|
||||
|
||||
speed = 2.0 // meters per second
|
||||
radius = 8.0
|
||||
ptx = 100
|
||||
pty = -50
|
||||
}
|
||||
|
||||
//----------------------------------------------
|
||||
Behavior = BHV_SimpleWaypoint
|
||||
{
|
||||
name = waypt_return
|
||||
pwt = 100
|
||||
condition = (RETURN = true)
|
||||
condition = (DEPLOY = true)
|
||||
|
||||
speed = 2.0
|
||||
radius = 8.0
|
||||
ptx = 0
|
||||
pty = 0
|
||||
}
|
||||
|
||||
//----------------------------------------------
|
||||
Behavior = BHV_HSLine
|
||||
{
|
||||
name = hsline
|
||||
time_on_leg = 20
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
// MOOS file
|
||||
|
||||
ServerHost = localhost
|
||||
ServerPort = 9000
|
||||
|
||||
//------------------------------------------
|
||||
// Antler configuration block
|
||||
ProcessConfig = ANTLER
|
||||
{
|
||||
MSBetweenLaunches = 200
|
||||
|
||||
Run = MOOSDB @ NewConsole = false
|
||||
Run = pXRelay @ NewConsole = true ~ pXRelay_APPLES
|
||||
Run = pXRelay @ NewConsole = true ~ pXRelay_PEARS
|
||||
Run = uXMS @ NewConsole = true
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// First pXRelay configuration block
|
||||
|
||||
ProcessConfig = pXRelay_APPLES
|
||||
{
|
||||
AppTick = 4
|
||||
CommsTick = 4
|
||||
|
||||
OUTGOING_VAR = APPLES
|
||||
INCOMING_VAR = PEARS
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
// Second pXRelay configuration block
|
||||
|
||||
ProcessConfig = pXRelay_PEARS
|
||||
{
|
||||
AppTick = 4
|
||||
CommsTick = 4
|
||||
|
||||
OUTGOING_VAR = PEARS
|
||||
INCOMING_VAR = APPLES
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
// uXMS configuration block
|
||||
|
||||
ProcessConfig = uXMS
|
||||
{
|
||||
AppTick = 4
|
||||
CommsTick = 4
|
||||
|
||||
VAR = PEARS, PEARS_ITER_HZ, PEARS_POST_HZ
|
||||
VAR = APPLES, APPLES_ITER_HZ, APPLES_POST_HZ
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
This directory may contain developer utility scripts.
|
||||
|
||||
The MyGenMOOSApp script is similar to that found in the moos-ivp/trunk/scripts/
|
||||
directory. Users are encouraged to tailor this one to their own needs.
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
##############################################################################
|
||||
# FILE: moos-ivp-extend/src/CMakeLists.txt
|
||||
# DATE: 2010/09/07
|
||||
# 2020/05/09 minor mods
|
||||
# DESCRIPTION: CMakeLists.txt file for the moos-ivp-extend source directory
|
||||
##############################################################################
|
||||
|
||||
|
||||
#============================================================================
|
||||
# Add the libraries in the current directory to the include path
|
||||
#============================================================================
|
||||
FILE(GLOB LOCAL_LIBRARY_DIRS ./lib_*)
|
||||
INCLUDE_DIRECTORIES(${LOCAL_LIBRARY_DIRS})
|
||||
|
||||
#============================================================================
|
||||
# List the subdirectories to build...
|
||||
#============================================================================
|
||||
ADD_SUBDIRECTORY(pPowerManger)
|
||||
|
||||
##############################################################################
|
||||
# END of CMakeLists.txt
|
||||
##############################################################################
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#--------------------------------------------------------
|
||||
# The CMakeLists.txt for: pPowerManger
|
||||
# Author(s):
|
||||
#--------------------------------------------------------
|
||||
|
||||
# Set System Specific Libraries
|
||||
if (${WIN32})
|
||||
# Windows Libraries
|
||||
SET(SYSTEM_LIBS
|
||||
wsock32 )
|
||||
else (${WIN32})
|
||||
# Linux and Apple Libraries
|
||||
SET(SYSTEM_LIBS
|
||||
m
|
||||
pthread )
|
||||
endif (${WIN32})
|
||||
|
||||
SET(SRC
|
||||
PowerManger.cpp
|
||||
PowerManger_Info.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(pPowerManger ${SRC})
|
||||
|
||||
TARGET_LINK_LIBRARIES(pPowerManger
|
||||
${MOOS_LIBRARIES}
|
||||
apputil
|
||||
mbutil
|
||||
m
|
||||
pthread
|
||||
${SYSTEM_LIBS})
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/************************************************************/
|
||||
/* NAME: */
|
||||
/* ORGN: MIT, Cambridge MA */
|
||||
/* FILE: PowerManger.cpp */
|
||||
/* DATE: December 29th, 1963 */
|
||||
/************************************************************/
|
||||
|
||||
#include <iterator>
|
||||
#include "MBUtils.h"
|
||||
#include "ACTable.h"
|
||||
#include "PowerManger.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Constructor()
|
||||
|
||||
PowerManger::PowerManger()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Destructor
|
||||
|
||||
PowerManger::~PowerManger()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Procedure: OnNewMail()
|
||||
|
||||
bool PowerManger::OnNewMail(MOOSMSG_LIST &NewMail)
|
||||
{
|
||||
AppCastingMOOSApp::OnNewMail(NewMail);
|
||||
|
||||
MOOSMSG_LIST::iterator p;
|
||||
for(p=NewMail.begin(); p!=NewMail.end(); p++) {
|
||||
CMOOSMsg &msg = *p;
|
||||
string key = msg.GetKey();
|
||||
|
||||
#if 0 // Keep these around just for template
|
||||
string comm = msg.GetCommunity();
|
||||
double dval = msg.GetDouble();
|
||||
string sval = msg.GetString();
|
||||
string msrc = msg.GetSource();
|
||||
double mtime = msg.GetTime();
|
||||
bool mdbl = msg.IsDouble();
|
||||
bool mstr = msg.IsString();
|
||||
#endif
|
||||
|
||||
if(key == "FOO")
|
||||
cout << "great!";
|
||||
|
||||
else if(key != "APPCAST_REQ") // handled by AppCastingMOOSApp
|
||||
reportRunWarning("Unhandled Mail: " + key);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Procedure: OnConnectToServer()
|
||||
|
||||
bool PowerManger::OnConnectToServer()
|
||||
{
|
||||
registerVariables();
|
||||
return(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Procedure: Iterate()
|
||||
// happens AppTick times per second
|
||||
|
||||
bool PowerManger::Iterate()
|
||||
{
|
||||
AppCastingMOOSApp::Iterate();
|
||||
// Do your thing here!
|
||||
AppCastingMOOSApp::PostReport();
|
||||
return(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Procedure: OnStartUp()
|
||||
// happens before connection is open
|
||||
|
||||
bool PowerManger::OnStartUp()
|
||||
{
|
||||
AppCastingMOOSApp::OnStartUp();
|
||||
|
||||
STRING_LIST sParams;
|
||||
m_MissionReader.EnableVerbatimQuoting(false);
|
||||
if(!m_MissionReader.GetConfiguration(GetAppName(), sParams))
|
||||
reportConfigWarning("No config block found for " + GetAppName());
|
||||
|
||||
STRING_LIST::iterator p;
|
||||
for(p=sParams.begin(); p!=sParams.end(); p++) {
|
||||
string orig = *p;
|
||||
string line = *p;
|
||||
string param = tolower(biteStringX(line, '='));
|
||||
string value = line;
|
||||
|
||||
bool handled = false;
|
||||
if(param == "foo") {
|
||||
handled = true;
|
||||
}
|
||||
else if(param == "bar") {
|
||||
handled = true;
|
||||
}
|
||||
|
||||
if(!handled)
|
||||
reportUnhandledConfigWarning(orig);
|
||||
|
||||
}
|
||||
|
||||
registerVariables();
|
||||
return(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Procedure: registerVariables()
|
||||
|
||||
void PowerManger::registerVariables()
|
||||
{
|
||||
AppCastingMOOSApp::RegisterVariables();
|
||||
// Register("FOOBAR", 0);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Procedure: buildReport()
|
||||
|
||||
bool PowerManger::buildReport()
|
||||
{
|
||||
m_msgs << "============================================" << endl;
|
||||
m_msgs << "File: " << endl;
|
||||
m_msgs << "============================================" << endl;
|
||||
|
||||
ACTable actab(4);
|
||||
actab << "Alpha | Bravo | Charlie | Delta";
|
||||
actab.addHeaderLines();
|
||||
actab << "one" << "two" << "three" << "four";
|
||||
m_msgs << actab.getFormattedString();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* @Author: zhaojingkui 1553836110@qq.com
|
||||
* @Date: 2024-10-22 16:47:01
|
||||
* @LastEditors: zhaojingkui 1553836110@qq.com
|
||||
* @LastEditTime: 2024-10-22 17:14:48
|
||||
* @FilePath: /H100PowerManger/src/pPowerManger/PowerManger.h
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
||||
*/
|
||||
/************************************************************/
|
||||
/* NAME: */
|
||||
/* ORGN: MIT, Cambridge MA */
|
||||
/* FILE: PowerManger.h */
|
||||
/* DATE: December 29th, 1963 */
|
||||
/************************************************************/
|
||||
|
||||
#ifndef PowerManger_HEADER
|
||||
#define PowerManger_HEADER
|
||||
|
||||
#include "MOOS/libMOOS/Thirdparty/AppCasting/AppCastingMOOSApp.h"
|
||||
#include "MOOS/libMOOS/Utils/MOOSThread.h"
|
||||
#include "MOOS/libMOOS/Comms/XPCUdpSocket.h"
|
||||
|
||||
class PowerManger : public AppCastingMOOSApp
|
||||
{
|
||||
public:
|
||||
PowerManger();
|
||||
~PowerManger();
|
||||
|
||||
protected: // Standard MOOSApp functions to overload
|
||||
bool OnNewMail(MOOSMSG_LIST &NewMail);
|
||||
bool Iterate();
|
||||
bool OnConnectToServer();
|
||||
bool OnStartUp();
|
||||
|
||||
protected: // Standard AppCastingMOOSApp function to overload
|
||||
bool buildReport();
|
||||
|
||||
protected:
|
||||
void registerVariables();
|
||||
|
||||
private: // Configuration variables
|
||||
CMOOSThread m_ListenThread;
|
||||
CMOOSThread m_SendThread;
|
||||
private: // State variables
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,115 @@
|
||||
/****************************************************************/
|
||||
/* NAME: */
|
||||
/* ORGN: MIT, Cambridge MA */
|
||||
/* FILE: PowerManger_Info.cpp */
|
||||
/* DATE: December 29th, 1963 */
|
||||
/****************************************************************/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include "PowerManger_Info.h"
|
||||
#include "ColorParse.h"
|
||||
#include "ReleaseInfo.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Procedure: showSynopsis
|
||||
|
||||
void showSynopsis()
|
||||
{
|
||||
blk("SYNOPSIS: ");
|
||||
blk("------------------------------------ ");
|
||||
blk(" The pPowerManger application is used for ");
|
||||
blk(" ");
|
||||
blk(" ");
|
||||
blk(" ");
|
||||
blk(" ");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Procedure: showHelpAndExit
|
||||
|
||||
void showHelpAndExit()
|
||||
{
|
||||
blk(" ");
|
||||
blu("=============================================================== ");
|
||||
blu("Usage: pPowerManger file.moos [OPTIONS] ");
|
||||
blu("=============================================================== ");
|
||||
blk(" ");
|
||||
showSynopsis();
|
||||
blk(" ");
|
||||
blk("Options: ");
|
||||
mag(" --alias","=<ProcessName> ");
|
||||
blk(" Launch pPowerManger with the given process name ");
|
||||
blk(" rather than pPowerManger. ");
|
||||
mag(" --example, -e ");
|
||||
blk(" Display example MOOS configuration block. ");
|
||||
mag(" --help, -h ");
|
||||
blk(" Display this help message. ");
|
||||
mag(" --interface, -i ");
|
||||
blk(" Display MOOS publications and subscriptions. ");
|
||||
mag(" --version,-v ");
|
||||
blk(" Display the release version of pPowerManger. ");
|
||||
blk(" ");
|
||||
blk("Note: If argv[2] does not otherwise match a known option, ");
|
||||
blk(" then it will be interpreted as a run alias. This is ");
|
||||
blk(" to support pAntler launching conventions. ");
|
||||
blk(" ");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Procedure: showExampleConfigAndExit
|
||||
|
||||
void showExampleConfigAndExit()
|
||||
{
|
||||
blk(" ");
|
||||
blu("=============================================================== ");
|
||||
blu("pPowerManger Example MOOS Configuration ");
|
||||
blu("=============================================================== ");
|
||||
blk(" ");
|
||||
blk("ProcessConfig = pPowerManger ");
|
||||
blk("{ ");
|
||||
blk(" AppTick = 4 ");
|
||||
blk(" CommsTick = 4 ");
|
||||
blk(" ");
|
||||
blk("} ");
|
||||
blk(" ");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Procedure: showInterfaceAndExit
|
||||
|
||||
void showInterfaceAndExit()
|
||||
{
|
||||
blk(" ");
|
||||
blu("=============================================================== ");
|
||||
blu("pPowerManger INTERFACE ");
|
||||
blu("=============================================================== ");
|
||||
blk(" ");
|
||||
showSynopsis();
|
||||
blk(" ");
|
||||
blk("SUBSCRIPTIONS: ");
|
||||
blk("------------------------------------ ");
|
||||
blk(" NODE_MESSAGE = src_node=alpha,dest_node=bravo,var_name=FOO, ");
|
||||
blk(" string_val=BAR ");
|
||||
blk(" ");
|
||||
blk("PUBLICATIONS: ");
|
||||
blk("------------------------------------ ");
|
||||
blk(" Publications are determined by the node message content. ");
|
||||
blk(" ");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Procedure: showReleaseInfoAndExit
|
||||
|
||||
void showReleaseInfoAndExit()
|
||||
{
|
||||
showReleaseInfo("pPowerManger", "gpl");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/****************************************************************/
|
||||
/* NAME: */
|
||||
/* ORGN: MIT, Cambridge MA */
|
||||
/* FILE: PowerManger_Info.h */
|
||||
/* DATE: Dececmber 29th, 1963 */
|
||||
/****************************************************************/
|
||||
|
||||
#ifndef PowerManger_INFO_HEADER
|
||||
#define PowerManger_INFO_HEADER
|
||||
|
||||
void showSynopsis();
|
||||
void showHelpAndExit();
|
||||
void showExampleConfigAndExit();
|
||||
void showInterfaceAndExit();
|
||||
void showReleaseInfoAndExit();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/************************************************************/
|
||||
/* NAME: */
|
||||
/* ORGN: MIT, Cambridge MA */
|
||||
/* FILE: main.cpp, Cambridge MA */
|
||||
/* DATE: December 29th, 1963 */
|
||||
/************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include "MBUtils.h"
|
||||
#include "ColorParse.h"
|
||||
#include "PowerManger.h"
|
||||
#include "PowerManger_Info.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
string mission_file;
|
||||
string run_command = argv[0];
|
||||
|
||||
for(int i=1; i<argc; i++) {
|
||||
string argi = argv[i];
|
||||
if((argi=="-v") || (argi=="--version") || (argi=="-version"))
|
||||
showReleaseInfoAndExit();
|
||||
else if((argi=="-e") || (argi=="--example") || (argi=="-example"))
|
||||
showExampleConfigAndExit();
|
||||
else if((argi == "-h") || (argi == "--help") || (argi=="-help"))
|
||||
showHelpAndExit();
|
||||
else if((argi == "-i") || (argi == "--interface"))
|
||||
showInterfaceAndExit();
|
||||
else if(strEnds(argi, ".moos") || strEnds(argi, ".moos++"))
|
||||
mission_file = argv[i];
|
||||
else if(strBegins(argi, "--alias="))
|
||||
run_command = argi.substr(8);
|
||||
else if(i==2)
|
||||
run_command = argi;
|
||||
}
|
||||
|
||||
if(mission_file == "")
|
||||
showHelpAndExit();
|
||||
|
||||
cout << termColor("green");
|
||||
cout << "pPowerManger launching as " << run_command << endl;
|
||||
cout << termColor() << endl;
|
||||
|
||||
PowerManger PowerManger;
|
||||
|
||||
PowerManger.Run(run_command.c_str(), mission_file.c_str());
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
//------------------------------------------------
|
||||
// pPowerManger config block
|
||||
|
||||
ProcessConfig = pPowerManger
|
||||
{
|
||||
AppTick = 4
|
||||
CommsTick = 4
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
#include "udpMsg.h"
|
||||
|
||||
|
||||
udpMsg::udpMsg()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
udpMsg::~udpMsg()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef UDPMSG__H
|
||||
#define UDPMSG__H
|
||||
|
||||
class udpMsg
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
udpMsg(/* args */);
|
||||
~udpMsg();
|
||||
};
|
||||
|
||||
udpMsg::udpMsg(/* args */)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
udpMsg::~udpMsg()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user