コード例 #1
0
// Adds the game to SteelSeries Engine 3 GameSense.
int AddToSSGS() {

	//////////////// -GameDataJson- ////////////////

	// Data.
	const char* GameDataJson = "{\"game\":\"FALLOUT4\",\"event\":\"HEALTH\",\"data\":{\"value\":0}}";
	const char* GameData2Json = "{\"game\":\"FALLOUT4\",\"event\":\"STAMINA\",\"data\":{\"value\":0}}";
	const char* GameData3Json = "{\"game\":\"FALLOUT4\",\"event\":\"RADS\",\"data\":{\"value\":0}}";
	const char* GameData4Json = "{\"game\":\"FALLOUT4\",\"event\":\"WEIGHT\",\"data\":{\"value\":0}}";

	// Parsed JSON.
	Document GameJsonParsed;
	// Processed JSON ready be posted.
	StringBuffer Buffer;

	//// -HEALTH- ////

	// Parse.
	GameJsonParsed.Parse(GameDataJson);
	// Insert default value.
	Value& STR = GameJsonParsed["data"]["value"];
	STR.SetInt(100); // 100 Health default.
					 // Format into buffer.
	Writer<StringBuffer>writer(Buffer);
	GameJsonParsed.Accept(writer);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_GameEvent);
	// Cleanup.
	Buffer.Clear();

	//// -STAMINA- ////

	// Parse.
	GameJsonParsed.Parse(GameData2Json);
	// Insert default value.
	Value& STR2 = GameJsonParsed["data"]["value"];
	STR2.SetInt(100); // 100 Stamina default.
					  // Format into buffer.
	Writer<StringBuffer>writer2(Buffer);
	GameJsonParsed.Accept(writer2);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_GameEvent);
	// Cleanup.
	Buffer.Clear();

	//// -RADS- ////

	// Parse.
	GameJsonParsed.Parse(GameData3Json);
	// Insert default value.
	Value& STR3 = GameJsonParsed["data"]["value"];
	STR3.SetInt(0); // 0 RADS default.
					// Format into buffer.
	Writer<StringBuffer>writer3(Buffer);
	GameJsonParsed.Accept(writer3);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_GameEvent);
	// Cleanup.
	Buffer.Clear();

	//// -WEIGHT- ////

	// Parse.
	GameJsonParsed.Parse(GameData4Json);
	// Insert default value.
	Value& STR4 = GameJsonParsed["data"]["value"];
	STR4.SetInt(100); // 100 WEIGHT default.
					  // Format into buffer.
	Writer<StringBuffer>writer4(Buffer);
	GameJsonParsed.Accept(writer4);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_GameEvent);
	// Cleanup.
	Buffer.Clear();

	//////////////// -GameInterfaceJson- ////////////////

	// Data.
	const char* GameInterfaceJson = "{\"game\":\"FALLOUT4\",\"game_display_name\":\"Fallout 4\",\"icon_color_id\":5}";

	//// -Interface- ////

	// Parse.
	GameJsonParsed.Parse(GameInterfaceJson);
	// Insert default value.
	Writer<StringBuffer>writer5(Buffer);
	GameJsonParsed.Accept(writer5);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_GameMetadata);
	// Cleanup.
	Buffer.Clear();

	//////////////// -GameInterfaceEventsJson- ////////////////

	// Data.
	const char* GameInterfaceEventsJson = "{\"game\":\"FALLOUT4\",\"event\":\"HEALTH\",\"min_value\":0,\"max_value\":100,\"icon_id\":1}";
	const char* GameInterfaceEvents2Json = "{\"game\":\"FALLOUT4\",\"event\":\"STAMINA\",\"min_value\":0,\"max_value\":100,\"icon_id\":11}";
	const char* GameInterfaceEvents3Json = "{\"game\":\"FALLOUT4\",\"event\":\"RADS\",\"min_value\":0,\"max_value\":100,\"icon_id\":6}";
	const char* GameInterfaceEvents4Json = "{\"game\":\"FALLOUT4\",\"event\":\"WEIGHT\",\"min_value\":0,\"max_value\":100,\"icon_id\":17}";

	//// -HEALTH- ////

	// Parse.
	GameJsonParsed.Parse(GameInterfaceEventsJson);
	// Insert default value.
	Writer<StringBuffer>writer6(Buffer);
	GameJsonParsed.Accept(writer6);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_RegisterGameEvent);
	// Cleanup.
	Buffer.Clear();

	//// -STAMINA- ////

	// Parse.
	GameJsonParsed.Parse(GameInterfaceEvents2Json);
	// Insert default value.
	Writer<StringBuffer>writer7(Buffer);
	GameJsonParsed.Accept(writer7);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_RegisterGameEvent);
	// Cleanup.
	Buffer.Clear();

	//// -RADS- ////

	// Parse.
	GameJsonParsed.Parse(GameInterfaceEvents3Json);
	// Insert default value.
	Writer<StringBuffer>writer8(Buffer);
	GameJsonParsed.Accept(writer8);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_RegisterGameEvent);
	// Cleanup.
	Buffer.Clear();

	//// -WEIGHT- ////

	// Parse.
	GameJsonParsed.Parse(GameInterfaceEvents4Json);
	// Insert default value.
	Writer<StringBuffer>writer9(Buffer);
	GameJsonParsed.Accept(writer9);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_RegisterGameEvent);
	// Cleanup.
	Buffer.Clear();

	// Setup INI.
	PWSTR INIPathPTR = 0;
	TCHAR INIPath[MAX_PATH];

	// Get paths.
	SHGetKnownFolderPath(FOLDERID_Documents, NULL, NULL, &INIPathPTR);
	_tcscpy_s(INIPath, MAX_PATH, INIPathPTR);
	_tcscat_s(INIPath, MAX_PATH, L"\\My Games\\Fallout4\\SSGSPlugin_Fallout4.ini");
	// Create fresh copy.
	HANDLE hFile = CreateFile(INIPath, GENERIC_ALL, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
	CloseHandle(hFile);
	// Write default settings.
	WritePrivateProfileString(L"General", L"bEnabled", L"1", INIPath);
	WritePrivateProfileString(L"General", L"iUpdateInterval", L"250", INIPath);
	WritePrivateProfileString(L"General", L"bConsoleLoggingEnabled", L"0", INIPath);

	return 0;
}
コード例 #2
0
ファイル: assignment7.cpp プロジェクト: felipegb94/simEngine
int main(int argc, char** argv){
	arma::wall_clock timer; //Keeps track of how much time my program is taking to run.

	timer.tic();

	cout << "In this program I'm assuming that the given json model.adm file will follow a certain format, where keys will have an expected name." <<endl;
	//cout << "If no information is displaying after this line that means that you didn't input the two integer arguments for bodyID and constraintID." <<endl;
	//double constraintID = double(atof(argv[1]));

	cout << "Start of Assignment" <<endl;


	MyJsonDocument d = parseJSON("models/simplePend.acf");

	string simulation = string(d["simulation"].GetString());
	double tend = d["tend"].GetDouble();
	double stepSize = d["stepSize"].GetDouble();
	double outputSteps = d["outputSteps"].GetDouble();


	cout << "Simulation = "  + simulation <<endl;
	cout << "tend = ";
	cout << tend << endl;
	cout << "stepSize = ";
	cout << stepSize << endl;
	cout << "outputSteps = ";
	cout << outputSteps << endl;


	//static const char* kTypeNames[] = { "Null", "False", "True", "Object", "Array", "String", "Number" };

	MyJsonDocument d4 = parseJSON("models/simplePend.adm");
	cout << "parsing is fine" << endl;
	Model m(d4, simulation, tend,outputSteps,stepSize);


/**
	vector<c_constraint*> constraints = m.getConstraints();
	for(std::vector<int>::size_type i = 0; i != constraints.size(); i++) {

			constraints[i]->print();

	}*/

	m.solveK();

	std::vector<arma::vec> q = m.getQList();
	std::vector<arma::vec> qd = m.getQdList();
	std::vector<arma::vec> qdd = m.getQddList();

	double xAccPlot[2][(int)m.getOutputSteps()];
	double trajectoryPlot[2][(int)m.getOutputSteps()];

	Document doc;
	doc.SetObject();
	rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();

	Value plot1(kArrayType);
	Value plot1X(kArrayType);
    Value plot1Y(kArrayType);
	Value plot2(kArrayType);
	Value plot2X(kArrayType);
    Value plot2Y(kArrayType);

	for(int i = 0; i <= m.getOutputSteps(); i++){
		xAccPlot[0][i] = m.getStepSize()*i;
		xAccPlot[1][i] = qdd.at(i)(0);

		plot1X.PushBack(xAccPlot[0][i],allocator);
		plot1Y.PushBack(xAccPlot[1][i],allocator);


		trajectoryPlot[0][i] = q.at(i)(0);
		trajectoryPlot[1][i] = q.at(i)(1);
		plot2X.PushBack(trajectoryPlot[0][i],allocator);
		plot2Y.PushBack(trajectoryPlot[1][i],allocator);

	}
	plot1.PushBack(plot1X,allocator);
	plot1.PushBack(plot1Y,allocator);
	plot2.PushBack(plot2X,allocator);
	plot2.PushBack(plot2Y,allocator);

	doc.AddMember("Plot1",plot1,allocator);
	doc.AddMember("Plot2",plot2,allocator);

	StringBuffer strbuf;
	Writer<StringBuffer> writer(strbuf);
	doc.Accept(writer);

    std::string plotsData = strbuf.GetString();


	ofstream dataFile ("plots/data.json");
	if (dataFile.is_open()){
	    dataFile << plotsData;
	    dataFile.close();
	}
	else cout << "Unable to open file";

	system( "python ../../repos/simEngine/python/plot2D.py" );


	cout << "took " << timer.toc() << " seconds for part 2" << endl;



  return 0;
}
コード例 #3
0
ファイル: profile_ctx.cpp プロジェクト: kku1993/ispc
std::string ProfileRegion::outputJSON() {
  const char *base = 
    "{"
      "\"region_id\":0,"
      "\"region_type\":0,"
      "\"file_name\":\"\","
      "\"start_line\":0,"
      "\"end_line\":0,"
      "\"initial_mask\":0,"
      "\"lane_usage\":[],"
      "\"full_mask_percentage\": [],"
      "\"ipc\":0,"
      "\"l2_hit\":0,"
      "\"l3_hit\":0,"
      "\"bytes_read\":0"
    "}";

  Document d;
  d.Parse(base);

  d["region_id"].SetUint64(this->id);
  d["region_type"].SetInt(this->region_type);
  d["file_name"].SetString(StringRef(this->file_name));
  d["start_line"].SetInt(this->start_line);
  d["end_line"].SetInt(this->end_line);
  d["initial_mask"].SetUint64(this->initial_mask);
  d["ipc"].SetDouble(this->avg_ipc);
  d["l2_hit"].SetDouble(this->avg_l2_hit);
  d["l3_hit"].SetDouble(this->avg_l3_hit);
  d["bytes_read"].SetDouble(this->avg_bytes_read);

  // Add list of lane usage by line number.
  Value &lane_usage = d["lane_usage"];
  Document::AllocatorType &allocator = d.GetAllocator();
  for (LaneUsageMap::iterator it = this->laneUsageMap.begin(); 
      it != this->laneUsageMap.end(); ++it) {
    Value line(kObjectType);

    double percent = it->second.second/double(it->second.first) * 100;

    line.AddMember("line", it->first, allocator);
    line.AddMember("percent", percent, allocator);

    lane_usage.PushBack(line, allocator); 
  }

  // Add list of percent of full mask runs by line number.
  Value &full_mask = d["full_mask_percentage"];
  for (LaneUsageMap::iterator it = this->fullMaskMap.begin(); 
      it != this->fullMaskMap.end(); ++it) {
    Value line(kObjectType);

    double percent = it->second.second/double(it->second.first) * 100;

    line.AddMember("line", it->first, allocator);
    line.AddMember("percent", percent, allocator);

    full_mask.PushBack(line, allocator); 
  }
  
  // Stringify the DOM
  StringBuffer buffer;
  Writer<StringBuffer> writer(buffer);
  d.Accept(writer);

  std::string str(buffer.GetString());
  return str;
}
コード例 #4
0
ファイル: NodeWifiHandler.cpp プロジェクト: snmbzkrt/rfkon
int NodeWifiHandler (int argc, char *argv[])
{

  // DDS değişkenleri
  ReturnCode_t                        status;
  InstanceHandle_t                    userHandle;
  DDSEntityManager                    mgrReqSub;
  DDSEntityManager                    mgrReqPub;
  DDSEntityManager                    mgrWifiPub;
  WifiSeq                             *wifiSeqInstance = new WifiSeq();;
  ServerReqSeq                        serverReqSeq;
  ServerReq                           *serverReq = new ServerReq();
  SampleInfoSeq_var                   infoSeq = new SampleInfoSeq();

  // Zaman ile alakalı değişkenler
  DDS::Duration_t                     waitAckTime = { 0, 800000000 }; //800ms
  int                                 refreshRate = 60;
  long int                            messageIDCount = 0;
  Time_t                              tsBeforeTheScan = { 0, 0 };
  Time_t                              tsAfterTheScan = { 0, 0 };
  struct timeval                      tsConverter;

  // Veri tutucular (data structures)
  vector<string>                      modemIdHolder;
  vector<int>                         dbmHolder;
  string                              wifiFileContenHolder;
  string                              ifconfigFileContentHolder;


  // Wifi tarama sonuçlarının yazdırıldığı dosyadan okuma yapacak
  // olan değişken
  boost::filesystem::ifstream         fInWifiScan, fInIfconfig;

  // Matlab komutları ayrıştırılmasında kullanılacak olan değişkenler
  string                              ip, subnet, gateway, dns, nodeName;

  char                                hostName[1024];
  gethostname(hostName, 1024);

  // Bluetooth tarama sıklığı ayarlayan değişken
  int refreshRateCounter = -1;


  // !!! Wifi tarama mesajlarını Publish edecek Topic yaratılıyor
  // ve o Topic'e ait konfigürasyon ayarları yapılıyor

  // Domain participant yaratılıyor
  mgrWifiPub.createParticipant("KonSensData_WifiSeq_Participant");

  // WifiSeq tipi yaratılıyor
  WifiSeqTypeSupport_var wifiSeqTS = new WifiSeqTypeSupport();
  mgrWifiPub.registerType(wifiSeqTS.in());

  // Topic yaratılıyor
  char wifiPubTopicName[] = "KonSensData_WifiSeq_Topic";
  mgrWifiPub.createTopic(wifiPubTopicName);

  // Publisher yaratılıyor
  mgrWifiPub.createPublisher();

  // DataWriter yaratılıyor
  bool autodisposeUnregisteredInstances = false;
  mgrWifiPub.createWriter(autodisposeUnregisteredInstances,
                          KEEP_ALL_HISTORY_QOS,
                          BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS);

  // Yaratılan DataWriter, WifiSeq tipi için özelleştiriliyor
  DataWriter_var dWriterWifPub = mgrWifiPub.getWriter();
  WifiSeqDataWriter_var wifiSeqWriter =
      WifiSeqDataWriter::_narrow(dWriterWifPub.in());

  // Düğüm numarası atanıyor
  wifiSeqInstance->userID = 13;

  cout << "=== [Publisher of KonSensData_WifiSeq_Topic] Ready ..." << endl;


  // !!! Sunucudan gelen komutlara Subscribe olacak olan Topic yaratılıyor
  // ve o Topic için gerekli konfigürasyon ayarları yapılıyor

  // Domain participant yaratılıyor
  mgrReqSub.createParticipant(
        "KonSensData_ServerReq_Participant_Server_to_Node");

  // ServerReq tipi yaratılıyor.
  ServerReqTypeSupport_var mgrSubscriberTS = new ServerReqTypeSupport();
  mgrReqSub.registerType(mgrSubscriberTS.in());

  // Topic yaratılıyor
  char reqSubTopicName[] = "KonSensData_ServerReq_Topic_Server_to_Node";
  mgrReqSub.createTopic(reqSubTopicName, RELIABLE_RELIABILITY_QOS,
                        VOLATILE_DURABILITY_QOS);

  // Subscriber yaratılıyor
  mgrReqSub.createSubscriber();

  // DataReader yaratılıyor
  mgrReqSub.createReader(KEEP_LAST_HISTORY_QOS, 1);

  // Yaratılan DataReader, ServerReq tipi için özelleştiriliyor.
  DataReader_var dReadeSub = mgrReqSub.getReader();
  ServerReqDataReader_var serverReqReader =
      ServerReqDataReader::_narrow(dReadeSub.in());
  checkHandle(serverReqReader.in(), "ServerReqDataReader::_narrow");

  cout << "=== [Subscriber of KonSensData_ServerReq_Topic_Server_to_Node]"
          " Ready ..." << endl;


  // !!! Sunucudan gelen komutlar ayrıştırılıp işlendikten sonra Response
  // mesajını Publish edecek olan Topic yaratılıyor

  // Domain participant yaratılıyor
  mgrReqPub.createParticipant(
        "KonSensData_ServerReq_Participant_Node_to_Server");

  // ServerReq tipi yaratılıyor.
  ServerReqTypeSupport_var mgrPublisherTS = new ServerReqTypeSupport();
  mgrReqPub.registerType(mgrPublisherTS.in());

  // Topic yaratılıyor
  char reqPubTopicName[] = "KonSensData_ServerReq_Topic_Node_to_Server";
  mgrReqPub.createTopic(reqPubTopicName, RELIABLE_RELIABILITY_QOS,
                        VOLATILE_DURABILITY_QOS);

  // Publisher yaratılıyor
  mgrReqPub.createPublisher();

  // DataWriter yaratılıyor
  // Not: Kullanılan autodisposeUnregisteredInstances değişkeni
  // WifiSeqDataWriter yaratılırken ki kullananla aynıdır
  mgrReqPub.createWriter(autodisposeUnregisteredInstances,
                         KEEP_LAST_HISTORY_QOS, 1);

  // Yaratılan DataReader, ServerReq tipi için özelleştiriliyor.
  DataWriter_var dWriterPub = mgrReqPub.getWriter();
  ServerReqDataWriter_var serverReqWriter =
      ServerReqDataWriter::_narrow(dWriterPub.in());

  cout << "=== [Publisher of KonSensData_ServerReq_Topic_Node_to_Server] "
          "Ready ..." << endl;

  // Yenileme sıklığını belirleyecek olan 'timelimit' değişkeni yaratılıyor.
  Timeout timeLimit(std::chrono::milliseconds(refreshRate*1000));

  while(true)
  {
    if (timeLimit.isExpired() || refreshRateCounter == -1)
    {

      // Wifi mesajını Publish etmek için hazırlık yapılıyor.
      cout << "-----------------------------------" << endl;

      wifiSeqInstance->messageID = messageIDCount;

      // Tarama öncesi alınan zaman etiketi (timestamp[0])
      gettimeofday(&tsConverter, NULL);
      tsBeforeTheScan.sec = tsConverter.tv_sec;
      tsBeforeTheScan.nanosec = (tsConverter.tv_usec * 1000);
      cout << " timestamp[0] (before the scan) = " << tsBeforeTheScan.sec
           << '.';
      cout << setfill('0') << setw(9) << (tsBeforeTheScan.nanosec)
           << endl;

      // Wifi taraması yapılıyor ve ardından tarama sonuçları 'wifi_rssi'
      // dosyasına yazdırılıyor.
      system("sudo iwlist wlan0 scanning >> wifi_rssi.txt");

      // Wifi bağlantısı kapatılıyor
      system("sudo ifconfig wlan0 down");

      // Wifi tarama dosyası okunuyor
      fInWifiScan.open("wifi_rssi.txt",ios::in);

      stringstream ssWifi;
      ssWifi << fInWifiScan.rdbuf();
      wifiFileContenHolder = ssWifi.str();
      system("rm wifi_rssi.txt");
      try
      {
        // Okunan dosya boost kütüphane yardımıyla ayrıştırılıyor
        boost::regex exp( "Signal level=.*?([0-9]+)") ;
        boost::regex expAd( "Address: ([0-9A-F:]{17})" ) ;
        boost::match_results<string::const_iterator> whatAd;
        string::const_iterator startAd =
            wifiFileContenHolder.begin() ;
        string::const_iterator finishAd =
            wifiFileContenHolder.end() ;

        while (boost::regex_search(startAd, finishAd,
                                   whatAd, expAd))
        {
          modemIdHolder.push_back(whatAd[1]);
          startAd = whatAd[0].second ;
        }

        boost::match_results<string::const_iterator> what;

        string::const_iterator start = wifiFileContenHolder.begin();
        string::const_iterator finish = wifiFileContenHolder.end();

        while (boost::regex_search(start, finish, what, exp))
        {
          string foundDbm(what[1]);
          dbmHolder.push_back(atoi(foundDbm.c_str()));
          start = what[0].second ;
        }

        cout << " Number of Wifi Network that has been founded: "
             << dbmHolder.size() << endl;

        // Tarama sonrası alınan zaman etiketi (timestamp[1])
        gettimeofday(&tsConverter, NULL);
        tsAfterTheScan.sec = tsConverter.tv_sec;
        tsAfterTheScan.nanosec = (tsConverter.tv_usec * 1000);
        cout << " timestamp[1] (after the scan) = "
             << tsAfterTheScan.sec << '.';
        cout << setfill('0') << setw(9) << (tsAfterTheScan.nanosec)
             << endl;

        // Ayrıştırılan Wifi tarama dosyası ve alınan zaman etiketleri,
        // Publish edilecek olan mesaj değişkenlerine kaydediliyor
        wifiSeqInstance->timestamp[0][0] = tsBeforeTheScan.nanosec;
        wifiSeqInstance->timestamp[0][1] = tsBeforeTheScan.sec;
        wifiSeqInstance->timestamp[1][0] = tsAfterTheScan.nanosec;
        wifiSeqInstance->timestamp[1][1] = tsAfterTheScan.sec;

        wifiSeqInstance->messages.length(modemIdHolder.size());
        cout << " MessageID: " << wifiSeqInstance->messageID << endl;
        for(int i = 0; i < modemIdHolder.size(); i++)
        {
          Msg msg;
          msg.devID = DDS::string_dup(modemIdHolder[i].c_str());
          msg.hostName = DDS::string_dup(hostName);
          msg.dbm = -dbmHolder[i];
          wifiSeqInstance->messages[i] = msg;

        }

        // Publish edilmeden önce, bir önceki mesajın acknowlegde mesajı
        // bekleniyor
        wifiSeqWriter->wait_for_acknowledgments(waitAckTime);
        status = wifiSeqWriter->write(*wifiSeqInstance,DDS::HANDLE_NIL);

        checkStatus(status, "konsensSensDugWifiSeqTopic::"
                            "WifiSeqDataWriter::write_w_timestamp");

        // Wifi bağlantısı tekrar açılıyor
        system("sudo ifconfig wlan0 up");

        messageIDCount++;
      }

      catch ( boost::bad_expression & ex )
      {
        cout << ex.what() ;
      }

      modemIdHolder.clear();
      dbmHolder.clear();
      wifiFileContenHolder.clear();
      fInWifiScan.close();

      cout << "-----------------------------------" << endl;

      timeLimit.setTimerToZero();

      // Tarama sıklığını belirleyen değişken sıfırlanıyor
      refreshRateCounter = 0;
      cout << refreshRateCounter << endl;

    } // Wifi Publisher kısmının sonu


    // Sunucu tarafından gönderilen Matlab komutlarına Subscribe olunuyor
    else
    {
      status = serverReqReader->take(serverReqSeq,
                                     infoSeq,
                                     LENGTH_UNLIMITED,
                                     ANY_SAMPLE_STATE,
                                     ANY_VIEW_STATE,
                                     ANY_INSTANCE_STATE);
      checkStatus(status, "severReqDataReader::take");

      // isDataReceived değişkeni bir kontrol değişkeni olup, Matlab komut
      // bilgisini içeren mesaja Subscribe olunduysa true, olunmadıysa false
      // değerini tutar
      bool isDataReceived = false;

      for (DDS::ULong j = 0; j < serverReqSeq.length(); j++)
      {

        if(infoSeq[j].valid_data)
        {
          cout << "=== [Subscriber] message received :" << endl;
          cout << "    Received Request Message  : "
               << serverReqSeq[j].request << endl;
          cout << "    Received RequestID : \""
               << serverReqSeq[j].requestID << "\"" << endl;

          // Rapidjson yapılandırıcısı yaratılıyor
          Document d;
          if(d.Parse(serverReqSeq[j].request).HasParseError())
            cout << " Parsing Error!" << endl;
          StringBuffer nodeIdBuffer;
          Writer<StringBuffer> nodeIdWriter(nodeIdBuffer);
          d["NodeID"].Accept(nodeIdWriter);
          string tempNodeId = nodeIdBuffer.GetString();

          // Subscribe olunan mesajın düğüme ait olup olmadığı kontrol ediliyor
          if (tempNodeId == "\"SensDug13\"")
          {
            StringBuffer buffer;

            // Reset komutunun gelip gelmediği kontrol ediliyor.
            Value::ConstMemberIterator itr = d.FindMember("Reset");
            if(itr != d.MemberEnd())
            {
              // Resetin değeri falsedan trueya çevriliyor
              Value& s = d["Reset"];
              s.SetBool(true);

              // Document formatındaki JSON mesajı StrinBuffer'a dönüştürülüyor
              Writer<StringBuffer> writer(buffer);
              d.Accept(writer);

              cout << "    Request Message is modified to  : "
                   << buffer.GetString() << endl;

              // Publish edilecek Response mesajı hazırlanıyor
              string str = buffer.GetString();
              str.append("\n");
              serverReq->request = DDS::string_dup(str.c_str());
              serverReq->requestID = serverReqSeq[j].requestID;

              if(!isDataReceived && status == DDS::RETCODE_OK)
              {
                // Response mesajı gönderiliyor
                ReturnCode_t tempStatus = serverReqWriter->write(
                      *serverReq, DDS::HANDLE_NIL);
                checkStatus(tempStatus, "severReqDataReader::write");
                isDataReceived = true;

                cout << "    Response Request Message is sent : "
                     << serverReq->request << endl;
                cout << "    Response RequestID is sent : \""
                     << serverReq->requestID << "\"" << endl;

              }

              // Sistem yeniden başlatılıyor !!!
              cout << "reboot" << endl;
              system("sudo reboot");
            }

            // GetRefreshRate ve SetRefreshRate komutundan herhangi birinin
            // gelip gelmediği kontrol ediliyor
            itr = d.FindMember("SetRefreshRate");
            if(itr != d.MemberEnd())
            {
              string refreshRateString;
              int refreshRateInt;

              // Status değeri falsedan trueya çevriliyor
              Value& s = d["Status"];
              s.SetBool(true);

              // Document formatındaki JSON mesajı StrinBuffer'a dönüştürülüyor
              Writer<StringBuffer> writer(buffer);
              d["SetRefreshRate"].Accept(writer);
              refreshRateString = buffer.GetString();

              // Gelen mesajda fazladan çift tırnak ile bulunuyor
              // Örneğin, ""15""
              // Bu yüzden ilk son karakterler kırpılıyor
              refreshRateString =
                  refreshRateString.substr(1, refreshRateString.size()-1);
              // Refresh rate değeri stringden integera çevriliyor
              refreshRateInt = atoi(refreshRateString.c_str());

              // Refresh rate değişkeni güncelleniyor
              refreshRate = refreshRateInt;
              timeLimit.setMaxDuration(std::chrono::milliseconds
                                       (refreshRate*1000));

            }

            itr = d.FindMember("GetRefreshRate");
            if(itr != d.MemberEnd())
            {
              // Status değeri falsedan trueya çevriliyor
              Value& s = d["Status"];
              s.SetBool(true);

              Value& tempRefreshRate = d["GetRefreshRate"];

              // Güncel refresh rate değişken bilgisi alınıyor
              string str = to_string(refreshRate);
              tempRefreshRate.SetString(str.c_str(), str.length());
            }

            // GetAliveStatus komutunun gönderilip gönderilmediği kontrol
            // ediliyor.
            itr = d.FindMember("Alive");
            if(itr != d.MemberEnd())
            {
              // Alive değeri truedan false çevriliyor
              Value& s = d["Alive"];
              s.SetBool(true);

              // Document formatındaki JSON mesajı StrinBuffer'a dönüştürülüyor
              Writer<StringBuffer> writer(buffer);
              d.Accept(writer);
            }

            // GetNetStatus komutunun gelip gelmediği kontrol ediliyor
            itr = d.FindMember("IP");
            if(itr != d.MemberEnd())
            {
              cout << "-----------------------------------" << endl;

              // Ağ durum bilgisi ifconfig.txt dosyasına yazdırılıyor
              system("cat /etc/network/interfaces >> ifconfig.txt");
              system("cat /etc/resolv.conf >> ifconfig.txt");
              system("echo -n hostname >> ifconfig.txt && hostname "
                     ">> ifconfig.txt");

              // ifconfig.txt dosyası açılıyor
              fInIfconfig.open("ifconfig.txt",ios::in);
              stringstream ssIfconfig;
              ssIfconfig << fInIfconfig.rdbuf();
              ifconfigFileContentHolder = ssIfconfig.str();
              system("rm ifconfig.txt");

              // Dosya içeriği ayrıştırılıyor
              try
              {
                boost::regex expIp
                    ("address (\\d{1,3}(\\.\\d{1,3}){3})");
                boost::regex expSubnet
                    ("netmask (\\d{1,3}(\\.\\d{1,3}){3})");
                boost::regex expGateway
                    ("gateway (\\d{1,3}(\\.\\d{1,3}){3})");
                boost::regex expDns
                    ("nameserver (\\d{1,3}(\\.\\d{1,3}){3})");
                boost::regex expNoneName
                    ("hostname.*");

                string::const_iterator startAd =
                    ifconfigFileContentHolder.begin() ;
                string::const_iterator finishAd =
                    ifconfigFileContentHolder.end() ;

                boost::match_results<string::const_iterator> whatIp;
                if ( boost::regex_search(startAd, finishAd,
                                         whatIp, expIp) )
                {
                  ip = whatIp[0];
                  cout << ip << endl;
                  string chopped_str = "address ";
                  string::size_type i = ip.find(chopped_str);
                  if (i != string::npos)
                    ip.erase(i, chopped_str.length());

                  Value& tempIp = d["IP"];
                  tempIp.SetString(ip.c_str(), ip.length());
                }

                startAd = ifconfigFileContentHolder.begin() ;
                finishAd = ifconfigFileContentHolder.end() ;

                boost::match_results<string::const_iterator> whatSubnet;
                if ( boost::regex_search(startAd, finishAd,
                                         whatSubnet, expSubnet) )
                {
                  subnet = whatSubnet[0];
                  cout << subnet << endl;
                  string chopped_str = "netmask ";
                  string::size_type i = subnet.find(chopped_str);
                  if (i != string::npos)
                    subnet.erase(i, chopped_str.length());

                  Value& tempSubnet = d["Subnet"];
                  tempSubnet.SetString(subnet.c_str(),
                                       subnet.length());

                }

                startAd = ifconfigFileContentHolder.begin() ;
                finishAd = ifconfigFileContentHolder.end() ;
                boost::match_results<string::const_iterator> whatGateway;

                if ( boost::regex_search(startAd, finishAd,
                                         whatGateway, expGateway) )
                {
                  gateway = whatGateway[0];
                  cout << gateway << endl;
                  string chopped_str = "gateway ";
                  string::size_type i = gateway.find(chopped_str);
                  if (i != string::npos)
                    gateway.erase(i, chopped_str.length());

                  Value& tempGateway = d["Gateway"];
                  tempGateway.SetString(gateway.c_str(),
                                        gateway.length());


                }

                startAd = ifconfigFileContentHolder.begin() ;
                finishAd = ifconfigFileContentHolder.end() ;
                boost::match_results<string::const_iterator> whatDns;

                if ( boost::regex_search(startAd, finishAd,
                                         whatDns, expDns) )
                {
                  dns = whatDns[0];
                  cout << dns << endl;
                  string chopped_str = "nameserver ";
                  string::size_type i = dns.find(chopped_str);
                  if (i != string::npos)
                    dns.erase(i, chopped_str.length());

                  Value& tempDns = d["DNS"];
                  tempDns.SetString(dns.c_str(), dns.length());
                }

                startAd = ifconfigFileContentHolder.begin() ;
                finishAd = ifconfigFileContentHolder.end() ;
                boost::match_results<string::const_iterator> whatNodeName;

                if ( boost::regex_search(startAd, finishAd,
                                         whatNodeName, expNoneName) )
                {
                  nodeName = whatNodeName[0];
                  cout << nodeName << endl;
                  string chopped_str = "hostname";
                  string::size_type i = nodeName.find(chopped_str);
                  if (i != string::npos)
                    nodeName.erase(i, chopped_str.length());
                  nodeName.erase(remove(nodeName.begin(),
                                        nodeName.end(),
                                        '\n'),
                                 nodeName.end());

                  Value& tempNodeName = d["Name"];
                  tempNodeName.SetString(nodeName.c_str(),
                                         nodeName.length());
                }

                cout << ip << endl;
                cout << subnet << endl;
                cout << dns << endl;
                cout << nodeName << endl;
              } // Dosya ayrıştırma işlemi bitti

              catch ( boost::bad_expression & ex )
              {
                cout << ex.what() ;
              }

              ifconfigFileContentHolder.clear();
              fInIfconfig.close();

              cout << "-----------------------------------" << endl;

              // GetNetStatus komutuna ait status değeri falsedan trueya
              // çevriliyor.
              Value& s = d["Status"];
              s.SetBool(true);
            }

            // Matlab'dan gelen mesaj içeriğinin ayrıştırılıp düzenlenme işlemi
            // tamamlandı ve sunucuya Response mesajını Publish etmek için
            // aşağıdaki adımlar gerçekleştiriliyor

            // Document formatındaki JSON mesajı StrinBuffer'a dönüştürülüyor
            StringBuffer responseBuffer;
            Writer<StringBuffer> writer(responseBuffer);
            d.Accept(writer);

            cout << "    Request Message is modified to  : "
                 << responseBuffer.GetString() << endl;

            // Response mesajı hazırlanıyor
            string str = responseBuffer.GetString();
            str.append("\n");
            serverReq->request = DDS::string_dup(str.c_str());
            //serverReq->request = DDS::string_dup("Hello World\n");
            serverReq->requestID = serverReqSeq[j].requestID;

            if(!isDataReceived && status == DDS::RETCODE_OK)
            {
              // Response mesajı Publish ediliyor
              ReturnCode_t tempStatus = serverReqWriter->write(
                    *serverReq, DDS::HANDLE_NIL);
              checkStatus(tempStatus, "severReqDataReader::write");
              isDataReceived = true;

              cout << "    Response Request Message is sent : "
                   << serverReq->request << endl;
              cout << "    Response RequestID is sent : \""
                   << serverReq->requestID << "\"" << endl;
            }
          }

          else
            cout << "Invalid NodeID!" << endl;
        }

      }

      status = serverReqReader->return_loan(serverReqSeq, infoSeq);
      checkStatus(status, "MsgDataReader::return_loan");

      refreshRateCounter++;
      cout << refreshRateCounter << endl;

    } // Matlab komutuna Subscribe olma kısmının sonu

    // Terminalde akacak olan çıktıları dah gözle görülebilir bir şekilde
    // yazdırmak için koyulmuştur
    fake_delay();
  }

  // Hafıza temizle işlemleri gerçekleştiriliyor

  status = wifiSeqWriter->dispose(*wifiSeqInstance, userHandle);
  checkStatus(status, "WifiSeqDataWriter::dispose");
  status = wifiSeqWriter->unregister_instance(*wifiSeqInstance, userHandle);
  checkStatus(status, "WifiSeqDataWriter::unregister_instance");

  delete wifiSeqInstance;
  delete serverReq;

  mgrWifiPub.deleteWriter();
  mgrWifiPub.deletePublisher();
  mgrWifiPub.deleteTopic();
  mgrWifiPub.deleteParticipant();

  mgrReqSub.deleteReader();
  mgrReqSub.deleteSubscriber();
  mgrReqSub.deleteTopic();
  mgrReqSub.deleteParticipant();

  mgrReqPub.deletePublisher();
  mgrReqPub.deleteWriter();
  mgrReqPub.deleteTopic();
  mgrReqPub.deleteParticipant();

  return 0;
}