<commit_before>#include "GraphicsRendererSystem.h"
#include <RenderInterface.h>
#include "GraphicsBackendSystem.h"
#include <GraphicsWrapper.h>
#include <RenderStateEnums.h>
#include "ShadowSystem.h"
#include <GPUTimer.h>
#include <AntTweakBarWrapper.h>
#include "ParticleRenderSystem.h"
#include "ClientStateSystem.h"
#include "MenuSystem.h"
#include "TimerSystem.h"

GraphicsRendererSystem::GraphicsRendererSystem(GraphicsBackendSystem* p_graphicsBackend,
											   ShadowSystem*	p_shadowSystem,
											   RenderInterface* p_mesh,
											   RenderInterface* p_libRocket,
											   RenderInterface* p_particle,
											   RenderInterface* p_antTweakBar,
											   RenderInterface* p_light)
											   : EntitySystem(
											   SystemType::GraphicsRendererSystem){
	m_backend				= p_graphicsBackend;
	m_shadowSystem			= p_shadowSystem;
	m_meshRenderer			= p_mesh;
	m_libRocketRenderSystem = p_libRocket;
	m_particleRenderSystem	= p_particle;
	m_antTweakBarSystem		= p_antTweakBar;
	m_lightRenderSystem		= p_light;
	m_shouldRender			= true;
	m_enteredIngamePreviousFrame = false;

	m_activeShadows			= new int[MAXSHADOWS];
	m_shadowViewProjections = new AglMatrix[MAXSHADOWS];

	m_profiles.push_back(GPUTimerProfile("MESH"));
	m_profiles.push_back(GPUTimerProfile("LIGH"));
	m_profiles.push_back(GPUTimerProfile("SSAO"));
	m_profiles.push_back(GPUTimerProfile("DOF"));
	m_profiles.push_back(GPUTimerProfile("COMP"));
	m_profiles.push_back(GPUTimerProfile("PART"));
	m_profiles.push_back(GPUTimerProfile("GUI"));
	m_profiles.push_back(GPUTimerProfile("TOTAL"));

	clearShadowStuf();
}
GraphicsRendererSystem::~GraphicsRendererSystem(){
	delete[] m_shadowViewProjections;
	delete[] m_activeShadows;
}
void GraphicsRendererSystem::initialize(){
	for (unsigned int i=0;i < NUMRENDERINGPASSES; i++)
	{

		string variableName = m_profiles[i].profile;
		AntTweakBarWrapper::getInstance()->addReadOnlyVariable(
			AntTweakBarWrapper::MEASUREMENT,
			variableName.c_str(),TwType::TW_TYPE_DOUBLE,
			&m_profiles[i].renderingTime,"group=GPU");

		variableName +=" Spike";
		AntTweakBarWrapper::getInstance()->addReadOnlyVariable(
			AntTweakBarWrapper::MEASUREMENT,
			variableName.c_str(),TwType::TW_TYPE_DOUBLE,
			&m_profiles[i].renderingSpike,"group='GPU Extra'");

		variableName = m_profiles[i].profile;
		variableName += " Avg";
		AntTweakBarWrapper::getInstance()->addReadOnlyVariable(
			AntTweakBarWrapper::MEASUREMENT,
			variableName.c_str(),TwType::TW_TYPE_DOUBLE,
			&m_profiles[i].renderingAverage,"group='GPU Extra'");

		m_backend->getGfxWrapper()->getGPUTimer()->addProfile(m_profiles[i].profile);
	}
}
void GraphicsRendererSystem::process(){

	m_wrapper = m_backend->getGfxWrapper();

	auto timerSystem = static_cast<TimerSystem*>(m_world->getSystem(SystemType::TimerSystem));
	if(timerSystem->checkTimeInterval(TimerIntervals::EverySecond)){
		for (unsigned int i= 0; i < NUMRENDERINGPASSES; i++)
		{
			m_profiles[i].calculateAvarage();
		}

	}

	auto gameState = static_cast<ClientStateSystem*>(
		m_world->getSystem(SystemType::ClientStateSystem));

	if( m_shouldRender){
		renderTheScene();
	}
	if(m_enteredIngamePreviousFrame){
		auto menuSystem = static_cast<MenuSystem*>(m_world->getSystem(SystemType::MenuSystem));
		menuSystem->endLoadingState();
		m_shouldRender = true;
		m_enteredIngamePreviousFrame = false;
	}
	if(!m_shouldRender && gameState->getStateDelta(GameStates::INGAME) == EnumGameDelta::NOTCHANGED){
		m_enteredIngamePreviousFrame = true;
	}
	else if(gameState->getStateDelta(GameStates::LOADING) == EnumGameDelta::EXITTHISFRAME){
		m_shouldRender = false;
	}
}

void GraphicsRendererSystem::renderTheScene()
{
	/*
	//Shadows
	//m_wrapper->getGPUTimer()->Start(m_profiles[SHADOW].profile);
	clearShadowStuf();
	//Fill the shadow view projections
	for (unsigned int i = 0; i < m_shadowSystem->getNumberOfShadowCameras(); i++){
		m_activeShadows[m_shadowSystem->getShadowIdx(i)] = 1;
		m_shadowViewProjections[m_shadowSystem->getShadowIdx(i)] =
			m_shadowSystem->getViewProjection(i);
	}
	*/
	/*
	initShadowPass();
	for(unsigned int i = 0; i < MAXSHADOWS; i++){
		if(m_activeShadows[i] != -1){
			m_wrapper->setShadowMapAsRenderTarget(i);
			//m_wrapper->setActiveShadow(i);
			m_meshRenderer->render();
		}
	}
	endShadowPass();
	*/
	//m_wrapper->getGPUTimer()->Stop(m_profiles[SHADOW].profile);
	m_wrapper->clearRenderTargets();

	// Meshes
	m_wrapper->getGPUTimer()->Start(m_profiles[MESH].profile);
	initMeshPass();
	m_meshRenderer->render();
	endMeshPass();
	m_wrapper->getGPUTimer()->Stop(m_profiles[MESH].profile);

	// Lights
	m_wrapper->getGPUTimer()->Start(m_profiles[LIGHT].profile);
	initLightPass();
	m_lightRenderSystem->render();
	endLightPass();
	m_wrapper->getGPUTimer()->Stop(m_profiles[LIGHT].profile);

	//SSAO
	m_wrapper->getGPUTimer()->Start(m_profiles[SSAO].profile);
	beginSsao();
	m_wrapper->generateSsao();
	endSsao();
	m_wrapper->getGPUTimer()->Stop(m_profiles[SSAO].profile);

	// DoF generation pass
	m_wrapper->getGPUTimer()->Start(m_profiles[DOF].profile);
	beginDofGenerationPass();
	m_wrapper->generateDof();
	endDofGenerationPass();
	m_wrapper->getGPUTimer()->Stop(m_profiles[DOF].profile);

	//Compose
	m_wrapper->getGPUTimer()->Start(m_profiles[COMPOSE].profile);
	initComposePass();
	m_wrapper->renderComposeStage();
	endComposePass();
	m_wrapper->getGPUTimer()->Stop(m_profiles[COMPOSE].profile);

	//Particles
	m_wrapper->getGPUTimer()->Start(m_profiles[PARTICLE].profile);
	initParticlePass();
	//renderParticles();
	endParticlePass();
	m_wrapper->getGPUTimer()->Stop(m_profiles[PARTICLE].profile);

	//GUI
	m_wrapper->getGPUTimer()->Start(m_profiles[GUI].profile);
	initGUIPass();
	m_libRocketRenderSystem->render();
	m_antTweakBarSystem->render();
	endGUIPass();
	m_wrapper->getGPUTimer()->Stop(m_profiles[GUI].profile);

	flipBackbuffer();

	updateTimers();
}

void GraphicsRendererSystem::initShadowPass(){
	m_wrapper->setRasterizerStateSettings(RasterizerState::FILLED_CW_FRONTCULL);
	m_wrapper->setBlendStateSettings(BlendState::DEFAULT);
	//m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);
	m_wrapper->setViewportToShadowMapSize();
	m_wrapper->setRenderingShadows();
	m_wrapper->setShadowViewProjections(m_shadowViewProjections);
}

void GraphicsRendererSystem::endShadowPass(){
	m_wrapper->resetViewportToStdSize();
	m_wrapper->stopedRenderingShadows();
	//m_wrapper->unmapPerShadowBuffer();
}

void GraphicsRendererSystem::initMeshPass(){
	m_wrapper->mapSceneInfo();
	m_wrapper->setRasterizerStateSettings(RasterizerState::DEFAULT);
	m_wrapper->setBlendStateSettings(BlendState::DEFAULT);
	//m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);
	m_wrapper->setBaseRenderTargets();
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);

}

void GraphicsRendererSystem::endMeshPass(){
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);
}

void GraphicsRendererSystem::initLightPass(){
	m_wrapper->setRasterizerStateSettings(
		//RasterizerState::WIREFRAME_NOCULL, false); // For debug /ML
		RasterizerState::FILLED_CW_FRONTCULL, false);
	m_wrapper->setBlendStateSettings(BlendState::LIGHT);
	m_wrapper->setLightRenderTargets();
	//m_wrapper->mapDeferredBaseToShader();
	m_wrapper->mapDepthAndNormal();
	//m_wrapper->mapShadows( m_activeShadows );
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);

}

void GraphicsRendererSystem::endLightPass(){
	m_wrapper->setRasterizerStateSettings(RasterizerState::DEFAULT);
	m_wrapper->setBlendStateSettings(BlendState::DEFAULT);
}

void GraphicsRendererSystem::beginSsao()
{
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLESTRIP);
	m_wrapper->setBlendStateSettings(BlendState::SSAO);
	m_wrapper->setRasterizerStateSettings(
		RasterizerState::FILLED_NOCULL_NOCLIP, false);
}

void GraphicsRendererSystem::endSsao()
{
	m_wrapper->setRasterizerStateSettings(RasterizerState::DEFAULT);
	m_wrapper->setBlendStateSettings(BlendState::DEFAULT);
	m_wrapper->unmapDepthAndNormal();
	//m_wrapper->unmapShadows(m_activeShadows);

}

void GraphicsRendererSystem::beginDofGenerationPass()
{
	m_wrapper->setViewportToLowRes();
	m_wrapper->setPrimitiveTopology( PrimitiveTopology::TRIANGLESTRIP );
	m_wrapper->setBlendStateSettings( BlendState::OVERWRITE );
	m_wrapper->setDofRenderTargets();
	//m_wrapper->setComposedRenderTargetWithNoDepthStencil();
	m_wrapper->mapGbuffers();
}

void GraphicsRendererSystem::endDofGenerationPass()
{
	m_wrapper->unmapGbuffers();
	m_wrapper->resetViewportToStdSize();

}

void GraphicsRendererSystem::initComposePass()
{
	m_wrapper->setRasterizerStateSettings(
		RasterizerState::DEFAULT, false);
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLESTRIP);
	m_wrapper->setComposedRenderTargetWithNoDepthStencil();
	m_wrapper->mapGbuffers();
	m_wrapper->mapDofBuffers();
	m_wrapper->mapDepth();
}

void GraphicsRendererSystem::endComposePass()
{
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);
	//m_wrapper->unmapVariousStagesAfterCompose();
	m_wrapper->unmapDofBuffers();
	m_wrapper->unmapGbuffers();
	m_wrapper->unmapDepth();
}

void GraphicsRendererSystem::initParticlePass(){
	m_wrapper->setParticleRenderState();
	//m_wrapper->setBlendStateSettings(BlendState::PARTICLE);
	m_wrapper->setBlendStateSettings(BlendState::ADDITIVE);
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::POINTLIST);
}

void GraphicsRendererSystem::renderParticles()
{
	// A ugly way to be able to call the different rendering functions. Needs refactoring /ML.
	ParticleRenderSystem* psRender = static_cast<ParticleRenderSystem*>( m_particleRenderSystem );

	for( int i=0; i<AglParticleSystemHeader::AglBlendMode_CNT; i++ ) {
		for( int j=0; j<AglParticleSystemHeader::AglRasterizerMode_CNT; j++ )
		{
			AglParticleSystemHeader::AglBlendMode blend = (AglParticleSystemHeader::AglBlendMode)i;
			AglParticleSystemHeader::AglRasterizerMode rast = (AglParticleSystemHeader::AglRasterizerMode)j;

			m_wrapper->setRasterizerStateSettings( psRender->rasterizerStateFromAglRasterizerMode(rast) );
			m_wrapper->setBlendStateSettings( psRender->blendStateFromAglBlendMode(blend) );
			psRender->render( blend, rast );
		}
	}
}

