<commit_before>#include "stdafx.h"
#include "scene.h"

Scene::Scene()
{
    _models = shared_ptr<vector<Model>>(new vector<Model>());
    _lights = shared_ptr<vector<Light>>(new vector<Light>());
    _resourceMappings = shared_ptr<vector<ResourceMapping>>(new vector<ResourceMapping>());
}

void Scene::Clear()
{

}

void Scene::Render()
{

}

void Scene::AddModel(Model *model)
{
    _models->push_back(*model);
}

void Scene::AddLight(Light *light)
{
    _lights->push_back(*light);
}

void Scene::AddCamera(Camera *camera)
{
    _camera = shared_ptr<Camera>(camera);
}

void Scene::AddResourceMapping(ResourceMapping *mapping)
{
    _resourceMappings->push_back(*mapping);
}

void Scene::Load(wstring fileName)
{
}

void Scene::SetAmbientLight(XMFLOAT4 *colorIntensity)
{
    D3D11_BUFFER_DESC ambientBufferDesc = { 0 };
    ambientBufferDesc.ByteWidth = sizeof(XMFLOAT4);
    ambientBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;

    D3D11_SUBRESOURCE_DATA  ambientBufferData = { 0 };
    ambientBufferData.pSysMem = colorIntensity;
    ambientBufferData.SysMemPitch = 0;
    ambientBufferData.SysMemSlicePitch = 0;

    Res::Get()->Device->CreateBuffer(&ambientBufferDesc, &ambientBufferData, &_ambientBuffer);
}

Scene* Scene::CreateStandardScene()
{
    auto scene = new Scene();
    scene->SetAmbientLight(new XMFLOAT4(1.0f, 1.0f, 1.0f, 0.1f));

    auto stdCamera = new Camera();
    stdCamera->SetPosition(new XMFLOAT3(0.0f, 0.0f, 5.0f));
    stdCamera->SetFocusPoint(new XMFLOAT3(0.0f, 0.0f, 0.0f));
    scene->AddCamera(stdCamera);

    auto pointLightPosition = new XMFLOAT3(1.0f, 1.0f, 1.0f);
    auto pointLightColorIntensity = new XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f);
    auto stdPointLight = new PointLight();
    stdPointLight->SetPosition(pointLightPosition);
    stdPointLight->SetColorIntensity(pointLightColorIntensity);
    scene->AddLight(stdPointLight);

    auto stdPixelShader = PixelShader::Load(L"../Debug/PhongPixelShader.cso");
    auto stdVertexShader = VertexShader::Load(L"../Debug/PhongVertexShader.cso");

    auto stdHullShader = HullShader::Load(L"../Debug/TesselationHullShader.cso");
    auto stdDomainShader = DomainShader::Load(L"../Debug/TesselationDomainShader.cso");

    auto shaders = new Shaders();
    shaders->PixelShader = stdPixelShader;
    shaders->VertexShader = stdVertexShader;
    shaders->HullShader = stdHullShader;
    shaders->DomainShader = stdDomainShader;

    auto phongMaterial1 = new Material();
    phongMaterial1->AssignShaders(shaders);
    phongMaterial1->SetColor(new XMFLOAT4(0.1f, 0.1f, 0.6f, 1.0f));

    auto phongMaterial2 = new Material();
    auto gridTexture = Texture::Load(L"../Textures/grid_texture.dds");
    phongMaterial2->AssignTexture(gridTexture);
    phongMaterial2->AssignShaders(shaders);
    phongMaterial2->SetColor(new XMFLOAT4(0.8f, 0.8f, 0.8f, 1.0f));

    auto stdTeapot = Model::LoadModelFromFBXFile("../Debug/teapot.fbx");
    stdTeapot->AssignMaterial(phongMaterial1);
    scene->AddModel(stdTeapot);

    auto stdPlane = Model::CreateHorizontalPlane(20.0f, new XMFLOAT3(0.0f, 0.0f, 0.0f));
    stdPlane->AssignMaterial(phongMaterial2);
    scene->AddModel(stdPlane);

    auto cameraMatrixBuffer = stdCamera->GetMatrixBuffer();
    auto cameraPositionBuffer = stdCamera->GetPositionBuffer();
    auto sceneAmbientBuffer = scene->GetAmbientBuffer();

    ResourceMapping m1 = { cameraMatrixBuffer, shaders->PixelShader->GetInput() };
    scene->AddResourceMapping(&m1);

    ResourceMapping m2 = { cameraPositionBuffer, shaders->PixelShader->GetInput() };
    scene->AddResourceMapping(&m2);

    ResourceMapping m3 = { sceneAmbientBuffer, shaders->PixelShader->GetInput() };
    scene->AddResourceMapping(&m3);

    ResourceMapping m4 = { stdPointLight->GetBuffer(), shaders->PixelShader->GetInput() };
    scene->AddResourceMapping(&m4);

    return scene;
}<commit_msg>updated scene to use texture shaders<commit_after>#include "stdafx.h"
#include "scene.h"

Scene::Scene()
{
    _models = shared_ptr<vector<Model>>(new vector<Model>());
    _lights = shared_ptr<vector<Light>>(new vector<Light>());
    _resourceMappings = shared_ptr<vector<ResourceMapping>>(new vector<ResourceMapping>());
}

void Scene::Clear()
{

}

void Scene::Render()
{

}

void Scene::AddModel(Model *model)
{
    _models->push_back(*model);
}

void Scene::AddLight(Light *light)
{
    _lights->push_back(*light);
}

void Scene::AddCamera(Camera *camera)
{
    _camera = shared_ptr<Camera>(camera);
}

void Scene::AddResourceMapping(ResourceMapping *mapping)
{
    _resourceMappings->push_back(*mapping);
}

void Scene::Load(wstring fileName)
{
}

void Scene::SetAmbientLight(XMFLOAT4 *colorIntensity)
{
    D3D11_BUFFER_DESC ambientBufferDesc = { 0 };
    ambientBufferDesc.ByteWidth = sizeof(XMFLOAT4);
    ambientBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;

    D3D11_SUBRESOURCE_DATA  ambientBufferData = { 0 };
    ambientBufferData.pSysMem = colorIntensity;
    ambientBufferData.SysMemPitch = 0;
    ambientBufferData.SysMemSlicePitch = 0;

    Res::Get()->Device->CreateBuffer(&ambientBufferDesc, &ambientBufferData, &_ambientBuffer);
}

Scene* Scene::CreateStandardScene()
{
    auto scene = new Scene();
    scene->SetAmbientLight(new XMFLOAT4(1.0f, 1.0f, 1.0f, 0.1f));

    auto stdCamera = new Camera();
    stdCamera->SetPosition(new XMFLOAT3(0.0f, 0.0f, 5.0f));
    stdCamera->SetFocusPoint(new XMFLOAT3(0.0f, 0.0f, 0.0f));
    scene->AddCamera(stdCamera);

    auto pointLightPosition = new XMFLOAT3(1.0f, 1.0f, 1.0f);
    auto pointLightColorIntensity = new XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f);
    auto stdPointLight = new PointLight();
    stdPointLight->SetPosition(pointLightPosition);
    stdPointLight->SetColorIntensity(pointLightColorIntensity);
    scene->AddLight(stdPointLight);

    /* teapot */
    auto phongPixelShader = PixelShader::Load(L"../Debug/PhongPixelShader.cso");
    auto phongVertexShader = VertexShader::Load(L"../Debug/PhongVertexShader.cso");

    auto phongShaders = new Shaders();
    phongShaders->PixelShader = phongPixelShader;
    phongShaders->VertexShader = phongVertexShader;

    auto phongMaterial = new Material();
    phongMaterial->AssignShaders(phongShaders);
    phongMaterial->SetColor(new XMFLOAT4(0.1f, 0.1f, 0.6f, 1.0f));

    auto teapot = Model::LoadModelFromFBXFile("../Debug/teapot.fbx");
    teapot->AssignMaterial(phongMaterial);
    scene->AddModel(teapot);

    /* plane */
    auto texturePixelShader = PixelShader::Load(L"../Debug/TexturePixelShader.cso");
    auto textureVertexShader = VertexShader::Load(L"../Debug/TextureVertexShader.cso");

    auto textureShaders = new Shaders();
    textureShaders->PixelShader = texturePixelShader;
    textureShaders->VertexShader = textureVertexShader;

    auto textureMaterial = new Material();
    auto gridTexture = Texture::Load(L"../Textures/grid_texture.dds");
    textureMaterial->AssignTexture(gridTexture);
    textureMaterial->AssignShaders(textureShaders);
    textureMaterial->SetColor(new XMFLOAT4(0.8f, 0.8f, 0.8f, 1.0f));

    auto plane = Model::CreateHorizontalPlane(20.0f, new XMFLOAT3(0.0f, 0.0f, 0.0f));
    plane->AssignMaterial(textureMaterial);
    scene->AddModel(plane);

    auto cameraMatrixBuffer = stdCamera->GetMatrixBuffer();
    auto cameraPositionBuffer = stdCamera->GetPositionBuffer();
    auto sceneAmbientBuffer = scene->GetAmbientBuffer();

    ResourceMapping m1 = { cameraMatrixBuffer, phongShaders->PixelShader->GetInput() };
    scene->AddResourceMapping(&m1);

    ResourceMapping m2 = { cameraPositionBuffer, phongShaders->PixelShader->GetInput() };
    scene->AddResourceMapping(&m2);

    ResourceMapping m3 = { sceneAmbientBuffer, phongShaders->PixelShader->GetInput() };
    scene->AddResourceMapping(&m3);

    ResourceMapping m4 = { stdPointLight->GetBuffer(), phongShaders->PixelShader->GetInput() };
    scene->AddResourceMapping(&m4);

    return scene;
}<|endoftext|>


<commit_before>#include <cstring>

#include "socket.h"

#include "../model/charnames.h"

using namespace charnames;

#include <iostream>

using namespace std;

void Socket::flushIn() {
	inBuffer.clear();
	const size_t bufsize = 4096;
	char b[bufsize];
	long size;
	bool cont = true;
	do {
		memset(b, nul, bufsize);
		size = Recv((void *)b, bufsize-1);
		if(size > 0) {
			cerr << size << " bytes partial: `" << b << '`';
			inBuffer.insert(inBuffer.end(), b, b + size);
			cerr << ", last char is " << (int)b[size - 1];
			cont = b[size - 1] != ht;
		} else {
			cont = false;
			if (size < 0) {
				cerr << "Error in connection!";
			} else {
				cerr << "Empty partial";
			}
		}
		cerr << endl;
	} while (cont);
	size_t s = (size_t)inBuffer.size() + 1;
	char message[s];
	strncpy(message, inBuffer.data(), s - 1);
	message[s - 1] = nul;
	cerr << "Received `" << message << '`' << endl;
}

void Socket::flushOut() {
	outBuffer.push_back(eot);
	Send((void *)outBuffer.data(), outBuffer.size());
	outBuffer.clear();
}

Socket& Socket::operator<<(char c) {
	outBuffer.push_back(c);
	return *this;
}

Socket& Socket::operator<<(int i) {
	return *this<<(long)i;
}

