예제 #1
0
 public static void MapTerminalAndType(
     this DfirModelMap dfirModelMap,
     SMTerminal modelTerminal,
     DfirTerminal dfirTerminal)
 {
     dfirModelMap.AddMapping(modelTerminal, dfirTerminal);
     dfirTerminal.DataType = modelTerminal.DataType.IsUnset() ? NITypes.Void : modelTerminal.DataType;
 }
예제 #2
0
        private void VisitTerminateLifetime(TerminateLifetime terminateLifetime)
        {
            TerminateLifetimeNode terminateLifetimeDfir = (TerminateLifetimeNode)_map.GetDfirForModel(terminateLifetime);

            if (terminateLifetimeDfir.RequiredInputCount != null && terminateLifetimeDfir.RequiredOutputCount != null)
            {
                terminateLifetime.UpdateTerminals(terminateLifetimeDfir.RequiredInputCount.Value, terminateLifetimeDfir.RequiredOutputCount.Value);
            }
            foreach (var pair in terminateLifetime.Terminals.Zip(terminateLifetimeDfir.Terminals))
            {
                if (!_map.ContainsTerminal(pair.Key))
                {
                    _map.AddMapping(pair.Key, pair.Value);
                }
            }
        }
예제 #3
0
        public static DfirWire TranslateModelWire(this DfirModelMap dfirModelMap, SMWire wire)
        {
            var connectedDfirTerminals = new List <DfirTerminal>();
            var looseEnds = new List <SMTerminal>();

            foreach (SMTerminal terminal in wire.Terminals)
            {
                if (terminal.ConnectedTerminal != null)
                {
                    connectedDfirTerminals.Add(dfirModelMap.GetDfirForTerminal(terminal.ConnectedTerminal));
                }
                else
                {
                    looseEnds.Add(terminal);
                }
            }

            var      parentDiagram = (DfirDiagram)dfirModelMap.GetDfirForModel(wire.Owner);
            DfirWire dfirWire      = DfirWire.Create(parentDiagram, connectedDfirTerminals);

            dfirModelMap.AddMapping(wire, dfirWire);
            int i = 0;

            // Map connected model wire terminals
            foreach (SMTerminal terminal in wire.Terminals.Where(t => t.ConnectedTerminal != null))
            {
                dfirModelMap.MapTerminalAndType(terminal, dfirWire.Terminals[i]);
                i++;
            }
            // Map unconnected model wire terminals
            foreach (SMTerminal terminal in looseEnds)
            {
                DfirTerminal dfirTerminal = dfirWire.CreateBranch();
                dfirModelMap.MapTerminalAndType(terminal, dfirTerminal);
            }
            // "Map" loose ends with no terminals in the model
            int numberOfLooseEndsInModel = wire.Joints.Count(j => j.Dangling);

            for (int looseEndsIndex = 0; looseEndsIndex < numberOfLooseEndsInModel; ++looseEndsIndex)
            {
                DfirTerminal dfirTerminal = dfirWire.CreateBranch();
                dfirTerminal.DataType = NITypes.Void;
            }
            return(dfirWire);
        }
예제 #4
0
        private void VisitRebarFlatSequence(FlatSequence flatSequence)
        {
            var firstDiagram     = flatSequence.NestedDiagrams.First();
            var flatSequenceDfir = Frame.Create(_currentDiagram);

            _map.AddMapping(flatSequence, flatSequenceDfir);
            _map.AddMapping(firstDiagram, flatSequenceDfir.Diagram);

            foreach (BorderNode borderNode in flatSequence.BorderNodes)
            {
                NationalInstruments.Dfir.BorderNode dfirBorderNode = TranslateBorderNode(borderNode, flatSequenceDfir);
                MapBorderNode(borderNode, dfirBorderNode);
            }

            firstDiagram.AcceptVisitor(this);
        }
예제 #5
0
        public void VisitNode(Node node)
        {
            var typePassthrough = node as TypePassthrough;

            if (typePassthrough != null)
            {
                var typePassthroughDfir = new Nodes.FunctionalNode(_currentDiagram, Signatures.ImmutablePassthroughType);
                _map.AddMapping(typePassthrough, typePassthroughDfir);
                _map.MapTerminalsInOrder(typePassthrough, typePassthroughDfir);
                return;
            }
            throw new NotImplementedException();
        }