Exemple #1
0
//------------------------------------------------------------------------------
// Name: resume
// Desc:
//------------------------------------------------------------------------------
void DebuggerCore::resume(edb::EVENT_STATUS status) {
	// TODO: assert that we are paused

	if(attached()) {
		if(status != edb::DEBUG_STOP) {
			const edb::tid_t tid = active_thread();
			const int code = (status == edb::DEBUG_EXCEPTION_NOT_HANDLED) ? resume_code(threads_[tid].status) : 0;
			ptrace_continue(tid, code);

			// resume the other threads passing the signal they originally reported had
			for(auto it = threads_.begin(); it != threads_.end(); ++it) {
				if(waited_threads_.contains(it.key())) {
					ptrace_continue(it.key(), resume_code(it->status));
				}
			}
		}
	}
}
Exemple #2
0
void Text::recalcStyle(StyleChange change)
{
    if (change != NoChange && parentNode()) {
        if (renderer())
            renderer()->setStyle(parentNode()->renderer()->style());
    }
    if (changed()) {
        if (renderer()) {
            if (renderer()->isText())
                static_cast<RenderText*>(renderer())->setText(m_data);
        } else {
            if (attached())
                detach();
            attach();
        }
    }
    setChanged(NoStyleChange);
}
Exemple #3
0
void Text::recalcStyle(StyleChange change)
{
    if (change != NoChange && parentNode()) {
        if (renderer())
            renderer()->setStyle(parentNode()->renderer()->style());
    }
    if (needsStyleRecalc()) {
        if (renderer()) {
            if (renderer()->isText())
                toRenderText(renderer())->setText(m_data);
        } else {
            if (attached())
                detach();
            attach();
        }
    }
    setNeedsStyleRecalc(NoStyleChange);
}
//------------------------------------------------------------------------------
// Name: end_debug_session
// Desc: Ends debug session, detaching from or killing debuggee according to
//		 user preferences
//------------------------------------------------------------------------------
void DebuggerCoreBase::end_debug_session() {
	if(attached()) {
		switch(edb::v1::config().close_behavior)
		{
		case Configuration::Detach:
			detach();
			break;
		case Configuration::Kill:
			kill();
			break;
		case Configuration::KillIfLaunchedDetachIfAttached:
			if(last_means_of_capture()==MeansOfCapture::Launch)
				kill();
			else
				detach();
			break;
		}
	}
}
Exemple #5
0
///
/// \brief Writes a value to a servo instance on it's attached pin
/// \details This will start a pulse on the attached pin that will cause a servo to
///        to go to the angle respective to the give value unless it is a continuous rotation servo.
/// \param [in] value - the microseconds for the pulse to be on in a 20 ms period
///
void Servo::writeMicroseconds(int value)
{
    if (!attached())
    {
        ThrowError("Error when calling writeMicroseconds, servo is not attached.\n");
        return;
    }

    // validating that the value inputted is within the bounds of the min and max
    int alternateValue = value;
    if (value < _min)
    {
        alternateValue = _min;
    }
    else if (value > _max)
    {
        alternateValue = _max;
    }

    // Making the frequency 50 Hz which is equal to a 20ms period
    int frequency = (int)((double) 1 / ((double) REFRESH_INTERVAL / 1000000));
    
    // Validation of the pin to make sure PWM functionality is allowed
    if (!g_pins.verifyPinFunction(_attachedPin, FUNC_PWM, BoardPinsClass::NO_LOCK_CHANGE))
    {
        ThrowError("Error occurred verifying pin: %d function: PWM, Error: %08x", _attachedPin, GetLastError());
    }

    HRESULT hr = ERROR_SUCCESS;

    // Scale the duty cycle to the range used by the driver.
    // From 0-255 to 0-PWM_MAX_DUTYCYCLE, rounding to nearest value.
    ULONG dutyCycle = (ULONG) ((((double) alternateValue / REFRESH_INTERVAL * 255UL * PWM_MAX_DUTYCYCLE) + 127UL) / 255UL);

    // Prepare the pin for PWM use.
    if (!g_pins.setPwmDutyCycle(_attachedPin, (ULONG) dutyCycle))
    {
        ThrowError("Error occurred setting pin: %d PWM duty cycle to: %d, Error: %08x", _attachedPin, dutyCycle, GetLastError());
    }

    double servoIndexDouble = (double) (alternateValue - _min) / (_max - _min) * 180;
    _servoIndex = static_cast<uint8_t>(servoIndexDouble);
}
Exemple #6
0
//------------------------------------------------------------------------------
// Name: detach
// Desc:
//------------------------------------------------------------------------------
void DebuggerCore::detach() {
	if(attached()) {

		stop_threads();

		clear_breakpoints();

		for(edb::tid_t thread: thread_ids()) {
			if(ptrace(PTRACE_DETACH, thread, 0, 0) == 0) {
				native::waitpid(thread, 0, __WALL);
			}
		}
		
		delete process_;
		process_ = 0;

		reset();
	}
}
void
scrollable_widget_rep::scroll_event_ver (SI& y, SI& bef, SI& af) {
  abs_round (y);
  if ((y + y1() - oy) < ey1) y = ey1 - y1() + oy;
  if ((y + y2() - oy) > ey2) y = ey2 - y2() + oy;

  if (attached ()) {
    int dy= max (-h, min (h, y- scy));
    if ((dy>-h) && (dy<h) && (dy!=0)) {
      win->translate (x1(), y1(), x2(), y2(), 0, -dy);
    }
    if (dy>0) this << emit_invalidate (x1()-ox, y2()-oy-dy, x2()-ox, y2()-oy);
    if (dy<0) this << emit_invalidate (x1()-ox, y1()-oy, x2()-ox, y1()-oy-dy);
  }

  scy      = y;
  bef      = oy- y1();
  af       = y2()- oy;
  a[0]->oy = oy- scy;
}
                void SenionLabLocationManager::StartLocationUpdates()
                {
                	ASSERT_NATIVE_THREAD

					AndroidSafeNativeThreadAttachment attached(m_nativeState);
					JNIEnv* env = attached.envForThread;

					jmethodID startUpdatingLocation = env->GetMethodID(m_locationManagerClass,
																	   "startUpdatingLocation",
																	   "(Ljava/lang/String;Ljava/lang/String;)V");

					jstring apiKeyJString = env->NewStringUTF(m_apiKey.c_str());
					jstring apiSecretJString = env->NewStringUTF(m_apiSecret.c_str());
					env->CallVoidMethod(m_locationManagerInstance,
										startUpdatingLocation,
										apiKeyJString,
										apiSecretJString);
					env->DeleteLocalRef(apiKeyJString);
					env->DeleteLocalRef(apiSecretJString);
                }
