コード例 #1
0
ファイル: continuo_burst.c プロジェクト: ascjunior/UdpTester
void print_result (settings *conf_settings, received_probe *probe , resume *result) {
	double bandwidth = 0.0, diff = 0.0;
	char buffer[256];
	char *log_file = probe->log_file;

	if (!probe)
		return;

	diff = difftimeval2db(&(probe->start), &(probe->end));
	if ((probe->received_total > 0) &&
		(probe->received_packets > 0) && (diff > 0.0)) {
		
		bandwidth = (double)(probe->received_total*8)/diff;

		result->packet_size = probe->received_total/probe->received_packets;
		result->packet_num = probe->received_packets;
		result->bytes = probe->received_total;
		/* double to timeval....*/
		double2timeval(bandwidth, &(result->bw_med));
		/* timeval - timeval */
		difftimeval ( &(probe->start), &(probe->end), &(result->time_med));
		result->jitter_med = result->jitter_med/(probe->received_packets - 1);

		memset (buffer, 0, 256);
		if (!get_currentDateTime (buffer, 256)) {
			LOG_FILE (((log_file != NULL) ? log_file : DEFAULT_RECVCONT_BURST_LOGFILE), "[%s]\t%4d\t%4d\t%5d\t%10d\t%12.4f\t%09.6f\n",
					buffer, conf_settings->recvsock_buffer, probe->received_total/probe->received_packets, probe->received_packets, probe->received_total, bandwidth/1000000, diff);
		}
		else {
			LOG_FILE (((log_file != NULL) ? log_file : DEFAULT_RECVCONT_BURST_LOGFILE), "%4d\t%4d\t%5d\t%10d\t%12.4f\t%09.6f\n",
					conf_settings->recvsock_buffer, probe->received_total/probe->received_packets, probe->received_packets, probe->received_total, bandwidth/1000000, diff);
		}
	}
	return;
}
コード例 #2
0
ファイル: dpsLogFileMgr.cpp プロジェクト: SequoiaDB/SequoiaDB
 DPS_LSN _dpsLogFileMgr::getStartLSN ( BOOLEAN mustExist )
 {
    DPS_LSN lsn =  LOG_FILE ( _work + 1 )->getFirstLSN ( mustExist ) ;
    if ( !lsn.invalid() )
       return lsn ;
    else
       return LOG_FILE ( _begin )->getFirstLSN ( mustExist ) ;
 }
コード例 #3
0
ファイル: QtWidgetManager.hpp プロジェクト: stryku/LifeHelper
 void QtWidgetManager::connectWithInput(InputPropagator &inputPropagator)
 {
     LOG_FILE("QtWidgetManager::connectWithInput");
     formWidget->connect(ui_pushButtonMinus,
                         &QPushButton::clicked,
                         inputPropagator.createDecrementSumCallback());
 }
コード例 #4
0
ファイル: dpsLogFileMgr.cpp プロジェクト: SequoiaDB/SequoiaDB
    // PD_TRACE_DECLARE_FUNCTION ( SDB__DPSLGFILEMGR_SYNC, "_dpsLogFileMgr::sync" )
   INT32 _dpsLogFileMgr::sync()
   {
      INT32 rc = SDB_OK ;
      PD_TRACE_ENTRY( SDB__DPSLGFILEMGR_SYNC ) ;

      UINT32 j = _work + 1 ;
      for ( UINT32 i = 0 ; i <= _files.size(); ++i, ++j )
      {
         _dpsLogFile *file = LOG_FILE( j ) ;
         if ( !file->isDirty() )
         {
            continue ;
         }
         rc = file->sync() ;
         if ( SDB_OK != rc )
         {
            PD_LOG( PDERROR, "Failed to sync log file: %d", rc ) ;
            goto error ;
         }
      }

   done:
      PD_TRACE_EXITRC( SDB__DPSLGFILEMGR_SYNC, rc ) ;
      return rc ;
   error:
      goto done ;
   }
コード例 #5
0
ファイル: InputHandler.hpp プロジェクト: stryku/LifeHelper
 void decrementSum() 
 {
     if (auto ptr = model.lock())
         ptr->decrementSum();
     else
         LOG_FILE("InputHandler::model expired");
 }
