Changeset 19564
- Timestamp:
- 07/19/19 19:25:26 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/gcn.cc
r19554 r19564 1 1 #include <functional> 2 2 #include <boost/algorithm/string/join.hpp> 3 4 #include "Database.h" 3 5 4 6 #include "Dim.h" … … 41 43 bool fDebugRx; 42 44 45 string fUri; 46 43 47 uint32_t fRxSize; 44 48 vector<char> fRxData; … … 79 83 { 80 84 if (root.isNull()) 81 return - 1;85 return -255; 82 86 83 87 const string role = root.attribute("role", "").toStdString(); … … 93 97 const QDomElement time = root.firstChildElement("TimeStamp"); 94 98 if (orig.isNull() || time.isNull()) 95 return - 1;99 return -254; 96 100 97 101 fLastKeepAlive = Time(time.text().toStdString()); … … 126 130 //const QDomElement ref = root.firstChildElement("Reference"); 127 131 if (who.isNull() || what.isNull() || when.isNull()) 128 return - 1;132 return -253; 129 133 130 134 const auto ptype = GetType(what); … … 149 153 150 154 const auto &id = ptype->first; 155 156 if (id==0) 157 { 158 Warn("Packet ID = 0"); 159 return -252; 160 } 151 161 152 162 // Gravitational wave event … … 187 197 { 188 198 Warn("Missing elements: "+boost::algorithm::join(missing, ", ")); 189 return - 1;199 return -id; 190 200 } 191 201 … … 468 478 Out() << fRxData.data() << '\n'; 469 479 Out() << "------------------------------------------------------" << endl; 470 PostClose( false);480 PostClose(true); 471 481 return; 472 482 } … … 482 492 Out() << fRxData.data() << '\n'; 483 493 Out() << "------------------------------------------------------" << endl; 484 PostClose(false); 494 //PostClose(false); 495 496 try 497 { 498 auto db = Database(fUri); 499 500 // Make an entry in the alter databse to issue a call 501 const string query = 502 "INSERT FlareTriggers SET\n" 503 " fTriggerInserted=Now(),\n" 504 " fNight="+to_string(Time().NightAsInt())+",\n" 505 " fRunID="+to_string(-rc)+",\n" 506 " fTriggerType=8"; 507 508 auto q = db.query(query); 509 q.execute(); 510 if (!q.info().empty()) 511 Info(q.info()); 512 } 513 catch (const mysqlpp::ConnectionFailed &e) 514 { 515 Error(e.what()); 516 } 517 485 518 return; 486 519 } … … 525 558 fDebugRx = b; 526 559 Connection::SetVerbose(b); 560 } 561 562 void SetURI(const string &uri) 563 { 564 fUri = uri; 527 565 } 528 566 … … 680 718 fGCN.SetEndPoints(conf.Vec<string>("addr")); 681 719 720 fGCN.SetURI(conf.Get<string>("schedule-database")); 721 682 722 return -1; 683 723 } … … 701 741 ("addr,a", vars<string>(), "Network addresses of GCN server") 702 742 ("quiet,q", po_bool(true), "Disable printing contents of all received messages (except dynamic data) in clear text.") 743 ("schedule-database", var<string>(), "Database link as in\n\tuser:password@server[:port]/database[?compress=0|1].") 703 744 ; 704 745
Note:
See TracChangeset
for help on using the changeset viewer.