Exemple #9
0
void CharacterData::setData(const String& data, ExceptionCode&)
{
    StringImpl* dataImpl = data.impl() ? data.impl() : StringImpl::empty();
    if (equal(m_data.get(), dataImpl))
        return;

    int oldLength = length();
    RefPtr<StringImpl> oldStr = m_data;
    m_data = dataImpl;
    
    if ((!renderer() || !rendererIsNeeded(renderer()->style())) && attached()) {
        detach();
        attach();
    } else if (renderer())
        static_cast<RenderText*>(renderer())->setText(m_data);
    
    dispatchModifiedEvent(oldStr.get());
    
    document()->textRemoved(this, 0, oldLength);
}
            jobjectArray SearchResultPoiView::CreateJavaArray(const std::vector<std::string>& stringVector)
            {
            	AndroidSafeNativeThreadAttachment attached(m_nativeState);
            	JNIEnv* env = attached.envForThread;

            	jobjectArray jniStringArray = env->NewObjectArray(
            			stringVector.size(),
						env->FindClass("java/lang/String"),
						0
            	);

            	for(size_t i = 0; i < stringVector.size(); ++ i)
            	{
            		jstring jniString = env->NewStringUTF(stringVector[i].c_str());
            		env->SetObjectArrayElement(jniStringArray, i, jniString);
            		env->DeleteLocalRef(jniString);
            	}

            	return jniStringArray;
            }