void GraphicsRendererSystem::endParticlePass(){
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);
	m_wrapper->setBlendStateSettings(BlendState::DEFAULT);
	m_wrapper->setComposedRenderTargetWithNoDepthStencil();
}

void GraphicsRendererSystem::initGUIPass(){
	m_wrapper->setBlendStateSettings(BlendState::ALPHA);
}

void GraphicsRendererSystem::endGUIPass(){
	m_wrapper->setBlendStateSettings(BlendState::DEFAULT);
}

void GraphicsRendererSystem::flipBackbuffer(){
	m_wrapper->flipBackBuffer();
}

void GraphicsRendererSystem::clearShadowStuf()
{
	for(int i = 0; i < MAXSHADOWS; i++){
		m_activeShadows[i] = -1;
		m_shadowViewProjections[i] = AglMatrix::identityMatrix();
	}
}

void GraphicsRendererSystem::updateTimers()
{
	double total = 0;
	GPUTimer* timer = m_wrapper->getGPUTimer();

	for(unsigned int i = 0; i < NUMRENDERINGPASSES-1; i++){
		m_profiles[i].pushNewTime(timer->getTheTimeAndReset(m_profiles[i].profile));
		total += m_profiles[i].renderingTime;
	}
	m_profiles[TOTAL].pushNewTime(total);
	m_wrapper->getGPUTimer()->tick();
}<commit_msg>Particle systems now visible again<commit_after>#include "GraphicsRendererSystem.h"
#include <RenderInterface.h>
#include "GraphicsBackendSystem.h"
#include <GraphicsWrapper.h>
#include <RenderStateEnums.h>
#include "ShadowSystem.h"
#include <GPUTimer.h>
#include <AntTweakBarWrapper.h>
#include "ParticleRenderSystem.h"
#include "ClientStateSystem.h"
#include "MenuSystem.h"
#include "TimerSystem.h"

GraphicsRendererSystem::GraphicsRendererSystem(GraphicsBackendSystem* p_graphicsBackend,
											   ShadowSystem*	p_shadowSystem,
											   RenderInterface* p_mesh,
											   RenderInterface* p_libRocket,
											   RenderInterface* p_particle,
											   RenderInterface* p_antTweakBar,
											   RenderInterface* p_light)
											   : EntitySystem(
											   SystemType::GraphicsRendererSystem){
	m_backend				= p_graphicsBackend;
	m_shadowSystem			= p_shadowSystem;
	m_meshRenderer			= p_mesh;
	m_libRocketRenderSystem = p_libRocket;
	m_particleRenderSystem	= p_particle;
	m_antTweakBarSystem		= p_antTweakBar;
	m_lightRenderSystem		= p_light;
	m_shouldRender			= true;
	m_enteredIngamePreviousFrame = false;

	m_activeShadows			= new int[MAXSHADOWS];
	m_shadowViewProjections = new AglMatrix[MAXSHADOWS];

	m_profiles.push_back(GPUTimerProfile("MESH"));
	m_profiles.push_back(GPUTimerProfile("LIGH"));
	m_profiles.push_back(GPUTimerProfile("SSAO"));
	m_profiles.push_back(GPUTimerProfile("DOF"));
	m_profiles.push_back(GPUTimerProfile("COMP"));
	m_profiles.push_back(GPUTimerProfile("PART"));
	m_profiles.push_back(GPUTimerProfile("GUI"));
	m_profiles.push_back(GPUTimerProfile("TOTAL"));

	clearShadowStuf();
}
GraphicsRendererSystem::~GraphicsRendererSystem(){
	delete[] m_shadowViewProjections;
	delete[] m_activeShadows;
}
void GraphicsRendererSystem::initialize(){
	for (unsigned int i=0;i < NUMRENDERINGPASSES; i++)
	{

		string variableName = m_profiles[i].profile;
		AntTweakBarWrapper::getInstance()->addReadOnlyVariable(
			AntTweakBarWrapper::MEASUREMENT,
			variableName.c_str(),TwType::TW_TYPE_DOUBLE,
			&m_profiles[i].renderingTime,"group=GPU");

		variableName +=" Spike";
		AntTweakBarWrapper::getInstance()->addReadOnlyVariable(
			AntTweakBarWrapper::MEASUREMENT,
			variableName.c_str(),TwType::TW_TYPE_DOUBLE,
			&m_profiles[i].renderingSpike,"group='GPU Extra'");

		variableName = m_profiles[i].profile;
		variableName += " Avg";
		AntTweakBarWrapper::getInstance()->addReadOnlyVariable(
			AntTweakBarWrapper::MEASUREMENT,
			variableName.c_str(),TwType::TW_TYPE_DOUBLE,
			&m_profiles[i].renderingAverage,"group='GPU Extra'");

		m_backend->getGfxWrapper()->getGPUTimer()->addProfile(m_profiles[i].profile);
	}
}
void GraphicsRendererSystem::process(){

	m_wrapper = m_backend->getGfxWrapper();

	auto timerSystem = static_cast<TimerSystem*>(m_world->getSystem(SystemType::TimerSystem));
	if(timerSystem->checkTimeInterval(TimerIntervals::EverySecond)){
		for (unsigned int i= 0; i < NUMRENDERINGPASSES; i++)
		{
			m_profiles[i].calculateAvarage();
		}

	}

	auto gameState = static_cast<ClientStateSystem*>(
		m_world->getSystem(SystemType::ClientStateSystem));

	if( m_shouldRender){
		renderTheScene();
	}
	if(m_enteredIngamePreviousFrame){
		auto menuSystem = static_cast<MenuSystem*>(m_world->getSystem(SystemType::MenuSystem));
		menuSystem->endLoadingState();
		m_shouldRender = true;
		m_enteredIngamePreviousFrame = false;
	}
	if(!m_shouldRender && gameState->getStateDelta(GameStates::INGAME) == EnumGameDelta::NOTCHANGED){
		m_enteredIngamePreviousFrame = true;
	}
	else if(gameState->getStateDelta(GameStates::LOADING) == EnumGameDelta::EXITTHISFRAME){
		m_shouldRender = false;
	}
}

void GraphicsRendererSystem::renderTheScene()
{
	/*
	//Shadows
	//m_wrapper->getGPUTimer()->Start(m_profiles[SHADOW].profile);
	clearShadowStuf();
	//Fill the shadow view projections
	for (unsigned int i = 0; i < m_shadowSystem->getNumberOfShadowCameras(); i++){
		m_activeShadows[m_shadowSystem->getShadowIdx(i)] = 1;
		m_shadowViewProjections[m_shadowSystem->getShadowIdx(i)] =
			m_shadowSystem->getViewProjection(i);
	}
	*/
	/*
	initShadowPass();
	for(unsigned int i = 0; i < MAXSHADOWS; i++){
		if(m_activeShadows[i] != -1){
			m_wrapper->setShadowMapAsRenderTarget(i);
			//m_wrapper->setActiveShadow(i);
			m_meshRenderer->render();
		}
	}
	endShadowPass();
	*/
	//m_wrapper->getGPUTimer()->Stop(m_profiles[SHADOW].profile);
	m_wrapper->clearRenderTargets();

	// Meshes
	m_wrapper->getGPUTimer()->Start(m_profiles[MESH].profile);
	initMeshPass();
	m_meshRenderer->render();
	endMeshPass();
	m_wrapper->getGPUTimer()->Stop(m_profiles[MESH].profile);

	// Lights
	m_wrapper->getGPUTimer()->Start(m_profiles[LIGHT].profile);
	initLightPass();
	m_lightRenderSystem->render();
	endLightPass();
	m_wrapper->getGPUTimer()->Stop(m_profiles[LIGHT].profile);

	//SSAO
	m_wrapper->getGPUTimer()->Start(m_profiles[SSAO].profile);
	beginSsao();
	m_wrapper->generateSsao();
	endSsao();
	m_wrapper->getGPUTimer()->Stop(m_profiles[SSAO].profile);

	// DoF generation pass
	m_wrapper->getGPUTimer()->Start(m_profiles[DOF].profile);
	beginDofGenerationPass();
	m_wrapper->generateDof();
	endDofGenerationPass();
	m_wrapper->getGPUTimer()->Stop(m_profiles[DOF].profile);

	//Compose
	m_wrapper->getGPUTimer()->Start(m_profiles[COMPOSE].profile);
	initComposePass();
	m_wrapper->renderComposeStage();
	endComposePass();
	m_wrapper->getGPUTimer()->Stop(m_profiles[COMPOSE].profile);

	//Particles
	m_wrapper->getGPUTimer()->Start(m_profiles[PARTICLE].profile);
	initParticlePass();
	renderParticles();
	endParticlePass();
	m_wrapper->getGPUTimer()->Stop(m_profiles[PARTICLE].profile);

	//GUI
	m_wrapper->getGPUTimer()->Start(m_profiles[GUI].profile);
	initGUIPass();
	m_libRocketRenderSystem->render();
	m_antTweakBarSystem->render();
	endGUIPass();
	m_wrapper->getGPUTimer()->Stop(m_profiles[GUI].profile);

	flipBackbuffer();

	updateTimers();
}

void GraphicsRendererSystem::initShadowPass(){
	m_wrapper->setRasterizerStateSettings(RasterizerState::FILLED_CW_FRONTCULL);
	m_wrapper->setBlendStateSettings(BlendState::DEFAULT);
	//m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);
	m_wrapper->setViewportToShadowMapSize();
	m_wrapper->setRenderingShadows();
	m_wrapper->setShadowViewProjections(m_shadowViewProjections);
}

void GraphicsRendererSystem::endShadowPass(){
	m_wrapper->resetViewportToStdSize();
	m_wrapper->stopedRenderingShadows();
	//m_wrapper->unmapPerShadowBuffer();
}

void GraphicsRendererSystem::initMeshPass(){
	m_wrapper->mapSceneInfo();
	m_wrapper->setRasterizerStateSettings(RasterizerState::DEFAULT);
	m_wrapper->setBlendStateSettings(BlendState::DEFAULT);
	//m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);
	m_wrapper->setBaseRenderTargets();
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);

}

void GraphicsRendererSystem::endMeshPass(){
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);
}

void GraphicsRendererSystem::initLightPass(){
	m_wrapper->setRasterizerStateSettings(
		//RasterizerState::WIREFRAME_NOCULL, false); // For debug /ML
		RasterizerState::FILLED_CW_FRONTCULL, false);
	m_wrapper->setBlendStateSettings(BlendState::LIGHT);
	m_wrapper->setLightRenderTargets();
	//m_wrapper->mapDeferredBaseToShader();
	m_wrapper->mapDepthAndNormal();
	//m_wrapper->mapShadows( m_activeShadows );
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);

}

void GraphicsRendererSystem::endLightPass(){
	m_wrapper->setRasterizerStateSettings(RasterizerState::DEFAULT);
	m_wrapper->setBlendStateSettings(BlendState::DEFAULT);
}

void GraphicsRendererSystem::beginSsao()
{
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLESTRIP);
	m_wrapper->setBlendStateSettings(BlendState::SSAO);
	m_wrapper->setRasterizerStateSettings(
		RasterizerState::FILLED_NOCULL_NOCLIP, false);
}

void GraphicsRendererSystem::endSsao()
{
	m_wrapper->setRasterizerStateSettings(RasterizerState::DEFAULT);
	m_wrapper->setBlendStateSettings(BlendState::DEFAULT);
	m_wrapper->unmapDepthAndNormal();
	//m_wrapper->unmapShadows(m_activeShadows);

}

void GraphicsRendererSystem::beginDofGenerationPass()
{
	m_wrapper->setViewportToLowRes();
	m_wrapper->setPrimitiveTopology( PrimitiveTopology::TRIANGLESTRIP );
	m_wrapper->setBlendStateSettings( BlendState::OVERWRITE );
	m_wrapper->setDofRenderTargets();
	//m_wrapper->setComposedRenderTargetWithNoDepthStencil();
	m_wrapper->mapGbuffers();
}

void GraphicsRendererSystem::endDofGenerationPass()
{
	m_wrapper->unmapGbuffers();
	m_wrapper->resetViewportToStdSize();

}