コード例 #6
0
ファイル: io_device.c プロジェクト: unixo/vmbo
/*! \fn int io_device_read(uint16_t procnum)
 *  \brief Richiede un accesso al dispositivo di I/O
 *  \details La funzione si occupa di accodare la richiesta d'accesso al
 *  dispositivo di I/O da parte di uno dei processi. Qualora l'MMU abbia
 *  gia terminato la propria esecuzione, la funzione non accetta
 *  ulteriori richieste.
 *  \param procnum      ID del processo
 *  \return             Restituisce l'esito dell'operazione:
 *                      1  la richiesta e' stata accodata
 *                      0  quando non sono piu' ammesse richieste
 */
int io_device_read(uint16_t procnum)
{
    io_entry_t *req;
    int ret;

    pthread_mutex_lock(&request_lock);

    if (!io_device_should_exit) {
        pthread_mutex_lock(&wait_lock);
        req = XMALLOC(io_entry_t, 1);
        req->pid = proc_table[procnum]->pid;
        req->procnum = procnum;
        pthread_mutex_lock(&fifo_lock);
        if (STAILQ_EMPTY(&io_request_head))
            STAILQ_INSERT_HEAD(&io_request_head, req, entries);
        else
            STAILQ_INSERT_TAIL(&io_request_head, req, entries);
        ioreq_count++;
        pthread_mutex_unlock(&fifo_lock);

        fprintf(LOG_FILE(procnum),
                "\nRichiesta d'accesso a dispositivo I/O accodata\n");

        pthread_mutex_unlock(&wait_lock);
        pthread_cond_signal(&wait_cond);
        ret = 1;
    } else
        ret = 0;

    pthread_mutex_unlock(&request_lock);

    return ret;
}
コード例 #7
0
ファイル: io_device.c プロジェクト: unixo/vmbo
/*! \fn void *thread_io_device(void *parg)
 *  \brief Thread dispositivo I/O
 *  \details La funzione costituisce il corpo del thread che rappresenta il
 *  dispositivo di I/O. Il suddetto thread sospende la propria esecuzione
 *  fintanto che non siano presenti delle richieste d'accesso al dispositivo.
 *  Il thread termina la propria esecuzione quando sono stati compiuti il
 *  numero massimo d'accessi alla memoria (ad opera dell'MMU).
 *  \param parg         inutilizzato
 *  \return             inutilizzato
 */
