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

Golang behaviour.SignalGraphTypeIf类代码示例

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

本文整理汇总了Golang中github.com/axel-freesp/sge/interface/behaviour.SignalGraphTypeIf的典型用法代码示例。如果您正苦于以下问题:Golang SignalGraphTypeIf类的具体用法?Golang SignalGraphTypeIf怎么用?Golang SignalGraphTypeIf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: parseNode

func parseNode(text, context string, graph bh.SignalGraphTypeIf) (job *PasteJob, ok bool) {
	xmln := backend.XmlNode{}
	_, xmlerr := xmln.Read([]byte(text))
	if xmlerr != nil {
		return
	}
	nodes := graph.Nodes()
	for true {
		valid := true
		for _, reg := range nodes {
			if reg.Name() == xmln.NName {
				valid = false
			}
		}
		if valid {
			break
		}
		xmln.NName = createNextNameCandidate(xmln.NName)
	}
	_, validType := freesp.GetNodeTypeByName(xmln.NType)
	var njob *NewElementJob
	switch {
	case validType:
		njob = NewElementJobNew(context, eNode)
		njob.input[iNodeName] = xmln.NName
		njob.input[iNodeTypeSelect] = xmln.NType
	case len(xmln.InPort) == 0:
		if len(xmln.OutPort) == 0 {
			fmt.Printf("parseNode error: no ports.\n")
			return
		}
		njob = NewElementJobNew(context, eInputNode)
		njob.input[iInputNodeName] = xmln.NName
		njob.input[iInputTypeSelect] = xmln.OutPort[0].PType // TODO
	case len(xmln.OutPort) == 0:
		njob = NewElementJobNew(context, eOutputNode)
		njob.input[iOutputNodeName] = xmln.NName
		njob.input[iOutputTypeSelect] = xmln.InPort[0].PType // TODO
	default:
		if !validType {
			fmt.Printf("parseNode error: node type %s not registered.\n", xmln.NType)
			return
		}
		// TODO: Create node type??
		njob = NewElementJobNew(context, eNode)
		njob.input[iNodeName] = xmln.NName
		njob.input[iNodeTypeSelect] = xmln.NType
	}
	job = PasteJobNew()
	job.context = context
	job.newElements = append(job.newElements, njob)
	ok = true
	return
}
开发者ID:axel-freesp,项目名称:sge,代码行数:54,代码来源:pastejob.go


示例2: TestGraph

