Commit 5c28ee5d authored by Marco De Marco's avatar Marco De Marco
Browse files

Script manager added

parent e005369f
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -7,10 +7,7 @@
VERIFY_TOOL="/home/mdm/workspace/nexecs/test/tools/fitsverify"
CHECK_STRING="conform to the FITS format"

NO_FILE_ERROR="failed to find or open the following file"

FATAL_ERROR="Fatal"

EOF_ERROR="End-of-file"

#-----------------------------------------------------------------------
+2 −2
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ EventBuffer::~EventBuffer()
}

//==============================================================================
//	EventBuffer::insertNew()
//	EventBuffer::create()
//==============================================================================
EventBuffer::SP EventBuffer::create(Tango::DeviceImpl* deviceImpl_p)
{
+10 −0
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ void EventThread::start()

    try
    {
        initScriptManager();

        initEventBuffer();

        initINotify();
@@ -149,6 +151,14 @@ void EventThread::writeStatus(std::string status)
    m_status = status;
}

//==============================================================================
//	EventThread::initScriptManager()
//==============================================================================
void EventThread::initScriptManager() throw(std::runtime_error)
{
    DEBUG_STREAM << "EventThread::initScriptManager()" << endl;
}

//==============================================================================
//	EventThread::initEventBuffer()
//==============================================================================
+6 −1
Original line number Diff line number Diff line
@@ -70,14 +70,19 @@ protected:
    virtual void writeStatus(std::string);

//------------------------------------------------------------------------------
//	[Protected] Utilities methods
//	[Protected] Initialization methods
//------------------------------------------------------------------------------
    virtual void initScriptManager() throw(std::runtime_error);

	virtual void initEventBuffer() throw(std::runtime_error);

	virtual void initINotify() throw(std::runtime_error);

	virtual void initThreadGroup() throw(std::runtime_error);

//------------------------------------------------------------------------------
//	[Protected] Event loop method
//------------------------------------------------------------------------------
    virtual void eventLoop();

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

src/ScriptManager.cpp

0 → 100644
+83 −0
Original line number Diff line number Diff line
#include <ScriptManager.h>

#include <iostream>
#include <sstream>

namespace PreProcessor_ns
{

//=============================================================================
//	ScriptManager::ScriptManager()
//=============================================================================
ScriptManager::ScriptManager(Tango::DeviceImpl* deviceImpl_p,
    Configuration::SP configuration_sp) : Tango::LogAdapter(deviceImpl_p),
    m_configuration_sp(configuration_sp)
{
    DEBUG_STREAM << "ScriptManager::ScriptManager()" << endl;
}

//=============================================================================
//	ScriptManager::~ScriptManager()
//=============================================================================
ScriptManager::~ScriptManager()
{
    DEBUG_STREAM << "ScriptManager::~ScriptManager()" << endl;
}

//==============================================================================
//	EventBuffer::create()
//==============================================================================
ScriptManager::SP ScriptManager::create(Tango::DeviceImpl* deviceImpl_p,
    Configuration::SP configuration_sp)
{
    ScriptManager::SP s_sp(new ScriptManager(deviceImpl_p, configuration_sp),
        ScriptManager::Deleter());

    return s_sp;
}

//=============================================================================
//	ScriptManager::isReadyToArchive()
//=============================================================================
bool ScriptManager::isReadyToArchive(std::string fileName)
     throw(std::runtime_error)
{
    DEBUG_STREAM << "ScriptManager::isReadyToArchive()" << endl;

    return true;
}

//=============================================================================
//	ScriptManager::exec()
//=============================================================================
std::string ScriptManager::exec(std::string command)
	throw(std::runtime_error)
{
    DEBUG_STREAM << "ScriptManager::exec()" << endl;

	const int BUFFSIZE = 1024;

    FILE* pipe = popen(command.c_str(), "r");

    if (!pipe)
    	throw std::runtime_error("Error launching external script");

    char buffer[BUFFSIZE];
    std::string result = "";

    while(!feof(pipe))
    {
        if(fgets(buffer, BUFFSIZE, pipe) != NULL)
                result += buffer;
    }

    pclose(pipe);

	DEBUG_STREAM << "ScriptManager::exec() " << result << endl;

    return result;
}

}

Loading