コード例 #1
0
ファイル: main.cpp プロジェクト: 854825967/zsummer
int main(int argc, char* argv[])
{

#ifndef _WIN32
	//! linux下需要屏蔽的一些信号
	signal( SIGHUP, SIG_IGN );
	signal( SIGALRM, SIG_IGN ); 
	signal( SIGPIPE, SIG_IGN );
	signal( SIGXCPU, SIG_IGN );
	signal( SIGXFSZ, SIG_IGN );
	signal( SIGPROF, SIG_IGN ); 
	signal( SIGVTALRM, SIG_IGN );
	signal( SIGQUIT, SIG_IGN );
	signal( SIGCHLD, SIG_IGN);
#endif
	//! 启动日志服务
	ILog4zManager::GetInstance()->Config("server.cfg");
	ILog4zManager::GetInstance()->Start();
//ILog4zManager::GetInstance()->ChangeLoggerDisplay(ILog4zManager::GetInstance()->GetMainLogger(), false);
//ILog4zManager::GetInstance()->ChangeLoggerLevel(ILog4zManager::GetInstance()->GetMainLogger(), LOG_LEVEL_INFO);

	//! 启动调度器
	CSchedule schedule;
	schedule.Start();

	//main线程用于服务状态统计与输出
	unsigned long long nLastRecv = 0;
	unsigned long long nLastSend = 0;
	unsigned long long nLastRecvCount = 0;
	unsigned long long nLastSendCount = 0;
	for (;;)
	{
		SleepMillisecond(5000);
		unsigned long long temp1 = 0;
		unsigned long long temp2 = 0;
		unsigned long long temp3 = 0;
		unsigned long long temp4 = 0;
		for (std::vector<CProcess *>::const_iterator iter = schedule.m_process.begin(); iter != schedule.m_process.end(); ++iter)
		{
			temp1 += (*iter)->GetTotalRecvLen();
			temp2 += (*iter)->GetTotalSendLen();
			temp3 += (*iter)->GetTotalRecvCount();
			temp4 += (*iter)->GetTotalSendCount();
		}
		LOGD("allLink[" << g_nTotalLinked 
			<<"]  allClosed[" << g_nTotalCloesed
			<< "]  Recv[" << (temp1 - nLastRecv)/1024.0/1024.0/5.0
			<< "]M  Send[" << (temp2 - nLastSend)/1024.0/1024.0/5.0
			<< "]M  RecvSpeed[" << (temp3 - nLastRecvCount)/5.0
			<< "]  SendSpeed[" << (temp4 - nLastSendCount)/5.0
			<< "].");
		nLastRecv = temp1;
		nLastSend = temp2;
		nLastRecvCount = temp3;
		nLastSendCount = temp4;
	}

	schedule.Stop();

	//日志服务不需要显式调用停止接口
	//InterfaceLogger::GetInstance()->Stop();
	return 0;
}
コード例 #2
0
#include "CRecipeDefinition.h"
#include "CRecipeDatabase.h"
#include <list>
#include "CDay.h"
#include "CSchedule.h"
#include "CManufacture.h"
#include "CDataLoader.h"
#include "CWarehouse.h"
#include "common.h"


using namespace std;

CItemDatabase db;
CRecipeDatabase recdb;
CSchedule cs, final;
CManufacture cm;

