void UdpServerThread::processPendingDatarams()
{
    QByteArray data;
    do{
        data.resize(m_udpServer.pendingDatagramSize());
        m_udpServer.readDatagram(data.data(),data.size());
    }while(m_udpServer.hasPendingDatagrams());

    QDataStream in(&data,QIODevice::ReadOnly);
    in.setVersion(QDataStream::Qt_4_8);

    AzSocketInfo sockInfo;

    AzIrisInfo irisInfo;
    //quint16 cmdHead;
    //qint8 command;
    //quint16 datasize;

    ConfigSettings *settings;
    QByteArray qbaHostAddress;
    QByteArray qbaDeviceSN;

    in>>sockInfo.commandHead>>sockInfo.command>>sockInfo.dataSize;

    QT_TRY{
    if(QString::number(sockInfo.commandHead,16)=="ccff")
    {
        switch(sockInfo.command)
        {
            case 0x01://setting
               settings= new ConfigSettings();
                in>>settings->pid>>qbaDeviceSN>>qbaHostAddress>>settings->port>>settings->seriesId>>settings->mode>>settings->allowSwitchMode
                >>settings->allowEnroll;
                settings->deviceSN=QString::fromAscii(qbaDeviceSN);
                settings->hostAddress=QString::fromAscii(qbaHostAddress);
                emit updateSettings(settings);
                qDebug()<<"CC-FF-01";
                break;
            case 0x02://personinfo
                irisInfo.command = sockInfo.command;
                irisInfo.dataSize = sockInfo.dataSize;
                in>>irisInfo.personId>>irisInfo.if_UserNo>>irisInfo.leftIrisTemplate
                    >>irisInfo.rightIrisTemplate;
                irisInfo.commandHead = QString::number(sockInfo.commandHead,16).toUpper();
                qDebug()<<irisInfo.commandHead<<quint8(0x02);
                emit readingDatagrams(irisInfo);
                break;
            case 0x03: //Enroll 注册人员
                dzrun.enrollMode = true;
                in>>irisInfo.pid>>irisInfo.personId>>irisInfo.if_UserNo;

                dzrun.enrollPerson->personId = irisInfo.personId;
                dzrun.enrollPerson->if_UserNo = irisInfo.if_UserNo;
                qDebug()<<"Enroll person "<<irisInfo.personId;
                emit enrollPerson(irisInfo);
                break;
            case 0x04://delete
                in>>irisInfo.personId;
                qDebug()<<"CC-FF-04";
                emit deletePerson(irisInfo.personId);
                break;
            default:
            break;
        }
    }
    if(QString::number(sockInfo.commandHead,16)=="ccaa") //answer
    {
        switch(sockInfo.command)
        {
            case 0x01:
                qint32 nums;
                in>>nums;
                emit deleteRecord(nums);

                break;
            default:
            break;
        }

    }
    }QT_CATCH(...){

    }
    in.device()->close();
}
Beispiel #2
0
/**
 * @brief MainWindow::deletePersonButton reagiert, wenn der Button zum Löschen einer Person gedrückt wurde
 */
