迁移分支

This commit is contained in:
zengxiaobin
2023-11-24 17:09:26 +08:00
commit a6919ec672
158 changed files with 30851 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
#--------------------------------------------------------
# The CMakeLists.txt for: pFaultHandle
# Author(s): wade
#--------------------------------------------------------
SET(SRC
FaultHandle.cpp
FaultHandle_Info.cpp
main.cpp
FaultHandle.h
)
# FIND_LIBRARY(/usr/local/lib)
# FIND_PATH(/usr/local/include)
include_directories(/usr/local/include/jsoncpp/)
link_directories(/usr/local/lib/)
ADD_EXECUTABLE(pFaultHandle ${SRC})
TARGET_LINK_LIBRARIES(pFaultHandle
${MOOS_LIBRARIES}
${CMAKE_DL_LIBS}
${SYSTEM_LIBS}
mbutil
pthread
jsoncpp
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,211 @@
/************************************************************/
/* NAME: wade */
/* ORGN: MIT */
/* FILE: FaultHandle.h */
/* DATE: */
/************************************************************/
#ifndef FaultHandle_HEADER
#define FaultHandle_HEADER
#include "MOOS/libMOOS/Thirdparty/AppCasting/AppCastingMOOSApp.h"
#include "MOOS/libMOOS/MOOSLib.h"
//#include "moos.h"
#include <json/json.h>
#include <string>
#include <vector>
#include <map>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
//class FaultHandle : public CMOOSApp
class FaultHandle : public AppCastingMOOSApp
{
public:
FaultHandle();
~FaultHandle();
protected: // Standard MOOSApp functions to overload
bool OnNewMail(MOOSMSG_LIST &NewMail);
bool Iterate();
bool OnConnectToServer();
bool OnStartUp();
bool buildReport();
void RegisterVariables();
protected:
void handleMailNewDBClients();
void handleMailStatusUpdate(std::string);
bool handleConfigWatchList(std::string);
bool handleConfigWatchItem(std::string);
bool handleConfigExcludeList(std::string);
bool handleConfigExcludeItem(std::string);
protected:
bool addToWatchList(std::string);
void checkForIndividualUpdates();
void postFullSummary();
bool isAlive(std::string);
void procNotedHere(std::string);
void procNotedGone(std::string);
void procNotedExcused(std::string);
void handlePostMapping(std::string);
std::string postVar(std::string);
void populateAntlerList();
bool processIncluded(const std::string& procname);
bool processExcluded(const std::string& procname);
protected:
std::string convertSecondsToString(double);
void errorMsgInit();
void MoosAppStatusMonitor();
void MoosAppOverloadMonitor();
void MissionFaultMonitor();
void MotionControlMonitor();
void DeviceLeakageMonitor();
void BatteryStatusMonitor();
void EmergencyBatteryMonitor();
void ThrustStatusMonitor();
void CPUTempMonitor();
void FaultReset();
bool MoosAppMissing();
bool MoosAppOverload();
protected: // State Variables
bool m_proc_watch_summary_changed;
double m_last_posting_time;
// Clients and Summary stored across iterations
std::string m_db_clients;
std::string m_proc_watch_summary;
std::vector<std::string> m_watch_list;
std::vector<std::string> m_excused_list;
// Mapping from proc name to data
std::map<std::string, bool> m_map_alive;
std::map<std::string, bool> m_map_alive_prev;
std::map<std::string, unsigned int> m_map_noted_gone;
std::map<std::string, unsigned int> m_map_noted_here;
std::map<std::string, double> m_map_now_cpuload;
std::map<std::string, double> m_map_max_cpuload;
std::set<std::string> m_set_db_clients;
std::set<std::string> m_set_watch_clients;
std::set<std::string> m_set_antler_clients;
protected: // Configurations Variables
bool m_watch_all_db;
bool m_watch_all_antler;
double m_allow_retractions;
double m_min_wait;
double m_noted_gone_wait;
// Include List
std::vector<std::string> m_include_list;
std::vector<bool> m_include_list_prefix;
// Exclude List
std::vector<std::string> m_exclude_list;
std::vector<bool> m_exclude_list_prefix;
// A dedicated MOOS var for posting when a proc chgs status
std::map<std::string, std::string> m_map_proc_post;
// A map for changing the MOOS variable posted.
std::map<std::string, std::string> m_map_chgpost;
protected:
int m_Mission_fault_fb;
int m_Motion_fault_fb;
double m_CPU_temperature;
bool m_resetMsg_fb;
uint32_t m_faultBattery;
uint32_t m_faultEmergencyBattery;
uint32_t m_faultLeakSensor;
uint32_t m_faultThrust;
uint32_t m_batteryLevel;
Json::Value Device_monitor;
Json::Value MoosApp_cpuLoad;
Json::Value MoosAppStatus;
Json::Value uFH_ErrorMsg_fb;
Json::Value uFH_errorMsg1_fb;
Json::Value uFH_errorMsg2_fb;
Json::Value uFH_errorMsg3_fb;
Json::Value msg3_faultID_array;
Json::Value msg2_PSfaultID_array;
Json::Value msg2_emergencyPS_array;
Json::Value msg2_thrust_Status_array;
Json::Value msg1_faultID_array;
//--------------------------------------test------------------------------
//std::string ODO_StatusStr;
std::string BSC_StatusStr;
std::string DM_StatusStr;
std::string MC_StatusStr;
std::string SSC_StatusStr;
std::string TM_StatusStr;
std::string pOdometryCPUload;
std::string BSC_CPUloadStr;
std::string DM_CPUloadStr;
std::string MC_CPUloadStr;
std::string SSC_CPUloadStr;
std::string TM_CPUloadStr;
//double ABC;
double BSC_cpuload;
double DM_cpuload;
double MC_cpuload;
double SSC_cpuload;
double TM_cpuload;
//--------------------------------------test------------------------------
protected:
//Contingency variable
// bool uSensor_leakage_fb;
// bool uMission_deepOut_fb;
// bool uMission_timeOut_fb;
// bool uDrive_batteryLow_fb;
// double uSoftWare_appMiss_fb; //AppID
//------------------------------------------------
//subscribe variables
private: // Configuration variables
private: // State variables
};
#endif

View File

@@ -0,0 +1,115 @@
/****************************************************************/
/* NAME: wade */
/* ORGN: MIT Cambridge MA */
/* FILE: FaultHandle_Info.cpp */
/* DATE: Dec 29th 1963 */
/****************************************************************/
#include <cstdlib>
#include <iostream>
#include "FaultHandle_Info.h"
#include "ColorParse.h"
#include "ReleaseInfo.h"
using namespace std;
//----------------------------------------------------------------
// Procedure: showSynopsis
void showSynopsis()
{
blk("SYNOPSIS: ");
blk("------------------------------------ ");
blk(" The pFaultHandle application is used for ");
blk(" ");
blk(" ");
blk(" ");
blk(" ");
}
//----------------------------------------------------------------
// Procedure: showHelpAndExit
void showHelpAndExit()
{
blk(" ");
blu("=============================================================== ");
blu("Usage: pFaultHandle file.moos [OPTIONS] ");
blu("=============================================================== ");
blk(" ");
showSynopsis();
blk(" ");
blk("Options: ");
mag(" --alias","=<ProcessName> ");
blk(" Launch pFaultHandle with the given process name ");
blk(" rather than pFaultHandle. ");
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 pFaultHandle. ");
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("pFaultHandle Example MOOS Configuration ");
blu("=============================================================== ");
blk(" ");
blk("ProcessConfig = pFaultHandle ");
blk("{ ");
blk(" AppTick = 4 ");
blk(" CommsTick = 4 ");
blk(" ");
blk("} ");
blk(" ");
exit(0);
}
//----------------------------------------------------------------
// Procedure: showInterfaceAndExit
void showInterfaceAndExit()
{
blk(" ");
blu("=============================================================== ");
blu("pFaultHandle 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("pFaultHandle", "gpl");
exit(0);
}

View File

@@ -0,0 +1,18 @@
/****************************************************************/
/* NAME: wade */
/* ORGN: MIT Cambridge MA */
/* FILE: FaultHandle_Info.h */
/* DATE: Dec 29th 1963 */
/****************************************************************/
#ifndef FaultHandle_INFO_HEADER
#define FaultHandle_INFO_HEADER
void showSynopsis();
void showHelpAndExit();
void showExampleConfigAndExit();
void showInterfaceAndExit();
void showReleaseInfoAndExit();
#endif

52
src/pFaultHandle/main.cpp Normal file
View File

@@ -0,0 +1,52 @@
/************************************************************/
/* NAME: wade */
/* ORGN: MIT */
/* FILE: main.cpp */
/* DATE: */
/************************************************************/
#include <string>
#include "MBUtils.h"
#include "ColorParse.h"
#include "FaultHandle.h"
#include "FaultHandle_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 << "pFaultHandle launching as " << run_command << endl;
cout << termColor() << endl;
FaultHandle FaultHandle;
FaultHandle.Run(run_command.c_str(), mission_file.c_str());
return(0);
}

View File

@@ -0,0 +1,9 @@
//------------------------------------------------
// pFaultHandle config block
ProcessConfig = pFaultHandle
{
AppTick = 4
CommsTick = 4
}