Пример #1
0
func (g Global) GetNodeById(id bh.NodeIdIf) (n bh.NodeIf, err error) {
	sg, err := g.SignalGraphMgr().Access(id.Filename())
	if err != nil {
		err = fmt.Errorf("Global.GetNodeById error: %s", err)
		return
	}
	for _, n = range sg.(bh.SignalGraphIf).Nodes() {
		if n.Name() == id.First() {
			return
		}
	}
	err = fmt.Errorf("Global.GetNodeById error: node %v not found in graph %s\n", id, id.Filename())
	return
}
Пример #2
0
func (g *Global) nodePath(n bh.NodeIf, nCursor tr.Cursor, selectId bh.NodeIdIf) (cursor tr.Cursor) {
	ids := strings.Split(selectId.String(), "/")
	if len(ids) == 1 {
		cursor = nCursor
		return
	}
	nt := n.ItsType()
	for _, impl := range nt.Implementation() {
		if impl.ImplementationType() == bh.NodeTypeGraph {
			for _, nn := range impl.Graph().ProcessingNodes() {
				if nn.Name() == ids[1] {
					nnId := behaviour.NodeIdFromString(strings.Join(ids[1:], "/"), selectId.Filename())
					cursor = g.nodePath(nn, g.fts.CursorAt(nCursor, nn), nnId)
					break
				}
			}
			break
		}
	}
	return
}