void GraphicsRendererSystem::initComposePass()
{
	m_wrapper->setRasterizerStateSettings(
		RasterizerState::DEFAULT, false);
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLESTRIP);
	m_wrapper->setComposedRenderTargetWithNoDepthStencil();
	m_wrapper->mapGbuffers();
	m_wrapper->mapDofBuffers();
	m_wrapper->mapDepth();
}

void GraphicsRendererSystem::endComposePass()
{
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);
	//m_wrapper->unmapVariousStagesAfterCompose();
	m_wrapper->unmapDofBuffers();
	m_wrapper->unmapGbuffers();
	m_wrapper->unmapDepth();
}

void GraphicsRendererSystem::initParticlePass(){
	m_wrapper->setParticleRenderState();
	//m_wrapper->setBlendStateSettings(BlendState::PARTICLE);
	m_wrapper->setBlendStateSettings(BlendState::ADDITIVE);
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::POINTLIST);
}

void GraphicsRendererSystem::renderParticles()
{
	// A ugly way to be able to call the different rendering functions. Needs refactoring /ML.
	ParticleRenderSystem* psRender = static_cast<ParticleRenderSystem*>( m_particleRenderSystem );

	for( int i=0; i<AglParticleSystemHeader::AglBlendMode_CNT; i++ ) {
		for( int j=0; j<AglParticleSystemHeader::AglRasterizerMode_CNT; j++ )
		{
			AglParticleSystemHeader::AglBlendMode blend = (AglParticleSystemHeader::AglBlendMode)i;
			AglParticleSystemHeader::AglRasterizerMode rast = (AglParticleSystemHeader::AglRasterizerMode)j;

			m_wrapper->setRasterizerStateSettings( psRender->rasterizerStateFromAglRasterizerMode(rast) );
			m_wrapper->setBlendStateSettings( psRender->blendStateFromAglBlendMode(blend) );
			psRender->render( blend, rast );
		}
	}
}

void GraphicsRendererSystem::endParticlePass(){
	m_wrapper->setPrimitiveTopology(PrimitiveTopology::TRIANGLELIST);
	m_wrapper->setBlendStateSettings(BlendState::DEFAULT);
	m_wrapper->setComposedRenderTargetWithNoDepthStencil();
}

void GraphicsRendererSystem::initGUIPass(){
	m_wrapper->setBlendStateSettings(BlendState::ALPHA);
}

void GraphicsRendererSystem::endGUIPass(){
	m_wrapper->setBlendStateSettings(BlendState::DEFAULT);
}

void GraphicsRendererSystem::flipBackbuffer(){
	m_wrapper->flipBackBuffer();
}

void GraphicsRendererSystem::clearShadowStuf()
{
	for(int i = 0; i < MAXSHADOWS; i++){
		m_activeShadows[i] = -1;
		m_shadowViewProjections[i] = AglMatrix::identityMatrix();
	}
}

void GraphicsRendererSystem::updateTimers()
{
	double total = 0;
	GPUTimer* timer = m_wrapper->getGPUTimer();

	for(unsigned int i = 0; i < NUMRENDERINGPASSES-1; i++){
		m_profiles[i].pushNewTime(timer->getTheTimeAndReset(m_profiles[i].profile));
		total += m_profiles[i].renderingTime;
	}
	m_profiles[TOTAL].pushNewTime(total);
	m_wrapper->getGPUTimer()->tick();
}<|endoftext|>


<commit_before>
//
// This source file is part of appleseed.
// Visit http://appleseedhq.net/ for additional information and resources.
//
// This software is released under the MIT license.
//
// Copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited
// Copyright (c) 2014 Francois Beaune, The appleseedhq Organization
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

// Interface header.
#include "scenepickinghandler.h"

// appleseed.studio headers.
#include "mainwindow/project/projectexplorer.h"
#include "utility/mousecoordinatestracker.h"

// appleseed.renderer headers.
#include "renderer/api/bsdf.h"
#include "renderer/api/camera.h"
#include "renderer/api/edf.h"
#include "renderer/api/entity.h"
#include "renderer/api/frame.h"
#include "renderer/api/log.h"
#include "renderer/api/material.h"
#include "renderer/api/object.h"
#include "renderer/api/project.h"
#include "renderer/api/rendering.h"
#include "renderer/api/scene.h"
#include "renderer/api/surfaceshader.h"

// appleseed.foundation headers.
#include "foundation/image/image.h"
#include "foundation/math/vector.h"

// Qt headers.
#include <QComboBox>
#include <QEvent>
#include <QLabel>
#include <QMouseEvent>
#include <QString>
#include <Qt>
#include <QWidget>

// Standard headers.
#include <cassert>
#include <sstream>

using namespace foundation;
using namespace renderer;
using namespace std;

namespace appleseed {
namespace studio {

ScenePickingHandler::ScenePickingHandler(
    QWidget*                        widget,
    QComboBox*                      picking_mode_combo,
    QLabel*                         r_label,
    QLabel*                         g_label,
    QLabel*                         b_label,
    QLabel*                         a_label,
    const MouseCoordinatesTracker&  mouse_tracker,
    const ProjectExplorer&          project_explorer,
    const Project&                  project)
  : m_widget(widget)
  , m_picking_mode_combo(picking_mode_combo)
  , m_r_label(r_label)
  , m_g_label(g_label)
  , m_b_label(b_label)
  , m_a_label(a_label)
  , m_mouse_tracker(mouse_tracker)
  , m_project_explorer(project_explorer)
  , m_project(project)
  , m_enabled(true)
{
    m_widget->installEventFilter(this);

    m_picking_mode_combo->clear();
    m_picking_mode_combo->addItem("Assembly", "assembly");
    m_picking_mode_combo->addItem("Assembly Instance", "assembly_instance");
    m_picking_mode_combo->addItem("Object", "object");
    m_picking_mode_combo->addItem("Object Instance", "object_instance");
    m_picking_mode_combo->addItem("Material", "material");
    m_picking_mode_combo->addItem("Surface Shader", "surface_shader");
    m_picking_mode_combo->addItem("BSDF", "bsdf");
    m_picking_mode_combo->addItem("EDF", "edf");
    m_picking_mode_combo->setCurrentIndex(3);
}

ScenePickingHandler::~ScenePickingHandler()
{
    m_widget->removeEventFilter(this);
}

void ScenePickingHandler::set_enabled(const bool enabled)
{
    m_enabled = enabled;
}

bool ScenePickingHandler::eventFilter(QObject* object, QEvent* event)
{
    if (!m_enabled)
        return QObject::eventFilter(object, event);

    const QMouseEvent* mouse_event = static_cast<QMouseEvent*>(event);

    switch (event->type())
    {
        case QEvent::MouseButtonPress:
            if (mouse_event->button() == Qt::LeftButton &&
                !(mouse_event->modifiers() & (Qt::AltModifier | Qt::ShiftModifier | Qt::ControlModifier)))
            {
                pick(mouse_event->pos());
                return true;
            }
            break;

        case QEvent::MouseMove:
            set_rgb_label(mouse_event->pos());
            break;

        case QEvent::Leave:
            m_r_label->clear();
            m_g_label->clear();
            m_b_label->clear();
            m_a_label->clear();
            break;
    }
    return QObject::eventFilter(object, event);
}

void ScenePickingHandler::set_rgb_label(const QPoint& point) const
{
    Color4f linear_rgba;
    m_project.get_frame()->image().get_pixel(static_cast<size_t>(point.x()), static_cast<size_t>( point.y()), linear_rgba);

    QString red;
    red.sprintf(" %4.3f", linear_rgba.r);
    m_r_label->setText(red);

    QString green;
    green.sprintf(" %4.3f", linear_rgba.g);
    m_g_label->setText(green);

    QString blue;
    blue.sprintf(" %4.3f", linear_rgba.b);
    m_b_label->setText(blue);

    QString alpha;
    alpha.sprintf(" %4.3f", linear_rgba.a);
    m_a_label->setText(alpha);
}

namespace
{
    void print_entity(stringstream& sstr, const char* label, const Entity* entity)
    {
        sstr << label;

        if (entity)
            sstr << "\"" << entity->get_name() << "\" (#" << entity->get_uid() << ")";
        else sstr << "n/a";

        sstr << endl;
    }

    const Entity* get_picked_entity(
        const ScenePicker::PickingResult&   picking_result,
        const QString&                      picking_mode)
    {
        if (picking_mode == "assembly")
            return picking_result.m_assembly;
        else if (picking_mode == "assembly_instance")
            return picking_result.m_assembly_instance;
        else if (picking_mode == "object")
            return picking_result.m_object;
        else if (picking_mode == "object_instance")
            return picking_result.m_object_instance;
        else if (picking_mode == "material")
            return picking_result.m_material;
        else if (picking_mode == "surface_shader")
            return picking_result.m_surface_shader;
        else if (picking_mode == "bsdf")
            return picking_result.m_bsdf;
        else if (picking_mode == "edf")
            return picking_result.m_edf;
        else
        {
            assert(!"Invalid picking mode.");
            return 0;
        }
    }
}

void ScenePickingHandler::pick(const QPoint& point)
{
    if (!m_project.has_trace_context())
    {
        RENDERER_LOG_INFO("the scene must be rendering or must have been rendered at least once for picking to be available.");
        return;
    }

    const Vector2i pix = m_mouse_tracker.widget_to_pixel(point);
    const Vector2d ndc = m_mouse_tracker.widget_to_ndc(point);

    const ScenePicker scene_picker(m_project.get_trace_context());
    const ScenePicker::PickingResult result = scene_picker.pick(ndc);

    stringstream sstr;

    sstr << "picking details:" << endl;
    sstr << "  pixel coords     " << pix.x << ", " << pix.y << endl;
    sstr << "  ndc coords       " << ndc.x << ", " << ndc.y << endl;

    print_entity(sstr, "  camera           ", result.m_camera);
    print_entity(sstr, "  assembly inst.   ", result.m_assembly_instance);
    print_entity(sstr, "  assembly         ", result.m_assembly);
    print_entity(sstr, "  object inst.     ", result.m_object_instance);
    print_entity(sstr, "  object           ", result.m_object);
    print_entity(sstr, "  material         ", result.m_material);
    print_entity(sstr, "  surface shader   ", result.m_surface_shader);
    print_entity(sstr, "  bsdf             ", result.m_bsdf);
    print_entity(sstr, "  edf              ", result.m_edf);

    RENDERER_LOG_INFO("%s", sstr.str().c_str());

    const QString picking_mode =
        m_picking_mode_combo->itemData(m_picking_mode_combo->currentIndex()).value<QString>();

    const Entity* picked_entity = get_picked_entity(result, picking_mode);

    if (picked_entity)
        m_project_explorer.highlight_entity(picked_entity->get_uid());
    else m_project_explorer.clear_highlighting();
}

}   // namespace studio
}   // namespace appleseed
<commit_msg>fixed formatting and eliminated dangerous construct.<commit_after>
//
// This source file is part of appleseed.
// Visit http://appleseedhq.net/ for additional information and resources.
//
// This software is released under the MIT license.
//
// Copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited
// Copyright (c) 2014 Francois Beaune, The appleseedhq Organization
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

// Interface header.
#include "scenepickinghandler.h"

// appleseed.studio headers.
#include "mainwindow/project/projectexplorer.h"
#include "utility/mousecoordinatestracker.h"

// appleseed.renderer headers.
#include "renderer/api/bsdf.h"
#include "renderer/api/camera.h"
#include "renderer/api/edf.h"
#include "renderer/api/entity.h"
#include "renderer/api/frame.h"
#include "renderer/api/log.h"
#include "renderer/api/material.h"
#include "renderer/api/object.h"
#include "renderer/api/project.h"
#include "renderer/api/rendering.h"
#include "renderer/api/scene.h"
#include "renderer/api/surfaceshader.h"

// appleseed.foundation headers.
#include "foundation/image/image.h"
#include "foundation/math/vector.h"

// Qt headers.
#include <QComboBox>
#include <QEvent>
#include <QLabel>
#include <QMouseEvent>
#include <QString>
#include <Qt>
#include <QWidget>

// Standard headers.
#include <cassert>
#include <sstream>

using namespace foundation;
using namespace renderer;
using namespace std;

