Page MenuHomePhorge

No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None
diff --git a/include/rosa/agent/State.hpp b/include/rosa/agent/State.hpp
index 06bb085..fe977bb 100644
--- a/include/rosa/agent/State.hpp
+++ b/include/rosa/agent/State.hpp
@@ -1,77 +1,109 @@
//===-- rosa/agent/State.hpp ----------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file rosa/agent/State.hpp
///
/// \author Maximilian Götzinger (maximilian.goetzinger@tuwien.ac.at)
///
/// \date 2019
///
/// \brief Definition of *state* *functionality*.
///
//===----------------------------------------------------------------------===//
#ifndef ROSA_AGENT_STATE_HPP
#define ROSA_AGENT_STATE_HPP
#include "rosa/agent/Functionality.h"
#include "rosa/agent/History.hpp"
namespace rosa {
namespace agent {
-/// \tparam D type of data
-template <typename D> class State : public Functionality {
+/// \tparam DIN type of data of input, \tparam DDAB type of data in which DABs are saved,
+/// \tparam DIN type of data of output
+template <typename DIN, typename DDAB, typename DOUT> class State : public Functionality {
private:
- DynamicHistory<D, HistoryPolicy::FIFO> SampleHistory; //Make History dynamic
- DynamicHistory<D, HistoryPolicy::SRWF> DAB;
- DynamicHistory<XXX, HistoryPolicy::LIFO> DABHistory; //Implement LIFO
+ DynamicHistory<DIN, HistoryPolicy::FIFO> SampleHistory;
+ DynamicHistory<DIN, HistoryPolicy::SRWF> DAB;
+ DynamicHistory<DDAB, HistoryPolicy::LIFO> DABHistory;
+
+ PartialFunction* ConfidenceSimilarToSample,
+ ConfidenceDifferentToSample;
public:
State(unsigned int sampleHistorySize, unsigned int DABSize,
- unsigned int DABHistorySize) noexcept :
+ unsigned int DABHistorySize, PartialFunction* ConfidenceSimilarToSample,
+ PartialFunction* ConfidenceDifferentToSample) noexcept :
SampleHistory(sampleHistorySize),
DAB(DABSize),
- DABHistory(DABHistorySize) {}
+ DABHistory(DABHistorySize) {
+ this->ConfidenceSimilarToSample = ConfidenceSimilarToSample;
+ this->ConfidenceDifferentToSample = ConfidenceDifferentToSample;
+ }
+ //TODO: static assert -> check:
+ // 1) if DIN == arithmetic,
+ // 2) if DDAB == float, double, ...?
+ // 3) output could be arithemtic or char/string, right?
+
~State(void) = default;
-
+
+ void leaveState(void) {
+ if(!DAB.empty()) {
+ //TODO: delete all entries in DAB
+ //@Benedikt:I would need such a method in history
+ }
+ }
+
+
bool insertSample(D Sample) {
bool workedForAll;
workedForAll = SampleHistory.addEntry(Sample);
if (workedForAll) {
- if (numberOfEntries >= DAB) {
+ workedForAll &= DAB.addEntry(Sample);
+ if (workedForAll) {
+ if (numberOfEntries >= DAB) {
+ //TODO: calculate average of DAB
+ //@Benedikt: should we do this avg calc in the history class or here or somewhere else?
+ AvgOfDAB = 0; //XXX - Dummy value
+ workedForAll &= DABHistory.addEntry(AvgOfDAB);
-
- }
-
-
- //check if full/empty
-
- workedForAll &= DAB.addEntry(Sample);
-
-
-
-
-
+ if(workedForAll) {
+ //TODO: delete all entries in DAB
+ } //xxx - what should be done if it has not worked?
+ }
+ if(workedForAll) {
+ //calculate if state is valid
+ }
+ }
}
- }
+ return workedForAll;
+ }
+
+
+
+
+
+
+
+
};
} // End namespace agent
} // End namespace rosa
#endif // ROSA_AGENT_STATE_HPP
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Fri, May 16, 5:20 PM (9 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
141465
Default Alt Text
(3 KB)

Event Timeline