CLAM-Development
1.1
|
00001 #include "OutControlSender.hxx" 00002 #include "ProcessingFactory.hxx" 00003 00004 00005 namespace CLAM 00006 { 00007 namespace Hidden 00008 { 00009 static const char * metadata[] = { 00010 "key", "OutControlSender", 00011 "category", "Controls", 00012 "description", "OutControlSender", 00013 0 00014 }; 00015 static FactoryRegistrator<ProcessingFactory, OutControlSender> reg = metadata; 00016 } 00017 00018 Enum::tEnumValue OutControlSenderConfig::EControlRepresentation::sEnumValues[] = 00019 { 00020 { EControlRepresentation::eUndetermined, "Undetermined" }, 00021 { EControlRepresentation::eVerticalSlider, "Vertical Slider" }, 00022 { EControlRepresentation::eHorizontalSlider, "Horizontal Slider" }, 00023 { EControlRepresentation::eKnot, "Knot" }, 00024 { EControlRepresentation::eSpinBox, "Spin Box" }, 00025 { 0, NULL } 00026 }; 00027 00028 Enum::tEnumValue OutControlSenderConfig::EMapping::sEnumValues[] = 00029 { 00030 { EMapping::eLinear, "Linear" }, 00031 { EMapping::eInverted, "Inverted" }, 00032 { EMapping::eLog, "Log" }, 00033 { EMapping::eReverseLog, "Reverse Log" }, 00034 { 0, NULL } 00035 }; 00036 00037 00038 Enum::tValue OutControlSenderConfig::EControlRepresentation::sDefault = 00039 OutControlSenderConfig::EControlRepresentation::eHorizontalSlider; 00040 00041 Enum::tValue OutControlSenderConfig::EMapping::sDefault = 00042 OutControlSenderConfig::EMapping::eLinear; 00043 00044 void OutControlSenderConfig::DefaultInit(void) 00045 { 00046 AddAll(); 00047 UpdateData(); 00048 SetMin( 0.0 ); 00049 SetDefault( 0.0 ); 00050 SetMax( 1.0 ); 00051 SetStep(1.0); 00052 } 00053 00054 OutControlSender::OutControlSender() 00055 : mOutput("out", this) 00056 , mFirstDoAfterStart(true) 00057 { 00058 OutControlSenderConfig cfg; 00059 Configure(cfg); 00060 } 00061 00062 OutControlSender::OutControlSender( const OutControlSenderConfig & cfg) 00063 : mOutput( "out", this ) 00064 , mFirstDoAfterStart(true) 00065 { 00066 Configure(cfg); 00067 } 00068 00069 00070 bool OutControlSender::ConcreteStart() 00071 { 00072 mFirstDoAfterStart=true; 00073 std::cout << "Start" << std::endl; 00074 return true; 00075 } 00076 00077 bool OutControlSender::Do() 00078 { 00079 if( !AbleToExecute() ) return true; 00080 if (mFirstDoAfterStart) 00081 { 00082 std::cout << "First do" << std::endl; 00083 mFirstDoAfterStart=false; 00084 mOutput.SendControl( mLastValue ); 00085 } 00086 return true; 00087 } 00088 00089 void OutControlSender::SendControl(TControlData value) 00090 { 00091 // TODO: Solve thread boundary here 00092 mLastValue=value; 00093 mOutput.SendControl( mLastValue ); 00094 } 00095 00096 bool OutControlSender::ConcreteConfigure(const ProcessingConfig& c) 00097 { 00098 CopyAsConcreteConfig(mConfig, c); 00099 if(mConfig.GetMin() > mConfig.GetMax() ) 00100 { 00101 AddConfigErrorMessage(" min value greater than max"); 00102 return false; 00103 } 00104 if((mConfig.GetDefault() > mConfig.GetMax()) || (mConfig.GetDefault() < mConfig.GetMin())) 00105 { 00106 AddConfigErrorMessage(" default value out of range"); 00107 return false; 00108 } 00109 if(mConfig.GetStep() == 0 ) 00110 { 00111 AddConfigErrorMessage(" step value equal to 0"); 00112 return false; 00113 } 00114 mLastValue = mConfig.GetDefault(); 00115 return true; 00116 } 00117 00118 } // namespace CLAM 00119 00120 00121