• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Wire类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Wire的典型用法代码示例。如果您正苦于以下问题:C++ Wire类的具体用法?C++ Wire怎么用?C++ Wire使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Wire类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: QGraphicsPathItem

Wire::Wire(Wire& ref)
    : QGraphicsPathItem(ref.parentItem(), ref.scene())
{
    setSource(ref.source());
    setDestination(ref.destination());
    setId(ref.id());
}
开发者ID:sjkatz,项目名称:toolflow_gui,代码行数:7,代码来源:wire.cpp


示例2: simulate_test

void Circuit::print_testability()
{
    simulate_test();
    int num_sites = 0;
    int num_found = 0;
    for (int i = 0; i < linsts.size(); ++i) {
        Wire* owire = linsts[i]->get_output(0)->get_wire();
        if (owire->is_output()) {
            continue;
        } 
        if (linsts[i]->is_visited()) {
            continue;
        }

        num_sites += 2;
        if (observable_signal(linsts[i], STUCK1)) {
            ++num_found;
        }
        if (observable_signal(linsts[i], STUCK0)) {
            ++num_found;
        }
    } 
    
    cout << "Testability of candidate gates: " << 
        double(num_found) / double(num_sites) * 100 << "; Num remaining: " 
        << num_sites - num_found << "; Num faults: " << num_sites << endl;
}
开发者ID:stephenplaza,项目名称:CircuitLock,代码行数:27,代码来源:Circuit.cpp


示例3: __addDdWireB

void BddBuilder::__buildWireListB(BddBuilder * pA, Wire * pWireHead){
	Wire * pWireHorse;
	DdWire * pNewWire;
	DdWire * pInputWireHorse;
	__inputWireCnt = 0;
	__outputWireCnt = 0;

	for(pWireHorse=pWireHead ; pWireHorse ; pWireHorse=pWireHorse->get_next()){
		pNewWire = __addDdWireB(pA, pWireHorse);		
		switch(pWireHorse->get_value()){
			case -1: break;
			case 0: pNewWire->setDdNode(__GND); break;
			case 1: pNewWire->setDdNode(__Vcc); break;
			default: break;
		}
	}
	__pddInputNodes = new DdNode*[__inputWireCnt];	
	__ppInputNodesNames = new char*[__inputWireCnt];
	int i=0;
	pInputWireHorse = __pddInputWireHead->getInputListNext()->getInputListNext();
	for( ; pInputWireHorse ; pInputWireHorse=pInputWireHorse->getInputListNext()){
		__ppInputNodesNames[i] = pInputWireHorse->getName();
		__pddInputNodes[i++] = pInputWireHorse->getDdNode();
	}
}
开发者ID:HosukChoi,项目名称:ECO,代码行数:25,代码来源:BddBuilder.cpp


示例4: items

/*---------------------------------------------------------------------------------------------
 * (function: mouseReleaseEvent)
 *-------------------------------------------------------------------------------------------*/
void ExplorerScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (line != 0 && myMode == InsertLine) {
        QList<QGraphicsItem *> startItems = items(line->line().p1());
        if (startItems.count() && startItems.first() == line)
            startItems.removeFirst();
        QList<QGraphicsItem *> endItems = items(line->line().p2());
        if (endItems.count() && endItems.first() == line)
            endItems.removeFirst();

        removeItem(line);
        delete line;


        if (startItems.count() > 0 && endItems.count() > 0 &&
            startItems.first()->type() == LogicUnit::Type &&
            endItems.first()->type() == LogicUnit::Type &&
            startItems.first() != endItems.first()) {
            LogicUnit *startItem =
                qgraphicsitem_cast<LogicUnit *>(startItems.first());
            LogicUnit *endItem =
                qgraphicsitem_cast<LogicUnit *>(endItems.first());
            Wire *wire = new Wire(startItem, endItem);
            wire->setColor(myLineColor);
            startItem->addConnection(wire);
            endItem->addConnection(wire);
            wire->setZValue(-1000.0);
            addItem(wire);
            wire->updatePosition();
        }
    }

    line = 0;
    QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
开发者ID:amusant,项目名称:vtr-verilog-to-routing,代码行数:38,代码来源:explorerscene.cpp


