AnimatLab  2
Test
MemoryChart.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
10 #include "AnimatBase.h"
11 
12 #include "Gain.h"
13 #include "Node.h"
14 #include "Link.h"
15 #include "IPhysicsMovableItem.h"
16 #include "IPhysicsBody.h"
17 #include "BoundingBox.h"
18 #include "MovableItem.h"
19 #include "BodyPart.h"
20 #include "Joint.h"
21 #include "ReceptiveField.h"
22 #include "ContactSensor.h"
23 #include "RigidBody.h"
24 #include "Structure.h"
25 #include "NeuralModule.h"
26 #include "Adapter.h"
27 #include "NervousSystem.h"
28 #include "Organism.h"
29 #include "ActivatedItem.h"
30 #include "ActivatedItemMgr.h"
31 #include "DataColumn.h"
32 #include "DataChart.h"
33 #include "MemoryChart.h"
34 #include "DataChartMgr.h"
35 #include "ExternalStimuliMgr.h"
36 #include "KeyFrame.h"
37 #include "SimulationRecorder.h"
38 #include "OdorType.h"
39 #include "Odor.h"
40 #include "Light.h"
41 #include "LightManager.h"
42 #include "Simulator.h"
43 
44 namespace AnimatSim
45 {
46  namespace Charting
47  {
55 {
56  m_oRowCountLock = Std_GetCriticalSection();
57 }
58 
66 {
67 
68 try
69 {
70  if(m_oRowCountLock)
71  delete m_oRowCountLock;
72 }
73 catch(...)
74 {Std_TraceMsg(0, "Caught Error in desctructor of MemoryChart\r\n", "", -1, false, true);}
75 }
76 
77 std::string MemoryChart::Type() {return "MemoryChart";}
78 
80 {
81  if(m_oRowCountLock && m_oRowCountLock->TryEnter())
82  return true;
83  else
84  return false;
85 }
86 
88 {
89  if(m_oRowCountLock)
90  m_oRowCountLock->Leave();
91 }
92 
94 {
96 
97  //The time window this memory chart will use for data collection is determined by
98  //the starttime/endtime. This is translated to startslice/endslice in ActivatedItem::Initialize
99  //and then datachart::Initialize creates a buffer of the correct size.
100 }
101 
103 {
105  {
106  if(m_oRowCountLock && m_oRowCountLock->TryEnter())
107  {
109  {
110  //If we have gotten to the point where the current row is equal to the row count
111  //then we are about to overflow our buffer. We need to dump all of the data and
112  //start over with a new time window.
113  if(!m_bSetStartEndTime)
114  m_lCurrentRow = 0;
115  }
116 
119 
120  m_oRowCountLock->Leave();
121  }
122  else
123  {
124  int iVal = 5;
125  }
126  }
127 }
128 
129 void MemoryChart::Load(CStdXml &oXml)
130 {
131  DataChart::Load(oXml);
132 
133  oXml.IntoElem(); //Into MemoryChart Element
134 
135  oXml.OutOfElem(); //OutOf MemoryChart Element
136 }
137 
138  } //Charting
139 } //AnimatSim
140 
Base class file for all Animat simulation objects.
MemoryChart()
Default constructor.
Definition: MemoryChart.cpp:54
Declares the nervous system class.
Declares the simulation recorder class.
bool m_bSetStartEndTime
true to set the start and end time. If false then the chart collects continuously.
Definition: DataChart.h:41
Root namespace for the base simulation library for AnimatLab.
Declares the body part class.
Simulator * m_lpSim
The pointer to a Simulation.
Definition: AnimatBase.h:43
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Definition: StdXml.cpp:42
virtual bool Lock()
Locks this data chart buffer from being written by any other process.
Definition: MemoryChart.cpp:79
CStdCriticalSection * m_oRowCountLock
Critical section to lock access to the data buffer for writing.
Definition: MemoryChart.h:31
virtual void StepSimulation()
Step the simulation for this object.
Definition: DataChart.cpp:796
Declares the key frame class.
virtual void Initialize()
Initializes this object.
Definition: DataChart.cpp:422
Declares the memory chart class.
Declares the joint class.
Declares the organism class.
Declares a light object.
virtual std::string Type()
returns the string type name of this object.
Definition: MemoryChart.cpp:77
Declares the activated item class.
Declares the data column class.
virtual void Load(std::string strProjectPath, std::string strConfigFile)
Loads a data chart from a file.
Definition: DataChart.cpp:867
Declares a light manager object.
Declares the bounding box class.
Declares the gain base class.
A standard xml manipulation class.
Definition: StdXml.h:19
Declares the node class.
virtual void StepSimulation()
Step the simulation for this object.
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
virtual void Unlock()
Unlocks this data chart buffer from being written by any other process.
Definition: MemoryChart.cpp:87
virtual void Initialize()
Initializes this object.
Definition: MemoryChart.cpp:93
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
Definition: StdXml.cpp:56
Declares the data chart class.
long m_lRowCount
Number of rows in the buffer.
Definition: DataChart.h:72
Declares the data chart manager class.
Declares the rigid body class.
virtual long TimeSlice()
Gets the current time slice.
Definition: Simulator.cpp:613
Declares the structure class.
Declares the odor type class.
Declares the odor class.
Declares the simulator class.
Declares the neural module class.
int m_lCurrentRow
The currently selected row.
Definition: DataChart.h:78
Declares the activated item manager class.
virtual ~MemoryChart()
Destructor.
Definition: MemoryChart.cpp:65
Declares the contact sensor class.
Declares the external stimuli manager class.
Declares the receptive field class.
short m_iCollectInterval
Tells what the time slice step interval to use when collecting data. This is.
Definition: DataChart.h:44