Ejemplo n.º 1
0
func (g *signalGraphType) removeOutputNodeFromPortType(p bh.PortTypeIf) {
	for _, n := range g.OutputNodes() {
		if n.Name() == fmt.Sprintf("out-%s", p.Name()) {
			g.RemoveNode(n)
			return
		}
	}
}
Ejemplo n.º 2
0
func (g *signalGraphType) findOutputNodeFromPortType(p bh.PortTypeIf) bh.NodeIf {
	for _, n := range g.OutputNodes() {
		if n.Name() == fmt.Sprintf("out-%s", p.Name()) {
			return n
		}
	}
	return nil
}
Ejemplo n.º 3
0
func (n *node) removePort(pt bh.PortTypeIf) {
	var list *portList
	if pt.Direction() == gr.InPort {
		list = &n.inPort
	} else {
		list = &n.outPort
	}
	var i int
	for i = 0; i < len(list.Ports()); i++ {
		if list.Ports()[i].Name() == pt.Name() {
			break
		}
	}
	toRemove := list.Ports()[i]
	for _, c := range toRemove.Connections() {
		c.RemoveConnection(toRemove)
	}
	list.Remove(toRemove)
}
Ejemplo n.º 4
0
func (t *nodeType) RemoveNamedPortType(p bh.PortTypeIf) {
	for _, impl := range t.implementation.Implementations() {
		if impl.ImplementationType() == bh.NodeTypeGraph {
			if p.Direction() == gr.InPort {
				impl.Graph().(*signalGraphType).removeInputNodeFromPortType(p)
			} else {
				impl.Graph().(*signalGraphType).removeOutputNodeFromPortType(p)
			}
		}
	}
	for _, n := range t.instances.Nodes() {
		n.(*node).removePort(p.(*portType))
	}
	var list *portTypeList
	if p.Direction() == gr.InPort {
		list = &t.inPorts
	} else {
		list = &t.outPorts
	}
	list.Remove(p)
}
Ejemplo n.º 5
0
func (g *signalGraphType) addOutputNodeFromPortType(p bh.PortTypeIf) {
	st := p.SignalType()
	ntName := createOutputNodeTypeName(st.TypeName())
	nt, ok := freesp.GetNodeTypeByName(ntName)
	if !ok {
		nt = NodeTypeNew(ntName, "")
		nt.(*nodeType).addInPort("", st)
		freesp.RegisterNodeType(nt)
	}
	if len(nt.(*nodeType).inPorts.PortTypes()) == 0 {
		log.Fatal("signalGraphType.addOutputNodeFromNamedPortType: invalid output node type")
	}
	n, err := NodeNew(fmt.Sprintf("out-%s", p.Name()), nt, g)
	if err != nil {
		log.Fatal("signalGraphType.addOutputNodeFromPortType: TODO: error handling")
	}
	n.portlink = p
	err = g.addNode(n)
	if err != nil {
		log.Fatal("signalGraphType.addOutputNodeFromNamedPortType: AddNode failed:", err)
	}
}
Ejemplo n.º 6
0
func (t *nodeType) AddNamedPortType(p bh.PortTypeIf) {
	if p.Direction() == gr.InPort {
		t.inPorts.Append(p)
	} else {
		t.outPorts.Append(p)
	}
	for _, n := range t.instances.Nodes() {
		if p.Direction() == gr.InPort {
			n.(*node).addInPort(p)
		} else {
			n.(*node).addOutPort(p)
		}
	}
	for _, impl := range t.implementation.Implementations() {
		if impl.ImplementationType() == bh.NodeTypeGraph {
			if p.Direction() == gr.InPort {
				impl.Graph().(*signalGraphType).addInputNodeFromPortType(p)
			} else {
				impl.Graph().(*signalGraphType).addOutputNodeFromPortType(p)
			}
		}
	}
}
Ejemplo n.º 7
0
func CreateXmlNamedOutPort(p bh.PortTypeIf) (xmlp *backend.XmlOutPort) {
	xmlp = backend.XmlOutPortNew(p.Name(), p.SignalType().TypeName())
	//xmlp.Entry = freesp.CreateXmlModePosition(p).Entry
	return
}