void MainWindow::deletePersonButton(){
    QPushButton *myB = qobject_cast<QPushButton*>(sender());
    /// und löscht die Person
    deletePerson(myB->parentWidget()->objectName().toInt());
}
Beispiel #3
0
	void Menu::initialize()
	{
		appService.getConsole().printLine("\n===Menu initialization===");
		menuBannerTexture = appService.getTextureManager().load(D6_TEXTURE_MENU_PATH, TextureFilter::LINEAR, true);
		appService.getConsole().printLine("...Starting GUI library");
		gui.screenSize(video.getScreen().getClientWidth(), video.getScreen().getClientHeight(),
			(video.getScreen().getClientWidth() - 800) / 2, (video.getScreen().getClientHeight() - 600) / 2);

		listbox[0] = new Gui::ListBox(gui, true);
		listbox[0]->setPosition(10, 199, 94, 12, 16);

		listbox[ALL_PLAYER_LIST] = new Gui::ListBox(gui, true);
		listbox[ALL_PLAYER_LIST]->setPosition(10, 470, 20, 13, 18);
		listbox[ALL_PLAYER_LIST]->onDoubleClick([this](Gui::ListBox& listBox, Int32 index, const std::string& item) {
			addPlayer(index);
		});

		listbox[CUR_PLAYERS_LIST] = new Gui::ListBox(gui, false);
		listbox[CUR_PLAYERS_LIST]->setPosition(200, 470, 20, D6_MAX_PLAYERS, 18);
		listbox[CUR_PLAYERS_LIST]->onDoubleClick([this](Gui::ListBox& listBox, Int32 index, const std::string& item) {
			removePlayer(index);
		});

		listbox[3] = new Gui::ListBox(gui, true);
		listbox[3]->setPosition(654, 410, 13, 6, 16);

		listbox[4] = new Gui::ListBox(gui, true);
		listbox[4]->setPosition(520, 363, 13, 3, 16);

		listbox[5] = new Gui::ListBox(gui, false);
		listbox[5]->setPosition(654, 470, 15, 2, 16);
		listbox[5]->addItem("Fullscreen");
		listbox[5]->addItem("Split screen");

		listbox[6] = new Gui::ListBox(gui, true);
		listbox[6]->setPosition(520, 470, 13, 5, 16);

		loadPersonProfiles(D6_FILE_PROFILES);
		loadPersonData(D6_FILE_PHIST);

		button[0] = new Gui::Button(gui);
		button[0]->setPosition(200, 282, 80, 25);
		button[0]->setCaption(">>");
		button[0]->onClick([this](Gui::Button&) {
			addPlayer(listbox[ALL_PLAYER_LIST]->selectedIndex());
		});

		button[1] = new Gui::Button(gui);
		button[1]->setPosition(200, 253, 80, 25);
		button[1]->setCaption("<<");
		button[1]->onClick([this](Gui::Button&) {
			removePlayer(listbox[CUR_PLAYERS_LIST]->selectedIndex());
		});

		button[2] = new Gui::Button(gui);
		button[2]->setPosition(284, 282, 80, 25);
		button[2]->setCaption("Remove");
		button[2]->onClick([this](Gui::Button&) {
			deletePerson();
			rebuildTable();
		});

		button[3] = new Gui::Button(gui);
		button[3]->setPosition(284, 253, 80, 25);
		button[3]->setCaption("Add");
		button[3]->onClick([this](Gui::Button&) {
			addPerson();
		});

		button[6] = new Gui::Button(gui);
		button[6]->setPosition(370, 282, 125, 25);
		button[6]->setCaption("Clear (F3)");
		button[6]->onClick([this](Gui::Button&) {
			if (deleteQuestion())
			{
				cleanPersonData();
			}
		});

		button[4] = new Gui::Button(gui);
		button[4]->setPosition(520, 299, 125, 73);
		button[4]->setCaption("Play (F1)");
		button[4]->onClick([this](Gui::Button&) {
			play();
		});

		button[5] = new Gui::Button(gui);
		button[5]->setPosition(654, 299, 125, 73);
		button[5]->setCaption("Quit (ESC)");
		button[5]->onClick([this](Gui::Button&) {
			close();
		});

		label[0] = new Gui::Label(gui);
		label[0]->setPosition(10, 219, 772, 18);
		label[0]->setCaption("    Name   | Games | Wins | Shots | Accuracy | Kills | Penalties | Points | Alive | Time");

		label[1] = new Gui::Label(gui);
		label[1]->setPosition(520, 383, 125, 18);
		label[1]->setCaption("Background");

		label[2] = new Gui::Label(gui);
		label[2]->setPosition(654, 429, 125, 18);
		label[2]->setCaption("Level");

		label[3] = new Gui::Label(gui);
		label[3]->setPosition(654, 489, 125, 18);
		label[3]->setCaption("Screen mode");

		label[4] = new Gui::Label(gui);
		label[4]->setPosition(520, 489, 125, 18);
		label[4]->setCaption("Zoom");

		label[5] = new Gui::Label(gui);
		label[5]->setPosition(10, 489, 181, 18);
		label[5]->setCaption("Persons");

		label[6] = new Gui::Label(gui);
		label[6]->setPosition(200, 489, 165, 18);
		label[6]->setCaption("Players");

		label[7] = new Gui::Label(gui);
		label[7]->setPosition(370, 489, 120, 18);
		label[7]->setCaption("Controller");

		textbox = new Gui::Textbox(gui);
		textbox->setPosition(370, 252, 14, 10, D6_ALL_CHR);

		// Switchbox - volba ovladani
		for (Size i = 0; i < D6_MAX_PLAYERS; i++)
		{
			controlSwitch[i] = new Gui::Spinner(gui);
			controlSwitch[i]->setPosition(370, 468 - i * 18, 120, 0);

			// TODO: Might be deleted in future if the use case is fully covered with detect-all functionality
			Gui::Button* button = new Gui::Button(gui);
			button->setCaption("D");
			button->setPosition(494, 466 - i * 18, 17, 17);
			button->onClick([this,i](Gui::Button&) {
				detectControls(i);
			});
		}

		// Button to detect all user's controllers in a batch
		Gui::Button* button = new Gui::Button(gui);
		button->setCaption("D");
		button->setPosition(490, 487, 24, 17);
		button->onClick([this](Gui::Button&){
			Size curPlayersCount = listbox[CUR_PLAYERS_LIST]->size();
			for (Size j = 0; j < curPlayersCount; j++)
			{
				detectControls(j);
			}
		});

		initializeGameModes();
		gameModeSwitch = new Gui::Spinner(gui);
		for(auto& gameMode : gameModes)
		{
			gameModeSwitch->addItem(gameMode->getName());
		}
		gameModeSwitch->setPosition(10, 0, 330, 20);

		joyRescan();

		backgroundCount = File::countFiles(D6_TEXTURE_BCG_PATH, D6_TEXTURE_EXTENSION);
		levelList.initialize(D6_FILE_LEVEL, D6_LEVEL_EXTENSION);

		listbox[3]->addItem("Random");
		for (Size i = 0; i < levelList.getLength(); i++)
		{
			listbox[3]->addItem(levelList.getFileName(i).substr(0, levelList.getFileName(i).rfind(".")));
		}

		listbox[4]->addItem("Random");
		for (Size i = 0; i < backgroundCount; i++)
		{
			listbox[4]->addItem(std::to_string(i + 1));
		}

		for (Int32 i = 5; i < 21; i++)
		{
			listbox[6]->addItem(std::to_string(i));
		}
		listbox[6]->selectItem(8).scrollToView(8);

		menuTrack = sound.loadModule("sound/undead.xm");
	}
