diff --git a/src/prog/domod/src/sequences/clock.cpp b/src/prog/domod/src/sequences/clock.cpp index efb684fa..4fa52ffe 100644 --- a/src/prog/domod/src/sequences/clock.cpp +++ b/src/prog/domod/src/sequences/clock.cpp @@ -63,9 +63,10 @@ bool Clock::is_equal_to_timer(const Timer &a_timer) the_compared_time = *localtime(&the_time); the_wday = the_compared_time.tm_wday; +#if 0 printf ("=>Timer: (%.2d h %.2d) Now: (%.2d h %.2d) week day:%d\n", a_timer.get_hour(),a_timer.get_minute(), the_compared_time.tm_hour, the_compared_time.tm_min, the_compared_time.tm_wday); - +#endif the_compared_time.tm_hour = a_timer.get_hour(); the_compared_time.tm_min = a_timer.get_minute(); @@ -93,7 +94,7 @@ bool Clock::is_expired(const Sequence &a_sequence) time_t the_time = time(NULL); the_compared_time = *localtime(&the_time); - printf ("=>Now: (%.2d h %.2d)\n", the_compared_time.tm_hour, the_compared_time.tm_min); + // printf ("=>Now: (%.2d h %.2d)\n", the_compared_time.tm_hour, the_compared_time.tm_min); the_compared_time.tm_hour = a_sequence.get_timer().get_hour(); @@ -103,7 +104,7 @@ bool Clock::is_expired(const Sequence &a_sequence) the_diff = difftime(the_time, the_expired); - printf ("%.f seconds of diff between current time and Timer time.\n", the_diff); + // printf ("%.f seconds of diff between current time and Timer time.\n", the_diff); if (the_diff == 0) return true; diff --git a/src/prog/domod/src/sequences/sequence.cpp b/src/prog/domod/src/sequences/sequence.cpp index f556fe39..5dfa2808 100644 --- a/src/prog/domod/src/sequences/sequence.cpp +++ b/src/prog/domod/src/sequences/sequence.cpp @@ -27,6 +27,8 @@ #include +#include "devices/devices-manager.h" + #include "domo.h" #include "sequence.h" @@ -213,6 +215,8 @@ void Sequence::start(DevicesManager *a_device_manager) m_is_in_progress = true; m_current_action = 0; m_current_duration = 0; + + a_device_manager->set_state(m_actions[m_current_action].get_capability(), m_actions[m_current_action].get_device_id(), true); } /*! ---------------------------------------------------------------------------- @@ -232,5 +236,16 @@ void Sequence::stop(void) */ bool Sequence::switch_to_next_action(DevicesManager *a_device_manager) { + printf("switch_to_next_action current: %d, size: %ld\n", m_current_action, m_actions.size()); + if ((m_current_action + 1) >= m_actions.size()) + { + printf("sequence is done.\n"); + return false; + } + + m_current_duration += m_actions[m_current_action].get_duration(); + // TODO STOP DEVICE MANAGER + m_current_action++; + // TODO START DEVICE MANAGER return true; } diff --git a/src/prog/domod/src/sequences/sequences-manager.cpp b/src/prog/domod/src/sequences/sequences-manager.cpp index e4427b5f..e55b4180 100644 --- a/src/prog/domod/src/sequences/sequences-manager.cpp +++ b/src/prog/domod/src/sequences/sequences-manager.cpp @@ -197,13 +197,13 @@ int SequencesManager::expire(void) { std::vector::iterator the_seq_it; Clock the_clock; - fprintf(stderr, "**** >> Manage timers....\n"); + // fprintf(stderr, "**** >> Manage timers....\n"); for (the_seq_it = m_sequences.begin(); the_seq_it != m_sequences.end(); the_seq_it++) { if ((*the_seq_it).is_active()) { - printf("sequence %d active.\n", (*the_seq_it).get_id()); + // printf("sequence %d active.\n", (*the_seq_it).get_id()); if (!(*the_seq_it).is_in_progress()) { // should the sequence start ? @@ -220,11 +220,10 @@ int SequencesManager::expire(void) if (the_clock.is_expired((*the_seq_it))) { if (!(*the_seq_it).switch_to_next_action(m_devices_manager)) { - fprintf(stdout, "Sequence Stopt\n"); + fprintf(stdout, "Sequence Stop\n"); (*the_seq_it).stop(); } } - } } }