Example #1
0
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);
}
Example #2
0
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), "");
}
Example #3
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();
}
Example #4
0
ECJFET::ECJFET( int JFET_type, ICNDocument * icnDocument, bool newItem, const char * id )
	: Component( icnDocument, newItem, id )
{
	m_JFET_type = JFET_type;
	if ( JFET_type == JFET::nJFET )
		m_name = i18n("N-Channel JFET");
	else
		m_name = i18n("P-Channel JFET");
	
	setSize( -8, -8, 16, 16 );
	m_pJFET = createJFET( createPin( 8, -16, 90, "D" ), createPin( -16, 0, 0, "G" ), createPin( 8, 16, 270, "S" ), JFET_type );
	
	JFETSettings s; // will be created with the default settings
	
	Variant * v = createProperty( "V_Th", Variant::Type::Double );
	v->setCaption( i18n("Threshold voltage") );
	v->setUnit("V");
	v->setMinValue(-1e6);
	v->setMaxValue(1e6);
	v->setValue( s.V_Th );
	v->setAdvanced( true );
	
	v = createProperty( "beta", Variant::Type::Double );
	v->setCaption( i18n("Transcondutance") );
	v->setUnit(QString("A/V") + QChar(0xb2));
	v->setMinValue(1e-12);
	v->setMaxValue(1e0);
	v->setValue( s.beta );
	v->setAdvanced( true );
	
	v = createProperty( "I_S", Variant::Type::Double );
	v->setCaption( i18n("Saturation current") );
	v->setUnit("A");
	v->setMinValue(1e-20);
	v->setMaxValue(1e0);
	v->setValue( s.I_S );
	v->setAdvanced( true );
	
	v = createProperty( "N", Variant::Type::Double );
	v->setCaption( i18n("PN emission coefficient") );
	v->setUnit("");
	v->setMinValue(0.0);
	v->setMaxValue(10.0);
	v->setValue( s.N );
	v->setAdvanced( true );
	
	v = createProperty( "N_R", Variant::Type::Double );
	v->setCaption( i18n("Isr emission coefficient") );
	v->setUnit("");
	v->setMinValue(0.0);
	v->setMaxValue(10.0);
	v->setValue( s.N_R );
	v->setAdvanced( true );
}
Example #5
0
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. );
}
Example #6
0
ECBJT::ECBJT( bool isNPN, ICNDocument * icnDocument, bool newItem, const char * id )
	: Component( icnDocument, newItem, id ? id : (isNPN ? "npnbjt" : "pnpbjt") )
{
	m_bIsNPN = isNPN;
	if ( m_bIsNPN )
		m_name = i18n("NPN Transistor");
	else
		m_name = i18n("PNP Transistor");
	
	setSize( -8, -8, 16, 16 );
	m_pBJT = createBJT( createPin( 8, -16, 90, "c" ), createPin( -16, 0, 0, "b" ), createPin( 8, 16, 270, "e" ), m_bIsNPN );
	
	BJTSettings s; // will be created with the default settings
	
	Variant * v = createProperty( "I_S", Variant::Type::Double );
	v->setCaption( i18n("Saturation Current") );
	v->setUnit("A");
	v->setMinValue(1e-20);
	v->setMaxValue(1e-0);
	v->setValue( s.I_S );
	v->setAdvanced(true);
	
	v = createProperty( "N_F", Variant::Type::Double );
	v->setCaption( i18n("Forward Coefficient") );
	v->setMinValue(1e0);
	v->setMaxValue(1e1);
	v->setValue( s.N_F );
	v->setAdvanced(true);
	
	v = createProperty( "N_R", Variant::Type::Double );
	v->setCaption( i18n("Reverse Coefficient") );
	v->setMinValue(1e0);
	v->setMaxValue(1e1);
	v->setValue( s.N_R );
	v->setAdvanced(true);
	
	v = createProperty( "B_F", Variant::Type::Double );
	v->setCaption( i18n("Forward Beta") );
	v->setMinValue(1e-1);
	v->setMaxValue(1e3);
	v->setValue( s.B_F );
	v->setAdvanced(true);
	
	v = createProperty( "B_R", Variant::Type::Double );
	v->setCaption( i18n("Reverse Beta") );
	v->setMinValue(1e-1);
	v->setMaxValue(1e3);
	v->setValue( s.B_R );
	v->setAdvanced(true);
}
Example #7
0
ECKeyPad::ECKeyPad(ICNDocument *icnDocument, bool newItem, const char *id)
        : Component(icnDocument, newItem, id ? id : "keypad") {
    m_name = i18n("Keypad");

    createProperty("useToggles", Variant::Type::Bool);
    property("useToggles")->setCaption(i18n("Use Toggles"));
    property("useToggles")->setValue(false);

    createProperty("numCols", Variant::Type::Int);
    property("numCols")->setCaption(i18n("Columns"));
    property("numCols")->setMinValue(3);
    property("numCols")->setMaxValue(9);
    property("numCols")->setValue(3);

    Variant *v = createProperty("bounce", Variant::Type::Bool);
    v->setCaption("Bounce");
    v->setAdvanced(true);
    v->setValue(false);

    v = createProperty("bounce_period", Variant::Type::Double);
    v->setCaption("Bounce Period");
    v->setAdvanced(true);
    v->setUnit("s");
    v->setValue(5e-3);

    for (int i = 0; i < 4; i++)
        createPin(0, -32 + i*24, 0, QString("row_%1").arg(QString::number(i)));

    m_numCols = 0;
}
Example #8
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
}
Example #9
0
FrequencyMeter::FrequencyMeter( ICNDocument *icnDocument, bool newItem, const char *id )
	: Meter( icnDocument, newItem, id ? id : "frequencymeter" )
{
	m_name = i18n("Frequency Meter");
	m_unit = "Hz";
	
	m_probeNode = createPin( 0, -24, 90, "n1" );
}
Example #10
0
E_LightBulb::E_LightBulb(Level& level,
						 const Vec2i& position,
						 int dir) : Electronics(level, position, dir)
{
	renderBox = false;
	on = false;

	// Eingang erzeugen
	createPin(0, Vec2i(7, 15), PT_INPUT);
}
Example #11
0
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);
}
Example #12
0
void MultiInputGate::updateInputs(int newNum) {
	if (newNum == m_numInputs) return;

	if (newNum < 2) newNum = 2;
	else if (newNum > maxGateInput)
		newNum = maxGateInput;

	int newWidth = logicSymbolShapeToWidth();

	QRect r(-newWidth / 2, -8 * newNum, newWidth, 16 * newNum);

	setSize(r, true);
	updateSymbolText();

	const bool added = (newNum > m_numInputs);

	if (added) {
		for (int i = m_numInputs; i < newNum; ++i) {
			ECNode *node = createPin(0, 0, 0, "in" + QString::number(i));
			inNode[i] = node;

			inLogic[i] = new LogicIn(LogicConfig());
			setup1pinElement(*(inLogic[i]), node->pin());

			inLogic[i]->setCallback(this, (CallbackPtr)(&MultiInputGate::inStateChanged));
		}
	} else {
		for (int i = newNum; i < m_numInputs; ++i) {
			removeNode("in" + QString::number(i));
			removeElement(inLogic[i], false);
			inNode[i] = 0;
			inLogic[i] = 0;
		}
	}

	m_numInputs = newNum;

	// We can't call a pure-virtual function if we haven't finished our constructor yet...

	if (m_bDoneInit)
		inStateChanged(!added);

	updateAttachedPositioning();
}
Example #13
0
void BusSplitter::dataChanged()
{
	unsigned busSize = dataInt("size");
	
	if ( busSize < 1 )
		busSize = 1;
	
	else if ( busSize > MAX_BUS_SIZE )
		busSize = MAX_BUS_SIZE;
	
	if ( busSize == m_busSize )
		return;
	
	m_pInNode->setNumPins(busSize);
	
	if ( busSize > m_busSize )
	{
		m_pWires.resize(busSize);
		for ( unsigned i = m_busSize; i < unsigned(busSize); i++ )
		{
			Pin * pin = createPin( 16, 0, 180, outNodeID(i) )->pin();
			m_pWires[i] = new Wire( m_pInNode->pin(i), pin );
		}
	}
	else
	{
		for ( unsigned i = busSize; i < unsigned(m_busSize); i++ )
		{
			removeNode( outNodeID(i) );
			delete m_pWires[i];
		}
		m_pWires.resize(busSize);
	}
	m_busSize = busSize;
	
	// Position pins
	setSize( 0, -int(m_busSize+1)*8, 8, int(m_busSize+1)*16, true );
	for ( int i = 0; i < int(m_busSize); i++ )
		m_nodeMap[ outNodeID(i) ].y = 16*i - int(m_busSize+1)*8 + 24;
	m_nodeMap["n1"].y = -int(m_busSize+1)*8 + 8;
	
	updateAttachedPositioning();
}
Example #14
0
void ECKeyPad::initPins(unsigned numCols) {
    if (numCols < 3)
        numCols = 3;
    else if (numCols > 9)
        numCols = 9;

    if (numCols == m_numCols)
        return;

    int w = sideLength(numCols);
    int h = sideLength(4);

    setSize(-int(w / 16)*8, -int(h / 16)*8, w, h, true);

    if (numCols > m_numCols) {
        // Adding columns
        for (unsigned i = 0; i < 4; i++) {
            for (unsigned j = m_numCols; j < numCols; j++)
                addButton(buttonID(i, j), QRect(0, 0, 20, 20), text[i][j]);
        }

        ECNode *cols[9];

        for (unsigned j = m_numCols; j < numCols; j++)
            cols[j] = createPin(0, 64, 270, "col_" + QString::number(j));

        for (unsigned i = 0; i < 4; i++) {
            Pin *row = &ecNodeWithID("row_" + QString::number(i))->pin();

            for (unsigned j = m_numCols; j < numCols; j++)
                m_switch[i][j] = new Switch(this, cols[j]->pin(), *row, Switch::Open);
        }
    } else {
        // Remove columns
        for (unsigned i = 0; i < 4; i++) {
            for (unsigned j = numCols; j < m_numCols; j++)
                removeWidget(buttonID(i, j));
        }

        for (unsigned j = numCols; j < m_numCols; j++)
            removeNode("col_" + QString::number(j));

        for (unsigned i = 0; i < 4; i++) {
            for (unsigned j = m_numCols; j < numCols; j++)
                delete m_switch[i][j];
        }
    }

    //BEGIN Update Positions
    m_numCols = numCols;

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < int(m_numCols); j++) {
            widgetWithID(buttonID(i, j))->setOriginalRect(
                QRect(offsetX() + 6 + 24*j, offsetY() + 6 + 24*i, 20, 20));
        }
    }

    for (int i = 0; i < 4; i++)
        m_nodeMap["row_" + QString::number(i)].x = width() + offsetX();

    for (int j = 0; j < int(m_numCols); j++)
        m_nodeMap["col_" + QString::number(j)].x = 24 * j + offsetX() + 16;

    updateAttachedPositioning();
    //END Update Positions
}
Example #15
0
ECMOSFET::ECMOSFET( int MOSFET_type, ICNDocument * icnDocument, bool newItem, const char * id )
	: Component( icnDocument, newItem, id )
{
	m_MOSFET_type = MOSFET_type;
	switch ( (MOSFET::MOSFET_type) m_MOSFET_type )
	{
		case MOSFET::neMOSFET:
		{
			m_name = i18n("N-Channel Enhancement MOSFET");
			break;
		}
		
		case MOSFET::peMOSFET:
		{
			m_name = i18n("P-Channel Enhancement MOSFET");
			break;
		}
		
#if 0
		case MOSFET::ndMOSFET:
		{
			m_name = i18n("N-Channel Depletion MOSFET");
			break;
		}
		
		case MOSFET::pdMOSFET:
		{
			m_name = i18n("P-Channel Depletion MOSFET");
			break;
		}
#endif
	}
	
	setSize( -8, -16, 16, 32 );
	ECNode * NodeS = createPin( 8, 24, 270, "s" );
	m_pMOSFET = createMOSFET( createPin( 8, -24, 90, "d" ), createPin( -16, 8, 0, "g" ), NodeS, NodeS, m_MOSFET_type );
	m_bHaveBodyPin = false;
	
	Variant * v = createProperty( "bodyPin", Variant::Type::Bool );
	v->setCaption( i18nc( "mosfet body/bulk pin", "Body Pin") );
	v->setValue( false );
	
#if 0
	MOSFETSettings s; // will be created with the default settings
	v = createProperty( "I_S", Variant::Type::Double );
	v->setCaption( i18n("Saturation Current") );
	v->setUnit("A");
	v->setMinValue(1e-20);
	v->setMaxValue(1e-0);
	v->setValue( s.I_S );
	v->setAdvanced(true);
	
	v = createProperty( "N_F", Variant::Type::Double );
	v->setCaption( i18n("Forward Coefficient") );
	v->setMinValue(1e0);
	v->setMaxValue(1e1);
	v->setValue( s.N_F );
	v->setAdvanced(true);
	
	v = createProperty( "N_R", Variant::Type::Double );
	v->setCaption( i18n("Reverse Coefficient") );
	v->setMinValue(1e0);
	v->setMaxValue(1e1);
	v->setValue( s.N_R );
	v->setAdvanced(true);
	
	v = createProperty( "B_F", Variant::Type::Double );
	v->setCaption( i18n("Forward Beta") );
	v->setMinValue(1e-1);
	v->setMaxValue(1e3);
	v->setValue( s.B_F );
	v->setAdvanced(true);
	
	v = createProperty( "B_R", Variant::Type::Double );
	v->setCaption( i18n("Reverse Beta") );
	v->setMinValue(1e-1);
	v->setMaxValue(1e3);
	v->setValue( s.B_R );
	v->setAdvanced(true);
#endif
}
Example #16
0
void MatrixDisplay::initPins(unsigned numRows, unsigned numCols) {
    if ((numRows == m_numRows) && (numCols == m_numCols))
        return;

    m_lastUpdatePeriod = 0.0;

    //BEGIN Create or destroy pins
// FIXME: Very Very broken. =( -- breaks on resize above initial size... 

    if (numCols >= m_numCols) {
        m_LEDs.resize(numCols);

        for (unsigned i = m_numCols; i < numCols; i++) {

            if (numRows == m_numRows) {
                std::vector<MatrixDisplayCell> *foo = &m_LEDs[i];
                foo->resize(numRows);

                for (unsigned j = 0; j < numRows; j++) {
                    MatrixDisplayCell *tmp = &(*foo)[j];

                    tmp->m_avgBrightness = 0.0;
                    tmp->m_lastBrightness = 255;
                }
            }

            m_pColNodes[i] = createPin(0, 0, 270, colPinID(i));
        }
    } else {
        for (unsigned i = numCols; i < m_numCols; i++) {
            std::vector<MatrixDisplayCell> *tmp = &m_LEDs[i];

            for (unsigned j = 0; j < m_numRows; j++) {
                removeElement(&((*tmp)[j].m_pDiode), false);
            }

            removeNode(colPinID(i));
            m_pColNodes[i] = 0;
        }

        m_LEDs.resize(numCols);
    }

    m_numCols = numCols;

    if (numRows >= m_numRows) {

        for (unsigned j = 0; j < m_numCols; j++)
            m_LEDs[j].resize(numRows);

        for (unsigned i = m_numRows; i < numRows; i++) {

            for (unsigned j = 0; j < m_numCols; j++) {
                MatrixDisplayCell *tmp = &(m_LEDs[j][i]);

                tmp->m_avgBrightness = 0.0;
                tmp->m_lastBrightness = 255;
            }

            m_pRowNodes[i] = createPin(0, 0, 0, rowPinID(i));
        }
    } else {

        for (unsigned i = numRows; i < m_numRows; i++) {
            for (unsigned j = 0; j < m_numCols; j++) {
                removeElement(&(m_LEDs[j][i].m_pDiode), false);
            }

            removeNode(rowPinID(i));
            m_pRowNodes[i] = 0;
        }

        for (unsigned j = 0; j < m_numCols; j++)
            m_LEDs[j].resize(numRows);
    }

    m_numRows = numRows;
    //END Create or destroy pins

    //BEGIN Position pins et al
    setSize(-int(numCols + 1) * 8,
            -int(numRows + 1) * 8,
            int(numCols + 1) * 16,
            int(numRows + 1) * 16, true);

    for (int i = 0; i < int(m_numCols); i++) {
        m_nodeMap[colPinID(i)].x = offsetX() + 16 + 16 * i;
        m_nodeMap[colPinID(i)].y = offsetY() + height() + 8;
    }

    for (int i = 0; i < int(m_numRows); i++) {
        m_nodeMap[rowPinID(i)].x = offsetX() - 8;
        m_nodeMap[rowPinID(i)].y = offsetY() + 16 + 16 * i;
    }

    updateAttachedPositioning();
    //END Position pins et al
}
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");
}
Example #18
0
PortLptWidget::PortLptWidget(QWidget *parent) :
    PortWidget(parent)
{
    QVBoxLayout *vlo = new QVBoxLayout;

    // first row
    QHBoxLayout *row = new QHBoxLayout;
    row->setContentsMargins(0, 0, 0, 0);
    row->setSpacing(0);

    row->addStretch();
    row->addWidget(createPin(13, "SR4", false, "SLCT"));
    row->addWidget(createPin(12, "SR5", false, "PE (Paper End)"));
    row->addWidget(createPin(11, "SR7", false, "-BUSY"));
    row->addWidget(createPin(10, "SR6", false, "! ACK"));
    row->addWidget(createPin(9, "db7", true, "DB7"));
    row->addWidget(createPin(8, "db6", true, "DB6"));
    row->addWidget(createPin(7, "db5", true, "DB5"));
    row->addWidget(createPin(6, "db4", true, "DB4"));
    row->addWidget(createPin(5, "db3", true, "DB3"));
    row->addWidget(createPin(4, "db2", true, "DB2"));
    row->addWidget(createPin(3, "db1", true, "DB1"));
    row->addWidget(createPin(2, "db0", true, "DB0"));
    row->addWidget(createPin(1, "CR0", true, "!STROBE"));
    row->addStretch();

    vlo->addLayout(row);

    // second row
    row = new QHBoxLayout;
    row->setContentsMargins(0, 0, 0, 0);
    row->setSpacing(0);

    row->addStretch();
    row->addWidget(createPin(25, "GND", false, "GND"));
    row->addWidget(createPin(24, "---", false, "GND"));
    row->addWidget(createPin(23, "---", false, "GND"));
    row->addWidget(createPin(22, "---", false, "GND"));
    row->addWidget(createPin(21, "---", false, "GND"));
    row->addWidget(createPin(20, "---", false, "GND"));
    row->addWidget(createPin(19, "---", false, "GND"));
    row->addWidget(createPin(18, "GND", false, "GND"));
    row->addWidget(createPin(17, "CR3", true, "!SLIN"));
    row->addWidget(createPin(16, "CR2", true, "! INITIALIZE"));
    row->addWidget(createPin(15, "SR3", false, "! ERROR"));
    row->addWidget(createPin(14, "CR1", true, "!LF/CR"));
    row->addStretch();

    vlo->addLayout(row);

    setLayout(vlo);

    setFixedSize(sizeHint());
}
Example #19
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"));
}