32#include <RobotComponents/interface/components/MotionPlanning/ResourceRequestStrategies/ComputingPowerRequestStrategy.h>
72 const Ice::Current& = Ice::emptyCurrent)
override
110 virtual public CompoundedRequestStrategyBase,
119 CompoundedRequestStrategyBase(requestStrategies)
133 void updateNodeCount(Ice::Long count,
const Ice::Current& = Ice::emptyCurrent)
override;
141 const Ice::Current& = Ice::emptyCurrent)
override;
157 const Ice::Current& = Ice::emptyCurrent)
override;
161 template <
class Base,
class Derived>
180 And(
const ComputingPowerRequestStrategyBaseList& requestStrategies) :
193 template <
class Base,
class Derived>
214 Or(
const ComputingPowerRequestStrategyBaseList& requestStrategies) :
226 return std::any_of(requestStrategies.begin(),
227 requestStrategies.end(),
228 [](ComputingPowerRequestStrategyBasePtr& s)
229 { return s->shouldAllocateComputingPower(); });
234 template <
class Base,
class Derived>
255 Not(
const ComputingPowerRequestStrategyBasePtr& s) : NotBase(s)
265 allocStrat->setCurrentStateAsInitialState();
275 allocStrat->updateNodeCount(count);
284 const Ice::Current& = Ice::emptyCurrent)
override
286 allocStrat->updateTaskStatus(newStatus);
295 allocStrat->allocatedComputingPower();
305 return !allocStrat->shouldAllocateComputingPower();
317 const Ice::Current& = Ice::emptyCurrent)
override
319 allocStrat->updateNodeCreations(nodesCreated, tries);
324 template <
class Base,
class Derived>
384 using Clock = std::chrono::system_clock;
433 template <
class Base,
class Derived>
457 NoNodeCreated(Ice::Long timeDeltaInSec,
bool skip,
float sig, Ice::Long backlogSz) :
458 NoNodeCreatedBase(timeDeltaInSec, skip, sig, backlogSz),
463 timeDeltaInSeconds = timeDeltaInSec;
475 const Ice::Current& = Ice::emptyCurrent)
override;
487 const auto usedTimeDelta = timeDeltaInSeconds / (1.f + sigma * perc);
490 static_cast<std::size_t
>(usedTimeDelta)};
499 backlog.assign(backlogSize, 0);
514 template <
class Base,
class Derived>
529 virtual public TotalNodeCountBase,
581 template <
class Base,
class Derived>
606 TaskStatusBase(strategyPerTaskStatus),
current{nullptr}
614 void updateNodeCount(Ice::Long count,
const Ice::Current& = Ice::emptyCurrent)
override;
621 const Ice::Current& = Ice::emptyCurrent)
override;
636 const Ice::Current& = Ice::emptyCurrent)
override;
646 return current->shouldAllocateComputingPower();
656 template <
class Base,
class Derived>
DateTime now() const
Current date/time of the clock.
Implementation of Always.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Always return true.
And(const ComputingPowerRequestStrategyBaseList &requestStrategies)
Ctor.
And()=default
Ctor used for object factories.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if all compounded strategies return true.
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
CompoundedRequestStrategy()=default
Ctor used for object factories.
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
CompoundedRequestStrategy(const ComputingPowerRequestStrategyBaseList &requestStrategies)
Ctor.
Implementation of ComputingPowerRequestStrategyBase.
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Default implementation.
void updateTaskStatus(armarx::TaskStatus::Status, const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override=0
Returns whether new computing power should be allocated.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
void updateNodeCreations(Ice::Long, Ice::Long, const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
~ComputingPowerRequestStrategy() override=default
Dtor.
void updateNodeCount(Ice::Long, const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
ElapsedTime(Ice::Long timeDeltaInSeconds, bool skipping)
Ctor.
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Sets the next time to allocate delta seconds from now.
std::chrono::system_clock Clock
The used clock type.
ElapsedTime()=default
Ctor used for object factories.
Clock::time_point TimePoint
The type of the used time point.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Sets the next time to allocate depending on the flag skipping.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if the last creation timepoint is more than delta seconds away.
TimePoint allocatedLastTime
The time point when more power should be allocated again.
Implementation of NeverBase.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Always return false.
void ice_postUnmarshal() override
Nulls the backlog after the object was transmitted through ice.
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Updates the number of failed node creations.
NoNodeCreated()=default
Ctor used for object factories.
NoNodeCreated(Ice::Long timeDeltaInSec, bool skip, float sig, Ice::Long backlogSz)
ctor
std::size_t currentBacklogIndex
The current index in the backlog.
std::vector< char > backlog
The backlog.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
shouldAllocateComputingPower
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
Not(const ComputingPowerRequestStrategyBasePtr &s)
Ctor.
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
Not()=default
Ctor used for object factories.
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns the negatedresult of the contained strategy.
Or(const ComputingPowerRequestStrategyBaseList &requestStrategies)
Ctor.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if any compounded strategies returns true.
Or()=default
Ctor used for object factories.
TaskStatus(TaskStatusMap strategyPerTaskStatus)
Ctor.
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
TaskStatus()
Ctor used for object factories.
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Switches the current strategy and passes this call to all sub strategies.
ComputingPowerRequestStrategyBase * current
The current strategy in use.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns the result of the current selected strategy.
Ice::Long nodeCount
The current node count.
Ice::Long allocateNextTime
The count when to allocate more power.
void updateNodeCount(Ice::Long newCount, const Ice::Current &=Ice::emptyCurrent) override
Updates the internal node count.
TotalNodeCount(Ice::Long nodeCountDelta, bool skipping)
Ctor.
TotalNodeCount()
Ctor used for object factories.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Sets the next creation count to allocate depending on the flag skipping.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if the the current count is >= the next creation count.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
IceInternal::Handle< ElapsedTime > ElapsedTimePtr
IceInternal::Handle< TotalNodeCount > TotalNodeCountPtr
IceInternal::Handle< Or > OrPtr
IceInternal::Handle< ComputingPowerRequestStrategy > ComputingPowerRequestStrategyPtr
IceInternal::Handle< And > AndPtr
IceInternal::Handle< Always > AlwaysPtr
IceInternal::Handle< Never > NeverPtr
IceInternal::Handle< TaskStatus > TaskStatusPtr
IceInternal::Handle< NoNodeCreated > NoNodeCreatedPtr
IceInternal::Handle< Not > NotPtr