Changeset 152 in pacpusframework for branches/2.0-beta1/src/PacpusLib
- Timestamp:
- Aug 1, 2013, 10:45:50 AM (11 years ago)
- Location:
- branches/2.0-beta1/src/PacpusLib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0-beta1/src/PacpusLib/ComponentBase.cpp
r120 r152 13 13 DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase"); 14 14 15 ComponentBase::ComponentBase(const QString& name) 16 : componentName(name) 17 , recording(true) 18 , THREAD_ALIVE(true) 19 , mIsActive(false) 20 , mgr(NULL) 21 , componentState_(NOT_MONITORED) 22 , ui(NULL) 15 ComponentBase::ComponentBase(const QString& componentName) 16 : m_componentName(componentName) 17 , m_isActive(false) 18 , m_isRecording(true) 19 , m_manager(NULL) 20 , m_ui(NULL) 21 , m_componentState(NOT_MONITORED) 23 22 { 24 23 LOG_TRACE("constructor"); 25 24 // Get a pointer on the instance of ComponentManager. 26 m gr = ComponentManager::getInstance();27 LOG_INFO("component " << componentName<< " was created");25 m_manager = ComponentManager::getInstance(); 26 LOG_INFO("component " << name() << " was created"); 28 27 } 29 28 … … 33 32 } 34 33 34 bool ComponentBase::isActive() const 35 { 36 return m_isActive; 37 } 38 39 void ComponentBase::setActive(bool isActive) 40 { 41 m_isActive = isActive; 42 } 43 44 bool ComponentBase::isRecording() const 45 { 46 return m_isRecording; 47 } 48 49 void ComponentBase::setRecording(bool isRecording) 50 { 51 m_isRecording = isRecording; 52 } 53 54 const XmlComponentConfig ComponentBase::xmlParameters() const 55 { 56 return param; 57 } 58 35 59 int ComponentBase::startComponent() 36 60 { 37 if (mIsActive) 38 return false; 39 40 mIsActive = true; 61 if (isActive()) { 62 LOG_DEBUG("component already started, cannot (re-)start"); 63 return false; 64 } 65 66 setActive(true); 41 67 startActivity(); 42 68 … … 46 72 int ComponentBase::stopComponent() 47 73 { 48 if (!mIsActive) 49 return false; 50 51 mIsActive = false; 74 if (!isActive()) { 75 LOG_DEBUG("component already stopped, cannot (re-)stop"); 76 return false; 77 } 78 79 setActive(false); 52 80 stopActivity(); 53 81 … … 57 85 void ComponentBase::setState(const COMPONENT_STATE state) 58 86 { 59 componentState_= state;87 m_componentState = state; 60 88 } 61 89 … … 63 91 ComponentBase::COMPONENT_STATE ComponentBase::getState() 64 92 { 65 COMPONENT_STATE state = componentState_;66 if (ComponentBase::NOT_MONITORED != componentState_) {67 componentState_= ComponentBase::MONITOR_NOK;93 COMPONENT_STATE state = m_componentState; 94 if (ComponentBase::NOT_MONITORED != m_componentState) { 95 m_componentState = ComponentBase::MONITOR_NOK; 68 96 } 69 97 return state; 70 98 } 71 99 100 ComponentBase::COMPONENT_CONFIGURATION ComponentBase::configurationState() const 101 { 102 return m_configurationState; 103 } 104 105 void ComponentBase::setConfigurationState(COMPONENT_CONFIGURATION state) 106 { 107 m_configurationState = state; 108 } 109 72 110 bool ComponentBase::isConfigured() const 73 111 { 74 return configuration_ == CONFIGURED_OK; 112 return (m_configurationState == CONFIGURED_OK); 113 } 114 115 QString ComponentBase::name() const 116 { 117 return m_componentName; 75 118 } 76 119 77 120 QString ComponentBase::getName() const 78 121 { 79 return componentName; 122 return m_componentName; 123 } 124 125 ComponentBase::InputsMap & ComponentBase::inputs() 126 { 127 return m_inputs; 128 } 129 130 const ComponentBase::InputsMap & ComponentBase::inputs() const 131 { 132 return m_inputs; 133 } 134 135 ComponentBase::OutputsMap & ComponentBase::outputs() 136 { 137 return m_outputs; 138 } 139 140 const ComponentBase::OutputsMap & ComponentBase::outputs() const 141 { 142 return m_outputs; 80 143 } 81 144 82 145 InputInterfaceBase * ComponentBase::getInput(QString inputName) const 83 146 { 84 85 if(input.contains(inputName)) 86 return input[inputName]; 87 else { 88 LOG_WARN("Component " << componentName << " does not containt input " << inputName); 89 return NULL; 147 if (inputs().contains(inputName)) { 148 return inputs()[inputName]; 90 149 } 150 LOG_WARN("Component " << name() << " does not contain input " << inputName); 151 return NULL; 91 152 } 92 153 … … 97 158 LOG_INFO("Key : " << keys[i])*/; 98 159 99 if(output.contains(outputName)) 100 return output[outputName]; 101 else { 102 LOG_WARN("Component " << componentName << " does not containt output " << outputName); 103 return NULL; 160 if (outputs().contains(outputName)) { 161 return outputs()[outputName]; 104 162 } 163 LOG_WARN("Component " << name() << " does not containt output " << outputName); 164 return NULL; 105 165 } 106 107 void ComponentBase::addInput()108 {109 110 }111 112 void ComponentBase::addOutput()113 {114 115 } -
branches/2.0-beta1/src/PacpusLib/ComponentManager.cpp
r146 r152 254 254 } else { 255 255 component->param.localCopy(cfg.qDomElement()); 256 component-> configuration_ = component->configureComponent(cfg);256 component->setConfigurationState(component->configureComponent(cfg)); 257 257 } 258 258 } // for … … 267 267 LOG_WARN("component '" << componentName << "' does not exist"); 268 268 } else { 269 // Pacpus 2.0 : add input and output270 component->addInput ();271 component->addOutput ();272 273 if ( component->configuration_ == ComponentBase::CONFIGURATION_DELAYED) {269 // Pacpus 2.0 : add inputs and outputs 270 component->addInputs(); 271 component->addOutputs(); 272 273 if (ComponentBase::CONFIGURATION_DELAYED == component->configurationState()) { 274 274 LOG_DEBUG("try to configure component '" << componentName << "'"); 275 275 276 276 // copy locally the config parameters of the component 277 277 component->param.localCopy(cfg.qDomElement()); 278 component-> configuration_ = component->configureComponent(cfg);278 component->setConfigurationState(component->configureComponent(cfg)); 279 279 } 280 280 281 if ( component->configuration_ == ComponentBase::CONFIGURED_OK) {281 if (ComponentBase::CONFIGURED_OK == component->configurationState()) { 282 282 --componentsToConfigureCount; 283 283 } else { … … 286 286 << ". It was not configured, please review your configuration and/or your component" 287 287 ); 288 component-> configuration_ = ComponentBase::CONFIGURED_FAILED;288 component->setConfigurationState(ComponentBase::CONFIGURED_FAILED); 289 289 } 290 290 }
Note:
See TracChangeset
for help on using the changeset viewer.