namespace appleseed {
namespace studio {

ScenePickingHandler::ScenePickingHandler(
    QWidget*                        widget,
    QComboBox*                      picking_mode_combo,
    QLabel*                         r_label,
    QLabel*                         g_label,
    QLabel*                         b_label,
    QLabel*                         a_label,
    const MouseCoordinatesTracker&  mouse_tracker,
    const ProjectExplorer&          project_explorer,
    const Project&                  project)
  : m_widget(widget)
  , m_picking_mode_combo(picking_mode_combo)
  , m_r_label(r_label)
  , m_g_label(g_label)
  , m_b_label(b_label)
  , m_a_label(a_label)
  , m_mouse_tracker(mouse_tracker)
  , m_project_explorer(project_explorer)
  , m_project(project)
  , m_enabled(true)
{
    m_widget->installEventFilter(this);

    m_picking_mode_combo->clear();
    m_picking_mode_combo->addItem("Assembly", "assembly");
    m_picking_mode_combo->addItem("Assembly Instance", "assembly_instance");
    m_picking_mode_combo->addItem("Object", "object");
    m_picking_mode_combo->addItem("Object Instance", "object_instance");
    m_picking_mode_combo->addItem("Material", "material");
    m_picking_mode_combo->addItem("Surface Shader", "surface_shader");
    m_picking_mode_combo->addItem("BSDF", "bsdf");
    m_picking_mode_combo->addItem("EDF", "edf");
    m_picking_mode_combo->setCurrentIndex(3);
}

ScenePickingHandler::~ScenePickingHandler()
{
    m_widget->removeEventFilter(this);
}

void ScenePickingHandler::set_enabled(const bool enabled)
{
    m_enabled = enabled;
}

bool ScenePickingHandler::eventFilter(QObject* object, QEvent* event)
{
    if (!m_enabled)
        return QObject::eventFilter(object, event);

    switch (event->type())
    {
      case QEvent::MouseButtonPress:
        {
            const QMouseEvent* mouse_event = static_cast<QMouseEvent*>(event);
            if (mouse_event->button() == Qt::LeftButton &&
                !(mouse_event->modifiers() & (Qt::AltModifier | Qt::ShiftModifier | Qt::ControlModifier)))
            {
                pick(mouse_event->pos());
                return true;
            }
        }
        break;

      case QEvent::MouseMove:
        {
            const QMouseEvent* mouse_event = static_cast<QMouseEvent*>(event);
            set_rgb_label(mouse_event->pos());
        }
        break;

      case QEvent::Leave:
        m_r_label->clear();
        m_g_label->clear();
        m_b_label->clear();
        m_a_label->clear();
        break;
    }

    return QObject::eventFilter(object, event);
}

void ScenePickingHandler::set_rgb_label(const QPoint& point) const
{
    Color4f linear_rgba;
    m_project.get_frame()->image().get_pixel(static_cast<size_t>(point.x()), static_cast<size_t>( point.y()), linear_rgba);

    QString red;
    red.sprintf(" %4.3f", linear_rgba.r);
    m_r_label->setText(red);

    QString green;
    green.sprintf(" %4.3f", linear_rgba.g);
    m_g_label->setText(green);

    QString blue;
    blue.sprintf(" %4.3f", linear_rgba.b);
    m_b_label->setText(blue);

    QString alpha;
    alpha.sprintf(" %4.3f", linear_rgba.a);
    m_a_label->setText(alpha);
}

namespace
{
    void print_entity(stringstream& sstr, const char* label, const Entity* entity)
    {
        sstr << label;

        if (entity)
            sstr << "\"" << entity->get_name() << "\" (#" << entity->get_uid() << ")";
        else sstr << "n/a";

        sstr << endl;
    }

    const Entity* get_picked_entity(
        const ScenePicker::PickingResult&   picking_result,
        const QString&                      picking_mode)
    {
        if (picking_mode == "assembly")
            return picking_result.m_assembly;
        else if (picking_mode == "assembly_instance")
            return picking_result.m_assembly_instance;
        else if (picking_mode == "object")
            return picking_result.m_object;
        else if (picking_mode == "object_instance")
            return picking_result.m_object_instance;
        else if (picking_mode == "material")
            return picking_result.m_material;
        else if (picking_mode == "surface_shader")
            return picking_result.m_surface_shader;
        else if (picking_mode == "bsdf")
            return picking_result.m_bsdf;
        else if (picking_mode == "edf")
            return picking_result.m_edf;
        else
        {
            assert(!"Invalid picking mode.");
            return 0;
        }
    }
}

void ScenePickingHandler::pick(const QPoint& point)
{
    if (!m_project.has_trace_context())
    {
        RENDERER_LOG_INFO("the scene must be rendering or must have been rendered at least once for picking to be available.");
        return;
    }

    const Vector2i pix = m_mouse_tracker.widget_to_pixel(point);
    const Vector2d ndc = m_mouse_tracker.widget_to_ndc(point);

    const ScenePicker scene_picker(m_project.get_trace_context());
    const ScenePicker::PickingResult result = scene_picker.pick(ndc);

    stringstream sstr;

    sstr << "picking details:" << endl;
    sstr << "  pixel coords     " << pix.x << ", " << pix.y << endl;
    sstr << "  ndc coords       " << ndc.x << ", " << ndc.y << endl;

    print_entity(sstr, "  camera           ", result.m_camera);
    print_entity(sstr, "  assembly inst.   ", result.m_assembly_instance);
    print_entity(sstr, "  assembly         ", result.m_assembly);
    print_entity(sstr, "  object inst.     ", result.m_object_instance);
    print_entity(sstr, "  object           ", result.m_object);
    print_entity(sstr, "  material         ", result.m_material);
    print_entity(sstr, "  surface shader   ", result.m_surface_shader);
    print_entity(sstr, "  bsdf             ", result.m_bsdf);
    print_entity(sstr, "  edf              ", result.m_edf);

    RENDERER_LOG_INFO("%s", sstr.str().c_str());

    const QString picking_mode =
        m_picking_mode_combo->itemData(m_picking_mode_combo->currentIndex()).value<QString>();

    const Entity* picked_entity = get_picked_entity(result, picking_mode);

    if (picked_entity)
        m_project_explorer.highlight_entity(picked_entity->get_uid());
    else m_project_explorer.clear_highlighting();
}

}   // namespace studio
}   // namespace appleseed
<|endoftext|>


<commit_before>/*
 * Copyright 2009-2018 The VOTCA Development Team (http://www.votca.org)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#define BOOST_TEST_MAIN

#define BOOST_TEST_MODULE test_hdf5
#include <boost/test/unit_test.hpp>
#include <votca/xtp/checkpoint.h>

BOOST_AUTO_TEST_SUITE(test_hdf5)

BOOST_AUTO_TEST_CASE(constructor_test) {
    votca::xtp::CheckpointFile cpf("xtp_testing.hdf5"); }

BOOST_AUTO_TEST_SUITE_END()
<commit_msg>Add orbfile write code to checkpoint file writing<commit_after>/*
 * Copyright 2009-2018 The VOTCA Development Team (http://www.votca.org)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#define BOOST_TEST_MAIN

#define BOOST_TEST_MODULE test_hdf5
#include <boost/test/unit_test.hpp>
#include <votca/xtp/checkpoint.h>

BOOST_AUTO_TEST_SUITE(test_hdf5)

BOOST_AUTO_TEST_CASE(checkpoint_file_test) {
    votca::xtp::CheckpointFile cpf("xtp_testing.hdf5");

    // Write orbitals
    votca::xtp::Orbitals orbWrite;

    orbWrite.setBasisSetSize(17);
    orbWrite.setNumberOfLevels(4,13);

    Eigen::VectorXd moeTest = Eigen::VectorXd::Zero(17);
    Eigen::MatrixXd mocTest = Eigen::MatrixXd::Zero(17,17);

    orbWrite.MOEnergies()=moeTest;
    orbWrite.MOCoefficients()=mocTest;

    cpf.WriteOrbitals(orbWrite, "Test Orb");

    // Read Orbitals
    votca::xtp::Orbitals orbRead;

}

BOOST_AUTO_TEST_SUITE_END()
<|endoftext|>


<commit_before>/**
 *  @file Mu0Poly.cpp
 *  Definitions for a single-species standard state object derived
 *  from \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType\endlink  based
 *  on a piecewise constant mu0 interpolation
 *  (see \ref spthermo and class \link Cantera::Mu0Poly Mu0Poly\endlink).
 */
#include "cantera/thermo/Mu0Poly.h"
#include "cantera/thermo/SpeciesThermo.h"
#include "cantera/base/ctml.h"
#include "cantera/base/stringUtils.h"

using namespace std;
using namespace ctml;

