Example #1
0
DataList* CreateEventTestData() {
	DataList* dataList = new DataList();

	NamedEventDataList* systemEventData = CreateSystemEventData();
	NamedEventDataList* runEventData = CreateRunEventData();
	NamedEventDataList* productionEventData = CreateProductionEventData();
	NamedEventDataList* agentEventData = CreateAgentEventData();
	NamedEventDataList* printEventData = CreatePrintEventData();
	NamedEventDataList* xmlEventData = CreateXMLEventData();
	NamedEventDataList* updateEventData = CreateUpdateEventData();
	NamedEventDataList* stringEventData = CreateStringEventData();

	dataList->push_back(systemEventData);
	dataList->push_back(runEventData);
	dataList->push_back(productionEventData);
	dataList->push_back(agentEventData);
	dataList->push_back(printEventData);
	dataList->push_back(xmlEventData);
	dataList->push_back(updateEventData);
	dataList->push_back(stringEventData);

	return dataList;
}
Example #2
0
void getData()
{
    // fstream fs ("..//input/iccad2015_input.case2" ,fstream::in);
   fstream fs ("..//input/test.txt" ,fstream::in);
//    fstream fs ("test.txt" ,fstream::in);
    string line;

    while(getline(fs,line))
    {
        int a = line[0];
        string num;
        num.clear();
        Data d;
        d.clear();
        if((a>=48 && a<=57) || a == 45)
        {
            for(int i=0; i< line.size(); i++)
            {
                if(((int)line[i]>=48 && (int)line[i]<=57 && i < line.size()-1) || (int)line[i]==45  )
                {
                    num.push_back(line[i]);
                }else if((int)line[i] == 44 )
                {
                    d.push_back(num);
                    num.clear();
                }else if(i == line.size()-1)
                {
                    num.push_back(line[i]);
                    d.push_back(num);
                    num.clear();
                    list.push_back(d);
                    d.clear();
                }
            }
        }
        else if(a==65)
        {
            for(int i=0;i<line.size();i++)
            {
                if(line[i]>=48 && line[i]<=57)
                {
                    alpha.push_back(line[i]);
                }
            }
        }
        else if(a==66)
        {
            for(int i=0;i<line.size();i++)
            {
                if(line[i]>=48 && line[i]<=57)
                {
                    beta.push_back(line[i]);
                }
            }
        }
        else if(a==79)
        {
            for(int i=0;i<line.size();i++)
            {
                if(line[i]>=48 && line[i]<=57)
                {
                    omega.push_back(line[i]);
                }
            }
        }
    }
}
Example #3
0
    void ScrDB::Write(TARGETING::TargetHandle_t i_ptargetHandle,
                      BitString & bs,
                      uint64_t registerId)
    {
        PRDF_TRAC( "ScrDB::Write() huid: %X, addr: %016X, data: %08X %08X",
                    getHuid(i_ptargetHandle), registerId,
                    bs.getFieldJustify(0,32), bs.getFieldJustify(32,32) );

        unsigned int dataWordSize = bs.getBitLen()/32;
        //    PRDF_TRAC("dataWordSize1: %d", dataWordSize);
        dataWordSize += (bs.getBitLen() % 32) ? 1 : 0;
        //    PRDF_TRAC("dataWordSize2: %d", dataWordSize);
        DataList data;

        // parse all data given
        data.push_back(bs.getFieldJustify(0,32));
        data.push_back(bs.getFieldJustify(32,32));
        //    PRDF_TRAC("parse all data given");
        // look for expected data
        DataList expectedData;
        if(eChipset.find(i_ptargetHandle) != eChipset.end())
        {
            PRDF_TRAC("found target");
            PreScrMap escrmap = eChipset[i_ptargetHandle];
            if(escrmap.find(registerId) != escrmap.end()) // we have expected data value
            {
                PRDF_TRAC("found scom reg");
                SimScrDataSet eValues = escrmap[registerId];
                expectedData = eValues.GetData(); // get next set of values
                escrmap[registerId] = eValues;
                eChipset[i_ptargetHandle] = escrmap;
            }
        }
        if(expectedData.size() > 0)
        {
            if((expectedData[0] != data[0]) || (expectedData[1] != data[1]))
            {
                PRDF_ERR("Verify SC register: %p", i_ptargetHandle);
                PRDF_ERR(" Address: 0x%016X", registerId);
                PRDF_ERR("SCR write Actual  : %08X %08X", data[0], data[1]);
                PRDF_ERR("SCR write Expected: %08X %08X", expectedData[0], expectedData[1]);
            }
            else
            {
                PRDF_TRAC("Verify SC register: %p", i_ptargetHandle);
                PRDF_TRAC(" Address: 0x%016X", registerId);
                PRDF_TRAC("SCR write Actual: %08X %08X", data[0], data[1]);
            }
        }

        //    PRDF_TRAC("get a copy");
        // get a copy of the scrMap for this chip - if one does not exist it will be created
        ScrMap scrMap = chipset[i_ptargetHandle];

        //    PRDF_TRAC("update register value");
        // update register value
        scrMap[registerId] = data; // copy the supplied value to the register

        //    PRDF_TRAC("update the master");
        chipset[i_ptargetHandle] = scrMap; // scrMap is only a copy so must update the master

        //PRDF_EXIT( "ScrDB::Write()" );

    }
