8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
15 #include "IPhysicsMovableItem.h"
16 #include "IPhysicsBody.h"
18 #include "MovableItem.h"
84 {
Std_TraceMsg(0,
"Caught Error in desctructor of DataChart\r\n",
"", -1,
false,
true);}
99 THROW_ERROR(Al_Err_lItemNotDataChartType, Al_Err_strItemNotDataChartType);
259 float fltMin =
m_lpSim->MinTimeStep();
281 float fltTimeBase = 0;
284 float fltMin =
m_lpSim->MinTimeStep();
438 if(lBuffSize > MAX_DATA_CHART_BUFFER)
439 THROW_PARAM_ERROR(Al_Err_lExceededMaxBuffer, Al_Err_strExceededMaxBuffer,
"Buffer Size", lBuffSize);
459 for(
int iCol=0; iCol<iCount; iCol++)
490 if(lBuffSize > MAX_DATA_CHART_BUFFER)
491 THROW_PARAM_ERROR(Al_Err_lExceededMaxBuffer, Al_Err_strExceededMaxBuffer,
"Buffer Size", lBuffSize);
515 for(
int iCol=0; iCol<iCount; iCol++)
530 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
559 for(
int iCol=0; iCol<iCount; iCol++)
603 oError.
m_strError +=
" Duplicate data column ID: " + lpColumn->
ID();
623 if(!lpColumn)
return;
643 CStdMap<std::string, DataColumn *>::iterator oPos;
647 lpColumn = oPos->second;
649 THROW_TEXT_ERROR(Al_Err_lDataColumnIDNotFound, Al_Err_strDataColumnIDNotFound,
" DataColumn ID: " + strID);
671 for(iIndex=0; iIndex<iCount; iIndex++)
675 if(lpColumn->
ID() == strID)
680 THROW_TEXT_ERROR(Al_Err_lDataColumnIDNotFound, Al_Err_strDataColumnIDNotFound,
" DataColumn ID: " + strID);
690 for(
int iCol=0; iCol<iCount; iCol++)
699 for(
int iCol=0; iCol<iCount; iCol++)
703 #pragma region DataAccesMethods
705 bool DataChart::SetData(
const std::string &strDataType,
const std::string &strValue,
bool bThrowError)
712 if(strType ==
"STARTTIME")
714 StartTime((
float) atof(strValue.c_str()));
718 if(strType ==
"ENDTIME")
720 EndTime((
float) atof(strValue.c_str()));
724 if(strType ==
"SETSTARTENDTIME")
730 if(strType ==
"COLLECTTIMEWINDOW")
736 if(strType ==
"COLLECTINTERVAL")
744 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
753 aryProperties.Add(
new TypeProperty(
"StartTime", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
754 aryProperties.Add(
new TypeProperty(
"EndTime", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
755 aryProperties.Add(
new TypeProperty(
"SetStartEndTime", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
756 aryProperties.Add(
new TypeProperty(
"CollectTimeWindow", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
757 aryProperties.Add(
new TypeProperty(
"CollectInterval", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
760 bool DataChart::AddItem(
const std::string &strItemType,
const std::string &strXml,
bool bThrowError,
bool bDoNotInit)
764 if(strType ==
"DATACOLUMN")
772 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Item Type", strItemType);
781 if(strType ==
"DATACOLUMN")
789 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Item Type", strItemType);
809 for(
int iCol=0; iCol<iCount; iCol++)
828 SetData(iColumn, iRow, fltVal);
850 THROW_PARAM_ERROR(Std_Err_lAboveMaxValue, Std_Err_strAboveMaxValue,
"Current Col Count", iColumn);
853 THROW_PARAM_ERROR(Std_Err_lAboveMaxValue, Std_Err_strAboveMaxValue,
"Current Row Count", iRow);
871 TRACE_DEBUG(
"Loading data chart config file.\r\nFile: " + strConfigFile);
874 THROW_ERROR(Al_Err_lProjectPathBlank, Al_Err_strProjectPathBlank);
877 THROW_ERROR(Al_Err_lFilenameBlank, Al_Err_strFilenameBlank);
882 oXml.
Load(AnimatSim::GetFilePath(strProjectPath, strConfigFile));
889 TRACE_DEBUG(
"Finished loading data chart config file.");
895 short iColumn, iTotalColumns;
897 ActivatedItem::Load(oXml);
918 for(iColumn=0; iColumn<iTotalColumns; iColumn++)
944 std::string strModuleName, strType;
955 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"DataColumn");
958 lpColumn->Load(oXml);
966 if(lpColumn)
delete lpColumn;
972 if(lpColumn)
delete lpColumn;
973 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
std::string m_strConfigFilename
Filename of the configuration file.
virtual void Deserialize(std::string &strXml)
Deserializes a string into an xml document.
Base class file for all Animat simulation objects.
Declares the nervous system class.
virtual int CollectInterval()
Gets the collect interval.
virtual void Activate()
Activates this item.
Declares the simulation recorder class.
long m_lEndSlice
The time slice where this item is deactived.
bool m_bSetStartEndTime
true to set the start and end time. If false then the chart collects continuously.
DataColumn * LoadDataColumn(CStdXml &oXml)
Loads a data column.
virtual bool FindChildElement(std::string strElementName, bool fThrowError=true)
Finds a child element by name.
Root namespace for the base simulation library for AnimatLab.
int m_lCurrentCol
The currently selected column.
float * m_aryDataBuffer
Buffer for data variable points.
Declares the body part class.
virtual bool operator<(ActivatedItem *lpItem)
Compares the Start slice time of two data charts to tell if one is less than the other.
virtual long CurrentRow()
Gets the current row.
long m_lCollectTimeWindow
The number of time slices where we will collect data.
virtual long UsedBufferSize()
Gets the size of buffer that is currently used.
virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false)
Adds a new object to this parent.
std::string m_strError
The error message.
virtual bool FindElement(std::string strElementName, bool fThrowError=true)
Finds an element with the specified name.
Simulator * m_lpSim
The pointer to a Simulation.
Information about the standard error.
virtual std::string ID()
Gets the unique GUID ID of this object.
virtual bool IntoElem()
Goes into the next element where the cursor is located.
virtual long RowCount()
Gets the row count.
virtual void SetData(int iColumn, int iRow, float fltVal)
Sets a data element to the data buffer.
Class that stores information about types for QueryProperty information.
virtual long CollectTimeWindow()
Gets the collect time window time slices.
long m_lError
The error number.
virtual void StepSimulation()
Step the simulation for this object.
virtual void RemoveColumn(std::string strID, bool bThrowError=true)
Removes the column with the specified ID.
Declares the link base class.
float m_fltCollectTimeWindow
The time duration where we will collect data.
Declares the key frame class.
virtual void Initialize()
Initializes this object.
virtual float ChartTimeBase()
Gets the Time base used by this data chart.
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
virtual long CalculateChartColumnCount()
Calculates the chart column count.
Base class for all activated items.
Declares the joint class.
Declares the organism class.
CStdMap< std::string, DataColumn * > m_aryColumnsMap
The array of datacolumns columns. This is a sorted map that is used to get columns based on their ID...
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
bool LessThanDataColumnCompare(DataColumn *lpColumn1, DataColumn *lpColumn2)
Compares two DataColumn items to find the one that is less than the other.
long m_lColumnCount
Number of data columns.
Declares the activated item class.
virtual float TimeStep()
Gets the smallest integration time step used within the simulation.
Declares the data column class.
virtual void Load(std::string strProjectPath, std::string strConfigFile)
Loads a data chart from a file.
virtual CStdSerialize * CreateObject(std::string strModule, std::string strClassName, std::string strType, bool bThrowError=true)
Creates an object using a class factory.
Declares a light manager object.
virtual void ResetSimulation()
Resets the simulation back to time 0.
Declares the bounding box class.
virtual float StartTime()
Gets the simulation start time for activation.
Declares the gain base class.
virtual void Load(std::string strFilename)
Loads an xml data file.
virtual float * DataBuffer()
Gets the data buffer.
virtual DataColumn * FindColumn(std::string strID, int &iIndex, bool bThrowError)
Searches for a column that matches the specified ID.
A standard xml manipulation class.
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
virtual void AddData(int iColumn, int iRow, float fltVal)
Adds a data element to the data buffer.
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
virtual void Unlock()
Unlocks this data chart buffer from being written by any other process.
float m_fltCollectInterval
Tells what the time slice step interval to use when collecting data. This is.
virtual bool Lock()
Locks this data chart buffer from being written by any other process.
bool Std_ToBool(int iVal)
Converts a value toa bool.
DataChart()
Default constructor.
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 bool GetChildBool(std::string strElementName)
Gets a bool value from the element with the specified name.
virtual long BufferByteSize()
Gets the buffer byte size.
virtual int NumberOfChildren()
Gets the number of children of the current element.
virtual bool SetStartEndTime()
Gets whether a start/end time is set for this chart.
bool m_bInitialized
true if item has been initialized
virtual long UsedBufferByteSize()
Gets the used buffer byte size.
virtual long ColumnCount()
Gets the column count.
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
virtual void Deactivate()
Deactivates this item.
std::string m_strProjectPath
Full pathname of the project file.
CStdPtrArray< DataColumn > m_aryDataColumns
The primary array of data columns. This array deletes the columns when destructed.
Declares the data chart class.
virtual std::string Type()
returns the string type name of this object.
long m_lRowCount
Number of rows in the buffer.
bool Std_IsBlank(std::string strVal)
Trims a string and tests if a string is blank.
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.
virtual void Deactivate()
Deactivates this item.
Declares the data chart manager class.
Declares the rigid body class.
virtual long BufferSize()
Gets the buffer size.
virtual bool IntoChildElement(std::string strElementName, bool bThrowError=true)
Goes into the child element with the specified name.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, DataChart *lpChart, bool bVerify)
Sets the system pointers.
float * m_aryTimeBuffer
Buffer for time data points.
virtual long TimeSlice()
Gets the current time slice.
Declares the structure class.
Declares the odor type class.
virtual void Initialize()
Initializes this object.
virtual void Activate()
Activates this item.
Declares the simulator class.
virtual ~DataChart()
Destructor.
Declares the neural module class.
virtual std::string ProjectPath()
Gets the project path.
int m_lCurrentRow
The currently selected row.
virtual bool FindChildByIndex(int iIndex, bool bThrowError=true)
Finds a child element by index.
virtual float Time()
Gets the current simulation time in seconds.
Declares the activated item manager class.
Declares the external stimuli manager class.
virtual float * TimeBuffer()
Gets the time buffer.
virtual bool AlwaysActive()
Gets whether this item is always active.
virtual void ReInitialize()
Re-initialize this object.
long m_lStartSlice
The time slice where this item becomes active.
virtual void AddColumn(DataColumn *lpColumn)
Adds a column.
Declares the receptive field class.
short m_iCollectInterval
Tells what the time slice step interval to use when collecting data. This is.
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
virtual float EndTime()
Gets the end simulation time for deactivation.