ComputingPowerRequestStrategy.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package RobotComponents
19  * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
20  * @date 2015
21  * @copyright http://www.gnu.org/licenses/gpl.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
26 #include <chrono>
27 #include <numeric>
28 
31 
32 #include <RobotComponents/interface/components/MotionPlanning/ResourceRequestStrategies/ComputingPowerRequestStrategy.h>
33 
34 namespace armarx::cprs
35 {
36  /**
37  * @brief Implementation of ComputingPowerRequestStrategyBase
38  * @see ComputingPowerRequestStrategyBase
39  */
40  class ComputingPowerRequestStrategy : virtual public ComputingPowerRequestStrategyBase
41  {
42  public:
43  /**
44  * @brief Dtor
45  */
46  ~ComputingPowerRequestStrategy() override = default;
47 
48  /**
49  * @brief Default implementation. Does nothing.
50  * @see ComputingPowerRequestStrategyBase::setCurrentStateAsInitialState
51  */
52  void
53  setCurrentStateAsInitialState(const ::Ice::Current& = Ice::emptyCurrent) override
54  {
55  }
56 
57  /**
58  * @brief Default implementation. Does nothing.
59  * @see ComputingPowerRequestStrategyBase::updateNodeCount
60  */
61  void
62  updateNodeCount(Ice::Long, const Ice::Current& = Ice::emptyCurrent) override
63  {
64  }
65 
66  /**
67  * @brief Default implementation. Does nothing.
68  * @see ComputingPowerRequestStrategyBase::updateTaskStatus
69  */
70  void
71  updateTaskStatus(armarx::TaskStatus::Status,
72  const Ice::Current& = Ice::emptyCurrent) override
73  {
74  }
75 
76  /**
77  * @brief Default implementation. Does nothing.
78  * @see ComputingPowerRequestStrategyBase::allocatedComputingPower
79  */
80  void
81  allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override
82  {
83  }
84 
85  /**
86  * @brief Default implementation. Does nothing.
87  * @see ComputingPowerRequestStrategyBase::updateNodeCreations
88  */
89  void
90  updateNodeCreations(Ice::Long, Ice::Long, const Ice::Current& = Ice::emptyCurrent) override
91  {
92  }
93 
94  /**
95  * @brief Returns whether new computing power should be allocated.
96  * Pure virtual.
97  * @see ComputingPowerRequestStrategyBase::shouldAllocateComputingPower
98  * @return Whether new computing power should be allocated.
99  */
100  bool shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override = 0;
101  };
102 
104 
105  /**
106  * @brief Implementation of CompoundedRequestStrategyBase
107  * @see CompoundedRequestStrategyBase
108  */
110  virtual public CompoundedRequestStrategyBase,
111  virtual public ComputingPowerRequestStrategy
112  {
113  public:
114  /**
115  * @brief Ctor
116  * @param requestStrategies The strategies forming this compound.
117  */
118  CompoundedRequestStrategy(const ComputingPowerRequestStrategyBaseList& requestStrategies) :
119  CompoundedRequestStrategyBase(requestStrategies)
120  {
121  }
122 
123  /**
124  * @brief Calls this function for all compounded strategies.
125  * @see ComputingPowerRequestStrategyBase::setCurrentStateAsInitialState
126  */
127  void setCurrentStateAsInitialState(const ::Ice::Current& = Ice::emptyCurrent) override;
128  /**
129  * @brief Calls this function for all compounded strategies.
130  * @see ComputingPowerRequestStrategyBase::updateNodeCount
131  * @param count The new node count
132  */
133  void updateNodeCount(Ice::Long count, const Ice::Current& = Ice::emptyCurrent) override;
134 
135  /**
136  * @brief Calls this function for all compounded strategies.
137  * @see ComputingPowerRequestStrategyBase::updateTaskStatus
138  * @param newStatus The new status
139  */
140  void updateTaskStatus(armarx::TaskStatus::Status newStatus,
141  const Ice::Current& = Ice::emptyCurrent) override;
142 
143  /**
144  * @brief Calls this function for all compounded strategies.
145  * @see ComputingPowerRequestStrategyBase::allocatedComputingPower
146  */
147  void allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override;
148 
149  /**
150  * @brief Passes this call to all sub strategies.
151  * @see ComputingPowerRequestStrategyBase::updateNodeCreations
152  * @param nodesCreated Number of created nodes.
153  * @param tries Number of tries to create nodes.
154  */
155  void updateNodeCreations(Ice::Long nodesCreated,
156  Ice::Long tries,
157  const Ice::Current& = Ice::emptyCurrent) override;
158 
159  protected:
160  //for object factory
161  template <class Base, class Derived>
163  /**
164  * @brief Ctor used for object factories.
165  */
166  CompoundedRequestStrategy() = default;
167  };
168 
169  /**
170  * @brief Implementation of AndBase
171  * @see AndBase
172  */
173  class And : virtual public AndBase, virtual public CompoundedRequestStrategy
174  {
175  public:
176  /**
177  * @brief Ctor
178  * @param requestStrategies The strategies forming this compound.
179  */
180  And(const ComputingPowerRequestStrategyBaseList& requestStrategies) :
181  AndBase(requestStrategies), CompoundedRequestStrategy(requestStrategies)
182  {
183  }
184 
185  /**
186  * @brief Returns true if all compounded strategies return true.
187  * @return True if all compounded strategies return true.
188  */
189  bool shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override;
190 
191  protected:
192  //for object factory
193  template <class Base, class Derived>
195  /**
196  * @brief Ctor used for object factories.
197  */
198  And() = default;
199  };
200 
202 
203  /**
204  * @brief Implementation of OrBase
205  * @see OrBase
206  */
207  class Or : virtual public OrBase, virtual public CompoundedRequestStrategy
208  {
209  public:
210  /**
211  * @brief Ctor
212  * @param requestStrategies The strategies forming this compound.
213  */
214  Or(const ComputingPowerRequestStrategyBaseList& requestStrategies) :
215  OrBase(requestStrategies), CompoundedRequestStrategy(requestStrategies)
216  {
217  }
218 
219  /**
220  * @brief Returns true if any compounded strategies returns true.
221  * @return True if all compounded strategies return true.
222  */
223  bool
224  shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
225  {
226  return std::any_of(requestStrategies.begin(),
227  requestStrategies.end(),
228  [](ComputingPowerRequestStrategyBasePtr& s)
229  { return s->shouldAllocateComputingPower(); });
230  }
231 
232  protected:
233  //for object factory
234  template <class Base, class Derived>
236  /**
237  * @brief Ctor used for object factories.
238  */
239  Or() = default;
240  };
241 
243 
244  /**
245  * @brief Implementation of NotBase
246  * @see NotBase
247  */
248  class Not : virtual public NotBase, virtual public ComputingPowerRequestStrategy
249  {
250  public:
251  /**
252  * @brief Ctor
253  * @param s The negated strategy.
254  */
255  Not(const ComputingPowerRequestStrategyBasePtr& s) : NotBase(s)
256  {
257  }
258 
259  /**
260  * @brief Passes the call to the contained strategy.
261  */
262  void
263  setCurrentStateAsInitialState(const ::Ice::Current& = Ice::emptyCurrent) override
264  {
265  allocStrat->setCurrentStateAsInitialState();
266  }
267 
268  /**
269  * @brief Passes the call to the contained strategy.
270  * @param count The new node count.
271  */
272  void
273  updateNodeCount(Ice::Long count, const Ice::Current& = Ice::emptyCurrent) override
274  {
275  allocStrat->updateNodeCount(count);
276  }
277 
278  /**
279  * @brief Passes the call to the contained strategy.
280  * @param newStatus The new task status.
281  */
282  void
283  updateTaskStatus(armarx::TaskStatus::Status newStatus,
284  const Ice::Current& = Ice::emptyCurrent) override
285  {
286  allocStrat->updateTaskStatus(newStatus);
287  }
288 
289  /**
290  * @brief Passes the call to the contained strategy.
291  */
292  void
293  allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override
294  {
295  allocStrat->allocatedComputingPower();
296  }
297 
298  /**
299  * @brief Returns the negatedresult of the contained strategy.
300  * @return The negatedresult of the contained strategy.
301  */
302  bool
303  shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
304  {
305  return !allocStrat->shouldAllocateComputingPower();
306  }
307 
308  /**
309  * @brief Passes this call to all sub strategies.
310  * @see ComputingPowerRequestStrategyBase::updateNodeCreations
311  * @param nodesCreated Number of created nodes.
312  * @param tries Number of tries to create nodes.
313  */
314  void
316  Ice::Long tries,
317  const Ice::Current& = Ice::emptyCurrent) override
318  {
319  allocStrat->updateNodeCreations(nodesCreated, tries);
320  }
321 
322  protected:
323  //for object factory
324  template <class Base, class Derived>
326  /**
327  * @brief Ctor used for object factories.
328  */
329  Not() = default;
330  };
331 
333 
334  /**
335  * @brief Implementation of Always
336  * @see Always
337  */
338  class Always : virtual public AlwaysBase, virtual public ComputingPowerRequestStrategy
339  {
340  public:
341  /**
342  * @brief Always return true.
343  * @return true
344  */
345  bool
346  shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
347  {
348  return true;
349  }
350  };
351 
353 
354  /**
355  * @brief Implementation of NeverBase
356  * @see NeverBase
357  */
358  class Never : virtual public NeverBase, virtual public ComputingPowerRequestStrategy
359  {
360  public:
361  /**
362  * @brief Always return false.
363  * @return false
364  */
365  bool
366  shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
367  {
368  return false;
369  }
370  };
371 
373 
374  /**
375  * @brief Implementation of ElapsedTimeBase
376  * @see ElapsedTimeBase
377  */
378  class ElapsedTime : virtual public ElapsedTimeBase, virtual public ComputingPowerRequestStrategy
379  {
380  public:
381  /**
382  * @brief The used clock type.
383  */
384  using Clock = std::chrono::system_clock;
385  /**
386  * @brief The type of the used time point.
387  */
388  using TimePoint = Clock::time_point;
389 
390  /**
391  * @brief Ctor
392  * @param timeDeltaInSeconds The delta to use.(in seconds)
393  * @param skipping Whether skipping is activated.
394  */
395  ElapsedTime(Ice::Long timeDeltaInSeconds, bool skipping) :
396  ElapsedTimeBase(timeDeltaInSeconds, skipping), allocatedLastTime{}
397  {
398  }
399 
400  /**
401  * @brief Sets the next time to allocate delta seconds from now.
402  */
403  void
404  setCurrentStateAsInitialState(const ::Ice::Current& = Ice::emptyCurrent) override
405  {
407  }
408 
409  /**
410  * @brief Sets the next time to allocate depending on the flag skipping.
411  * skipping == true: now + delta seconds.
412  * skipping == false: the current next time point + delta seconds. (may already passed)
413  */
414  void allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override;
415 
416  /**
417  * @brief Returns true if the last creation timepoint is more than delta seconds away.
418  * @return Whether more computing power should be allocated.
419  */
420  bool
421  shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
422  {
423  return Clock::now() >= allocatedLastTime + std::chrono::seconds{timeDeltaInSeconds};
424  }
425 
426  protected:
427  /**
428  * @brief The time point when more power should be allocated again.
429  */
431 
432  //for object factory
433  template <class Base, class Derived>
435  /**
436  * @brief Ctor used for object factories.
437  */
438  ElapsedTime() = default;
439  };
440 
442 
443  /**
444  * @brief Implementation of NoNodeCreatedBase
445  * @see NoNodeCreatedBase
446  */
447  class NoNodeCreated : virtual public NoNodeCreatedBase, virtual public ElapsedTime
448  {
449  public:
450  /**
451  * @brief ctor
452  * @param timeDeltaInSeconds The delta to use.(in seconds)
453  * @param skipping Whether skipping is activated.
454  * @param sig The parameter sigma.
455  * @param backlogSz The backlog's size.
456  */
457  NoNodeCreated(Ice::Long timeDeltaInSec, bool skip, float sig, Ice::Long backlogSz) :
458  NoNodeCreatedBase(timeDeltaInSec, skip, sig, backlogSz),
459  ElapsedTime(timeDeltaInSec, skip),
460  backlog(backlogSz, 0),
462  {
463  timeDeltaInSeconds = timeDeltaInSec; //somehow does not get set by ctor call
464  ARMARX_CHECK_EXPRESSION(timeDeltaInSeconds >= 0);
465  ARMARX_CHECK_EXPRESSION(backlogSize >= 0);
466  }
467 
468  /**
469  * @brief Updates the number of failed node creations.
470  * @param nodesCreated Number of created nodes.
471  * @param tries Number of tries to create nodes.
472  */
473  void updateNodeCreations(Ice::Long nodesCreated,
474  Ice::Long tries,
475  const Ice::Current& = Ice::emptyCurrent) override;
476 
477  void allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override;
478 
479  /**
480  * @brief shouldAllocateComputingPower
481  * @return Whrether
482  */
483  bool
484  shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
485  {
486  const auto perc = std::accumulate(backlog.begin(), backlog.end(), 1.f) / backlog.size();
487  const auto usedTimeDelta = timeDeltaInSeconds / (1.f + sigma * perc);
488  ARMARX_CHECK_EXPRESSION(usedTimeDelta >= 0);
489  return Clock::now() >= allocatedLastTime + std::chrono::seconds{
490  static_cast<std::size_t>(usedTimeDelta)};
491  }
492 
493  /**
494  * @brief Nulls the backlog after the object was transmitted through ice.
495  */
496  void
497  ice_postUnmarshal() override
498  {
499  backlog.assign(backlogSize, 0);
500  }
501 
502  protected:
503  /**
504  * @brief The backlog. chars are used instead of bools since vector<bool> is specialized.
505  * contains a 1 if a node creation failed and 0 if it was successfull;
506  */
507  std::vector<char> backlog;
508  /**
509  * @brief The current index in the backlog. (used to determine which variables will be overwritten)
510  */
511  std::size_t currentBacklogIndex;
512 
513  //for object factory
514  template <class Base, class Derived>
516  /**
517  * @brief Ctor used for object factories.
518  */
519  NoNodeCreated() = default;
520  };
521 
523 
524  /**
525  * @brief Implementation of TotalNodeCountBase
526  * @see TotalNodeCountBase
527  */
529  virtual public TotalNodeCountBase,
530  virtual public ComputingPowerRequestStrategy
531  {
532  public:
533  /**
534  * @brief Ctor
535  * @param nodeCountDelta The delta to use.
536  * @param skipping Whether skipping is activated.
537  */
538  TotalNodeCount(Ice::Long nodeCountDelta, bool skipping) :
539  TotalNodeCountBase(nodeCountDelta, skipping), allocateNextTime{0}, nodeCount{0}
540  {
541  }
542 
543  /**
544  * @brief Updates the internal node count.
545  * @param newCount The new node count.
546  */
547  void
548  updateNodeCount(Ice::Long newCount, const Ice::Current& = Ice::emptyCurrent) override
549  {
550  nodeCount = newCount;
551  }
552 
553  /**
554  * @brief Sets the next creation count to allocate depending on the flag skipping.
555  * skipping == true: current count + delta.
556  * skipping == false: the current next creation count + delta. (may be smaller than the current count)
557  */
558  void allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override;
559 
560  /**
561  * @brief Returns true if the the current count is >= the next creation count.
562  * @return Whether more computing power should be allocated.
563  */
564  bool
565  shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
566  {
567  return nodeCount >= allocateNextTime;
568  }
569 
570  protected:
571  /**
572  * @brief The count when to allocate more power.
573  */
575  /**
576  * @brief The current node count.
577  */
579 
580  //for object factory
581  template <class Base, class Derived>
583 
584  /**
585  * @brief Ctor used for object factories.
586  */
588  {
589  }
590  };
591 
593 
594  /**
595  * @brief Implementation of TaskStatusBase
596  * @see TaskStatusBase
597  */
598  class TaskStatus : virtual public TaskStatusBase, virtual public ComputingPowerRequestStrategy
599  {
600  public:
601  /**
602  * @brief Ctor
603  * @param strategyPerTaskStatus Task status to sub strategy map.
604  */
605  TaskStatus(TaskStatusMap strategyPerTaskStatus) :
606  TaskStatusBase(strategyPerTaskStatus), current{nullptr}
607  {
608  }
609 
610  /**
611  * @brief Passes this call to all sub strategies.
612  * @param count The new count
613  */
614  void updateNodeCount(Ice::Long count, const Ice::Current& = Ice::emptyCurrent) override;
615 
616  /**
617  * @brief Switches the current strategy and passes this call to all sub strategies.
618  * @param newStatus
619  */
620  void updateTaskStatus(armarx::TaskStatus::Status newStatus,
621  const Ice::Current& = Ice::emptyCurrent) override;
622 
623  /**
624  * @brief Passes this call to all sub strategies.
625  */
626  void allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override;
627 
628  /**
629  * @brief Passes this call to all sub strategies.
630  * @see ComputingPowerRequestStrategyBase::updateNodeCreations
631  * @param nodesCreated Number of created nodes.
632  * @param tries Number of tries to create nodes.
633  */
634  void updateNodeCreations(Ice::Long nodesCreated,
635  Ice::Long tries,
636  const Ice::Current& = Ice::emptyCurrent) override;
637 
638  /**
639  * @brief Returns the result of the current selected strategy.
640  * @return The result of the current selected strategy.
641  */
642  bool
643  shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
644  {
646  return current->shouldAllocateComputingPower();
647  }
648 
649  protected:
650  /**
651  * @brief The current strategy in use.
652  */
653  ComputingPowerRequestStrategyBase* current;
654 
655  //for object factory
656  template <class Base, class Derived>
658 
659  /**
660  * @brief Ctor used for object factories.
661  */
662  TaskStatus() : current{nullptr}
663  {
664  }
665  };
666 
668 } // namespace armarx::cprs
armarx::cprs::NoNodeCreated::NoNodeCreated
NoNodeCreated(Ice::Long timeDeltaInSec, bool skip, float sig, Ice::Long backlogSz)
ctor
Definition: ComputingPowerRequestStrategy.h:457
armarx::cprs::Always::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Always return true.
Definition: ComputingPowerRequestStrategy.h:346
armarx::cprs::ElapsedTime::ElapsedTime
ElapsedTime()=default
Ctor used for object factories.
armarx::cprs::ElapsedTime::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if the last creation timepoint is more than delta seconds away.
Definition: ComputingPowerRequestStrategy.h:421
armarx::cprs::Not::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns the negatedresult of the contained strategy.
Definition: ComputingPowerRequestStrategy.h:303
armarx::cprs::ComputingPowerRequestStrategy::updateNodeCreations
void updateNodeCreations(Ice::Long, Ice::Long, const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
Definition: ComputingPowerRequestStrategy.h:90
armarx::cprs::Never
Implementation of NeverBase.
Definition: ComputingPowerRequestStrategy.h:358
armarx::cprs::ComputingPowerRequestStrategy::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
Definition: ComputingPowerRequestStrategy.h:81
armarx::cprs::TotalNodeCount::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if the the current count is >= the next creation count.
Definition: ComputingPowerRequestStrategy.h:565
armarx::cprs::CompoundedRequestStrategy::CompoundedRequestStrategy
CompoundedRequestStrategy(const ComputingPowerRequestStrategyBaseList &requestStrategies)
Ctor.
Definition: ComputingPowerRequestStrategy.h:118
armarx::cprs::CompoundedRequestStrategy::updateTaskStatus
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
Definition: ComputingPowerRequestStrategy.cpp:155
armarx::cprs::TotalNodeCount::updateNodeCount
void updateNodeCount(Ice::Long newCount, const Ice::Current &=Ice::emptyCurrent) override
Updates the internal node count.
Definition: ComputingPowerRequestStrategy.h:548
armarx::cprs::TotalNodeCount::allocateNextTime
Ice::Long allocateNextTime
The count when to allocate more power.
Definition: ComputingPowerRequestStrategy.h:574
armarx::cprs::And::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if all compounded strategies return true.
Definition: ComputingPowerRequestStrategy.cpp:30
armarx::cprs::NoNodeCreated::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
shouldAllocateComputingPower
Definition: ComputingPowerRequestStrategy.h:484
FactoryCollectionBase.h
armarx::cprs::NoNodeCreated::NoNodeCreated
NoNodeCreated()=default
Ctor used for object factories.
armarx::cprs::ComputingPowerRequestStrategy::updateNodeCount
void updateNodeCount(Ice::Long, const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
Definition: ComputingPowerRequestStrategy.h:62
armarx::cprs::NoNodeCreated::currentBacklogIndex
std::size_t currentBacklogIndex
The current index in the backlog.
Definition: ComputingPowerRequestStrategy.h:511
armarx::cprs::Not::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
Definition: ComputingPowerRequestStrategy.h:293
armarx::cprs::TotalNodeCount
Implementation of TotalNodeCountBase.
Definition: ComputingPowerRequestStrategy.h:528
armarx::cprs::ComputingPowerRequestStrategy::setCurrentStateAsInitialState
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Default implementation.
Definition: ComputingPowerRequestStrategy.h:53
armarx::cprs::NoNodeCreated
Implementation of NoNodeCreatedBase.
Definition: ComputingPowerRequestStrategy.h:447
armarx::cprs::Not::setCurrentStateAsInitialState
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
Definition: ComputingPowerRequestStrategy.h:263
armarx::cprs
Definition: ComputingPowerRequestStrategy.h:34
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::cprs::TaskStatus::updateNodeCount
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
Definition: ComputingPowerRequestStrategy.cpp:65
armarx::cprs::ComputingPowerRequestStrategy::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override=0
Returns whether new computing power should be allocated.
armarx::cprs::TaskStatus::updateNodeCreations
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
Definition: ComputingPowerRequestStrategy.cpp:95
armarx::cprs::CompoundedRequestStrategy::updateNodeCount
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
Definition: ComputingPowerRequestStrategy.cpp:146
armarx::cprs::NoNodeCreated::backlog
std::vector< char > backlog
The backlog.
Definition: ComputingPowerRequestStrategy.h:507
armarx::cprs::And::And
And()=default
Ctor used for object factories.
armarx::cprs::TotalNodeCount::nodeCount
Ice::Long nodeCount
The current node count.
Definition: ComputingPowerRequestStrategy.h:578
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:918
armarx::cprs::CompoundedRequestStrategy::setCurrentStateAsInitialState
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
Definition: ComputingPowerRequestStrategy.cpp:137
armarx::cprs::TaskStatus::TaskStatus
TaskStatus()
Ctor used for object factories.
Definition: ComputingPowerRequestStrategy.h:662
armarx::cprs::Or::Or
Or(const ComputingPowerRequestStrategyBaseList &requestStrategies)
Ctor.
Definition: ComputingPowerRequestStrategy.h:214
armarx::cprs::TaskStatus::current
ComputingPowerRequestStrategyBase * current
The current strategy in use.
Definition: ComputingPowerRequestStrategy.h:653
armarx::cprs::ElapsedTime::TimePoint
Clock::time_point TimePoint
The type of the used time point.
Definition: ComputingPowerRequestStrategy.h:388
armarx::cprs::NoNodeCreated::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Definition: ComputingPowerRequestStrategy.cpp:120
ExpressionException.h
armarx::cprs::Not
Implementation of NotBase.
Definition: ComputingPowerRequestStrategy.h:248
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
armarx::cprs::Not::updateNodeCount
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
Definition: ComputingPowerRequestStrategy.h:273
armarx::cprs::Or
Implementation of OrBase.
Definition: ComputingPowerRequestStrategy.h:207
armarx::cprs::ElapsedTime::allocatedLastTime
TimePoint allocatedLastTime
The time point when more power should be allocated again.
Definition: ComputingPowerRequestStrategy.h:430
armarx::cprs::NoNodeCreated::ice_postUnmarshal
void ice_postUnmarshal() override
Nulls the backlog after the object was transmitted through ice.
Definition: ComputingPowerRequestStrategy.h:497
armarx::cprs::ElapsedTime
Implementation of ElapsedTimeBase.
Definition: ComputingPowerRequestStrategy.h:378
armarx::cprs::TaskStatus::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
Definition: ComputingPowerRequestStrategy.cpp:86
armarx::cprs::ElapsedTime::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Sets the next time to allocate depending on the flag skipping.
Definition: ComputingPowerRequestStrategy.cpp:39
armarx::cprs::TotalNodeCount::TotalNodeCount
TotalNodeCount(Ice::Long nodeCountDelta, bool skipping)
Ctor.
Definition: ComputingPowerRequestStrategy.h:538
armarx::cprs::TotalNodeCount::TotalNodeCount
TotalNodeCount()
Ctor used for object factories.
Definition: ComputingPowerRequestStrategy.h:587
armarx::cprs::TaskStatus
Implementation of TaskStatusBase.
Definition: ComputingPowerRequestStrategy.h:598
armarx::cprs::Not::Not
Not(const ComputingPowerRequestStrategyBasePtr &s)
Ctor.
Definition: ComputingPowerRequestStrategy.h:255
armarx::cprs::Always
Implementation of Always.
Definition: ComputingPowerRequestStrategy.h:338
armarx::cprs::Not::updateTaskStatus
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
Definition: ComputingPowerRequestStrategy.h:283
armarx::cprs::ComputingPowerRequestStrategy::~ComputingPowerRequestStrategy
~ComputingPowerRequestStrategy() override=default
Dtor.
armarx::GenericFactory
Definition: FactoryCollectionBase.h:51
armarx::cprs::TaskStatus::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns the result of the current selected strategy.
Definition: ComputingPowerRequestStrategy.h:643
armarx::cprs::TaskStatus::TaskStatus
TaskStatus(TaskStatusMap strategyPerTaskStatus)
Ctor.
Definition: ComputingPowerRequestStrategy.h:605
armarx::cprs::ComputingPowerRequestStrategy::updateTaskStatus
void updateTaskStatus(armarx::TaskStatus::Status, const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
Definition: ComputingPowerRequestStrategy.h:71
armarx::cprs::And::And
And(const ComputingPowerRequestStrategyBaseList &requestStrategies)
Ctor.
Definition: ComputingPowerRequestStrategy.h:180
armarx::cprs::And
Implementation of AndBase.
Definition: ComputingPowerRequestStrategy.h:173
armarx::cprs::CompoundedRequestStrategy::updateNodeCreations
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
Definition: ComputingPowerRequestStrategy.cpp:174
armarx::cprs::Or::Or
Or()=default
Ctor used for object factories.
armarx::cprs::ComputingPowerRequestStrategy
Implementation of ComputingPowerRequestStrategyBase.
Definition: ComputingPowerRequestStrategy.h:40
armarx::cprs::TaskStatus::updateTaskStatus
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Switches the current strategy and passes this call to all sub strategies.
Definition: ComputingPowerRequestStrategy.cpp:74
armarx::cprs::Or::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if any compounded strategies returns true.
Definition: ComputingPowerRequestStrategy.h:224
armarx::cprs::CompoundedRequestStrategy::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
Definition: ComputingPowerRequestStrategy.cpp:165
armarx::cprs::ElapsedTime::setCurrentStateAsInitialState
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Sets the next time to allocate delta seconds from now.
Definition: ComputingPowerRequestStrategy.h:404
armarx::cprs::Never::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Always return false.
Definition: ComputingPowerRequestStrategy.h:366
armarx::cprs::Not::updateNodeCreations
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
Definition: ComputingPowerRequestStrategy.h:315
armarx::cprs::ElapsedTime::ElapsedTime
ElapsedTime(Ice::Long timeDeltaInSeconds, bool skipping)
Ctor.
Definition: ComputingPowerRequestStrategy.h:395
armarx::cprs::TotalNodeCount::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Sets the next creation count to allocate depending on the flag skipping.
Definition: ComputingPowerRequestStrategy.cpp:52
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::cprs::ElapsedTime::Clock
std::chrono::system_clock Clock
The used clock type.
Definition: ComputingPowerRequestStrategy.h:384
armarx::cprs::CompoundedRequestStrategy::CompoundedRequestStrategy
CompoundedRequestStrategy()=default
Ctor used for object factories.
armarx::cprs::Not::Not
Not()=default
Ctor used for object factories.
armarx::cprs::NoNodeCreated::updateNodeCreations
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Updates the number of failed node creations.
Definition: ComputingPowerRequestStrategy.cpp:106
armarx::core::time::Clock::now
DateTime now() const
Current date/time of the clock.
Definition: Clock.cpp:22
armarx::cprs::CompoundedRequestStrategy
Implementation of CompoundedRequestStrategyBase.
Definition: ComputingPowerRequestStrategy.h:109