-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKrakenHashgraph.cpp
More file actions
68 lines (50 loc) · 1.77 KB
/
Copy pathKrakenHashgraph.cpp
File metadata and controls
68 lines (50 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <fstream> // Include for file operations
#include <sstream> // Include for stringstream
#include <iomanip> // Include for setprecision
#include "KrakenHashgraph.h"
using namespace std;
// Assuming other necessary includes and namespaces are already present...
//---------------------------------------------------------
// Procedure: OnNewMail()
bool KrakenHashgraph::OnNewMail(MOOSMSG_LIST &NewMail)
{
AppCastingMOOSApp::OnNewMail(NewMail);
ofstream outputFile("output.txt", ios::trunc); // Open file for truncating (clearing) and writing
MOOSMSG_LIST::iterator p;
for(p = NewMail.begin(); p != NewMail.end(); p++) {
CMOOSMsg &msg = *p;
string key = msg.GetKey();
string sval = msg.GetString();
// Write key-value pair to file
// outputFile << "'" << key << "' = '" << sval << "'" << endl;
bool handled = false;
if(key == "NODE_REPORT")
handled = onNodeReport(sval);
else if(key == "NODE_REPORT_LOCAL")
handled = onNodeReportLocal(sval);
else if(key == "DB_UPTIME"){
dbtime = msg.GetDouble();
outputFile << "'" << key << "' = '" << sval << "'" << endl;
handled = true;
}
//else if(key == "DOA"){
// doa = msg.GetDouble();
// outputFile << "'" << key << "' = '" << sval << "'" << endl;
// handled = true;
//}
else if(key == "NAV_X"){
nav_x = msg.GetDouble();
outputFile << "'" << key << "' = '" << sval << "'" << endl;
handled = true;
}
else if(key == "NAV_Y"){
nav_y = msg.GetDouble();
outputFile << "'" << key << "' = '" << sval << "'" << endl;
handled = true;
}
if(!handled)
reportRunWarning("Unhandled Mail: '" + key + "'");
}
// outputFile will automatically close when going out of scope
return true;
}