Go to the documentation of this file.
32 #include <RobotComponents/interface/components/MotionPlanning/ResourceRequestStrategies/ComputingPowerRequestStrategy.h>
41 virtual public ComputingPowerRequestStrategyBase
68 void updateTaskStatus(armarx::TaskStatus::Status,
const Ice::Current& = Ice::emptyCurrent)
override
103 virtual public CompoundedRequestStrategyBase,
111 CompoundedRequestStrategy(
const ComputingPowerRequestStrategyBaseList& requestStrategies): CompoundedRequestStrategyBase(requestStrategies) {}
130 void updateTaskStatus(armarx::TaskStatus::Status newStatus,
const Ice::Current& = Ice::emptyCurrent)
override;
160 virtual public AndBase,
168 And(
const ComputingPowerRequestStrategyBaseList& requestStrategies):
169 AndBase(requestStrategies),
192 virtual public OrBase,
200 Or(
const ComputingPowerRequestStrategyBaseList& requestStrategies):
201 OrBase(requestStrategies),
210 return std::any_of(requestStrategies.begin(), requestStrategies.end(),
211 [](ComputingPowerRequestStrategyBasePtr &
s)
213 return s->shouldAllocateComputingPower();
232 virtual public NotBase,
240 Not(
const ComputingPowerRequestStrategyBasePtr&
s): NotBase(
s) {}
247 allocStrat->setCurrentStateAsInitialState();
256 allocStrat->updateNodeCount(count);
263 void updateTaskStatus(armarx::TaskStatus::Status newStatus,
const Ice::Current& = Ice::emptyCurrent)
override
265 allocStrat->updateTaskStatus(newStatus);
273 allocStrat->allocatedComputingPower();
282 return !allocStrat->shouldAllocateComputingPower();
293 allocStrat->updateNodeCreations(nodesCreated, tries);
310 virtual public AlwaysBase,
330 virtual public NeverBase,
350 virtual public ElapsedTimeBase,
357 using Clock = std::chrono::system_clock;
369 ElapsedTimeBase(timeDeltaInSeconds, skipping),
418 virtual public NoNodeCreatedBase,
430 NoNodeCreatedBase(timeDeltaInSec, skip, sig, backlogSz),
435 timeDeltaInSeconds = timeDeltaInSec;
456 const auto usedTimeDelta = timeDeltaInSeconds / (1.f + sigma * perc);
466 backlog.assign(backlogSize, 0);
494 virtual public TotalNodeCountBase,
504 TotalNodeCountBase(nodeCountDelta, skipping),
559 virtual public TaskStatusBase,
568 TaskStatusBase(strategyPerTaskStatus),
583 void updateTaskStatus(armarx::TaskStatus::Status newStatus,
const Ice::Current& = Ice::emptyCurrent)
override;
605 return current->shouldAllocateComputingPower();
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.