Socket& Socket::operator<<(long l) {
	auto n = htonl(l);
	for(auto i = sizeof(n); i > 0; i--) {
		*this << (char)n;
		n >>= 8;
	}
}

Socket& Socket::operator<<(size_t s) {
	return *this<<(long)s;
}

Socket& Socket::operator<<(std::string s) {
	for(size_t i = 0; i < s.length(); i++) {
		*this<<s[i];
	}
	*this<<nul;
	return *this;
}

Socket& Socket::operator<<(double d) {
	return *this << (int)(d * 100);
}

<commit_msg>Quito mensaje de debug que requiere C++14<commit_after>#include <cstring>

#include "socket.h"

#include "../model/charnames.h"

using namespace charnames;

#include <iostream>

using namespace std;

void Socket::flushIn() {
	inBuffer.clear();
	const size_t bufsize = 4097;
	char b[bufsize];
	long size;
	bool cont = true;
	do {
		memset(b, nul, bufsize);
		size = Recv((void *)b, bufsize-1);
		if(size > 0) {
			cerr << size << " bytes partial: `" << b << '`';
			inBuffer.insert(inBuffer.end(), b, b + size);
			cerr << ", last char is " << (int)b[size - 1];
			cont = b[size - 1] != ht;
		} else {
			cont = false;
			if (size < 0) {
				cerr << "Error in connection!";
			} else {
				cerr << "Empty partial";
			}
		}
		cerr << endl;
	} while (cont);
}

void Socket::flushOut() {
	outBuffer.push_back(eot);
	Send((void *)outBuffer.data(), outBuffer.size());
	outBuffer.clear();
}

Socket& Socket::operator<<(char c) {
	outBuffer.push_back(c);
	return *this;
}

Socket& Socket::operator<<(int i) {
	return *this<<(long)i;
}

Socket& Socket::operator<<(long l) {
	auto n = htonl(l);
	for(auto i = sizeof(n); i > 0; i--) {
		*this << (char)n;
		n >>= 8;
	}
}

Socket& Socket::operator<<(size_t s) {
	return *this<<(long)s;
}

Socket& Socket::operator<<(std::string s) {
	for(size_t i = 0; i < s.length(); i++) {
		*this<<s[i];
	}
	*this<<nul;
	return *this;
}

Socket& Socket::operator<<(double d) {
	return *this << (int)(d * 100);
}

<|endoftext|>


<commit_before>/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company.  For licensing terms and
** conditions see http://www.qt.io/terms-conditions.  For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights.  These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/

#include "translationunit.h"

#include "codecompleter.h"
#include "projectpart.h"
#include "translationunitfilenotexitexception.h"
#include "translationunitisnullexception.h"
#include "translationunitparseerrorexception.h"
#include "unsavedfiles.h"

#include <utf8string.h>

#include <QFileInfo>

namespace ClangBackEnd {

class TranslationUnitData
{
public:
    TranslationUnitData(const Utf8String &filePath,
                        const UnsavedFiles &unsavedFiles,
                        const ProjectPart &projectPart);
    ~TranslationUnitData();

public:
    time_point lastChangeTimePoint;
    ProjectPart projectPart;
    Utf8String filePath;
    CXTranslationUnit translationUnit = nullptr;
    CXIndex index = nullptr;
    UnsavedFiles unsavedFiles;
};

TranslationUnitData::TranslationUnitData(const Utf8String &filePath,
                                         const UnsavedFiles &unsavedFiles,
                                         const ProjectPart &projectPart)
    : lastChangeTimePoint(std::chrono::steady_clock::now()),
      projectPart(projectPart),
      filePath(filePath),
      unsavedFiles(unsavedFiles)
{
}

TranslationUnitData::~TranslationUnitData()
{
    clang_disposeTranslationUnit(translationUnit);
    clang_disposeIndex(index);
}

TranslationUnit::TranslationUnit(const Utf8String &filePath,
                                 const UnsavedFiles &unsavedFiles,
                                 const ProjectPart &project,
                                 FileExistsCheck fileExistsCheck)
    : d(std::make_shared<TranslationUnitData>(filePath, unsavedFiles, project))
{
    if (fileExistsCheck == CheckIfFileExists)
        checkIfFileExists();
}

bool TranslationUnit::isNull() const
{
    return !d;
}

void TranslationUnit::reset()
{
    d.reset();
}

void TranslationUnit::reparse()
{
    cxTranslationUnit();

    reparseTranslationUnit();
}

CXIndex TranslationUnit::index() const
{
    checkIfNull();

    if (!d->index)
        d->index = clang_createIndex(1, 1);

    return d->index;
}

CXTranslationUnit TranslationUnit::cxTranslationUnit() const
{
    checkIfNull();

    removeOutdatedTranslationUnit();

    createTranslationUnitIfNeeded();

    return d->translationUnit;
}

const Utf8String &TranslationUnit::filePath() const
{
    checkIfNull();

    return d->filePath;
}

const Utf8String &TranslationUnit::projectPartId() const
{
    checkIfNull();

    return d->projectPart.projectPartId();
}

const time_point &TranslationUnit::lastChangeTimePoint() const
{
    return d->lastChangeTimePoint;
}

void TranslationUnit::checkIfNull() const
{
    if (isNull())
        throw TranslationUnitIsNullException();
}

void TranslationUnit::checkIfFileExists() const
{
    if (!QFileInfo::exists(d->filePath.toString()))
        throw TranslationUnitFileNotExitsException(d->filePath);
}

void TranslationUnit::updateLastChangeTimePoint() const
{
    d->lastChangeTimePoint = std::chrono::steady_clock::now();
}

void TranslationUnit::removeOutdatedTranslationUnit() const
{
    if (d->projectPart.lastChangeTimePoint() >= d->lastChangeTimePoint) {
        clang_disposeTranslationUnit(d->translationUnit);
        d->translationUnit = nullptr;
    }
}

void TranslationUnit::createTranslationUnitIfNeeded() const
{
    if (!d->translationUnit) {
        d->translationUnit = CXTranslationUnit();
        CXErrorCode errorCode = clang_parseTranslationUnit2(index(),
                                                            d->filePath.constData(),
                                                            d->projectPart.cxArguments(),
                                                            d->projectPart.argumentCount(),
                                                            d->unsavedFiles.cxUnsavedFiles(),
                                                            d->unsavedFiles.count(),
                                                            defaultOptions(),
                                                            &d->translationUnit);

        checkTranslationUnitErrorCode(errorCode);

        // We need to reparse to create the precompiled preamble, which will speed up further calls,
        // e.g. clang_codeCompleteAt() dramatically.
        reparseTranslationUnit();

        updateLastChangeTimePoint();
    }
}

void TranslationUnit::checkTranslationUnitErrorCode(CXErrorCode errorCode) const
{
    switch (errorCode) {
        case CXError_Success: break;
        default: throw TranslationUnitParseErrorException(d->filePath, d->projectPart.projectPartId());
    }
}

void TranslationUnit::reparseTranslationUnit() const
{
    clang_reparseTranslationUnit(d->translationUnit,
                                 d->unsavedFiles.count(),
                                 d->unsavedFiles.cxUnsavedFiles(),
                                 clang_defaultReparseOptions(d->translationUnit));
}

int TranslationUnit::defaultOptions()
{
    return CXTranslationUnit_CacheCompletionResults
         | CXTranslationUnit_PrecompiledPreamble
         | CXTranslationUnit_SkipFunctionBodies;
}

uint TranslationUnit::unsavedFilesCount() const
{
    return d->unsavedFiles.count();
}

CXUnsavedFile *TranslationUnit::cxUnsavedFiles() const
{
    return d->unsavedFiles.cxUnsavedFiles();
}

TranslationUnit::~TranslationUnit() = default;

TranslationUnit::TranslationUnit(const TranslationUnit &) = default;
TranslationUnit &TranslationUnit::operator=(const TranslationUnit &) = default;

TranslationUnit::TranslationUnit(TranslationUnit &&other)
    : d(std::move(other.d))
{
}

TranslationUnit &TranslationUnit::operator=(TranslationUnit &&other)
{
    d = std::move(other.d);

    return *this;
}

bool operator==(const TranslationUnit &first, const TranslationUnit &second)
{
    return first.filePath() == second.filePath() && first.projectPartId() == second.projectPartId();
}

} // namespace ClangBackEnd

<commit_msg>Clang: Suppress printing diagnostics by default<commit_after>/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company.  For licensing terms and
** conditions see http://www.qt.io/terms-conditions.  For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights.  These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/

#include "translationunit.h"

#include "codecompleter.h"
#include "projectpart.h"
#include "translationunitfilenotexitexception.h"
#include "translationunitisnullexception.h"
#include "translationunitparseerrorexception.h"
#include "unsavedfiles.h"

#include <utf8string.h>

#include <QFileInfo>
#include <QLoggingCategory>

static Q_LOGGING_CATEGORY(verboseLibLog, "qtc.clangbackend.verboselib");