static void *
thread_io_device(void *parg)
{
    io_entry_t *req;
    struct timespec timeout;
    int num;

    printf("--> Thread DEVICE I/O avviato [Tmin=%d, Tmax=%d]\n",
           io_dev.Tmin, io_dev.Tmax);

    while (!io_device_should_exit) {
        pthread_mutex_lock(&wait_lock);
        while ((ioreq_count == 0) && !io_device_should_exit) {
            pthread_cond_wait(&wait_cond, &wait_lock);
        }

        if (io_device_should_exit && (ioreq_count == 0)) {
            pthread_mutex_unlock(&wait_lock);
            break;
        }

        /*
         *  Estraggo la prima richiesta e la rimuovo dalla coda, aggiornando
         *  la variabile "ioreq_count" che tiene traccia di quante richieste
         *  sono ancora in attesa.
         */
        req = STAILQ_FIRST(&io_request_head);
        assert(req);

        pthread_mutex_lock(&fifo_lock);
        STAILQ_REMOVE(&io_request_head, req, io_entry, entries);
        ioreq_count--;
        pthread_mutex_unlock(&fifo_lock);

        /*
         *  Genero un numero casuale compreso nell'intervallo chiuso
         *  [Tmin,Tmax] utile a simulare il reperimento dell'informazione dal
         *  dispositivo.
         */
        num = bounded_rand(io_dev.Tmin, io_dev.Tmax);
        timeout.tv_sec = 0;
        timeout.tv_nsec = num * 1000000;
        nanosleep(&timeout, NULL);
        fprintf(LOG_FILE(req->procnum),
                "Richiesta d'accesso servita in %d ms\n", num);

        /*
         *  Aggiorno le statistiche e "risveglio" il processo che ha fatto la
         *  richiesta.
         */
        io_dev.req_count++;
        proc_table[req->procnum]->stats.io_requests++;
        proc_table[req->procnum]->stats.time_elapsed += num;
        pthread_mutex_unlock(&wait_lock);
        pthread_cond_signal(&proc_table[req->procnum]->io_cond);
        XFREE(req);
    }
    printf("<-- Thread DEVICE I/O terminato\n");
    pthread_exit(NULL);
}
コード例 #8
0
ファイル: UpdateEntity.cpp プロジェクト: staring/UpdateAgent
void UpdateEntity::Start(void* h) {
	svy::CHttpClient	http;
	//使用第一个参数连接服务器
	NetConfig::SERVICE netcfg = mNetCfg_.mSvrs[0];
	CString a(netcfg.ip);
	a += _T(":") + svy::strFormat(_T("%d"),netcfg.port);
	a = svy::catUrl(a, netcfg.act);
	a.Replace('\\','/');
	http.AddHeader(_T("SENDER"),_T("SERVYOU001"));
	http.AddHeader(_T("ZCBM"), _T(""));
	http.AddHeader(_T("SWJG_DM"), _T("19901000000"));
	http.AddHeader(_T("JKVERSION"), _T("V1.0.055"));
	http.AddHeader(_T("ACTIONCODE"), _T("5002"));
	http.AddHeader(_T("HAS_BODY"), _T("1"));
	http.AddHeader(_T("IS_CRYPT"), _T("0"));
	http.AddHeader(_T("IS_COMPRESS"), _T("0"));
	http.AddHeader(_T("RESERVE_HEAD"), _T("tdp"));
	http.AddHeader(_T("CREATE_DATE"), CTime::GetCurrentTime().Format(_T("%Y/%m/%d")));
	http.SetAgent(_T("Mozilla/3.0 (compatible; Indy Library)"));

	std::string f = BuildBody(BUILD_XML_FILE);

	http.AddParam("file0", f, svy::CHttpClient::ParamFile);
	http.EnableWriteHeader(true);
	http.PerformParam(a);
	long hCode = svy::CHttpClient::PerformUrl(http.GetCURL());
	//上传结束后删除文件
	::DeleteFileA(f.c_str());

	if (hCode != 200) {
		CString msg = svy::strFormat(_T("%s failed %d"),a, hCode);
		LOG_FILE(svy::Log::L_ERROR,msg);
		return;
	} 
	std::string result = http.GetHeader();
	//留下罪证
	LOG_FILE(svy::Log::L_INFO,(LPCTSTR)CA2CT(result.c_str()) );
	//解析返回的数据
	result = http.GetStream();
	if (!result.size()) {
		LOG_FILE(svy::Log::L_INFO,_T("缺少body数据"));
		return;
	}
	FetchUpdate(result);
}
コード例 #9
0
ファイル: ProcessFactory.hpp プロジェクト: stryku/LifeHelper
 static tpl::Process create(ModelId id)
 {
     try
     {
         auto command = createCommand(id);
         LOG_FILE("Process::Facroty creating with command: " << command);
         return std::move(tpl::Process{ command.c_str(), "" });
     }
     catch (std::exception &e)
     {
         LOG("Process::Factory::create exception caught: " << e.what());
     }
 }
コード例 #10
0
ファイル: test-barrier.cpp プロジェクト: claudioscordino/PBSM
int main (int argc, char* argv[])
{
	LOG_FILE("/tmp/pbsm.log");
	pbsm_init(argc, argv);

	std::this_thread::sleep_for(std::chrono::seconds(10));

	for(;;)
		PBSM_BARRIER();

	DEBUG("DONE!");

	return 0;
}
コード例 #11
0
ファイル: AdjustStock.cpp プロジェクト: bigc2000/tutu
 double CAdjustStock::OP( unsigned int opType, double num1, double num2 )
 {
	 double result=0.0;
	 switch(opType)
	 {
	 case LT_:
		 {
			 result = num2 < num1;
			 LOG_FILE(LOG_LEVEL::LOG_DEBUG,"[AdjustStock], logic calculate of %f < %f = %f;",num2,num1,result);
			 break;
		 }
	 case GT:
		 {
			 result = num2 > num1;
			 LOG_FILE(LOG_LEVEL::LOG_DEBUG,"[AdjustStock], logic calculate of %f > %f = %f;",num2,num1,result);
			 break;
		 }
	 case AND:
		 {
			 result = num2 && num1;
			 LOG_FILE(LOG_LEVEL::LOG_DEBUG,"[AdjustStock], logic calculate of %f && %f = %f;",num2,num1,result);
			 break;
		 }	

	 case OR:
		 {
			 result = num2 || num1;
			 LOG_FILE(LOG_LEVEL::LOG_DEBUG,"[AdjustStock], logic calculate of %f || %f = %f;",num2,num1,result);
			// cout<<"logic calculate of "<< num2<<" || "<<num1<<"="<<result<<";"<<endl;
			 break;
		 }	
	 default:
		 break;
	 }
	 numbers.push(result);
	 return result;
 }
