void OnkyoRemoteItem::cmd(const QString &str)
{
    if( getConnected()==false )
        connect_(true);

    if( getConnected() )
        onkyo_->request(str);
}
Example #2
0
const std::string& clip_t::getUnmappedComponents() const
{
    static const std::string srgba( kOfxImageComponentRGBA);
    static const std::string snone( kOfxImageComponentNone);

    if( node()->all_inputs_optional())
    {
#ifndef NDEBUG
        DLOG( INFO) << "clip_t::getUnmappedComponents, node = " << node()->name() << ", port = " << port() << ", result = srgba";
#endif

        return srgba;
    }

    if( getConnected())
    {
#ifndef NDEBUG
        DLOG( INFO) << "clip_t::getUnmappedComponents, node = " << node()->name() << ", port = " << port() << ", result = srgba";
#endif

        return srgba;
    }

#ifndef NDEBUG
    DLOG( INFO) << "clip_t::getUnmappedComponents, node = " << node()->name() << ", port = " << port() << ", result = none";
#endif

    return snone;
}
void DirectShowPlayerService::doReleaseAudioOutput(QMutexLocker *locker)
{
    m_pendingTasks |= m_executedTasks & (Play | Pause);

    if (IMediaControl *control = com_cast<IMediaControl>(m_graph, IID_IMediaControl)) {
        control->Stop();
        control->Release();
    }

    IBaseFilter *decoder = getConnected(m_audioOutput, PINDIR_INPUT);
    if (!decoder) {
        decoder = m_audioOutput;
        decoder->AddRef();
    }

    // {DCFBDCF6-0DC2-45f5-9AB2-7C330EA09C29}
    static const GUID iid_IFilterChain = {
        0xDCFBDCF6, 0x0DC2, 0x45f5, {0x9A, 0xB2, 0x7C, 0x33, 0x0E, 0xA0, 0x9C, 0x29} };

    if (IFilterChain *chain = com_cast<IFilterChain>(m_graph, iid_IFilterChain)) {
        chain->RemoveChain(decoder, m_audioOutput);
        chain->Release();
    } else {
        m_graph->RemoveFilter(m_audioOutput);
    }

    decoder->Release();

    m_executedTasks &= ~SetAudioOutput;

    m_loop->wake();
}
void OnkyoRemoteItem::connect_(bool conn)
{
    bool linked_ = getConnected();
    if( linked_ != conn ){

        if(conn){
            onkyo_.reset( new OnkyoClient() );
            connect(onkyo_.data(), SIGNAL( newStatus(QString) ), this, SLOT(status_(QString)) );
            connect(onkyo_.data(), SIGNAL( error(QString)), this, SLOT(error_(QString)) );
            if(addr_.isEmpty())
                onkyo_->init();
            else {
                DeviceInfo d;
                d.addr = QHostAddress(addr_);
                d.port = port_;
                onkyo_->init(d);
            }
            onkyo_->setConnected(true);
        }
        else {//make diskonnect
            if(! onkyo_.isNull() ){
                this->disconnect(onkyo_.data());
                onkyo_.reset();
            }
        }
        emit connectChanged();
    }

}
Example #5
0
/**
 * @brief  Optional plugin function called after analysis is complete but
 *         before PRD exits.
 * @param  i_cenChip A Centaur MBA chip.
 * @param  i_sc      The step code data struct.
 * @note   This is especially useful for any analysis that still needs to be
 *         done after the framework clears the FIR bits that were at attention.
 * @return SUCCESS.
 */