Example #4
0
int main(int argc, char* argv[])
{
	
	int capacity;
	int NumOfFood;
    fstream fin(argv[1]);
    fstream fout;
    fout.open(argv[2],ios::out);
    fin>>capacity;
    fin>>NumOfFood;
    int x;
	int y;
	int weight;
	
	

	DataList FoodInfo;
	vector<int>aa(4,0);
	FoodInfo.push_back(aa);
	while(fin>>x>>y>>weight)
	{
		Data temp(3);
		temp[0] = x;
		temp[1] = y;
		temp[2] = weight;
		FoodInfo.push_back(temp);
	}
	//test
	cout<<capacity<<endl;
	cout<<NumOfFood<<endl;
	//cout<<x<<" "<<y<<" "<<weight<<endl;
	
	for(int i=0;i<FoodInfo.size();i++)
	{
		for(int j=0;j<3;j++)
		{
			cout<<FoodInfo[i][j]<<" ";
		}
		cout<<endl;
	}
	//cout<<"capacity="<<capacity<<endl;
	//cout<<"size:"<<FoodInfo.size()<<endl;
	int *minimalDist = new int[FoodInfo.size()];
	//int* position = new int[FoodInfo.size()];
	vector<int> position;
	
	ShortestPath(FoodInfo.size()-1,capacity,FoodInfo,minimalDist,position);
	for(int i=1;i<=NumOfFood;i++)
	{
		cout<<minimalDist[i]<<endl;
	}
	cout<<"postition"<<endl;
	for(int i=position.size()-1;i>=0;i--)
		{
			cout<<position[i]<<endl;
		}
	//cout<<FoodInfo.size()-1<<endl;
	
	
	cout<<"GREEDY!"<<endl;
	
	int distance = 0;
	Data position1;
	Greedy(FoodInfo,FoodInfo.size()-1,capacity,position1,distance);
	
	for(int i=0;i<position1.size();i++)
	{
		cout<<position1[i]<<endl;
	}
	
	cout<<"distance"<<distance<<endl;
	
	
	
	
	
	
	
	cout<<"end"<<endl;
	
	/*
	cout<<CapacityCheck(0 , 3 , capacity ,FoodInfo);
	cout<<CapacityCheck(1 , 3 , capacity ,FoodInfo);
	cout<<CapacityCheck(2 , 3 , capacity ,FoodInfo);
	cout<<CapacityCheck(3 , 3 , capacity ,FoodInfo);
	
	cout<<endl;
	cout<<dist2origin(0, FoodInfo)<<endl;
	cout<<dist2origin(1, FoodInfo)<<endl;
	cout<<dist2origin(2, FoodInfo)<<endl;
	cout<<dist2origin(3, FoodInfo)<<endl;
	
	cout<<endl;
	
	//cout<<dist(0, 0, FoodInfo)<<endl;
	//c//out<<dist(0, 1, FoodInfo)<<endl;
	//cout<<dist(1, 2, FoodInfo)<<endl;
	
	//cout<<"asd"<<dist(0, 1, FoodInfo)+dist(1, 2, FoodInfo)+dist(2, 3, FoodInfo)<<endl;
	
	
	*/
	//cout<<dist2origin(1, FoodInfo);
	
}
Example #5
0
bool Network::ProcPacket()
{
	if( _client == NULL )
	{
		return FALSE;
	}

	Sleep(30);

	Packet* p;
	p = _client->Receive();

	if (p==0)
		return FALSE;

	RakNet::BitStream inStream( p->data, p->length, false );

	unsigned char packetIdentifier;
	inStream.Read( packetIdentifier );

	switch (packetIdentifier)
	{
	case S2CH_LOGIN_RES:
		{
			// 패킷 읽기
			int isSuccessAuth;
			inStream.Read( isSuccessAuth );

			int isHost;
			inStream.Read( isHost );

			int userNo;
			inStream.Read( userNo );
			
			// 데이터 저장
			Network::GetInstance()._isSuccessAuth = isSuccessAuth;
			Network::GetInstance()._isHost = isHost;
			_myUserNo = userNo;
		}
		break;

	case S2H_GET_USERINFO_LIST_RES:
		{
			// 기존 데이터 초기화
			_userList.clear();

			// 패킷 읽기
			int count = 0;
			inStream.Read( count );

			for( int num = 0; num < count; num++ )
			{
				UserInfo userInfo;
				inStream.Read( userInfo._userNo );
				inStream.Read( userInfo._userName );
				inStream.Read( userInfo._age );
				inStream.Read( userInfo._sex );
				inStream.Read( userInfo._tall );
				inStream.Read( userInfo._weight );
				inStream.Read( userInfo._blood );
				inStream.Read( userInfo._tel );
				inStream.Read( userInfo._pic );
				_userList.push_back( userInfo );
			}

			// 데이터 갱신
			return TRUE;
		}
		break;
	case S2CH_GET_USERDATA_LIST_RES:
		{
			// 기존 데이터 초기화
			_userDataList.clear();

			// 패킷 읽기
			int count = 0;
			inStream.Read( count );

			for( int num = 0; num < count; num++ )
			{
				UserData userData;
				inStream.Read( userData._year );
				inStream.Read( userData._month );
				inStream.Read( userData._day );
				inStream.Read( userData._hour );
				inStream.Read( userData._min );
				inStream.Read( userData._value );
				inStream.Read( userData._temp );
				_userDataList.push_back( userData );
			}

			// 데이터 갱신
			return TRUE;
		}
		break;
	case S2H_CLIENT_DATA_RES:
		{
			// 패킷 읽기
			int userNo = 0;
			inStream.Read( userNo );

			int count = 0;
			inStream.Read( count );

			DataList dataList;
			for( int num = 0; num < count; num++ )
			{
				PacketData data;
				inStream.Read( data );
				dataList.push_back( data );
			}

			// 기존 데이터 초기화
			DataList & buf = _dataMap[ userNo ];
			buf.clear();

			// 데이터 갱신
			_dataMap[ userNo ] = dataList;
		}
		break;
	default:
		{
			
		}
		break;
	}

	_client->DeallocatePacket(p);
}