/*------------------------------------------------------- Upstream MQTTSnRegister -------------------------------------------------------*/ void GatewayControlTask::handleSnRegister(Event* ev, ClientNode* clnode, MQTTSnMessage* msg){ printf(FORMAT2, currentDateTime(), "REGISTER", LEFTARROW, clnode->getNodeId()->c_str(), msgPrint(msg)); MQTTSnRegister* snMsg = new MQTTSnRegister(); MQTTSnRegAck* respMsg = new MQTTSnRegAck(); snMsg->absorb(msg); respMsg->setMsgId(snMsg->getMsgId()); uint16_t tpId = clnode->getTopics()->createTopic(snMsg->getTopicName()); respMsg->setTopicId(tpId); respMsg->setReturnCode(MQTTSN_RC_ACCEPTED); clnode->setClientSendMessage(respMsg); Event* evrg = new Event(); evrg->setClientSendEvent(clnode); printf(FORMAT1, currentDateTime(), "REGACK", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(respMsg)); _res->getClientSendQue()->post(evrg); delete snMsg; }
/*------------------------------------------------------- Upstream MQTTSnWillMsg -------------------------------------------------------*/ void GatewayControlTask::handleSnWillMsg(Event* ev, ClientNode* clnode, MQTTSnMessage* msg){ printf(FORMAT1, currentDateTime(), "WILLMSG", LEFTARROW, clnode->getNodeId()->c_str(), msgPrint(msg)); MQTTSnWillMsg* snMsg = new MQTTSnWillMsg(); snMsg->absorb(msg); if(clnode->getConnectMessage()){ clnode->getConnectMessage()->setWillMessage(snMsg->getWillMsg()); clnode->setBrokerSendMessage(clnode->getConnectMessage()); clnode->setConnectMessage(0); Event* ev1 = new Event(); ev1->setBrokerSendEvent(clnode); _res->getBrokerSendQue()->post(ev1); }else{ MQTTSnConnack* connack = new MQTTSnConnack(); connack->setReturnCode(MQTTSN_RC_REJECTED_CONGESTION); clnode->setClientSendMessage(connack); Event* ev1 = new Event(); ev1->setClientSendEvent(clnode); printf(RED_FORMAT1, currentDateTime(), "*CONNACK", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(connack)); _res->getClientSendQue()->post(ev1); // Send CONNACK REJECTED CONGESTION to Client } delete snMsg; }
/** * Function: Logger::WriteToFile() * Description: Writes a specific message to a logFile and the generic logfile. * Based on the messageType it also writes the message to a specific log file */ void Logger::WriteToFile(MessageType newType, const std::string& message) { std::fstream theLogfile (genericlogfile.c_str(), std::fstream::in | std::fstream::out | std::fstream::app); if (theLogfile.is_open()) { theLogfile << "[" << currentDateTime() << "] " << toString(newType) << ": " << message << std::endl; theLogfile.close(); } else { std::cout << "Error: unable to open logfile '" << genericlogfile << "'!" << std::endl; } if (newType == Success) { std::fstream specialisedLog(succeslogfile.c_str(), std::fstream::in | std::fstream::out | std::fstream::app); if (specialisedLog.is_open()) { specialisedLog << "[" << currentDateTime() << "] " << toString(newType) << ": " << message << std::endl; specialisedLog.close(); } else { std::cout << "Error: unable to open logfile '" << succeslogfile << "'!" << std::endl; } } else if (newType == Error || newType == FatalError) { std::fstream specialisedLog(errorlogfile.c_str(), std::fstream::in | std::fstream::out | std::fstream::app); if (specialisedLog.is_open()) { specialisedLog << "[" << currentDateTime() << "] " << toString(newType) << ": " << message << std::endl; specialisedLog.close(); } else { std::cout << "Error: unable to open logfile '" << errorlogfile << "'!" << std::endl; } } else if (newType == Warning) { std::fstream specialisedLog(warninglogfile.c_str(), std::fstream::in | std::fstream::out | std::fstream::app); if (specialisedLog.is_open()) { specialisedLog << "[" << currentDateTime() << "] " << toString(newType) << ": " << message << std::endl; specialisedLog.close(); } else { std::cout << "Error: unable to open logfile '" << warninglogfile << "'!" << std::endl; } } }
/*------------------------------------------------------- Downstream MQTTPublish -------------------------------------------------------*/ void GatewayControlTask::handlePublish(Event* ev, ClientNode* clnode, MQTTMessage* msg){ MQTTPublish* mqMsg = static_cast<MQTTPublish*>(msg); MQTTSnPublish* snMsg = new MQTTSnPublish(); string* tp = mqMsg->getTopic(); uint16_t tpId; if(tp->size() == 2){ tpId = getUint16((uint8_t*)tp); snMsg->setFlags(MQTTSN_TOPIC_TYPE_SHORT); }else{ tpId = clnode->getTopics()->getTopicId(tp); snMsg->setFlags(MQTTSN_TOPIC_TYPE_NORMAL); } if(tpId == 0){ /* ----- may be a publish message response of subscribed with '#' or '+' -----*/ tpId = clnode->getTopics()->createTopic(tp); if(tpId > 0){ MQTTSnRegister* regMsg = new MQTTSnRegister(); regMsg->setTopicId(tpId); regMsg->setTopicName(tp); printf(FORMAT2, currentDateTime(), "REGISTER", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(regMsg)); clnode->setClientSendMessage(regMsg); Event* evrg = new Event(); evrg->setClientSendEvent(clnode); _res->getClientSendQue()->post(evrg); // Send Register first. }else{ printf("GatewayControlTask Can't create Topic %s\n", tp->c_str()); return; } } snMsg->setTopicId(tpId); snMsg->setMsgId(mqMsg->getMessageId()); snMsg->setData(mqMsg->getPayload(),mqMsg->getPayloadLength()); snMsg->setQos(mqMsg->getQos()); if(mqMsg->isDup()){ snMsg->setDup(); } if(mqMsg->isRetain()){ snMsg->setDup(); } clnode->setClientSendMessage(snMsg); printf(GREEN_FORMAT1, currentDateTime(), "PUBLISH", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(snMsg)); Event* ev1 = new Event(); ev1->setClientSendEvent(clnode); _res->getClientSendQue()->post(ev1); }
void CoreServer::write_log (log PRIORTY,std::string logtxt) { std::fstream log("ArmaEasyDB.log",std::ios::out | std::ios::app); switch(PRIORTY) { case INFO : if(debug) { std::cout << "[" << currentDateTime() <<"]" << " [INFO]: " << logtxt << std::endl; } log << "[" << currentDateTime() <<"]" << " [INFO]: " << logtxt << std::endl; break; case WARNING : if(debug) { std::cout << "[" << currentDateTime() <<"]" << " [WARNING]: " << logtxt << std::endl; } log << "[" << currentDateTime() <<"]" << " [WARNING]: " << logtxt << std::endl; break; case _ERROR: if(debug) { std::cout << "[" << currentDateTime() <<"]" << " [ERROR]: " << logtxt << std::endl; } log << "[" << currentDateTime() <<"]" << " [ERROR]: " << logtxt << std::endl; break; case OUTPUT: if(debug) { std::cout << "[" << currentDateTime() <<"]" << " [OUTPUT]: " << logtxt << std::endl; } log << "[" << currentDateTime() <<"]" << " [OUTPUT]: " << logtxt << std::endl; break; } }
/*------------------------------------------------------- Upstream MQTTSnUnsubscribe -------------------------------------------------------*/ void GatewayControlTask::handleSnUnsubscribe(Event* ev, ClientNode* clnode, MQTTSnMessage* msg){ printf(FORMAT2, currentDateTime(), "UNSUBSCRIBE", LEFTARROW, clnode->getNodeId()->c_str(), msgPrint(msg)); MQTTSnUnsubscribe* sUnsubscribe = new MQTTSnUnsubscribe(); MQTTUnsubscribe* unsubscribe = new MQTTUnsubscribe(); sUnsubscribe->absorb(msg); uint8_t topicIdType = sUnsubscribe->getFlags() & 0x03; unsubscribe->setMessageId(sUnsubscribe->getMsgId()); if(topicIdType != MQTTSN_FLAG_TOPICID_TYPE_RESV){ if(topicIdType == MQTTSN_FLAG_TOPICID_TYPE_SHORT){ unsubscribe->setTopicName(sUnsubscribe->getTopicName()); // TopicName }else if(clnode->getTopics()->getTopic(sUnsubscribe->getTopicId())){ if(topicIdType == MQTTSN_FLAG_TOPICID_TYPE_PREDEFINED) goto uslbl1; unsubscribe->setTopicName(sUnsubscribe->getTopicName()); } clnode->setBrokerSendMessage(unsubscribe); Event* ev1 = new Event(); ev1->setBrokerSendEvent(clnode); _res->getBrokerSendQue()->post(ev1); // UNSUBSCRIBE to Broker delete sUnsubscribe; return; } /*-- Irregular TopicIdType or MQTTSN_FLAG_TOPICID_TYPE_PREDEFINED --*/ uslbl1: if(sUnsubscribe->getMsgId()){ MQTTSnUnsubAck* sUnsuback = new MQTTSnUnsubAck(); sUnsuback->setMsgId(sUnsubscribe->getMsgId()); clnode->setClientSendMessage(sUnsuback); Event* evun = new Event(); evun->setClientSendEvent(clnode); printf(FORMAT1, currentDateTime(), "UNSUBACK", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(sUnsuback)); _res->getClientSendQue()->post(evun); // Send UNSUBACK to Client } delete sUnsubscribe; }
void sendMessageHidden(string str,string message){ vector<string> temp; string ret; //string message; //cout << "Please enter your message to " << str << " : "; //getline(cin >> ws,message); temp.push_back("MSG"); temp.push_back(username); temp.push_back(str); temp.push_back(currentDateTime()); temp.push_back(message); ret = protocolMaker(temp); if (sendToServer(ret) == 0){ string path = "bin/client/message_history/"; path += username; path += "-"; path += str; path += ".txt"; vector<string> data = readExternalFileAutoCreate(path); data.push_back(ret); //moveToBottom(path); //writeExternalFile(path,data); writeExternalFile2(path,ret); //append data baru aja } else{ cout << "Failed to send messages or the user does not exist!" << endl << endl; } }
// Initializes LOG.txt file with some info for the session void initialize(FILE *file) { char* dateTime = currentDateTime(); fprintf(file, "\n\n"); fprintf(file, "|***********************************************************|\n"); fprintf(file, "| _ _ _____ _ ___ _ _ |\n"); fprintf(file, "| | | | | |_ _|| | / _ \\ | || | |\n"); fprintf(file, "| | |_| | ___ __ _ _ __ | | | |_ / /_\\ \\| || | |\n"); fprintf(file, "| | _ | / _ \\ / _` || '__| | | | __| | _ || || | |\n"); fprintf(file, "| | | | || __/| (_| || | _| |_ | |_ | | | || || | |\n"); fprintf(file, "| \\_| |_/ \\___| \\__,_||_| \\___/ \\__| \\_| |_/|_||_| |\n"); fprintf(file, "| |\n"); fprintf(file, "| |\n"); fprintf(file, "| Windows version |\n"); fprintf(file, "| |\n"); fprintf(file, "|***********************************************************|\n"); fprintf(file, "| |\n"); fprintf(file, "| Created by: Ander Granado |\n"); fprintf(file, "| |\n"); fprintf(file, "| Avaiable here: |\n"); fprintf(file, "| https://github.com/ander94lakx/HearItAllLinux |\n"); fprintf(file, "| |\n"); fprintf(file, "| Session timestamp: " + dateTime + " |\n"); fprintf(file, "| |\n"); fprintf(file, "|***********************************************************|\n\n"); }
void TMesh::logToFileAndExit(const char *s) { static char msg[2048]; sprintf(msg, "%s\nFILE: %s\nRETURN VALUE: %s\n\n", currentDateTime(), (filename) ? (filename) : ("unknown"), s); addMessageToLogFile(msg); TMesh::error(msg); }
void Logger::print(LogLevel level, std::string message, const char* file, int line) { if(!m_file.is_open() || level > m_level) return; m_file << currentDateTime(); switch(level) { case INFO: { m_file<<" [INFO] "; break; } case WARN: { m_file<<" [WARN] "; break; } case ERROR: { m_file<<" [ERROR] "; break; } default: { m_file<<" [INFO] "; break; } } m_file<<"- "<<file<<":"<<line<<" - "<<message<<std::endl; }
void ReportFailure(const char * condition, const char * file, int line, const char * msg, ...) { char messageBuffer[1024] = ""; if (msg != NULL) { va_list args; va_start(args, msg); //vsprintf(messageBuffer, msg, args); vsnprintf_s(messageBuffer, 1024, msg, args); va_end(args); } std::stringstream ss; ss << std::endl; ss << "!Assert: " << condition << std::endl; ss << "File: " << file << std::endl; ss << "Message: " << messageBuffer << std::endl; ss << "Line: " << line << std::endl; ss << "Time: " << currentDateTime() << std::endl; lastErrorMessage = messageBuffer; std::cerr << ss.str(); BWAPI::Broodwar->printf("%s", ss.str().c_str()); Logger::LogAppendToFile(Config::Debug::ErrorLogFilename, ss.str()); }
void ReportFailure(const char * condition, const char * file, int line, const char * msg, ...) { char messageBuffer[1024] = ""; if (msg != NULL) { va_list args; va_start(args, msg); //vsprintf(messageBuffer, msg, args); vsnprintf_s(messageBuffer, 1024, msg, args); va_end(args); } std::stringstream ss; ss << std::endl; ss << "!Assert: " << condition << std::endl; ss << "File: " << file << std::endl; ss << "Message: " << messageBuffer << std::endl; ss << "Line: " << line << std::endl; ss << "Time: " << currentDateTime() << std::endl; lastErrorMessage = messageBuffer; std::cerr << ss.str(); throw BOSSException(ss.str()); }
string generateReport(string filePath) { TCHAR szEXEPath[2048]; char applicationPath[2048]; string mes; GetModuleFileName(NULL, szEXEPath, 2048); int j; for (j = 0; szEXEPath[j] != 0; j++) { applicationPath[j] = szEXEPath[j]; } applicationPath[j] = '\0'; Json::Value incident; incident["appTitle"] = GetActiveWindowTitle(); incident["appPID"] = ::getpid(); incident["currentUser"] = getUserName(); incident["incidentTime"] = currentDateTime(); incident["actionTaken"] = 1; incident["fileTried"] = filePath; incident["appPath"] = applicationPath; incident["ruleId"] = crValidator->getLastIncidentId(); ostringstream inc; inc << incident; string json = inc.str(); return json; }
void CityGMLWriter::writeHeader(){ gml_ofstream << indent << "<?xml version=\"1.0\" encoding=\"utf-8\"?>"<< std::endl; gml_ofstream << indent << "<!-- CityGML Dataset produced with the IfCity-Converter developed by Sjors Donkers ([email protected]) -->"<< std::endl; gml_ofstream << indent << "<!-- Created: "<<currentDateTime()<<" -->"<<std::endl; gml_ofstream << indent++ << "<CityModel" << std::endl; gml_ofstream << indent << "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" << std::endl; gml_ofstream << indent << "xmlns:xAL=\"urn:oasis:names:tc:ciq:xsdschema:xAL:2.0\"" << std::endl; gml_ofstream << indent << "xmlns:app=\"http://www.opengis.net/citygml/appearance/2.0\"" << std::endl; gml_ofstream << indent << "xmlns:xlink=\"http://www.w3.org/1999/xlink\"" << std::endl; gml_ofstream << indent << "xmlns:gml=\"http://www.opengis.net/gml\"" << std::endl; gml_ofstream << indent << "xmlns=\"http://www.opengis.net/citygml/2.0\"" << std::endl; gml_ofstream << indent << "xmlns:bldg=\"http://www.opengis.net/citygml/building/2.0\"" << std::endl; gml_ofstream << indent << "xsi:schemaLocation=\"http://www.opengis.net/citygml/2.0 http://schemas.opengis.net/citygml/2.0/cityGMLBase.xsd" << std::endl; gml_ofstream << indent << "\thttp://www.opengis.net/citygml/appearance/2.0 http://schemas.opengis.net/citygml/appearance/2.0/appearance.xsd" << std::endl; gml_ofstream << indent << "\thttp://www.opengis.net/citygml/building/2.0 http://schemas.opengis.net/citygml/building/2.0/building.xsd\">" << std::endl; gml_ofstream << indent << "<gml:name>3D city model LOD3/4</gml:name>"<<std::endl; // gml_ofstream << indent++ << "<gml:boundedBy>"<<std::endl; // gml_ofstream << indent++ << "<gml:Envelope srsDimension=\"3\" srsName=\"urn:ogc:def:crs,crs:EPSG::25832,crs:EPSG::5783\">"<<std::endl; // gml_ofstream << indent << "<gml:lowerCorner>-50 -50 -50</gml:lowerCorner>"<<std::endl; // gml_ofstream << indent << "<gml:upperCorner>50 50 50</gml:upperCorner>"<<std::endl; // gml_ofstream << --indent << "</gml:Envelope>"<<std::endl; // gml_ofstream << --indent << "</gml:boundedBy>"<<std::endl; }
int insertOid(Oid oid) { sqlite3_stmt * stmt; std::string time = currentDateTime(); int rc = sqlite3_prepare_v2(db, sql_insert.c_str(), -1, &stmt, NULL); if (rc != SQLITE_OK) { sqlite3_finalize(stmt); return rc; } // (\'device_id\', \'oid\', \'translate\', \'active\', \'created_at\', \'updated_at\') rc |= sqlite3_bind_int(stmt, 1, oid.getDeviceId()); rc |= sqlite3_bind_text(stmt, 2, oid.getOid().c_str(), oid.getOid().length(), SQLITE_STATIC); rc |= sqlite3_bind_text(stmt, 3, oid.getTranslate().c_str(), oid.getTranslate().length(), SQLITE_STATIC); rc |= sqlite3_bind_int(stmt, 4, oid.getPingRequest()); rc |= sqlite3_bind_text(stmt, 5, oid.getActive() ? "t" : "f", 1, SQLITE_STATIC); rc |= sqlite3_bind_text(stmt, 6, time.c_str(), time.length(), SQLITE_STATIC); rc |= sqlite3_bind_text(stmt, 7, time.c_str(), time.length(), SQLITE_STATIC); if (rc != SQLITE_OK) { sqlite3_finalize(stmt); // formatting problems and SQL return rc; } rc = sqlite3_step(stmt); sqlite3_finalize(stmt); return rc; }
EntityEvent::EntityEvent(Outcome outcome, EventActionCode eventActionCode, CodedValueType eventId) : m_outcome(outcome), m_eventActionCode(eventActionCode), m_eventId(std::move(eventId)), m_eventDateTime(currentDateTime()) { }
Notebook::Notebook() { pugi::xml_node note = XmlInterface::get()->GetDocument()->child("Configuration").child("Notebook"); file_name_ = std::string(note.attribute("file").as_string()); mode_ = std::string(note.attribute("mode").as_string("a")); Messenger m; m.detail("Notebook: " + file_name_ + " mode: " + mode_); std::ofstream note_file; if (mode_ == "r") { note_file.open(file_name_.c_str(), std::ios::out); } else if (mode_ == "a") { note_file.open(file_name_.c_str(), std::ios::out | std::ios::app); } else { std::stringstream ss; ss << "Notebook: unknown mode"; ss << " : " << mode_; throw IOException(ss.str()); } if (!note_file.good()) { std::stringstream ss; ss << "Notebook: error opening output file"; ss << " : " << file_name_; throw IOException(ss.str()); } note_file << "# Starting notebook on : " << currentDateTime() << std::endl; note_file.close(); }
// Capture video and create data for report. void frm::startWork(char * haarcascade_frontalface_alt, int cameraId, char * noderedApi, bool isShowVideo) { try { m_face_cascade = new cv::CascadeClassifier(haarcascade_frontalface_alt); if (m_face_cascade->empty()) { printf("Error on loading face cascade"); } VideoCapture cameraRecord(cameraId); //0 is the id of video device.0 if you have only one camera. if (!cameraRecord.isOpened()) { //check if video device has been initialised cout << "cannot open camera cameraId=" << cameraId << endl; exit(1); } // set up parameter : cameraRecord.set(CV_CAP_PROP_FRAME_WIDTH, CAMERA_WIDTH); //set camera frame width and height cameraRecord.set(CV_CAP_PROP_FRAME_HEIGHT, CAMERA_HEIGHT); int waitInterval = 1000 / CAMERA_FPS; while (!isRunning) { // Create image from cropped area. Mat imageCaptureFull; cameraRecord.read(imageCaptureFull); if (imageCaptureFull.empty()) break; int winX = 0; int winY = 0; int winW = imageCaptureFull.cols; int winH = imageCaptureFull.rows; calculateCropROI(imageCaptureFull, winX, winY, winW, winH); Mat imageCrop = imageCaptureFull(cv::Rect(winX, winY, winW, winH)); if (isShowVideo) { imshow("camera", imageCrop); //show camera for verification waitKey(waitInterval); } //Create report data bool status = false; checkEyesBlinkStatus(imageCrop, status); if (status) { cout << "1" << endl; int pidId = fork(); if (pidId == 0) { try { execl("/usr/bin/curl", "curl", noderedApi, (char *) 0); } catch (Exception e) { } } } else { cout << currentDateTime() << "\t0" << endl; } this_thread::sleep_for(chrono::milliseconds(waitInterval)); } } catch (int e) { printf("read file error\n"); } }
/** * Function: Logger::currentDateTime() * Description: Function that creates a datetime and returns it. Used for logging purposes, hence why it's here */ void Logger::SetFiles() { std::string formattedDatetime = EngineTextHandling::ReplaceCharsInString(currentDateTime(), ':', '_'); genericlogfile = "../Logs/Log " + formattedDatetime + ".txt"; errorlogfile = "../Logs/Error/Log " + formattedDatetime + ".txt"; succeslogfile = "../Logs/Success/Log " + formattedDatetime + ".txt"; warninglogfile = "../Logs/Warning/Log " + formattedDatetime + ".txt"; }
/*------------------------------------------------------- Upstream MQTTSnConnect -------------------------------------------------------*/ void GatewayControlTask::handleSnConnect(Event* ev, ClientNode* clnode, MQTTSnMessage* msg){ printf(FORMAT2, currentDateTime(), "CONNECT", LEFTARROW, clnode->getNodeId()->c_str(), msgPrint(msg)); Topics* topics = clnode->getTopics(); MQTTSnConnect* sConnect = new MQTTSnConnect(); MQTTConnect* mqMsg = new MQTTConnect(); mqMsg->setProtocol(_protocol); sConnect->absorb(msg); mqMsg->setClientId(clnode->getNodeId()); mqMsg->setKeepAliveTime(sConnect->getDuration()); if(_loginId != "" && _password != ""){ mqMsg->setUserName(&_loginId); mqMsg->setPassword(&_password); } clnode->setConnectMessage(mqMsg); if(sConnect->isCleanSession()){ if(topics){ delete topics; } topics = new Topics(); clnode->setTopics(topics); mqMsg->setCleanSessionFlg(); } if(sConnect->isWillRequired()){ MQTTSnWillTopicReq* reqTopic = new MQTTSnWillTopicReq(); Event* evwr = new Event(); clnode->setClientSendMessage(reqTopic); evwr->setClientSendEvent(clnode); printf(FORMAT1, currentDateTime(), "WILLTOPICREQ", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(reqTopic)); _res->getClientSendQue()->post(evwr); // Send WILLTOPICREQ to Client }else{ Event* ev1 = new Event(); clnode->setBrokerSendMessage(clnode->getConnectMessage()); ev1->setBrokerSendEvent(clnode); _res->getBrokerSendQue()->post(ev1); } delete sConnect; }
inline LogMessage::LogMessage(const LoggerTypes& type, const std::string& file, const int& i) : m_stream(), m_type(type) { //build the logstring m_stream << "[" + LoggerTypeMap::get(type) + "][File:" + file + "][Line:" + std::to_string(i) + "][thread:" << std::this_thread::get_id() << "]" + currentDateTime() + " "; }
void Log::debug(const std::string msg) { #ifdef DEBUG std::cout << currentDateTime() << " [DEBUG]:\t" << msg << std::endl; #else (void) msg; #endif }
/** * @brief updates the time * Color and font settings can be configured in Qt CSS */ void LxQtClock::updateTime() { QDateTime now = currentDateTime(); if (now.time().msec() > 500) restartTimer(now); showTime(now); }
void login() { Packet login( 0x0F, 38 ); login << xen_account; login << (uint32)0; login << xen_pass; login[31] = xen_version; printf( "[%s] Sending login\n", currentDateTime().c_str() ); send_queue.push( login ); }
/*------------------------------------------------------- Downstream MQTTDisconnect -------------------------------------------------------*/ void GatewayControlTask::handleDisconnect(Event* ev, ClientNode* clnode, MQTTMessage* msg){ MQTTSnDisconnect* snMsg = new MQTTSnDisconnect(); //MQTTDisconnect* mqMsg = static_cast<MQTTDisconnect*>(msg); clnode->setClientSendMessage(snMsg); printf(FORMAT1, currentDateTime(), "DISCONNECT", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(snMsg)); Event* ev1 = new Event(); ev1->setClientSendEvent(clnode); _res->getClientSendQue()->post(ev1); }
void enterWorld( uint16 p_id ) { Packet enter_word( 0x10, 38 ); enter_word << p_id; enter_word << (uint32)0; enter_word << (uint16)0; enter_word << xen_pass; printf( "[%s] Sending enter world.\n", currentDateTime().c_str() ); send_queue.push( enter_word ); }
/*------------------------------------------------------- Downstream MQTTPubComp -------------------------------------------------------*/ void GatewayControlTask::handlePubComp(Event* ev, ClientNode* clnode, MQTTMessage* msg){ MQTTSnPubComp* snMsg = new MQTTSnPubComp(); MQTTPubComp* mqMsg = static_cast<MQTTPubComp*>(msg); snMsg->setMsgId(mqMsg->getMessageId()); printf(BLUE_FORMAT1, currentDateTime(), "PUBCOMP", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(snMsg)); clnode->setClientSendMessage(snMsg); Event* ev1 = new Event(); ev1->setClientSendEvent(clnode); _res->getClientSendQue()->post(ev1); }
void XmlTestReporter::BeginResults(std::ostream& os, int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed) { os << "<unittest-results" << " date_time = \""<< currentDateTime() << "\"" << " tests=\"" << totalTestCount << "\"" << " failedtests=\"" << failedTestCount << "\"" << " failures=\"" << failureCount << "\"" << " time=\"" << secondsElapsed << "\"" << ">\n"; }
void Log::write(string str, bool repeatMessage) { if (repeatMessage || mLastMessage != str) { mLastMessage = str; std::ofstream outfile; outfile.open(mFilename, std::ios_base::app); outfile << currentDateTime() << ": " << str << endl; } }
/*------------------------------------------------------- Downstream MQTTPingResp -------------------------------------------------------*/ void GatewayControlTask::handlePingresp(Event* ev, ClientNode* clnode, MQTTMessage* msg){ MQTTSnPingResp* snMsg = new MQTTSnPingResp(); //MQTTPingResp* mqMsg = static_cast<MQTTPingResp*>(msg); printf(FORMAT1, currentDateTime(), "PINGRESP", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(snMsg)); clnode->setClientSendMessage(snMsg); Event* ev1 = new Event(); ev1->setClientSendEvent(clnode); _res->getClientSendQue()->post(ev1); }