namespace ClangBackEnd {

class TranslationUnitData
{
public:
    TranslationUnitData(const Utf8String &filePath,
                        const UnsavedFiles &unsavedFiles,
                        const ProjectPart &projectPart);
    ~TranslationUnitData();

public:
    time_point lastChangeTimePoint;
    ProjectPart projectPart;
    Utf8String filePath;
    CXTranslationUnit translationUnit = nullptr;
    CXIndex index = nullptr;
    UnsavedFiles unsavedFiles;
};

TranslationUnitData::TranslationUnitData(const Utf8String &filePath,
                                         const UnsavedFiles &unsavedFiles,
                                         const ProjectPart &projectPart)
    : lastChangeTimePoint(std::chrono::steady_clock::now()),
      projectPart(projectPart),
      filePath(filePath),
      unsavedFiles(unsavedFiles)
{
}

TranslationUnitData::~TranslationUnitData()
{
    clang_disposeTranslationUnit(translationUnit);
    clang_disposeIndex(index);
}

TranslationUnit::TranslationUnit(const Utf8String &filePath,
                                 const UnsavedFiles &unsavedFiles,
                                 const ProjectPart &project,
                                 FileExistsCheck fileExistsCheck)
    : d(std::make_shared<TranslationUnitData>(filePath, unsavedFiles, project))
{
    if (fileExistsCheck == CheckIfFileExists)
        checkIfFileExists();
}

bool TranslationUnit::isNull() const
{
    return !d;
}

void TranslationUnit::reset()
{
    d.reset();
}

void TranslationUnit::reparse()
{
    cxTranslationUnit();

    reparseTranslationUnit();
}

CXIndex TranslationUnit::index() const
{
    checkIfNull();

    if (!d->index) {
        const bool displayDiagnostics = verboseLibLog().isDebugEnabled();
        d->index = clang_createIndex(1, displayDiagnostics);
    }

    return d->index;
}

CXTranslationUnit TranslationUnit::cxTranslationUnit() const
{
    checkIfNull();

    removeOutdatedTranslationUnit();

    createTranslationUnitIfNeeded();

    return d->translationUnit;
}

const Utf8String &TranslationUnit::filePath() const
{
    checkIfNull();

    return d->filePath;
}

const Utf8String &TranslationUnit::projectPartId() const
{
    checkIfNull();

    return d->projectPart.projectPartId();
}

const time_point &TranslationUnit::lastChangeTimePoint() const
{
    return d->lastChangeTimePoint;
}

void TranslationUnit::checkIfNull() const
{
    if (isNull())
        throw TranslationUnitIsNullException();
}

void TranslationUnit::checkIfFileExists() const
{
    if (!QFileInfo::exists(d->filePath.toString()))
        throw TranslationUnitFileNotExitsException(d->filePath);
}

void TranslationUnit::updateLastChangeTimePoint() const
{
    d->lastChangeTimePoint = std::chrono::steady_clock::now();
}

void TranslationUnit::removeOutdatedTranslationUnit() const
{
    if (d->projectPart.lastChangeTimePoint() >= d->lastChangeTimePoint) {
        clang_disposeTranslationUnit(d->translationUnit);
        d->translationUnit = nullptr;
    }
}

void TranslationUnit::createTranslationUnitIfNeeded() const
{
    if (!d->translationUnit) {
        d->translationUnit = CXTranslationUnit();
        CXErrorCode errorCode = clang_parseTranslationUnit2(index(),
                                                            d->filePath.constData(),
                                                            d->projectPart.cxArguments(),
                                                            d->projectPart.argumentCount(),
                                                            d->unsavedFiles.cxUnsavedFiles(),
                                                            d->unsavedFiles.count(),
                                                            defaultOptions(),
                                                            &d->translationUnit);

        checkTranslationUnitErrorCode(errorCode);

        // We need to reparse to create the precompiled preamble, which will speed up further calls,
        // e.g. clang_codeCompleteAt() dramatically.
        reparseTranslationUnit();

        updateLastChangeTimePoint();
    }
}

void TranslationUnit::checkTranslationUnitErrorCode(CXErrorCode errorCode) const
{
    switch (errorCode) {
        case CXError_Success: break;
        default: throw TranslationUnitParseErrorException(d->filePath, d->projectPart.projectPartId());
    }
}

void TranslationUnit::reparseTranslationUnit() const
{
    clang_reparseTranslationUnit(d->translationUnit,
                                 d->unsavedFiles.count(),
                                 d->unsavedFiles.cxUnsavedFiles(),
                                 clang_defaultReparseOptions(d->translationUnit));
}

int TranslationUnit::defaultOptions()
{
    return CXTranslationUnit_CacheCompletionResults
         | CXTranslationUnit_PrecompiledPreamble
         | CXTranslationUnit_SkipFunctionBodies;
}

uint TranslationUnit::unsavedFilesCount() const
{
    return d->unsavedFiles.count();
}

CXUnsavedFile *TranslationUnit::cxUnsavedFiles() const
{
    return d->unsavedFiles.cxUnsavedFiles();
}

TranslationUnit::~TranslationUnit() = default;

TranslationUnit::TranslationUnit(const TranslationUnit &) = default;
TranslationUnit &TranslationUnit::operator=(const TranslationUnit &) = default;

TranslationUnit::TranslationUnit(TranslationUnit &&other)
    : d(std::move(other.d))
{
}

TranslationUnit &TranslationUnit::operator=(TranslationUnit &&other)
{
    d = std::move(other.d);

    return *this;
}

bool operator==(const TranslationUnit &first, const TranslationUnit &second)
{
    return first.filePath() == second.filePath() && first.projectPartId() == second.projectPartId();
}

} // namespace ClangBackEnd

<|endoftext|>


<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/mem/prdfMemRowRepair.C $        */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2018                             */
/* [+] 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                                                     */

/** @file  prdfMemRowRepair.C */

#include <prdfMemRowRepair.H>

#include <UtilHash.H>
#include <iipServiceDataCollector.h>
#include <prdfParserUtils.H>
#include <prdfErrlUtil.H>
#include <prdfMemUtils.H>

#ifdef __HOSTBOOT_MODULE
#include <rowRepairsFuncs.H>
#endif // __HOSTBOOT_MODULE

namespace PRDF
{

using namespace PlatServices;
using namespace PARSERUTILS;
using namespace TARGETING;

//------------------------------------------------------------------------------

bool MemRowRepair::nonZero() const
{
    bool o_nonZero = false;

    for ( uint32_t i = 0; i < ROW_REPAIR::ROW_REPAIR_SIZE; i++ )
    {
        if ( 0 != iv_data[i] )
        {
            o_nonZero = true;
            break;
        }
    }

    return o_nonZero;
}

//##############################################################################
//                              Utility Functions
//##############################################################################

template<TARGETING::TYPE T, fapi2::TargetType F>
uint32_t __getRowRepairData( TargetHandle_t i_dimm, const MemRank & i_rank,
                             MemRowRepair & o_rowRepair )
{
    #define PRDF_FUNC "[PlatServices::__getRowRepairData] "

    uint32_t o_rc = SUCCESS;

    #ifdef __HOSTBOOT_MODULE

    uint8_t l_data[ROW_REPAIR::ROW_REPAIR_SIZE] = {0};

    errlHndl_t l_errl = nullptr;

    // get port select
    uint8_t l_ps = getDimmPort<T>( i_dimm );

    // get mba
    TargetHandle_t l_mba = getConnectedParent( i_dimm, T );
    fapi2::Target<F> l_fapiMba( l_mba );

    FAPI_INVOKE_HWP( l_errl, getRowRepair, l_fapiMba, i_rank.getDimmSlct(),
                     i_rank.getRankSlct(), l_data, l_ps );
    if ( nullptr != l_errl )
    {
        PRDF_ERR( PRDF_FUNC "getRowRepair() failed: i_dimm=0x%08x "
                  "l_ps=%d ds=%d rs=%d", getHuid(i_dimm), l_ps,
                  i_rank.getDimmSlct(), i_rank.getRankSlct() );
        PRDF_COMMIT_ERRL( l_errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    else
    {
        o_rowRepair = MemRowRepair( i_dimm, i_rank, l_data );
    }

    #endif // __HOSTBOOT_MODULE

    return o_rc;

    #undef PRDF_FUNC
}

template<>
uint32_t getRowRepairData<TYPE_MBA>( TargetHandle_t i_dimm,
    const MemRank & i_rank, MemRowRepair & o_rowRepair )
{
    return __getRowRepairData<TYPE_MBA, fapi2::TARGET_TYPE_MBA>( i_dimm, i_rank,
                                                                 o_rowRepair );
}

template<>
uint32_t getRowRepairData<TYPE_MCA>( TargetHandle_t i_dimm,
    const MemRank & i_rank, MemRowRepair & o_rowRepair )
{
    return __getRowRepairData<TYPE_MCA, fapi2::TARGET_TYPE_MCA>( i_dimm, i_rank,
                                                                 o_rowRepair );
}

//------------------------------------------------------------------------------

template<TARGETING::TYPE T, fapi2::TargetType F>
uint32_t __setRowRepairData( TargetHandle_t i_dimm, const MemRank & i_rank,
                           const MemRowRepair & i_rowRepair )
{
    #define PRDF_FUNC "[PlatServices::__setRowRepairData] "

    uint32_t o_rc = SUCCESS;

    #ifdef __HOSTBOOT_MODULE

    if ( !areDramRepairsDisabled() )
    {
        uint8_t l_data[ROW_REPAIR::ROW_REPAIR_SIZE] = {0};
        memcpy( l_data, i_rowRepair.getData(), sizeof(l_data) );

        errlHndl_t l_errl = nullptr;

        // get port select
        uint8_t l_ps = getDimmPort<T>( i_dimm );

        // get mba
        TargetHandle_t l_mba = getConnectedParent(i_dimm, T);
        fapi2::Target<F> l_fapiMba( l_mba );

        FAPI_INVOKE_HWP( l_errl, setRowRepair, l_fapiMba, i_rank.getDimmSlct(),
                         i_rank.getRankSlct(), l_data, l_ps );
        if ( nullptr != l_errl )
        {
            PRDF_ERR( PRDF_FUNC "setRowRepair() failed: i_dimm=0x%08x "
                    "l_ps=%d ds=%d rs=%d", getHuid(i_dimm), l_ps,
                    i_rank.getDimmSlct(), i_rank.getRankSlct() );
            PRDF_COMMIT_ERRL( l_errl, ERRL_ACTION_REPORT );
            o_rc = FAIL;
        }

    }

    #endif // __HOSTBOOT_MODULE

    return o_rc;

    #undef PRDF_FUNC
}

template<>
uint32_t setRowRepairData<TYPE_MBA>( TargetHandle_t i_dimm,
                                     const MemRank & i_rank,
                                     const MemRowRepair & i_rowRepair )
{
    return __setRowRepairData<TYPE_MBA, fapi2::TARGET_TYPE_MBA>( i_dimm, i_rank,
                                                                 i_rowRepair );
}

template<>
uint32_t setRowRepairData<TYPE_MCA>( TargetHandle_t i_dimm,
                                     const MemRank & i_rank,
                                     const MemRowRepair & i_rowRepair )
{
    return __setRowRepairData<TYPE_MCA, fapi2::TARGET_TYPE_MCA>( i_dimm, i_rank,
                                                                 i_rowRepair );
}

//------------------------------------------------------------------------------

template<TARGETING::TYPE T>
void __setRowRepairDataHelper( const MemAddr & i_addr, uint32_t & io_tmp );

template<>
void __setRowRepairDataHelper<TYPE_MBA>( const MemAddr & i_addr,
                                         uint32_t & io_tmp )
{
    #ifdef __HOSTBOOT_MODULE

    // Bank is stored as MBA "(DDR4): bg1-bg0,b1-b0 (4-bit)" in a MemAddr.
    // bank group - 2 bits (bg1-bg0)
    io_tmp = ( io_tmp << 2 ) | ( (i_addr.getBank() >> 2) & 0x03 );

    // bank - 3 bits (b2-b0)
    io_tmp = ( io_tmp << 3 ) | ( i_addr.getBank() & 0x03 );

    // Row is stored as "MBA: r17-r0 (18-bit)" in a MemAddr.
    // row - 18 bits (r17-r0)
    io_tmp = ( io_tmp << 18 ) | ( i_addr.getRow() & 0x0003ffff );

    #endif // __HOSTBOOT_MODULE
}

template<>
void __setRowRepairDataHelper<TYPE_MCA>( const MemAddr & i_addr,
                                         uint32_t & io_tmp )
{
    #ifdef __HOSTBOOT_MODULE

    // Bank is stored as "MCBIST: b0-b2,bg0-bg1 (5-bit)" in a MemAddr.
    // bank group - 2 bits (bg1-bg0)
    uint64_t l_bnkGrp = i_addr.getBank() & 0x03;
    l_bnkGrp = MemUtils::reverseBits( l_bnkGrp, 2 );

    io_tmp = ( io_tmp << 2 ) | ( l_bnkGrp & 0x03 );

    // bank - 3 bits (b2-b0)
    uint64_t l_bnk = (i_addr.getBank() & 0x1C) >> 2;
    l_bnk = MemUtils::reverseBits( l_bnk, 3 );

    io_tmp = ( io_tmp << 3 ) | ( l_bnk & 0x03 );

    // Row is stored as "MCBIST: r0-r17 (18-bit)" in a MemAddr.
    uint64_t l_row = MemUtils::reverseBits( i_addr.getRow(), 18 );

    // row - 18 bits (r17-r0)
    io_tmp = ( io_tmp << 18 ) | ( l_row & 0x0003ffff );

    #endif // __HOSTBOOT_MODULE
}

//------------------------------------------------------------------------------

template<TARGETING::TYPE T>
uint32_t setRowRepairData( TargetHandle_t i_dimm,
                           const MemRank & i_rank,
                           const MemAddr & i_addr,
                           uint8_t i_dram )
{
    #define PRDF_FUNC "[PlatServices::setRowRepairData] "

    uint32_t o_rc = SUCCESS;

    #ifdef __HOSTBOOT_MODULE

    if ( !areDramRepairsDisabled() )
    {
        uint32_t l_tmp = 0;

        // The format for a row repair is 32 bits total:
        // 5 bits : DRAM position (x8: 0-9, x4: 0-19)
        // 3 bits : slave ranks(0-7)
        // 2 bits : bank group(0-3) (bg1-bg0)
        // 3 bits : bank(0-7) (b2-b0)
        // 18 bits: row (r17-r0)
        // 1 bit  : repair validity (0: invalid, 1: valid)

        // dram - 5 bits
        l_tmp = ( l_tmp << 5 ) | ( i_dram & 0x1f );

        // slave rank - 3 bits
        l_tmp = ( l_tmp << 3 ) | ( i_addr.getRank().getSlave() & 0x07 );

        // bank group, bank, and row - 23 bits
        __setRowRepairDataHelper<T>( i_addr, l_tmp );

        // validity - 1 bit
        l_tmp = ( l_tmp << 1 ) | 0x1;

        // ROW_REPAIR_SIZE = 4
        uint8_t l_data[ROW_REPAIR::ROW_REPAIR_SIZE] = {0};
        memcpy( l_data, &l_tmp, sizeof(l_data) );

        MemRowRepair l_rowRepair( i_dimm, i_rank, l_data );

        o_rc = setRowRepairData<TYPE_MBA>( i_dimm, i_rank, l_rowRepair );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "setRowRepairData() failed" );
        }

    }

    #endif // __HOSTBOOT_MODULE

    return o_rc;

    #undef PRDF_FUNC

}

template
uint32_t setRowRepairData<TYPE_MBA>( TargetHandle_t i_dimm,
                                     const MemRank & i_rank,
                                     const MemAddr & i_addr,
                                     uint8_t i_dram );
template
uint32_t setRowRepairData<TYPE_MCA>( TargetHandle_t i_dimm,
                                     const MemRank & i_rank,
                                     const MemAddr & i_addr,
                                     uint8_t i_dram );

//------------------------------------------------------------------------------

template<TARGETING::TYPE T>
uint32_t clearRowRepairData( TargetHandle_t i_dimm, const MemRank & i_rank )
{
    #define PRDF_FUNC "[PlatServices::clearRowRepairData] "

    uint32_t o_rc = SUCCESS;

    #ifdef __HOSTBOOT_MODULE

    if ( !areDramRepairsDisabled() )
    {
        uint8_t l_data[ROW_REPAIR::ROW_REPAIR_SIZE] = {0};
        memset( l_data, 0, sizeof(l_data) );

        MemRowRepair l_rowRepair( i_dimm, i_rank, l_data );

        o_rc = setRowRepairData<T>( i_dimm, i_rank, l_rowRepair );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "setRowRepairData() failed" )
        }
    }

    #endif // __HOSTBOOT_MODULE

    return o_rc;

    #undef PRDF_FUNC
}

