Exemplo n.º 1
0
void VariableCapacitor::dataChanged() {


	double new_minCapacitance = dataDouble("minimum capacitance");
	double new_maxCapacitance = dataDouble("maximum capacitance");

	if (new_minCapacitance != m_minCapacitance) {
		if (new_minCapacitance >= m_maxCapacitance) {
			m_minCapacitance = m_maxCapacitance;
			property("minimum capacitance")->setValue(m_minCapacitance);
		} else m_minCapacitance = new_minCapacitance;
	}

	if (new_maxCapacitance != m_maxCapacitance) {
		if (new_maxCapacitance <= m_minCapacitance) {
			m_maxCapacitance = m_minCapacitance;
			property("maximum capacitance")->setValue(m_maxCapacitance);
		} else m_maxCapacitance = new_maxCapacitance;
	}

	/*  Attempt at  fixme.
		m_currCapacitance = property( "currcapacitance" )->value().asDouble();

		if(m_currCapacitance > m_maxCapacitance) m_currCapacitance = m_maxCapacitance;
		else if(m_currCapacitance < m_minCapacitance) m_currCapacitance = m_minCapacitance;
	*/

	m_tickValue = (m_maxCapacitance - m_minCapacitance) / m_pSlider->maxValue();

	property("currcapacitance")->setValue(m_currCapacitance);

	// Calculate the capacitance jump per tick of a 100 tick slider.
	sliderValueChanged("slider", slider("slider")->value());
}
Exemplo n.º 2
0
void VariableResistor::dataChanged()
{

    double new_minResistance = dataDouble( "minimum resistance" );
    double new_maxResistance = dataDouble( "maximum resistance" );

    if( new_minResistance != m_minResistance )
    {
        if( new_minResistance >= m_maxResistance )
        {
            m_minResistance = m_maxResistance;
            property( "minimum resistance" )->setValue( m_minResistance );
        } else m_minResistance = new_minResistance;
    }

    if( new_maxResistance != m_maxResistance )
    {
        if( new_maxResistance <= m_minResistance )
        {
            m_maxResistance = m_minResistance;
            property( "maximum resistance" )->setValue( m_maxResistance );
        } else m_maxResistance = new_maxResistance;
    }

    m_tickValue = ( m_maxResistance - m_minResistance ) / m_pSlider->maxValue();

    // Calculate the resistance jump per tick of a 100 tick slider.
    sliderValueChanged( "slider", slider("slider")->value() );
}
Exemplo n.º 3
0
void ECMOSFET::dataChanged()
{
	bool haveBodyPin = dataBool( "bodyPin" );
	if ( haveBodyPin != m_bHaveBodyPin )
	{
		m_bHaveBodyPin = haveBodyPin;
		if ( m_bHaveBodyPin )
		{
			// Creating a body pin
			ECNode * NodeB = createPin( 16, 0, 180, "b" );
			removeElement( m_pMOSFET, false );
			m_pMOSFET = createMOSFET( ecNodeWithID( "d" ), ecNodeWithID( "g" ), ecNodeWithID( "s" ), NodeB, m_MOSFET_type );
		}
		else
		{
			// Removing a body pin
			removeNode( "b" );
			removeElement( m_pMOSFET, false );
			m_pMOSFET = createMOSFET( ecNodeWithID( "d" ), ecNodeWithID( "g" ), ecNodeWithID( "s" ), ecNodeWithID( "s" ), m_MOSFET_type );
		}
	}
	
#if 0
	MOSFETSettings s;
	s.I_S = dataDouble( "I_S" );
	s.N_F = dataDouble( "N_F" );
	s.N_R = dataDouble( "N_R" );
	s.B_F = dataDouble( "B_F" );
	s.B_R = dataDouble( "B_R" );
	
	m_pMOSFET->setMOSFETSettings( s );
#endif
}
Exemplo n.º 4
0
void FloatingProbe::dataChanged() {
	Probe::dataChanged();

	if (dataString("scaling") == "Linear")
		m_pFloatingProbeData->setScaling(FloatingProbeData::Linear);
	else	m_pFloatingProbeData->setScaling(FloatingProbeData::Logarithmic);

	m_pFloatingProbeData->setUpperAbsValue(dataDouble("upper_abs_value"));
	m_pFloatingProbeData->setLowerAbsValue(dataDouble("lower_abs_value"));
}
Exemplo n.º 5
0
void ECJFET::dataChanged()
{
	JFETSettings s;
	s.V_Th = dataDouble( "V_Th" );
	s.beta = dataDouble( "beta" );
	s.I_S = dataDouble( "I_S" );
	s.N = dataDouble( "N" );
	s.N_R = dataDouble( "N_R" );
	
	m_pJFET->setJFETSettings( s );
}
Exemplo n.º 6
0
void ECCurrentSignal::dataChanged()
{
	const double current = dataDouble("1-current");
	const double frequency = dataDouble("1-frequency");
	
	QString display = QString::number( current / getMultiplier(current), 'g', 3 ) + getNumberMag(current) + "A";
	setDisplayText( "current", display );
	
	m_currentSignal->setStep(ElementSignal::st_sinusoidal, frequency );
	m_currentSignal->setCurrent(current);
}
Exemplo n.º 7
0
void ECBJT::dataChanged()
{
	BJTSettings s;
	s.I_S = dataDouble( "I_S" );
	s.N_F = dataDouble( "N_F" );
	s.N_R = dataDouble( "N_R" );
	s.B_F = dataDouble( "B_F" );
	s.B_R = dataDouble( "B_R" );
	
	m_pBJT->setBJTSettings( s );
}
Exemplo n.º 8
0
void ResistorDIP::initPins()
{
	const int count = dataInt("count");
	const double resistance = dataDouble("resistance");
	
	if ( count == m_resistorCount )
		return;
	
	if ( count < m_resistorCount )
	{
		for ( int i=count; i<m_resistorCount; ++i )
		{
			removeElement( m_resistance[i], false );
			m_resistance[i] = 0l;
			removeNode( "n"+QString::number(i) );
			removeNode( "p"+QString::number(i) );
		}
	}
	else
	{
		for ( int i=m_resistorCount; i<count; ++i )
		{
			const QString nid = "n"+QString::number(i);
			const QString pid = "p"+QString::number(i);
			m_resistance[i] = createResistance( createPin( -24, 0, 0, nid ), createPin( 24, 0, 180, pid ), resistance );
		}
	}
	m_resistorCount = count;
	
	setSize( -16, -count*8, 32, count*16, true );
	updateDIPNodePositions();
}
Exemplo n.º 9
0
void ECCell::dataChanged() {
    const double voltage = dataDouble("voltage");

    m_voltageSource.setVoltage(voltage);
    QString display = QString::number(voltage / getMultiplier(voltage), 'g', 3) + getNumberMag(voltage) + "V";
    setDisplayText("voltage", display);
}
Exemplo n.º 10
0
void Capacitor::dataChanged() {
	double capacitance = dataDouble("Capacitance");

	QString display = QString::number(capacitance / getMultiplier(capacitance), 'g', 3) + getNumberMag(capacitance) + "F";
	setDisplayText("capacitance", display);

	m_capacitance.setCapacitance(capacitance);
}
Exemplo n.º 11
0
void LEDBarGraphDisplay::dataChanged() {
	DiodeSettings ds;
	QColor color = dataColor("color");

	ds.I_S = dataDouble("I_S");
	ds.V_B = dataDouble("V_B");
	ds.N = dataDouble("N");

	initPins();

	// Update each diode in array with new diode setting as they are acting individually.

	for (unsigned i = 0; i < m_numRows; i++) {
		m_LEDParts[i]->setDiodeSettings(ds);
		m_LEDParts[i]->setColor(color);
	}
}
Exemplo n.º 12
0
void ECVCVS::dataChanged() {
	double gain = dataDouble("gain");

	QString display = QString::number(gain / getMultiplier(gain), 'g', 3) + getNumberMag(gain) + QChar(' ');
	setDisplayText("gain", display);

	m_vcvs.setGain(gain);
}
Exemplo n.º 13
0
void ECPotentiometer::dataChanged()
{
	m_resistance = dataDouble("resistance");
	
	QString display = QString::number( m_resistance / getMultiplier(m_resistance), 'g', 3 ) + getNumberMag(m_resistance) + QChar(0x3a9);
	setDisplayText( "res", display );
	
	sliderValueChanged( "slider", slider("slider")->value() );
}
Exemplo n.º 14
0
void ResistorDIP::dataChanged()
{
	initPins();
	const double resistance = dataDouble("resistance");
	for ( int i=0; i<m_resistorCount; ++i )
		m_resistance[i]->setResistance(resistance);
	
	const QString display = QString::number( resistance / getMultiplier(resistance), 'g', 3 ) + getNumberMag(resistance) + QChar(0x3a9);
	addDisplayText( "res", QRect( offsetX(), offsetY()-16, 32, 12 ), display );
}
Exemplo n.º 15
0
void ECMOSFET::propertyChanged(Property& theProperty, QVariant newValue, QVariant oldValue)
{
    Q_UNUSED(oldValue);

    if( theProperty.name() == "bodyPin") {
        bool haveBodyPin = newValue.toBool();
        if (haveBodyPin == m_bHaveBodyPin)
            return;

        // body pin state changed
        if (m_bHaveBodyPin) {
            // TODO Creating a body pin
//             removeElement(&m_pMOSFET, false);
//
//             setup4pinElement(m_pMOSFET, ecNodeWithID("d")->pin(),
//                 ecNodeWithID("g")->pin(), ecNodeWithID("s")->pin(),
//                 createPin(16, 0, 180, "b")->pin());

        } else {
            // TODO Removing a body pin
            // removeNode("b");
            // removeElement(&m_pMOSFET, false);

        }
    }

    MOSFETSettings s = m_pMOSFET.settings();
#if 0
    s.I_S = dataDouble("I_S");
    s.N_F = dataDouble("N_F");
    s.N_R = dataDouble("N_R");
    s.B_F = dataDouble("B_F");
    s.B_R = dataDouble("B_R");
#endif
    if( theProperty.name() == "mosfetL") {
        s.L = newValue.toDouble();
    } else if(theProperty.name() == "mosfetW") {
        s.W = newValue.toDouble();
    } else
        qCritical() << "ECMOSFET: unknown property: " << theProperty.name();

    m_pMOSFET.setMOSFETSettings(s);
}
Exemplo n.º 16
0
void ECKeyPad::dataChanged() {
    initPins(dataInt("numCols"));

    bool useToggle = dataBool("useToggles");
    bool bounce = dataBool("bounce");
    int bouncePeriod_ms = int(dataDouble("bounce_period") * 1e3);

    for (unsigned i = 0; i < 4; i++) {
        for (unsigned j = 0; j < m_numCols; j++) {
            button(buttonID(i, j))->setToggle(useToggle);
            m_switch[i][j]->setBounce(bounce, bouncePeriod_ms);
        }
    }
}
Exemplo n.º 17
0
void Delay::generateMicrobe( FlowCode *code )
{
	const double delayLength_ms = dataDouble("delay_length")*1e3;
	code->addCode( "delay "+QString::number(delayLength_ms) );
	code->addCodeBranch( outputPart("stdoutput") );
	
// 	code->addVariable("COUNT_REPEAT");
	
#if 0
	// Code for pauses less than 769uS
	if ( pauseLength < 769 )
	{
		code->addCodeBlock( id(),	"movlw " + QString::number(pauseLength/3) + "\n"
									"movwf COUNT_REPEAT\n"
									"call count_3uS\n"
									+ gotoCode("stdoutput") );
									
		code->addCodeBlock( "count_3uS",	"decfsz COUNT_REPEAT,1\n"
											"goto count_3uS\n"
											"return" );
	}
	else if ( pauseLength < 196609 )
	{
		code->addVariable("COUNT_LOOP_1");
		
		code->addCodeBlock( id(),	"movlw " + QString::number(pauseLength/(3*256)) + "\n"
									"movwf COUNT_REPEAT\n"
									"call count_768uS\n"
									+ gotoCode("stdoutput") );
									
		code->addCodeBlock( "count_768uS",	"decfsz	COUNT_LOOP_1,1\n"
											"goto count_768uS\n"
											"decfsz COUNT_REPEAT,1\n"
											"goto count_768uS\n"
											"return" );
	}
	else if ( pauseLength < 50331649 )
	{
		code->addVariable("COUNT_LOOP_1");
		code->addVariable("COUNT_LOOP_2");
		
		code->addCodeBlock( id(),	"movlw " + QString::number(pauseLength/(3*256*256)) + "\n"
									"movwf COUNT_REPEAT\n"
									"call count_200mS\n"
									+ gotoCode("stdoutput") );
									
		code->addCodeBlock( "count_200mS",	"decfsz	COUNT_LOOP_1,1\n"
											"goto count_200mS\n"
											"decfsz COUNT_LOOP_2,1\n"
											"goto count_200mS\n"
											"decfsz COUNT_REPEAT,1\n"
											"goto count_200mS\n"
											"return" );
	}
	else/* if ( pauseLength < 12884901889 )*/
	{
		code->addVariable("COUNT_LOOP_1");
		code->addVariable("COUNT_LOOP_2");
		code->addVariable("COUNT_LOOP_3");
		
		code->addCodeBlock( id(),	"movlw " + QString::number(pauseLength/(3*256*256*256)) + "\n"
									"movwf COUNT_REPEAT\n"
									"call count_50S\n"
									+ gotoCode("stdoutput") );
									
		code->addCodeBlock( "count_50S",	"decfsz	COUNT_LOOP_1,1\n"
											"goto count_50S\n"
											"decfsz COUNT_LOOP_2,1\n"
											"goto count_50S\n"
											"decfsz COUNT_LOOP_3,1\n"
											"goto count_50S\n"
											"decfsz COUNT_REPEAT,1\n"
											"goto count_50S\n"
											"return" );
	}
#endif
}
Exemplo n.º 18
0
void Meter::dataChanged()
{
	m_minValue = dataDouble("0-minValue");
	m_maxValue = dataDouble("1-maxValue");
	setChanged();
}
Exemplo n.º 19
0
void DPArrow::dataChanged()
{
	DPLine::dataChanged();
	m_headAngle = dataDouble( "HeadAngle" );
	setChanged();
}
Exemplo n.º 20
0
void Delay::dataChanged()
{
	double delay = dataDouble("delay_length");
	setCaption( i18n("Delay for %1 sec").arg(QString::number( delay / getMultiplier(delay), 'g', 3 )+getNumberMag(delay)) );
}