示例#1
0
ECCurrentSignal::ECCurrentSignal( ICNDocument *icnDocument, bool newItem, const char *id )
	: Component( icnDocument, newItem, id ? id : "current_signal" )
{
	m_name = i18n("Current Signal");
	setSize( -8, -8, 16, 16 );
	
	init1PinLeft();
	init1PinRight();
	
	m_pNNode[0]->pin()->setGroundType( Pin::gt_low );
	m_currentSignal = createCurrentSignal( m_pNNode[0], m_pPNode[0], 0. );
	m_currentSignal->setStep(ElementSignal::st_sinusoidal, 50. );
	
	createProperty( "1-frequency", Variant::Type::Double );
	property("1-frequency")->setCaption( i18n("Frequency") );
	property("1-frequency")->setUnit("Hz");
	property("1-frequency")->setMinValue(1e-9);
	property("1-frequency")->setMaxValue(1e3);
	property("1-frequency")->setValue(50.0);
	
	createProperty( "1-current", Variant::Type::Double );
	property("1-current")->setCaption( i18n("Current Range") );
	property("1-current")->setUnit("A");
	property("1-current")->setMinValue(-1e12);
	property("1-current")->setMaxValue(1e12);
	property("1-current")->setValue(0.02);
	
	addDisplayText( "~", QRect( -8, -8, 16, 16 ), "~" );
	addDisplayText( "current", QRect( -16, -24, 32, 16 ), "" );
}
示例#2
0
BiDirLED::BiDirLED(ICNDocument *icnDocument, bool newItem, const char *id)
		: SimpleComponent(icnDocument, newItem, id ? id : "bidir_led") {
	m_name = i18n("Bidirectional LED");
	m_bDynamicContent = true;

	setSize(-8, -16, 16, 32);
	init1PinLeft();
	init1PinRight();
	setSize(-8, -24, 24, 40);

	m_pDiode[0] = new Diode();
	setup2pinElement(*(m_pDiode[0]), m_pNNode[0]->pin(), m_pPNode[0]->pin());

	m_pDiode[1] = new Diode();
	setup2pinElement(*(m_pDiode[1]), m_pPNode[0]->pin(), m_pNNode[0]->pin());

	avg_brightness[0] = avg_brightness[1] = 255;
	lastUpdatePeriod = 0.;
	r[0] = r[1] = g[0] = g[1] = b[0] = b[1] = 0;
	last_brightness[0] = last_brightness[1] = 255;

	createProperty("0-color1", Variant::Type::Color);
	property("0-color1")->setCaption(i18n("Color 1"));
	property("0-color1")->setColorScheme(ColorCombo::LED);

	createProperty("0-color2", Variant::Type::Color);
	property("0-color2")->setCaption(i18n("Colour 2"));
	property("0-color2")->setColorScheme(ColorCombo::LED);
}
示例#3
0
ECVoltMeter::ECVoltMeter( ICNDocument *icnDocument, bool newItem, const char *id )
	: Meter( icnDocument, newItem, id ? id : "voltmeter" )
{
	m_name = i18n("Voltmeter");
	m_unit = "V";
	
	init1PinLeft(0);
	init1PinRight(0);
}
示例#4
0
VoltageProbe::VoltageProbe(ICNDocument *icnDocument, bool newItem, const char *id)
		: FloatingProbe(icnDocument, newItem, id ? id : "voltageprobe") {
	m_name = i18n("Voltage Probe");

	property("upper_abs_value")->setUnit("V");
	property("lower_abs_value")->setUnit("V");

	init1PinLeft();
	init1PinRight();
	m_pPin1 = &m_pNNode[0]->pin();
	m_pPin2 = &m_pPNode[0]->pin();
}
VariableCapacitor::VariableCapacitor(ICNDocument* icnDocument, bool newItem, const QString& id)
		: SimpleComponent(icnDocument, newItem, id ? id : "variable capacitor"),
		m_pCapacitance(m_currCapacitance, LINEAR_UPDATE_PERIOD) {
	m_name = i18n("Variable Capacitor");

	// Top Left(x,y) from centre point, width, height.
	setSize(-16, -8, 32, 16);

	// william - you might want to change this value. I added this line as it
	// was being used unitialized (in the sliderValueChanged function when
	// addSlider is called later on), and causing a crash - david.
	m_tickValue = 1;

	m_maxCapacitance = 0.0001;
	m_minCapacitance = 0.00005;

	m_currCapacitance = m_minCapacitance + ((m_maxCapacitance - m_minCapacitance) / 2);

	init1PinLeft();
	init1PinRight();

	m_pNNode[0]->setLength(15);
	m_pPNode[0]->setLength(15);

	setup2pinElement(m_pCapacitance, m_pNNode[0]->pin(), m_pPNode[0]->pin());

	addDisplayText("capacitance", QRect(-8, -26, 16, 16), "", false);

	createProperty("currcapacitance", Variant::Type::Double);
	property("currcapacitance")->setCaption(i18n("Capacitance"));
	property("currcapacitance")->setUnit("F");
	property("currcapacitance")->setMinValue(1e-12);
	property("currcapacitance")->setMaxValue(1e12);
	property("currcapacitance")->setValue(m_currCapacitance);

	createProperty("maximum capacitance", Variant::Type::Double);
	property("maximum capacitance")->setCaption(i18n("Max"));
	property("maximum capacitance")->setUnit("F");
	property("maximum capacitance")->setMinValue(1e-12);
	property("maximum capacitance")->setMaxValue(1e12);
	property("maximum capacitance")->setValue(m_maxCapacitance);

	createProperty("minimum capacitance", Variant::Type::Double);
	property("minimum capacitance")->setCaption(i18n("Min"));
	property("minimum capacitance")->setUnit("F");
	property("minimum capacitance")->setMinValue(1e-12);
	property("minimum capacitance")->setMaxValue(1e12);
	property("minimum capacitance")->setValue(m_minCapacitance);

	Slider * s = addSlider("slider", 0, 100, 1, 50, Qt::Horizontal, QRect(-16, 10, 32, 16));
	m_pSlider = static_cast<QSlider*>(s->widget());
}
示例#6
0
CurrentProbe::CurrentProbe(ICNDocument *icnDocument, bool newItem, const char *id)
		: FloatingProbe(icnDocument, newItem, id ? id : "currentprobe"),
		 m_voltageSource(0) {
	m_name = i18n("Current Probe");

	property("upper_abs_value")->setUnit("A");
	property("lower_abs_value")->setUnit("A");

	init1PinLeft(0);
	init1PinRight(0);

	setup2pinElement(m_voltageSource, m_pNNode[0]->pin(), m_pPNode[0]->pin());
}
示例#7
0
ECAmmeter::ECAmmeter(ICNDocument *icnDocument, bool newItem, const char *id)
	: Meter(icnDocument, newItem, id ? id : "ammeter")
{
	m_name = i18n("Ammeter");
	setSize(-16, -16, 32, 32);
	m_unit = "A";

	init1PinLeft(0);
	init1PinRight(0);

	setup2pinElement(m_voltageSource, m_pNNode[0]->pin(), m_pPNode[0]->pin());
	m_voltageSource.setVoltage(0);
}
示例#8
0
BusSplitter::BusSplitter( ICNDocument *icnDocument, bool newItem, const char *id )
	: Component( icnDocument, newItem, id ? id : "Bus" )
{
	m_name = i18n("Bus Splitter");

	m_busSize = 0;	
	init1PinLeft();
	m_pInNode = m_pNNode[0];
	
	createProperty( "size", Variant::Type::Int );
	property("size")->setCaption( i18n("Size") );
	property("size")->setMinValue(1);
	property("size")->setMaxValue(MAX_BUS_SIZE);
	property("size")->setValue(8);
}
示例#9
0
Inverter::Inverter( ICNDocument *icnDocument, bool newItem, const char *id )
	: Component( icnDocument, newItem, id ? id : "not" )
{
	m_name = i18n("Inverter");
	setSize( -8, -8, 16, 16 );

	init1PinLeft();
	init1PinRight();
	
	m_pIn = createLogicIn(m_pNNode[0]);
	m_pOut = createLogicOut( m_pPNode[0], true );
	
	m_pIn->setCallback( this, (CallbackPtr)(&Inverter::inStateChanged) );
	inStateChanged(false);
}
示例#10
0
ECSignalLamp::ECSignalLamp( ICNDocument *icnDocument, bool newItem, const char *id )
	: Component( icnDocument, newItem, id ? id : "signal_lamp" )
{
	m_name = i18n("Signal Lamp");
	setSize( -8, -8, 16, 16 );
	
	init1PinLeft();
	init1PinRight();
	
	createResistance( m_pPNode[0], m_pNNode[0], RESISTANCE );
	
	advanceSinceUpdate = 0;
	avgPower = 0.;
	m_bDynamicContent = true;
}
示例#11
0
ECSignalLamp::ECSignalLamp(ICNDocument *icnDocument, bool newItem, const char *id)
	: SimpleComponent(icnDocument, newItem, id ? id : "signal_lamp")
{
	m_name = i18n("Signal Lamp");
	setSize(-8, -8, 16, 16);

	init1PinLeft();
	init1PinRight();

//	createResistance(m_pPNode[0]->pin(), m_pNNode[0]->pin(), RESISTANCE);
	the_filament.setResistance(RESISTANCE);
	setup2pinElement(the_filament, m_pPNode[0]->pin(), m_pNNode[0]->pin());

	advanceSinceUpdate = 0;
	avgPower = 0.;
	m_bDynamicContent = true;
}
示例#12
0
VariableResistor::VariableResistor( ICNDocument* icnDocument, bool newItem, const QString& id )
    : Component( icnDocument, newItem, (!id.isEmpty()) ? id : "variable resistor" )
{
    m_name = i18n("Resistor");

    // Top Left(x,y) from centre point, width, height.
    setSize( -16, -16, 32, 32 );

    init1PinLeft();
    init1PinRight();

    // (see comment in variablecapacitor.cpp) - david
    m_tickValue = 1;

    m_minResistance = 0.5;
    m_maxResistance = 1.0;

    m_currResistance = m_minResistance + ( ( m_maxResistance - m_minResistance ) / 2 ) ;

    m_pResistance = createResistance( m_pPNode[0], m_pNNode[0], m_currResistance );

    createProperty( "resistance", Variant::Type::Double );
    property("resistance")->setCaption( i18n("Resistance") );
    property("resistance")->setUnit( QChar( 0x3a9 ) );
    property("resistance")->setMinValue( 1e-6 );
    property("resistance")->setValue( m_currResistance );

    createProperty( "minimum resistance", Variant::Type::Double );
    property("minimum resistance")->setCaption( i18n("Min") );
    property("minimum resistance")->setUnit( QChar( 0x3a9 ) );
    property("minimum resistance")->setMinValue( 1e-6 );
    property("minimum resistance")->setValue( m_minResistance );

    createProperty( "maximum resistance", Variant::Type::Double );
    property("maximum resistance")->setCaption( i18n("Max") );
    property("maximum resistance")->setUnit( QChar( 0x3a9 ) );
    property("maximum resistance")->setMinValue( 1e-6 );
    property("maximum resistance")->setValue( m_maxResistance );

    addDisplayText( "res", QRect( -16, -26, 32, 12 ), "", false );

    Slider * s = addSlider( "slider", 0, 100, 1, 50, Qt::Horizontal, QRect( -16, 14, width(), 16 ) );
    m_pSlider = static_cast<QSlider*>( s->widget() );

}
示例#13
0
ECLogicOutput::ECLogicOutput( ICNDocument *icnDocument, bool newItem, const char *id )
	: Component( icnDocument, newItem, id ? id : "logic_output" )
{
	m_name = i18n("Logic Output");
	setSize( -8, -8, 16, 16 );
	
	init1PinLeft();
	m_pIn = createLogicIn(m_pNNode[0]);
	
	m_pSimulator = Simulator::self();
	
	m_lastDrawState = 0.0;
	m_lastSwitchTime = m_lastDrawTime = m_pSimulator->time();
	m_highTime = 0;
	m_bLastState = false;
	m_bDynamicContent = true;
	
	m_pIn->setCallback( this, (CallbackPtr)(&ECLogicOutput::inStateChanged) );
}
示例#14
0
Capacitor::Capacitor( ICNDocument *icnDocument, bool newItem, const char *id )
	: Component( icnDocument, newItem, id ? id : "capacitor" )
{
	m_name = i18n("Capacitor");
	setSize( -8, -8, 16, 16 );
	
	init1PinLeft();
	init1PinRight();
	
	m_capacitance = createCapacitance( m_pNNode[0], m_pPNode[0], 0.001 );
	
	createProperty( "Capacitance", Variant::Type::Double );
	property("Capacitance")->setCaption( i18n("Capacitance") );
	property("Capacitance")->setUnit("F");
	property("Capacitance")->setMinValue(1e-12);
	property("Capacitance")->setMaxValue(1e12);
	property("Capacitance")->setValue(1e-3);
	
	addDisplayText( "capacitance", QRect( -8, -24, 16, 16 ), "", false );
}
示例#15
0
Capacitor::Capacitor(ICNDocument *icnDocument, bool newItem, const char *id)
		: SimpleComponent(icnDocument, newItem, id ? id : "capacitor"),
		m_capacitance(0.001, LINEAR_UPDATE_PERIOD) {
	m_name = i18n("Capacitor");
	setSize(-8, -8, 16, 16);

	init1PinLeft();
	init1PinRight();

;
	setup2pinElement(m_capacitance, m_pNNode[0]->pin(), m_pPNode[0]->pin());

	createProperty("Capacitance", Variant::Type::Double);
	property("Capacitance")->setCaption(i18n("Capacitance"));
	property("Capacitance")->setUnit("F");
	property("Capacitance")->setMinValue(1e-12);
	property("Capacitance")->setMaxValue(1e12);
	property("Capacitance")->setValue(1e-3);

	addDisplayText("capacitance", QRect(-8, -24, 16, 16), "", false);
}
示例#16
0
ECCell::ECCell(ICNDocument *icnDocument, bool newItem, const char *id)
        : SimpleComponent(icnDocument, newItem, id ? id : "cell") {
    m_name = i18n("Battery");
    setSize(-8, -8, 16, 16);

    init1PinLeft();
    init1PinRight();

    m_pNNode[0]->pin().setGroundType(Pin::gt_medium);

    setup2pinElement(m_voltageSource, m_pNNode[0]->pin(), m_pPNode[0]->pin());

    createProperty("voltage", Variant::Type::Double);
    property("voltage")->setUnit("V");
    property("voltage")->setCaption(i18n("Voltage"));
    property("voltage")->setMinValue(-1e12);
    property("voltage")->setMaxValue(1e12);
    property("voltage")->setValue(5.0);

    addDisplayText("voltage", QRect(-16, -24, 32, 16), "");
}