Example #1
0
bool QDesignerAxWidget::loadControl(const QString &clsid)
{
    if (clsid.isEmpty())
        return false;
    if (m_axobject)
        resetControl();
    m_axobject = new QAxWidget();

    if (!m_axobject->setControl(clsid)) {
        delete m_axobject;
        m_axobject = 0;
        return false;
    }
    update();
    return true;
}
Example #2
0
void TownsEuphonyDriver::reset() {
	_intf->callback(0);

	_intf->callback(74);
	_intf->callback(70);
	_intf->callback(75, 3);

	setTimerA(true, 1);
	setTimerA(false, 1);
	setTimerB(true, 221);

	_paraCount = _command = _para[0] = _para[1] = 0;
	memset(_sustainChannels, 0, 16);
	memset(_activeChannels, -1, 16);
	for (int i = 0; i < 128; i++) {
		_assignedChannels[i].chan = _assignedChannels[i].next = -1;
		_assignedChannels[i].note = _assignedChannels[i].sub = 0;
	}

	int e = 0;
	for (int i = 0; i < 6; i++)
		assignChannel(i, e++);
	for (int i = 0x40; i < 0x48; i++)
		assignChannel(i, e++);

	resetTables();

	memset(_eventBuffer, 0, 64 * sizeof(DlEvent));
	_bufferedEventsCount = 0;

	_playing = _endOfTrack = _suspendParsing = _loop = false;
	_elapsedEvents = 0;
	_tempoDiff = 0;

	resetTempo();

	if (_tempoControlMode == 1) {
		//if (///)
		//  return;
		setTempoIntern(_defaultTempo);
	} else {
		setTempoIntern(_defaultTempo);
	}

	resetControl();
}
Example #3
0
void Pilot::handleControl() {

    _Cmd* command = NULL;
    rapidjson::Document* doc = NULL;
    int uid = -1;
    pthread_mutex_lock(&_RecvLock);
    if(!_RecvList.empty()){
        command = _RecvList.begin()->element;
        _RecvList.erase(_RecvList.begin());
    }
    pthread_mutex_unlock(&_RecvLock);

    if(command) {
        bool ret = true;
        uid = command->id;
        doc = new rapidjson::Document;
        do{
            doc->Parse<0>(command->cmd.c_str());
            if(doc->HasParseError()||doc->IsObject() == false||doc->HasMember("name") == false||
                    doc->HasMember("args") == false ) {
                ret = false;
                break;
            }
            if(!strcmp((*doc)["name"].GetString(),"ControlState")) {
                const rapidjson::Value& pArgs = (*doc)["args"];
                if(pArgs.IsArray()&&pArgs[rapidjson::SizeType(0)].IsInt()) {
                    int s = pArgs[rapidjson::SizeType(0)].GetInt();
                    _PilotState = s;
                    resetControl();
                    if(_PilotState == PILOT_AUTOCONTROL&&_autoScript.length() != 0) {
                        _autoController->close();
                        _autoController->init(_autoScript.c_str(),this);
                    }
                }
                ret = false;
            }

        }while(0);

        if(ret == false) {
            delete doc;
            doc = NULL;
        }
        delete command;
    }

    if(_hardware&&_hardware->getStatus()->isAllUpdated() == true) {
        _hardware->getStatus()->copyStatus(_status);
        _hardware->getStatus()->reset();
    }

    if(_sendStatusTimer.elapsed(1000)) {
        sendStatus();
    }

    switch (_PilotState) {
        case PILOT_MANUAL:
            if(doc)
                manualControl(doc,uid);
            break;
        case PILOT_HALFMANUAL:
            if(doc)
                halfManualControl(doc,uid);
            break;
        case PILOT_AUTOCONTROL:
            autoControl();
            break;
        default:
            _PilotState = PILOT_MANUAL;
            break;
    }

    if(doc != NULL)
        delete doc;
}