void
scrollable_widget_rep::scroll_event_hor (SI& x, SI& bef, SI& af) {
  abs_round (x);
  if ((x + x1() - ox) < ex1) x = ex1 - x1() + ox;
  if ((x + x2() - ox) > ex2) x = ex2 - x2() + ox;

  if (attached ()) {
    int dx= max (-w, min (w, x- scx));
    if ((dx>-w) && (dx<w) && (dx!=0)) {
      win->translate (x1(), y1(), x2(), y2(), -dx, 0);
    }
    if (dx>0) this << emit_invalidate (x2()-ox-dx, y1()-oy, x2()-ox, y2()-oy);
    if (dx<0) this << emit_invalidate (x1()-ox, y1()-oy, x1()-ox-dx, y2()-oy);
  }

  scx      = x;
  bef      = ox- x1();
  af       = x2()- ox;
  a[0]->ox = ox- scx;
}
//------------------------------------------------------------------------------
// Name: write_byte_base
// Desc: the base implementation of writing a byte
//------------------------------------------------------------------------------
void DebuggerCoreUNIX::write_byte_base(edb::address_t address, quint8 value, bool *ok) {
	// TODO: assert that we are paused

	Q_ASSERT(ok);

	*ok = false;
	if(attached()) {
		long v;
		long mask;
		// page_size() - 1 will always be 0xf* because pagesizes
		// are always 0x10*, so the masking works
		// range of a is [1..n] where n=pagesize, and we have to adjust
		// if a < wordsize
		const edb::address_t a = page_size() - (address & (page_size() - 1));

		v = value;
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
		if(a < EDB_WORDSIZE) {
			address -= (EDB_WORDSIZE - a);                       // LE + BE
			mask = ~(0xffUL << (CHAR_BIT * (EDB_WORDSIZE - a))); // LE
			v <<= CHAR_BIT * (EDB_WORDSIZE - a);                 // LE
		} else {
			mask = ~0xffUL; // LE
		}
#else /* BIG ENDIAN */
		if(a < EDB_WORDSIZE) {
			address -= (EDB_WORDSIZE - a);            // LE + BE
			mask = ~(0xffUL << (CHAR_BIT * (a - 1))); // BE
			v <<= CHAR_BIT * (a - 1);                 // BE
		} else {
			mask = ~(0xffUL << (CHAR_BIT * (EDB_WORDSIZE - 1))); // BE
			v <<= CHAR_BIT * (EDB_WORDSIZE - 1);                 // BE
		}
#endif

		v |= (read_data(address, ok) & mask);
		if(*ok) {
			*ok = write_data(address, v);
		}
	}
}
void HTMLFormControlElement::attach()
{
    ASSERT(!attached());

    suspendPostAttachCallbacks();

    HTMLElement::attach();

    // The call to updateFromElement() needs to go after the call through
    // to the base class's attach() because that can sometimes do a close
    // on the renderer.
    if (renderer())
        renderer()->updateFromElement();

    if (shouldAutofocus(this)) {
        ref();
        queuePostAttachCallback(focusPostAttach, this);
    }

    resumePostAttachCallbacks();
}
BOOL CSE_ALifeItem::Net_Relevant			()
{
	if (inherited1::Net_Relevant())
		return					(TRUE);

	if (inherited2::Net_Relevant())
		return					(TRUE);

	if (attached())
		return					(FALSE);

	if (!m_physics_disabled && !fis_zero(State.linear_vel.square_magnitude(),EPS_L))
		return					(TRUE);

#ifdef XRGAME_EXPORTS
//	if (Device.dwTimeGlobal < (m_last_update_time + update_rate()))
//		return					(FALSE);
#endif // XRGAME_EXPORTS

	return						(FALSE);
}
Exemple #15
0
void SM5100B::loop() {
  while(serial.available()) {
    read_line();
    if(strncmp(buffer,(const char*) F("+SIND: "),7)==0) {
      int status = -1;
      if(isDigit(buffer[7]) && isDigit(buffer[8])) {
        char a[3] = {buffer[7],buffer[8],0};
        status = atoi(a);
      } else if(isDigit(buffer[7])) {
        status = buffer[7] - '0';
      }
      Serial.print(F("Status "));
      Serial.println(status);
      switch(status) {
        case SM_NETWORK_REGISTERED:
        case SM_NETWORK_LOST:
          _network_state = status;
          break;
        case SM_SMS_READY:
          _phone_state = status;
          _lastAutoconnect = millis() + 1000;
          break;
      }
    } else if(buffer[0] == (char)160 && buffer[0] == buffer[1] &&
              buffer[0] == buffer[2] && buffer[0] == buffer[3]) {
      // PASS
    } else {
      Serial.print(F("Unknown line:"));
      Serial.println(buffer);
    }
  }
  if(_gprs_state!=1 && autoconnect && _phone_state==SM_SMS_READY && _lastAutoconnect + 10000 < millis()) {
    _lastAutoconnect = millis();
    if(attached()) {
      if(attach_gprs()==0) {
        _gprs_state=1;
      }
    }
  }
}
    void PinsWithAttachedJavaUIExample::Draw()
    {
    	//lazily create the pin button when we start drawing so it is not displayed on top of the loading screen
		if(m_world.Initialising()) {
			return;
		}
		else if(m_buttonID == 0) {
			CreateJavaUIButton();
		}

		AndroidSafeNativeThreadAttachment attached(m_nativeState);
		JNIEnv* env = attached.envForThread;

		Eegeo_ASSERT(m_buttonID != 0);

		// Get the pin position on the screen
		Eegeo::Pins::PinRepository& pinRepo = m_pPinsModule->GetRepository();
		Eegeo::Pins::Pin* pPin = pinRepo.GetPinAtIndex(0);
		Eegeo_ASSERT(pPin != NULL);

		Eegeo::Pins::PinController& pinController = m_pPinsModule->GetController();
		Eegeo::Geometry::Bounds2D pinScreenBounds = Eegeo::Geometry::Bounds2D::Empty();
		pinController.GetScreenBoundsForPin(*pPin, pinScreenBounds);
		Eegeo::v2 screenPosition = pinScreenBounds.center();

		// now update the java ui to be in sync with the pin, positioned above it on screen.
		// the pixel nudging is hard-coded for simplicity; you should probably do something more sophisticated
		// (based on the size of your pin & java ui assets)
		const int buttonOffsetPixelsX = 40;
		const int buttonOffsetPixelsY = 110;

		env->CallVoidMethod(
			m_hudPinController,
			m_updateLocationMethodId,
			m_buttonID,
			screenPosition.GetX() - buttonOffsetPixelsX,
			screenPosition.GetY() - buttonOffsetPixelsY
		);
    }
