Ejemplo n.º 1
0
/*!
    Adjusts preCondition to \a preCondition.
 */
void QUmlProtocolTransition::setPreCondition(QUmlConstraint *preCondition)
{
    // This is a read-write association end

    if (_preCondition != preCondition) {
        // Adjust subsetted properties

        _preCondition = preCondition;
        if (preCondition && preCondition->asQModelingObject() && this->asQModelingObject())
            QObject::connect(preCondition->asQModelingObject(), SIGNAL(destroyed()), this->asQModelingObject(), SLOT(setPreCondition()));
        preCondition->asQModelingObject()->setParent(this->asQModelingObject());

        // Adjust subsetted properties
        setGuard(preCondition);
    }
}
Ejemplo n.º 2
0
void Kicker::process() {
	// do sensors imply that the state should end?
	bool sensor_end;

	switch (state) {
	case kKickInactive:
		turnKicker(0.0);
		setGuard(false);
		break;
	case kKickOpenGuard:
		printf("OPENING GUARDS\n");
		turnKicker(0.0);
		// guardsSet could be true iff the controls previously set it true
		if (timer.Get() > OPEN_GUARD_TIME || guardsSet) {
			printf("Guards satisfactory at %f with guards %c\n", timer.Get(),
					guardsSet ? 'T' : 'F');
			timer.Reset();
			timer.Start();
			state = kKickWaitForIntake;
		}
		setGuard(true);
		break;
	case kKickWaitForIntake:
		printf("WAITING for INTAKE\n");
		turnKicker(0.0);
		setGuard(true);
		if (timer.Get() > INTAKE_WAIT_TIME || intake.isRaised()
				|| sensorsBroken) {
			printf("INTAKE wait was %f\n", timer.Get());
			timer.Reset();
			timer.Start();
			state = kKickSpinning;
		}
		break;
	case kKickSpinning:
		// these two can be broken
		bool d_encoder = kicker_encoder.Get() >= ENCODER_HIGH_LIMIT;

		// guaranteed to work ;-)
		bool d_highflag = getHighFlag();
		bool d_timer = timer.Get() > SAFETY_WAIT_TIME;

		sensor_end = d_encoder;

		if ((sensor_end && !sensorsBroken) || d_highflag || d_timer) {
			timer.Reset();
			timer.Start();
			turnKicker(0.0);
			state = kKickStopping;
			low_counter.Reset();
			low_counter.Start();
			setGuard(false);
			kickPostMortem();
			printf("ENC: %d >= %.0f\n", (int) kicker_encoder.Get(),
					ENCODER_HIGH_LIMIT);
			printf("END: encoder %d; high flag %d; timer %d\n", d_encoder,
					d_highflag, d_timer);
		} else {
			printf("SPINNING %f with intake at %f\n", startKickPower,
					intake.getLocation());
			turnKicker(startKickPower);
			setGuard(true);
		}
		break;
	case kKickStopping:
		turnKicker(0.0);
		setGuard(false);
		if (timer.Get() > STOP_TIME) {
			timer.Reset();
			timer.Start();
			state = kKickResetting;
		}
		break;
	case kKickResetting:
		setGuard(false);

		sensor_end = low_counter.Get() != 0;
		if (timer.Get() > RESET_SAFETY_TIME || (sensor_end && !sensorsBroken)) {
			printf("On reset conclusion: encoder at %d; beam at %c\n",
					(int) kicker_encoder.Get(), sensor_end ? 'T' : 'F');
			turnKicker(0.0); //stop the kicker
			kicker_encoder.Reset();
			kicker_encoder.Start();
			timer.Reset();
			timer.Start();
			state = kKickInactive;
		} else {
			turnKicker(-KICKER_RESET_SPEED);
		}

		break;
	}

	processGuard();
}