Example #1
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
}
Example #2
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
		}
	}
}
Example #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)
}
Example #4
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)
	}
}
Example #5
0
func CreateXmlNamedOutPort(p bh.PortTypeIf) (xmlp *backend.XmlOutPort) {
	xmlp = backend.XmlOutPortNew(p.Name(), p.SignalType().TypeName())
	//xmlp.Entry = freesp.CreateXmlModePosition(p).Entry
	return
}