示例5: spanResetWires

    void spanResetWires(Pin* source){
        if (source == NULL) return;
        if (source->visited()) return;
        source->visited(true);

        Wire *wire = source->wire();
        if (!wire) return;
        //cout <<"spanResetWires wire: "<< wire->info()<<endl;
        wire->voltage(false);
        list<Pin *>pins = wire->pins();
        list<Pin *>::iterator it;
        for (it = pins.begin(); it != pins.end(); it++){
            Pin *pin = (*it);
            if (pin == source) continue;
            pin->visited(true);
            Element *element = pin->element();
            if (element->type() == "switch"){
                Switch *switc = (Switch *)element;
                Pin *nextPin = switc->outPin(pin);
                spanResetWires(nextPin);
            }
            else if (element->type() == "resistor"){
                Resistor *resistor = (Resistor *)element;
                Pin *nextPin = resistor->outPin(pin);
                spanResetWires(nextPin);
                
            }
            else if (element->type() == "bridge"){
                Bridge *bridge = (Bridge *)element;
                Pin *nextPin = bridge->outPin(pin);
                spanResetWires(nextPin);
            }
        }
    }
开发者ID:johnyu916,项目名称:jarvis,代码行数:34,代码来源:Compute.cpp


示例6: gate

void Circuit::dumpCircuit()
{
    cout<<endl;
    cout<<"  Gate Name\tGate Level"<<endl;
    cout<<"========================================="<<endl;
    for( unsigned i = 0; i< numGate(); ++i )
    {
        Gate g = gate( i );
        cout<< "  " << g.name() << '\t' ;
        cout<< g.level() << '\t' ;
        //cout<< bitset<32>( value[i] ) <<'\t';
        cout<< endl;
    }

    cout<<endl;
    cout<<"  WireID\tWire Name\tType    \tValue"<<endl;
    cout<<"======================================================================================="<<endl;
    for( unsigned j = 0; j< numWire(); ++j )
    {
        Wire w = wire( j );
        cout<< "  "<< j << "\t\t";
        cout<< w.name() << "\t\t";
        cout<< setiosflags(ios::left) << setw(8) << w.type() <<'\t';
        if( w.type() != "UNUSED" )
            cout<< bitset<32>( w.valueSet() )<<'\t';
        else
            cout<<"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"<<'\t';
        cout<<endl;
    }
}
开发者ID:bhb811340,项目名称:SoCV_fp,代码行数:30,代码来源:circuit.cpp


示例7: __addDdWire

void BddBuilder::__buildWireList(Wire * pWireHead,char** input_sequence,int& total_input_band){
	Wire * pWireHorse;
	DdWire * pNewWire;
	DdWire * pInputWireHorse;
	__inputWireCnt = 0;
	__outputWireCnt = 0;

	for(pWireHorse=pWireHead ; pWireHorse ; pWireHorse=pWireHorse->get_next()){
		pNewWire = __addDdWire(pWireHorse);		
		switch(pWireHorse->get_value()){
			case -1: break;
			case 0: pNewWire->setDdNode(__GND); break;
			case 1: pNewWire->setDdNode(__Vcc); break;
			default: break;
		}
	}
	__pddInputNodes = new DdNode*[__inputWireCnt];
	__ppInputNodesNames = new char*[__inputWireCnt];
	int i=0;
	pInputWireHorse=__pddInputWireHead->getInputListNext()->getInputListNext();
	for( ; pInputWireHorse ; pInputWireHorse=pInputWireHorse->getInputListNext()){
		__ppInputNodesNames[i] = pInputWireHorse->getName();
		strcpy(input_sequence[i],__ppInputNodesNames[i]);
		__pddInputNodes[i++] = pInputWireHorse->getDdNode();
	}
	total_input_band =i;
}
开发者ID:HosukChoi,项目名称:ECO,代码行数:27,代码来源:BddBuilder.cpp


示例8: QPointF

void SchematicSceneBuilder::add_wire_component(
    std::map<std::string, std::string> props
  )
{
  if(!discard(props)) {
    Wire* item = static_cast<Wire*>(
      SchematicScene::itemByType(SchematicScene::WireItemType));

    bool ok;

    double to_x = QString::fromStdString(props["to_x"]).toDouble(&ok);
    if(!ok)
      to_x = SchematicScene::GridStep;

    double to_y = QString::fromStdString(props["to_y"]).toDouble(&ok);
    if(!ok)
      to_y = SchematicScene::GridStep;

    bool conn = QString::fromStdString(props["conn"]).toInt(&ok);
    if(!ok)
      conn = false;

    item->setWire(QLineF(QPointF(0, 0), QPointF(to_x, to_y)));
    item->setConnectedJunctions(conn);

    scene_->addSupportedItem(item, false);
    grid_coordinate(item, props);
    items_.push_back(item);
  }
}
开发者ID:skypjack,项目名称:qsapecng,代码行数:30,代码来源:schematicsceneparser.cpp