template
uint32_t clearRowRepairData<TYPE_MBA>( TargetHandle_t i_dimm,
                                       const MemRank & i_rank );
template
uint32_t clearRowRepairData<TYPE_MCA>( TargetHandle_t i_dimm,
                                       const MemRank & i_rank );

//------------------------------------------------------------------------------

} // end namespace PRDF

<commit_msg>PRD: Row Repair adjust for MBA Port 1 inversion<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/mem/prdfMemRowRepair.C $        */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2018                             */
/* [+] 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                                                     */

/** @file  prdfMemRowRepair.C */

#include <prdfMemRowRepair.H>

#include <UtilHash.H>
#include <iipServiceDataCollector.h>
#include <prdfParserUtils.H>
#include <prdfErrlUtil.H>
#include <prdfMemUtils.H>

#ifdef __HOSTBOOT_MODULE
#include <rowRepairsFuncs.H>
#endif // __HOSTBOOT_MODULE

namespace PRDF
{

using namespace PlatServices;
using namespace PARSERUTILS;
using namespace TARGETING;

//------------------------------------------------------------------------------

bool MemRowRepair::nonZero() const
{
    bool o_nonZero = false;

    for ( uint32_t i = 0; i < ROW_REPAIR::ROW_REPAIR_SIZE; i++ )
    {
        if ( 0 != iv_data[i] )
        {
            o_nonZero = true;
            break;
        }
    }

    return o_nonZero;
}

//##############################################################################
//                              Utility Functions
//##############################################################################

template<TARGETING::TYPE T, fapi2::TargetType F>
uint32_t __getRowRepairData( TargetHandle_t i_dimm, const MemRank & i_rank,
                             MemRowRepair & o_rowRepair )
{
    #define PRDF_FUNC "[PlatServices::__getRowRepairData] "

    uint32_t o_rc = SUCCESS;

    #ifdef __HOSTBOOT_MODULE

    uint8_t l_data[ROW_REPAIR::ROW_REPAIR_SIZE] = {0};

    errlHndl_t l_errl = nullptr;

    // get port select
    uint8_t l_ps = getDimmPort<T>( i_dimm );

    // get mba
    TargetHandle_t l_mba = getConnectedParent( i_dimm, T );
    fapi2::Target<F> l_fapiMba( l_mba );

    FAPI_INVOKE_HWP( l_errl, getRowRepair, l_fapiMba, i_rank.getDimmSlct(),
                     i_rank.getRankSlct(), l_data, l_ps );
    if ( nullptr != l_errl )
    {
        PRDF_ERR( PRDF_FUNC "getRowRepair() failed: i_dimm=0x%08x "
                  "l_ps=%d ds=%d rs=%d", getHuid(i_dimm), l_ps,
                  i_rank.getDimmSlct(), i_rank.getRankSlct() );
        PRDF_COMMIT_ERRL( l_errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    else
    {
        o_rowRepair = MemRowRepair( i_dimm, i_rank, l_data );
    }

    #endif // __HOSTBOOT_MODULE

    return o_rc;

    #undef PRDF_FUNC
}

template<>
uint32_t getRowRepairData<TYPE_MBA>( TargetHandle_t i_dimm,
    const MemRank & i_rank, MemRowRepair & o_rowRepair )
{
    return __getRowRepairData<TYPE_MBA, fapi2::TARGET_TYPE_MBA>( i_dimm, i_rank,
                                                                 o_rowRepair );
}

template<>
uint32_t getRowRepairData<TYPE_MCA>( TargetHandle_t i_dimm,
    const MemRank & i_rank, MemRowRepair & o_rowRepair )
{
    return __getRowRepairData<TYPE_MCA, fapi2::TARGET_TYPE_MCA>( i_dimm, i_rank,
                                                                 o_rowRepair );
}

//------------------------------------------------------------------------------

template<TARGETING::TYPE T, fapi2::TargetType F>
uint32_t __setRowRepairData( TargetHandle_t i_dimm, const MemRank & i_rank,
                           const MemRowRepair & i_rowRepair )
{
    #define PRDF_FUNC "[PlatServices::__setRowRepairData] "

    uint32_t o_rc = SUCCESS;

    #ifdef __HOSTBOOT_MODULE

    if ( !areDramRepairsDisabled() )
    {
        uint8_t l_data[ROW_REPAIR::ROW_REPAIR_SIZE] = {0};
        memcpy( l_data, i_rowRepair.getData(), sizeof(l_data) );

        errlHndl_t l_errl = nullptr;

        // get port select
        uint8_t l_ps = getDimmPort<T>( i_dimm );

        // get mba
        TargetHandle_t l_mba = getConnectedParent(i_dimm, T);
        fapi2::Target<F> l_fapiMba( l_mba );

        FAPI_INVOKE_HWP( l_errl, setRowRepair, l_fapiMba, i_rank.getDimmSlct(),
                         i_rank.getRankSlct(), l_data, l_ps );
        if ( nullptr != l_errl )
        {
            PRDF_ERR( PRDF_FUNC "setRowRepair() failed: i_dimm=0x%08x "
                    "l_ps=%d ds=%d rs=%d", getHuid(i_dimm), l_ps,
                    i_rank.getDimmSlct(), i_rank.getRankSlct() );
            PRDF_COMMIT_ERRL( l_errl, ERRL_ACTION_REPORT );
            o_rc = FAIL;
        }

    }

    #endif // __HOSTBOOT_MODULE

    return o_rc;

    #undef PRDF_FUNC
}

template<>
uint32_t setRowRepairData<TYPE_MBA>( TargetHandle_t i_dimm,
                                     const MemRank & i_rank,
                                     const MemRowRepair & i_rowRepair )
{
    return __setRowRepairData<TYPE_MBA, fapi2::TARGET_TYPE_MBA>( i_dimm, i_rank,
                                                                 i_rowRepair );
}

template<>
uint32_t setRowRepairData<TYPE_MCA>( TargetHandle_t i_dimm,
                                     const MemRank & i_rank,
                                     const MemRowRepair & i_rowRepair )
{
    return __setRowRepairData<TYPE_MCA, fapi2::TARGET_TYPE_MCA>( i_dimm, i_rank,
                                                                 i_rowRepair );
}

//------------------------------------------------------------------------------

template<TARGETING::TYPE T>
void __setRowRepairDataHelper( const MemAddr & i_addr, uint32_t & io_tmp );

template<>
void __setRowRepairDataHelper<TYPE_MBA>( const MemAddr & i_addr,
                                         uint32_t & io_tmp )
{
    #ifdef __HOSTBOOT_MODULE

    // Bank is stored as MBA "(DDR4): bg1-bg0,b1-b0 (4-bit)" in a MemAddr.
    // bank group - 2 bits (bg1-bg0)
    io_tmp = ( io_tmp << 2 ) | ( (i_addr.getBank() >> 2) & 0x03 );

    // bank - 3 bits (b2-b0)
    io_tmp = ( io_tmp << 3 ) | ( i_addr.getBank() & 0x03 );

    // Row is stored as "MBA: r17-r0 (18-bit)" in a MemAddr.
    // row - 18 bits (r17-r0)
    io_tmp = ( io_tmp << 18 ) | ( i_addr.getRow() & 0x0003ffff );

    #endif // __HOSTBOOT_MODULE
}

template<>
void __setRowRepairDataHelper<TYPE_MCA>( const MemAddr & i_addr,
                                         uint32_t & io_tmp )
{
    #ifdef __HOSTBOOT_MODULE

    // Bank is stored as "MCBIST: b0-b2,bg0-bg1 (5-bit)" in a MemAddr.
    // bank group - 2 bits (bg1-bg0)
    uint64_t l_bnkGrp = i_addr.getBank() & 0x03;
    l_bnkGrp = MemUtils::reverseBits( l_bnkGrp, 2 );

    io_tmp = ( io_tmp << 2 ) | ( l_bnkGrp & 0x03 );

    // bank - 3 bits (b2-b0)
    uint64_t l_bnk = (i_addr.getBank() & 0x1C) >> 2;
    l_bnk = MemUtils::reverseBits( l_bnk, 3 );

    io_tmp = ( io_tmp << 3 ) | ( l_bnk & 0x03 );

    // Row is stored as "MCBIST: r0-r17 (18-bit)" in a MemAddr.
    uint64_t l_row = MemUtils::reverseBits( i_addr.getRow(), 18 );

    // row - 18 bits (r17-r0)
    io_tmp = ( io_tmp << 18 ) | ( l_row & 0x0003ffff );

    #endif // __HOSTBOOT_MODULE
}

//------------------------------------------------------------------------------

template<TARGETING::TYPE T>
uint32_t setRowRepairData( TargetHandle_t i_dimm,
                           const MemRank & i_rank,
                           const MemAddr & i_addr,
                           uint8_t i_dram )
{
    #define PRDF_FUNC "[PlatServices::setRowRepairData] "

    uint32_t o_rc = SUCCESS;

    #ifdef __HOSTBOOT_MODULE

    if ( !areDramRepairsDisabled() )
    {
        uint32_t l_tmp = 0;

        // The format for a row repair is 32 bits total:
        // 5 bits : DRAM position (x8: 0-9, x4: 0-19)
        // 3 bits : slave ranks(0-7)
        // 2 bits : bank group(0-3) (bg1-bg0)
        // 3 bits : bank(0-7) (b2-b0)
        // 18 bits: row (r17-r0)
        // 1 bit  : repair validity (0: invalid, 1: valid)

        // dram - 5 bits
        l_tmp = ( l_tmp << 5 ) | ( i_dram & 0x1f );

        // slave rank - 3 bits
        l_tmp = ( l_tmp << 3 ) | ( i_addr.getRank().getSlave() & 0x07 );

        // bank group, bank, and row - 23 bits
        __setRowRepairDataHelper<T>( i_addr, l_tmp );

        // validity - 1 bit
        l_tmp = ( l_tmp << 1 ) | 0x1;

        // Adjust for mba port 1 address inversion if necessary
        if ( (1 == getDimmPort<T>(i_dimm) % 2) && (T == TYPE_MBA) )
        {
            // Bits flipped in port 1 inversion: (10:12, 16:22, 24, 26:28)
            // mask:
            // 0000 0000 0011 1000 1111 1110 1011 1000
            uint32_t mask = 0x0038FEB8;
            l_tmp ^= mask;
        }

        // ROW_REPAIR_SIZE = 4
        uint8_t l_data[ROW_REPAIR::ROW_REPAIR_SIZE] = {0};
        memcpy( l_data, &l_tmp, sizeof(l_data) );

        MemRowRepair l_rowRepair( i_dimm, i_rank, l_data );

        o_rc = setRowRepairData<TYPE_MBA>( i_dimm, i_rank, l_rowRepair );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "setRowRepairData() failed" );
        }

    }

    #endif // __HOSTBOOT_MODULE

    return o_rc;

    #undef PRDF_FUNC

}

template
uint32_t setRowRepairData<TYPE_MBA>( TargetHandle_t i_dimm,
                                     const MemRank & i_rank,
                                     const MemAddr & i_addr,
                                     uint8_t i_dram );
template
uint32_t setRowRepairData<TYPE_MCA>( TargetHandle_t i_dimm,
                                     const MemRank & i_rank,
                                     const MemAddr & i_addr,
                                     uint8_t i_dram );

//------------------------------------------------------------------------------

template<TARGETING::TYPE T>
uint32_t clearRowRepairData( TargetHandle_t i_dimm, const MemRank & i_rank )
{
    #define PRDF_FUNC "[PlatServices::clearRowRepairData] "

    uint32_t o_rc = SUCCESS;

    #ifdef __HOSTBOOT_MODULE

    if ( !areDramRepairsDisabled() )
    {
        uint8_t l_data[ROW_REPAIR::ROW_REPAIR_SIZE] = {0};
        memset( l_data, 0, sizeof(l_data) );

        MemRowRepair l_rowRepair( i_dimm, i_rank, l_data );

        o_rc = setRowRepairData<T>( i_dimm, i_rank, l_rowRepair );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "setRowRepairData() failed" )
        }
    }

    #endif // __HOSTBOOT_MODULE

    return o_rc;

    #undef PRDF_FUNC
}

