Component::Component( ::Loop::ProcessModel& element, const ::Execution::Context& ctx, const Id<score::Component>& id, QObject* parent) : ::Execution::ProcessComponent_T<Loop::ProcessModel, ossia::loop>{ element, ctx, id, "LoopComponent", parent} { ossia::time_value main_duration( ctx.time(element.interval().duration.defaultDuration())); std::shared_ptr<ossia::loop> loop = std::make_shared<ossia::loop>( main_duration, ossia::time_interval::exec_callback{}, [this, &element](ossia::time_event::status newStatus) { element.startEvent().setStatus( static_cast<Scenario::ExecutionStatus>(newStatus), process()); switch (newStatus) { case ossia::time_event::status::NONE: break; case ossia::time_event::status::PENDING: break; case ossia::time_event::status::HAPPENED: startIntervalExecution(m_ossia_interval->scoreInterval().id()); break; case ossia::time_event::status::DISPOSED: break; default: SCORE_TODO; break; } }, [this, &element](ossia::time_event::status newStatus) { element.endEvent().setStatus( static_cast<Scenario::ExecutionStatus>(newStatus), process()); switch (newStatus) { case ossia::time_event::status::NONE: break; case ossia::time_event::status::PENDING: break; case ossia::time_event::status::HAPPENED: stopIntervalExecution(m_ossia_interval->scoreInterval().id()); break; case ossia::time_event::status::DISPOSED: break; default: SCORE_TODO; break; } }); m_ossia_process = loop; node = loop->node; // TODO also states in BasEelement // TODO put graphical settings somewhere. auto& main_start_node = loop->get_start_timesync(); auto& main_end_node = loop->get_end_timesync(); auto main_start_event = *main_start_node.get_time_events().begin(); auto main_end_event = *main_end_node.get_time_events().begin(); using namespace Execution; m_ossia_startTimeSync = std::make_shared<TimeSyncRawPtrComponent>( element.startTimeSync(), system(), score::newId(element.startTimeSync()), this); m_ossia_endTimeSync = std::make_shared<TimeSyncRawPtrComponent>( element.endTimeSync(), system(), score::newId(element.endTimeSync()), this); m_ossia_startEvent = std::make_shared<EventComponent>( element.startEvent(), system(), score::newId(element.startEvent()), this); m_ossia_endEvent = std::make_shared<EventComponent>( element.endEvent(), system(), score::newId(element.endEvent()), this); m_ossia_startState = std::make_shared<StateComponent>( element.startState(), system(), score::newId(element.startState()), this); m_ossia_endState = std::make_shared<StateComponent>( element.endState(), system(), score::newId(element.endState()), this); m_ossia_interval = std::make_shared<IntervalRawPtrComponent>( element.interval(), system(), score::newId(element.interval()), this); m_ossia_startTimeSync->onSetup( &main_start_node, m_ossia_startTimeSync->makeTrigger()); m_ossia_endTimeSync->onSetup( &main_end_node, m_ossia_endTimeSync->makeTrigger()); m_ossia_startEvent->onSetup( main_start_event, m_ossia_startEvent->makeExpression(), (ossia::time_event::offset_behavior)element.startEvent() .offsetBehavior()); m_ossia_endEvent->onSetup( main_end_event, m_ossia_endEvent->makeExpression(), (ossia::time_event::offset_behavior)element.endEvent().offsetBehavior()); m_ossia_startState->onSetup(main_start_event); m_ossia_endState->onSetup(main_end_event); m_ossia_interval->onSetup( m_ossia_interval, &loop->get_time_interval(), m_ossia_interval->makeDurations()); auto cable = ossia::make_edge( ossia::immediate_glutton_connection{}, m_ossia_interval->OSSIAInterval()->node->outputs()[0], loop->node->inputs()[0], m_ossia_interval->OSSIAInterval()->node, loop->node); in_exec([g = system().execGraph, cable] { g->connect(cable); }); }
RecreateOnPlay::Loop::Component::Component( RecreateOnPlay::ConstraintElement& parentConstraint, ::Loop::ProcessModel& element, const Context& ctx, const Id<iscore::Component>& id, QObject* parent): ProcessComponent{parentConstraint, element, id, "LoopComponent", parent}, m_ctx{ctx} { OSSIA::TimeValue main_duration(iscore::convert::time(element.constraint().duration.defaultDuration())); auto loop = OSSIA::Loop::create(main_duration, [] (const OSSIA::TimeValue& t0, const OSSIA::TimeValue&, std::shared_ptr<OSSIA::StateElement>) { }, [this,&element] (OSSIA::TimeEvent::Status newStatus) { element.startEvent().setStatus(static_cast<Scenario::ExecutionStatus>(newStatus)); switch(newStatus) { case OSSIA::TimeEvent::Status::NONE: break; case OSSIA::TimeEvent::Status::PENDING: break; case OSSIA::TimeEvent::Status::HAPPENED: startConstraintExecution(m_ossia_constraint->iscoreConstraint().id()); break; case OSSIA::TimeEvent::Status::DISPOSED: break; default: ISCORE_TODO; break; } }, [this,&element] (OSSIA::TimeEvent::Status newStatus) { element.endEvent().setStatus(static_cast<Scenario::ExecutionStatus>(newStatus)); switch(newStatus) { case OSSIA::TimeEvent::Status::NONE: break; case OSSIA::TimeEvent::Status::PENDING: break; case OSSIA::TimeEvent::Status::HAPPENED: stopConstraintExecution(m_ossia_constraint->iscoreConstraint().id()); break; case OSSIA::TimeEvent::Status::DISPOSED: break; default: ISCORE_TODO; break; } } ); m_ossia_process = loop; // TODO also states in BasEelement // TODO put graphical settings somewhere. auto startTN = loop->getPatternStartTimeNode(); auto endTN = loop->getPatternEndTimeNode(); auto startEV = *startTN->timeEvents().begin(); auto endEV = *endTN->timeEvents().begin(); auto startST = OSSIA::State::create(); auto endST = OSSIA::State::create(); startEV->addState(startST); endEV->addState(endST); m_ossia_startTimeNode = new TimeNodeElement{startTN, element.startTimeNode(), m_ctx.devices.list(), this}; m_ossia_endTimeNode = new TimeNodeElement{endTN, element.endTimeNode(), m_ctx.devices.list(), this}; m_ossia_startEvent = new EventElement{startEV, element.startEvent(), m_ctx.devices.list(), this}; m_ossia_endEvent = new EventElement{endEV, element.endEvent(), m_ctx.devices.list(), this}; m_ossia_startState = new StateElement{ element.startState(), startST, m_ctx, this}; m_ossia_endState = new StateElement{ element.endState(), endST, m_ctx, this}; m_ossia_constraint = new ConstraintElement{loop->getPatternTimeConstraint(), element.constraint(), m_ctx, this}; }