Esempio n. 1
0
void AVTransport::handleEvent(ArgMap vars) {
#if 0
//	log()<<"got avtransport event"<<vars.size();
	if (!vars.contains("LastChange")) return;
	QString change = vars["LastChange"];
	IXML_Document* doc = ixmlParseBuffer(qPrintable(change));
	if (!doc) {
		log()<<"failed parsing lastchange";
		return;
	}
//	log() << ixmlPrintDocument(doc);
	ArgMap args;
	for(Nodeptr i=doc->n.firstChild->firstChild->firstChild; i; i=i->nextSibling) {
//		log()<<i->nodeName<<i->firstAttr->nodeValue;
		args[QString::fromUtf8(i->nodeName)] = QString::fromUtf8(i->firstAttr->nodeValue);
	}
//	log()<<args;
	emit lastChange(args);
#endif
}
Esempio n. 2
0
/*******************************************************************
* Function Name: externalFunction
********************************************************************/
Model &Transducer2::externalFunction( const ExternalMessage &msg )
{
	long id;
	union request req;
	cpuLoad ( cpuLoad() + static_cast< long >( ( msg.time() - lastChange() ).asMsecs() * unsolved().size() ));

	if( msg.port() == arrived )
	{
		req = (union request) msg.value();
		id = req.r.idtask * 100 + req.r.origin;		

		if( unsolved().find( id ) != unsolved().end() )
		{
			MException e( string("Unresolved Work Id: ") + (float) id + " is duplicated." );
			e.addLocation( MEXCEPTION_LOCATION() );
			throw e;
		}

		unsolved()[ id ] = msg.time() ;
	}

	if( msg.port() == solved )
	{
		req = (union request) msg.value();
		id = req.r.idtask * 100 + req.r.destino;	

		Transducer2State::JobsList::iterator cursor( unsolved().find( id) ) ;

		if( cursor == unsolved().end() )
		{
			MException e( string("Resolved Work Id: ") + (float) id + " Not Found!" );
			e.addLocation( MEXCEPTION_LOCATION() );
			throw e;
		}

		procCount( procCount() + 1 );
		unsolved().erase( cursor ) ;
	}
	return *this ;
}