template
uint32_t clearRowRepairData<TYPE_MBA>( TargetHandle_t i_dimm,
                                       const MemRank & i_rank );
template
uint32_t clearRowRepairData<TYPE_MCA>( TargetHandle_t i_dimm,
                                       const MemRank & i_rank );

//------------------------------------------------------------------------------

} // end namespace PRDF

<|endoftext|>


<commit_before>/*
* ----------------------------------------------------------------------------
* “THE COFFEEWARE LICENSE” (Revision 1):
* <ihsan@kehribar.me> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a coffee in return.
* -----------------------------------------------------------------------------
* This library is based on this library:
*   https://github.com/aaronds/arduino-nrf24l01
* Which is based on this library:
*   http://www.tinkerer.eu/AVRLib/nRF24L01
* -----------------------------------------------------------------------------
*/
#include "nrf24.hpp"

uint8_t payload_len;

// FIXME: correct pin definitions
typedef xpcc::stm32::GpioE6 Ce;
typedef xpcc::stm32::GpioA4 Csn;
typedef xpcc::stm32::GpioA5 Sck;
typedef xpcc::stm32::GpioA7 Mosi;
typedef xpcc::stm32::GpioA6 Miso;

/* init the hardware pins */
void nrf24_init()
{
/*    - Set MISO pin input
 *    - Set MOSI pin output
 *    - Set SCK pin output
 *    - Set CSN pin output
 *    - Set CE pin output     */
    Miso::setInput();
    Mosi::setOutput(xpcc::Gpio::Low);
    Sck::setOutput(xpcc::Gpio::Low);
    Csn::setOutput(xpcc::Gpio::Low);
    Ce::setOutput(xpcc::Gpio::Low);

    Ce::reset();
    Csn::set();
}

/* configure the module */
void nrf24_config(uint8_t channel, uint8_t pay_length)
{
    /* Use static payload length ... */
    payload_len = pay_length;

    // Set RF channel
    nrf24_configRegister(RF_CH,channel);

    // Set length of incoming payload
    nrf24_configRegister(RX_PW_P0, 0x00); // Auto-ACK pipe ...
    nrf24_configRegister(RX_PW_P1, payload_len); // Data payload pipe
    nrf24_configRegister(RX_PW_P2, 0x00); // Pipe not used
    nrf24_configRegister(RX_PW_P3, 0x00); // Pipe not used
    nrf24_configRegister(RX_PW_P4, 0x00); // Pipe not used
    nrf24_configRegister(RX_PW_P5, 0x00); // Pipe not used

    // 1 Mbps, TX gain: 0dbm
    nrf24_configRegister(RF_SETUP, (0<<RF_DR)|((0x03)<<RF_PWR));

    // CRC enable, 1 byte CRC length
    nrf24_configRegister(CONFIG,nrf24_CONFIG);

    // Auto Acknowledgment
    nrf24_configRegister(EN_AA,(1<<ENAA_P0)|(1<<ENAA_P1)|(0<<ENAA_P2)|(0<<ENAA_P3)|(0<<ENAA_P4)|(0<<ENAA_P5));

    // Enable RX addresses
    nrf24_configRegister(EN_RXADDR,(1<<ERX_P0)|(1<<ERX_P1)|(0<<ERX_P2)|(0<<ERX_P3)|(0<<ERX_P4)|(0<<ERX_P5));

    // Auto retransmit delay: 1000 us and Up to 15 retransmit trials
    nrf24_configRegister(SETUP_RETR,(0x04<<ARD)|(0x0F<<ARC));

    // Dynamic length configurations: No dynamic length
    nrf24_configRegister(DYNPD,(0<<DPL_P0)|(0<<DPL_P1)|(0<<DPL_P2)|(0<<DPL_P3)|(0<<DPL_P4)|(0<<DPL_P5));

    // Start listening
    nrf24_powerUpRx();
}

/* Set the RX address */
void nrf24_rx_address(const uint8_t * adr)
{
    Ce::reset();
    xpcc::delay_ms(1);
    nrf24_writeRegister(RX_ADDR_P1,adr,nrf24_ADDR_LEN);
    xpcc::delay_ms(1);
    Ce::set();
}

/* Returns the payload length */
uint8_t nrf24_payload_length()
{
    return payload_len;
}

/* Set the TX address */
void nrf24_tx_address(const uint8_t* adr)
{
    /* RX_ADDR_P0 must be set to the sending addr for auto ack to work. */
    nrf24_writeRegister(RX_ADDR_P0,adr,nrf24_ADDR_LEN);
    nrf24_writeRegister(TX_ADDR,adr,nrf24_ADDR_LEN);
}

/* Checks if data is available for reading */
/* Returns 1 if data is ready ... */
uint8_t nrf24_dataReady()
{
    // See note in getData() function - just checking RX_DR isn't good enough
    uint8_t status = nrf24_getStatus();

    // We can short circuit on RX_DR, but if it's not set, we still need
    // to check the FIFO for any pending packets
    if ( status & (1 << RX_DR) )
    {
        return 1;
    }

    return !nrf24_rxFifoEmpty();;
}

/* Checks if receive FIFO is empty or not */
uint8_t nrf24_rxFifoEmpty()
{
    uint8_t fifoStatus;

    nrf24_readRegister(FIFO_STATUS,&fifoStatus,1);

    return (fifoStatus & (1 << RX_EMPTY));
}

/* Returns the length of data waiting in the RX fifo */
uint8_t nrf24_payloadLength()
{
    uint8_t status;
    Csn::reset();
    xpcc::delay_ms(1);
    spi_transfer(R_RX_PL_WID);
    xpcc::delay_ms(1);
    status = spi_transfer(0x00);
    xpcc::delay_ms(1);
    Csn::set();
    xpcc::delay_ms(1);
    return status;
}

/* Reads payload bytes into data array */
void nrf24_getData(uint8_t* data)
{
    /* Pull down chip select */
    Csn::reset();
    xpcc::delay_ms(1);
    /* Send cmd to read rx payload */
    spi_transfer( R_RX_PAYLOAD );
    xpcc::delay_ms(1);
    /* Read payload */
    nrf24_transferSync(data,data,payload_len);
    xpcc::delay_ms(1);
    /* Pull up chip select */
    Csn::set();
    xpcc::delay_ms(1);
    /* Reset status register */
    nrf24_configRegister(STATUS,(1<<RX_DR));
    xpcc::delay_ms(1);
}

/* Returns the number of retransmissions occured for the last message */
uint8_t nrf24_retransmissionCount()
{
    uint8_t rv;
    nrf24_readRegister(OBSERVE_TX,&rv,1);
    rv = rv & 0x0F;
    return rv;
}