コード例 #12
0
ファイル: VerConfig.cpp プロジェクト: staring/UpdateAgent
bool loadVerConfigByFile(const CString& file, VerConfig &ret) {
	tinyxml2::XMLDocument	doc;	
	if (tinyxml2::XML_SUCCESS != doc.LoadFile(CT2A(file))) {
		LOG_FILE(svy::Log::L_ERROR, svy::strFormat(_T("%s ½âÎöʧ°Ü"), file));
		return false;
	}
	tinyxml2::XMLElement *root = doc.RootElement();
	tinyxml2::XMLElement *nd1 = root->FirstChildElement("Version");
	tinyxml2::XMLElement *nd2 = root->FirstChildElement("ProductCode");
	tinyxml2::XMLElement *nd3 = root->FirstChildElement("EntryName");
	if (nd1 && nd2 && nd3) {
		ret.mVer_ = nd1->GetText();
		ret.mProductCode_ = nd2->GetText();
		ret.mEntryName_ = nd3->GetText();
		return true;
	}
	return false;
}
コード例 #13
0
ファイル: dpsLogFileMgr.cpp プロジェクト: SequoiaDB/SequoiaDB
   // PD_TRACE_DECLARE_FUNCTION ( SDB__DPSLGFILEMGR_LOAD, "_dpsLogFileMgr::load" )
   INT32 _dpsLogFileMgr::load( const DPS_LSN &lsn, _dpsMessageBlock *mb,
                               BOOLEAN onlyHeader,
                               UINT32 *pLength )
   {
      INT32 rc      = SDB_OK ;
      PD_TRACE_ENTRY ( SDB__DPSLGFILEMGR_LOAD );
      SDB_ASSERT ( mb, "mb can't be NULL" ) ;
      UINT32 sub    = ( UINT32 )( lsn.offset / _logFileSz  % _files.size() ) ;
      dpsLogRecordHeader head ;
      UINT32 len = 0 ;
      rc = LOG_FILE( sub )->read( lsn.offset, sizeof(dpsLogRecordHeader),
                                  (CHAR*)&head ) ;
      if ( rc )
      {
         PD_LOG ( PDERROR, "Failed to read log file %d, rc = %d", sub, rc ) ;
         goto error ;
      }
      if ( lsn.offset != head._lsn )
      {
         PD_LOG ( PDERROR, "Invalid LSN is read from log file, expect %lld, %d,"
                  "actual %lld, %d", lsn.offset, lsn.version, head._lsn,
                  head._version ) ;
         rc = SDB_DPS_LOG_NOT_IN_FILE ;
         goto error ;
      }
      if ( head._length < sizeof(dpsLogRecordHeader) )
      {
         PD_LOG ( PDERROR, "LSN length[%u] is smaller than dps log head",
                  head._length ) ;
         rc = SDB_DPS_CORRUPTED_LOG ;
         goto error ;
      }

      if ( pLength )
      {
         *pLength = head._length ;
      }

      if ( onlyHeader )
      {
         len = sizeof( dpsLogRecordHeader ) ;
      }
      else
      {
         len = head._length ;
      }

      if ( mb->idleSize() < len )
      {
         rc = mb->extend ( len - mb->idleSize() ) ;
         if ( rc )
         {
            PD_LOG ( PDERROR, "Failed to extend mb, rc = %d", rc ) ;
            goto error ;
         }
      }
      ossMemcpy( mb->writePtr(), &head, sizeof(dpsLogRecordHeader ) ) ;
      mb->writePtr( mb->length() + sizeof( dpsLogRecordHeader ) ) ;
      if ( onlyHeader )
      {
         goto done ;
      }

      rc = LOG_FILE( sub )->read ( lsn.offset + sizeof(dpsLogRecordHeader ),
                                   head._length - sizeof( dpsLogRecordHeader ),
                                   mb->writePtr() ) ;
      if ( rc )
      {
         PD_LOG ( PDERROR, "Failed to read from log file %d for %d bytes, "
                  "rc = %d", sub, head._length-sizeof(dpsLogRecordHeader),
                  rc ) ;
         mb->writePtr( mb->length() - sizeof( dpsLogRecordHeader ) ) ;
         goto error ;
      }
      mb->writePtr ( mb->length() + head._length -
                     sizeof( dpsLogRecordHeader ) ) ;

   done:
      PD_TRACE_EXITRC ( SDB__DPSLGFILEMGR_LOAD, rc ) ;
      return rc ;
   error:
      goto done ;
   }
