void masterPanelCell::textChanged() { if(myType==0&&text().toDouble()-previousValue>0.01) sendNewValue(myNode,paraName,text().toDouble(),previousValue); }
tResult cSimpleFusion::OnPinEvent( IPin *pSource, tInt nEventCode, tInt nParam1, tInt nParam2, IMediaSample *pMediaSample) { RETURN_IF_POINTER_NULL(pMediaSample); RETURN_IF_POINTER_NULL(pSource); if (nEventCode == IPinEventSink::PE_MediaSampleReceived) { tFloat32 signalValue = 0; tUInt32 timeStamp = 0; m_nLastMSTime = pMediaSample->GetTime(); if (pMediaSample != NULL && m_pCoderDescSignalInput != NULL) { // read-out the incoming Media Sample cObjectPtr<IMediaCoder> pCoderInput; RETURN_IF_FAILED(m_pCoderDescSignalInput->Lock(pMediaSample, &pCoderInput)); //get values from media sample and sets it on signalValue / timeStamp pCoderInput->Get("f32Value", (tVoid*)&signalValue); pCoderInput->Get("ui32ArduinoTimestamp", (tVoid*)&timeStamp); m_pCoderDescSignalInput->Unlock(pCoderInput); } else RETURN_ERROR(ERR_FAILED); // do stuff for the IR-longrange sensor if (pSource == &m_ir_long_in) { //Do not iterate if the input pin is deactivated but connected if(stateOfLongeRangeInputPin != 1) { RETURN_NOERROR; } //Schwellwerte für ir long range if (signalValue < thresholdIRLongRange) { last_ir_long_input = signalValue; sigma_vector.push_back((tFloat32)20.0); // kürzesten Wert ausgeben zw. 20 } // Ausreißer else if(abs(int(last_ir_long_input - tUInt32(signalValue))) > 30) { //Ausreißer Statistisch auswerten ob es wirklich ein Ausreißer ist last_ir_long_input = signalValue; last_ir_long_oor = true; //sigma_vector.push_back(); RETURN_NOERROR; } else { last_ir_long_input = signalValue; // add every iteration the signalValue into the vector sigma_vector.push_back(signalValue); } } //Do not iterate if the input pin is deactivated but connected else if(pSource == &m_ir_short_in1 && stateOfShortRangeInputPin1 != 1) { RETURN_NOERROR; } //Do not iterate if the input pin is deactivated but connected else if(pSource == &m_ir_short_in2 && stateOfShortRangeInputPin2 != 1) { RETURN_NOERROR; } // do stuff for the IR-shortrange sensor else if (pSource == &m_ir_short_in1 || pSource == &m_ir_short_in2) { // Schwellwert von short range einhalten if (signalValue < thresholdIRShortRange) { last_ir_short_input = signalValue; last_ir_short_oor = true; sigma_vector.push_back((tFloat32)8.0);// kürzesten Wert ausgeben 8 } // Ausreißer else if(abs(int(last_ir_short_input - tUInt32(signalValue))) > 30) { //Ausreißer...todo: Statistisch auswerten ob es wirklich ein Ausreißer ist last_ir_short_input = signalValue; last_ir_short_oor = true; RETURN_NOERROR; } else { last_ir_short_input = signalValue; sigma_vector.push_back(signalValue); } } //Do not iterate if the input pin is deactivated but connected else if(pSource == &m_us_left_in && stateOfUSLeftInputPin != 1) { RETURN_NOERROR; } //Do not iterate if the input pin is deactivated but connected else if(pSource == &m_us_right_in && stateOfUSRightInputPin != 1) { RETURN_NOERROR; } // do stuff for the Ultrasonic sensors(left||right) else if(pSource == &m_us_left_in || pSource == &m_us_right_in) { //Setion für Schwellwerte für US if(signalValue < thresholdUS && pSource == &m_us_left_in ) { last_us_left_input = signalValue; sigma_vector.push_back((tFloat32)thresholdUS); // kürzesten Wert ausgeben last_us_left_oor = true; } else if(signalValue < thresholdUS && pSource == &m_us_right_in) { last_us_right_input = signalValue; sigma_vector.push_back((tFloat32)thresholdUS); // kürzesten Wert ausgeben last_us_right_oor = true; } else { sigma_vector.push_back(signalValue); } } //decrement everytime a signalValue comes in sigma_iterations++; //send the median value from the sigma_vector to the output if(sigma_iterations == lengthOfMedianVector && sigma_vector.capacity() != 0) { sort(sigma_vector.begin(),sigma_vector.end()); sigma_Value = sigma_vector.at(median-1); //LOG_INFO(cString::Format("%f",sigma_Value)); sendNewValue(sigma_Value); sigma_vector.clear(); sigma_iterations = 0; } } else { sendNewValue(0); } RETURN_NOERROR; }
void Slider::updateView(float mouseData[2], int clickType, wchar_t keyChar, vector<string> eventCompList) { if (getVisible()) { float transparency = getTransparency(); if ((getFocusEffect() == true) && (getMouseOverContainer() == true)) transparency = 1.0f; if (!getMouseOverContainer()) slide = false; if (!getEnabled()) { setActualTex(getDisabledTex()); } else { if ((slide || isMouseOver(mouseData) || button->isMouseOver(mouseData))&&getMouseOverContainer()) setActualTex(getHighlightTex()); else { setActualTex(getNormalTex()); //slide = false; } } if (clickType == 1 && (isMouseOver(mouseData) || button->isMouseOver(mouseData))) { slide = true; } if ((clickType == -1) && (slide)) { slide = false; } if (slide) { if (horizontal) { float step = getWidth()/((getMaxValue()-getMinValue())/getValueStep()); if (mouseData[0] >= button->getPosX()+step) { if (setPosition(getPosition()+getValueStep())) sendNewValue(getPosition(), eventCompList); } if (mouseData[0] <= button->getPosX()-step) { if (setPosition(getPosition()-getValueStep())) sendNewValue(getPosition(), eventCompList); } } else { float step = getHeight()/((getMaxValue()-getMinValue())/getValueStep()); if (mouseData[1] <= button->getPosY()-step) { if (setPosition(getPosition()+getValueStep())) sendNewValue(getPosition(), eventCompList); } if (mouseData[1] >= button->getPosY()+step) { if (setPosition(getPosition()-getValueStep())) sendNewValue(getPosition(), eventCompList); } } } float posX = getPosX(); float posY = getPosY(); float height = getHeight(); float width = getWidth(); float vals[] = {posX, posY, 0, 1, posX, posY+height, 0, 0, posX+width, posY+height, 1, 0, posX+width, posY, 1, 1 }; h3dShowOverlays(vals, 4,1, 1, 1, transparency,getActualTex(), 0 ); if (slide) { button->setMouseOverIsTrue(true); button->updateView(mouseData,1,keyChar,eventCompList); } else { button->setMouseOverIsTrue(false); button->updateView(mouseData,clickType,keyChar,eventCompList); } } }