// Sends a data package to the default address. Be sure to send the correct
// amount of bytes as configured as payload on the receiver.
void nrf24_send(uint8_t* value)
{
    /* Go to Standby-I first */
    Ce::reset();
    xpcc::delay_ms(1);
    /* Set to transmitter mode , Power up if needed */
    nrf24_powerUpTx();
    xpcc::delay_ms(1);
    /* Do we really need to flush TX fifo each time ? */
    #if 1
        /* Pull down chip select */
        Csn::reset();
        xpcc::delay_ms(1);
        /* Write cmd to flush transmit FIFO */
        spi_transfer(FLUSH_TX);
        xpcc::delay_ms(1);
        /* Pull up chip select */
        Csn::set();
    #endif
        xpcc::delay_ms(1);
    /* Pull down chip select */
    Csn::reset();
    xpcc::delay_ms(1);
    /* Write cmd to write payload */
    spi_transfer(W_TX_PAYLOAD);
    xpcc::delay_ms(1);
    /* Write payload */
    nrf24_transmitSync(value,payload_len);
    xpcc::delay_ms(1);
    /* Pull up chip select */
    Csn::set();
    xpcc::delay_ms(1);
    /* Start the transmission */
    Ce::set();
    xpcc::delay_ms(1);
}

uint8_t nrf24_isSending()
{
    uint8_t status;

    /* read the current status */
    status = nrf24_getStatus();

    /* if sending successful (TX_DS) or max retries exceded (MAX_RT). */
    if((status & ((1 << TX_DS)  | (1 << MAX_RT))))
    {
        return 0; /* false */
    }

    return 1; /* true */

}

uint8_t nrf24_getStatus()
{
    uint8_t rv;
    Csn::reset();
    xpcc::delay_ms(1);
    rv = spi_transfer(NOP);
    xpcc::delay_ms(1);
    Csn::set();
    xpcc::delay_ms(1);
    return rv;
}

uint8_t nrf24_lastMessageStatus()
{
    uint8_t rv;

    rv = nrf24_getStatus();

    /* Transmission went OK */
    if((rv & ((1 << TX_DS))))
    {
        return NRF24_TRANSMISSON_OK;
    }
    /* Maximum retransmission count is reached */
    /* Last message probably went missing ... */
    else if((rv & ((1 << MAX_RT))))
    {
        return NRF24_MESSAGE_LOST;
    }
    /* Probably still sending ... */
    else
    {
        return 0xFF;
    }
}

void nrf24_powerUpRx()
{
    Csn::reset();
    spi_transfer(FLUSH_RX);
    Csn::set();

    nrf24_configRegister(STATUS,(1<<RX_DR)|(1<<TX_DS)|(1<<MAX_RT));

    Ce::reset();
    nrf24_configRegister(CONFIG,nrf24_CONFIG|((1<<PWR_UP)|(1<<PRIM_RX)));
    Ce::set();
}

void nrf24_powerUpTx()
{
    nrf24_configRegister(STATUS,(1<<RX_DR)|(1<<TX_DS)|(1<<MAX_RT));

    nrf24_configRegister(CONFIG,nrf24_CONFIG|((1<<PWR_UP)|(0<<PRIM_RX)));
}

void nrf24_powerDown()
{
    Ce::reset();
    xpcc::delay_ms(1);
    nrf24_configRegister(CONFIG,nrf24_CONFIG);
}

/* software spi routine */
uint8_t spi_transfer(uint8_t tx)
{
    uint8_t i = 0;
    uint8_t rx = 0;
    xpcc::delay_ms(1);
    Sck::reset();

    for(i=0;i<8;i++)
    {

        if(tx & (1<<(7-i)))
        {
            Mosi::set();
        }
        else
        {
            Mosi::reset();
        }
        xpcc::delay_ms(1);
        Sck::set();
        xpcc::delay_ms(1);

        rx = rx << 1;
        if(Miso::read())
        {
            rx |= 0x01;
        }

        Sck::reset();
        xpcc::delay_ms(1);
    }

    return rx;
}

/* send and receive multiple bytes over SPI */
void nrf24_transferSync(const uint8_t* dataout,uint8_t* datain,uint8_t len)
{
    uint8_t i;

    for(i=0;i<len;i++)
    {
        datain[i] = spi_transfer(dataout[i]);
    }

}

/* send multiple bytes over SPI */
void nrf24_transmitSync(const uint8_t* dataout,uint8_t len)
{
    uint8_t i;

    for(i=0;i<len;i++)
    {
        spi_transfer(dataout[i]);
    }

}

/* Clocks only one byte into the given nrf24 register */
void nrf24_configRegister(uint8_t reg, uint8_t value)
{
    Csn::reset();
    xpcc::delay_ms(1);
    spi_transfer(W_REGISTER | (REGISTER_MASK & reg));
    xpcc::delay_ms(1);
    spi_transfer(value);
    xpcc::delay_ms(1);
    Csn::set();
}

/* Read single register from nrf24 */
void nrf24_readRegister(uint8_t reg, uint8_t* value, uint8_t len)
{
    Csn::reset();
    xpcc::delay_ms(1);
    spi_transfer(R_REGISTER | (REGISTER_MASK & reg));
    xpcc::delay_ms(1);
    nrf24_transferSync(value,value,len);
    xpcc::delay_ms(1);
    Csn::set();
}

/* Write to a single register of nrf24 */
void nrf24_writeRegister(uint8_t reg, const uint8_t* value, uint8_t len)
{
    Csn::reset();
    xpcc::delay_ms(1);
    spi_transfer(W_REGISTER | (REGISTER_MASK & reg));
    xpcc::delay_ms(1);
    nrf24_transmitSync(value,len);
    xpcc::delay_ms(1);
    Csn::set();
}
<commit_msg>Nrf24: use free pins<commit_after>/*
* ----------------------------------------------------------------------------
* “THE COFFEEWARE LICENSE” (Revision 1):
* <ihsan@kehribar.me> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a coffee in return.
* -----------------------------------------------------------------------------
* This library is based on this library:
*   https://github.com/aaronds/arduino-nrf24l01
* Which is based on this library:
*   http://www.tinkerer.eu/AVRLib/nRF24L01
* -----------------------------------------------------------------------------
*/
#include "nrf24.hpp"

uint8_t payload_len;

// FIXME: correct pin definitions
typedef xpcc::stm32::GpioB11 Ce;
typedef xpcc::stm32::GpioB12 Csn;
typedef xpcc::stm32::GpioB13 Sck;
typedef xpcc::stm32::GpioB14 Miso;
typedef xpcc::stm32::GpioB15 Mosi;

/* init the hardware pins */
void nrf24_init()
{
/*    - Set MISO pin input
 *    - Set MOSI pin output
 *    - Set SCK pin output
 *    - Set CSN pin output
 *    - Set CE pin output     */
    Miso::setInput();
    Mosi::setOutput(xpcc::Gpio::Low);
    Sck::setOutput(xpcc::Gpio::Low);
    Csn::setOutput(xpcc::Gpio::Low);
    Ce::setOutput(xpcc::Gpio::Low);

    Ce::reset();
    Csn::set();
}

/* configure the module */
void nrf24_config(uint8_t channel, uint8_t pay_length)
{
    /* Use static payload length ... */
    payload_len = pay_length;

    // Set RF channel
    nrf24_configRegister(RF_CH,channel);

    // Set length of incoming payload
    nrf24_configRegister(RX_PW_P0, 0x00); // Auto-ACK pipe ...
    nrf24_configRegister(RX_PW_P1, payload_len); // Data payload pipe
    nrf24_configRegister(RX_PW_P2, 0x00); // Pipe not used
    nrf24_configRegister(RX_PW_P3, 0x00); // Pipe not used
    nrf24_configRegister(RX_PW_P4, 0x00); // Pipe not used
    nrf24_configRegister(RX_PW_P5, 0x00); // Pipe not used

    // 1 Mbps, TX gain: 0dbm
    nrf24_configRegister(RF_SETUP, (0<<RF_DR)|((0x03)<<RF_PWR));

    // CRC enable, 1 byte CRC length
    nrf24_configRegister(CONFIG,nrf24_CONFIG);

    // Auto Acknowledgment
    nrf24_configRegister(EN_AA,(1<<ENAA_P0)|(1<<ENAA_P1)|(0<<ENAA_P2)|(0<<ENAA_P3)|(0<<ENAA_P4)|(0<<ENAA_P5));

    // Enable RX addresses
    nrf24_configRegister(EN_RXADDR,(1<<ERX_P0)|(1<<ERX_P1)|(0<<ERX_P2)|(0<<ERX_P3)|(0<<ERX_P4)|(0<<ERX_P5));

    // Auto retransmit delay: 1000 us and Up to 15 retransmit trials
    nrf24_configRegister(SETUP_RETR,(0x04<<ARD)|(0x0F<<ARC));

    // Dynamic length configurations: No dynamic length
    nrf24_configRegister(DYNPD,(0<<DPL_P0)|(0<<DPL_P1)|(0<<DPL_P2)|(0<<DPL_P3)|(0<<DPL_P4)|(0<<DPL_P5));

    // Start listening
    nrf24_powerUpRx();
}

/* Set the RX address */
void nrf24_rx_address(const uint8_t * adr)
{
    Ce::reset();
    xpcc::delay_ms(1);
    nrf24_writeRegister(RX_ADDR_P1,adr,nrf24_ADDR_LEN);
    xpcc::delay_ms(1);
    Ce::set();
}

/* Returns the payload length */
uint8_t nrf24_payload_length()
{
    return payload_len;
}

/* Set the TX address */
void nrf24_tx_address(const uint8_t* adr)
{
    /* RX_ADDR_P0 must be set to the sending addr for auto ack to work. */
    nrf24_writeRegister(RX_ADDR_P0,adr,nrf24_ADDR_LEN);
    nrf24_writeRegister(TX_ADDR,adr,nrf24_ADDR_LEN);
}

/* Checks if data is available for reading */
/* Returns 1 if data is ready ... */
uint8_t nrf24_dataReady()
{
    // See note in getData() function - just checking RX_DR isn't good enough
    uint8_t status = nrf24_getStatus();

    // We can short circuit on RX_DR, but if it's not set, we still need
    // to check the FIFO for any pending packets
    if ( status & (1 << RX_DR) )
    {
        return 1;
    }

    return !nrf24_rxFifoEmpty();;
}

/* Checks if receive FIFO is empty or not */
uint8_t nrf24_rxFifoEmpty()
{
    uint8_t fifoStatus;

    nrf24_readRegister(FIFO_STATUS,&fifoStatus,1);

    return (fifoStatus & (1 << RX_EMPTY));
}

/* Returns the length of data waiting in the RX fifo */
uint8_t nrf24_payloadLength()
{
    uint8_t status;
    Csn::reset();
    xpcc::delay_ms(1);
    spi_transfer(R_RX_PL_WID);
    xpcc::delay_ms(1);
    status = spi_transfer(0x00);
    xpcc::delay_ms(1);
    Csn::set();
    xpcc::delay_ms(1);
    return status;
}

