void home(UINT8 axis)
	{
		switch(homing_state[axis])
		{
			case homed:
				return;
			break;
			case start:
				set_position(axis, park_position[axis], 0.3, -0.3);
				homing_state[axis] = moving_to_park_dly;
				dly_tmr = 1;
			break;
			case moving_to_park_dly:
				if (delay_passed())
					homing_state[axis] = moving_to_park;
			break;
			case moving_to_park:
				if (at_position(axis))
					homing_state[axis] = parked;
				if (stalled(axis))
					homing_state[axis] = parked;
			break;
			case parked:
				if (axis != elevator)
					set_position(axis, -20, 0.3, -0.3); // drive to mechanical stop
				else
					set_position(axis, -20, 0.3, -0.3, 8); // drive to mechanical stop (limited)
				
				dly_tmr = 0.8;
				homing_state[axis] = moving_to_stops_dly;
			break;
			case moving_to_stops_dly:
				if (delay_passed())
					homing_state[axis] = moving_to_stops;
			break;
			case moving_to_stops:
				if (stalled(axis), 0.01)
					homing_state[axis] = at_home;
			break;
			case at_home:
				pot_offset[axis] = pot_in[axis];
				set_position(axis, park_position[axis], 0.3, -0.3);
				homing_state[axis] = homed_parking;
			break;
			case homed_parking:
				if (at_position(axis))
					homing_state[axis] = homed;
			break;
		}
	}
示例#2
0
void Server::serverThreadStalled( ServerConnection* connection, bool isStalled )
{
    if( isStalled )
        emit stalled(connection);
    else
        emit unstalled(connection);
}
示例#3
0
void BlinkerMac::recv(const uint8_t c)
{
    digitalWrite(13, blink());

    // if you haven't gotten a byte in a while, then what you have
    // is probably garbage.
    if (packet_in_progress && stalled()) {
        debug("aborting rcv");
        IRFrame::hexdump(buf);
        reset();
        return;
    }
    if (!packet_in_progress) {
        packet_in_progress = prefix_hit(c);
        last_rx_time = millis();
        return; //the next byte should be the first byte of a packet
    }

    debugstart("%d", buf_pos);
    debugcont(" ");
    //geting a packet
    uint8_t input;
    if (decode_byte(c, input)) {
        buf->blob()[buf_pos] = input;
        buf_pos++;
    } else {
        return; // was a stuffed byte
    }

    if (buf_pos >= sizeof(IRFrame)) {
        //whole packet recieved!
        buf_pos = 0;
        packet_in_progress = false;

        if (buf->valid()) {
            buf->ntoh();

            if (buf->source == address) {
                // don't relay our own packets
                debugend();
                reset();
                return;
            }

            if (buf->destination != address) {
                if (buf->hops < MAX_HOPS) {
                    auto newbuf = FrameFactory.alloc();
                    IRFrame::copy(newbuf, buf);
                    eventManager.queueEvent(PacketNeedsRelayEvent, (int)newbuf);
                    debugend();
                    reset();
                    return;
                } else {
                    debugcont("too many hops.. eating");
                    debugend();
                    reset();
                    return;
                }
            }

            auto newbuf = FrameFactory.alloc();
            IRFrame::copy(newbuf, buf);
            eventManager.queueEvent(ValidFrameRecievedEvent, (int)newbuf);
            debugend();
            reset();
            return;
        } else {
            auto newbuf = FrameFactory.alloc();
            IRFrame::copy(newbuf, buf);
            eventManager.queueEvent(InvalidFrameRecievedEvent, (int)newbuf);
            debugend();
            reset();
        }
    }
    return;
}
示例#4
0
Server::Server(QObject *parent) : QTcpServer(parent)
{
    connect( this, SIGNAL( stalled() ), parent, SLOT( stalled() ) );
    connect( this, SIGNAL( unstalled() ), parent, SLOT( unstalled() ) );
}
示例#5
0
 void Server::serverThreadStalled( ServerConnection* connection, bool isStalled )
 {
     qDebug() << "Server: a connection stalled";
     if( isStalled ) emit stalled();
     else emit unstalled();
 }