/*!
    \qmlproperty Plugin Category::plugin

    This property holds the location based service to which the category belongs.
*/
void QDeclarativeCategory::setPlugin(QDeclarativeGeoServiceProvider *plugin)
{
    if (m_plugin == plugin)
        return;

    m_plugin = plugin;
    if (m_complete)
        emit pluginChanged();

    if (m_icon && m_icon->parent() == this && !m_icon->plugin())
        m_icon->setPlugin(m_plugin);

    if (!m_plugin)
        return;

    if (m_plugin->isAttached()) {
        pluginReady();
    } else {
        connect(m_plugin, SIGNAL(attached()),
                this, SLOT(pluginReady()));
    }
}
Exemple #18
0
void CharacterData::insertData(unsigned offset, const String& arg, ExceptionCode& ec)
{
    checkCharDataOperation(offset, ec);
    if (ec)
        return;

    String newStr = m_data;
    newStr.insert(arg, offset);

    RefPtr<StringImpl> oldStr = m_data;
    m_data = newStr.impl();

    if ((!renderer() || !rendererIsNeeded(renderer()->style())) && attached()) {
        detach();
        attach();
    } else if (renderer())
        static_cast<RenderText*>(renderer())->setTextWithOffset(m_data, offset, 0);

    dispatchModifiedEvent(oldStr.get());
    
    document()->textInserted(this, offset, arg.length());
}
///
/// \brief Writes a value to a servo instance on it's attached pin
/// \details This will start a pulse on the attached pin that will cause a servo to
///        to go to the angle respective to the give value unless it is a continuous rotation servo.
/// \param [in] value - the microseconds for the pulse to be on in a 20 ms period
///
void Servo::writeMicroseconds(int value)
{
    ULONGLONG pulseMicroseconds;
    ULONG dutyCycle;
    HRESULT hr;

    if (!attached())
    {
        ThrowError(HRESULT_FROM_WIN32(ERROR_INVALID_STATE), "Error when calling writeMicroseconds, servo is not attached.");
        return;
    }

    // Limit the pulse microseconds to the range previously specifed as the min and max.
    if (value < _min)
    {
        pulseMicroseconds = _min;
    }
    else if (value > _max)
    {
        pulseMicroseconds = _max;
    }
    else
    {
        pulseMicroseconds = value;
    }

    // Scale the duty cycle to the range used by the driver (0-0xFFFFFFFF)
    dutyCycle = (ULONG)(((pulseMicroseconds * 0xFFFFFFFFLL) + (ULONGLONG)(_actualPeriodMicroseconds / 2)) / ((ULONGLONG)_actualPeriodMicroseconds));

    // Prepare the pin for PWM use.
    hr = g_pins.setPwmDutyCycle(_attachedPin, (ULONG)dutyCycle);
    if (FAILED(hr))
    {
        ThrowError(hr, "Error occurred setting pin: %d PWM duty cycle to: %d, Error: %08x", _attachedPin, dutyCycle, hr);
    }

    // Record the currently set pulse time in microseconds.
    _currentPulseMicroseconds = (ULONG)pulseMicroseconds;
}
Exemple #20
0
void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
{
    NodeVector children;
    getChildNodes(oldParent, children);
    oldParent->removeAllChildren();

    for (unsigned i = 0; i < children.size(); ++i) {
        ExceptionCode ec = 0;
        if (children[i]->attached())
            children[i]->detach();
        // FIXME: We need a no mutation event version of adoptNode.
        RefPtr<Node> child = document()->adoptNode(children[i].release(), ec);
        ASSERT(!ec);
        parserAppendChild(child.get());
        // FIXME: Together with adoptNode above, the tree scope might get updated recursively twice
        // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree).
        // Can we do better?
        treeScope()->adoptIfNeeded(child.get());
        if (attached() && !child->attached())
            child->attach();
    }
}
Exemple #21
0
void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName)
{
    SVGStyledTransformableElement::svgAttributeChanged(attrName);

    if (!attached())
        return;

    if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
        attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr ||
        SVGTests::isKnownAttribute(attrName) ||
        SVGLangSpace::isKnownAttribute(attrName) ||
        SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
        SVGURIReference::isKnownAttribute(attrName) ||
        SVGStyledTransformableElement::isKnownAttribute(attrName)) {
        // TODO: Now that we're aware of the attribute name, we can finally optimize
        // updating <use> attributes - to not reclone every time.
        buildPendingResource();

        if (m_shadowTreeRootElement)
            m_shadowTreeRootElement->setChanged();
    }
}
//------------------------------------------------------------------------------
// Name: set_state
// Desc:
//------------------------------------------------------------------------------
void DebuggerCore::set_state(const State &state) {

	// TODO: assert that we are paused


	if(attached()) {

		if(auto state_impl = static_cast<PlatformState *>(state.impl_)) {
			bool setRegSetDone=false;
			if(EDB_IS_32_BIT && state_impl->is64Bit()) {
				// Try to set 64-bit state
				PrStatus_X86_64 prstat64;
				state_impl->fillStruct(prstat64);
				iovec prstat_iov = {&prstat64, sizeof(prstat64)};
				if(ptrace(PTRACE_SETREGSET, active_thread_, NT_PRSTATUS, &prstat_iov) != -1)
					setRegSetDone=true;
				else
					perror("PTRACE_SETREGSET failed");
			}
			// Fallback to setting 32-bit set
			if(!setRegSetDone) {
				user_regs_struct regs;
				state_impl->fillStruct(regs);
				ptrace(PTRACE_SETREGS, active_thread_, 0, &regs);
			}

			// debug registers
			for(std::size_t i=0;i<8;++i)
				set_debug_register(i,state_impl->x86.dbgRegs[i]);

			// FPU registers
			user_fpregs_struct fpregs;
			state_impl->fillStruct(fpregs);
			if(ptrace(PTRACE_SETFPREGS, active_thread_, 0, &fpregs)==-1)
				perror("PTRACE_SETFPREGS failed");
		}
	}
}
Exemple #23
0
///
/// \brief Writes a value to a servo instance on it's attached pin
/// \details This will start a pulse on the attached pin that will cause a servo to
///        to go to the given angle unless it is a continuous rotation servo.
/// \param [in] value - the angle for the servo to turn to
///
void Servo::write(int value)
{
    if (!attached())
    {
        ThrowError("Error when calling write, servo is not attached.\n");
        return;
    }

    // value is in angles and needs to be converted to microSeconds
    if (value <= 0)
    {
        writeMicroseconds(_min);
    }
    else if (value >= 180)
    {
        writeMicroseconds(_max);
    }
    else
    {
        double alternateValue = (double) value / 180 * (_max - _min) + _min;
        writeMicroseconds((int) alternateValue);
    }
}
Exemple #24
0
bool NetDBase::attach( const std::string & name )
{
  
  if ( name == "-" || name == "." ) { dettach(); return false; } 
  
  //if ( Helper::fileExists( name ) ) { sql.open( name ); return true; }
  
  if ( attached() ) dettach();  

  sql.open( name );   

  // Create database

  sql.synchronous(false);
  
  // Edge table ( double-enter n1-n2 and n2-n1 )
  
  sql.query(" CREATE TABLE IF NOT EXISTS edges("
	    "   node1_id   INTEGER , "
	    "   node2_id   INTEGER , "	      
	    "   score      REAL ) ; " );
  
  sql.query( "CREATE TABLE IF NOT EXISTS nodes("
	     "  node_id    INTEGER PRIMARY KEY , " 
	     "  name       VARCHAR(12) ); " );
  
  // Indices
  index();
  
  stmt_insert_node = sql.prepare( " INSERT OR REPLACE INTO nodes( name ) values( :name ); " ); 
  stmt_fetch_node  = sql.prepare( " SELECT node_id FROM nodes WHERE name == :name ; " );
  stmt_insert_edge = sql.prepare( " INSERT OR REPLACE INTO edges( node1_id , node2_id , score ) values( :n1 , :n2 , :score ); " );
  stmt_fetch_connections = sql.prepare( " SELECT name FROM nodes WHERE node_id IN ( SELECT node2_id FROM edges WHERE node1_id == :n ) ; " );

  return true;

}
            MyPinCreationInitiationView::MyPinCreationInitiationView(AndroidNativeState& nativeState)
                : m_nativeState(nativeState)
            {
                ASSERT_UI_THREAD

                AndroidSafeNativeThreadAttachment attached(m_nativeState);
                JNIEnv* env = attached.envForThread;

                jstring strClassName = env->NewStringUTF("com.eegeo.mypincreation.MyPinCreationButtonView");
                jclass uiClass = m_nativeState.LoadClass(env, strClassName);
                env->DeleteLocalRef(strClassName);

                m_uiViewClass = static_cast<jclass>(env->NewGlobalRef(uiClass));
                jmethodID uiViewCtor = env->GetMethodID(m_uiViewClass, "<init>", "(Lcom/eegeo/entrypointinfrastructure/MainActivity;J)V");

                jobject instance = env->NewObject(
                                       m_uiViewClass,
                                       uiViewCtor,
                                       m_nativeState.activity,
                                       (jlong)(this)
                                   );

                m_uiView = env->NewGlobalRef(instance);
            }