func TestGraph(t *testing.T) {
	case1 := []struct {
		library, graph     string
		nodes, connections int
	}{
		{`<library xmlns="http://www.freesp.de/xml/freeSP" version="1.0">
   <signal-type name="s1" scope="" mode="" c-type="" message-id=""></signal-type>
   <node-type name="Test">
      <intype port="" type="s1"></intype>
      <outtype port="" type="s1"></outtype>
   </node-type>
</library>
`, `<?xml version="1.0" encoding="UTF-8"?>
<signal-graph xmlns="http://www.freesp.de/xml/freeSP" version="1.0">
    <nodes>
        <input name="sensor">
            <outtype type="s1"/>
        </input>
        <output name="actuator">
            <intype type="s1"/>
        </output>
        <processing-node name="test" type="Test"></processing-node>
    </nodes>
    <connections>
        <connect from="sensor" to="test"/>
        <connect from="test" to="actuator"/>
    </connections>
</signal-graph>
`, 3, 2},
	}

	for i, c := range case1 {
		freesp.Init()
		var l bh.LibraryIf = LibraryNew("test.alml", nil)
		buf := copyBuf(c.library)
		_, err := l.Read(buf)
		if err != nil {
			t.Errorf("Testcase %d: Failed to read from buffer: %v", i, err)
			return
		}
		var sg bh.SignalGraphIf = SignalGraphNew("test.sml", nil)
		buf = copyBuf(c.graph)
		_, err = sg.Read(buf)
		if err != nil {
			t.Errorf("Testcase %d: Failed to read from buffer: %v", i, err)
			return
		}
		var st bh.SignalGraphTypeIf = sg.ItsType()
		if len(st.Nodes()) != c.nodes {
			t.Errorf("Testcase %d: NodeIf count mismatch", i)
			return
		}
	}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:54,代码来源:signalgraph_test.go


示例3: SignalGraphTypeUsesNodeType

func SignalGraphTypeUsesNodeType(t bh.SignalGraphTypeIf, nt bh.NodeTypeIf) bool {
	for _, n := range t.Nodes() {
		if n.ItsType().TypeName() == nt.TypeName() {
			return true
		}
		for _, impl := range n.ItsType().Implementation() {
			if impl.ImplementationType() == bh.NodeTypeGraph {
				if SignalGraphTypeUsesNodeType(impl.Graph(), nt) {
					return true
				}
			}
		}
	}
	return false
}
开发者ID:axel-freesp,项目名称:sge,代码行数:15,代码来源:signalgraphtype.go


示例4: NodesApplyHints

func NodesApplyHints(path string, g bh.SignalGraphTypeIf, xmlh []backend.XmlNodePosHint) {
	for _, n := range g.ProcessingNodes() {
		var p string
		if len(path) == 0 {
			p = n.Name()
		} else {
			p = fmt.Sprintf("%s/%s", path, n.Name())
		}
		ok := false
		var xmln backend.XmlNodePosHint
		for _, xmln = range xmlh {
			if p == xmln.Name {
				ok = true
				break
			}
		}
		if ok {
			n.SetExpanded(xmln.Expanded)
			freesp.PathModePositionerApplyHints(n, xmln.XmlModeHint)
			for i, p := range n.InPorts() {
				ok = p.Name() == xmln.InPorts[i].Name
				if !ok {
					log.Printf("NodesApplyHints FIXME: name mismatch\n")
					continue
				}
				freesp.ModePositionerApplyHints(p, xmln.InPorts[i].XmlModeHint)
			}
			for i, p := range n.OutPorts() {
				ok = p.Name() == xmln.OutPorts[i].Name
				if !ok {
					log.Printf("NodesApplyHints FIXME: name mismatch\n")
					continue
				}
				freesp.ModePositionerApplyHints(p, xmln.OutPorts[i].XmlModeHint)
			}
		}
		nt := n.ItsType()
		for _, impl := range nt.Implementation() {
			if impl.ImplementationType() == bh.NodeTypeGraph {
				NodesApplyHints(p, impl.Graph(), xmlh)
				break
			}
		}
	}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:45,代码来源:signalgraph.go


示例5: SignalGraphTypeUsesSignalType

func SignalGraphTypeUsesSignalType(t bh.SignalGraphTypeIf, st bh.SignalTypeIf) bool {
	for _, n := range t.Nodes() {
		for _, p := range n.InPorts() {
			if p.SignalType() == st {
				return true
			}
		}
		for _, p := range n.OutPorts() {
			if p.SignalType() == st {
				return true
			}
		}
		for _, impl := range n.ItsType().Implementation() {
			if impl.ImplementationType() == bh.NodeTypeGraph {
				if SignalGraphTypeUsesSignalType(impl.Graph(), st) {
					return true
				}
			}
		}
	}
	return false
}
开发者ID:axel-freesp,项目名称:sge,代码行数:22,代码来源:signalgraphtype.go


示例6: NodeNew

func NodeNew(name string, ntype bh.NodeTypeIf, context bh.SignalGraphTypeIf) (ret *node, err error) {
	for _, n := range context.Nodes() {
		if n.Name() == name {
			err = fmt.Errorf("NodeNew error: node '%s' already exists in context.", name)
			return
		}
	}
	if len(ntype.InPorts())+len(ntype.OutPorts()) == 0 {
		err = fmt.Errorf("NodeNew error: type '%s' has no ports.", ntype.TypeName())
		return
	}
	ret = &node{*gr.PathModePositionerObjectNew(), context, name, ntype,
		portListInit(), portListInit(), nil, false}
	for _, p := range ntype.InPorts() {
		ret.addInPort(p)
	}
	for _, p := range ntype.OutPorts() {
		ret.addOutPort(p)
	}
	ntype.(*nodeType).addInstance(ret)
	return
}
开发者ID:axel-freesp,项目名称:sge,代码行数:22,代码来源:node.go


示例7: CreateXmlSignalGraphType

func CreateXmlSignalGraphType(t bh.SignalGraphTypeIf) *backend.XmlSignalGraph {
	ret := backend.XmlSignalGraphNew()
	for _, l := range t.Libraries() {
		ret.Libraries = append(ret.Libraries, *CreateXmlLibraryRef(l.Filename()))
	}
	for _, n := range t.InputNodes() {
		ret.InputNodes = append(ret.InputNodes, *CreateXmlInputNode(n))
	}
	for _, n := range t.OutputNodes() {
		ret.OutputNodes = append(ret.OutputNodes, *CreateXmlOutputNode(n))
	}
	for _, n := range t.ProcessingNodes() {
		ret.ProcessingNodes = append(ret.ProcessingNodes, *CreateXmlProcessingNode(n))
	}
	for _, n := range t.Nodes() {
		for _, p := range n.OutPorts() {
			for _, c := range p.Connections() {
				conn := p.Connection(c)
				ret.Connections = append(ret.Connections, *CreateXmlConnection(conn))
			}
		}
	}
	return ret
}
开发者ID:axel-freesp,项目名称:sge,代码行数:24,代码来源:backendconversions.go


示例8: ExpandedNodeNew

func ExpandedNodeNew(getPositioner GetPositioner, userObj bh.NodeIf, nId bh.NodeIdIf) (ret *ExpandedNode) {
	positioner := getPositioner(nId)
	pos := positioner.Position()
	path := nId.String()
	config := DrawConfig{ColorInit(ColorOption(NormalExpandedNode)),
		ColorInit(ColorOption(HighlightExpandedNode)),
		ColorInit(ColorOption(SelectExpandedNode)),
		ColorInit(ColorOption(BoxFrame)),
		ColorInit(ColorOption(Text)),
		image.Point{global.padX, global.padY}}
	cconfig := ContainerConfig{expandedPortWidth, expandedPortHeight, 120, 80}
	// Add children
	var g bh.SignalGraphTypeIf
	nt := userObj.ItsType()
	for _, impl := range nt.Implementation() {
		if impl.ImplementationType() == bh.NodeTypeGraph {
			g = impl.Graph()
			break
		}
	}
	var children []ContainerChild
	if g != nil {
		empty := image.Point{}
		first := image.Point{16, 32}
		shift := image.Point{16, 16}
		for i, n := range g.ProcessingNodes() {
			var ch ContainerChild
			var mode gr.PositionMode
			if n.Expanded() {
				mode = gr.PositionModeExpanded
			} else {
				mode = gr.PositionModeNormal
			}
			proxy := gr.PathModePositionerProxyNew(n)
			proxy.SetActivePath(path)
			proxy.SetActiveMode(mode)
			log.Printf("ExpandedNodeNew TODO: position of child nodes. path=%s, mode=%v\n", path, mode)
			chpos := proxy.Position()
			if chpos == empty {
				chpos = pos.Add(first.Add(shift.Mul(i)))
				proxy.SetPosition(chpos)
			}
			id := freesp.NodeIdNew(nId, n.Name())
			if n.Expanded() {
				ch = ExpandedNodeNew(getPositioner, n, id)
			} else {
				ch = NodeNew(getPositioner, n, id)
			}
			children = append(children, ch)
		}
	}
	ret = &ExpandedNode{ContainerInit(children, config, userObj, cconfig),
		userObj, positioner, nil, nil}
	ret.ContainerInit()
	empty := image.Point{}
	config = DrawConfig{ColorInit(ColorOption(InputPort)),
		ColorInit(ColorOption(HighlightInPort)),
		ColorInit(ColorOption(SelectInPort)),
		ColorInit(ColorOption(BoxFrame)),
		Color{},
		image.Point{}}
	for i, p := range userObj.InPorts() {
		pos := p.ModePosition(gr.PositionModeExpanded)
		if pos == empty {
			pos = ret.CalcInPortPos(i)
		}
		positioner := gr.ModePositionerProxyNew(p, gr.PositionModeExpanded)
		ret.AddPort(config, p, positioner)
	}
	config = DrawConfig{ColorInit(ColorOption(OutputPort)),
		ColorInit(ColorOption(HighlightOutPort)),
		ColorInit(ColorOption(SelectOutPort)),
		ColorInit(ColorOption(BoxFrame)),
		Color{},
		image.Point{}}
	for i, p := range userObj.OutPorts() {
		pos := p.ModePosition(gr.PositionModeExpanded)
		if pos == empty {
			pos = ret.CalcOutPortPos(i)
		}
		positioner := gr.ModePositionerProxyNew(p, gr.PositionModeExpanded)
		ret.AddPort(config, p, positioner)
	}
	for _, n := range g.ProcessingNodes() {
		from, ok := ret.ChildByName(n.Name())
		if !ok {
			log.Printf("ExpandedNodeNew error: node %s not found\n", n.Name())
			continue
		}
		for _, p := range n.OutPorts() {
			fromId := from.OutPortIndex(p.Name())
			for _, c := range p.Connections() {
				to, ok := ret.ChildByName(c.Node().Name())
				if ok {
					toId := to.InPortIndex(c.Name())
					ret.connections = append(ret.connections, ConnectionNew(from, to, fromId, toId))
				} else {
					portname, ok := c.Node().PortLink()
					if !ok {
						log.Printf("ExpandedNodeNew error: output node %s not linked\n", c.Node().Name())
//.........这里部分代码省略.........
开发者ID:axel-freesp,项目名称:sge,代码行数:101,代码来源:expandednode.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang behaviour.SignalTypeIf类代码示例发布时间:2022-05-24
下一篇:
Golang behaviour.SignalGraphIf类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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