コード例 #14
0
ファイル: QtView.hpp プロジェクト: stryku/LifeHelper
 void updateSum( size_t newSum )
 {
     LOG_FILE("InputPropagator::updateSum( " << newSum << " )");
     updateLabel( QString::number( newSum ) );
 }
コード例 #15
0
ファイル: UpdateEntity.cpp プロジェクト: staring/UpdateAgent
bool UpdateEntity::FetchUpdate(const std::string& val) {
	{
		//解析xml判断当前动作
		tinyxml2::XMLDocument doc;
		if (tinyxml2::XML_NO_ERROR != doc.Parse(val.c_str())) {
			CString body = svy::strFormat(_T("无法解析 %s"), (LPCTSTR)CA2CT(val.c_str()));
			LOG_FILE(svy::Log::L_INFO, body);
			return false;
		}
		tinyxml2::XMLElement *root = doc.RootElement();
		tinyxml2::XMLElement *ndExt= root->FirstChildElement("EXTEND");	//扩展字段
		tinyxml2::XMLElement *body = root->FirstChildElement("BODY");
		if (!body) {
			CString body = svy::strFormat(_T("不符合规范 %s"), (LPCTSTR)CA2CT(val.c_str()));
			LOG_FILE(svy::Log::L_INFO, body);
			return false;
		}
		tinyxml2::XMLElement *response = body->FirstChildElement("RETURN");
		if (!response) {
			CString body = svy::strFormat(_T("不符合规范 %s"), (LPCTSTR)CA2CT(val.c_str()));
			LOG_FILE(svy::Log::L_INFO, body);
			return false;
		}
		if (0 != strcmp(response->Attribute("CODE"), "0000")) {
			CString body = svy::strFormat(_T("异常 %s"), (LPCTSTR)CA2CT(val.c_str()));
			LOG_FILE(svy::Log::L_INFO, body);
			return false;
		}
		tinyxml2::XMLElement *ndSJXX = body->FirstChildElement("SJXX");		//产品字段
		tinyxml2::XMLElement *product = nullptr;
		if (!ndSJXX) {
			CString body = svy::strFormat(_T("不符合规范 %s"), (LPCTSTR)CA2CT(val.c_str()));
			LOG_FILE(svy::Log::L_INFO, body);
			return false;
		}
		//找到该产品的升级node
		for (tinyxml2::XMLElement *next = ndSJXX->FirstChildElement(); next; next = next->NextSiblingElement()) {
			if (strcmp(next->Name(), "PRODUCT"))
				continue;
			CString a = (LPCTSTR)CA2CT(next->Attribute("CODE"));
			if (a != mExe_.mVer_.mProductCode_)
				continue;
			product = next;
			break;
		}
		if (product==nullptr) {
			CString body = svy::strFormat(_T("缺少对应产品 %s"), (LPCTSTR)CA2CT(val.c_str()));
			LOG_FILE(svy::Log::L_INFO, body);
			return false;
		}
		//存第一个版本升级包
		std::shared_ptr<UP_PACK> info = std::make_shared<UP_PACK>();
		info->url = CA2CT(product->Attribute("UPDATEURL"));
		if (info->url.IsEmpty()) {
			info->url = CA2CT(product->Attribute("OTHERURL"));
			long dot = info->url.Find(',');
			if (dot != -1 && dot > 0)
				info->url = info->url.Mid(0, dot);
		}
		info->ver = CA2CT(product->Attribute("END_VERSION"));
		CString bNeedUp = CA2CT(product->Attribute("HAS_UPDATE"));
		bNeedUp.Trim();
		if (0 == bNeedUp.CompareNoCase(_T("0"))) {
			LOG_FILE(svy::Log::L_INFO,(LPCTSTR)CA2CT(val.c_str()));
			return true;
		}
		if ( !info->ver.IsEmpty() || !info->url.IsEmpty()) {
			mUpData_.push_back(info);
		}
		//存其他版本升级包
		tinyxml2::XMLElement *packs = product->FirstChildElement("GREATERVERSION");
		for (tinyxml2::XMLElement *next = packs; next; next = next->NextSiblingElement()) {
			std::shared_ptr<UP_PACK> info = std::make_shared<UP_PACK>();
			info->url = CA2CT(next->Attribute("UPDATEURL"));
			if (info->url.IsEmpty()) {
				info->url = CA2CT(next->Attribute("OTHERURL"));
				long dot = info->url.Find(',');
				if (dot != -1 && dot > 0)
					info->url = info->url.Mid(0, dot);
			}
			info->ver = CA2CT(next->Attribute("END_VERSION"));
			if (!info->ver.IsEmpty() || !info->url.IsEmpty()) {
				mUpData_.push_back(info);
			}
		}
	}
	std::vector<CString>	badVers;	//异常版本队列,可能是下载错误或写入错误也可能是挂包错误导致
	size_t nCount = mUpData_.count();
	for (size_t nI = 0; nI < nCount; nI++) {
		std::shared_ptr<UP_PACK> info = mUpData_[nI];
		//生成文件
		CString path;
		long	hCode = 0;
		{
			path.Format(_T("%s_%s.zip"),svy::PathGetFileName(mExe_.getPathFile()), info->ver);
			FILE *f = nullptr;
			errno_t err;
			if ((err = fopen_s(&f, CT2CA(path), "wb")) != 0) {
				LOG_FILE(svy::Log::L_ERROR, svy::strFormat(_T("file open filed %d"), err));
				return false;
			}
			//下载数据
			svy::CHttpClient	http;
			http.BodySaveFile(f);
			http.PerformParam(info->url);
			hCode = svy::CHttpClient::PerformUrl(http.GetCURL());
			fclose(f);
			f = nullptr;
		}
		if (hCode != 200) {
			//异常文件
			LOG_FILE(svy::Log::L_ERROR,info->url);
			::DeleteFile(path);
			badVers.push_back(info->ver);
			continue;
		}
		//需要解压缩
		info->step = Step::ExtractFiles;
		info->path = path;
	}
	//移除异常的数据
	nCount = badVers.size();
	for (size_t nI = 0; nI < nCount; nI++) {
		CString key = badVers[nI];
		std::shared_ptr<UP_PACK> pack = mUpData_.getBegin();
		while (pack=mUpData_.getNext()) {
			if (key == pack->ver) {
				mUpData_.erase(pack);
				break;
			}
		}		
	}
	//处理升级包
	HandleUpdatePack();
	return true;
}
コード例 #16
0
ファイル: UpdateAgent.cpp プロジェクト: staring/UpdateAgent
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
#if defined(_DEBUG)
	MessageBoxW(NULL, lpCmdLine, L"wait for debug", 0);