int32_t PllPostAnalysis( ExtensibleChip * i_cenChip,
                         STEP_CODE_DATA_STRUCT & i_sc )
{
    #define PRDF_FUNC "[Membuf::PllPostAnalysis] "

    int32_t o_rc = SUCCESS;

    TargetHandle_t cenTrgt = i_cenChip->GetChipHandle();

    do
    {
        // need to clear associated bits in the MCIFIR bits.
        o_rc = MemUtils::mcifirCleanup( i_cenChip, i_sc );
        if( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC"mcifirCleanup() failed");
            break;
        }

        // Check to make sure we are at threshold and have something garded.
        if ( !i_sc.service_data->IsAtThreshold() ||
             (GardAction::NoGard == i_sc.service_data->QueryGard()) )
        {
            break; // nothing to do
        }

        TargetHandleList list = getConnected( cenTrgt, TYPE_MBA );
        if ( 0 == list.size() )
        {
            PRDF_ERR( PRDF_FUNC"getConnected(0x%08x, TYPE_MBA) failed",
                      getHuid(cenTrgt) );
            o_rc = FAIL; break;
        }

        // Send SKIP_MBA message for each MBA.
        for ( TargetHandleList::iterator mbaIt = list.begin();
              mbaIt != list.end(); ++mbaIt )
        {
            int32_t l_rc = mdiaSendEventMsg( *mbaIt, MDIA::SKIP_MBA );
            if ( SUCCESS != l_rc )
            {
                PRDF_ERR( PRDF_FUNC"mdiaSendEventMsg(0x%08x, SKIP_MBA) failed",
                          getHuid(*mbaIt) );
                o_rc |= FAIL;
                continue; // keep going
            }
        }

    } while(0);

    return o_rc;

    #undef PRDF_FUNC
}
Example #6
0
//=====================================
// XTablet add widget to mainframe...
//-------------------------------------
void XTablet::addTo (XFrame* xf,XIntro* xi) {
	mIntro    = xi;
	mFrame    = xf;
	mInit     = mFrame -> getInit();
	mStatus   = mFrame -> statusBar();
	mFilePtr  = mIntro -> getFiles();
	mIndex    = Tablet;
	mPage     = mIndex;
	mLastPage = TabletPage1;
	getConnected (xf);
	dialogCreate ();
}
bool TServerList::main()
{
	if (!getConnected())
		return false;

	// definitions
	CString line;
	int lineEnd;

	// do we have enough data to parse?
	rBuffer.setRead(0);
	while (rBuffer.length() != 0)
	{
		// Read a packet.
		if (!nextIsRaw)
		{
			if ((lineEnd = rBuffer.find("\n")) == -1) break;
			line = rBuffer.readString("\n");
			rBuffer.removeI(0, line.length() + 1);	// +1 for \n
		}
		else
		{
			if (rBuffer.length() < rawPacketSize) break;

			// Read the packet in and remove the terminating \n.
			line = rBuffer.readChars(rawPacketSize);
			rBuffer.removeI(0, line.length());
			line.removeI(line.length() - 1, 1);
			nextIsRaw = false;
		}

		// Parse the packet.
		parsePacket(line);

		// update last data
		lastData = time(0);
	}

	return getConnected();
}
Example #8
0
const std::string &clip_t::getUnmappedComponents() const
{
    static const std::string srgba( kOfxImageComponentRGBA);
    static const std::string snone( kOfxImageComponentNone);

    if( node()->all_inputs_optional())
	return srgba;

    if( getConnected())
	return srgba;

    return snone;
}
Example #9
0
const std::string& clip_t::getUnmappedBitDepth() const
{
    static const std::string sfloat( kOfxBitDepthFloat);
    static const std::string snone( kOfxBitDepthNone);

    if( node()->all_inputs_optional())
        return sfloat;

    if( getConnected())
        return sfloat;

    return snone;
}
Example #10
0
glm::ivec2 Z3DRenderOutputPort::getExpectedSize() const
{
    glm::ivec2 result(-1, -1);
    const std::vector<Z3DInputPortBase*> inports = getConnected();
    for (size_t j=0; j<inports.size(); ++j) {
        Z3DRenderInputPort *renderInport = dynamic_cast< Z3DRenderInputPort* >(inports[j]);
        if (renderInport)
            result = glm::max(result, renderInport->getExpectedSize());
        else
            LERROR() << "This should not happen..";
    }
    return result;
}
Example #11
0
TargetHandleList getConnectedDimms( TargetHandle_t i_mba )
{
    TargetHandleList o_list;

    if ( TYPE_MBA != getTargetType(i_mba) )
    {
        PRDF_ERR( "[CalloutUtil::getConnectedDimms] Invalid target type: "
                  "HUID=0x%08x", getHuid(i_mba) );
    }
    else
        o_list = getConnected( i_mba, TYPE_DIMM );

    return o_list;
}
Example #12
0
// this polling loop is much more portable between OSs than detecting actual connect/disconnect events
void ConnectEvent::run()
{
    Device dev;

    connect(this, SIGNAL(connected(Device,bool)), m_main, SLOT(handleConnected(Device,bool)));

    // sleep a while (so we can wait for other devices to be de-registered)
    msleep(m_sleep);
    while(m_run)
    {
        dev = getConnected();
        if (dev!=NONE)
        {
            msleep(1000);
            emit connected(dev, true);
            return;
        }
        msleep(1000);
    }
}
void DirectShowPlayerService::doReleaseVideoOutput(QMutexLocker *locker)
{
    m_pendingTasks |= m_executedTasks & (Play | Pause);

    if (IMediaControl *control = com_cast<IMediaControl>(m_graph, IID_IMediaControl)) {
        control->Stop();
        control->Release();
    }

    IBaseFilter *intermediate = 0;
    if (!SUCCEEDED(m_graph->FindFilterByName(L"Color Space Converter", &intermediate))) {
        intermediate = m_videoOutput;
        intermediate->AddRef();
    }

    IBaseFilter *decoder = getConnected(intermediate, PINDIR_INPUT);
    if (!decoder) {
        decoder = intermediate;
        decoder->AddRef();
    }

    // {DCFBDCF6-0DC2-45f5-9AB2-7C330EA09C29}
    static const GUID iid_IFilterChain = {
        0xDCFBDCF6, 0x0DC2, 0x45f5, {0x9A, 0xB2, 0x7C, 0x33, 0x0E, 0xA0, 0x9C, 0x29} };

    if (IFilterChain *chain = com_cast<IFilterChain>(m_graph, iid_IFilterChain)) {
        chain->RemoveChain(decoder, m_videoOutput);
        chain->Release();
    } else {
        m_graph->RemoveFilter(m_videoOutput);
    }

    intermediate->Release();
    decoder->Release();

    m_executedTasks &= ~SetVideoOutput;

    m_loop->wake();
}
Example #14
0
TargetHandleList getConnectedDimms( TargetHandle_t i_mba,
                                    const CenRank & i_rank )
{
    #define PRDF_FUNC "[CalloutUtil::getConnectedDimms] "

    TargetHandleList o_list;

    if ( TYPE_MBA != getTargetType(i_mba) )
    {
        PRDF_ERR( PRDF_FUNC "Invalid target type: HUID=0x%08x", getHuid(i_mba) );
    }
    else
    {
        TargetHandleList dimmList = getConnected( i_mba, TYPE_DIMM );
        for ( TargetHandleList::iterator dimmIt = dimmList.begin();
              dimmIt != dimmList.end(); dimmIt++)
        {
            uint8_t dimmSlct;
            int32_t l_rc = getMbaDimm( *dimmIt, dimmSlct );
            if ( SUCCESS != l_rc )
            {
                PRDF_ERR( PRDF_FUNC "getMbaDimm(0x%08x) failed",
                          getHuid(*dimmIt) );
                continue;
            }

            if ( dimmSlct == i_rank.getDimmSlct() )
            {
                o_list.push_back( *dimmIt );
            }
        }
    }

    return o_list;

    #undef PRDF_FUNC
}
void clientMessage(std::string command, std::string option, std::string data, IClientSocket *socket)
{
	if(command == "message") insertMessage(option,data);
	
	//	Client command: connect to a server
	if(command == "connect"){
		clientMessage("/info,connect:"+data);
		
		if(state.enableClient == false){
			state.client = fusion->Network->CreateSocket();
			if(state.client->Connect(data.c_str(),state.port) == true){
				state.enableClient = true;
							
				//	You are connected to the server with a socket
				
				//	Set your nick, to what it is now 
				//	(results not in an update of username, but an 
				//	update of the clients username on the server)
				remoteMessage("/newClient,"+state.username);
			}else{
				clientMessage("/error,connect");
			}
		}else{
			clientMessage("/error,connectionPresent");
		}
	}
	
	//	Client command: disconnect from a server
	if(command == "disconnect"){
		state.client->Disconnect();
		state.enableClient = false;
		setDisconnected();
	}	
	
	//	Client command: server accepted your connection
	if(command == "accepted"){
		if(getConnected() == "Connect"){
			//	Inform the client it has connected successfully
			clientMessage("/info,accepted");
			//	Set the identifying code for this client
			state.id = data;
			//	Set the gui to show connected to a server
			setConnected();
		}
	}
	
	//	Client command: informs the client a new user has entered the server
	if(command == "userConnect")
	{
		clientMessage("/info,userConnect:"+option+";"+data);
		//	If the user being added, is you, then set the state.id
		if(addUser(option,data) == false){
			//	Error adding the user to the client
			clientMessage("/error,invalidUsername",socket);
		}else{
			//	Should the client do something if addUser succeeded?
			clientMessage("/info,userConnect");
		}
	}
	
	//	Client command: informs the client a user has disconnected from the server
	if(command == "userDisconnect"){}
	
	//	Client command: show information to the interface
	if(command == "info")
	{
		if(option == "connect")		data = "Lets connect to: " + data;
		if(data == "accepted")		data = "connection accepted!";
		if(data == "userConnect")	data = option + " has entered the room";
		if(data == "userDisconnect")data = option + " has left the room";

		insertMessage("info",data);
	}	
	
	if(command == "error")
	{
		//	The client failed to connect to the server
		if(data == "connect") data = "Failed to connect, sorry";

		//	The connect address was invalid (the network couldnt resolve or understand the address given
		if(data == "invalidAddress") data = "Try to use a correct hostname/address please";

		//	The app is running as a server, or the client is already connected
		//	therefore you cannot make another connection until the server is deactivated
		//	or the client, disconnected.
		if(data == "connectionPresent") data = "Cannot connect, Server running, or client already connected";
		
		//	The username is invalid (you entered a semi colon?)
		if(data == "invalidUsername"){
			data = "the username requested is invalid, please attempt to choose another";
			updateUsername();
		}

		//	This is sent from the server in response to an attempt to use an username which already exists there
		//	it says userFound, so you can choose another username and attempt again
		if(data == "userFound"){
			data = "Server reported this username is not available";
			updateUsername();
		}
		insertMessage("error",data);
	}
}
Example #16
0
void MantaController::update()
{
    if (!connected)
    {
        connected = getConnected();
        return;
    }
    
    // pad velocities
    int idx = 0;
    for (int row=0; row<6; row++)
    {
        for (int col=0; col<8; col++)
        {
            padVelocity[row][col] = ofLerp(padVelocity[row][col], getPad(row, col) - prevPad[row][col], 0.1);
            prevPad[row][col] = getPad(row, col);
            idx++;
        }
    }
    // slider velocities
    for (int i=0; i<2; i++)
    {
        sliderVelocity[i] = ofLerp(sliderVelocity[i], getSlider(i) - prevSlider[i], velocityLerpRate);
        prevSlider[i] = getSlider(i);
    }
    // button velocities
    for (int i=0; i<4; i++)
    {
        buttonVelocity[i] = ofLerp(buttonVelocity[i], getButton(i) - prevButton[i], velocityLerpRate);
        prevButton[i] = getButton(i);
    }
    
    // finger stats
    float _padSum = 0;
    float _padAverage = 0;
    float _width = 0;
    float _height = 0;
    float _whRatio = 0;
    float _numPads = 0;
    
    fingers.clear();
    fingerValues.clear();
    ofPoint fingersMin = ofPoint(1, 1);
    ofPoint fingersMax = ofPoint(0, 0);
    float currentValue;
    for (int row=0; row<6; row++)
    {
        for (int col=0; col<8; col++)
        {
            currentValue = getPad(row, col);
            if (currentValue > 0)
            {
                ofPoint fingerPos = getPositionAtPad(row, col);
                fingers.push_back(fingerPos);
                fingerValues.push_back(currentValue);
                _numPads+=1.0;
                _padSum += currentValue;
                if (fingerPos.x > fingersMax.x)   fingersMax.x = fingerPos.x;
                if (fingerPos.x < fingersMin.x)   fingersMin.x = fingerPos.x;
                if (fingerPos.y > fingersMax.y)   fingersMax.y = fingerPos.y;
                if (fingerPos.y < fingersMin.y)   fingersMin.y = fingerPos.y;
            }
        }
    }
    
    _padAverage = fingers.size() > 0 ? _padSum / _numPads : 0.0;
    
    float _perimeter = 0.0;
    float _averageInterFingerDistance = 0.0;
    
    // stats on finger groups
    if (fingers.size() < 2)
    {
        _width = 0;
        _height = 0;
        _whRatio = 0;
        _perimeter = 0;
        _averageInterFingerDistance = 0;
        fingersHull.resize(0);
        fingersHullNormalized.resize(0);
    }
    else if (fingers.size() == 2)
    {
        _width = fingersMax.x - fingersMin.x;
        _height = fingersMax.y - fingersMin.y;
        _whRatio = _width / (1.0 + _height);
        
        _perimeter = (pow(fingers[0].x - fingers[1].x, 2)+
                      pow(fingers[0].y - fingers[1].y, 2));
        
        _averageInterFingerDistance = _perimeter;
        fingersHull.resize(0);
        fingersHullNormalized.resize(0);
    }
    else
    {
        _width = fingersMax.x - fingersMin.x;
        _height = fingersMax.y - fingersMin.y;
        _whRatio = _width / _height;
        
        fingersHull = convexHull.getConvexHull(fingers);
        fingersHullNormalized.resize(fingersHull.size());
        for (int i=0; i<fingersHull.size(); i++)
        {
            fingersHullNormalized[i].x = (fingersHull[i].x - fingersMin.x) / (fingersMax.x - fingersMin.x);
            fingersHullNormalized[i].y = (fingersHull[i].y - fingersMin.y) / (fingersMax.y - fingersMin.y);
        }
        for (int i=0; i<fingersHull.size()-1; i++)
        {
            _perimeter += (pow(fingersHull[i].x - fingersHull[(i+1)].x, 2)+
                           pow(fingersHull[i].y - fingersHull[(i+1)].y, 2));
        }
        _averageInterFingerDistance = _perimeter / (float) (fingersHull.size()-1);
    }
    
    numPadsVelocity = ofLerp(numPadsVelocity, _numPads-numPads, velocityLerpRate);
    perimeterVelocity = ofLerp(perimeterVelocity, _perimeter-perimeter, velocityLerpRate);
    averageInterFingerDistanceVelocity = ofLerp(averageInterFingerDistanceVelocity, _averageInterFingerDistance-averageInterFingerDistance, velocityLerpRate);
    
    padSumVelocity = ofLerp(padSumVelocity, _padSum-padSum, velocityLerpRate);
    padAverageVelocity = ofLerp(padAverageVelocity, _padAverage-padAverage, velocityLerpRate);
    
    widthVelocity = ofLerp(widthVelocity, _width-padWidth, velocityLerpRate);
    heightVelocity = ofLerp(heightVelocity, _height-padHeight, velocityLerpRate);
    whRatioVelocity = ofLerp(whRatioVelocity, _whRatio-whRatio, velocityLerpRate);
    
    padWidth = _width;
    padHeight = _height;
    whRatio = _whRatio;
    perimeter = _perimeter;
    averageInterFingerDistance = _averageInterFingerDistance;
    padSum = _padSum;
    padAverage = _padAverage;
    numPads = _numPads;
    
    // centroid and weighted centroid
    ofPoint _centroid, _weightedCentroid;
    for (int i=0; i<fingers.size(); i++)
    {
        _centroid += fingers[i];
        _weightedCentroid += (fingers[i] * fingerValues[i] / padSum);
    }
    _centroid /= _numPads;
    
    centroidVelocityX = ofLerp(centroidVelocityX, _centroid.x-centroidX, velocityLerpRate);
    centroidVelocityY = ofLerp(centroidVelocityY, _centroid.y-centroidY, velocityLerpRate);
    weightedCentroidVelocityX = ofLerp(weightedCentroidVelocityX, _weightedCentroid.x-weightedCentroidX, velocityLerpRate);
    weightedCentroidVelocityY = ofLerp(weightedCentroidVelocityY, _weightedCentroid.y-weightedCentroidY, velocityLerpRate);
    
    centroidX = _centroid.x;
    centroidY = _centroid.y;
    weightedCentroidX = _weightedCentroid.x;
    weightedCentroidY = _weightedCentroid.y;
}
//	The network commandMessage method
void commandMessage(std::string text, IClientSocket *socket)
{
	std::string command, option, data;
	decodeMessage(text,command,option,data);
	
	fusion->errlog << "command = " << command << ", option = " << option << ", data = " << data << std::endl;
	
	//	If all strings are empty, error occured, a blank
	//	string, or messed up string	cannot be processed
	if(command.empty() == true && option.empty() == true && data.empty() == true) return;
	
	if(socket == state.client)	clientMessage(command,option,data,socket);
	else						serverMessage(command,option,data,socket);
	
	/*
		Client/Server commands go here, where they are not resolved
		in the specific clientMessage/serverMessage methods
	*/	
	
	//	Client/Server command: both can change their userName they are chatting with
	if(command == "setUsername")
	{
		if(option.empty() == true){
			//	No ID passed with this command
			
			//	WAITING CLIENT
			if(state.enableClient == true && getConnected() == "Connect"){
				remoteMessage("/newClient,"+data);
			}else{
				std::string name;
				std::string idcode = state.id;

				if(state.enableClient == true){
					if(getConnected() == "Disconnect")	name	= state.username;
					else								socket	= state.client;
				}else if(state.enableServer == true){
					if(socket == NULL)					name	= state.username;
					else								idcode	= idstring(socket);
				}
				
				clientMessage("/info,socket = "+idcode);
				remoteMessage("/setUsername,"+name+";"+data+":"+idcode,socket);
			}
		}else{
			//	ID was passed with this command
			
			size_t pos = option.find(";");
			if(pos > 0){
				std::string oldUser = option.substr(0,pos);
				std::string newUser = option.substr(pos+1);
				
				if(renameUser(oldUser,newUser,data) == true){
					broadcastMessage("/setUsername,"+option+":"+data, socket);
				}else{
					clientMessage("/error,userFound");
				}
			}else{
				updateUsername(option.substr(1));
			}
		}
	}
	
	if(command == "quit") closeApp();
}