AnimatLab  2
Test
IonChannelSigmoid.cpp
Go to the documentation of this file.
1 
7 #include "stdafx.h"
8 #include "IonChannelSigmoid.h"
9 
10 
11 namespace IntegrateFireSim
12 {
13  namespace Gains
14  {
15 
23 {
24  m_fltA = 0;
25  m_fltB = 0;
26  m_fltC = 0;
27  m_fltD = 0;
28  m_fltE = 0;
29  m_fltF = 0;
30  m_fltG = 0;
31  m_fltH = 1;
32 }
33 
41 {
42 
43 try
44 {
45 }
46 catch(...)
47 {Std_TraceMsg(0, "Caught Error in desctructor of IonChannelSigmoid\r\n", "", -1, false, true);}
48 }
49 
50 float IonChannelSigmoid::CalculateGain(float fltInput)
51 {
52  if(InLimits(fltInput))
53  return (m_fltA + (m_fltB/(m_fltH + exp(m_fltC*(fltInput+m_fltD)) + m_fltE*exp(m_fltF*(fltInput+m_fltG)) )));
54  else
55  return CalculateLimitOutput(fltInput);
56 }
57 
58 bool IonChannelSigmoid::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
59 {
60  if(Gain::SetData(strDataType, strValue, false))
61  return true;
62 
63  if(strDataType == "A")
64  {
65  m_fltA = atof(strValue.c_str());
66  return true;
67  }
68 
69  if(strDataType == "B")
70  {
71  m_fltB = atof(strValue.c_str());
72  return true;
73  }
74 
75  if(strDataType == "C")
76  {
77  m_fltC = atof(strValue.c_str());
78  return true;
79  }
80 
81  if(strDataType == "D")
82  {
83  m_fltD = atof(strValue.c_str());
84  return true;
85  }
86 
87  if(strDataType == "E")
88  {
89  m_fltE = atof(strValue.c_str());
90  return true;
91  }
92 
93  if(strDataType == "F")
94  {
95  m_fltF = atof(strValue.c_str());
96  return true;
97  }
98 
99  if(strDataType == "G")
100  {
101  m_fltG = atof(strValue.c_str());
102  return true;
103  }
104 
105  if(strDataType == "H")
106  {
107  m_fltH = atof(strValue.c_str());
108  return true;
109  }
110 
111  //If it was not one of those above then we have a problem.
112  if(bThrowError)
113  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
114 
115  return false;
116 }
117 
118 void IonChannelSigmoid::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
119 {
120  Gain::QueryProperties(aryProperties);
121 
122  aryProperties.Add(new TypeProperty("A", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
123  aryProperties.Add(new TypeProperty("B", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
124  aryProperties.Add(new TypeProperty("C", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
125  aryProperties.Add(new TypeProperty("D", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
126  aryProperties.Add(new TypeProperty("E", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
127  aryProperties.Add(new TypeProperty("F", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
128  aryProperties.Add(new TypeProperty("G", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
129  aryProperties.Add(new TypeProperty("H", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
130 }
131 
132 void IonChannelSigmoid::Load(CStdXml &oXml)
133 {
134  Gain::Load(oXml);
135 
136  oXml.IntoElem(); //Into Adapter Element
137 
138  m_fltA = oXml.GetChildFloat("A");
139  m_fltB = oXml.GetChildFloat("B");
140  m_fltC = oXml.GetChildFloat("C");
141  m_fltD = oXml.GetChildFloat("D");
142  m_fltE = oXml.GetChildFloat("E");
143  m_fltF = oXml.GetChildFloat("F");
144  m_fltG = oXml.GetChildFloat("G");
145  m_fltH = oXml.GetChildFloat("H");
146 
147  oXml.OutOfElem(); //OutOf Adapter Element
148 }
149 
150  } //Gains
151 } //AnimatSim
bool InLimits(float fltInput)
Tells whether the input value is within the defined limit ranges.
Definition: Gain.h:63
virtual float CalculateGain(float fltInput)
Calculates the gain.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
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.
float CalculateLimitOutput(float fltInput)
Calculates the output when the input is outside of the limit ranges.
Definition: Gain.h:81
Declares the ion channel sigmoid class.
Contains all of the classes to implement a basic integrate and fire neural model. ...