Beispiel #1
0
	void NodesManager::pingNetwork()
	{
		// check whether there are new nodes in the network, for new targets (protocol >= 5)
		ListNodes listNodes;
		sendMessage(listNodes);
		
		// check nodes that have not been seen for long, mark them as disconnected
		const UnifiedTime now;
		const UnifiedTime delayToDisconnect(3000);
		bool isAnyConnected(false);
		for (NodesMap::iterator nodeIt = nodes.begin(); nodeIt != nodes.end(); ++nodeIt)
		{
			// if node supports listing, 
			if (nodeIt->second.protocolVersion >= 5 && (now - nodeIt->second.lastSeen) > delayToDisconnect && nodeIt->second.connected)
			{
				nodeIt->second.connected = false;
				nodeDisconnected(nodeIt->first);
			}
			// is this node connected?
			isAnyConnected = isAnyConnected || nodeIt->second.connected;
		}
		
		// if no node is connected, broadcast get description as well, for old targets (protocol 4)
		if (!isAnyConnected)
		{
			GetDescription getDescription;
			sendMessage(getDescription);
		}
	}
	//! The network connection has been cut: disconnect VPL node if connected
	void ThymioVPLStandalone::networkDisconnected()
	{
		// disconnect VPL if present
		if (vpl)
			nodeDisconnected(id);
		// start timer for reconnection
		if (!getDescriptionTimer)
			getDescriptionTimer = startTimer(2000);
	}
Beispiel #3
0
void jarvisNodeTestApp::connectNodeSignals(sJarvisNode* node)
{
    connect(node,SIGNAL(tx()),&m_rxWidget,SLOT(tx()));
    connect(node,SIGNAL(rx()),&m_rxWidget,SLOT(rx()));
    connect(node,SIGNAL(rawInput(QByteArray)),this,SLOT(console_log(QByteArray)));
    connect(node,SIGNAL(writeData(QByteArray)),this,SLOT(console_log(QByteArray)));
    connect(node,SIGNAL(incomingEvent(QString,jarvisEvents,QStringList)),this,SLOT(eventLog(QString,jarvisEvents,QStringList)));
    //connect(node,SIGNAL(newComponent(sJarvisNodeComponent*)),this,SLOT(addComponent(sJarvisNodeComponent*)));
    //connect(&m_sensorsTimer,SIGNAL(timeout()),this,SLOT(timedCmd()));
    connect(node,SIGNAL(sensorReads(QVector<QString>,QVector<double>)),this,SLOT(sensorRead(QVector<QString>,QVector<double>)));
    connect(node,SIGNAL(ready()),this,SLOT(nodeConnected()));
    connect(node,SIGNAL(disconnected()),this,SLOT(nodeDisconnected()));
    connect(ui->sliderUpdateInterval,SIGNAL(sliderMoved(int)),node,SLOT(setUpdateInterval(int)));
    connect(ui->btnReset,SIGNAL(clicked()),node,SLOT(resetNode()));
}