示例9: upWires

 void upWires(list<Wire *>wires){
     list<Wire *>::iterator it;
     for (it = wires.begin(); it != wires.end(); it++){
         Wire *wire = (*it);
         wire->voltage(true);
         //cout <<"upped wire: "<<wire->info()<<endl;
     }
 }
开发者ID:johnyu916,项目名称:jarvis,代码行数:8,代码来源:Compute.cpp


示例10: foreach

void SchematicSketchWidget::tidyWires() {
	QList<Wire *> wires;
	QList<Wire *> visited;
	foreach (QGraphicsItem * item, scene()->selectedItems()) {
		Wire * wire = dynamic_cast<Wire *>(item);
		if (wire == NULL) continue;
		if ((wire->getViewGeometry().wireFlags() & ViewGeometry::SchematicTraceFlag) == 0) continue;
		if (visited.contains(wire)) continue;
	}
开发者ID:DHaylock,项目名称:fritzing-app,代码行数:9,代码来源:schematicsketchwidget.cpp


示例11: setLineColor

/*---------------------------------------------------------------------------------------------
 * (function: setLineColor)
 *-------------------------------------------------------------------------------------------*/
void ExplorerScene::setLineColor(const QColor &color)
{
    myLineColor = color;
    if (isItemChange(Wire::Type)) {
        Wire *item =
            qgraphicsitem_cast<Wire *>(selectedItems().first());
        item->setColor(myLineColor);
        update();
    }
}
开发者ID:amusant,项目名称:vtr-verilog-to-routing,代码行数:13,代码来源:explorerscene.cpp


示例12: commit_signatures

void Circuit::commit_signatures()
{
    for (sym_map::iterator iter = sym_table.begin();
            iter != sym_table.end(); ++iter) {
        if (iter->second->get_type() == WIRE) {
            Wire* wire = (Wire*)(iter->second);
            wire->commit_signature();
        }
    }
}
开发者ID:stephenplaza,项目名称:CircuitLock,代码行数:10,代码来源:Circuit.cpp


示例13: console

Circuit::Circuit(Console *_console) : console(_console), terminals(1000),
    outLedList(IO_COUNT), usedInput(IO_COUNT, false), usedOutput(IO_COUNT, false)
{
    QList<QGraphicsItem *> items = console->items();

    Wire *wire;
    LED *led;
    IC *ic;
    int i, j;

    for (auto it = items.begin(); it != items.end(); it++)
    {
        if ((wire = dynamic_cast<Wire *>(*it)))
        {
            i = _console->getOffset(wire->line().p1());
            j = _console->getOffset(wire->line().p2());
            if (terminals.join(i, j))
            {
                connections.push_back(Connection(i, j));
                wire->markRedundent(false);
            }
            else
                wire->markRedundent(true);
            if (i >= OUTPUT_OFFSET)
                usedOutput[i-OUTPUT_OFFSET] = true;
            else if (i >= INPUT_OFFSET)
                usedInput[i-INPUT_OFFSET] = true;
            else if (j >= OUTPUT_OFFSET)
                usedOutput[j-OUTPUT_OFFSET] = true;
            else if (j >= INPUT_OFFSET)
                usedInput[j-INPUT_OFFSET] = true;
        }
        else if ((led = dynamic_cast<LED *>(*it)))
        {
            if (led->col >= 0 && led->col < 10)
                outLedList[led->col] = led;
            else
                ledList.push_back(led);
            led->switchOn(POWER);
        }
        else if ((ic = dynamic_cast<IC *>(*it)))
        {
            icList.push_back(ic);
        }
    }

    for (size_t i = 0; i < IO_COUNT; i++)
    {
        terminals.setstate(OUTPUT_OFFSET + i, State::undefined);
    }
    silentOutput = false;
#ifdef QT_DEBUG
    //terminals.print();
#endif
}
开发者ID:vinayak-garg,项目名称:dic-sim,代码行数:55,代码来源:circuit.cpp


示例14: Wire

Wire* Wire::Clone()
{
    Wire* clone = new Wire();
    list<ConnectionPoint *>::iterator it;

    for( it = this->connectionPoints->begin(); it != this->connectionPoints->end(); it++ )
    {
        ConnectionPoint* cp = (*it)->Clone();
        clone->Attach( cp );
    }

    return clone;
}
开发者ID:IndigoVerge,项目名称:Agilart-Run-Time,代码行数:13,代码来源:Wire.cpp


示例15: spanResistors

    //void spanResistors(Pin *source, list<Wire *>wires){
    void spanResistors(Pin *source, list<Resistor *>resistors){
        //cout <<"entering spanResistors"<<endl;
        /* 1. try to reach the end. 
         * 2. if end is reached, must go back and turn all wires on in the path
         */
        if (source == NULL) return;
        if (source->visited()) return;
        source->visited(true);
        //debug("spanResistors source pin: "<< source->fullName());

        Wire *wire = source->wire();
        if (!wire) return;
        //debug("spanResistors wire: "<< wire->name());
        list<Pin *>pins = wire->pins();
        list<Pin *>::iterator it;
        for (it = pins.begin(); it != pins.end(); it++){
            Pin *pin = (*it);
            if (pin == source) continue;
            pin->visited(true);
            //get element for source
            Element *element = pin->element();
            if (element->type() == "source"){
                //cerr << "Encountered source "<< element->info() <<" while completing circuit."<<endl;
                return;
            }
            else if (element->type() == "ground"){
                //cout <<"ground reached: "<<endl;
                //end reached.
                activateResistors(resistors);
                //upWires(wires);
            }
            else if (element->type() == "switch"){
                Switch *switc = (Switch *)element;
                if (!switc->isOn()) continue;

                Pin *nextPin = switc->outPin(pin);
                spanResistors(nextPin,resistors);
            }
            else if (element->type() == "resistor"){
                Resistor *resistor = (Resistor *)element;
                resistors.push_back(resistor);
                Pin *nextPin = resistor->outPin(pin);
                spanResistors(nextPin, resistors);
            }
            else if (element->type() == "bridge"){
                Bridge *bridge = (Bridge *)element;
                Pin *nextPin = bridge->outPin(pin);
                spanResistors(nextPin, resistors);
            }
        }
    }
开发者ID:johnyu916,项目名称:jarvis,代码行数:52,代码来源:Compute.cpp


示例16: assert

// true if current input signatures reveal that the given signal is observable
bool Circuit::observable_cover(string inst_name, string wire_name, CoverType cover)
{
    Inst* inst = (Inst*) sym_table[inst_name];
    Wire* wire = (Wire*) sym_table[wire_name];
    assert(sim_patterns > 0);

    Wire* owire = inst->get_output(0)->get_wire();
    int num_patterns = (sim_patterns - 1)/ SIGSTEP + 1;
    int leftover = sim_patterns%SIGSTEP;
        
    for (int j = 0; j < num_patterns; ++j) {
        for (int i = 0; i < int(input_wires.size()); ++i) {
            input_wires[i]->set_sig_temp(input_wires[i]->get_signature(j));
        }

        for (int i = 0; i < int(linsts.size()); ++i) {
            if ((j == (num_patterns - 1)) && (leftover > 0)) {
                linsts[i]->evaluate(leftover);
            } else {
                linsts[i]->evaluate(SIGSTEP);
            }

            if (linsts[i] == inst) {
                if (cover == EQUAL) {
                    owire->set_sig_temp((wire->get_sig_temp()));
                } else if (cover == AND) {
                    owire->set_sig_temp((wire->get_sig_temp() & owire->get_sig_temp()));
                } else if (cover == OR) {
                    owire->set_sig_temp((wire->get_sig_temp() | owire->get_sig_temp()));
                } else {
                    assert(0);
                }
            }
        } 

        for (int i = 0; i < int(output_wires.size()); ++i) {
            if (output_wires[i]->get_sig_temp() != output_wires[i]->get_signature(j)) {
                return true;
            }
        }
    }

    return false;
}
开发者ID:stephenplaza,项目名称:CircuitLock,代码行数:45,代码来源:Circuit.cpp


示例17: display

void display(void) {
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();

    // Wind
    wind.draw();

    // Wires
    w[0].draw();
    w[1].draw();
    w[2].draw();

    // Air duct
    glColor3f WHITE;
    glLine(ADOffset, ADOffset, WIDTH - ADOffset, ADOffset);
    glLine(ADOffset, ADOffset + ADHeight, WIDTH - ADOffset, ADOffset + ADHeight);

    // Air sensor - controller connection
    TT_TIC.draw();

    // Air temperature sensor
    TT.draw();

    // Controller
    TIC.draw();

    // Air turbine
    glColor3f WHITE;
    turbine.draw();

    // Boiler_Wind pipe
    boiler_wind[0].draw();
    boiler_wind[1].draw();
    boiler_wind[2].draw();
    boiler_wind[3].draw();

    // Pressure Release Pipe
    boiler_.draw();

    // Pressure Valve;
    pressureValve.draw();

    // Boiler
    boiler.draw();

    // Pressure Indicator
    PrI.draw();

    // Oil Valve
    oilValve.draw();

    glPopMatrix();
    glutSwapBuffers();
}
开发者ID:KovaxG,项目名称:ACAD,代码行数:54,代码来源:source.cpp


示例18: wire

void Circuit::AssignPiValue( Pattern* PatternSet )
{
    for( unsigned i = 0, j = 0 ; i < numWire(); ++i )
    {
        Wire pWire = wire(i);
        if( pWire.type() == "PI" )
        {
            value[ i ] = PatternSet->value[j];
            wire(i).setValueSet( PatternSet->value[j] );
            ++j;
        }
        else if ( pWire.type() == "TIE0" ) // assign value to TIE0
        {
            value[ i ] = 0;
            wire(i).setValueSet( 0 );
        }
        else if ( pWire.type() == "TIE1" ) // assign value to TIE1
        {
            value[ i ] = ~0;
            wire(i).setValueSet( ~0 );
        }
        else if ( pWire.type() == "CUT" || pWire.type() == "CUT_BAR" ) // assign value to cut points
        {
            value[ i ] = PatternSet->value[j];
            wire(i).setValueSet( PatternSet->value[j] );
            ++j;
        }
    }
}
开发者ID:bhb811340,项目名称:SoCV_fp,代码行数:29,代码来源:circuit.cpp


示例19: get

void GraphUtils::minCut(QList<ConnectorItem *> & connectorItems, QList<SketchWidget *> & foreignSketchWidgets, ConnectorItem * source, ConnectorItem * sink, QList<ConnectorEdge *> & minCut) 
{
	// this helped:  http://boost.2283326.n4.nabble.com/graph-edmund-karp-max-flow-vs-kolmogorov-max-flow-color-map-td2565611.html
	
	using namespace boost;

	typedef adjacency_list_traits < vecS, vecS, directedS > Traits;
    typedef property < vertex_color_t, boost::default_color_type > COLOR;
	typedef property < vertex_index_t, long, COLOR > VERTEX;
    typedef property < edge_reverse_t, Traits::edge_descriptor > REVERSE;
    typedef property < edge_residual_capacity_t, long, REVERSE > RESIDUAL;
	typedef property < edge_capacity_t, long, RESIDUAL > EDGE;
	typedef adjacency_list < listS, vecS, directedS, VERTEX, EDGE > Graph;

	Graph g;

	property_map < Graph, edge_capacity_t >::type capacity = get(edge_capacity, g);
	property_map < Graph, edge_residual_capacity_t >::type residual_capacity = get(edge_residual_capacity, g);
	property_map < Graph, edge_reverse_t >::type reverse = get(edge_reverse, g);

	property_map < Graph, vertex_color_t >::type color = get(vertex_color, g);
	property_map < Graph, vertex_index_t >::type index = get(vertex_index, g);

	Traits::vertex_descriptor s, t;

	QList<Wire *> visitedWires;
	QList<int> indexes;
	QHash<ConnectorItem *, int> vertices;
	QList<ConnectorEdge *> edges;
	QVector<Traits::vertex_descriptor> verts;

	vertices.insert(source, 0);
	vertices.insert(sink, 1);
	verts.append(s = add_vertex(g));
	verts.append(t = add_vertex(g));

	foreach (ConnectorItem * connectorItem, connectorItems) {
		//connectorItem->debugInfo("input");
		if (connectorItem->attachedToItemType() == ModelPart::Wire) {
			Wire * wire = qobject_cast<Wire *>(connectorItem->attachedTo());
			if (visitedWires.contains(wire)) continue;

			QList<Wire *> wires;
			QList<ConnectorItem *> ends;
			wire->collectChained(wires, ends);
			visitedWires.append(wires);
			if (ends.count() < 2) continue;

			foreach (ConnectorItem * end, ends) {
				appendVertIf(end, vertices, verts);
			}

			for (int i = 0; i < ends.count(); i++) {
				ConnectorItem * end = ends[i];
				for (int j = i + 1; j < ends.count(); j++) {
					ConnectorEdge * connectorEdge = makeConnectorEdge(edges, end, ends[j], 1000, wire);
					connectorEdge->setHeadTail(vertices.value(connectorEdge->c0), vertices.value(connectorEdge->c1));
				}
			}
			continue;
		}
开发者ID:DHaylock,项目名称:fritzing-app,代码行数:61,代码来源:graphutils.cpp


示例20: ResetVerticesMarks

void Graph::CountCost (){
  ResetVerticesMarks();

  for (auto source:source_vertices_) {   //bfs for each source;
    ResetVerticesMarks();
    queue<Vertex*> bfs_queue;
    bfs_queue.push(source);
    source->SetIsVisted(true);
    string source_name = source ->GetRaw()->GetName();
    vector <Vertex*> vector_leafs;
    //cout <<"Start:"<<source_name<<endl;
    while (!bfs_queue.empty()){
      Vertex* front = bfs_queue.front();
      bfs_queue.pop();
      for (int i=0; i<front->GetIncidentEdgesNum();++i){
        Vertex* child = front->GetIncidentEdge(i)->GetNeighbor(front);
        Edge* connect_edge = front->GetIncidentEdge(i);
        if (child->GetType()==Vertex::Type::PSEUDO){
          child = dynamic_cast<PseudoVertex*>(child)->GetBoundaryVertex(front->GetIncidentEdge(i));
          connect_edge = edges_[front->GetIncidentEdge(i)->GetRaw()->GetName()];
        }

        if (child->GetIsVisited() || child->GetAssignSource()!=source_name){
          continue;
        }
        child->SetIsVisted(true);
        child->SetParent(front);
        front->AddChild(child);
        bfs_queue.push(child);
        child->SetParentEdge(connect_edge);
      }
      if (front->GetChildrenNum() == 0){
        vector_leafs.push_back(front);
      } else if (front->GetType() == Vertex::Type::RESIDENT ){
        cout <<"error!!! :resident has more one edge"<<endl;
      }
    }
    /*
       for (auto pair: vertices_) {
       if (!pair.second->GetIsVisited() && pair.second->GetAssignSource()==source_name){
       cout <<"someting wrong!!"<<endl;
       }
       }
       */
    cout <<"process:"<<source_name<<" leafnum:"<<vector_leafs.size()<<endl;
    for (auto child : vector_leafs){
      //Vertex* child = pair.second;
      if (child->GetType() == Vertex::Type::RESIDENT && child->GetAssignSource() == source_name) {
        //cout <<"IN!! "<<endl;
        double load_current = dynamic_cast<ResidentVertex*>(child)->GetConsumingPower()/child->GetVoltage();
        //cout <<"load:"<< load_current<<endl;
        while (child!=source) {
          Vertex* parent = child->GetParent();
          Edge* connect_edge = child->GetParentEdge();
          assert(connect_edge->GetNeighbor(child)==parent);
          connect_edge->SetCurrent(connect_edge->GetCurrent()+load_current);
          child = parent;
        }
      }
    }
    //cout <<"finish:"<<source_name<<endl;
  }

  //cout <<"counting..."<<endl;
  wire_upgrade = 0.0;
  switch_change =0;

  for (auto pair:edges_) {
    if (pair.second->GetType()==Edge::Type::EDGE){
      Wire* wire = pair.second->GetRaw();
      if (pair.second->GetCurrent() > wire->GetCurrentLimit()){
        //cout <<"Current:"<< pair.second->GetCurrent()<< "  Limit:"<< wire->GetCurrentLimit()<<endl;
        wire_upgrade += pair.second->GetCurrent()-wire->GetCurrentLimit();
      }
    }else if(pair.second->GetType()==Edge::Type::SWITCH){
      Switch* switches = dynamic_cast<Switch*> (pair.second->GetRaw());
      Vertex* a = pair.second->GetIncidentVertex(0);
      Vertex* b = pair.second->GetIncidentVertex(1);

      if ( (a->GetAssignSource() != b->GetAssignSource() && switches->GetIsOn()) || (a->GetAssignSource() == b->GetAssignSource() && !switches->GetIsOn() ))
        switch_change++;
    }
  }
  cout << "wire upgrade :" << wire_upgrade << endl;
  cout << "wire change  :" << switch_change << endl;
}
开发者ID:harry830622,项目名称:smart-grid,代码行数:86,代码来源:graph.cpp



注:本文中的Wire类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WiredTigerSession类代码示例发布时间:2022-05-31
下一篇:
C++ WindowsDllInterceptor类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap