Go to the documentation of this file.
32 #include <RobotComponents/interface/components/MotionPlanning/ResourceRequestStrategies/ComputingPowerRequestStrategy.h>
72 const Ice::Current& = Ice::emptyCurrent)
override
110 virtual public CompoundedRequestStrategyBase,
119 CompoundedRequestStrategyBase(requestStrategies)
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>
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}
621 const Ice::Current& = Ice::emptyCurrent)
override;
636 const Ice::Current& = Ice::emptyCurrent)
override;
646 return current->shouldAllocateComputingPower();
656 template <
class Base,
class Derived>
NoNodeCreated(Ice::Long timeDeltaInSec, bool skip, float sig, Ice::Long backlogSz)
ctor
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Always return true.
ElapsedTime()=default
Ctor used for object factories.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if the last creation timepoint is more than delta seconds away.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns the negatedresult of the contained strategy.
void updateNodeCreations(Ice::Long, Ice::Long, const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
Implementation of NeverBase.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if the the current count is >= the next creation count.
CompoundedRequestStrategy(const ComputingPowerRequestStrategyBaseList &requestStrategies)
Ctor.
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
void updateNodeCount(Ice::Long newCount, const Ice::Current &=Ice::emptyCurrent) override
Updates the internal node count.
Ice::Long allocateNextTime
The count when to allocate more power.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if all compounded strategies return true.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
shouldAllocateComputingPower
NoNodeCreated()=default
Ctor used for object factories.
void updateNodeCount(Ice::Long, const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
std::size_t currentBacklogIndex
The current index in the backlog.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
Implementation of TotalNodeCountBase.
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Default implementation.
Implementation of NoNodeCreatedBase.
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override=0
Returns whether new computing power should be allocated.
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.
std::vector< char > backlog
The backlog.
And()=default
Ctor used for object factories.
Ice::Long nodeCount
The current node count.
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
TaskStatus()
Ctor used for object factories.
Or(const ComputingPowerRequestStrategyBaseList &requestStrategies)
Ctor.
ComputingPowerRequestStrategyBase * current
The current strategy in use.
Clock::time_point TimePoint
The type of the used time point.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Implementation of NotBase.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
Implementation of OrBase.
TimePoint allocatedLastTime
The time point when more power should be allocated again.
void ice_postUnmarshal() override
Nulls the backlog after the object was transmitted through ice.
Implementation of ElapsedTimeBase.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Sets the next time to allocate depending on the flag skipping.
TotalNodeCount(Ice::Long nodeCountDelta, bool skipping)
Ctor.
TotalNodeCount()
Ctor used for object factories.
Implementation of TaskStatusBase.
Not(const ComputingPowerRequestStrategyBasePtr &s)
Ctor.
Implementation of Always.
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
~ComputingPowerRequestStrategy() override=default
Dtor.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns the result of the current selected strategy.
TaskStatus(TaskStatusMap strategyPerTaskStatus)
Ctor.
void updateTaskStatus(armarx::TaskStatus::Status, const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
And(const ComputingPowerRequestStrategyBaseList &requestStrategies)
Ctor.
Implementation of AndBase.
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
Or()=default
Ctor used for object factories.
Implementation of ComputingPowerRequestStrategyBase.
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Switches the current strategy and passes this call to all sub strategies.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if any compounded strategies returns true.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Sets the next time to allocate delta seconds from now.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Always return false.
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
ElapsedTime(Ice::Long timeDeltaInSeconds, bool skipping)
Ctor.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Sets the next creation count to allocate depending on the flag skipping.
double s(double t, double s0, double v0, double a0, double j)
std::chrono::system_clock Clock
The used clock type.
CompoundedRequestStrategy()=default
Ctor used for object factories.
Not()=default
Ctor used for object factories.
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Updates the number of failed node creations.
DateTime now() const
Current date/time of the clock.
Implementation of CompoundedRequestStrategyBase.