Exemplo n.º 1
0
        /// <summary>
        /// Helper method that creates all the wires on the VI.
        /// Since the other nodes have all been created, this method can look at all the connections on the wire.
        /// </summary>
        private void ConnectWires()
        {
            foreach (Wire wire in _modelWires)
            {
                var connectedDfirTerminals = new List <NationalInstruments.Dfir.Terminal>();
                var looseEnds = new List <Terminal>();
                foreach (Terminal terminal in wire.Terminals)
                {
                    if (terminal.ConnectedTerminal != null)
                    {
                        connectedDfirTerminals.Add(_map.GetDfirForTerminal(terminal.ConnectedTerminal));
                    }
                    else
                    {
                        looseEnds.Add(terminal);
                    }
                }

                var parentDiagram = (NationalInstruments.Dfir.Diagram)_map.GetDfirForModel(wire.Owner);
                NationalInstruments.Dfir.Wire dfirWire = NationalInstruments.Dfir.Wire.Create(parentDiagram, connectedDfirTerminals);
                _map.AddMapping(wire, dfirWire);
                dfirWire.SetWireBeginsMutableVariable(wire.GetWireBeginsMutableVariable());
                int i = 0;
                // Map connected model wire terminals
                foreach (Terminal terminal in wire.Terminals.Where(t => t.ConnectedTerminal != null))
                {
                    MapTerminalAndType(terminal, dfirWire.Terminals[i]);
                    i++;
                }
                // Map unconnected model wire terminals
                foreach (Terminal terminal in looseEnds)
                {
                    NationalInstruments.Dfir.Terminal dfirTerminal = dfirWire.CreateBranch();
                    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)
                {
                    NationalInstruments.Dfir.Terminal dfirTerminal = dfirWire.CreateBranch();
                    dfirTerminal.DataType = PFTypes.Void;
                }

                // Now split the wire up into multiple wires if there are multiple sinks
                if (dfirWire.SinkTerminals.Count > 1)
                {
                }
            }

            // done with stored wires, set to null to avoid memory leaks
            _modelWires = null;
        }
Exemplo n.º 2
0
 private void MapTerminalAndType(Terminal modelTerminal, NationalInstruments.Dfir.Terminal dfirTerminal)
 {
     _map.AddMapping(modelTerminal, dfirTerminal);
     dfirTerminal.SetSourceModelId(modelTerminal);
     dfirTerminal.DataType = modelTerminal.DataType.IsUnset() ? PFTypes.Void : modelTerminal.DataType;
 }