#endif
#if !defined(_DEBUG)
	if (lpCmdLine == NULL || lpCmdLine[0] == '\0') {
		//没有任何参数无法运行
		return	0;
	}
#endif
	LOG_FILE(svy::Log::L_INFO,svy::strFormat(_T("run cmd %s"),lpCmdLine));
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);
	//读取自己的配置信息
	svy::SinglePtr<AppModule> app;
	AppModule::REG_INFO regInfo;
	PreLogic			prelogic;	
	app->getMySlefModule();
	prelogic.parseCommondLine();
	if (1 >= app->getModuleCount()) {
		return 0;
	}
	if ( !prelogic.canRunUpdate() ) {
		//建立copy
		CString dirAppD = svy::GetLocalAppDataPath();
		CString dirSrc = svy::GetAppPath();
		CString dirDst = svy::catUrl(dirAppD, svy::GetAppName());
		svy::CopyDir(dirSrc, dirDst);
		//
		dirAppD = dirDst; //缓存运行目录
		dirDst = svy::catUrl(dirDst, svy::GetAppName()) + _T(".exe");
		CString strCmd;
		CString strPrevCmds((LPCTSTR)CW2CT(lpCmdLine));
		strPrevCmds.TrimRight();
		if ('|' != strPrevCmds[strPrevCmds.GetLength() - 1]) {
			strCmd.Format(_T("%s | version:%s %s |"), strPrevCmds,
				app->getMySlefModule().mVer_.mVer_, cmdSelfKey() );
		}
		else {
			strCmd.Format(_T("%s version:%s %s |"), strPrevCmds,
				app->getMySlefModule().mVer_.mVer_, cmdSelfKey() );
		}
		regInfo.path = dirSrc;
		regInfo.name = svy::GetAppName();
		//将自己位置信息写入注册表
		AppModule::SaveRegisteInfo(regInfo);		
		::ShellExecute(NULL, _T("open"), dirDst,strCmd,dirAppD,0);
		return 0;
	}
	//初始化lua模块
	lua_State *L = app->getLua();
	//初始化libcurl环境
	svy::CHttpClient::GlobalSetup();
	//判断是否运行copy
	//访问服务器检查更新
	svy::SinglePtr<UpdateSchedule>	updateSchedule;

	updateSchedule->run();

	svy::CHttpClient::GlobalClean();
	return 0;
}
コード例 #17
0
ファイル: QtView.hpp プロジェクト: stryku/LifeHelper
            void updateLabel( const QString &str )
            {
                LOG_FILE("InputPropagator::updateLabel(" << str.toStdString() << ")");

                widgetManager.setLabelSum( str );
            }
