コード例 #1
0
ファイル: flipflop.cpp プロジェクト: ktechlab/ktechlab-0.3
ECSRFlipFlop::ECSRFlipFlop( ICNDocument *icnDocument, bool newItem, const char *id )
	: Component( icnDocument, newItem, id ? id : "sr_flipflop" )
{
	m_name = i18n("SR Flip-Flop");
	
	setSize( -24, -24, 48, 48 );

	init2PinLeft( -8, 8 );
	init2PinRight( -8, 8 );
	
	m_pS = createLogicIn( m_pNNode[0] );
	m_pR = createLogicIn( m_pNNode[1] );
	m_pQ = createLogicOut( m_pPNode[0], true );
	m_pQBar = createLogicOut( m_pPNode[1], false );
	
	old_q1 = true;
	old_q2 = false;
	m_pQ->setHigh(old_q1);
	m_pQBar->setHigh(old_q2);
	
	addDisplayText( "S", QRect( -24, -16, 20, 16 ), "S" );
	addDisplayText( "R", QRect( -24, 0, 20, 16 ), "R" );
	addDisplayText( "Q", QRect( 4, -16, 20, 16 ), "Q" );
	addDisplayText( "Q'", QRect( 4, 0, 20, 16 ), "Q'" );
	
	m_pS->setCallback( this, static_cast<CallbackPtr>(&ECSRFlipFlop::inStateChanged) );
	m_pR->setCallback( this, static_cast<CallbackPtr>(&ECSRFlipFlop::inStateChanged) );
	m_pQ->setCallback( this, static_cast<CallbackPtr>(&ECSRFlipFlop::inStateChanged) );
	m_pQBar->setCallback( this, static_cast<CallbackPtr>(&ECSRFlipFlop::inStateChanged) );
}
コード例 #2
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 ), "" );
}
コード例 #3
0
VarComparison::VarComparison( ICNDocument *icnDocument, bool newItem, const char *id )
	: FlowPart( icnDocument, newItem, id ? id : "varcomparison" )
{
	m_name = i18n("Variable Comparison");
	initDecisionSymbol();
	createStdInput();
	createStdOutput();
	createAltOutput();
	
	createProperty( "0var1", Variant::Type::Combo );
	property("0var1")->setCaption( i18n("Variable") );
	property("0var1")->setValue("x");
	
	createProperty( "1op", Variant::Type::Select );
	property("1op")->setAllowed( QStringList::split( ',', "==,<,>,<=,>=,!=" ) );
	property("1op")->setValue("==");
	property("1op")->setToolbarCaption(" ");
	property("1op")->setEditorCaption( i18n("Operation") );
	
	createProperty( "2var2", Variant::Type::Combo );
	property("2var2")->setToolbarCaption(" ");
	property("2var2")->setEditorCaption( i18n("Value") );
	property("2var2")->setValue("0");
	
	addDisplayText( "output_false", QRect( offsetX()+width(), 2, 40, 20 ), "No" );
	addDisplayText( "output_true", QRect( 0, offsetY()+height(), 50, 20 ), "Yes" ); 
}
コード例 #4
0
ファイル: flipflop.cpp プロジェクト: ktechlab/ktechlab-0.3
ECDFlipFlop::ECDFlipFlop( ICNDocument *icnDocument, bool newItem, const char *id )
	: ClockedFlipFlop( icnDocument, newItem, id ? id : "d_flipflop" )
{
	m_name = i18n("D-Type Flip-Flop");
	
	setSize( -32, -24, 64, 48 );
	init2PinLeft( -8, 8 );
	init2PinRight( -8, 8 );
	initSymbolFromTrigger();
	
	m_prevD = false;
	m_pSimulator = Simulator::self();
	
	m_bPrevClock = false;
	m_pD = createLogicIn( m_pNNode[0] );
	m_pClock = createLogicIn( m_pNNode[1] );
	m_pQ = createLogicOut( m_pPNode[0], false );
	m_pQBar = createLogicOut( m_pPNode[1], false );
	
	setp = createLogicIn( createPin( 0, -32, 90, "set" ) );
	rstp = createLogicIn( createPin( 0, 32, 270, "rst" ) );
	
	// (The display text for D, >, Set, Rst is set in initSymbolFromTrigger
	addDisplayText( "Q",	QRect( 12,	-16,	20, 16 ), "Q" );
	addDisplayText( "Q'",	QRect( 12,	0,		20, 16 ), "Q'" );
	
	m_pD->setCallback( this, static_cast<CallbackPtr>(&ECDFlipFlop::inputChanged) );
	m_pClock->setCallback( this, static_cast<CallbackPtr>(&ECDFlipFlop::clockChanged) );
	setp->setCallback( this, static_cast<CallbackPtr>(&ECDFlipFlop::asyncChanged) );
	rstp->setCallback( this, static_cast<CallbackPtr>(&ECDFlipFlop::asyncChanged) );
	
	inStateChanged(false);
}
コード例 #5
0
ファイル: flipflop.cpp プロジェクト: ktechlab/ktechlab-0.3
void ECDFlipFlop::initSymbolFromTrigger()
{
	int offset = (m_edgeTrigger == Rising) ? 0 : 6;
	
	int w = 64-offset;
	setSize( offset-32, -24, w, 48, true );
	m_pNNode[0]->setLength( 8+offset );
	addDisplayText( "D",	QRect( offset-28,	-16,	20, 16 ), "D", true, Qt::AlignLeft );
	addDisplayText( ">",	QRect( offset-28,	0,		20, 16 ), ">", true, Qt::AlignLeft ); 
	addDisplayText( "Set",	QRect( offset-28,	-20,	w-8, 16 ), "Set", true, Qt::AlignHCenter );
	addDisplayText( "Rst",	QRect( offset-28,	4,		w-8, 16 ), "Rst", true, Qt::AlignHCenter );
	
	updateAttachedPositioning();
}
コード例 #6
0
ファイル: ec555.cpp プロジェクト: ktechlab/ktechlab
EC555::EC555( ICNDocument *icnDocument, bool newItem, const char *id )
	: Component( icnDocument, newItem, (id) ? id : "555" )
{
	m_name = i18n("555");
// 	m_pins = QStringList::split( ',', "Gnd,Trg,Out,Res,CV,Th,Dis,Vcc" );
// 	m_pins = QStringList::split( ',', "Dis,Th,Trg,Gnd,CV,Out,Res,Vcc" );
	
	old_com1 = false;
	old_com2 = false;
	old_q = false;
	
	setSize( -32, -32, 64, 64 );

	// Pins down left
	
	// Pin 7
	discharge = createPin( -40, -16, 0, "Dis" )->pin();
	addDisplayText( "dis", QRect( -32, -24, 24, 16 ), "Dis" );
	
	// Pin 6
	threshold = createPin( -40, 0, 0, "Th" )->pin();
	addDisplayText( "th", QRect( -32, -8, 24, 16 ), "Th" );
	
	// Pin 2
	trigger = createPin( -40, 16, 0, "Trg" )->pin();
	addDisplayText( "trg", QRect( -32, 8, 24, 16 ), "Trg" );

	// Top two
	
	// Pin 8
	vcc = createPin( -16, -40, 90, "Vcc" )->pin();
	addDisplayText( "vcc", QRect( -24, -32, 16, 8 ), "+" );
	
	// Pin 4
	reset = createPin( 16, -40, 90, "Res" )->pin();
	addDisplayText( "res", QRect( 8, -28, 16, 16 ), "Res" );
	
	// Bottom two
	
	// Pin 1
	ground = createPin( -16, 40, 270, "Gnd" )->pin();
	addDisplayText( "gnd", QRect( -24, 20, 16, 8 ), "-" );
	
	// Pin 5
	control = createPin( 16, 40, 270, "CV" )->pin();
	addDisplayText( "cv", QRect( 8, 12, 16, 16 ), "CV" );
	
	// Output on right
	
	// Pin 3
	output = createPin( 40, 0, 180, "Out" )->pin();
	addDisplayText( "out", QRect( 8, -8, 16, 16 ), "Out" );
	
	m_r1 = createResistance( vcc, control, 5e3 );
	m_r23 = createResistance( control, ground, 1e4 );
	m_po_sink = createResistance( output, ground, 0. );
	m_po_source = createResistance( output, vcc, 0. );
	m_po_source->setConductance(0.);
	m_r_discharge = createResistance( discharge, ground, 0. );
}
コード例 #7
0
ファイル: ecpotentiometer.cpp プロジェクト: Munrek/ktechlab
ECPotentiometer::ECPotentiometer(ICNDocument *icnDocument, bool newItem, const char *id)
	: Component(icnDocument, newItem, id ? id : "potentiometer")
{
	m_name = i18n("Potentiometer");
	setSize(-16, -16, 40, 32);

	ECNode *m_p1 = createPin(32, 0, 180, "p1");

	m_sliderProp = 0.0;
	m_resistance = 5000.;

	setup2pinElement(m_r1, createPin(-8, -24, 90, "n1")->pin(), m_p1->pin());
	setup2pinElement(m_r2, createPin(-8, 24, 270, "n2")->pin(), m_p1->pin());

	Slider * s = addSlider("slider", 0, 100, 5, 50, Qt::Vertical, QRect(0, -16, 16, 32));
	m_pSlider = static_cast<QSlider*>(s->widget());

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

	addDisplayText("res", QRect(-56, -8, 40, 16), "");
}
コード例 #8
0
ファイル: testpin.cpp プロジェクト: Munrek/ktechlab
TestPin::TestPin( ICNDocument *icnDocument, bool newItem, const char *id )
	: FlowPart( icnDocument, newItem, id ? id : "testpin" )
{
	m_name = i18n("Test Pin State");
	initDecisionSymbol();
	createStdInput();
	createStdOutput();
	createAltOutput();
	
	createProperty( "pin", Variant::Type::Pin );
	property("pin")->setCaption( i18n("Pin") );
	property("pin")->setValue("RA0");
	
	addDisplayText( "output_false", QRect( offsetX()+width(), 2, 40, 20 ), "Low" );
	addDisplayText( "output_true", QRect( 0, offsetY()+height(), 50, 20 ), "High" );
}
コード例 #9
0
ファイル: meter.cpp プロジェクト: zoltanp/ktechlab-0.3
//BEGIN class Meter
Meter::Meter( ICNDocument *icnDocument, bool newItem, const char *id )
	: SimpleComponent( icnDocument, newItem, id )
{
	b_timerStarted = false;
	m_timeSinceUpdate = 0.;
	m_old_value  = 0.;
	m_avgValue = 0.;
	b_firstRun = true;
	m_prevProp = 0.0;
	setSize( -16, -16, 32, 32 );

	p_displayText = addDisplayText( "meter", QRect( -16, 16, 32, 16 ), displayText() );
	
	createProperty( "0-minValue", Variant::Type::Double );
	property("0-minValue")->setCaption( i18n("Minimum Value") );
	property("0-minValue")->setMinValue(1e-12);
	property("0-minValue")->setMaxValue(1e12);
	property("0-minValue")->setValue(1e-3);
	
	createProperty( "1-maxValue", Variant::Type::Double );
	property("1-maxValue")->setCaption( i18n("Maximum Value") );
	property("1-maxValue")->setMinValue(1e-12);
	property("1-maxValue")->setMaxValue(1e12);
	property("1-maxValue")->setValue(1e3);
}
コード例 #10
0
void MultiInputGate::updateSymbolText() {
	if (m_logicSymbolShape == Distinctive)
		removeDisplayText("rect-shape-text");
	else {
		int w = 32 - (m_bInvertedOutput ? 6 : 0);
		QRect r(-16, 4 - height() / 2, w, height() - 4);
		addDisplayText("rect-shape-text", r, m_rectangularShapeText, true, AlignTop | AlignHCenter);
	}
}
コード例 #11
0
ファイル: resistordip.cpp プロジェクト: ktechlab/ktechlab-0.3
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 );
}
コード例 #12
0
ファイル: flipflop.cpp プロジェクト: ktechlab/ktechlab-0.3
ECJKFlipFlop::ECJKFlipFlop( ICNDocument *icnDocument, bool newItem, const char *id )
	: ClockedFlipFlop( icnDocument, newItem, id ? id : "jk_flipflop" )
{
	m_name = i18n("JK-Type Flip-Flop");
	
	setSize( -32, -32, 64, 64 );
	init3PinLeft( -16, 0, 16 );
	init2PinRight( -16, 16 );
	initSymbolFromTrigger();
	
	m_bPrevClock = false;
	
	createProperty( "trig", Variant::Type::Select );
	property("trig")->setCaption( i18n("Trigger Edge") );
	QStringMap allowed;
	allowed["Rising"] = i18n("Rising");
	allowed["Falling"] = i18n("Falling");
	property("trig")->setAllowed( allowed );
	property("trig")->setValue("Rising");
	m_edgeTrigger = Rising;
	initSymbolFromTrigger();
	
	m_pJ = createLogicIn( m_pNNode[0] );
	m_pClock = createLogicIn( m_pNNode[1] );
	m_pK = createLogicIn( m_pNNode[2] );
	
	m_pQ = createLogicOut( m_pPNode[0], false );
	m_pQBar = createLogicOut( m_pPNode[1], false );

	setp = createLogicIn( createPin( 0, -40, 90, "set" ) );
	rstp = createLogicIn( createPin( 0, 40, 270, "rst" ) );
	
	addDisplayText( "Q",	QRect( 12,	-24,	20, 16 ), "Q" );
	addDisplayText( "Q'",	QRect( 12,	8,		20, 16 ), "Q'" );
		
	m_pClock->setCallback( this, static_cast<CallbackPtr>(&ECJKFlipFlop::clockChanged) );
	setp->setCallback( this, static_cast<CallbackPtr>(&ECJKFlipFlop::asyncChanged) );
	rstp->setCallback( this, static_cast<CallbackPtr>(&ECJKFlipFlop::asyncChanged) );
	
	inStateChanged(false);
}
コード例 #13
0
ファイル: pinmapping.cpp プロジェクト: ktechlab/ktechlab-0.3
void PIC_IC::initPackage( MicroInfo * microInfo )
{
	// The code in this function is a stripped down version of that in PICComponent::initPackage
	
	if (!microInfo)
		return;
	
	MicroPackage * microPackage = microInfo->package();
	if (!microPackage)
		return;
	
	//BEGIN Get pin IDs
	QStringList allPinIDs = microPackage->pinIDs();
	QStringList ioPinIDs = microPackage->pinIDs( PicPin::type_bidir | PicPin::type_input | PicPin::type_open );
	
	// Now, we make the unwanted pin ids blank, so a pin is not created for them
	const QStringList::iterator allPinIDsEnd = allPinIDs.end();
	for ( QStringList::iterator it = allPinIDs.begin(); it != allPinIDsEnd; ++it )
	{
		if ( !ioPinIDs.contains(*it) )
			*it = "";
	}
	//END Get pin IDs
	
	
	//BEGIN Remove old stuff
	// Remove old text
	TextMap textMapCopy = m_textMap;
	const TextMap::iterator textMapEnd = textMapCopy.end();
	for ( TextMap::iterator it = textMapCopy.begin(); it != textMapEnd; ++it )
		removeDisplayText(it.key());
	
	// Remove old nodes
	NodeInfoMap nodeMapCopy = m_nodeMap;
	const NodeInfoMap::iterator nodeMapEnd = nodeMapCopy.end();
	for ( NodeInfoMap::iterator it = nodeMapCopy.begin(); it != nodeMapEnd; ++it )
	{
		if ( !ioPinIDs.contains(it.key()) )
			removeNode( it.key() );
	}
	//END Remove old stuff
	
	
	
	//BEGIN Create new stuff
	initDIPSymbol( allPinIDs, 80 );
	initDIP(allPinIDs);
	//END Create new stuff
	
	
	addDisplayText( "picid", QRect(offsetX(), offsetY()-16, width(), 16), microInfo->id() );
}
コード例 #14
0
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());
}
コード例 #15
0
//BEGIN class DependentSource
DependentSource::DependentSource(ICNDocument *icnDocument, bool newItem, const char *id)
		: SimpleComponent(icnDocument, newItem, id) {
	setSize(-16, -16, 32, 32);

	init2PinLeft();
	init2PinRight();

	m_pNNode[1]->setLength(13);
	m_pPNode[1]->setLength(13);

	createProperty("gain", Variant::Type::Double);
	property("gain")->setCaption(i18n("Gain"));
	property("gain")->setValue(1.0);

	addDisplayText("gain", QRect(-16, -32, 32, 16), "");
}
コード例 #16
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() );

}
コード例 #17
0
ファイル: capacitor.cpp プロジェクト: ktechlab/ktechlab-0.3
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 );
}
コード例 #18
0
ファイル: capacitor.cpp プロジェクト: zoltanp/ktechlab-0.3
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);
}
コード例 #19
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), "");
}
コード例 #20
0
ファイル: piccomponent.cpp プロジェクト: ktechlab/ktechlab
void PICComponent::initPackage( MicroInfo * microInfo )
{
	MicroPackage * microPackage = microInfo ? microInfo->package() : 0l;
	
	if ( microPackage )
	{
		m_bCreatedInitialPackage = true;
		
		//BEGIN Get pin IDs
		QStringList allPinIDs = microPackage->pinIDs();
		QStringList ioPinIDs = microPackage->pinIDs( PicPin::type_bidir | PicPin::type_input | PicPin::type_open );
	
		// Now, we make the unwanted pin ids blank, so a pin is not created for them
		const QStringList::iterator allPinIDsEnd = allPinIDs.end();
		for ( QStringList::iterator it = allPinIDs.begin(); it != allPinIDsEnd; ++it )
		{
			if ( !ioPinIDs.contains(*it) )
				*it = "";
		}
		//END Get pin IDs
	
	
		//BEGIN Remove old stuff
		// Remove old text
		TextMap textMapCopy = m_textMap;
		const TextMap::iterator textMapEnd = textMapCopy.end();
		for ( TextMap::iterator it = textMapCopy.begin(); it != textMapEnd; ++it )
			removeDisplayText(it.key());
	
		// Remove the old pins
		deletePICComponentPins();
	
		// Remove old nodes
		NodeInfoMap nodeMapCopy = m_nodeMap;
		const NodeInfoMap::iterator nodeMapEnd = nodeMapCopy.end();
		for ( NodeInfoMap::iterator it = nodeMapCopy.begin(); it != nodeMapEnd; ++it )
		{
			if ( !ioPinIDs.contains(it.key()) )
				removeNode( it.key() );
		}
	
		removeElements();
		//END Remove old stuff
	
	
	
		//BEGIN Create new stuff
		initDIPSymbol( allPinIDs, 80 );
		initDIP(allPinIDs);
	
		PicPinMap picPinMap = microPackage->pins( PicPin::type_bidir | PicPin::type_input | PicPin::type_open );
		const PicPinMap::iterator picPinMapEnd = picPinMap.end();
		for ( PicPinMap::iterator it = picPinMap.begin(); it != picPinMapEnd; ++it )
			m_picComponentPinMap[it.key()] = new PICComponentPin( this, it.value() );
		//END Create new stuff
	
	
		removeDisplayText( "no_file" );
		addDisplayText( "picid", QRect(offsetX(), offsetY()-16, width(), 16), microInfo->id() );
	}
	else
	{
		setSize( -48, -72, 96, 144 );
		removeDisplayText( "picid" );
		addDisplayText( "no_file", sizeRect(), i18n("(No\nprogram\nloaded)") );
	}
	
	
	//BEGIN Update button positions
	int leftpos = (width()-88)/2+offsetX();
	button("run")->setOriginalRect( QRect( leftpos, height()+4+offsetY(), 20, 20 ) );
	button("pause")->setOriginalRect( QRect( leftpos+23, height()+4+offsetY(), 20, 20 ) );
	button("reset")->setOriginalRect( QRect( leftpos+46, height()+4+offsetY(), 20, 20 ) );
	button("reload")->setOriginalRect( QRect( leftpos+69, height()+4+offsetY(), 20, 20 ) );
	updateAttachedPositioning();
	//END Update button positions
}
コード例 #21
0
ParallelPortComponent::ParallelPortComponent(ICNDocument *icnDocument, bool newItem, const char *id)
		: DSubCon(icnDocument, newItem, id ? id : "parallel_port") {
	m_name = i18n("Parallel Port");

	Q3PointArray pa(4);
	pa[0] = QPoint(-32, -112);
	pa[1] = QPoint(32, -104);
	pa[2] = QPoint(32, 104);
	pa[3] = QPoint(-32, 112);
	setItemPoints(pa);

	m_pParallelPort = new ParallelPort();

	for (unsigned i = 0; i < 24; ++i)
		m_pLogic[i] = 0;

	ECNode *pin = 0;

	//BEGIN Data register
	for (int i = 0; i < 8; ++i) {
		QString id = QString("D%1").arg(i);
		QString name = id;

		pin = createPin(-40, -80 + 16 * i, 0, id);
		addDisplayText(id, QRect(-28, -88 + 16 * i, 28, 16), name, true, Qt::AlignLeft | Qt::AlignVCenter);

		m_pLogic[i] = new LogicOut(LogicConfig(), false);
		setup1pinElement(*(m_pLogic[i]), createPin(-40, -80 + 16 * i, 0, id)->pin());

//		m_pLogic[i]->setCallback(this, (CallbackPtr)(&ParallelPortComponent::dataCallback));
	}
	//END Data register

	//BEGIN Status register
	QString statusNames[] = {"ERR", "ON", "PE", "ACK", "BUSY"};

	// The statusIDs are referenced in the save file and must not change
	QString statusIDs[] = {"ERROR", "ONLINE", "PE", "ACK", "BUSY"};

	// Bits 0...2 in the Status register are not used
	for (int i = 3; i < 8; ++i) {
		QString id = statusIDs[i - 3];
		QString name = statusNames[i - 3];

		// Bit 3 (pin 15) doesn't not follow the same positioning pattern as
		// the other pins in the Status register.

		if (i == 3) {
			pin = createPin(40, -72, 180, id);
			addDisplayText(id, QRect(0, -80, 28, 16), name, true, Qt::AlignRight | Qt::AlignVCenter);
		} else {
			pin = createPin(-40, -16 + 16 * i, 0, id);
			addDisplayText(id, QRect(-28, -24 + 16*i, 28, 16), name, true, Qt::AlignLeft | Qt::AlignVCenter);
		}

		m_pLogic[i + 8] = new LogicOut(LogicConfig(), false);

		setup1pinElement(*(m_pLogic[i + 8]), pin->pin());
	}
	//END Status register

	//BEGIN Control register
	QString controlNames[] = { "STR", "AUT", "INIT", "SEL" };

	// The controlIDs are referenced in the save file and must not change
	QString controlIDs[] = { "STROBE", "AUTO", "INIT", "SELECT" };

	// Bits 4..7 are not used (well; bit 5 is, but not as a pin)
	for (int i = 0; i < 4; ++i) {
		QString id = controlIDs[i];
		QString name = controlNames[i];

		if (i == 0) {
			pin = createPin(-40, -96, 0, id);
			addDisplayText(id, QRect(-28, -104, 28, 16), name, true, Qt::AlignLeft | Qt::AlignVCenter);
		} else if (i == 1) {
			pin = createPin(40, -88, 180, id);
			addDisplayText(id, QRect(0, -96, 28, 16), name, true, Qt::AlignRight | Qt::AlignVCenter);
		} else {
			pin = createPin(40, -88 + i * 16, 180, id);
			addDisplayText(id, QRect(0, -96 + i * 16, 28, 16), name, true, Qt::AlignRight | Qt::AlignVCenter);
		}

		m_pLogic[i + 16] = new LogicOut(LogicConfig(), false);

		setup1pinElement(*(m_pLogic[i + 16]), pin->pin());

//		m_pLogic[i + 16]->setCallback(this, (CallbackPtr)(&ParallelPortComponent::controlCallback));
	}
	//END Control register

#if 0
	// And make the rest of the pins ground
	for (int i = 0; i < 8; ++i) {
		pin = createPin(40, -24 + i * 16, 180, QString("GND%1").arg(i));
		pin->pin()->setGroundType(Pin::gt_always);
	}

#endif
	Variant *v = createProperty("port", Variant::Type::Combo);
	v->setAllowed(ParallelPort::ports(Port::ExistsAndRW));
	v->setCaption(i18n("Port"));
}
コード例 #22
0
SerialPortComponent::SerialPortComponent( ICNDocument *icnDocument, bool newItem, const char *id )
	: Component( icnDocument, newItem, id ? id : "serial_port" )
{
	m_name = i18n("Serial Port");
	
	Q3PointArray pa( 4 );
	pa[0] = QPoint( -32, -48 );
	pa[1] = QPoint( 32, -40 );
	pa[2] = QPoint( 32, 40 );
	pa[3] = QPoint( -32, 48 );
	
	setItemPoints( pa );
	
	m_pSerialPort = new SerialPort();
	
	ECNode * pin = 0;
	
	// Works
	pin = createPin( -40,  32,   0, "CD" );
	addDisplayText( "CD", QRect( -28, 24, 28, 16 ), "CD", true, Qt::AlignLeft | Qt::AlignVCenter );
	m_pCD = createLogicOut( pin, false  );
	
	// Doesn't work
// 	pin = createPin( -40,  16,   0, "RD" );
	addDisplayText( "RD", QRect( -28, 8, 28, 16 ), "RD", true, Qt::AlignLeft | Qt::AlignVCenter );
// 	m_pRD = createLogicOut( pin, false  );
	
	// Works
	pin = createPin( -40,   0,   0, "TD" );
	addDisplayText( "TD", QRect( -28, -8, 28, 16 ), "TD", true, Qt::AlignLeft | Qt::AlignVCenter );
	m_pTD = createLogicIn( pin);
	m_pTD->setCallback( this, (CallbackPtr)(&SerialPortComponent::tdCallback) );
	
	// Works
	pin = createPin( -40, -16,   0, "DTR" );
	addDisplayText( "DTR", QRect( -28, -24, 28, 16 ), "DTR", true, Qt::AlignLeft | Qt::AlignVCenter );
	m_pDTR = createLogicIn( pin );
	m_pDTR->setCallback( this, (CallbackPtr)(&SerialPortComponent::dtrCallback) );
	
	// N/A
	pin = createPin( -40, -32,   0, "GND" );
	addDisplayText( "GND", QRect( -28, -40, 28, 16 ), "GND", true, Qt::AlignLeft | Qt::AlignVCenter );
	pin->pin()->setGroundType( Pin::gt_always );
	
	// Doesn't work
// 	pin = createPin(  40,  24, 180, "DSR" );
	addDisplayText( "DSR", QRect( 0, 16, 28, 16 ), "DSR", true, Qt::AlignRight | Qt::AlignVCenter );
// 	m_pDSR = createLogicIn( pin );
// 	m_pDSR->setCallback( this, (CallbackPtr)(&SerialPortComponent::dsrCallback) );
	
	// Doesn't work
// 	pin = createPin(  40,   8, 180, "RTS" );
	addDisplayText( "RTS", QRect( 0, 0, 28, 16 ), "RTS", true, Qt::AlignRight | Qt::AlignVCenter );
// 	m_pRTS = createLogicIn( pin );
// 	m_pRTS->setCallback( this, (CallbackPtr)(&SerialPortComponent::rtsCallback) );
	
	// Works
	pin = createPin(  40,  -8, 180, "CTS" );
	addDisplayText( "CTS", QRect( 0, -16, 28, 16 ), "CTS", true, Qt::AlignRight | Qt::AlignVCenter );
	m_pCTS = createLogicOut( pin, false  );
	
	// Works
	pin = createPin(  40, -24, 180, "RI" );
	addDisplayText( "RI", QRect( 0, -32, 28, 16 ), "RI", true, Qt::AlignRight | Qt::AlignVCenter );
	m_pRI = createLogicOut( pin, false  );
	
	Variant * v = createProperty( "port", Variant::Type::Combo );
	v->setAllowed( SerialPort::ports( Port::ExistsAndRW ) );
	v->setCaption( i18n("Port") );
	
// 	v = createProperty( "baudRate", Variant::Type::Select );
// 	v->setAllowed( QStringList::split( ",", "B0,B50,B75,B110,B134,B150,B200,B300,B600,B1200,B1800,B2400,B4800,B9600,B19200,B38400" ) );
// 	v->setCaption( i18n("Baud rate") );
// 	v->setValue("B9600");
}