Skip to content

Commit

Permalink
Merge pull request #35 from aurusov/dev
Browse files Browse the repository at this point in the history
Текущий dev
  • Loading branch information
aurusov committed Aug 24, 2015
2 parents 1a21ab9 + feebadc commit 8dc91f1
Show file tree
Hide file tree
Showing 828 changed files with 79,499 additions and 83,420 deletions.
4 changes: 2 additions & 2 deletions app/rdo_console/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ SET(APP_NAME rdo)
CONFIGURE_FILE(${CMAKE_MODULE_PATH}/build.version.cmake ${CMAKE_CURRENT_BINARY_DIR}/build_version.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
SET(RESOURCES_FILES
${CMAKE_CURRENT_BINARY_DIR}/build_version.h
${CMAKE_CURRENT_BINARY_DIR}/build_version.h
)

FILE(GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
FILE(GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.h)
ADD_EXECUTABLE(rdo ${SOURCE_FILES} ${TEXT_FILES})
SET_TARGET_PROPERTIES(rdo PROPERTIES FOLDER ${APPS_FOLDERS}/.rdo)

Expand Down
227 changes: 114 additions & 113 deletions app/rdo_console/controller/rdo_console_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "kernel/rdokernel.h"
#include "simulator/service/src/simulator.h"
#include "simulator/report/src/build_edit_line_info.h"
#include "simulator/report/src/error_code.h"
#include "app/rdo_console/controller/rdo_console_controller.h"
// --------------------------------------------------------------------------------

Expand All @@ -14,147 +15,147 @@ using namespace rdo::simulation::report;

#define MUTEXT_PROTECTION(A) boost::lock_guard<boost::mutex> lg_##__LINE__(A);

console_controller::console_controller()
: RDOThread("RDOThreadStudioConsoleController")
, m_state(SS_UNDEFINED)
, m_converted(false)
, m_buildError(false)
, m_runtimeError(false)
, m_convertorError(false)
, m_exitCode(rdo::simulation::report::EC_OK)
ConsoleController::ConsoleController()
: RDOThread("RDOThreadStudioConsoleController")
, state(SimulatorState::UNDEFINED)
, converted(false)
, buildError(false)
, runtimeError(false)
, convertorError(false)
{
notifies.push_back(RT_REPOSITORY_MODEL_OPEN_ERROR );
notifies.push_back(RT_RUNTIME_MODEL_START_BEFORE ); /// @todo : wait
notifies.push_back(RT_RUNTIME_MODEL_STOP_AFTER );
notifies.push_back(RT_SIMULATOR_PARSE_OK );
notifies.push_back(RT_SIMULATOR_PARSE_ERROR );
notifies.push_back(RT_SIMULATOR_PARSE_ERROR_SMR );
notifies.push_back(RT_SIMULATOR_PARSE_ERROR_SMR_EMPTY );
notifies.push_back(RT_SIMULATOR_MODEL_STOP_OK );
notifies.push_back(RT_SIMULATOR_MODEL_STOP_RUNTIME_ERROR);
notifies.push_back(RT_CONVERTOR_NONE );
notifies.push_back(RT_CONVERTOR_OK );
notifies.push_back(RT_CONVERTOR_ERROR );

after_constructor();
notifies.push_back(Message::REPOSITORY_MODEL_OPEN_ERROR );
notifies.push_back(Message::RUNTIME_MODEL_START_BEFORE ); // TODO : wait
notifies.push_back(Message::RUNTIME_MODEL_STOP_AFTER );
notifies.push_back(Message::SIMULATOR_PARSE_OK );
notifies.push_back(Message::SIMULATOR_PARSE_ERROR );
notifies.push_back(Message::SIMULATOR_PARSE_ERROR_SMR );
notifies.push_back(Message::SIMULATOR_PARSE_ERROR_SMR_EMPTY );
notifies.push_back(Message::SIMULATOR_MODEL_STOP_OK );
notifies.push_back(Message::SIMULATOR_MODEL_STOP_RUNTIME_ERROR);
notifies.push_back(Message::CONVERTOR_NONE );
notifies.push_back(Message::CONVERTOR_OK );
notifies.push_back(Message::CONVERTOR_ERROR );

after_constructor();
}

console_controller::~console_controller()
ConsoleController::~ConsoleController()
{}

bool console_controller::finished() const
bool ConsoleController::isFinished() const
{
bool res = true;
{
MUTEXT_PROTECTION(m_stateMutex);
res = (m_state == SS_FINISHED);
}
return res;
bool res = true;
{
MUTEXT_PROTECTION(stateMutex);
res = (state == SimulatorState::FINISHED);
}
return res;
}

bool console_controller::converted() const
bool ConsoleController::isConverted() const
{
return m_converted;
return converted;
}

bool console_controller::simulationSuccessfully()
bool ConsoleController::isSimulationSuccessfully()
{
sendMessage(kernel->simulator(), RT_SIMULATOR_GET_MODEL_EXITCODE, &m_exitCode);
return m_exitCode == rdo::simulation::report::EC_OK;
rdo::simulation::report::ExitCode exitCode;
sendMessage(kernel->simulator(), Message::SIMULATOR_GET_MODEL_EXITCODE, &exitCode);
return exitCode == rdo::simulation::report::ExitCode::OK;
}

bool console_controller::buildError() const
bool ConsoleController::isBuildError() const
{
return m_buildError;
return buildError;
}

bool console_controller::runtimeError() const
bool ConsoleController::isRuntimeError() const
{
return m_runtimeError;
return runtimeError;
}

bool console_controller::convertorError() const
bool ConsoleController::isConvertorError() const
{
return m_convertorError;
return convertorError;
}

void console_controller::getBuildLogList(StringList& list) const
void ConsoleController::getBuildLog(std::list<std::string>& list) const
{
list = m_buildLogList;
list = buildLog;
}

void console_controller::proc(RDOThread::RDOMessageInfo& msg)
void ConsoleController::proc(RDOThread::RDOMessageInfo& msg)
{
switch (msg.message)
{
case RDOThread::RT_REPOSITORY_MODEL_OPEN_ERROR:
break;

case RDOThread::RT_RUNTIME_MODEL_START_BEFORE:
{
MUTEXT_PROTECTION(m_stateMutex);
m_state = SS_IN_PROGRESS;
}
break;

case RDOThread::RT_RUNTIME_MODEL_STOP_AFTER:
{
MUTEXT_PROTECTION(m_stateMutex);
m_state = SS_FINISHED;
}
break;

case RDOThread::RT_SIMULATOR_PARSE_OK:
break;

case RDOThread::RT_SIMULATOR_PARSE_ERROR:
{
m_buildError = true;
std::vector<FileMessage> errors;
sendMessage(kernel->simulator(), RT_SIMULATOR_GET_ERRORS, &errors);
fillBuildLogList(errors);
}
break;

case RDOThread::RT_SIMULATOR_PARSE_ERROR_SMR:
break;

case RDOThread::RT_SIMULATOR_PARSE_ERROR_SMR_EMPTY:
break;

case RDOThread::RT_SIMULATOR_MODEL_STOP_OK:
break;

case RDOThread::RT_SIMULATOR_MODEL_STOP_RUNTIME_ERROR:
m_runtimeError = true;
break;

case RDOThread::RT_CONVERTOR_NONE:
m_converted = true;
m_convertorError = false;
break;

case RDOThread::RT_CONVERTOR_OK:
m_converted = true;
m_convertorError = false;
break;

case RDOThread::RT_CONVERTOR_ERROR:
m_converted = true;
m_convertorError = true;
break;

default:
break;
}
switch (msg.message)
{
case RDOThread::Message::REPOSITORY_MODEL_OPEN_ERROR:
break;

case RDOThread::Message::RUNTIME_MODEL_START_BEFORE:
{
MUTEXT_PROTECTION(stateMutex);
state = SimulatorState::IN_PROGRESS;
}
break;

case RDOThread::Message::RUNTIME_MODEL_STOP_AFTER:
{
MUTEXT_PROTECTION(stateMutex);
state = SimulatorState::FINISHED;
}
break;

case RDOThread::Message::SIMULATOR_PARSE_OK:
break;

case RDOThread::Message::SIMULATOR_PARSE_ERROR:
{
buildError = true;
std::vector<FileMessage> errors;
sendMessage(kernel->simulator(), Message::SIMULATOR_GET_ERRORS, &errors);
appendToBuildLog(errors);
}
break;

case RDOThread::Message::SIMULATOR_PARSE_ERROR_SMR:
break;

case RDOThread::Message::SIMULATOR_PARSE_ERROR_SMR_EMPTY:
break;

case RDOThread::Message::SIMULATOR_MODEL_STOP_OK:
break;

case RDOThread::Message::SIMULATOR_MODEL_STOP_RUNTIME_ERROR:
runtimeError = true;
break;

case RDOThread::Message::CONVERTOR_NONE:
converted = true;
convertorError = false;
break;

case RDOThread::Message::CONVERTOR_OK:
converted = true;
convertorError = false;
break;

case RDOThread::Message::CONVERTOR_ERROR:
converted = true;
convertorError = true;
break;

default:
break;
}
}

void console_controller::fillBuildLogList(std::vector<FileMessage>& errors)
void ConsoleController::appendToBuildLog(std::vector<FileMessage>& errors)
{
for (const FileMessage& error: errors)
{
const BuildEditLineInfo info(error);
const std::string line = info.getMessage();
m_buildLogList.push_back(line);
}
for (const FileMessage& error: errors)
{
const BuildEditLineInfo info(error);
const std::string line = info.getMessage();
buildLog.push_back(line);
}
}
72 changes: 31 additions & 41 deletions app/rdo_console/controller/rdo_console_controller.h
Original file line number Diff line number Diff line change
@@ -1,62 +1,52 @@
#ifndef _RDO_STUDIO_CONSOLE_CONTROLLER_H_
#define _RDO_STUDIO_CONSOLE_CONTROLLER_H_
#pragma once

// ----------------------------------------------------------------------- INCLUDES
#include <boost/optional.hpp>
#include <boost/thread/mutex.hpp>
// ----------------------------------------------------------------------- SYNOPSIS
#include "kernel/rdothread.h"
#include "simulator/report/src/error_code.h"
#include "simulator/report/src/file_message.h"
// --------------------------------------------------------------------------------

namespace rdo {

class console_controller: public RDOThread
class ConsoleController: public RDOThread
{
public:
typedef std::list<std::string> StringList;
ConsoleController();
virtual ~ConsoleController();

console_controller();
virtual ~console_controller();
bool isFinished() const;
bool isConverted() const;
bool isSimulationSuccessfully();

bool finished() const;
bool converted() const;
bool simulationSuccessfully();
bool isBuildError() const;
bool isRuntimeError() const;
bool isConvertorError() const;

bool buildError() const;
bool runtimeError() const;
bool convertorError() const;

void getBuildLogList(StringList& list) const;

private:
typedef rdo::simulation::report::FileMessage FileMessage;
typedef rdo::simulation::report::RDOExitCode RDOExitCode;
void getBuildLog(std::list<std::string>& list) const;

private:
void proc(RDOMessageInfo& msg);
void fillBuildLogList(std::vector<FileMessage>& errors);

private:
enum SimulatorState
{
SS_UNDEFINED,
SS_IN_PROGRESS,
SS_FINISHED
};

SimulatorState m_state;
bool m_converted;
bool m_buildError;
bool m_runtimeError;
bool m_convertorError;
RDOExitCode m_exitCode;
StringList m_buildLogList;

mutable boost::mutex m_stateMutex;
typedef rdo::simulation::report::FileMessage FileMessage;

enum class SimulatorState
{
UNDEFINED,
IN_PROGRESS,
FINISHED
};

SimulatorState state;
mutable boost::mutex stateMutex;

bool converted;
bool buildError;
bool runtimeError;
bool convertorError;
std::list<std::string> buildLog;

void proc(RDOMessageInfo& msg);
void appendToBuildLog(std::vector<FileMessage>& errors);
};

} // namespace rdo

#endif // _RDO_STUDIO_CONSOLE_CONTROLLER_H_
Loading

0 comments on commit 8dc91f1

Please sign in to comment.