int main()
{
    db.Load("items.txt");
    //db.Load("D:/WORK/CPP/Manufacturing1/bin/Debug/items.txt");
    recdb.Create(&db);
    recdb.Load("recipes.txt");
    //recdb.Load("D:/WORK/CPP/Manufacturing1/bin/Debug/recipes.txt");
    //recdb.Show();
    //cout <<db.Show();
    cm.Create(&db,&recdb,&cs);
    //cm.init();

     int CreateDemands[] = {30, 20, 20, 0 , 10, 20, 20};//, 0, 10, 20, 20};
コード例 #3
0
ファイル: main.cpp プロジェクト: maydayzm/zsummerX
int main(int argc, char* argv[])
{

#ifndef _WIN32
	//! linux下需要屏蔽的一些信号
	signal( SIGHUP, SIG_IGN );
	signal( SIGALRM, SIG_IGN ); 
	signal( SIGPIPE, SIG_IGN );
	signal( SIGXCPU, SIG_IGN );
	signal( SIGXFSZ, SIG_IGN );
	signal( SIGPROF, SIG_IGN ); 
	signal( SIGVTALRM, SIG_IGN );
	signal( SIGQUIT, SIG_IGN );
	signal( SIGCHLD, SIG_IGN);
#endif
	if (argc == 2 && 
		(strcmp(argv[1], "--help") == 0 
		|| strcmp(argv[1], "/?") == 0))
	{
		cout << "please input like example:" << endl;
		cout << "tcpTest remoteIP remotePort startType maxClient sendType interval" << endl;
		cout << "./tcpTest 0.0.0.0 81 0" << endl;
		cout << "startType: 0 server, 1 client" << endl;
		cout << "maxClient: limite max" << endl;
		cout << "sendType: 0 echo send, 1 direct send" << endl;
		cout << "interval: send once interval" << endl;
		return 0;
	}
	if (argc > 1)
	{
		g_remoteIP = argv[1];
	}
	if (argc > 2)
	{
		g_remotePort = atoi(argv[2]);
	}
	if (argc > 3)
	{
		g_startType = atoi(argv[3]);
	}
	if (argc > 4)
	{
		g_maxClient = atoi(argv[4]);
	}
	if (argc > 5)
	{
		g_sendType = atoi(argv[5]);
	}
	if (argc > 6)
	{
		g_intervalMs = atoi(argv[6]);
	}

	
	if (g_startType == 0)
	{
		//! 启动日志服务
		ILog4zManager::GetInstance()->Config("server.cfg");
		ILog4zManager::GetInstance()->Start();
	}
	else
	{
				//! 启动日志服务
		ILog4zManager::GetInstance()->Config("client.cfg");
		ILog4zManager::GetInstance()->Start();
	}
	LOGI("g_remoteIP=" << g_remoteIP << ", g_remotePort=" << g_remotePort << ", g_startType=" << g_startType 
		<< ", g_maxClient=" << g_maxClient << ", g_sendType=" << g_sendType << ", g_intervalMs=" << g_intervalMs);



	//! 启动调度器
	CSchedule schedule;
	schedule.Start();


	//main线程用于服务状态统计与输出

	unsigned long long nLast[10] = {0};
	unsigned long long temp[10] = {0};
	for (;;)
	{
		std::this_thread::sleep_for(std::chrono::milliseconds(5000));
		memset(&temp, 0, sizeof(temp));

		for (std::vector<CProcess *>::const_iterator iter = schedule.m_process.begin(); iter != schedule.m_process.end(); ++iter)
		{
			temp[0] += (*iter)->GetTotalRecvLen();
			temp[1] += (*iter)->GetTotalSendLen();
			temp[2] += (*iter)->GetTotalRecvCount();
			temp[3] += (*iter)->GetTotalSendCount();
			temp[4] += (*iter)->GetTotalOpen();
			temp[5] += (*iter)->GetTotalClosed();
			temp[6] += (*iter)->GetTotalEcho();
			temp[7] += (*iter)->GetTotalEchoTime();
		}
		LOGD("Linked[" << temp[4] 
			<<"]  Closed[" << temp[5]
			<<"]  Recv[" << (temp[0] - nLast[0])/1024.0/1024.0/5.0
			<<"]M  Send[" << (temp[1] - nLast[1])/1024.0/1024.0/5.0
			<<"]M  RecvSpeed[" << (temp[2] - nLast[2])/5.0
			<<"]  SendSpeed[" << (temp[3] - nLast[3])/5.0
			<<"]  EchoSpeed[" << (temp[6]- nLast[6])/5.0
			<<"]  DelayTime[" << (temp[7]-nLast[7])/1.0/(temp[6]-nLast[6] == 0 ? 1 :temp[6]-nLast[6])
			<<"].");


		memcpy(&nLast, &temp, sizeof(temp));
	}

	schedule.Stop();

	//日志服务不需要显式调用停止接口
	//InterfaceLogger::GetInstance()->Stop();
	return 0;
}