//------------------------------------------------------------------------------
// Name: clear_breakpoints
// Desc: removes all breakpoints
//------------------------------------------------------------------------------
void DebuggerCoreBase::clear_breakpoints() {
	if(attached()) {
		breakpoints_.clear();
	}
}
void CharacterData::updateRenderer(unsigned offsetOfReplacedData, unsigned lengthOfReplacedData)
{
    if ((!renderer() || !rendererIsNeeded(NodeRenderingContext(this, renderer()->style()))) && attached())
        reattach();
    else if (renderer())
        toRenderText(renderer())->setTextWithOffset(m_data.impl(), offsetOfReplacedData, lengthOfReplacedData);
}
Exemple #28
0
bool Foam::twoStrokeEngine::update()
{
    // Detaching the interface
    if (attached())
    {
        Info << "Decoupling sliding interfaces" << endl;
        makeSlidersLive();

        // Changing topology by hand
        autoPtr<mapPolyMesh> topoChangeMap5 = topoChanger_.changeMesh();

        if (topoChangeMap5->hasMotionPoints() && topoChangeMap5->morphing())
        {
            Info << "Topology change; executing pre-motion after "
                << "sliding detach" << endl;
            movePoints(topoChangeMap5->preMotionPoints());
        }

        Info << "sliding interfaces successfully decoupled!!!" << endl;
    }
    else
    {
        Info << "Sliding interfaces decoupled" << endl;
    }

    Info << "Executing layer action" << endl;

    // Piston Layering

    makeLayersLive();
    // Changing topology by hand


// /* Tommaso, 23/5/2008

    // Find piston mesh modifier
    const label pistonLayerID =
        topoChanger_.findModifierID("pistonLayer");

    if (pistonLayerID < 0)
    {
        FatalErrorIn("void engineFvMesh::moveAndMorph()")
            << "Piston modifier not found."
            << abort(FatalError);
    }

    scalar minLayerThickness = piston().minLayer();
    scalar deltaZ = engTime().pistonDisplacement().value();
    virtualPistonPosition() += deltaZ;

    Info << "virtualPistonPosition = " << virtualPistonPosition()
    << ", deckHeight = " << deckHeight()
    << ", pistonPosition = " << pistonPosition() << endl;

    if (realDeformation())
    {
        // Dectivate piston layer
        Info << "Mesh deformation mode" << endl;
        topoChanger_[pistonLayerID].disable();
    }
    else
    {
        // Activate piston layer
        Info << "Piston layering mode" << endl;
        topoChanger_[pistonLayerID].enable();
    }


    // Changing topology by hand
    autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh();

    // Work array for new points position.
    pointField newPoints = allPoints();
    const pointField& refPoints = allPoints();

    if (topoChangeMap->morphing())
    {
        if (topoChangeMap->hasMotionPoints())
        {
            Info<< "Topology change; executing pre-motion after "
                << "dynamic layering" << endl;
            movePoints(topoChangeMap->preMotionPoints());
            newPoints = topoChangeMap->preMotionPoints();
        }

        setV0();
        resetMotion();
    }

    // Reset the position of layered interfaces

    boolList scaleDisp(nPoints(), true);

    boolList pistonPoint(newPoints.size(), false);
    boolList headPoint(newPoints.size(), false);

    // Make a list of piston and head points. HJ, 2/Dec/2009

    labelList pistonPoints;
    labelList headPoints;
    {
        label pistonCellIndex = cellZones().findZoneID("pistonCells");

        if (pistonCellIndex < 0)
        {
            FatalErrorIn("bool twoStrokeEngine::update()")
                << "Cannot find cell zone pistonCells"
                << abort(FatalError);
        }


        const labelList& pistonCells = cellZones()[pistonCellIndex];

        label headCellIndex = cellZones().findZoneID("headCells");

        if (headCellIndex < 0)
        {
            FatalErrorIn("bool twoStrokeEngine::update()")
                << "Cannot find cell zone headCells"
                << abort(FatalError);
        }

        const labelList& headCells = cellZones()[headCellIndex];

        const labelListList& cp = cellPoints();

        boolList count(newPoints.size(), false);

        forAll (pistonCells, cellI)
        {
            const labelList& curCellPoints = cp[pistonCells[cellI]];

            forAll (curCellPoints, i)
            {
                count[curCellPoints[i]] = true;
            }
        }

        // Count the points
        label nCounted = 0;
        forAll (count, pointI)
        {
            if (count[pointI] == true)
            {
                nCounted++;
            }
        }

        pistonPoints.setSize(nCounted);

        // Collect the points
        nCounted = 0;
        forAll (count, pointI)
        {
            if (count[pointI] == true)
            {
                pistonPoints[nCounted] = pointI;
                nCounted++;
            }
        }

        // Repeat for head points
        count = false;

        forAll (headCells, cellI)
        {
            const labelList& curCellPoints = cp[pistonCells[cellI]];

            forAll (curCellPoints, i)
            {
                count[curCellPoints[i]] = true;
            }
        }

        // Count the points
        nCounted = 0;
        forAll (count, pointI)
        {
            if (count[pointI] == true)
            {
                nCounted++;
            }
        }

        headPoints.setSize(nCounted);

        // Collect the points
        nCounted = 0;
        forAll (count, pointI)
        {
            if (count[pointI] == true)
            {
                headPoints[nCounted] = pointI;
                nCounted++;
            }
        }
    }


    label nScaled = nPoints();

//     label pistonPtsIndex = pointZones().findZoneID("pistonPoints");
//     const labelList& pistonPoints = pointZones()[pistonPtsIndex];

//     label headPtsIndex = pointZones().findZoneID("headPoints");
//     const labelList& headPoints = pointZones()[headPtsIndex];

    const scalarField& movingPointsM = movingPointsMask();

    forAll(pistonPoints, i)
    {
        label pointI = pistonPoints[i];
        pistonPoint[pointI] = true;
        point& p = newPoints[pointI];

        if (p.z() < pistonPosition() - 1.0e-6)
        {
            scaleDisp[pointI] = false;
            nScaled--;
        }
    }
Exemple #29
0
IC	void CObjectHandler::switch_torch	(CInventoryItem *inventory_item, bool value)
{
	CTorch						*torch = smart_cast<CTorch*>(inventory_item);
	if (torch && attached(torch) && planner().object().g_Alive())
		torch->Switch			(value);
}
Exemple #30
0
/*
 * Read the message from the rtdServer and call a virtual method to
 * display the image and evaluate the tcl event scripts.
 */
int RtdCamera::fileEvent()
{
    Mem mem;
    rtdIMAGE_INFO info;
    int stat;

    memset(&info, '\0', sizeof(rtdIMAGE_INFO));
    info.semId = info.shmNum = -1;

    stat = rtdRecvImageInfo(eventHndl_, &info, verbose_, buffer_);

    semId_  = info.semId;
    shmNum_ = info.shmNum;

    if (stat != RTD_OK || checkType(info.dataType) != RTD_OK || 
	info.xPixels <=0 || info.yPixels <= 0) {
	checkStat();
	return TCL_ERROR;
    }
    
    if ( ! attached()) {
	semDecr();
	return TCL_OK;
    }

    /*
     * class Mem takes care of possible reusing previous shared memory areas 
     * and cleanup. Choose the constructor depending on whether the 
     * semaphore fields of the image info have been set.
     */
    int bytes = info.xPixels * info.yPixels * (abs(info.dataType) / 8);
    if (semId_ > 0)
	mem = Mem(bytes, info.shmId, 0, verbose_, shmNum_, semId_);
    else
	mem = Mem(bytes, info.shmId, 0, verbose_);
    
    if (mem.status() != 0) {
	checkStat();
	return TCL_ERROR;
    }

    dbl_->log("image event: Id=%d, x=%d, y=%d, width=%d, height=%d, "
	      "shmId=%d shmNum=%d semId=%d\n",
	      info.frameId, info.frameX, info.frameY, info.xPixels, info.yPixels, 
	      info.shmId, shmNum_, semId_);

    /*
     * before displaying the image delete the file handler. This blocks
     * new image events which must not be handled between camera pre/post commands.
     */
    fileHandler(0);

    // call the virtual method in a derived class to display the image
    int disperr = display(info, mem);

    // re-install the file handler
    fileHandler(1);

    // finally decrement the semaphore
    semDecr();
    return disperr;
}