namespace Cantera
{
Mu0Poly::Mu0Poly() : m_numIntervals(0),
    m_H298(0.0)
{
}

Mu0Poly::Mu0Poly(size_t n, doublereal tlow, doublereal thigh,
                 doublereal pref,
                 const doublereal* coeffs) :
    SpeciesThermoInterpType(n, tlow, thigh, pref),
    m_numIntervals(0),
    m_H298(0.0)
{
    processCoeffs(coeffs);
}

Mu0Poly::Mu0Poly(const Mu0Poly& b)
    : SpeciesThermoInterpType(b),
      m_numIntervals(b.m_numIntervals),
      m_H298(b.m_H298),
      m_t0_int(b.m_t0_int),
      m_mu0_R_int(b.m_mu0_R_int),
      m_h0_R_int(b.m_h0_R_int),
      m_s0_R_int(b.m_s0_R_int),
      m_cp0_R_int(b.m_cp0_R_int)
{
}

Mu0Poly& Mu0Poly::operator=(const Mu0Poly& b)
{
    if (&b != this) {
        SpeciesThermoInterpType::operator=(b);
        m_numIntervals = b.m_numIntervals;
        m_H298         = b.m_H298;
        m_t0_int       = b.m_t0_int;
        m_mu0_R_int    = b.m_mu0_R_int;
        m_h0_R_int     = b.m_h0_R_int;
        m_s0_R_int     = b.m_s0_R_int;
        m_cp0_R_int    = b.m_cp0_R_int;
    }
    return *this;
}

SpeciesThermoInterpType*
Mu0Poly::duplMyselfAsSpeciesThermoInterpType() const
{
    return new Mu0Poly(*this);
}

void  Mu0Poly::updateProperties(const doublereal* tt,  doublereal* cp_R,
                                doublereal* h_RT, doublereal* s_R) const
{
    size_t j = m_numIntervals;
    double T = *tt;
    for (size_t i = 0; i < m_numIntervals; i++) {
        double T2 =  m_t0_int[i+1];
        if (T <=T2) {
            j = i;
            break;
        }
    }
    double T1 = m_t0_int[j];
    double cp_Rj = m_cp0_R_int[j];

    doublereal rt = 1.0/T;
    cp_R[m_index] = cp_Rj;
    h_RT[m_index] = rt*(m_h0_R_int[j] + (T - T1) * cp_Rj);
    s_R[m_index]  = m_s0_R_int[j] + cp_Rj * (log(T/T1));
}

void Mu0Poly::updatePropertiesTemp(const doublereal T,
                                   doublereal* cp_R,
                                   doublereal* h_RT,
                                   doublereal* s_R) const
{
    updateProperties(&T, cp_R, h_RT, s_R);
}

void Mu0Poly::reportParameters(size_t& n, int& type,
                               doublereal& tlow, doublereal& thigh,
                               doublereal& pref,
                               doublereal* const coeffs) const
{
    n = m_index;
    type = MU0_INTERP;
    tlow = m_lowT;
    thigh = m_highT;
    pref = m_Pref;
    coeffs[0] = int(m_numIntervals)+1;
    coeffs[1] = m_H298 * GasConstant;
    int j = 2;
    for (size_t i = 0; i < m_numIntervals+1; i++) {
        coeffs[j] = m_t0_int[i];
        coeffs[j+1] = m_mu0_R_int[i] * GasConstant;
        j += 2;
    }
}

void Mu0Poly::modifyParameters(doublereal* coeffs)
{
    processCoeffs(coeffs);
}

Mu0Poly* newMu0ThermoFromXML(const std::string& speciesName,
                             const XML_Node& Mu0Node)
{
    doublereal tmin, tmax;
    bool dimensionlessMu0Values = false;

    tmin = fpValue(Mu0Node["Tmin"]);
    tmax = fpValue(Mu0Node["Tmax"]);
    doublereal pref = fpValue(Mu0Node["Pref"]);

    doublereal h298 = 0.0;
    if (Mu0Node.hasChild("H298")) {
        h298 = getFloat(Mu0Node, "H298", "actEnergy");
    }

    size_t numPoints = 1;
    if (Mu0Node.hasChild("numPoints")) {
        numPoints = getInteger(Mu0Node, "numPoints");
    }

    vector_fp cValues(numPoints);
    const XML_Node* valNode_ptr =
        getByTitle(const_cast<XML_Node&>(Mu0Node), "Mu0Values");
    if (!valNode_ptr) {
        throw CanteraError("installMu0ThermoFromXML",
                           "missing required while processing "
                           + speciesName);
    }
    getFloatArray(*valNode_ptr, cValues, true, "actEnergy");
    /*
     * Check to see whether the Mu0's were input in a dimensionless
     * form. If they were, then the assumed temperature needs to be
     * adjusted from the assumed T = 273.15
     */
    string uuu = valNode_ptr->attrib("units");
    if (uuu == "Dimensionless") {
        dimensionlessMu0Values = true;
    }
    size_t ns = cValues.size();
    if (ns != numPoints) {
        throw CanteraError("installMu0ThermoFromXML",
                           "numPoints inconsistent while processing "
                           + speciesName);
    }

    vector_fp cTemperatures(numPoints);
    const XML_Node* tempNode_ptr =
        getByTitle(const_cast<XML_Node&>(Mu0Node), "Mu0Temperatures");
    if (!tempNode_ptr) {
        throw CanteraError("installMu0ThermoFromXML",
                           "missing required while processing + "
                           + speciesName);
    }
    getFloatArray(*tempNode_ptr, cTemperatures, false);
    ns = cTemperatures.size();
    if (ns != numPoints) {
        throw CanteraError("installMu0ThermoFromXML",
                           "numPoints inconsistent while processing "
                           + speciesName);
    }

    /*
     * Fix up dimensionless Mu0 values if input
     */
    if (dimensionlessMu0Values) {
        for (size_t i = 0; i < numPoints; i++) {
            cValues[i] *= cTemperatures[i] / 273.15;
        }
    }

    vector_fp c(2 + 2 * numPoints);

    c[0] = static_cast<double>(numPoints);
    c[1] = h298;
    for (size_t i = 0; i < numPoints; i++) {
        c[2+i*2]   = cTemperatures[i];
        c[2+i*2+1] = cValues[i];
    }

    return new Mu0Poly(0, tmin, tmax, pref, &c[0]);
}

void Mu0Poly::processCoeffs(const doublereal* coeffs)
{
    size_t i, iindex;
    double T1, T2;
    size_t nPoints = (size_t) coeffs[0];
    if (nPoints < 2) {
        throw CanteraError("Mu0Poly",
                           "nPoints must be >= 2");
    }
    m_numIntervals = nPoints - 1;
    m_H298       = coeffs[1] / GasConstant;
    size_t iT298 = 0;
    /*
     * Resize according to the number of points
     */
    m_t0_int.resize(nPoints);
    m_h0_R_int.resize(nPoints);
    m_s0_R_int.resize(nPoints);
    m_cp0_R_int.resize(nPoints);
    m_mu0_R_int.resize(nPoints);
    /*
     * Calculate the T298 interval and make sure that
     * the temperatures are strictly monotonic.
     * Also distribute the data into the internal arrays.
     */
    bool ifound = false;
    for (i = 0, iindex = 2; i < nPoints; i++) {
        T1 = coeffs[iindex];
        m_t0_int[i] = T1;
        m_mu0_R_int[i] =  coeffs[iindex+1] / GasConstant;
        if (T1 == 298.15) {
            iT298 = i;
            ifound = true;
        }
        if (i < nPoints - 1) {
            T2 = coeffs[iindex+2];
            if (T2 <= T1) {
                throw CanteraError("Mu0Poly",
                                   "Temperatures are not monotonic increasing");
            }
        }
        iindex += 2;
    }
    if (!ifound) {
        throw CanteraError("Mu0Poly",
                           "One temperature has to be 298.15");
    }

    /*
     * Starting from the interval with T298, we go up
     */
    doublereal mu2, s1, s2, h1, h2, cpi, deltaMu, deltaT;
    T1 = m_t0_int[iT298];
    doublereal mu1 = m_mu0_R_int[iT298];
    m_h0_R_int[iT298] = m_H298;
    m_s0_R_int[iT298] = - (mu1 - m_h0_R_int[iT298]) / T1;
    for (i = iT298; i < m_numIntervals; i++) {
        T1      = m_t0_int[i];
        s1      = m_s0_R_int[i];
        h1      = m_h0_R_int[i];
        mu1     = m_mu0_R_int[i];
        T2      = m_t0_int[i+1];
        mu2     = m_mu0_R_int[i+1];
        deltaMu = mu2 - mu1;
        deltaT  = T2 - T1;
        cpi = (deltaMu - T1 * s1 + T2 * s1) / (deltaT - T2 * log(T2/T1));
        h2 = h1 + cpi * deltaT;
        s2 = s1 + cpi * log(T2/T1);
        m_cp0_R_int[i]   = cpi;
        m_h0_R_int[i+1]  = h2;
        m_s0_R_int[i+1]  = s2;
        m_cp0_R_int[i+1] = cpi;
    }

    /*
     * Starting from the interval with T298, we go down
     */
    if (iT298 != 0) {
        T2 = m_t0_int[iT298];
        mu2 = m_mu0_R_int[iT298];
        m_h0_R_int[iT298] = m_H298;
        m_s0_R_int[iT298] = - (mu2 - m_h0_R_int[iT298]) / T2;
        for (i = iT298 - 1; i != npos; i--) {
            T1      = m_t0_int[i];
            mu1     = m_mu0_R_int[i];
            T2      = m_t0_int[i+1];
            mu2     = m_mu0_R_int[i+1];
            s2      = m_s0_R_int[i+1];
            h2      = m_h0_R_int[i+1];
            deltaMu = mu2 - mu1;
            deltaT  = T2 - T1;
            cpi = (deltaMu - T1 * s2 + T2 * s2) / (deltaT - T1 * log(T2/T1));
            h1 = h2 - cpi * deltaT;
            s1 = s2 - cpi * log(T2/T1);
            m_cp0_R_int[i]   = cpi;
            m_h0_R_int[i]    = h1;
            m_s0_R_int[i]    = s1;
            if (i == (m_numIntervals-1)) {
                m_cp0_R_int[i+1] = cpi;
            }
        }
    }
#ifdef DEBUG_HKM_NOT
    printf("    Temp     mu0(J/kmol)   cp0(J/kmol/K)   "
           " h0(J/kmol)   s0(J/kmol/K) \n");
    for (i = 0; i < nPoints; i++) {
        printf("%12.3g %12.5g %12.5g %12.5g %12.5g\n",
               m_t0_int[i],  m_mu0_R_int[i] * GasConstant,
               m_cp0_R_int[i]* GasConstant,
               m_h0_R_int[i]* GasConstant,
               m_s0_R_int[i]* GasConstant);
        fflush(stdout);
    }
#endif
}

}
<commit_msg>Remove unnecessary use of const_cast<commit_after>/**
 *  @file Mu0Poly.cpp
 *  Definitions for a single-species standard state object derived
 *  from \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType\endlink  based
 *  on a piecewise constant mu0 interpolation
 *  (see \ref spthermo and class \link Cantera::Mu0Poly Mu0Poly\endlink).
 */
#include "cantera/thermo/Mu0Poly.h"
#include "cantera/thermo/SpeciesThermo.h"
#include "cantera/base/ctml.h"
#include "cantera/base/stringUtils.h"

using namespace std;
using namespace ctml;

