| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////
- /////////////////
- //
- // Global Include Files
- //
- //
- //
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////
- /////////////////
- //
- // Include Files from local modules
- //
- //
- #include "cViewSwitch.h"
- #include "views/cViewHdl.h"
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////
- /////////////////
- //
- // Class instanciation, external declarations and defines
- //
- //
- void cSwitchView::addView(cViewHdl* vw) {
- m_view.push_back(vw);
- };
-
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- *
- */
- void cSwitchView::setView(const char * name) {
- for(std::vector<cViewHdl*>::size_type i = 0; i < m_view.size(); i++)
- {
- if (0 == strcmp(m_view[i]->getViewName(), name)) {
- // LOGMSG(INFO, m_view[i]->getViewName() ," at index position: ", i);
- m_viewNbr = (uint8_t) i; // Set View
- return;
- }
- }
- LOGMSG(INFO, "[ERROR] setView name not found ");
- };
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- *
- */
- cViewHdl * cSwitchView::getView() {
- if (m_view.empty()) {
- LOGMSG(INFO,"[ERROR] getView vector is empty ", __FILE__, ":", __LINE__);
- return nullptr;
- }
- return m_view[m_viewNbr];
- };
- cViewHdl * cSwitchView::getView(uint8_t nb) {
- return m_view[nb];
- };
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- *
- */
- cViewHdl * cSwitchView::getView(const char * name) {
- for (auto& _vw : m_view) {
- if (0 == strcmp(_vw->getViewName(), name)) {
- return _vw;
- }
- }
- LOGMSG(INFO, "[ERROR]: View not found");
- return nullptr;
- }
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- *
- */
- void cSwitchView::run() {
- if (activeScreen != getView()) { // counterpart to setView (Name)
- activeScreen = getView();
- LOGMSG(INFO, "[INFO]: Active Screen: ", activeScreen->getViewName());
- activeScreen->init(); // initialize new view
- activeScreen->updateView(); // update view
- activeScreen->showConfiguration(); // show configuration of the view
- delay(600);
- }
- activeScreen->run(); // excute new view (Event Handler)
- }
- cSwitchView* cSwitchView::_Instance = nullptr;
|