Exemplo n.º 1
0
void
ParticipantManager::
deactivateParticipant(const synthclone::Participant *participant)
{
    CONFIRM(participant, tr("participant is set to NULL"));

    ParticipantData *data = participantDataMap.value(participant, 0);

    CONFIRM(data, tr("participant is not registered with participant manager"));

    Context *context = data->context;

    CONFIRM(data->context, tr("participant is not currently activated"));

    ParticipantList &children = data->children;
    for (int i = children.count() - 1; i >= 0; i--) {
        removeParticipant(children[i]);
    }
    const QByteArray &id = data->id;
    const synthclone::Participant *parent = data->parent;
    emit deactivatingParticipant(participant, parent, id);
    data->participant->deactivate(*context);
    data->context = 0;
    delete context;
    emit participantDeactivated(participant, parent, id);
}
Exemplo n.º 2
0
const synthclone::Registration &
ParticipantManager::addParticipant(synthclone::Participant *participant,
                                   const QByteArray &id)
{
    CONFIRM(participant, tr("participant is set to NULL"));
    CONFIRM(! participantDataMap.value(participant, 0),
            tr("participant is already registered with participant manager"));
    QList<QByteArray> parts = id.split('.');
    for (int i = parts.count() - 1; i >= 0; i--) {
        CONFIRM(verifySubId(parts[i]),
                tr("'%1': invalid participant id").arg(id.constData()));
    }

    emit addingParticipant(participant, 0, id);
    ParticipantData *data = new ParticipantData();
    Registration *registration = new Registration(participant, this);
    data->context = 0;
    data->id = id;
    data->parent = 0;
    data->participant = participant;
    data->registration = registration;
    participantDataMap[participant] = data;
    participantIdMap[id] = participant;
    rootParticipants.append(participant);
    emit participantAdded(participant, 0, id);
    return *registration;
}
Exemplo n.º 3
0
const synthclone::Registration &
ParticipantManager::addParticipant(synthclone::Participant *participant,
                                   const synthclone::Participant *parent,
                                   const QByteArray &subId)
{
    CONFIRM(participant, tr("participant is set to NULL"));
    CONFIRM(participantDataMap.contains(participant),
            tr("participant is already registered with participant manager"));
    CONFIRM(verifySubId(subId),
            tr("'%1': invalid participant sub-id").arg(subId.constData()));
    assert(parent);

    ParticipantData *parentData = participantDataMap.value(parent, 0);

    assert(parentData);
    assert(parentData->context);

    QByteArray id;
    id.append(parentData->id);
    id.append('.');
    id.append(subId);
    emit addingParticipant(participant, parent, id);
    ParticipantData *data = new ParticipantData();
    Registration *registration = new Registration(participant, this);
    data->context = 0;
    data->id = id;
    data->parent = parentData->participant;
    data->participant = participant;
    data->registration = registration;
    participantDataMap[participant] = data;
    participantIdMap[id] = participant;
    parentData->children.append(participant);
    emit participantAdded(participant, parent, id);
    return *registration;
}
Exemplo n.º 4
0
void
ParticipantManager::
removeParticipant(const synthclone::Participant *participant)
{
    CONFIRM(participant, tr("participant is set to NULL"));

    ParticipantData *data = participantDataMap.value(participant, 0);

    CONFIRM(data, tr("participant is not registered with participant manager"));

    if (data->context) {
        deactivateParticipant(participant);
    }
    QByteArray &id = data->id;
    const synthclone::Participant *parent = data->parent;
    emit removingParticipant(participant, parent, id);
    assert(participantDataMap.contains(participant));
    assert(participantIdMap.contains(id));
    participantDataMap.remove(participant);
    participantIdMap.remove(id);
    bool removed;
    if (parent) {
        ParticipantData *parentData = participantDataMap.value(parent, 0);
        assert(parentData);
        removed = parentData->children.removeOne(data->participant);
    } else {
        removed = rootParticipants.removeOne(data->participant);
    }
    assert(removed);
    QScopedPointer<Registration> registrationPtr(data->registration);
    delete data;
    emit participantRemoved(participant, parent, id);
}
Exemplo n.º 5
0
synthclone::Participant *
ParticipantManager::
getParticipantParent(const synthclone::Participant *participant)
{
    CONFIRM(participant, tr("participant is set to NULL"));

    ParticipantData *data = participantDataMap.value(participant, 0);

    CONFIRM(data, tr("participant is not registered with participant manager"));

    return data->parent;
}
Exemplo n.º 6
0
Arquivo: ascmenu.c Projeto: E-LLP/QuIP
static COMMAND_FUNC( do_disp_obj )
{
	Data_Obj *dp;
	FILE *fp;

	dp=PICK_OBJ("");
	if( dp==NO_OBJ ) return;

	// We used to insist that the object be in RAM,
	// but we make life easier by automatically creating
	// a temporary object...

	dp = insure_ram_obj(QSP_ARG  dp);
	if( dp == NO_OBJ ) return;

	fp = tell_msgfile(SINGLE_QSP_ARG);
	if( fp == stdout ){
		if( IS_IMAGE(dp) || IS_SEQUENCE(dp) )
			if( !CONFIRM(
		"are you sure you want to display an image/sequence in ascii") )
				return;
		list_dobj(QSP_ARG  dp);
	}
	pntvec(QSP_ARG  dp,fp);
	fflush(fp);

	DELETE_IF_COPY(dp)
}
Exemplo n.º 7
0
bool
ParticipantManager::
isParticipantActivated(const synthclone::Participant *participant) const
{
    ParticipantData *data = participantDataMap.value(participant, 0);
    CONFIRM(data, tr("participant is not registered with participant manager"));
    return static_cast<bool>(data->context);
}
void
SessionSampleData::setSampleChannelCount(synthclone::SampleChannelCount count)
{
    CONFIRM(count > 0, tr("sample channel count cannot be 0"));
    if (this->sampleChannelCount != count) {
        this->sampleChannelCount = count;
        emit sampleChannelCountChanged(count);
    }
}
Exemplo n.º 9
0
synthclone::Participant *
ParticipantManager::getParticipant(int index,
                                   const synthclone::Participant *parent)
{
    const ParticipantList *participants;
    if (! parent) {
        participants = &rootParticipants;
    } else {
        ParticipantData *data = participantDataMap.value(parent, 0);

        CONFIRM(data, tr("the given parent is not a registered participant"));

        participants = &(data->children);
    }

    CONFIRM((index >= 0) && (index < participants->count()),
            tr("'%1': index is out of range").arg(index));

    return participants->at(index);
}
Exemplo n.º 10
0
void
ParticipantManager::
activateParticipant(const synthclone::Participant *participant,
                    const QVariant &state)
{
    CONFIRM(participant, tr("participant is set to NULL"));

    ParticipantData *data = participantDataMap.value(participant, 0);

    CONFIRM(data, tr("participant is not registered with participant manager"));
    CONFIRM(! data->context, tr("participant is already activated"));

    QByteArray &id = data->id;
    const synthclone::Participant *parent = data->parent;
    synthclone::Participant *mutableParticipant = data->participant;
    emit activatingParticipant(participant, parent, id);
    Context *context = new Context(*mutableParticipant, *this, controller);
    mutableParticipant->activate(*context, state);
    data->context = context;
    emit participantActivated(participant, parent, id);
}
Exemplo n.º 11
0
int
ParticipantManager::
getParticipantCount(const synthclone::Participant *parent) const
{
    if (! parent) {
        return rootParticipants.count();
    }
    ParticipantData *data = participantDataMap.value(parent, 0);

    CONFIRM(data, tr("the given parent is not a registered participant"));

    return data->children.count();
}
void
SessionSampleData::setSampleRate(synthclone::SampleRate sampleRate)
{
    CONFIRM((sampleRate == synthclone::SAMPLE_RATE_NOT_SET) ||
            ((sampleRate >= synthclone::SAMPLE_RATE_MINIMUM) &&
             (sampleRate <= synthclone::SAMPLE_RATE_MAXIMUM)),
            tr("'%1': invalid sample rate").arg(sampleRate));

    if (this->sampleRate != sampleRate) {
        this->sampleRate = sampleRate;
        emit sampleRateChanged(sampleRate);
    }
}
Exemplo n.º 13
0
int main(int argc, char* argv[])
{
	if (argc == 1) return 1;
	const char* s = NULL;
	const char* dev = argv[1];
	Laser* laser = laser_open(dev);
	if (laser == NULL) {
		perror("laeser_open");
		return 2;
	}
	
	// setup address
	unsigned char addr, light, tmpr;
	CONFIRM(laser_get_params(laser, &addr, &light, &tmpr));
	printf("Addr %x, Light %d, Tmpr: %d\n", addr, light, tmpr);
	s = input("Change address? ");
	int iaddr;
	if (sscanf(s, "%x", &iaddr) == 1) {
		addr = (unsigned char)iaddr;
		CONFIRM(laser_config_addr(laser, addr));
		printf("Address change to %x\n", addr);
	} else {
		printf("Address unchanged\n");
	}
	
	// calibrate
	CONFIRM(laser_config_range(laser, 5));
	CONFIRM(laser_config_resolution(laser, LASER_RESOL_0_1MM));
	
	signal(SIGINT, sighandler);

	s = input("Adjust [y/N]? ");
	if (s[0] == 'y' || s[0] == 'Y') {
		int delta = 0;
		CONFIRM(laser_adjust_distance(laser, delta));	// reset to 0
		while (!stop) {
			// CONFIRM(laser_wakeup(laser));
			float dist = laser_mesure_once(laser);
			// CONFIRM(laser_sleep(laser));
			printf("Distance: %f mm\n", dist * 1000);
			const char* s = input("Adjust +x mm, or [c]ancel: ");
			if (s[0] == 'C' || s[0] == 'c') break;
			int d = atoi(s);
			delta += d;
			if (d) CONFIRM(laser_adjust_distance(laser, delta));	// reset to 0
		}
	}
	
	// continious test
	while (!stop) {
		float dist = laser_mesure_once(laser);
		printf("Distance: %f m\n", dist);
	}
	
	laser_close(laser);
	return 0;
}
Exemplo n.º 14
0
Arquivo: ascmenu.c Projeto: E-LLP/QuIP
static COMMAND_FUNC( do_wrt_obj )
{
	Data_Obj *dp;
	FILE *fp;
	/* BUG what if pathname is longer than 256??? */
	const char *filename;

	dp=PICK_OBJ("");
	filename = NAMEOF("output file");

	if( dp==NO_OBJ ) return;

	if( strcmp(filename,"-") && strcmp(filename,"stdout") ){
		// BUG? we don't check append flag here,
		// but there is a separate append command...

		fp=TRYNICE( filename, "w" );
		if( !fp ) return;
	} else {
		// If the invoking script has redirected stdout,
		// then use that
		if( QS_MSG_FILE(THIS_QSP)!=NULL )
			fp = QS_MSG_FILE(THIS_QSP);
		else
			fp = stdout;
	}

	if( IS_IMAGE(dp) || IS_SEQUENCE(dp) )
		if( !CONFIRM(
		"are you sure you want to write an image/sequence in ascii") ){
			fclose(fp);
			return;
		}

	dp = insure_ram_obj(QSP_ARG  dp);
	if( dp == NO_OBJ ) return;

	pntvec(QSP_ARG  dp,fp);
	if( fp != stdout && QS_MSG_FILE(THIS_QSP)!=NULL && fp != QS_MSG_FILE(THIS_QSP) ) {
		if( verbose ){
			sprintf(MSG_STR,"closing file %s",filename);
			prt_msg(MSG_STR);
		}
		fclose(fp);
	}

	DELETE_IF_COPY(dp)
}
Exemplo n.º 15
0
void PackageDeal::PTL_Test(int sock, NetMessage* pMsg)
{
	LogManager::getInstance()->Log("收到消息了!sock:%d", sock);
	CONFIRM(pMsg);

	uint8 u8 = 0;
	uint16 u16 = 0;
	uint32 u32 = 0;
	uint64 u64 = 0;
	std::string str = "";
	uint64 u64empty = 0;
	*pMsg >> u8 >> u16 >> u32 >> u64 >> str;// >> u64empty;
	std::cout << "u8:" << (int)u8 << ",u16:" << (int)u16 << ",u32:" << (int)u32 << ",u64:" << u64 << ",str:" << str << ",empty:" << (int)u64empty << std::endl;

	NetMessage msg;
	msg.SetType(PTL_TEST);
	msg << (uint8)111 << (uint16)65530 << (uint32)200000001 << (uint64)1234567890123 << "abcdefg";
	m_socketServer.SendMsg(sock, msg);
}
Exemplo n.º 16
0
int
ParticipantManager::
getActivatedParticipantCount(const synthclone::Participant *parent) const
{
    const ParticipantList *participants;
    if (! parent) {
        participants = &rootParticipants;
    } else {
        ParticipantData *data = participantDataMap.value(parent, 0);
        CONFIRM(data, tr("the given parent is not a registered participant"));
        participants = &(data->children);
    }
    int activatedCount = 0;
    for (int i = participants->count() - 1; i >= 0; i--) {
        if (isParticipantActivated(participants->at(i))) {
            activatedCount++;
        }
    }
    return activatedCount;
}
Exemplo n.º 17
0
Arquivo: ascmenu.c Projeto: E-LLP/QuIP
static COMMAND_FUNC( do_append )
{
	Data_Obj *dp;
	FILE *fp;

	dp=PICK_OBJ("");
	if( dp==NO_OBJ ) return;

	if( IS_IMAGE(dp) || IS_SEQUENCE(dp) )
		if( !CONFIRM(
		"are you sure you want to write an image/sequence in ascii") )
			return;
	fp=TRYNICE( NAMEOF("output file"), "a" );
	if( !fp ) return;

	dp = insure_ram_obj(QSP_ARG  dp);
	if( dp == NO_OBJ ) return;

	pntvec(QSP_ARG  dp,fp);
	fclose(fp);

	DELETE_IF_COPY(dp)
}