Changeset 165 in pacpusframework


Ignore:
Timestamp:
08/01/13 18:30:31 (11 years ago)
Author:
Marek Kurdej
Message:

Major: changed plugins section name to plugings. Parameters section will be used for something else.

Location:
branches/2.0-beta1
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0-beta1/examples/ProducerConsumerExample/ConsumerExample.cpp

    r163 r165  
    5252    LOG_TRACE(Q_FUNC_INFO);
    5353    moveToThread(&thread);
     54    m_counter = 0;
    5455   
    55     m_counter = 0;
    56     static const char * outputFileName = "test2.txt";
     56    static const char * outputFileName = "consumer.txt";
    5757    m_file.open(outputFileName, std::ios_base::out | std::ios_base::app);
    5858    if (!m_file.is_open()) {
     
    7777void ConsumerExample::process(const QImage& matrix)
    7878{
    79     LOG_INFO("Size " << matrix.size().width()<< " x " << matrix.size().height());
    80     unsigned int k = 0;
     79    m_file << ++m_counter << " " << road_time() << "\n" << std::flush;
    8180
    82     // a process
    83     for (int i = 0; i < 100; ++i) {
    84         ++k;
    85     }
    86     m_file << ++m_counter << " " << road_time() << "\n";
     81    LOG_INFO("Received QIMage: "
     82        << "size = " << matrix.size().width()<< " x " << matrix.size().height()
     83        );
     84
     85    // DO PROCESSING
    8786
    8887    setState(MONITOR_OK);
  • branches/2.0-beta1/examples/ProducerConsumerExample/ProducerConsumerExample.xml

    r163 r165  
    1010    </connections>
    1111
    12     <!-- FIXME: change into plugins -->
    13     <parameters prefix="" postfix="_d" extension="dll">
     12    <plugins prefix="" postfix="" extension="dll">
    1413        <plugin lib="ProducerConsumerExample" />
    15         <plugin lib="ShMem" />
     14    </plugins>
     15   
     16    <parameters>
    1617    </parameters>
    1718</pacpus>
  • branches/2.0-beta1/examples/ProducerConsumerExample/ProducerExample.cpp

    r163 r165  
    7171void ProducerExample::run()
    7272{
    73     unsigned int counter = 0;
    74     int waitTime = 5000;
     73    unsigned int counter = 1;
     74    int waitTimeMicros = 150 * 1000;
    7575
    7676    std::fstream file(outputFileName, std::ios_base::out | std::ios_base::app);
     
    8787    while (isActive()) {
    8888        //mat.setPixel(0,0,i);
    89         LOG_INFO("Size " << mat.size().width()<< " x " << mat.size().height());
     89        LOG_INFO("Sent QImage: "
     90            << "size = " << mat.size().width()<< " x " << mat.size().height()
     91            );
    9092
    9193        if (imageOutput && imageOutput->hasConnection()) {
     
    9395        }
    9496
    95         LOG_INFO("Send data " << counter << " time " << road_time());
    96         file << ++counter << " " << road_time() << "\n";
     97        LOG_INFO("Sent data=" << counter << ", time=" << road_time());
     98        file << counter << " " << road_time() << "\n" << std::flush;
    9799
    98         usleep(waitTime);
     100        usleep(waitTimeMicros);
    99101        ++counter;
    100102        setState(MONITOR_OK);
  • branches/2.0-beta1/include/Pacpus/kernel/PacpusApplication.h

    r141 r165  
    4141
    4242    virtual bool notify(QObject * receiver, QEvent * ev);
     43
     44private:
     45    void installSignalHandler();
    4346};
    4447
  • branches/2.0-beta1/include/Pacpus/kernel/XmlConfigFile.h

    r146 r165  
    7878
    7979protected:
     80    QDomElement getSection(const char * name) const;
     81    QDomNodeList getNodesInSection(const char * sectionName, const char * nodeName) const;
     82
    8083    QDomNodeList getAllComponents() const;
    8184    QDomNodeList getAllConnections() const;
     85    QDomNodeList getAllParameters() const;
    8286    QDomNodeList getAllPlugins();
    8387
  • branches/2.0-beta1/src/PacpusLib/PacpusApplication.cpp

    r162 r165  
    99/// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
    1010
     11#include <csignal>
    1112#include <Pacpus/kernel/Log.h>
    1213#include <Pacpus/kernel/PacpusApplication.h>
    1314#include <Pacpus/kernel/PacpusException.h>
     15#include <sstream>
     16#include <string>
    1417
    1518using namespace pacpus;
     
    2427    : QApplication(argc, argv, _internal)
    2528{
     29    //installSignalHandler();
    2630}
    2731
     
    9296    return false;
    9397}
     98
     99void signalHandler(int signal);
     100
     101void PacpusApplication::installSignalHandler()
     102{
     103    LOG_INFO("installing signal handler...");
     104
     105    typedef void (*SignalHandlerType)(int);
     106
     107    //std::signal(SIGABRT, &signalHandler);
     108    //std::signal(SIGFPE, &signalHandler);
     109    //std::signal(SIGILL, &signalHandler);
     110    std::signal(SIGINT, &signalHandler); // interrupt (CTRL-C)
     111    //std::signal(SIGSEGV, &signalHandler);
     112    //std::signal(SIGTERM, &signalHandler);
     113
     114    LOG_INFO("successfully installed signal handler");
     115}
     116
     117void signalHandler(int signal)
     118{
     119    LOG_FATAL("signal received: sig = " << signal);
     120    std::stringstream errorMessage;
     121    errorMessage << "received signal number " << signal;
     122    throw PacpusException(errorMessage.str());
     123}
  • branches/2.0-beta1/src/PacpusLib/XmlComponentConfig.cpp

    r162 r165  
    1414DECLARE_STATIC_LOGGER("pacpus.core.XmlComponentConfig");
    1515
    16 // FIXME: const char* instead of const string
    17 static const string kPropertyComponentName = "name";
    18 static const string kPropertyComponentType = "type";
    19 static const string kPropertyConnectionType = "type";
    20 static const string kPropertyConnectionInput = "input";
    21 static const string kPropertyConnectionOutput = "output";
    22 static const string kPropertyConnectionPriority = "priority";
    23 //static const string kPropertyConnectionInputC = "inputC";
    24 //static const string kPropertyConnectionInputP = "inputP";
    25 //static const string kPropertyConnectionOutputC = "outputC";
    26 //static const string kPropertyConnectionOutputP = "outputP";
     16static const char* kPropertyComponentName = "name";
     17static const char* kPropertyComponentType = "type";
     18static const char* kPropertyConnectionType = "type";
     19static const char* kPropertyConnectionInput = "input";
     20static const char* kPropertyConnectionOutput = "output";
     21static const char* kPropertyConnectionPriority = "priority";
    2722
    2823XmlComponentConfig::XmlComponentConfig(const QString& name)
     
    4742    {
    4843        LOG_ERROR("cannot add component property:"
    49                   << " component '" << component_.attribute(kPropertyComponentName.c_str()) << "'"
     44                  << " component '" << component_.attribute(kPropertyComponentName) << "'"
    5045                  << " already contains property '" << name << "'"
    5146                  << " and its value is '" << component_.attribute(name) << "'"
     
    5752    component_.setAttribute(name, 0);
    5853    LOG_INFO("property '" << name << "'"
    59               << " was added to the component " << component_.attribute(kPropertyComponentName.c_str()) << "'"
     54              << " was added to the component " << component_.attribute(kPropertyComponentName) << "'"
    6055              << " and set to '" << component_.attribute(name) << "'"
    6156              );
     
    6661    if (!hasProperty(name)) {
    6762        LOG_WARN("cannot delete compoenent property '" << name << "'"
    68                  << " of component '" << component_.attribute(kPropertyComponentName.c_str()) << "'"
     63                 << " of component '" << component_.attribute(kPropertyComponentName) << "'"
    6964                 << ". Component does not contain this property."
    7065                 );
     
    7570    component_.removeAttribute(name);
    7671    LOG_INFO("property '" << name << "' "
    77       << " of component '" << component_.attribute(kPropertyComponentName.c_str()) << "'"
     72      << " of component '" << component_.attribute(kPropertyComponentName) << "'"
    7873      << " was deleted"
    7974      );
     
    8782    {
    8883        LOG_WARN("cannot retrieve component property '" << name << "'"
    89                  << " of component '" << component_.attribute(kPropertyComponentName.c_str()) << "'"
     84                 << " of component '" << component_.attribute(kPropertyComponentName) << "'"
    9085                 << ". Component does not contain this property."
    9186                 );
     
    116111    component_.setAttribute(name, value);
    117112    LOG_INFO("property " << name
    118              << " of the component " << component_.attribute(kPropertyComponentName.c_str())
     113             << " of the component " << component_.attribute(kPropertyComponentName)
    119114             << " was set to : " << value
    120115             );
     
    138133QString const XmlComponentConfig::getComponentName() const
    139134{
    140     //return component_.attribute(kPropertyComponentName.c_str());
    141     return getProperty(kPropertyComponentName.c_str());
     135    return getProperty(kPropertyComponentName);
    142136}
    143137
    144138QString const XmlComponentConfig::getComponentType() const
    145139{
    146     return getProperty(kPropertyComponentType.c_str());
     140    return getProperty(kPropertyComponentType);
    147141}
    148142
    149143QString const XmlComponentConfig::getConnectionType() const
    150144{
    151     return getProperty(kPropertyConnectionType.c_str());
     145    return getProperty(kPropertyConnectionType);
    152146}
    153147
    154148QString const XmlComponentConfig::getConnectionInput() const
    155149{
    156     return getProperty(kPropertyConnectionInput.c_str());
     150    return getProperty(kPropertyConnectionInput);
    157151}
    158152
    159153QString const XmlComponentConfig::getConnectionOutput() const
    160154{
    161     return getProperty(kPropertyConnectionOutput.c_str());
     155    return getProperty(kPropertyConnectionOutput);
    162156}
    163157
    164158int const XmlComponentConfig::getConnectionPriority() const
    165159{
    166     return getIntProperty(kPropertyConnectionPriority.c_str(),0);
     160    return getIntProperty(kPropertyConnectionPriority, /*defaultValue=*/0);
    167161}
  • branches/2.0-beta1/src/PacpusLib/XmlConfigFile.cpp

    r147 r165  
    2828static const char * kConnectionSection = "connections";
    2929static const char * kParameterSection = "parameters";
     30static const char * kPluginSection = "plugins";
    3031
    3132static const char * kComponentNode = "component";
    3233static const char * kConnectionNode = "connection";
     34static const char * kParameterNode = "parameter";
    3335static const char * kPluginNode = "plugin";
    3436
     
    5557    // create the sections
    5658    m_document.documentElement().appendChild(m_document.createElement(kParameterSection));
     59    m_document.documentElement().appendChild(m_document.createElement(kPluginSection));
    5760    m_document.documentElement().appendChild(m_document.createElement(kComponentSection));
    5861    m_document.documentElement().appendChild(m_document.createElement(kConnectionSection));
     
    9396    (void) mutexLocker; // unused
    9497
    95     // TODO: change .tagName => .attribute(kPropertyComponentName.c_str())
     98    // TODO: change .tagName => .attribute(kPropertyComponentName)
    9699    QDomNode componentSectionNode = getNamedItemFromDomDocument(m_document, kComponentSection);
    97100    if (componentSectionNode.namedItem(component.attribute(kNameAttribute)/*.tagName()*/).isNull()) {
     
    206209}
    207210
     211// XML
     212QDomElement XmlConfigFile::getSection(const char * name) const
     213{
     214    QDomElement sectionElement = getNamedItemFromDomDocument(m_document, name).toElement();
     215    if (sectionElement.isNull()) {
     216        LOG_WARN("there is no '" << name << "' section in the XML");
     217        return QDomElement();
     218    }
     219    return sectionElement;
     220}
     221
     222QDomNodeList XmlConfigFile::getNodesInSection(const char * sectionName, const char * nodeName) const
     223{
     224    QDomElement sectionElement = getSection(sectionName);
     225    return sectionElement.elementsByTagName(nodeName);
     226}
     227
    208228// COMPONENTS
    209229QDomNodeList XmlConfigFile::getAllComponents() const
    210230{
    211     // get components section
    212     QDomElement componentsElement = getNamedItemFromDomDocument(m_document, kComponentSection).toElement();
    213     if (componentsElement.isNull()) {
    214         LOG_WARN("there is no '" << kComponentSection << "' section in the XML");
    215         return QDomNodeList();
    216     }
    217 
    218     // get component nodes
    219     return componentsElement.elementsByTagName(kComponentNode);
     231    return getNodesInSection(kComponentSection, kComponentNode);
    220232}
    221233
     
    252264QDomNodeList XmlConfigFile::getAllConnections() const
    253265{
    254     // get connections section
    255     QDomElement connectionsElement = getNamedItemFromDomDocument(m_document, kParameterSection).toElement();
    256     if (connectionsElement.isNull()) {
    257         LOG_WARN("there is no '" << kParameterSection << "' section in the XML");
    258         return QDomNodeList();
    259     }
    260 
    261     // get connection nodes
    262     //return connectionsElement.elementsByTagName(kConnectionNode);
    263     return getNamedItemFromDomDocument(m_document, kConnectionSection).childNodes();
     266    return getNodesInSection(kConnectionSection, kConnectionNode);
    264267}
    265268
     
    281284}
    282285
     286// PARAMETERS
     287QDomNodeList XmlConfigFile::getAllParameters() const
     288{
     289    return getNodesInSection(kParameterSection, kParameterNode);
     290}
     291
    283292// PLUGINS
    284293QDomNodeList XmlConfigFile::getAllPlugins()
    285294{
    286     // get parameters section
    287     QDomElement parametersElement = getNamedItemFromDomDocument(m_document, kParameterSection).toElement();
    288     if (parametersElement.isNull()) {
    289         LOG_WARN("there is no '" << kParameterSection << "' section in the XML");
    290         return QDomNodeList();
    291     }
     295    // get section
     296    QDomElement pluginsElement = getSection(kPluginSection);
    292297
    293298    // get attributes
    294     m_libraryExtension = parametersElement.attribute(kExtensionAttribute);
     299    m_libraryExtension = pluginsElement.attribute(kExtensionAttribute);
    295300    if (!m_libraryExtension.isEmpty()) {
    296301        // prefix with a dot '.' if there is no one
     
    299304        }
    300305    }
    301     m_libraryPrefix = parametersElement.attribute(kPrefixAttribute);
    302     m_libraryPostfix = parametersElement.attribute(kPostfixAttribute);
     306    m_libraryPrefix = pluginsElement.attribute(kPrefixAttribute);
     307    m_libraryPostfix = pluginsElement.attribute(kPostfixAttribute);
    303308   
    304     // get plugin nodes
    305     return parametersElement.elementsByTagName(kPluginNode);
     309    // get nodes
     310    return getNodesInSection(kPluginSection, kPluginNode);
    306311}
    307312
     
    313318        return QStringList();
    314319    }
     320    LOG_INFO("there are " << pluginList.size() << " plugins");
    315321
    316322    // get plugin library paths
Note: See TracChangeset for help on using the changeset viewer.