fixed conflict
parent
8dc9405414
commit
9e36adef92
154
galmonmon.cc
154
galmonmon.cc
|
@ -161,8 +161,10 @@ static std::string string_replace(const std::string& str, const std::string& mat
|
||||||
|
|
||||||
void sendTweet(const string& tweet)
|
void sendTweet(const string& tweet)
|
||||||
{
|
{
|
||||||
string etweet = string_replace(tweet, "+", "%2b");
|
string etweet = tweet;
|
||||||
system((string("twurl -X POST \"/1.1/statuses/update.json?status=")+etweet+"\" >> twitter.log").c_str());
|
//system((string("twurl -X POST /1.1/statuses/update.json -d \"media_ids=1215649475231997953&status=")+etweet+"\" >> twitter.log").c_str());
|
||||||
|
system((string("twurl -X POST /1.1/statuses/update.json -d \"status=")+etweet+"\" >> twitter.log").c_str());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -170,7 +172,7 @@ int main(int argc, char **argv)
|
||||||
MiniCurl mc;
|
MiniCurl mc;
|
||||||
MiniCurl::MiniCurlHeaders mch;
|
MiniCurl::MiniCurlHeaders mch;
|
||||||
// string url="https://galmon.eu/svs.json";
|
// string url="https://galmon.eu/svs.json";
|
||||||
string url="http://[::1]:10000/";
|
string url="http://[::1]:29599/";
|
||||||
bool doVERSION{false};
|
bool doVERSION{false};
|
||||||
|
|
||||||
CLI::App app(program);
|
CLI::App app(program);
|
||||||
|
@ -195,8 +197,13 @@ int main(int argc, char **argv)
|
||||||
std::variant<bool, string> tst;
|
std::variant<bool, string> tst;
|
||||||
|
|
||||||
auto observers = nlohmann::json::parse(mc.getURL(url+"observers.json"));
|
auto observers = nlohmann::json::parse(mc.getURL(url+"observers.json"));
|
||||||
|
|
||||||
|
sendTweet("Galmonmon " +string(g_gitHash)+ " started, " + std::to_string(observers.size()) +" observers seen");
|
||||||
cout<<("Galmonmon " +string(g_gitHash)+ " started, " + std::to_string(observers.size()) +" observers seen")<<endl;
|
cout<<("Galmonmon " +string(g_gitHash)+ " started, " + std::to_string(observers.size()) +" observers seen")<<endl;
|
||||||
|
|
||||||
|
string meh="🤔";
|
||||||
|
string unhappy="😬";
|
||||||
|
string alert="🚨";
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
try {
|
try {
|
||||||
|
@ -218,31 +225,39 @@ int main(int argc, char **argv)
|
||||||
j = nlohmann::json::parse(res);
|
j = nlohmann::json::parse(res);
|
||||||
bool first=true;
|
bool first=true;
|
||||||
for(const auto& sv : j) {
|
for(const auto& sv : j) {
|
||||||
|
if(!sv.count("gnssid") || !sv.count("fullName") || !sv.count("sigid")) {
|
||||||
int gnssid = sv["gnssid"];
|
cout<<"Skipping "<< sv.count("gnssid") <<", "<< sv.count("fullName") <<", " <<sv.count("sigid") <<endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int gnssid = sv["gnssid"], sigid = sv["sigid"];
|
||||||
string fullName = sv["fullName"];
|
string fullName = sv["fullName"];
|
||||||
|
|
||||||
if(!(gnssid == 2 && sv["sigid"]==1) &&
|
if(!(gnssid == 2 && sigid==1) &&
|
||||||
!(gnssid == 0 && sv["sigid"]==0) &&
|
!(gnssid == 0 && sigid==0) &&
|
||||||
!(gnssid == 3 && sv["sigid"]==0) &&
|
!(gnssid == 3 && sigid==0) &&
|
||||||
!(gnssid == 6 && sv["sigid"]==0))
|
!(gnssid == 6 && sigid==0))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int numfresh=0;
|
int numfresh=0;
|
||||||
// we only track "received status" for GPS and Galileo
|
// we only track "received status" for GPS and Galileo
|
||||||
bool notseen= gnssid ==0 || gnssid==2;
|
bool notseen= gnssid ==0 || gnssid==2;
|
||||||
if(!sv.count("sisa") && !sv.count("eph-age-m"))
|
if(!sv.count("healthissue") || !sv.count("eph-age-m") || !sv.count("sisa") || !sv.count("perrecv")) {
|
||||||
|
// cout<<"Skipping "<<fullName<<" in loop: "<<sv.count("healthissue")<<", "<<sv.count("eph-age-m") << ", "<<sv.count("perrecv")<<endl;
|
||||||
continue;
|
continue;
|
||||||
if(sv.count("perrecv")) {
|
|
||||||
for(const auto& recv : sv["perrecv"]) {
|
|
||||||
if((int)recv["last-seen-s"] < 60)
|
|
||||||
numfresh++;
|
|
||||||
if((int)recv["last-seen-s"] < 3600)
|
|
||||||
notseen=false;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(const auto& recv : sv["perrecv"]) {
|
||||||
|
if(!recv.count("last-seen-s")) {
|
||||||
|
cout<<"Missing last-seen-s"<<endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if((int)recv["last-seen-s"] < 60)
|
||||||
|
numfresh++;
|
||||||
|
if((int)recv["last-seen-s"] < 3600)
|
||||||
|
notseen=false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
auto healthchange = g_sk.reportState(fullName, "health", sv["healthissue"]!=0);
|
auto healthchange = g_sk.reportState(fullName, "health", sv["healthissue"]!=0);
|
||||||
std::optional<string> tooOldChange;
|
std::optional<string> tooOldChange;
|
||||||
if(gnssid == 2)
|
if(gnssid == 2)
|
||||||
|
@ -253,6 +268,14 @@ int main(int argc, char **argv)
|
||||||
auto seenChange = g_sk.reportState(fullName, "silent", notseen);
|
auto seenChange = g_sk.reportState(fullName, "silent", notseen);
|
||||||
|
|
||||||
auto sisaChange = g_sk.reportState(fullName, "sisa", (string)sv["sisa"]);
|
auto sisaChange = g_sk.reportState(fullName, "sisa", (string)sv["sisa"]);
|
||||||
|
|
||||||
|
double ephdisco = sv.count("latest-disco") ? (double)sv["latest-disco"] : -1.0;
|
||||||
|
auto ephdiscochange = g_sk.reportState(fullName, "eph-disco", ephdisco);
|
||||||
|
if(ephdisco == -1.0)
|
||||||
|
ephdiscochange.reset();
|
||||||
|
|
||||||
|
double timedisco = sv.count("time-disco") ? fabs((double)sv["time-disco"]) : 0.0;
|
||||||
|
auto timediscochange = g_sk.reportState(fullName, "time-disco", timedisco);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
cout<<fullName<<": numfresh "<<numfresh << " healthissue "<<sv["healthissue"];
|
cout<<fullName<<": numfresh "<<numfresh << " healthissue "<<sv["healthissue"];
|
||||||
|
@ -264,39 +287,72 @@ int main(int argc, char **argv)
|
||||||
if(auto val = g_sk.getState(fullName, "health"); val) {
|
if(auto val = g_sk.getState(fullName, "health"); val) {
|
||||||
cout<<" health \""<<*val<<"\"";
|
cout<<" health \""<<*val<<"\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ephdiscochange) {
|
||||||
|
cout<<fullName <<": ephemeris (orbit description) discontinuity of "<< fmt::sprintf("%.02f", ephdisco)<<" meters"<<endl;
|
||||||
|
}
|
||||||
|
if(timediscochange) {
|
||||||
|
cout<<fullName <<": clock jump of "<< fmt::sprintf("%.02f", timedisco)<<" nanoseconds (= " <<fmt::sprintf("%.01f meters)", timedisco/2.99)<<endl;
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
if(healthchange || tooOldChange || seenChange || sisaChange) {
|
ostringstream out;
|
||||||
|
|
||||||
|
|
||||||
|
if(healthchange)
|
||||||
|
out<< *healthchange<<" ";
|
||||||
|
if(tooOldChange) {
|
||||||
|
out<< "Ephemeris age: "<<*tooOldChange<<", new value: "<< fmt::sprintf("%.02f", (double)sv["eph-age-m"])<<" minutes, old: ";
|
||||||
|
out<< *g_sk.getPrevState(fullName, "eph-too-old");
|
||||||
|
}
|
||||||
|
if(seenChange)
|
||||||
|
out<< *seenChange<<" ";
|
||||||
|
|
||||||
|
if(ephdiscochange && (gnssid ==0 || gnssid == 2) && ephdisco > 1.45) {
|
||||||
|
if(ephdisco > 10)
|
||||||
|
out<<alert;
|
||||||
|
else if(ephdisco > 5)
|
||||||
|
out<<unhappy;
|
||||||
|
else
|
||||||
|
out<<meh;
|
||||||
|
|
||||||
|
out<<" ephemeris (orbit description) discontinuity of "<< fmt::sprintf("%.02f", ephdisco)<<" meters"<<endl;
|
||||||
|
}
|
||||||
|
if(timediscochange && (gnssid == 2 && timedisco > 2.5)) {
|
||||||
|
if(timedisco > 10)
|
||||||
|
out<<alert;
|
||||||
|
else if(timedisco > 5)
|
||||||
|
out<<unhappy;
|
||||||
|
else
|
||||||
|
out<<meh;
|
||||||
|
out<<" clock jump of "<< fmt::sprintf("%.02f", timedisco)<<" nanoseconds (= " <<fmt::sprintf("%.01f meters)", timedisco/2.99)<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sisaChange) {
|
||||||
|
ostringstream tmp;
|
||||||
|
tmp<< " SISA/URA reported ranging accuracy changed, new: "<<*sisaChange<<", old: " << *g_sk.getPrevState(fullName, "sisa");
|
||||||
|
if(tmp.str().find("200 cm") == string::npos || tmp.str().find("282 cm") == string::npos)
|
||||||
|
out << tmp.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
string tweet;
|
||||||
|
if(!out.str().empty()) {
|
||||||
|
if(gnssid == 0)
|
||||||
|
tweet = "GPS";
|
||||||
|
else if(gnssid == 2)
|
||||||
|
tweet = "Galileo";
|
||||||
|
else if(gnssid == 3)
|
||||||
|
tweet ="BeiDou";
|
||||||
|
else if(gnssid== 6)
|
||||||
|
tweet = "GLONASS";
|
||||||
|
tweet += " " + fullName +": ";
|
||||||
|
tweet += out.str();
|
||||||
|
|
||||||
|
|
||||||
|
sendTweet(tweet);
|
||||||
if(first)
|
if(first)
|
||||||
cout<<"\n";
|
cout<<"\n";
|
||||||
first=false;
|
first=false;
|
||||||
ostringstream out;
|
cout<<humanTimeNow() <<" " << tweet << endl;
|
||||||
|
|
||||||
if(gnssid == 0)
|
|
||||||
out<<"GPS";
|
|
||||||
else if(gnssid == 2)
|
|
||||||
out<<"Galileo";
|
|
||||||
else if(gnssid == 3)
|
|
||||||
out<<"BeiDou";
|
|
||||||
else if(gnssid== 6)
|
|
||||||
out<<"GLONASS";
|
|
||||||
out<<" "<<fullName<<": ";
|
|
||||||
|
|
||||||
if(healthchange)
|
|
||||||
out<< *healthchange<<" ";
|
|
||||||
if(tooOldChange) {
|
|
||||||
out<< *tooOldChange<<", new value: "<< fmt::sprintf("%.02f", (double)sv["eph-age-m"])<<" minutes, old: ";
|
|
||||||
out<< *g_sk.getPrevState(fullName, "eph-too-old");
|
|
||||||
}
|
|
||||||
if(seenChange)
|
|
||||||
out<< *seenChange<<" ";
|
|
||||||
if(sisaChange) {
|
|
||||||
out<< "SISA/URA reported ranging accuracy new: "<<*sisaChange<<", old: " << *g_sk.getPrevState(fullName, "sisa");
|
|
||||||
}
|
|
||||||
if(out.str().find("200 cm") == string::npos || out.str().find("282 cm") == string::npos)
|
|
||||||
sendTweet("TESTING: "+out.str());
|
|
||||||
cout<<humanTimeNow()<<" CHANGE ";
|
|
||||||
cout<<out.str()<<endl;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout<<".";
|
cout<<".";
|
||||||
|
|
Loading…
Reference in New Issue