Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef SIMPLECONDITION_H
00028 #define SIMPLECONDITION_H
00029
00030 #include "AbstractCondition.h"
00031 #include "DinverCoreDLLExport.h"
00032
00033 namespace DinverCore {
00034
00035 class DINVERCORE_EXPORT SimpleCondition : public AbstractCondition
00036 {
00037 public:
00038 enum Type {NoCondition, LessThan, GreaterThan};
00039
00040 SimpleCondition(Parameter * p1, Type type, double factor, Parameter * p2, double constant);
00041 virtual bool operator==(const AbstractCondition& o) const;
00042
00043 virtual const QString& xml_tagName() const {return xmlSimpleConditionTag;}
00044 static const QString xmlSimpleConditionTag;
00045
00046 inline virtual void getLimits(int paramIndex, double& min, double& max) const;
00047 virtual bool adjustRanges();
00048 virtual void humanInfo() const;
00049
00050 static QString toString(Type t);
00051 static Type fromString(QString t, bool& ok);
00052 protected:
00053 virtual uint internalChecksum() const;
00054 virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00055 virtual XMLMember xml_member(XML_MEMBER_ARGS);
00056 virtual bool xml_setProperty(XML_SETPROPERTY_ARGS);
00057 private:
00058 Type _type;
00059 double _factor;
00060 double _constant;
00061 };
00062
00063 }
00064
00065 #include "Parameter.h"
00066
00067 namespace DinverCore {
00068
00069 inline void SimpleCondition::getLimits(int paramIndex, double& min, double& max) const
00070 {
00071 TRACE;
00072 double threshold;
00073 switch (paramIndex) {
00074 case 0:
00075 threshold=_factor * parameter(1).realValue() + _constant;
00076 switch (_type) {
00077 case LessThan:
00078 if(threshold < max) {
00079 max=threshold;
00080 }
00081 break;
00082 case GreaterThan:
00083 if(threshold > min) {
00084 min=threshold;
00085 }
00086 break;
00087 case NoCondition:
00088 break;
00089 }
00090 break;
00091 default:
00092 threshold=parameter(0).realValue() - _constant;
00093 switch (_type) {
00094 case LessThan:
00095 if(threshold > _factor * min) {
00096 if(_factor==1.0)
00097 min=threshold;
00098 else
00099 min=threshold/_factor;
00100 }
00101 break;
00102 case GreaterThan:
00103 if(threshold < _factor * max) {
00104 if(_factor==1.0)
00105 max=threshold;
00106 else
00107 max=threshold/_factor;
00108 }
00109 break;
00110 case NoCondition:
00111 break;
00112 }
00113 break;
00114 }
00115 }
00116
00117 }
00118
00119 #endif // SIMPLECONDITION_H