namespace Cantera
{
Mu0Poly::Mu0Poly() : m_numIntervals(0),
    m_H298(0.0)
{
}

Mu0Poly::Mu0Poly(size_t n, doublereal tlow, doublereal thigh,
                 doublereal pref,
                 const doublereal* coeffs) :
    SpeciesThermoInterpType(n, tlow, thigh, pref),
    m_numIntervals(0),
    m_H298(0.0)
{
    processCoeffs(coeffs);
}

Mu0Poly::Mu0Poly(const Mu0Poly& b)
    : SpeciesThermoInterpType(b),
      m_numIntervals(b.m_numIntervals),
      m_H298(b.m_H298),
      m_t0_int(b.m_t0_int),
      m_mu0_R_int(b.m_mu0_R_int),
      m_h0_R_int(b.m_h0_R_int),
      m_s0_R_int(b.m_s0_R_int),
      m_cp0_R_int(b.m_cp0_R_int)
{
}

Mu0Poly& Mu0Poly::operator=(const Mu0Poly& b)
{
    if (&b != this) {
        SpeciesThermoInterpType::operator=(b);
        m_numIntervals = b.m_numIntervals;
        m_H298         = b.m_H298;
        m_t0_int       = b.m_t0_int;
        m_mu0_R_int    = b.m_mu0_R_int;
        m_h0_R_int     = b.m_h0_R_int;
        m_s0_R_int     = b.m_s0_R_int;
        m_cp0_R_int    = b.m_cp0_R_int;
    }
    return *this;
}

SpeciesThermoInterpType*
Mu0Poly::duplMyselfAsSpeciesThermoInterpType() const
{
    return new Mu0Poly(*this);
}

void  Mu0Poly::updateProperties(const doublereal* tt,  doublereal* cp_R,
                                doublereal* h_RT, doublereal* s_R) const
{
    size_t j = m_numIntervals;
    double T = *tt;
    for (size_t i = 0; i < m_numIntervals; i++) {
        double T2 =  m_t0_int[i+1];
        if (T <=T2) {
            j = i;
            break;
        }
    }
    double T1 = m_t0_int[j];
    double cp_Rj = m_cp0_R_int[j];

    doublereal rt = 1.0/T;
    cp_R[m_index] = cp_Rj;
    h_RT[m_index] = rt*(m_h0_R_int[j] + (T - T1) * cp_Rj);
    s_R[m_index]  = m_s0_R_int[j] + cp_Rj * (log(T/T1));
}

void Mu0Poly::updatePropertiesTemp(const doublereal T,
                                   doublereal* cp_R,
                                   doublereal* h_RT,
                                   doublereal* s_R) const
{
    updateProperties(&T, cp_R, h_RT, s_R);
}

void Mu0Poly::reportParameters(size_t& n, int& type,
                               doublereal& tlow, doublereal& thigh,
                               doublereal& pref,
                               doublereal* const coeffs) const
{
    n = m_index;
    type = MU0_INTERP;
    tlow = m_lowT;
    thigh = m_highT;
    pref = m_Pref;
    coeffs[0] = int(m_numIntervals)+1;
    coeffs[1] = m_H298 * GasConstant;
    int j = 2;
    for (size_t i = 0; i < m_numIntervals+1; i++) {
        coeffs[j] = m_t0_int[i];
        coeffs[j+1] = m_mu0_R_int[i] * GasConstant;
        j += 2;
    }
}

void Mu0Poly::modifyParameters(doublereal* coeffs)
{
    processCoeffs(coeffs);
}

Mu0Poly* newMu0ThermoFromXML(const std::string& speciesName,
                             const XML_Node& Mu0Node)
{
    doublereal tmin, tmax;
    bool dimensionlessMu0Values = false;

    tmin = fpValue(Mu0Node["Tmin"]);
    tmax = fpValue(Mu0Node["Tmax"]);
    doublereal pref = fpValue(Mu0Node["Pref"]);

    doublereal h298 = 0.0;
    if (Mu0Node.hasChild("H298")) {
        h298 = getFloat(Mu0Node, "H298", "actEnergy");
    }

    size_t numPoints = 1;
    if (Mu0Node.hasChild("numPoints")) {
        numPoints = getInteger(Mu0Node, "numPoints");
    }

    vector_fp cValues(numPoints);
    const XML_Node* valNode_ptr = getByTitle(Mu0Node, "Mu0Values");
    if (!valNode_ptr) {
        throw CanteraError("installMu0ThermoFromXML",
                           "missing required while processing "
                           + speciesName);
    }
    getFloatArray(*valNode_ptr, cValues, true, "actEnergy");
    /*
     * Check to see whether the Mu0's were input in a dimensionless
     * form. If they were, then the assumed temperature needs to be
     * adjusted from the assumed T = 273.15
     */
    string uuu = valNode_ptr->attrib("units");
    if (uuu == "Dimensionless") {
        dimensionlessMu0Values = true;
    }
    size_t ns = cValues.size();
    if (ns != numPoints) {
        throw CanteraError("installMu0ThermoFromXML",
                           "numPoints inconsistent while processing "
                           + speciesName);
    }

    vector_fp cTemperatures(numPoints);
    const XML_Node* tempNode_ptr = getByTitle(Mu0Node, "Mu0Temperatures");
    if (!tempNode_ptr) {
        throw CanteraError("installMu0ThermoFromXML",
                           "missing required while processing + "
                           + speciesName);
    }
    getFloatArray(*tempNode_ptr, cTemperatures, false);
    ns = cTemperatures.size();
    if (ns != numPoints) {
        throw CanteraError("installMu0ThermoFromXML",
                           "numPoints inconsistent while processing "
                           + speciesName);
    }

    /*
     * Fix up dimensionless Mu0 values if input
     */
    if (dimensionlessMu0Values) {
        for (size_t i = 0; i < numPoints; i++) {
            cValues[i] *= cTemperatures[i] / 273.15;
        }
    }

    vector_fp c(2 + 2 * numPoints);

    c[0] = static_cast<double>(numPoints);
    c[1] = h298;
    for (size_t i = 0; i < numPoints; i++) {
        c[2+i*2]   = cTemperatures[i];
        c[2+i*2+1] = cValues[i];
    }

    return new Mu0Poly(0, tmin, tmax, pref, &c[0]);
}

void Mu0Poly::processCoeffs(const doublereal* coeffs)
{
    size_t i, iindex;
    double T1, T2;
    size_t nPoints = (size_t) coeffs[0];
    if (nPoints < 2) {
        throw CanteraError("Mu0Poly",
                           "nPoints must be >= 2");
    }
    m_numIntervals = nPoints - 1;
    m_H298       = coeffs[1] / GasConstant;
    size_t iT298 = 0;
    /*
     * Resize according to the number of points
     */
    m_t0_int.resize(nPoints);
    m_h0_R_int.resize(nPoints);
    m_s0_R_int.resize(nPoints);
    m_cp0_R_int.resize(nPoints);
    m_mu0_R_int.resize(nPoints);
    /*
     * Calculate the T298 interval and make sure that
     * the temperatures are strictly monotonic.
     * Also distribute the data into the internal arrays.
     */
    bool ifound = false;
    for (i = 0, iindex = 2; i < nPoints; i++) {
        T1 = coeffs[iindex];
        m_t0_int[i] = T1;
        m_mu0_R_int[i] =  coeffs[iindex+1] / GasConstant;
        if (T1 == 298.15) {
            iT298 = i;
            ifound = true;
        }
        if (i < nPoints - 1) {
            T2 = coeffs[iindex+2];
            if (T2 <= T1) {
                throw CanteraError("Mu0Poly",
                                   "Temperatures are not monotonic increasing");
            }
        }
        iindex += 2;
    }
    if (!ifound) {
        throw CanteraError("Mu0Poly",
                           "One temperature has to be 298.15");
    }

    /*
     * Starting from the interval with T298, we go up
     */
    doublereal mu2, s1, s2, h1, h2, cpi, deltaMu, deltaT;
    T1 = m_t0_int[iT298];
    doublereal mu1 = m_mu0_R_int[iT298];
    m_h0_R_int[iT298] = m_H298;
    m_s0_R_int[iT298] = - (mu1 - m_h0_R_int[iT298]) / T1;
    for (i = iT298; i < m_numIntervals; i++) {
        T1      = m_t0_int[i];
        s1      = m_s0_R_int[i];
        h1      = m_h0_R_int[i];
        mu1     = m_mu0_R_int[i];
        T2      = m_t0_int[i+1];
        mu2     = m_mu0_R_int[i+1];
        deltaMu = mu2 - mu1;
        deltaT  = T2 - T1;
        cpi = (deltaMu - T1 * s1 + T2 * s1) / (deltaT - T2 * log(T2/T1));
        h2 = h1 + cpi * deltaT;
        s2 = s1 + cpi * log(T2/T1);
        m_cp0_R_int[i]   = cpi;
        m_h0_R_int[i+1]  = h2;
        m_s0_R_int[i+1]  = s2;
        m_cp0_R_int[i+1] = cpi;
    }

    /*
     * Starting from the interval with T298, we go down
     */
    if (iT298 != 0) {
        T2 = m_t0_int[iT298];
        mu2 = m_mu0_R_int[iT298];
        m_h0_R_int[iT298] = m_H298;
        m_s0_R_int[iT298] = - (mu2 - m_h0_R_int[iT298]) / T2;
        for (i = iT298 - 1; i != npos; i--) {
            T1      = m_t0_int[i];
            mu1     = m_mu0_R_int[i];
            T2      = m_t0_int[i+1];
            mu2     = m_mu0_R_int[i+1];
            s2      = m_s0_R_int[i+1];
            h2      = m_h0_R_int[i+1];
            deltaMu = mu2 - mu1;
            deltaT  = T2 - T1;
            cpi = (deltaMu - T1 * s2 + T2 * s2) / (deltaT - T1 * log(T2/T1));
            h1 = h2 - cpi * deltaT;
            s1 = s2 - cpi * log(T2/T1);
            m_cp0_R_int[i]   = cpi;
            m_h0_R_int[i]    = h1;
            m_s0_R_int[i]    = s1;
            if (i == (m_numIntervals-1)) {
                m_cp0_R_int[i+1] = cpi;
            }
        }
    }
#ifdef DEBUG_HKM_NOT
    printf("    Temp     mu0(J/kmol)   cp0(J/kmol/K)   "
           " h0(J/kmol)   s0(J/kmol/K) \n");
    for (i = 0; i < nPoints; i++) {
        printf("%12.3g %12.5g %12.5g %12.5g %12.5g\n",
               m_t0_int[i],  m_mu0_R_int[i] * GasConstant,
               m_cp0_R_int[i]* GasConstant,
               m_h0_R_int[i]* GasConstant,
               m_s0_R_int[i]* GasConstant);
        fflush(stdout);
    }
#endif
}

}
<|endoftext|>


