Exemplo n.º 1
0
func CreateXmlIONodePosHint(n bh.NodeIf, path string) (xmln *backend.XmlNodePosHint) {
	if len(path) == 0 {
		xmln = backend.XmlNodePosHintNew(n.Name())
	} else {
		xmln = backend.XmlNodePosHintNew(fmt.Sprintf("%s/%s", path, n.Name()))
	}
	empty := image.Point{}
	for _, p := range n.PathList() {
		for _, m := range gr.ValidModes {
			xmlp := string(gr.CreatePathMode(p, m))
			pos := n.PathModePosition(p, m)
			if pos != empty {
				xmln.Entry = append(xmln.Entry, *backend.XmlModeHintEntryNew(xmlp, pos.X, pos.Y))
			}
		}
	}
	for _, p := range n.InPorts() {
		xmlp := backend.XmlPortPosHintNew(p.Name())
		xmlp.Entry = freesp.CreateXmlModePosition(p).Entry
		xmln.InPorts = append(xmln.InPorts, *xmlp)
	}
	for _, p := range n.OutPorts() {
		xmlp := backend.XmlPortPosHintNew(p.Name())
		xmlp.Entry = freesp.CreateXmlModePosition(p).Entry
		xmln.OutPorts = append(xmln.OutPorts, *xmlp)
	}
	return
}
Exemplo n.º 2
0
func CreateXmlMappingHint(m mp.MappingIf) (xmlm *backend.XmlMappingHint) {
	xmlm = backend.XmlMappingHintNew(m.Filename())
	for _, nId := range m.MappedIds() {
		melem, ok := m.MappedElement(nId)
		if !ok {
			log.Fatal("CreateXmlMappingHint internal error: inconsistent maplist.\n")
		}
		log.Printf("CreateXmlMappingHint(%s): nId=%s, melem.mode=%v, pos=%v\n", melem.NodeId(), nId.String(), melem.ActiveMode(), melem.Position())
		xmln := backend.XmlNodePosHintNew(nId.String())
		empty := image.Point{}
		for _, mod := range gr.ValidModes {
			pos := melem.ModePosition(mod)
			log.Printf("mod %v, pos=%v\n", mod, pos)
			if pos != empty {
				xmln.Entry = append(xmln.Entry, *backend.XmlModeHintEntryNew(string(mod), pos.X, pos.Y))
			}
		}
		for i, p := range melem.(*mapelem).inports {
			xmlp := backend.XmlPortPosHintNew(melem.(*mapelem).node.InPorts()[i].Name())
			log.Printf("CreateXmlMappingHint(inports):    xmlp=%s\n", xmlp.Name)
			for _, mod := range gr.ValidModes {
				pos := p.ModePosition(mod)
				log.Printf("   mod %v, pos=%v\n", mod, pos)
				if pos != empty {
					xmlp.Entry = append(xmlp.Entry, *backend.XmlModeHintEntryNew(string(mod), pos.X, pos.Y))
				}
			}
			xmln.InPorts = append(xmln.InPorts, *xmlp)
		}
		for i, p := range melem.(*mapelem).outports {
			xmlp := backend.XmlPortPosHintNew(melem.(*mapelem).node.OutPorts()[i].Name())
			log.Printf("CreateXmlMappingHint(outports):    xmlp=%s\n", xmlp.Name)
			for _, mod := range gr.ValidModes {
				pos := p.ModePosition(mod)
				log.Printf("   mod %v, pos=%v\n", mod, pos)
				if pos != empty {
					xmlp.Entry = append(xmlp.Entry, *backend.XmlModeHintEntryNew(string(mod), pos.X, pos.Y))
				}
			}
			xmln.OutPorts = append(xmln.InPorts, *xmlp)
		}
		xmlm.MappedNodes = append(xmlm.MappedNodes, *xmln)
	}
	return
}