/* Reads payload bytes into data array */
void nrf24_getData(uint8_t* data)
{
    /* Pull down chip select */
    Csn::reset();
    xpcc::delay_ms(1);
    /* Send cmd to read rx payload */
    spi_transfer( R_RX_PAYLOAD );
    xpcc::delay_ms(1);
    /* Read payload */
    nrf24_transferSync(data,data,payload_len);
    xpcc::delay_ms(1);
    /* Pull up chip select */
    Csn::set();
    xpcc::delay_ms(1);
    /* Reset status register */
    nrf24_configRegister(STATUS,(1<<RX_DR));
    xpcc::delay_ms(1);
}

/* Returns the number of retransmissions occured for the last message */
uint8_t nrf24_retransmissionCount()
{
    uint8_t rv;
    nrf24_readRegister(OBSERVE_TX,&rv,1);
    rv = rv & 0x0F;
    return rv;
}

// Sends a data package to the default address. Be sure to send the correct
// amount of bytes as configured as payload on the receiver.
void nrf24_send(uint8_t* value)
{
    /* Go to Standby-I first */
    Ce::reset();
    xpcc::delay_ms(1);
    /* Set to transmitter mode , Power up if needed */
    nrf24_powerUpTx();
    xpcc::delay_ms(1);
    /* Do we really need to flush TX fifo each time ? */
    #if 1
        /* Pull down chip select */
        Csn::reset();
        xpcc::delay_ms(1);
        /* Write cmd to flush transmit FIFO */
        spi_transfer(FLUSH_TX);
        xpcc::delay_ms(1);
        /* Pull up chip select */
        Csn::set();
    #endif
        xpcc::delay_ms(1);
    /* Pull down chip select */
    Csn::reset();
    xpcc::delay_ms(1);
    /* Write cmd to write payload */
    spi_transfer(W_TX_PAYLOAD);
    xpcc::delay_ms(1);
    /* Write payload */
    nrf24_transmitSync(value,payload_len);
    xpcc::delay_ms(1);
    /* Pull up chip select */
    Csn::set();
    xpcc::delay_ms(1);
    /* Start the transmission */
    Ce::set();
    xpcc::delay_ms(1);
}

uint8_t nrf24_isSending()
{
    uint8_t status;

    /* read the current status */
    status = nrf24_getStatus();

    /* if sending successful (TX_DS) or max retries exceded (MAX_RT). */
    if((status & ((1 << TX_DS)  | (1 << MAX_RT))))
    {
        return 0; /* false */
    }

    return 1; /* true */

}

uint8_t nrf24_getStatus()
{
    uint8_t rv;
    Csn::reset();
    xpcc::delay_ms(1);
    rv = spi_transfer(NOP);
    xpcc::delay_ms(1);
    Csn::set();
    xpcc::delay_ms(1);
    return rv;
}

uint8_t nrf24_lastMessageStatus()
{
    uint8_t rv;

    rv = nrf24_getStatus();

    /* Transmission went OK */
    if((rv & ((1 << TX_DS))))
    {
        return NRF24_TRANSMISSON_OK;
    }
    /* Maximum retransmission count is reached */
    /* Last message probably went missing ... */
    else if((rv & ((1 << MAX_RT))))
    {
        return NRF24_MESSAGE_LOST;
    }
    /* Probably still sending ... */
    else
    {
        return 0xFF;
    }
}

void nrf24_powerUpRx()
{
    Csn::reset();
    spi_transfer(FLUSH_RX);
    Csn::set();

    nrf24_configRegister(STATUS,(1<<RX_DR)|(1<<TX_DS)|(1<<MAX_RT));

    Ce::reset();
    nrf24_configRegister(CONFIG,nrf24_CONFIG|((1<<PWR_UP)|(1<<PRIM_RX)));
    Ce::set();
}

void nrf24_powerUpTx()
{
    nrf24_configRegister(STATUS,(1<<RX_DR)|(1<<TX_DS)|(1<<MAX_RT));

    nrf24_configRegister(CONFIG,nrf24_CONFIG|((1<<PWR_UP)|(0<<PRIM_RX)));
}

void nrf24_powerDown()
{
    Ce::reset();
    xpcc::delay_ms(1);
    nrf24_configRegister(CONFIG,nrf24_CONFIG);
}

/* software spi routine */
uint8_t spi_transfer(uint8_t tx)
{
    uint8_t i = 0;
    uint8_t rx = 0;
    xpcc::delay_ms(1);
    Sck::reset();

    for(i=0;i<8;i++)
    {

        if(tx & (1<<(7-i)))
        {
            Mosi::set();
        }
        else
        {
            Mosi::reset();
        }
        xpcc::delay_ms(1);
        Sck::set();
        xpcc::delay_ms(1);

        rx = rx << 1;
        if(Miso::read())
        {
            rx |= 0x01;
        }

        Sck::reset();
        xpcc::delay_ms(1);
    }

    return rx;
}

/* send and receive multiple bytes over SPI */
void nrf24_transferSync(const uint8_t* dataout,uint8_t* datain,uint8_t len)
{
    uint8_t i;

    for(i=0;i<len;i++)
    {
        datain[i] = spi_transfer(dataout[i]);
    }

}

/* send multiple bytes over SPI */
void nrf24_transmitSync(const uint8_t* dataout,uint8_t len)
{
    uint8_t i;

    for(i=0;i<len;i++)
    {
        spi_transfer(dataout[i]);
    }

}

/* Clocks only one byte into the given nrf24 register */
void nrf24_configRegister(uint8_t reg, uint8_t value)
{
    Csn::reset();
    xpcc::delay_ms(1);
    spi_transfer(W_REGISTER | (REGISTER_MASK & reg));
    xpcc::delay_ms(1);
    spi_transfer(value);
    xpcc::delay_ms(1);
    Csn::set();
}

/* Read single register from nrf24 */
void nrf24_readRegister(uint8_t reg, uint8_t* value, uint8_t len)
{
    Csn::reset();
    xpcc::delay_ms(1);
    spi_transfer(R_REGISTER | (REGISTER_MASK & reg));
    xpcc::delay_ms(1);
    nrf24_transferSync(value,value,len);
    xpcc::delay_ms(1);
    Csn::set();
}

/* Write to a single register of nrf24 */
void nrf24_writeRegister(uint8_t reg, const uint8_t* value, uint8_t len)
{
    Csn::reset();
    xpcc::delay_ms(1);
    spi_transfer(W_REGISTER | (REGISTER_MASK & reg));
    xpcc::delay_ms(1);
    nrf24_transmitSync(value,len);
    xpcc::delay_ms(1);
    Csn::set();
}
<|endoftext|>


<commit_before>/* OpenSceneGraph example, osganimate.
*
*  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 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.
*/

#include <osgViewer/Viewer>
#include <osgViewer/CompositeViewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/TrackballManipulator>
#include <osgDB/ReadFile>

#if USE_QT4

    #include <QtCore/QString>
    #include <QtCore/QTimer>
    #include <QtGui/QKeyEvent>
    #include <QtGui/QApplication>
    #include <QtOpenGL/QGLWidget>

    using Qt::WindowFlags;

#else

    class QWidget;
    #include <qtimer.h>
    #include <qgl.h>
    #include <qapplication.h>

    #define WindowFlags WFlags

#endif

#include <iostream>

class AdapterWidget : public QGLWidget
{
    public:

        AdapterWidget( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WindowFlags f = 0 );

        virtual ~AdapterWidget() {}

        osgViewer::GraphicsWindow* getGraphicsWindow() { return _gw.get(); }
        const osgViewer::GraphicsWindow* getGraphicsWindow() const { return _gw.get(); }

    protected:

        void init();

        virtual void resizeGL( int width, int height );
        virtual void keyPressEvent( QKeyEvent* event );
        virtual void keyReleaseEvent( QKeyEvent* event );
        virtual void mousePressEvent( QMouseEvent* event );
        virtual void mouseReleaseEvent( QMouseEvent* event );
        virtual void mouseMoveEvent( QMouseEvent* event );

        osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> _gw;
};

AdapterWidget::AdapterWidget( QWidget * parent, const char * name, const QGLWidget * shareWidget, WindowFlags f):
#if USE_QT4
    QGLWidget(parent, shareWidget, f)
#else
    QGLWidget(parent, name, shareWidget, f)
#endif
{
    _gw = new osgViewer::GraphicsWindowEmbedded(0,0,width(),height());
}

void AdapterWidget::resizeGL( int width, int height )
{
    _gw->getEventQueue()->windowResize(0, 0, width, height );
    _gw->resized(0,0,width,height);
}

void AdapterWidget::keyPressEvent( QKeyEvent* event )
{
#if USE_QT4
    _gw->getEventQueue()->keyPress( (osgGA::GUIEventAdapter::KeySymbol) *(event->text().toAscii().data() ) );
#else
    _gw->getEventQueue()->keyPress( (osgGA::GUIEventAdapter::KeySymbol) event->ascii() );
#endif
}

void AdapterWidget::keyReleaseEvent( QKeyEvent* event )
{
#if USE_QT4
    _gw->getEventQueue()->keyRelease( (osgGA::GUIEventAdapter::KeySymbol) *(event->text().toAscii().data() ) );
#else
    _gw->getEventQueue()->keyRelease( (osgGA::GUIEventAdapter::KeySymbol) event->ascii() );
#endif
}

void AdapterWidget::mousePressEvent( QMouseEvent* event )
{
    int button = 0;
    switch(event->button())
    {
        case(Qt::LeftButton): button = 1; break;
        case(Qt::MidButton): button = 2; break;
        case(Qt::RightButton): button = 3; break;
        case(Qt::NoButton): button = 0; break;
        default: button = 0; break;
    }
    _gw->getEventQueue()->mouseButtonPress(event->x(), event->y(), button);
}

void AdapterWidget::mouseReleaseEvent( QMouseEvent* event )
{
    int button = 0;
    switch(event->button())
    {
        case(Qt::LeftButton): button = 1; break;
        case(Qt::MidButton): button = 2; break;
        case(Qt::RightButton): button = 3; break;
        case(Qt::NoButton): button = 0; break;
        default: button = 0; break;
    }
    _gw->getEventQueue()->mouseButtonRelease(event->x(), event->y(), button);
}

void AdapterWidget::mouseMoveEvent( QMouseEvent* event )
{
    _gw->getEventQueue()->mouseMotion(event->x(), event->y());
}

class ViewerQT : public osgViewer::Viewer, public AdapterWidget
{
    public:

        ViewerQT(QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WindowFlags f = 0):
            AdapterWidget( parent, name, shareWidget, f )
        {
            getCamera()->setViewport(new osg::Viewport(0,0,width(),height()));
            getCamera()->setGraphicsContext(getGraphicsWindow());
            getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width())/static_cast<double>(height()), 1.0f, 10000.0f);

            setThreadingModel(osgViewer::Viewer::SingleThreaded);

            connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL()));
            _timer.start(10);
        }

        virtual void paintGL()
        {
            frame();
        }

    protected:

        QTimer _timer;
};

class CompositeViewerQT : public osgViewer::CompositeViewer, public AdapterWidget
{
    public:

        CompositeViewerQT(QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WindowFlags f = 0):
            AdapterWidget( parent, name, shareWidget, f )
        {
            setThreadingModel(osgViewer::CompositeViewer::SingleThreaded);

            connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL()));
            _timer.start(10);
        }

        virtual void paintGL()
        {
            frame();
        }

    protected:

        QTimer _timer;
};