<commit_before>/******************************************************************************
 * Copyright 2017 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

#include "modules/planning/planning.h"

#include <algorithm>

#include "google/protobuf/repeated_field.h"
#include "modules/common/adapters/adapter_manager.h"
#include "modules/common/time/time.h"
#include "modules/common/vehicle_state/vehicle_state.h"
#include "modules/common/vehicle_state/vehicle_state.h"
#include "modules/planning/common/planning_gflags.h"
#include "modules/planning/planner/em/em_planner.h"
#include "modules/planning/planner/rtk/rtk_replay_planner.h"
#include "modules/planning/trajectory_stitcher/trajectory_stitcher.h"

namespace apollo {
namespace planning {

using apollo::common::ErrorCode;
using apollo::common::Status;
using apollo::common::TrajectoryPoint;
using apollo::common::VehicleState;
using apollo::common::adapter::AdapterManager;
using apollo::common::time::Clock;

std::string Planning::Name() const { return "planning"; }

void Planning::RegisterPlanners() {
  planner_factory_.Register(
      PlanningConfig::RTK, []() -> Planner* { return new RTKReplayPlanner(); });
  planner_factory_.Register(PlanningConfig::EM,
                            []() -> Planner* { return new EMPlanner(); });
}

const Frame* Planning::GetFrame() const { return frame_.get(); }
const hdmap::PncMap* Planning::GetPncMap() const { return pnc_map_.get(); }

bool Planning::InitFrame(const uint32_t sequence_num) {
  frame_.reset(new Frame(sequence_num));
  if (AdapterManager::GetRoutingResult()->Empty()) {
    AERROR << "Routing is empty";
    return false;
  }
  common::TrajectoryPoint point;
  frame_->SetVehicleInitPose(VehicleState::instance()->pose());
  frame_->SetRoutingResult(
      AdapterManager::GetRoutingResult()->GetLatestObserved());
  if (FLAGS_enable_prediction && !AdapterManager::GetPrediction()->Empty()) {
    const auto& prediction =
        AdapterManager::GetPrediction()->GetLatestObserved();
    frame_->SetPrediction(prediction);
    ADEBUG << "Get prediction";
  }

  if (!frame_->Init()) {
    AERROR << "failed to init frame";
    return false;
  }
  return true;
}

Status Planning::Init() {
  pnc_map_.reset(new hdmap::PncMap(FLAGS_map_filename));
  Frame::SetMap(pnc_map_.get());

  if (!apollo::common::util::GetProtoFromFile(FLAGS_planning_config_file,
                                              &config_)) {
    AERROR << "failed to load planning config file "
           << FLAGS_planning_config_file;
    return Status(
        ErrorCode::PLANNING_ERROR,
        "failed to load planning config file: " + FLAGS_planning_config_file);
  }

  AdapterManager::Init(FLAGS_adapter_config_path);
  if (AdapterManager::GetLocalization() == nullptr) {
    std::string error_msg("Localization is not registered");
    AERROR << error_msg;
    return Status(ErrorCode::PLANNING_ERROR, error_msg);
  }
  if (AdapterManager::GetChassis() == nullptr) {
    std::string error_msg("Chassis is not registered");
    AERROR << error_msg;
    return Status(ErrorCode::PLANNING_ERROR, error_msg);
  }
  if (AdapterManager::GetRoutingResult() == nullptr) {
    std::string error_msg("RoutingResult is not registered");
    AERROR << error_msg;
    return Status(ErrorCode::PLANNING_ERROR, error_msg);
  }
  // TODO(all) temporarily use the offline routing data.
  if (!AdapterManager::GetRoutingResult()->HasReceived()) {
    if (!AdapterManager::GetRoutingResult()->FeedFile(
            FLAGS_offline_routing_file)) {
      auto error_msg = common::util::StrCat(
          "Failed to load offline routing file ", FLAGS_offline_routing_file);
      AERROR << error_msg;
      return Status(ErrorCode::PLANNING_ERROR, error_msg);
    } else {
      AWARN << "Using offline routing file " << FLAGS_offline_routing_file;
    }
  }
  if (AdapterManager::GetPrediction() == nullptr) {
    std::string error_msg("Prediction is not registered");
    AERROR << error_msg;
    return Status(ErrorCode::PLANNING_ERROR, error_msg);
  }

  RegisterPlanners();
  planner_ = planner_factory_.CreateObject(config_.planner_type());
  if (!planner_) {
    return Status(
        ErrorCode::PLANNING_ERROR,
        "planning is not initialized with config : " + config_.DebugString());
  }

  return planner_->Init(config_);
}

Status Planning::Start() {
  static ros::Rate loop_rate(FLAGS_planning_loop_rate);
  while (ros::ok()) {
    RunOnce();
    ros::spinOnce();
    loop_rate.sleep();
  }
  return Status::OK();
}

void Planning::RecordInput(ADCTrajectory* trajectory_pb) {
  if (!FLAGS_enable_record_debug) {
    ADEBUG << "Skip record input into debug";
    return;
  }
  auto planning_data = trajectory_pb->mutable_debug()->mutable_planning_data();
  auto adc_position = planning_data->mutable_adc_position();
  const auto& localization =
      AdapterManager::GetLocalization()->GetLatestObserved();
  adc_position->CopyFrom(localization);

  const auto& chassis = AdapterManager::GetChassis()->GetLatestObserved();
  auto debug_chassis = planning_data->mutable_chassis();
  debug_chassis->CopyFrom(chassis);

  const auto& routing_result =
      AdapterManager::GetRoutingResult()->GetLatestObserved();

  auto debug_routing = planning_data->mutable_routing();
  debug_routing->CopyFrom(routing_result);
}

void Planning::RunOnce() {
  AdapterManager::Observe();
  if (AdapterManager::GetLocalization()->Empty()) {
    AERROR << "Localization is not available; skip the planning cycle";
    return;
  }

  if (AdapterManager::GetChassis()->Empty()) {
    AERROR << "Chassis is not available; skip the planning cycle";
    return;
  }
  if (AdapterManager::GetRoutingResult()->Empty()) {
    AERROR << "RoutingResult is not available; skip the planning cycle";
    return;
  }

  // FIXME(all): enable prediction check when perception and prediction is
  // ready.
  // if (FLAGS_enable_prediction && AdapterManager::GetPrediction()->Empty()) {
  //   AERROR << "Prediction is not available; skip the planning cycle";
  //   return;
  // }

  AINFO << "Start planning ...";
  const double start_timestamp = apollo::common::time::ToSecond(Clock::Now());

  // localization
  const auto& localization =
      AdapterManager::GetLocalization()->GetLatestObserved();
  ADEBUG << "Get localization:" << localization.DebugString();

  // chassis
  const auto& chassis = AdapterManager::GetChassis()->GetLatestObserved();
  ADEBUG << "Get chassis:" << chassis.DebugString();

  common::VehicleState::instance()->Update(localization, chassis);

  const double planning_cycle_time = 1.0 / FLAGS_planning_loop_rate;

  ADCTrajectory trajectory_pb;
  RecordInput(&trajectory_pb);

  const uint32_t frame_num = AdapterManager::GetPlanning()->GetSeqNum() + 1;
  if (!InitFrame(frame_num)) {
    AERROR << "Init frame failed";
    return;
  }

  bool is_auto_mode = chassis.driving_mode() == chassis.COMPLETE_AUTO_DRIVE;
  bool res_planning = Plan(is_auto_mode, start_timestamp, planning_cycle_time,
      &trajectory_pb);

  const double end_timestamp = apollo::common::time::ToSecond(Clock::Now());
  const double time_diff_ms = (end_timestamp - start_timestamp) * 1000;
  trajectory_pb.mutable_latency_stats()->set_total_time_ms(time_diff_ms);
  ADEBUG << "Planning latency: " << trajectory_pb.latency_stats().DebugString();

  if (res_planning) {
    AdapterManager::FillPlanningHeader("planning", &trajectory_pb);
    trajectory_pb.mutable_header()->set_timestamp_sec(start_timestamp);
    AdapterManager::PublishPlanning(trajectory_pb);
    ADEBUG << "Planning succeeded:" << trajectory_pb.header().DebugString();
  } else {
    AERROR << "Planning failed";
  }
}

void Planning::Stop() {}

bool Planning::Plan(const bool is_on_auto_mode,
                    const double current_time_stamp,
                    const double planning_cycle_time,
                    ADCTrajectory* trajectory_pb) {

  const auto& stitching_trajectory =
      TrajectoryStitcher::compute_stitching_trajectory(
          is_on_auto_mode, current_time_stamp, planning_cycle_time,
          last_publishable_trajectory_);

  frame_->SetPlanningStartPoint(stitching_trajectory.back());

  PublishableTrajectory publishable_trajectory;
  auto status = planner_->Plan(stitching_trajectory.back(),
      frame_.get(), &publishable_trajectory, trajectory_pb->mutable_debug(),
      trajectory_pb->mutable_latency_stats());

  if (status != Status::OK()) {
    AERROR << "planner failed to make a driving plan";
    last_publishable_trajectory_.Clear();
    return false;
  }

  publishable_trajectory.prepend_trajectory_points(
      stitching_trajectory.begin(), stitching_trajectory.end() - 1);

  publishable_trajectory.set_header_time(current_time_stamp);

  publishable_trajectory.populate_trajectory_protobuf(trajectory_pb);

  // update last publishable trajectory;
  last_publishable_trajectory_ = std::move(publishable_trajectory);
  return true;
}

}  // namespace planning
}  // namespace apollo
<commit_msg>planning passes GEAR_DRIVE.<commit_after>/******************************************************************************
 * Copyright 2017 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

#include "modules/planning/planning.h"

#include <algorithm>

#include "google/protobuf/repeated_field.h"
#include "modules/common/adapters/adapter_manager.h"
#include "modules/common/time/time.h"
#include "modules/common/vehicle_state/vehicle_state.h"
#include "modules/common/vehicle_state/vehicle_state.h"
#include "modules/planning/common/planning_gflags.h"
#include "modules/planning/planner/em/em_planner.h"
#include "modules/planning/planner/rtk/rtk_replay_planner.h"
#include "modules/planning/trajectory_stitcher/trajectory_stitcher.h"

namespace apollo {
namespace planning {

using apollo::common::ErrorCode;
using apollo::common::Status;
using apollo::common::TrajectoryPoint;
using apollo::common::VehicleState;
using apollo::common::adapter::AdapterManager;
using apollo::common::time::Clock;

std::string Planning::Name() const { return "planning"; }

void Planning::RegisterPlanners() {
  planner_factory_.Register(
      PlanningConfig::RTK, []() -> Planner* { return new RTKReplayPlanner(); });
  planner_factory_.Register(PlanningConfig::EM,
                            []() -> Planner* { return new EMPlanner(); });
}

const Frame* Planning::GetFrame() const { return frame_.get(); }
const hdmap::PncMap* Planning::GetPncMap() const { return pnc_map_.get(); }

bool Planning::InitFrame(const uint32_t sequence_num) {
  frame_.reset(new Frame(sequence_num));
  if (AdapterManager::GetRoutingResult()->Empty()) {
    AERROR << "Routing is empty";
    return false;
  }
  common::TrajectoryPoint point;
  frame_->SetVehicleInitPose(VehicleState::instance()->pose());
  frame_->SetRoutingResult(
      AdapterManager::GetRoutingResult()->GetLatestObserved());
  if (FLAGS_enable_prediction && !AdapterManager::GetPrediction()->Empty()) {
    const auto& prediction =
        AdapterManager::GetPrediction()->GetLatestObserved();
    frame_->SetPrediction(prediction);
    ADEBUG << "Get prediction";
  }

  if (!frame_->Init()) {
    AERROR << "failed to init frame";
    return false;
  }
  return true;
}

Status Planning::Init() {
  pnc_map_.reset(new hdmap::PncMap(FLAGS_map_filename));
  Frame::SetMap(pnc_map_.get());

  if (!apollo::common::util::GetProtoFromFile(FLAGS_planning_config_file,
                                              &config_)) {
    AERROR << "failed to load planning config file "
           << FLAGS_planning_config_file;
    return Status(
        ErrorCode::PLANNING_ERROR,
        "failed to load planning config file: " + FLAGS_planning_config_file);
  }

  AdapterManager::Init(FLAGS_adapter_config_path);
  if (AdapterManager::GetLocalization() == nullptr) {
    std::string error_msg("Localization is not registered");
    AERROR << error_msg;
    return Status(ErrorCode::PLANNING_ERROR, error_msg);
  }
  if (AdapterManager::GetChassis() == nullptr) {
    std::string error_msg("Chassis is not registered");
    AERROR << error_msg;
    return Status(ErrorCode::PLANNING_ERROR, error_msg);
  }
  if (AdapterManager::GetRoutingResult() == nullptr) {
    std::string error_msg("RoutingResult is not registered");
    AERROR << error_msg;
    return Status(ErrorCode::PLANNING_ERROR, error_msg);
  }
  // TODO(all) temporarily use the offline routing data.
  if (!AdapterManager::GetRoutingResult()->HasReceived()) {
    if (!AdapterManager::GetRoutingResult()->FeedFile(
            FLAGS_offline_routing_file)) {
      auto error_msg = common::util::StrCat(
          "Failed to load offline routing file ", FLAGS_offline_routing_file);
      AERROR << error_msg;
      return Status(ErrorCode::PLANNING_ERROR, error_msg);
    } else {
      AWARN << "Using offline routing file " << FLAGS_offline_routing_file;
    }
  }
  if (AdapterManager::GetPrediction() == nullptr) {
    std::string error_msg("Prediction is not registered");
    AERROR << error_msg;
    return Status(ErrorCode::PLANNING_ERROR, error_msg);
  }

  RegisterPlanners();
  planner_ = planner_factory_.CreateObject(config_.planner_type());
  if (!planner_) {
    return Status(
        ErrorCode::PLANNING_ERROR,
        "planning is not initialized with config : " + config_.DebugString());
  }

  return planner_->Init(config_);
}

Status Planning::Start() {
  static ros::Rate loop_rate(FLAGS_planning_loop_rate);
  while (ros::ok()) {
    RunOnce();
    ros::spinOnce();
    loop_rate.sleep();
  }
  return Status::OK();
}

void Planning::RecordInput(ADCTrajectory* trajectory_pb) {
  if (!FLAGS_enable_record_debug) {
    ADEBUG << "Skip record input into debug";
    return;
  }
  auto planning_data = trajectory_pb->mutable_debug()->mutable_planning_data();
  auto adc_position = planning_data->mutable_adc_position();
  const auto& localization =
      AdapterManager::GetLocalization()->GetLatestObserved();
  adc_position->CopyFrom(localization);

  const auto& chassis = AdapterManager::GetChassis()->GetLatestObserved();
  auto debug_chassis = planning_data->mutable_chassis();
  debug_chassis->CopyFrom(chassis);

  const auto& routing_result =
      AdapterManager::GetRoutingResult()->GetLatestObserved();

  auto debug_routing = planning_data->mutable_routing();
  debug_routing->CopyFrom(routing_result);
}

void Planning::RunOnce() {
  AdapterManager::Observe();
  if (AdapterManager::GetLocalization()->Empty()) {
    AERROR << "Localization is not available; skip the planning cycle";
    return;
  }

  if (AdapterManager::GetChassis()->Empty()) {
    AERROR << "Chassis is not available; skip the planning cycle";
    return;
  }
  if (AdapterManager::GetRoutingResult()->Empty()) {
    AERROR << "RoutingResult is not available; skip the planning cycle";
    return;
  }

  // FIXME(all): enable prediction check when perception and prediction is
  // ready.
  // if (FLAGS_enable_prediction && AdapterManager::GetPrediction()->Empty()) {
  //   AERROR << "Prediction is not available; skip the planning cycle";
  //   return;
  // }

  AINFO << "Start planning ...";
  const double start_timestamp = apollo::common::time::ToSecond(Clock::Now());

  // localization
  const auto& localization =
      AdapterManager::GetLocalization()->GetLatestObserved();
  ADEBUG << "Get localization:" << localization.DebugString();

  // chassis
  const auto& chassis = AdapterManager::GetChassis()->GetLatestObserved();
  ADEBUG << "Get chassis:" << chassis.DebugString();

  common::VehicleState::instance()->Update(localization, chassis);

  const double planning_cycle_time = 1.0 / FLAGS_planning_loop_rate;

  ADCTrajectory trajectory_pb;
  RecordInput(&trajectory_pb);

  const uint32_t frame_num = AdapterManager::GetPlanning()->GetSeqNum() + 1;
  if (!InitFrame(frame_num)) {
    AERROR << "Init frame failed";
    return;
  }

  bool is_auto_mode = chassis.driving_mode() == chassis.COMPLETE_AUTO_DRIVE;
  bool res_planning = Plan(is_auto_mode, start_timestamp, planning_cycle_time,
      &trajectory_pb);

  const double end_timestamp = apollo::common::time::ToSecond(Clock::Now());
  const double time_diff_ms = (end_timestamp - start_timestamp) * 1000;
  trajectory_pb.mutable_latency_stats()->set_total_time_ms(time_diff_ms);
  ADEBUG << "Planning latency: " << trajectory_pb.latency_stats().DebugString();

  if (res_planning) {
    AdapterManager::FillPlanningHeader("planning", &trajectory_pb);
    trajectory_pb.mutable_header()->set_timestamp_sec(start_timestamp);
    // TODO(all): integrate reverse gear
    trajectory_pb.set_gear(canbus::Chassis::GEAR_DRIVE);
    AdapterManager::PublishPlanning(trajectory_pb);
    ADEBUG << "Planning succeeded:" << trajectory_pb.header().DebugString();
  } else {
    AERROR << "Planning failed";
  }
}

void Planning::Stop() {}

bool Planning::Plan(const bool is_on_auto_mode,
                    const double current_time_stamp,
                    const double planning_cycle_time,
                    ADCTrajectory* trajectory_pb) {

  const auto& stitching_trajectory =
      TrajectoryStitcher::compute_stitching_trajectory(
          is_on_auto_mode, current_time_stamp, planning_cycle_time,
          last_publishable_trajectory_);

  frame_->SetPlanningStartPoint(stitching_trajectory.back());

  PublishableTrajectory publishable_trajectory;
  auto status = planner_->Plan(stitching_trajectory.back(),
      frame_.get(), &publishable_trajectory, trajectory_pb->mutable_debug(),
      trajectory_pb->mutable_latency_stats());

  if (status != Status::OK()) {
    AERROR << "planner failed to make a driving plan";
    last_publishable_trajectory_.Clear();
    return false;
  }

  publishable_trajectory.prepend_trajectory_points(
      stitching_trajectory.begin(), stitching_trajectory.end() - 1);

  publishable_trajectory.set_header_time(current_time_stamp);

  publishable_trajectory.populate_trajectory_protobuf(trajectory_pb);

  // update last publishable trajectory;
  last_publishable_trajectory_ = std::move(publishable_trajectory);
  return true;
}

}  // namespace planning
}  // namespace apollo
<|endoftext|>


<commit_before>/*
 * SessionConnectionsIndexer.cpp
 *
 * Copyright (C) 2009-16 by RStudio, Inc.
 *
 * Unless you have received this program directly from RStudio pursuant
 * to the terms of a commercial license agreement with RStudio, then
 * this program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

#include <core/Macros.hpp>
#include <core/Algorithm.hpp>
#include <core/Debug.hpp>
#include <core/Error.hpp>
#include <core/Exec.hpp>
#include <core/FilePath.hpp>
#include <core/FileSerializer.hpp>
#include <core/text/DcfParser.hpp>

#include <boost/regex.hpp>
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
#include <boost/range/adaptor/map.hpp>
#include <boost/system/error_code.hpp>

#include <r/RSexp.hpp>
#include <r/RExec.hpp>

#include <session/projects/SessionProjects.hpp>
#include <session/SessionModuleContext.hpp>
#include <session/SessionPackageProvidedExtension.hpp>

using namespace rstudio::core;

namespace rstudio {
namespace session {
namespace modules {
namespace connections {

namespace {

class SessionConnectionsIndexEntry
{
public:

   SessionConnectionsIndexEntry() {}

   SessionConnectionsIndexEntry(const std::string& name,
                                const std::string& package)
      : name_(name), package_(package)
   {
   }

   const std::string& getName() const { return name_; }
   const std::string& getPackage() const { return package_; }

   json::Object toJson() const
   {
      json::Object object;

      object["name"] = name_;
      object["package"] = package_;

      return object;
   }

private:
   std::string name_;
   std::string package_;
};

}

} // namespace connections
} // namespace modules
} // namesapce session
} // namespace rstudio

<commit_msg>implement a connections registry based of addinregistry<commit_after>/*
 * SessionConnectionsIndexer.cpp
 *
 * Copyright (C) 2009-16 by RStudio, Inc.
 *
 * Unless you have received this program directly from RStudio pursuant
 * to the terms of a commercial license agreement with RStudio, then
 * this program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

#include <core/Macros.hpp>
#include <core/Algorithm.hpp>
#include <core/Debug.hpp>
#include <core/Error.hpp>
#include <core/Exec.hpp>
#include <core/FilePath.hpp>
#include <core/FileSerializer.hpp>
#include <core/text/DcfParser.hpp>

#include <boost/regex.hpp>
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
#include <boost/range/adaptor/map.hpp>
#include <boost/system/error_code.hpp>

#include <r/RSexp.hpp>
#include <r/RExec.hpp>

#include <session/projects/SessionProjects.hpp>
#include <session/SessionModuleContext.hpp>
#include <session/SessionPackageProvidedExtension.hpp>

using namespace rstudio::core;

namespace rstudio {
namespace session {
namespace modules {
namespace connections {

namespace {

class SessionConnectionsIndexEntry
{
public:

   SessionConnectionsIndexEntry() {}

   SessionConnectionsIndexEntry(const std::string& name,
                                const std::string& package)
      : name_(name), package_(package)
   {
   }

   const std::string& getName() const { return name_; }
   const std::string& getPackage() const { return package_; }

   json::Object toJson() const
   {
      json::Object object;

      object["name"] = name_;
      object["package"] = package_;

      return object;
   }

private:
   std::string name_;
   std::string package_;
};

class SessionConnectionsIndexRegistry : boost::noncopyable
{
public:

   void add(const std::string& package, const SessionConnectionsIndexEntry& spec)
   {
      connections_[constructKey(package, spec.getName())] = spec;
   }

   void add(const std::string& pkgName,
            std::map<std::string, std::string>& fields)
   {
      add(pkgName, SessionConnectionsIndexEntry(
            fields["Name"],
            pkgName));
   }

   void add(const std::string& pkgName, const FilePath& connectionExtensionPath)
   {
      static const boost::regex reSeparator("\\n{2,}");

      std::string contents;
      Error error = core::readStringFromFile(connectionExtensionPath, &contents, string_utils::LineEndingPosix);
      if (error)
      {
         LOG_ERROR(error);
         return;
      }

      boost::sregex_token_iterator it(contents.begin(), contents.end(), reSeparator, -1);
      boost::sregex_token_iterator end;

      for (; it != end; ++it)
      {
         std::map<std::string, std::string> fields = parseConnectionsDcf(*it);
         add(pkgName, fields);
      }
   }

   bool contains(const std::string& package, const std::string& name)
   {
      return connections_.count(constructKey(package, name));
   }

   const SessionConnectionsIndexEntry& get(const std::string& package, const std::string& name)
   {
      return connections_[constructKey(package, name)];
   }

   json::Object toJson() const
   {
      json::Object object;

      BOOST_FOREACH(const std::string& key, connections_ | boost::adaptors::map_keys)
      {
         object[key] = connections_.at(key).toJson();
      }

      return object;
   }

   std::size_t size() const { return connections_.size(); }

private:

   static std::map<std::string, std::string> parseConnectionsDcf(
       const std::string& contents)
   {
      // read and parse the DCF file
      std::map<std::string, std::string> fields;
      std::string errMsg;
      Error error = text::parseDcfFile(contents, true, &fields, &errMsg);
      if (error)
         LOG_ERROR(error);

      return fields;
   }

   static std::string constructKey(const std::string& package, const std::string& name)
   {
      return package + "::" + name;
   }

   std::map<std::string, SessionConnectionsIndexEntry> connections_;
};

}

} // namespace connections
} // namespace modules
} // namesapce session
} // namespace rstudio

<|endoftext|>


<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/ocmb/odyssey/common/include/ody_scom_mp.H $  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2021,2022                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#pragma once

#include "ody_scom_mp_rdf.H"
<commit_msg>Add Synopsys includes and test.<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/ocmb/odyssey/common/include/ody_scom_mp.H $  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2021,2022                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#pragma once

#include "ody_scom_mp_rdf.H"
#include "ody_scom_mp_acsm0_b0.H"
#include "ody_scom_mp_acsm0_b1.H"
#include "ody_scom_mp_acsm0_b2.H"
#include "ody_scom_mp_acsm0_b3.H"
#include "ody_scom_mp_anib0_b0.H"
#include "ody_scom_mp_anib0_b1.H"
#include "ody_scom_mp_anib0_b2.H"
#include "ody_scom_mp_anib0_b3.H"
#include "ody_scom_mp_anib10_b0.H"
#include "ody_scom_mp_anib10_b1.H"
#include "ody_scom_mp_anib10_b2.H"
#include "ody_scom_mp_anib10_b3.H"
#include "ody_scom_mp_anib11_b0.H"
#include "ody_scom_mp_anib11_b1.H"
#include "ody_scom_mp_anib11_b2.H"
#include "ody_scom_mp_anib11_b3.H"
#include "ody_scom_mp_anib12_b0.H"
#include "ody_scom_mp_anib12_b1.H"
#include "ody_scom_mp_anib12_b2.H"
#include "ody_scom_mp_anib12_b3.H"
#include "ody_scom_mp_anib13_b0.H"
#include "ody_scom_mp_anib13_b1.H"
#include "ody_scom_mp_anib13_b2.H"
#include "ody_scom_mp_anib13_b3.H"
#include "ody_scom_mp_anib1_b0.H"
#include "ody_scom_mp_anib1_b1.H"
#include "ody_scom_mp_anib1_b2.H"
#include "ody_scom_mp_anib1_b3.H"
#include "ody_scom_mp_anib2_b0.H"
#include "ody_scom_mp_anib2_b1.H"
#include "ody_scom_mp_anib2_b2.H"
#include "ody_scom_mp_anib2_b3.H"
#include "ody_scom_mp_anib3_b0.H"
#include "ody_scom_mp_anib3_b1.H"
#include "ody_scom_mp_anib3_b2.H"
#include "ody_scom_mp_anib3_b3.H"
#include "ody_scom_mp_anib4_b0.H"
#include "ody_scom_mp_anib4_b1.H"
#include "ody_scom_mp_anib4_b2.H"
#include "ody_scom_mp_anib4_b3.H"
#include "ody_scom_mp_anib5_b0.H"
#include "ody_scom_mp_anib5_b1.H"
#include "ody_scom_mp_anib5_b2.H"
#include "ody_scom_mp_anib5_b3.H"
#include "ody_scom_mp_anib6_b0.H"
#include "ody_scom_mp_anib6_b1.H"
#include "ody_scom_mp_anib6_b2.H"
#include "ody_scom_mp_anib6_b3.H"
#include "ody_scom_mp_anib7_b0.H"
#include "ody_scom_mp_anib7_b1.H"
#include "ody_scom_mp_anib7_b2.H"
#include "ody_scom_mp_anib7_b3.H"
#include "ody_scom_mp_anib8_b0.H"
#include "ody_scom_mp_anib8_b1.H"
#include "ody_scom_mp_anib8_b2.H"
#include "ody_scom_mp_anib8_b3.H"
#include "ody_scom_mp_anib9_b0.H"
#include "ody_scom_mp_anib9_b1.H"
#include "ody_scom_mp_anib9_b2.H"
#include "ody_scom_mp_anib9_b3.H"
#include "ody_scom_mp_apbonly0.H"
#include "ody_scom_mp_dbyte0_b0.H"
#include "ody_scom_mp_dbyte0_b1.H"
#include "ody_scom_mp_dbyte0_b2.H"
#include "ody_scom_mp_dbyte0_b3.H"
#include "ody_scom_mp_dbyte1_b0.H"
#include "ody_scom_mp_dbyte1_b1.H"
#include "ody_scom_mp_dbyte1_b2.H"
#include "ody_scom_mp_dbyte1_b3.H"
#include "ody_scom_mp_dbyte2_b0.H"
#include "ody_scom_mp_dbyte2_b1.H"
#include "ody_scom_mp_dbyte2_b2.H"
#include "ody_scom_mp_dbyte2_b3.H"
#include "ody_scom_mp_dbyte3_b0.H"
#include "ody_scom_mp_dbyte3_b1.H"
#include "ody_scom_mp_dbyte3_b2.H"
#include "ody_scom_mp_dbyte3_b3.H"
#include "ody_scom_mp_dbyte4_b0.H"
#include "ody_scom_mp_dbyte4_b1.H"
#include "ody_scom_mp_dbyte4_b2.H"
#include "ody_scom_mp_dbyte4_b3.H"
#include "ody_scom_mp_dbyte5_b0.H"
#include "ody_scom_mp_dbyte5_b1.H"
#include "ody_scom_mp_dbyte5_b2.H"
#include "ody_scom_mp_dbyte5_b3.H"
#include "ody_scom_mp_dbyte6_b0.H"
#include "ody_scom_mp_dbyte6_b1.H"
#include "ody_scom_mp_dbyte6_b2.H"
#include "ody_scom_mp_dbyte6_b3.H"
#include "ody_scom_mp_dbyte7_b0.H"
#include "ody_scom_mp_dbyte7_b1.H"
#include "ody_scom_mp_dbyte7_b2.H"
#include "ody_scom_mp_dbyte7_b3.H"
#include "ody_scom_mp_dbyte8_b0.H"
#include "ody_scom_mp_dbyte8_b1.H"
#include "ody_scom_mp_dbyte8_b2.H"
#include "ody_scom_mp_dbyte8_b3.H"
#include "ody_scom_mp_dbyte9_b0.H"
#include "ody_scom_mp_dbyte9_b1.H"
#include "ody_scom_mp_dbyte9_b2.H"
#include "ody_scom_mp_dbyte9_b3.H"
#include "ody_scom_mp_drtub0.H"
#include "ody_scom_mp_intgo_b0.H"
#include "ody_scom_mp_intgo_b1.H"
#include "ody_scom_mp_intgo_b2.H"
#include "ody_scom_mp_intgo_b3.H"
#include "ody_scom_mp_mastr_b0.H"
#include "ody_scom_mp_mastr_b1.H"
#include "ody_scom_mp_mastr_b2.H"
#include "ody_scom_mp_mastr_b3.H"
#include "ody_scom_mp_ppgc0.H"
<|endoftext|>