Changeset 121 in pacpusframework


Ignore:
Timestamp:
Jul 19, 2013, 12:42:35 PM (11 years ago)
Author:
morasjul
Message:

add cmake macro
and improve serial component

Location:
branches/2.0-beta1
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0-beta1/cmake/PacpusUtilities.cmake

    r120 r121  
    1313## Qt macro compatibility Qt4 / Qt5
    1414## ========================================
    15 #function(qt_wrap_moc MOC_SRCS FILES_TO_MOC)
    16 
    17 #    if(QT4_FOUNDED)
    18 #        qt4_wrap_cpp(TEMP_VAR ${FILES_TO_MOC})
    19 
    20 #    elseif(Qt5Core_FOUND)
    21 #        qt5_wrap_cpp(${MOC_SRCS} ${FILES_TO_MOC} PARENT_SCOPE)
    22 
    23 #    else()
    24 #        message(WARNING "QT ui found, can't wrap moc File")
    25 #    endif()
    26 
    27 #    #set(${MOC_SRCS} ${TEMP_VAR} PARENT_SCOPE)
    28 
    29 #endfunction(qt_wrap_moc)
     15function(qt_wrap_cpp OUT_MOC_SRCS FILES_TO_MOC)
     16
     17    if(QT4_FOUNDED)
     18        qt4_wrap_cpp(MOC_SRCS ${FILES_TO_MOC})
     19
     20    elseif(Qt5Core_FOUND)
     21        qt5_wrap_cpp(MOC_SRCS ${FILES_TO_MOC})
     22
     23    else()
     24        message(WARNING "QT not found, can't wrap moc File")
     25    endif()
     26
     27    set(${OUT_MOC_SRCS} ${MOC_SRCS} PARENT_SCOPE)
     28
     29endfunction(qt_wrap_cpp)
    3030
    3131## ========================================
    3232## Qt macro compatibility Qt4 / Qt5
    3333## ========================================
    34 #function(qt_wrap_ui UI_SRCS UI_FILES)
    35 #    if(QT4_FOUND)
    36 #        qt4_wrap_ui( TEMP_VAR ${UI_FILES})
    37 
    38 #    elseif(Qt5Core_FOUND)
    39 #        qt5_wrap_ui( TEMP_VAR ${UI_FILES})
    40 
    41 #    else()
    42 #        message(WARNING "QT ui found, can't wrap ui File")
    43 #    endif()
    44 
    45 #    set(${UI_SRCS} ${TEMP_VAR} PARENT_SCOPE)
    46 #endfunction()
     34function(qt_wrap_ui OUT_UI_SRCS UI_FILES)
     35    if(QT4_FOUND)
     36        qt4_wrap_ui( UI_SRCS ${UI_FILES})
     37
     38    elseif(Qt5Core_FOUND)
     39        qt5_wrap_ui( UI_SRCS ${UI_FILES})
     40
     41    else()
     42        message(WARNING "QT not found, can't wrap ui File")
     43    endif()
     44
     45    set(${OUT_UI_SRCS} ${UI_SRCS} PARENT_SCOPE)
     46
     47endfunction()
    4748
    4849# ========================================
     
    5354    if(QT4_FOUND)
    5455        pacpus_plugin_qt4(PLUGIN_CPP PLUGIN_H ${PROJECT_NAME} )
     56        #message("Create QT4 Plugin")
    5557
    5658    elseif(Qt5Core_FOUND)
     
    6163    endif()
    6264
     65    set(${OUT_CPP} ${PLUGIN_CPP} PARENT_SCOPE)
     66    set(${OUT_H} ${PLUGIN_H} PARENT_SCOPE)
    6367
    6468endfunction(PACPUS_PLUGIN)
     
    162166        "    Q_OBJECT\n"
    163167        "    //Qt5 Plugins Macro\n"
    164         "    Q_PLUGIN_METADATA(IID \"papus.pacpuscityvip." ${PLUGIN_NAME} "\" FILE \"" ${PLUGIN_NAME} ".json\")\n"
     168        "    Q_PLUGIN_METADATA(IID \"papus." ${PLUGIN_NAME} "\" FILE \"" ${PLUGIN_NAME} ".json\")\n"
    165169        "    Q_INTERFACES(PacpusPluginInterface)\n"   
    166170        "\n"
     
    366370  SET(${result} ${dirlist})
    367371ENDMACRO()
     372
     373
     374# ========================================
     375# Create export header for plugins
     376# ========================================
     377function(CREATE_EXPORT OUT_H PLUGIN_NAME)
     378
     379    set(${OUT_H} "export_${PLUGIN_NAME}.h" PARENT_SCOPE)
     380
     381    string(TOUPPER ${PLUGIN_NAME} PLUGIN_NAME_UPPER)
     382
     383    # create the header file
     384    file(WRITE "export_${PLUGIN_NAME}.h"
     385        "// Autogenerated file by PacpusUtilities.cmake\n"
     386        "// DO NOT EDIT!!! ALL CHANGES WOULD BE REMOVED BY THE NEXT CALL OF CMAKE\n"
     387        "\n"
     388
     389        "#ifndef __EXPORT_${PLUGIN_NAME_UPPER}__H__\n"
     390        "#define __EXPORT_${PLUGIN_NAME_UPPER}_H__\n"
     391        "\n"
     392        "// Export macro for use DLL for Windows only\n"
     393        "#ifdef WIN32\n"
     394        "#   ifdef ${PLUGIN_NAME_UPPER}_EXPORT\n"
     395        "//      make DLL\n"
     396        "#       define ${PLUGIN_NAME_UPPER}_API __declspec(dllexport)\n"
     397        "#   else\n"
     398        "//      use DLL\n"
     399        "#       define ${PLUGIN_NAME_UPPER}_API __declspec(dllimport)\n"
     400        "#   endif\n"
     401        "#else\n"
     402        "//      On other platforms, simply ignore this\n"
     403        "#       define ${PLUGIN_NAME_UPPER}_API\n"
     404        "//#endif\n"
     405
     406        "#endif // __EXPORT_${PLUGIN_NAME_UPPER}_H__\n"
     407        )
     408endfunction(CREATE_EXPORT)
  • branches/2.0-beta1/include/Pacpus/PacpusTools/PacpusSerialPort.h

    r120 r121  
    6262
    6363    QString sepChar;
     64    QString startChar;
     65    QString stopChar;
    6466
    6567
  • branches/2.0-beta1/src/PacpusLib/CMakeLists.txt

    r120 r121  
    6565    ${PACPUS_INCLUDE_DIR}/Pacpus/kernel/inputOutputInterface.h
    6666    ${PACPUS_INCLUDE_DIR}/Pacpus/kernel/PacpusEvent.h
    67     #${PACPUS_INCLUDE_DIR}/Pacpus/kernel/pacpusStruct.h
     67    ${PACPUS_INCLUDE_DIR}/Pacpus/kernel/pacpusStruct.h
    6868
    6969    ./ComponentBase.cpp
     
    7575    ./XmlConfigFile.cpp
    7676    ./inputOutputBase.cpp
    77     #./pacpusStruct.cpp
     77    ./pacpusStruct.cpp
    7878)
    7979
  • branches/2.0-beta1/src/PacpusTools/src/PacpusSerialPort.cpp

    r120 r121  
    4242    sepChar = "\n";
    4343
     44    startChar = "$";
     45    stopChar = "\n";
     46
    4447    // Or threaded
    4548    connect(serialPort,SIGNAL(readyRead()),this,SLOT(readData()));
     
    101104    sepChar =  param.getProperty("sepChar");
    102105
     106    if(param.hasProperty("startChar"))
     107    startChar =  param.getProperty("startChar");
     108
     109    if(param.hasProperty("stopChar"))
     110    stopChar =  param.getProperty("stopChar");
     111
    103112    serialPort->setPortName(portName);
    104113
    105114    if(!serialPort->setBaudRate(baudRate,direction))
    106         LOG_ERROR("n° "<< serialPort->error());
     115        LOG_ERROR(getName() << "\t error n° "<< serialPort->error());
    107116    if(!serialPort->setDataBits(dataBits))
    108         LOG_ERROR("n° "<< serialPort->error());
     117        LOG_ERROR(getName() << "\t error n° "<< serialPort->error());
    109118    if(!serialPort->setParity(parity))
    110         LOG_ERROR("n° "<< serialPort->error());
     119        LOG_ERROR(getName() << "\t error n° "<< serialPort->error());
    111120    if(!serialPort->setStopBits(stopBits))
    112         LOG_ERROR("n° "<< serialPort->error());
     121        LOG_ERROR(getName() << "\t error n° "<< serialPort->error());
    113122    if(!serialPort->setFlowControl(flowControl))
    114         LOG_ERROR("n° "<< serialPort->error());
     123        LOG_ERROR(getName() << "\t error n° "<< serialPort->error());
    115124    if(!serialPort->setDataErrorPolicy(errorPolicy))
    116         LOG_ERROR("n° "<< serialPort->error());
     125        LOG_ERROR(getName() << "\t error n° "<< serialPort->error());
    117126
    118127    // For futher developpements
     
    160169    {
    161170        setState(MONITOR_OK);
    162         LOG_DEBUG("Serial write performed")
     171        LOG_DEBUG(getName() << " Serial write performed")
    163172    }
    164173    else
    165174     {
    166175        setState(MONITOR_NOK);
    167         LOG_WARN("Serial write error")
     176        LOG_WARN(getName() << " Serial write error")
    168177    }
    169178}
Note: See TracChangeset for help on using the changeset viewer.