void lightweightdialog::handleSliderRelease()
{

    float slider_sum = 0;
    for (auto light = 0; light < nlights_; ++light) {
        slider_sum += sliders[light]->value();
    }
    for (auto light = 0; light < nlights_; ++light) {
        weights_[light] = (float)sliders[light]->value() / (float)slider_sum;
    }
    emit weightsChanged(weights_);
}
Example #2
0
void ANNModelWrapper::setArtificialNeuralNetwork(ArtificialNeuralNetwork *ann)
{
	this->ann = ann;

	switch(ann->getType()){
		case ann_base::ArtificialNeuralNetwork::NoType:

			break;
		case ann_base::ArtificialNeuralNetwork::Adaline:
			adaline = (Adaline*)ann;

			//TODO: 27/4/16 put connections here
			break;
		case ann_base::ArtificialNeuralNetwork::SimplePerceptron:
			sp = (SimplePerceptron*)ann;

			//TODO: 27/4/16 put connections here
			break;
		case ann_base::ArtificialNeuralNetwork::MultilayerPerceptron:
			mlp = (MultilayerPerceptron*)ann;

			connect(mlp, SIGNAL(weightsChanged()), SLOT(onWeightsChanged()));
//			connect(mlp, SIGNAL(trainingAboutStart()), SLOT(onTrainingAboutStart()));
//			connect(mlp, SIGNAL(trainingFinished()), SLOT(onTrainingFinished()));
			connect(mlp, SIGNAL(layerCountChanged(int, int)), SLOT(onLayerCountChanged(int, int)));
			connect(mlp, SIGNAL(layerRemoved(int)), SLOT(onLayerRemoved(int)));
			connect(mlp, SIGNAL(layerSizeChanged(int, int, int)), SLOT(onLayerSizeChanged(int, int, int)));
			break;
		case ann_base::ArtificialNeuralNetwork::Hopfiel:
			hopfield = (Hopfield*)ann;

			//TODO: 27/4/16 put connections here
			break;
		case ann_base::ArtificialNeuralNetwork::Kohonen:
			kohonen = (Kohonen*)ann;

			//TODO: 27/4/16 put connections here
			break;

	}

	setupTree();
}
Example #3
0
AddFtnDialog::AddFtnDialog(std::vector<std::string>& neighList,QDialog *parent) : QDialog(parent)
{
	this->cancelled=0;
	this->destPort=0;
	this->srcPort=0;
	this->sourceAddr="0000";
	this->destAddr="0000";
	this->outLabel=1000000;
	
	//source = new QLabel("Source Address:", this);
	//destination = new QLabel("Destination Address:", this);
	//labelTCP = new QLabel("TCP Destination Port :", this);
	//labelUDP = new QLabel("UDP Destination Port :", this);
	label = new QLabel("Label:", this);
	next = new QLabel("Next Hop :", this);

	sIPcb=new QCheckBox("Source Address", this);
	dIPcb=new QCheckBox("Destination Address", this);
	uPcb=new QCheckBox("UDP Destination Port", this);
	tPcb=new QCheckBox("TCP Destination Port", this);
	suPcb=new QCheckBox("UDP Source Port", this);
	stPcb=new QCheckBox("TCP Source Port", this);

	QValidator *inputMask=new QIntValidator(1,1000000,this);
	QValidator *portMask=new QIntValidator(1,65535,this);
	QDoubleValidator *weightMask=new QDoubleValidator(0.000,1.000,3,this);
	weightMask->setNotation(QDoubleValidator::StandardNotation);
	weightMask->setTop(1.000);

	add = new QPushButton("Add", this);
	cancel = new QPushButton("Cancel", this);


	nextHop = new QComboBox;
	for ( unsigned int i=0; i<neighList.size(); i++)
	{
		nextHop->addItem(tr(neighList[i].c_str()));
	}

	nextHop2 = new QComboBox;
	for ( unsigned int i=0; i<neighList.size(); i++)
	{
		nextHop2->addItem(tr(neighList[i].c_str()));
	}


	le1 = new QLineEdit(this);
	le1->setInputMask("999.999.999.999/99;_");

	le2 = new QLineEdit(this);
	le2->setInputMask("999.999.999.999/99;_");

	le3 = new QLineEdit(this);
	le3->setValidator(inputMask);
	le8 = new QLineEdit(this);
	le8->setValidator(portMask);
	le9 = new QLineEdit(this);
	le9->setValidator(portMask);
	le10 = new QLineEdit(this);
	le10->setValidator(portMask);
	le11 = new QLineEdit(this);
	le11->setValidator(portMask);

	label2 = new QLabel("Label:", this);
	next2 = new QLabel("Next Hop :", this);
	le4 = new QLineEdit(this);
	le4->setValidator(inputMask);
	le5 = new QLineEdit(this);
	le5->setValidator(inputMask);
	le6 = new QLineEdit(this);
	le6->setValidator(weightMask);
	le7 = new QLineEdit(this);
	le7->setValidator(weightMask);

	grid = new QGridLayout(); 
	cb=new QCheckBox("Configure Fast Reroute", this);
	
	main = new QLabel(this);
	main->setTextFormat(Qt::RichText);
	main->setText("<b><u>Primary Path</u></b>");
	bcup = new QLabel(this);
	bcup->setTextFormat(Qt::RichText);
	bcup->setText("<b><u>Backup Path</u></b>");
	polic = new QLabel(this);
	polic->setTextFormat(Qt::RichText);
	polic->setText("<b><u>Add Policy</u></b>");
	attrValue=new QLabel("Value",this);
	weights=new QLabel("Weights : 0<w<1",this);
	policyType=new QComboBox(this);
	policyType->addItem(tr("Default Policy"));
	policyType->addItem(tr("Weighted Policy"));
	policyAttr=new QComboBox;
	policyAttr->addItem(tr("Max Packets in Queue"));
	policyAttr->addItem(tr("Max Bytes in Queue"));
	connect(le6, SIGNAL(textChanged(QString)), this, SLOT(weightsChanged()));

	bcup->hide();
	label2->hide();
	nextHop2->hide();
	next2->hide();
	le4->hide();
	le5->hide();
	le6->hide();
	le7->hide();
	policyAttr->hide();
	policyType->hide();
	attrValue->hide();
	polic->hide();
	attrValue->hide();
	weights->hide();

	//grid->addWidget(source, 0, 0);
	grid->addWidget(sIPcb, 0, 0);
	grid->addWidget(le1, 0, 1);
	//grid->addWidget(destination, 1, 0);
	grid->addWidget(dIPcb, 1, 0);
	grid->addWidget(le2, 1, 1);
	grid->addWidget(suPcb, 2, 0);
	grid->addWidget(le10, 2, 1);
	grid->addWidget(stPcb, 3, 0);
	grid->addWidget(le11, 3, 1);
	grid->addWidget(uPcb, 4, 0);
	grid->addWidget(le8, 4, 1);
	grid->addWidget(tPcb, 5, 0);
	grid->addWidget(le9, 5, 1);
	grid->addWidget(main,6,0);
	grid->addWidget(label, 7, 0);
	grid->addWidget(le3, 7, 1);
	grid->addWidget(next, 8, 0);
	grid->addWidget(nextHop, 8, 1);
	grid->addWidget(cb,9,0);
	grid->addWidget(bcup,10,0);
	grid->addWidget(label2, 11, 0);
	grid->addWidget(le4, 11, 1);
	grid->addWidget(next2, 12, 0);
	grid->addWidget(nextHop2, 12, 1);
	grid->addWidget(polic,13,0);
	grid->addWidget(policyType,14,0);
	grid->addWidget(policyAttr,14,1);
	grid->addWidget(attrValue,15,0);
	grid->addWidget(le5,15,1);
	grid->addWidget(weights,16,0);
	grid->addWidget(le6,17,0);
	grid->addWidget(le7,17,1);
	grid->addWidget(add, 18, 0);
	grid->addWidget(cancel, 18, 1);

	le1->setReadOnly(1);
	le2->setReadOnly(1);
	le8->setReadOnly(1);
	le9->setReadOnly(1);
	le10->setReadOnly(1);
	le11->setReadOnly(1);

	connect(add, SIGNAL(clicked()), this, SLOT(add2()));
	connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
	connect(cb, SIGNAL(stateChanged(int)), this, SLOT(fastReroute(int)));
	connect(sIPcb, SIGNAL(stateChanged(int)), this, SLOT(enableSIP(int)));
	connect(dIPcb, SIGNAL(stateChanged(int)), this, SLOT(enableDIP(int)));
	connect(uPcb, SIGNAL(stateChanged(int)), this, SLOT(enableUP(int)));
	connect(tPcb, SIGNAL(stateChanged(int)), this, SLOT(enableTP(int)));
	connect(suPcb, SIGNAL(stateChanged(int)), this, SLOT(enableSUP(int)));
	connect(stPcb, SIGNAL(stateChanged(int)), this, SLOT(enableSTP(int)));
	connect(policyType, SIGNAL(activated(QString)), this, SLOT(showWeights(QString)));

	setLayout(grid);
	this->setWindowTitle("Add FEC to NHLFE Map");
}