void Interface::doCommand(QString command_string, char type)
{
    QString command = request.extractCommand(command_string);
    QString id = request.extractId(command_string);

    clearConsole();
    printLines();


    if(type == 'p') //PERSON
    {
        if(request.getPerson(id).getId().isEmpty()) //needed to prevent crashes
        {
            setStatus("Person #" + id.toStdString() + " does not exist or is omitted!");
            return;
        }

        printMenuHead(command.toUpper().toStdString() + " PERSON");

        if(command == "edit")
        {
            editPerson(id);
        }
        else if(command == "delete")
        {
            deletePerson(id);
        }
        else if(command == "addr")
        {
            addPersonRelation(id);
        }
        else if(command == "viewr")
        {
            viewPersonXComputers(id);
        }
    }
    else if(type == 'c') //COMPUTER
    {
        if(request.getComputer(id).getId().isEmpty()) //needed to prevent crashes
        {
            setStatus("Computer #" + id.toStdString() + " does not exist!");
            return;
        }

        printMenuHead(command.toUpper().toStdString() + " COMPUTER");

        if(command == "edit")
        {
            editComputer(id);
        }
        else if(command == "delete")
        {
            deleteComputer(id);
        }
        else if(command == "addr")
        {
            addComputerRelation(id);
        }
        else if(command == "viewr")
        {
            viewComputerXPersons(id);
        }
    }
}