예제 #1
0
파일: Channel.cpp 프로젝트: ADTRAN/ipfixcol
void Channel::removeSource(Channel *channel)
{
	if (m_sources.find(channel) == m_sources.end()) {
		return;
	}

	m_sources.erase(channel);
	updateNodeData();
}
예제 #2
0
파일: Channel.cpp 프로젝트: ADTRAN/ipfixcol
void Channel::addSource(Channel *channel)
{
	if (m_sources.find(channel) != m_sources.end()) {
		return;
	}

	m_sources.insert(channel);
	updateNodeData();
}
예제 #3
0
파일: Channel.cpp 프로젝트: ADTRAN/ipfixcol
void Channel::setNode(pugi::xml_node node)
{
	m_node = node;

	if (!m_node.child("sources")) {
		m_node.append_child("sources");
	}

	if (!m_node.child("filter")) {
		m_node.append_child("filter");
	}

	if (!m_node.attribute("name")) {
		m_node.append_attribute("name");
	}

	updateNodeData();
}
예제 #4
0
파일: Channel.cpp 프로젝트: ADTRAN/ipfixcol
void Channel::setName(std::string name)
{
	m_name = name;
	updateNodeData();
}
예제 #5
0
파일: Channel.cpp 프로젝트: ADTRAN/ipfixcol
void Channel::setFilter(std::string filter)
{
	m_filter = filter;
	updateNodeData();
}
예제 #6
0
void EDIProcessCarOnExternalRoad(CONTEXT context, EDI_EXT_ROAD * workingSection, bool goingIn, uint posInLine, bool isLeft)
{
#ifdef DEBUG_BUILD
	const void * a = workingSection;
	const bool b = goingIn, d = isLeft;
	const uint c = posInLine;
#endif

	CAR * currentCar = GET_CAR(workingSection, goingIn, posInLine, isLeft);
	if(!EDICarShouldMove(currentCar, UINT_MAX))
		return;
	
#ifdef DEBUG_BUILD
	printf("Processing %p %d %u %d -> %p\n", a, b, c, d, currentCar);
#endif
	
	uint oldPosInLine = posInLine;
	const CAR backupCar = *currentCar;
	
	for(byte speed = currentCar->speed; speed > 0; --speed)
	{
		//The car is getting out \o/
		if(!goingIn && posInLine == 0)
		{
			EDIRemoveCarFromContext(context, currentCar);
			break;
		}
		
		else if(goingIn && posInLine == NB_SLOTS_BORDER - 1)
		{
			const byte entrySlots[4] = ENTRY_SLOTS;
			
			if(EDIIsNodeSlotAvailable(context->EDI.node, entrySlots[currentCar->context.section], isLeft))
			{
				currentCar->context.index = entrySlots[currentCar->context.section] - isLeft;
				currentCar->context.section = SECTION_NODE;
				currentCar->context.onLeftRoad = false;

				updateNodeData(currentCar);
				
#ifdef DEBUG_BUILD
				if(GET_CAR(workingSection, goingIn, oldPosInLine, isLeft) != currentCar)
				{
					printf("Trying to get a car to enter from an empty slot? WTF?!\n");
					break;
				}
				
				printf("[%d] Leaving the external road\n", currentCar->ID);
#endif

				if(!EDITransitionCars(&GET_CAR(workingSection, goingIn, oldPosInLine, isLeft), &GET_CAR_NODE(context->EDI.node, currentCar->context.index, isLeft)))
					currentCar->context = backupCar.context;
				else
					context->rendering.sorted = false;
				
#ifdef DEBUG_BUILD
				if(GET_CAR(workingSection, goingIn, oldPosInLine, isLeft) != NULL)
				{
					printf("Failed to move the car! WTFH? Reexecuting the line to tracing\n");
					if(!EDITransitionCars(&GET_CAR(workingSection, goingIn, oldPosInLine, isLeft), &GET_CAR_NODE(context->EDI.node, currentCar->context.index, isLeft)))
						currentCar->context = backupCar.context;
				}
#endif
			}
			
			break;
		}
		
		else
		{
			if(goingIn)
				++posInLine;
			else
				--posInLine;
			
			for(byte flag = 0; flag < 2; ++flag)
			{
				if(EDIIsExternalSlotAvailable(workingSection, goingIn, posInLine, flag))
				{
					if(EDITransitionCars(&GET_CAR(workingSection, goingIn, oldPosInLine, isLeft), &GET_CAR(workingSection, goingIn, posInLine, flag)))
					{
#ifdef DEBUG_BUILD
						printf("	Moved to %d %u %d %p %p\n", goingIn, posInLine, flag, GET_CAR(workingSection, goingIn, oldPosInLine, isLeft), GET_CAR(workingSection, goingIn, posInLine, flag));
#endif

						currentCar->context.onLeftRoad = flag;
						currentCar->context.index = posInLine & 0xffff;
						oldPosInLine = posInLine;
						isLeft = flag;
					}
					else
					{
						context->rendering.sorted = false;

#ifdef DEBUG_BUILD
						printf("	Failed at moving to %d %u %d %p %p?!\n", goingIn, posInLine, flag, GET_CAR(workingSection, goingIn, oldPosInLine, isLeft), GET_CAR(workingSection, goingIn, posInLine, flag));
#endif
					}

					break;
				}
			}
		}
	}
}
예제 #7
0
bool EDIProcessCarInNode(CONTEXT context, uint posInLine, bool isLeft, uint _currentSession)
{
	CAR * currentCar = GET_CAR_NODE(context->EDI.node, posInLine, isLeft);
	if(!EDICarShouldMove(currentCar, _currentSession))
		return false;
	else
		currentCar->context.session = _currentSession;
	
	//Okay, start processing
	const uint oldPosInLine = posInLine++;
	
	if(currentCar->context.onLeftRoad)
	{
		while(EDIIsSlotReservedForExternalRing(posInLine))
			++posInLine;
	}
	
	posInLine %= NB_SLOTS_NODE;
	
	const bool inLastQuarter = EDIIsCarInQuarterBeforeExit(currentCar->context.index, currentCar->direction), isInFrontOfExit = EDIIsCarInFrontOfExit(oldPosInLine & 0xff, currentCar->direction);
	bool wantToGoToLeft = !inLastQuarter, gotOut = false;
	const CAR backupCar = *currentCar;
	
	//So, in the node, there is couple of scenarios:
	//	1. We just entered, we try to get in the internal road (shorter, 4 less slots than the external ring)
	//	2. We try to get in the external road when getting in the last quarter to get out easily
	//	3. We are in front of the exit
	//		1. We are in the external road, we just get out
	//		2. We are still in the internal road, we try really hard to get out
	//		3. If the road is really too crowded, or the exit unavailable, ¯\_(ツ)_/¯, we make one more turn
	
	if(isInFrontOfExit && isLeft && EDIIsNodeSlotAvailableFullCheck(context->EDI.node, oldPosInLine, wantToGoToLeft))
	{
#ifdef DEBUG_BUILD
		printf("[%d]: Successfully steared toward the external ring\n", currentCar->ID);
#endif
	}
	
	else if(isInFrontOfExit && !isLeft && EDIIsExternalSlotAvailable(&context->EDI.externalRoads[currentCar->direction], false, NB_SLOTS_BORDER - 1, EDIIsCarOnLastStepExit(oldPosInLine & 0xff, currentCar->direction)))
	{
		//\o/
#ifdef DEBUG_BUILD
		printf("[%d]: Successfully got out of the ring\n", currentCar->ID);
#endif
		gotOut = true;
	}
	
	//Perfect case?
	else if(EDIIsNodeSlotAvailableFullCheck(context->EDI.node, posInLine, wantToGoToLeft))
	{
		//ᕕ( ᐛ )ᕗ
#ifdef DEBUG_BUILD
		printf("[%d]: Successfully went to our optimal goal\n", currentCar->ID);
#endif
	}
	
	//Can we go forward, even on the wrong line?
	else if(EDIIsNodeSlotAvailableFullCheck(context->EDI.node, posInLine, !wantToGoToLeft))
	{
		wantToGoToLeft = !wantToGoToLeft;
#ifdef DEBUG_BUILD
		printf("[%d]: Changing line forward\n", currentCar->ID);
#endif
	}

	//No space to go forward, but can we change line?
	else if(EDIIsNodeSlotAvailableFullCheck(context->EDI.node, oldPosInLine, wantToGoToLeft))
	{
		posInLine = oldPosInLine;
#ifdef DEBUG_BUILD
		printf("[%d]: Changing line\n", currentCar->ID);
#endif
	}

	//Nope :(
	else
	{
		return true;
	}
	
	if(gotOut)
	{
		currentCar->context.index = NB_SLOTS_BORDER - 1;
		currentCar->context.section = currentCar->direction;
		currentCar->context.onLeftRoad = EDIIsCarOnLastStepExit(oldPosInLine & 0xff, currentCar->direction);
		
		EDI_EXT_ROAD * section = &context->EDI.externalRoads[currentCar->direction];
		
		if(!EDITransitionCars(&GET_CAR_NODE(context->EDI.node, oldPosInLine, isLeft), &GET_CAR(section, false, currentCar->context.index, currentCar->context.onLeftRoad)))
			currentCar->context = backupCar.context;
		else
			context->rendering.sorted = false;
	}
	else
	{
		currentCar->context.index = posInLine & 0xff;
		currentCar->context.onLeftRoad = wantToGoToLeft;
		
		updateNodeData(currentCar);
		
		if(!EDITransitionCars(&GET_CAR_NODE(context->EDI.node, oldPosInLine, isLeft), &GET_CAR_NODE(context->EDI.node, currentCar->context.index, wantToGoToLeft)))
			currentCar->context = backupCar.context;
		else
			context->rendering.sorted = false;
	}
	
#ifdef DEBUG_BUILD
	printCar(currentCar);
#endif

	return false;
}