8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
14 #include "IPhysicsMovableItem.h"
15 #include "IPhysicsBody.h"
17 #include "MovableItem.h"
21 #include "PropertyControlAdapter.h"
56 m_fltSetThreshold = 0.5;
57 m_fltPreviousSetVal = 0;
58 m_fltInitialValue = 0;
73 m_ePropertyType = AnimatPropertyType::Invalid;
77 {
Std_TraceMsg(0,
"Caught Error in desctructor of PropertyControlAdapter\r\n",
"", -1,
false,
true);}
101 if(
Std_Trim(strPropName).length() == 0)
102 THROW_PARAM_ERROR(Al_Err_lPropertyNameBlank, Al_Err_strPropertyNameBlank,
"Adapter ID",
m_strID);
105 THROW_PARAM_ERROR(Al_Err_lTargetDoesNotHaveProperty, Al_Err_strTargetDoesNotHaveProperty,
"Property name", strPropName);
107 AnimatPropertyType ePropertyType =
m_lpTargetObject->PropertyType(strPropName);
108 if(!(ePropertyType != AnimatPropertyType::Boolean || ePropertyType != AnimatPropertyType::Integer || ePropertyType != AnimatPropertyType::Float))
109 THROW_PARAM_ERROR(Al_Err_lTargetInvalidPropertyType, Al_Err_strTargetInvalidPropertyType,
"Property name", strPropName);
111 m_ePropertyType = ePropertyType;
114 m_ePropertyType = AnimatPropertyType::Invalid;
116 m_strPropertyName = strPropName;
128 {
return m_strPropertyName;}
144 THROW_PARAM_ERROR(Al_Err_lInvalidSetThreshold, Al_Err_strInvalidSetThreshold,
"Threshold", fltThreshold);
146 m_fltSetThreshold = fltThreshold;
158 {
return m_fltSetThreshold;}
170 m_fltInitialValue = fltVal;
171 m_fltPreviousSetVal = fltVal;
183 {
return m_fltInitialValue;}
195 m_fltFinalValue = fltVal;
207 {
return m_fltFinalValue;}
226 if(strType ==
"PROPERTYNAME")
232 if(strType ==
"SETTHRESHOLD")
238 if(strType ==
"INITIALVALUE")
244 if(strType ==
"FINALVALUE")
252 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Data Type", strDataType);
261 aryProperties.Add(
new TypeProperty(
"PropertyName", AnimatPropertyType::String, AnimatPropertyDirection::Set));
262 aryProperties.Add(
new TypeProperty(
"SetThreshold", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
263 aryProperties.Add(
new TypeProperty(
"InitialValue", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
264 aryProperties.Add(
new TypeProperty(
"FinalValue", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
273 m_fltPreviousSetVal = m_fltInitialValue;
274 if(m_ePropertyType != AnimatPropertyType::Invalid)
283 m_fltPreviousSetVal = m_fltInitialValue;
284 if(m_ePropertyType != AnimatPropertyType::Invalid)
296 THROW_PARAM_ERROR(Al_Err_lNodeNotFound, Al_Err_strNodeNotFound,
"ID: ",
m_strSourceID);
301 THROW_TEXT_ERROR(Al_Err_lDataPointNotFound, Al_Err_strDataPointNotFound,
307 THROW_PARAM_ERROR(Al_Err_lNodeNotFound, Al_Err_strNodeNotFound,
"ID: ",
m_strTargetID);
311 m_fltPreviousSetVal = m_fltInitialValue;
317 void PropertyControlAdapter::SetPropertyValue(
float fltVal)
320 if(m_ePropertyType != AnimatPropertyType::Invalid)
322 float fltDiff = fltVal - m_fltPreviousSetVal;
323 if(fabs(fltDiff) > m_fltSetThreshold)
325 m_fltPreviousSetVal = fltVal;
327 if(m_ePropertyType == AnimatPropertyType::Boolean)
334 else if(m_ePropertyType == AnimatPropertyType::Integer)
336 int iVal = (int) fltVal;
350 SetPropertyValue(fltInput);
354 void PropertyControlAdapter::SetDestinationID(std::string strXml)
380 void PropertyControlAdapter::Load(
CStdXml &oXml)
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.
Gain * m_lpGain
Pointer to the Gain that will be used to convert the source value into the target value...
Declares the simulation recorder class.
virtual std::string TargetModule()
Gets the name of the target NeuralModule.
virtual void SimStarting()
Called just before the simulation starts.
virtual bool FindChildElement(std::string strElementName, bool fThrowError=true)
Finds a child element by name.
virtual void StepSimulation()
Step the simulation for this object.
Root namespace for the base simulation library for AnimatLab.
Declares the body part class.
virtual AnimatBase * TargetObject()
Gets the target object.
virtual bool FindElement(std::string strElementName, bool fThrowError=true)
Finds an element with the specified name.
Simulator * m_lpSim
The pointer to a Simulation.
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 bool HasProperty(const std::string &strName)
Queries this object if it has a property with the given name.
virtual std::string PropertyName()
Gets the name of the property that this adapter will be setting.
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
Class that stores information about types for QueryProperty information.
virtual void Initialize()
Initializes this object.
virtual float FinalValue()
Gets the final value used to set this property when the simulation ends.
Declares the link base class.
std::string m_strSourceDataType
DateType of the source variable that will be converted. This is retrieved using the GetDataPointer me...
Declares the key frame class.
virtual float InitialValue()
Gets vthe initial value used to set this property when the simulation starts.
Node * m_lpSourceNode
Pointer to the source node.
Declares the joint class.
Declares the organism class.
AnimatSim::Environment::Structure * m_lpStructure
The pointer to this items parent Structure. If this is not relevant for this object then this is NULL...
std::string m_strID
The unique Id for this object.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
std::string Std_Trim(std::string strVal)
Trims a string.
std::string m_strSourceID
GUID ID of the source node.
std::string m_strTargetID
GUID ID of the target node.
Node * m_lpTargetNode
Pointer to the target node.
Declares the activated item class.
Declares a light manager object.
virtual ~PropertyControlAdapter()
Destructor.
Declares the bounding box class.
Declares the gain base class.
A standard xml manipulation class.
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
virtual AnimatBase * FindByID(std::string strID, bool bThrowError=true)
Searches for the object with the specified ID.
virtual std::string TargetID()
Gets the GUID ID of the target node where we will add the transformed data variable.
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 float SetThreshold()
Gets the threshold value used for determining when to set the value on the target object...
bool m_bEnabled
Tells if this item is enabled or not. If it is not enabled then it is not run.
float * m_lpSourceData
Pointer to the source data varaible.
virtual void ResetSimulation()
Resets the simulation back to time 0.
PropertyControlAdapter()
Default constructor.
Base class for body parts and neural network nodes.
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
bool Std_IsBlank(std::string strVal)
Trims a string and tests if a string is blank.
Declares the data chart manager class.
Declares the rigid body class.
virtual float CalculateGain(float fltInput)=0
Calculates the gain.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
Declares the structure class.
Declares the odor type class.
Declares the simulator class.
Declares the neural module class.
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
Declares the activated item manager class.
Declares the external stimuli manager class.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
Declares the receptive field class.
AnimatBase * m_lpTargetObject
Pointer to the target node.
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
virtual void Initialize()
Initializes this object.