int main( int argc, char **argv )
{
    QApplication a( argc, argv );

    if (argc<2)
    {
        std::cout << argv[0] <<": requires filename argument." << std::endl;
        return 1;
    }

    osg::ArgumentParser arguments(&argc, argv);

    // load the scene.
    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
    if (!loadedModel)
    {
        std::cout << argv[0] <<": No data loaded." << std::endl;
        return 1;
    }

    if (arguments.read("--CompositeViewer"))
    {
        CompositeViewerQT* viewerWindow = new CompositeViewerQT;

        unsigned int width = viewerWindow->width();
        unsigned int height = viewerWindow->height();

        {
            osgViewer::View* view1 = new osgViewer::View;
            view1->getCamera()->setGraphicsContext(viewerWindow->getGraphicsWindow());
            view1->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width)/static_cast<double>(height/2), 1.0, 1000.0);
            view1->getCamera()->setViewport(new osg::Viewport(0,0,width,height/2));
            view1->setCameraManipulator(new osgGA::TrackballManipulator);
            view1->setSceneData(loadedModel.get());

            viewerWindow->addView(view1);
        }

        {
            osgViewer::View* view2 = new osgViewer::View;
            view2->getCamera()->setGraphicsContext(viewerWindow->getGraphicsWindow());
            view2->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width)/static_cast<double>(height/2), 1.0, 1000.0);
            view2->getCamera()->setViewport(new osg::Viewport(0,height/2,width,height/2));
            view2->setCameraManipulator(new osgGA::TrackballManipulator);
            view2->setSceneData(loadedModel.get());

            viewerWindow->addView(view2);
        }

        viewerWindow->show();
    }
    else
    {
        ViewerQT* viewerWindow = new ViewerQT;

        viewerWindow->setCameraManipulator(new osgGA::TrackballManipulator);
        viewerWindow->setSceneData(loadedModel.get());

        viewerWindow->show();
    }

    a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) );

    return a.exec();
}

/*EOF*/
<commit_msg>Reorder the setProjectionMatrix.. mathod<commit_after>/* OpenSceneGraph example, osganimate.
*
*  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 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.
*/

#include <osgViewer/Viewer>
#include <osgViewer/CompositeViewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/TrackballManipulator>
#include <osgDB/ReadFile>

#if USE_QT4

    #include <QtCore/QString>
    #include <QtCore/QTimer>
    #include <QtGui/QKeyEvent>
    #include <QtGui/QApplication>
    #include <QtOpenGL/QGLWidget>

    using Qt::WindowFlags;

#else

    class QWidget;
    #include <qtimer.h>
    #include <qgl.h>
    #include <qapplication.h>

    #define WindowFlags WFlags

#endif

#include <iostream>

class AdapterWidget : public QGLWidget
{
    public:

        AdapterWidget( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WindowFlags f = 0 );

        virtual ~AdapterWidget() {}

        osgViewer::GraphicsWindow* getGraphicsWindow() { return _gw.get(); }
        const osgViewer::GraphicsWindow* getGraphicsWindow() const { return _gw.get(); }

    protected:

        void init();

        virtual void resizeGL( int width, int height );
        virtual void keyPressEvent( QKeyEvent* event );
        virtual void keyReleaseEvent( QKeyEvent* event );
        virtual void mousePressEvent( QMouseEvent* event );
        virtual void mouseReleaseEvent( QMouseEvent* event );
        virtual void mouseMoveEvent( QMouseEvent* event );

        osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> _gw;
};

AdapterWidget::AdapterWidget( QWidget * parent, const char * name, const QGLWidget * shareWidget, WindowFlags f):
#if USE_QT4
    QGLWidget(parent, shareWidget, f)
#else
    QGLWidget(parent, name, shareWidget, f)
#endif
{
    _gw = new osgViewer::GraphicsWindowEmbedded(0,0,width(),height());
}

void AdapterWidget::resizeGL( int width, int height )
{
    _gw->getEventQueue()->windowResize(0, 0, width, height );
    _gw->resized(0,0,width,height);
}

void AdapterWidget::keyPressEvent( QKeyEvent* event )
{
#if USE_QT4
    _gw->getEventQueue()->keyPress( (osgGA::GUIEventAdapter::KeySymbol) *(event->text().toAscii().data() ) );
#else
    _gw->getEventQueue()->keyPress( (osgGA::GUIEventAdapter::KeySymbol) event->ascii() );
#endif
}

void AdapterWidget::keyReleaseEvent( QKeyEvent* event )
{
#if USE_QT4
    _gw->getEventQueue()->keyRelease( (osgGA::GUIEventAdapter::KeySymbol) *(event->text().toAscii().data() ) );
#else
    _gw->getEventQueue()->keyRelease( (osgGA::GUIEventAdapter::KeySymbol) event->ascii() );
#endif
}

void AdapterWidget::mousePressEvent( QMouseEvent* event )
{
    int button = 0;
    switch(event->button())
    {
        case(Qt::LeftButton): button = 1; break;
        case(Qt::MidButton): button = 2; break;
        case(Qt::RightButton): button = 3; break;
        case(Qt::NoButton): button = 0; break;
        default: button = 0; break;
    }
    _gw->getEventQueue()->mouseButtonPress(event->x(), event->y(), button);
}

void AdapterWidget::mouseReleaseEvent( QMouseEvent* event )
{
    int button = 0;
    switch(event->button())
    {
        case(Qt::LeftButton): button = 1; break;
        case(Qt::MidButton): button = 2; break;
        case(Qt::RightButton): button = 3; break;
        case(Qt::NoButton): button = 0; break;
        default: button = 0; break;
    }
    _gw->getEventQueue()->mouseButtonRelease(event->x(), event->y(), button);
}

void AdapterWidget::mouseMoveEvent( QMouseEvent* event )
{
    _gw->getEventQueue()->mouseMotion(event->x(), event->y());
}

class ViewerQT : public osgViewer::Viewer, public AdapterWidget
{
    public:

        ViewerQT(QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WindowFlags f = 0):
            AdapterWidget( parent, name, shareWidget, f )
        {
            getCamera()->setViewport(new osg::Viewport(0,0,width(),height()));
            getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width())/static_cast<double>(height()), 1.0f, 10000.0f);
            getCamera()->setGraphicsContext(getGraphicsWindow());

            setThreadingModel(osgViewer::Viewer::SingleThreaded);

            connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL()));
            _timer.start(10);
        }

        virtual void paintGL()
        {
            frame();
        }

    protected:

        QTimer _timer;
};

class CompositeViewerQT : public osgViewer::CompositeViewer, public AdapterWidget
{
    public:

        CompositeViewerQT(QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WindowFlags f = 0):
            AdapterWidget( parent, name, shareWidget, f )
        {
            setThreadingModel(osgViewer::CompositeViewer::SingleThreaded);

            connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL()));
            _timer.start(10);
        }

        virtual void paintGL()
        {
            frame();
        }

    protected:

        QTimer _timer;
};

int main( int argc, char **argv )
{
    QApplication a( argc, argv );

    if (argc<2)
    {
        std::cout << argv[0] <<": requires filename argument." << std::endl;
        return 1;
    }

    osg::ArgumentParser arguments(&argc, argv);

    // load the scene.
    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
    if (!loadedModel)
    {
        std::cout << argv[0] <<": No data loaded." << std::endl;
        return 1;
    }

    if (arguments.read("--CompositeViewer"))
    {
        CompositeViewerQT* viewerWindow = new CompositeViewerQT;

        unsigned int width = viewerWindow->width();
        unsigned int height = viewerWindow->height();

        {
            osgViewer::View* view1 = new osgViewer::View;
            view1->getCamera()->setGraphicsContext(viewerWindow->getGraphicsWindow());
            view1->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width)/static_cast<double>(height/2), 1.0, 1000.0);
            view1->getCamera()->setViewport(new osg::Viewport(0,0,width,height/2));
            view1->setCameraManipulator(new osgGA::TrackballManipulator);
            view1->setSceneData(loadedModel.get());

            viewerWindow->addView(view1);
        }

        {
            osgViewer::View* view2 = new osgViewer::View;
            view2->getCamera()->setGraphicsContext(viewerWindow->getGraphicsWindow());
            view2->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width)/static_cast<double>(height/2), 1.0, 1000.0);
            view2->getCamera()->setViewport(new osg::Viewport(0,height/2,width,height/2));
            view2->setCameraManipulator(new osgGA::TrackballManipulator);
            view2->setSceneData(loadedModel.get());

            viewerWindow->addView(view2);
        }

        viewerWindow->show();
    }
    else
    {
        ViewerQT* viewerWindow = new ViewerQT;

        viewerWindow->setCameraManipulator(new osgGA::TrackballManipulator);
        viewerWindow->setSceneData(loadedModel.get());

        viewerWindow->show();
    }

    a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) );

    return a.exec();
}

/*EOF*/
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: dlgeppm.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 02:42:13 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _DLGEPPM_HXX_
#define _DLGEPPM_HXX_
#include <svtools/fltcall.hxx>
#include <vcl/dialog.hxx>
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
#include <vcl/field.hxx>
#include <svtools/stdctrl.hxx>

/*************************************************************************
|*
|* Dialog zum Einstellen von Filteroptionen
|*
\************************************************************************/

class FilterConfigItem;
class ResMgr;

class DlgExportEPPM : public ModalDialog
{
private:

    FltCallDialogParameter& rFltCallPara;

    FixedLine           aGrpFormat;
    RadioButton         aRBRaw;
    RadioButton         aRBASCII;
    OKButton            aBtnOK;
    CancelButton        aBtnCancel;
    HelpButton          aBtnHelp;

    FilterConfigItem*   pConfigItem;
    ResMgr*             pMgr;

    DECL_LINK( OK, void * );

public:
            DlgExportEPPM( FltCallDialogParameter& rPara );
            ~DlgExportEPPM();
};

#endif // _DLGEPPM_HXX_
<commit_msg>INTEGRATION: CWS changefileheader (1.5.268); FILE MERGED 2008/03/31 13:39:35 rt 1.5.268.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: dlgeppm.hxx,v $
 * $Revision: 1.6 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _DLGEPPM_HXX_
#define _DLGEPPM_HXX_
#include <svtools/fltcall.hxx>
#include <vcl/dialog.hxx>
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
#include <vcl/field.hxx>
#include <svtools/stdctrl.hxx>

/*************************************************************************
|*
|* Dialog zum Einstellen von Filteroptionen
|*
\************************************************************************/

class FilterConfigItem;
class ResMgr;

class DlgExportEPPM : public ModalDialog
{
private:

    FltCallDialogParameter& rFltCallPara;

    FixedLine           aGrpFormat;
    RadioButton         aRBRaw;
    RadioButton         aRBASCII;
    OKButton            aBtnOK;
    CancelButton        aBtnCancel;
    HelpButton          aBtnHelp;

    FilterConfigItem*   pConfigItem;
    ResMgr*             pMgr;

    DECL_LINK( OK, void * );

public:
            DlgExportEPPM( FltCallDialogParameter& rPara );
            ~DlgExportEPPM();
};

#endif // _DLGEPPM_HXX_
<|endoftext|>