- Timestamp:
- Aug 1, 2013, 6:30:31 PM (11 years ago)
- Location:
- branches/2.0-beta1
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0-beta1/examples/ProducerConsumerExample/ConsumerExample.cpp
r163 r165 52 52 LOG_TRACE(Q_FUNC_INFO); 53 53 moveToThread(&thread); 54 m_counter = 0; 54 55 55 m_counter = 0; 56 static const char * outputFileName = "test2.txt"; 56 static const char * outputFileName = "consumer.txt"; 57 57 m_file.open(outputFileName, std::ios_base::out | std::ios_base::app); 58 58 if (!m_file.is_open()) { … … 77 77 void ConsumerExample::process(const QImage& matrix) 78 78 { 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; 81 80 82 // a process83 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 87 86 88 87 setState(MONITOR_OK); -
branches/2.0-beta1/examples/ProducerConsumerExample/ProducerConsumerExample.xml
r163 r165 10 10 </connections> 11 11 12 <!-- FIXME: change into plugins --> 13 <parameters prefix="" postfix="_d" extension="dll"> 12 <plugins prefix="" postfix="" extension="dll"> 14 13 <plugin lib="ProducerConsumerExample" /> 15 <plugin lib="ShMem" /> 14 </plugins> 15 16 <parameters> 16 17 </parameters> 17 18 </pacpus> -
branches/2.0-beta1/examples/ProducerConsumerExample/ProducerExample.cpp
r163 r165 71 71 void ProducerExample::run() 72 72 { 73 unsigned int counter = 0;74 int waitTime = 5000;73 unsigned int counter = 1; 74 int waitTimeMicros = 150 * 1000; 75 75 76 76 std::fstream file(outputFileName, std::ios_base::out | std::ios_base::app); … … 87 87 while (isActive()) { 88 88 //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 ); 90 92 91 93 if (imageOutput && imageOutput->hasConnection()) { … … 93 95 } 94 96 95 LOG_INFO("Sen d 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; 97 99 98 usleep(waitTime );100 usleep(waitTimeMicros); 99 101 ++counter; 100 102 setState(MONITOR_OK); -
branches/2.0-beta1/include/Pacpus/kernel/PacpusApplication.h
r141 r165 41 41 42 42 virtual bool notify(QObject * receiver, QEvent * ev); 43 44 private: 45 void installSignalHandler(); 43 46 }; 44 47 -
branches/2.0-beta1/include/Pacpus/kernel/XmlConfigFile.h
r146 r165 78 78 79 79 protected: 80 QDomElement getSection(const char * name) const; 81 QDomNodeList getNodesInSection(const char * sectionName, const char * nodeName) const; 82 80 83 QDomNodeList getAllComponents() const; 81 84 QDomNodeList getAllConnections() const; 85 QDomNodeList getAllParameters() const; 82 86 QDomNodeList getAllPlugins(); 83 87 -
branches/2.0-beta1/src/PacpusLib/PacpusApplication.cpp
r162 r165 9 9 /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved. 10 10 11 #include <csignal> 11 12 #include <Pacpus/kernel/Log.h> 12 13 #include <Pacpus/kernel/PacpusApplication.h> 13 14 #include <Pacpus/kernel/PacpusException.h> 15 #include <sstream> 16 #include <string> 14 17 15 18 using namespace pacpus; … … 24 27 : QApplication(argc, argv, _internal) 25 28 { 29 //installSignalHandler(); 26 30 } 27 31 … … 92 96 return false; 93 97 } 98 99 void signalHandler(int signal); 100 101 void 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 117 void 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 14 14 DECLARE_STATIC_LOGGER("pacpus.core.XmlComponentConfig"); 15 15 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"; 16 static const char* kPropertyComponentName = "name"; 17 static const char* kPropertyComponentType = "type"; 18 static const char* kPropertyConnectionType = "type"; 19 static const char* kPropertyConnectionInput = "input"; 20 static const char* kPropertyConnectionOutput = "output"; 21 static const char* kPropertyConnectionPriority = "priority"; 27 22 28 23 XmlComponentConfig::XmlComponentConfig(const QString& name) … … 47 42 { 48 43 LOG_ERROR("cannot add component property:" 49 << " component '" << component_.attribute(kPropertyComponentName .c_str()) << "'"44 << " component '" << component_.attribute(kPropertyComponentName) << "'" 50 45 << " already contains property '" << name << "'" 51 46 << " and its value is '" << component_.attribute(name) << "'" … … 57 52 component_.setAttribute(name, 0); 58 53 LOG_INFO("property '" << name << "'" 59 << " was added to the component " << component_.attribute(kPropertyComponentName .c_str()) << "'"54 << " was added to the component " << component_.attribute(kPropertyComponentName) << "'" 60 55 << " and set to '" << component_.attribute(name) << "'" 61 56 ); … … 66 61 if (!hasProperty(name)) { 67 62 LOG_WARN("cannot delete compoenent property '" << name << "'" 68 << " of component '" << component_.attribute(kPropertyComponentName .c_str()) << "'"63 << " of component '" << component_.attribute(kPropertyComponentName) << "'" 69 64 << ". Component does not contain this property." 70 65 ); … … 75 70 component_.removeAttribute(name); 76 71 LOG_INFO("property '" << name << "' " 77 << " of component '" << component_.attribute(kPropertyComponentName .c_str()) << "'"72 << " of component '" << component_.attribute(kPropertyComponentName) << "'" 78 73 << " was deleted" 79 74 ); … … 87 82 { 88 83 LOG_WARN("cannot retrieve component property '" << name << "'" 89 << " of component '" << component_.attribute(kPropertyComponentName .c_str()) << "'"84 << " of component '" << component_.attribute(kPropertyComponentName) << "'" 90 85 << ". Component does not contain this property." 91 86 ); … … 116 111 component_.setAttribute(name, value); 117 112 LOG_INFO("property " << name 118 << " of the component " << component_.attribute(kPropertyComponentName .c_str())113 << " of the component " << component_.attribute(kPropertyComponentName) 119 114 << " was set to : " << value 120 115 ); … … 138 133 QString const XmlComponentConfig::getComponentName() const 139 134 { 140 //return component_.attribute(kPropertyComponentName.c_str()); 141 return getProperty(kPropertyComponentName.c_str()); 135 return getProperty(kPropertyComponentName); 142 136 } 143 137 144 138 QString const XmlComponentConfig::getComponentType() const 145 139 { 146 return getProperty(kPropertyComponentType .c_str());140 return getProperty(kPropertyComponentType); 147 141 } 148 142 149 143 QString const XmlComponentConfig::getConnectionType() const 150 144 { 151 return getProperty(kPropertyConnectionType .c_str());145 return getProperty(kPropertyConnectionType); 152 146 } 153 147 154 148 QString const XmlComponentConfig::getConnectionInput() const 155 149 { 156 return getProperty(kPropertyConnectionInput .c_str());150 return getProperty(kPropertyConnectionInput); 157 151 } 158 152 159 153 QString const XmlComponentConfig::getConnectionOutput() const 160 154 { 161 return getProperty(kPropertyConnectionOutput .c_str());155 return getProperty(kPropertyConnectionOutput); 162 156 } 163 157 164 158 int const XmlComponentConfig::getConnectionPriority() const 165 159 { 166 return getIntProperty(kPropertyConnectionPriority .c_str(),0);160 return getIntProperty(kPropertyConnectionPriority, /*defaultValue=*/0); 167 161 } -
branches/2.0-beta1/src/PacpusLib/XmlConfigFile.cpp
r147 r165 28 28 static const char * kConnectionSection = "connections"; 29 29 static const char * kParameterSection = "parameters"; 30 static const char * kPluginSection = "plugins"; 30 31 31 32 static const char * kComponentNode = "component"; 32 33 static const char * kConnectionNode = "connection"; 34 static const char * kParameterNode = "parameter"; 33 35 static const char * kPluginNode = "plugin"; 34 36 … … 55 57 // create the sections 56 58 m_document.documentElement().appendChild(m_document.createElement(kParameterSection)); 59 m_document.documentElement().appendChild(m_document.createElement(kPluginSection)); 57 60 m_document.documentElement().appendChild(m_document.createElement(kComponentSection)); 58 61 m_document.documentElement().appendChild(m_document.createElement(kConnectionSection)); … … 93 96 (void) mutexLocker; // unused 94 97 95 // TODO: change .tagName => .attribute(kPropertyComponentName .c_str())98 // TODO: change .tagName => .attribute(kPropertyComponentName) 96 99 QDomNode componentSectionNode = getNamedItemFromDomDocument(m_document, kComponentSection); 97 100 if (componentSectionNode.namedItem(component.attribute(kNameAttribute)/*.tagName()*/).isNull()) { … … 206 209 } 207 210 211 // XML 212 QDomElement 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 222 QDomNodeList XmlConfigFile::getNodesInSection(const char * sectionName, const char * nodeName) const 223 { 224 QDomElement sectionElement = getSection(sectionName); 225 return sectionElement.elementsByTagName(nodeName); 226 } 227 208 228 // COMPONENTS 209 229 QDomNodeList XmlConfigFile::getAllComponents() const 210 230 { 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); 220 232 } 221 233 … … 252 264 QDomNodeList XmlConfigFile::getAllConnections() const 253 265 { 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); 264 267 } 265 268 … … 281 284 } 282 285 286 // PARAMETERS 287 QDomNodeList XmlConfigFile::getAllParameters() const 288 { 289 return getNodesInSection(kParameterSection, kParameterNode); 290 } 291 283 292 // PLUGINS 284 293 QDomNodeList XmlConfigFile::getAllPlugins() 285 294 { 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); 292 297 293 298 // get attributes 294 m_libraryExtension = p arametersElement.attribute(kExtensionAttribute);299 m_libraryExtension = pluginsElement.attribute(kExtensionAttribute); 295 300 if (!m_libraryExtension.isEmpty()) { 296 301 // prefix with a dot '.' if there is no one … … 299 304 } 300 305 } 301 m_libraryPrefix = p arametersElement.attribute(kPrefixAttribute);302 m_libraryPostfix = p arametersElement.attribute(kPostfixAttribute);306 m_libraryPrefix = pluginsElement.attribute(kPrefixAttribute); 307 m_libraryPostfix = pluginsElement.attribute(kPostfixAttribute); 303 308 304 // get pluginnodes305 return parametersElement.elementsByTagName(kPluginNode);309 // get nodes 310 return getNodesInSection(kPluginSection, kPluginNode); 306 311 } 307 312 … … 313 318 return QStringList(); 314 319 } 320 LOG_INFO("there are " << pluginList.size() << " plugins"); 315 321 316 322 // get plugin library paths
Note:
See TracChangeset
for help on using the changeset viewer.