コード例 #18
0
ファイル: QtView.hpp プロジェクト: stryku/LifeHelper
 void connectWithInput(InputPropagator &input )
 {
     LOG_FILE("InputPropagator::connectWithInput");
     widgetManager.connectWithInput( input );
 }
コード例 #19
0
ファイル: AdjustStock.cpp プロジェクト: bigc2000/tutu
bool CAdjustStock::ParseAdjustLogic(const char* logicExp, HASH_MAP< string, double >&signalMap)
{  
	pANTLR3_INPUT_STREAM input;
	pExprLexer lexer;
	pANTLR3_COMMON_TOKEN_STREAM tstream ;
	pExprParser parser;
	pANTLR3_BASE_TREE root ;
	if( strlen(logicExp) == 0 )
		return false ;
	try
	{
		input = antlr3StringStreamNew( (pANTLR3_UINT8) logicExp, ANTLR3_ENC_UTF8, strlen(logicExp), (pANTLR3_UINT8)"Expr" );
		SHOULD( input, "fail to create stream from string: " << logicExp );

		lexer = ExprLexerNew( input );
		SHOULD( input, "fail to create lexer" );

		tstream = antlr3CommonTokenStreamSourceNew( ANTLR3_SIZE_HINT, TOKENSOURCE(lexer) );
		SHOULD( tstream, "fail to create token stream" );

		parser = ExprParserNew( tstream );
		SHOULD( parser, "fail to create parser" );

		ExprParser_expr_return statments = (ExprParser_expr_return)( parser->expr(parser) );
		int errs = parser->pParser->rec->state->errorCount;
		if( errs>0 ){
			LOG_FILE(LOG_LEVEL::LOG_INFO,"[AdjustStock] The parser returned %d errors, tree walking aborted.\n", errs);
			return false ;
		}

		root = statments.tree;
		SHOULD( root, "fail to get tree" );

		pANTLR3_TOKEN_STREAM stream = tstream->tstream;

		m_adjustTree.tree_ = root;
		m_adjustTree.stream_ = stream;
		//根据语法树的节点得到叶子节点类型为VAR的变量,返给调仓查询
		//修改叶子节点是变量的值,key用Value替换
		getVARList( m_adjustTree, m_varVec );
		HASH_MAP< string, double >::iterator mit;
		//test: srcSingleMap[000407_alpha_7_indus_sort, 1.23]
		for ( size_t i =0; i<m_varVec.size(); i++ )
		{
			mit = signalMap.find(m_varVec[i]);
			if ( mit != signalMap.end() )  {
				m_parseMap[m_varVec[i]] = mit->second;
			} else {			
				ISM_LOG_ERR("[AdjustStock]","the signal value not founded in singal map!");
				return false;
			}
		}
		//calculate the result from the replaced tree
		int result = calcExpr(m_adjustTree);

		if( parser )  { parser->free( parser );}
		if( tstream ) { tstream->free( tstream );}
		if( lexer )   { lexer->free( lexer );}
		if( input )   { input->close( input );}	

		return result==1 ;
	}
	catch( Exp& e )
	{
		RETHROW( e, "fail to parse. line: " << logicExp  );
	}
}
コード例 #20
0
ファイル: sendctrl.c プロジェクト: ascjunior/UdpTester
int sendctrl (settings *conf_settings) {
	int ret = 0;
	pthread_t sendtest_thread_id;

	/* cria thread de envio do probe */
	switch (conf_settings->t_type) {
		case UDP_CONTINUO:
				if ((ret = pthread_create (&sendtest_thread_id, NULL, send_continuo_burst, (void *)conf_settings))) {
					DEBUG_LEVEL_MSG (DEBUG_LEVEL_LOW, "Could not create recvtest thread: %s\n",
					(ret == EAGAIN) ? "EAGAIN" : (ret == EINVAL) ? "EINVAL" : (ret == EPERM) ? "EPERM" : "UNKNOW");
				}
			break;
		case UDP_PACKET_TRAIN:
				if ((ret = pthread_create (&sendtest_thread_id, NULL, send_packet_train, (void *)conf_settings))) {
					DEBUG_LEVEL_MSG (DEBUG_LEVEL_LOW, "Could not create recvtest thread: %s\n",
					(ret == EAGAIN) ? "EAGAIN" : (ret == EINVAL) ? "EINVAL" : (ret == EPERM) ? "EPERM" : "UNKNOW");
				}
			break;
		default:
			DEBUG_LEVEL_MSG (DEBUG_LEVEL_LOW, "Invalid test type %d\n", conf_settings->t_type);
	}

	if (ret)
		return ret;

	/* join thread */
	pthread_join (sendtest_thread_id, NULL);

	/* log de resultados */
	char log_buffer[256];
	memset (log_buffer, 0, 256);
	switch (conf_settings->t_type) {
		case UDP_CONTINUO:
			if (!get_currentDateTime(log_buffer, 256)) {
				LOG_FILE (DEFAULT_SENDCONT_BURST_LOGFILE, "[%s]\t%4d\t%4d\t%5d\t%10d\t%4d\t%4d\n",
						log_buffer, conf_settings->sendsock_buffer, conf_settings->packet_size, conf_settings->test.cont.pkt_num,
						conf_settings->test.cont.pkt_num*conf_settings->packet_size, conf_settings->udp_rate,
						conf_settings->test.cont.size);
			}
			else {
				LOG_FILE (DEFAULT_SENDCONT_BURST_LOGFILE, "%4d\t%4d\t%5d\t%10d\t%4d\t%4d\n",
						conf_settings->sendsock_buffer, conf_settings->packet_size, conf_settings->test.cont.pkt_num,
						conf_settings->test.cont.pkt_num*conf_settings->packet_size, conf_settings->udp_rate,
						conf_settings->test.cont.size);
			}
			break;
		case UDP_PACKET_TRAIN:
			if (!get_currentDateTime(log_buffer, 256)) {
				LOG_FILE (DEFAULT_SENDTRAIN_BURST_LOGFILE, "[%s]\t%4d\t%4d\t%5d\t%10d\t%4d\t%4d\t%4d\t%4d\n",
						log_buffer, conf_settings->sendsock_buffer, conf_settings->packet_size,
						(conf_settings->test.train.num * conf_settings->test.train.size),
						(conf_settings->test.train.num * conf_settings->test.train.size * conf_settings->packet_size),
						conf_settings->udp_rate, conf_settings->test.train.num,
						conf_settings->test.train.size, conf_settings->test.train.interval);
			}
			else {
				LOG_FILE (DEFAULT_SENDTRAIN_BURST_LOGFILE, "%4d\t%4d\t%5d\t%10d\t%4d\t%4d\t%4d\t%4d\n",
						conf_settings->sendsock_buffer, conf_settings->packet_size,
						(conf_settings->test.train.num * conf_settings->test.train.size),
						(conf_settings->test.train.num * conf_settings->test.train.size * conf_settings->packet_size),
						conf_settings->udp_rate, conf_settings->test.train.num,
						conf_settings->test.train.size, conf_settings->test.train.interval);
			}
			break;
		default:
			DEBUG_LEVEL_MSG (DEBUG_LEVEL_LOW, "Invalid test type %d\n", conf_settings->t_type);
	}

	return ret;
}