Exemplo n.º 1
0
        public Element2D4(string id, string[] eNodes, string materialId, FEModell feModell)
        {
            if (eNodes == null)
            {
                throw new ArgumentNullException(nameof(eNodes));
            }
            Modell          = feModell ?? throw new ArgumentNullException(nameof(feModell));
            ElementId       = id ?? throw new ArgumentNullException(nameof(id));
            ElementDof      = 1;
            NodesPerElement = 4;
            NodeIds         = eNodes ?? throw new ArgumentNullException(nameof(eNodes));
            Nodes           = new Knoten[NodesPerElement];
            for (var i = 0; i < NodesPerElement; i++)
            {
                if (Modell.Knoten.TryGetValue(NodeIds[i], out var node))
                {
                }

                if (node != null)
                {
                    Nodes[i] = node ?? throw new ArgumentNullException(nameof(node));
                }
            }
            ElementMaterialId  = materialId ?? throw new ArgumentNullException(nameof(materialId));
            SpecificHeatMatrix = new double[4];
        }
Exemplo n.º 2
0
        private PathGeometry EineFesthaltungZeichnen(Knoten lagerKnoten)
        {
            var       pathGeometry = new PathGeometry();
            var       pathFigure   = new PathFigure();
            const int lagerSymbol  = 20;

            var startPoint = TransformKnoten(lagerKnoten, auflösung, maxY);

            pathFigure.StartPoint = startPoint;

            var endPoint = new Point(startPoint.X - lagerSymbol, startPoint.Y + lagerSymbol);

            pathFigure.Segments.Add(new LineSegment(endPoint, true));
            endPoint = new Point(endPoint.X + 2 * lagerSymbol, startPoint.Y + lagerSymbol);
            pathFigure.Segments.Add(new LineSegment(endPoint, true));
            pathFigure.Segments.Add(new LineSegment(startPoint, true));

            startPoint = new Point(endPoint.X + 5, endPoint.Y + 5);
            pathFigure.Segments.Add(new LineSegment(startPoint, false));
            endPoint = new Point(startPoint.X - 50, startPoint.Y);
            pathFigure.Segments.Add(new LineSegment(endPoint, true));

            pathGeometry.Figures.Add(pathFigure);
            return(pathGeometry);
        }
Exemplo n.º 3
0
        public void KnotentemperaturZeichnen()
        {
            foreach (var item in modell.Knoten)
            {
                knoten = item.Value;
                var temperatur = knoten.NodalDof[0].ToString("N2");
                temp = knoten.NodalDof[0];
                if (temp > maxTemp)
                {
                    maxTemp = temp;
                }
                if (temp < minTemp)
                {
                    minTemp = temp;
                }
                var fensterKnoten = TransformKnoten(knoten, auflösung, maxY);

                var id = new TextBlock
                {
                    FontSize   = 12,
                    Background = LightGray,
                    FontWeight = FontWeights.Bold,
                    Text       = temperatur
                };
                Knotentemperaturen.Add(id);
                SetTop(id, fensterKnoten.Y + RandOben);
                SetLeft(id, fensterKnoten.X + RandLinks);
                visualErgebnisse.Children.Add(id);
            }
        }
Exemplo n.º 4
0
        public void DiffDifferentTest()
        {
            const string f_alt = @"diff-b1.xml";
            const string f_neu = @"diff-b2.xml";

            Knoten alt = Knoten.createOf(createDOM(XmlReader.Create(f_alt)));
            Knoten neu = Knoten.createOf(createDOM(XmlReader.Create(f_neu)));

            DiffEngine diff = new DiffEngine();
            Knoten     res  = diff.Diff(alt, neu);

            Assert.IsNotNull(res);
            Assert.AreEqual(
                "<fucc>" +
                "<property name=\"launch\">" +
                "<!-- ADDED:   hinzugefuegt (aslkdfh) -->" +
                "</property>" +
                "<program name=\"\">" +
                "<argument startsWith=\"\">" +
                "<dir recursive=\"false\" type=\"files\">" +
                "<!-- REMOVED: match (.+\\.(cmd|exe|lnk|bat)) -->" +
                "<!-- ADDED:   match (sdf.+\\.(cmd|exe|lnk|bat)) -->" +
                "</dir>" +
                "<!-- REMOVED: pathenv () -->" +
                "<!-- ADDED:   pathenb () -->" +
                "</argument>" +
                "</program>" +
                "<!-- REMOVED: alias name=\"gt\" appendParams=\"true\" () -->" +
                "</fucc>",
                res.ToString());
        }
Exemplo n.º 5
0
        public void FestlegungAuflösung()
        {
            const int rand = 100;

            screenH = visualErgebnisse.ActualWidth;
            screenV = visualErgebnisse.ActualHeight;

            foreach (var item in modell.Knoten)
            {
                knoten = item.Value;
                if (knoten.Coordinates[0] > maxX)
                {
                    maxX = knoten.Coordinates[0];
                }
                if (knoten.Coordinates[1] > maxY)
                {
                    maxY = knoten.Coordinates[1];
                }
            }
            if (screenH / maxX < screenV / maxY)
            {
                auflösung = (screenH - rand) / maxX;
            }
            else
            {
                auflösung = (screenV - rand) / maxY;
            }
        }
Exemplo n.º 6
0
        public void KnotengradientenZeichnen(int index)
        {
            foreach (var item in modell.Knoten)
            {
                knoten = item.Value;
                var gradient = knoten.NodalDerivatives[0][index].ToString("N2");
                temp = knoten.NodalDof[0];
                if (temp > maxTemp)
                {
                    maxTemp = temp;
                }
                if (temp < minTemp)
                {
                    minTemp = temp;
                }
                var fensterKnoten = TransformKnoten(knoten, auflösung, maxY);

                var id = new TextBlock
                {
                    FontSize   = 12,
                    Background = LightBlue,
                    FontWeight = FontWeights.Bold,
                    Text       = gradient
                };
                Knotengradienten.Add(id);
                SetTop(id, fensterKnoten.Y + RandOben + 15);
                SetLeft(id, fensterKnoten.X + RandLinks);
                visualErgebnisse.Children.Add(id);
            }
        }
Exemplo n.º 7
0
 // ... Constructor ........................................................
 public FederElement(string[] springNode, string eMaterialId, FEModell feModel)
 {
     modell            = feModel;
     NodeIds           = springNode;
     ElementMaterialId = eMaterialId;
     ElementDof        = 3;
     NodesPerElement   = 1;
     Nodes             = new Knoten[1];
 }
Exemplo n.º 8
0
        private static readonly double[] GWeight = { 5.0 / 9.0, 8.0 / 9.0, 5.0 / 9.0 };   // gaussian coordinates, weights

        public Element3D8(string[] eNodes, string eMaterialId, FEModell feModell)
        {
            this.Modell       = feModell;
            ElementDof        = 3;
            NodesPerElement   = 8;
            NodeIds           = eNodes;
            Nodes             = new Knoten[NodesPerElement];
            ElementMaterialId = eMaterialId;
        }
Exemplo n.º 9
0
        private readonly double[,] e = new double[3, 3];               // Materialmatrix

        // ....Constructor................................................
        public Element2D3(string[] eNodes, string crossSectionId, string eMaterialId, FEModell feModell)
        {
            Modell                = feModell;
            ElementDof            = 2;
            NodesPerElement       = 3;
            NodeIds               = eNodes;
            Nodes                 = new Knoten[NodesPerElement];
            ElementCrossSectionId = crossSectionId;
            ElementMaterialId     = eMaterialId;
        }
Exemplo n.º 10
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (value is Knoten)
            {
                Knoten kn = (Knoten)value;

                return(kn.ID.ToString());
            }
            return(value.GetType().FullName);
        }
Exemplo n.º 11
0
        public Point TransformKnoten(Knoten modellKnoten, double[] zustand, double resolution, double max)
        {
            var fensterKnoten = new int[2];

            fensterKnoten[0] = (int)(modellKnoten.Coordinates[0] * resolution + zustand[modellKnoten.SystemIndices[0]] * eigenformSkalierung);
            fensterKnoten[1] = (int)((-modellKnoten.Coordinates[1] + max) * resolution - zustand[modellKnoten.SystemIndices[1]] * eigenformSkalierung);
            var punkt = new Point(fensterKnoten[0], fensterKnoten[1]);

            return(punkt);
        }
Exemplo n.º 12
0
 public Element2D3(string[] eNodes, string eMaterialId, FEModell feModell)
 {
     Modell             = feModell;
     ElementDof         = 1;
     NodesPerElement    = 3;
     NodeIds            = eNodes;
     Nodes              = new Knoten[NodesPerElement];
     ElementMaterialId  = eMaterialId;
     SpecificHeatMatrix = new double[3];
 }
Exemplo n.º 13
0
        private int[] TransformKnoten(Knoten knoten, double aufl, double mY)
        {
            this.auflösung = aufl;
            this.maxY      = mY;
            var fensterKnoten = new int[2];

            fensterKnoten[0] = (int)(knoten.Coordinates[0] * auflösung);
            fensterKnoten[1] = (int)(-knoten.Coordinates[1] * auflösung + maxY);
            return(fensterKnoten);
        }
Exemplo n.º 14
0
        private bool Ausfuehren_Neuzeichnen()
        {
            object[] parameter = (object[])_neuerWert;
            switch (_elementTyp)
            {
            case ElementTyp.Gleis:

                Knoten startKnoten = _anlagenElemente.SucheKnoten((Point)parameter[1]);
                Knoten endKnoten   = _anlagenElemente.SucheKnoten((Point)parameter[2]);
                if (startKnoten == null)
                {
                    startKnoten = new Knoten(_anlagenElemente, _anlagenElemente.KnotenElemente.SucheFreieNummer()
                                             , _anlagenElemente.Zoom, AnzeigeTyp.Bearbeiten, (Point)parameter[1]);
                }
                if (endKnoten == null)
                {
                    endKnoten = new Knoten(_anlagenElemente, _anlagenElemente.KnotenElemente.SucheFreieNummer()
                                           , _anlagenElemente.Zoom, AnzeigeTyp.Bearbeiten, (Point)parameter[2]);
                }
                new Gleis(_anlagenElemente, (int)parameter[0], _anlagenElemente.Zoom
                          , AnzeigeTyp.Bearbeiten, startKnoten, endKnoten);
                break;

            case ElementTyp.Signal:
                new Signal(_anlagenElemente, (int)parameter[0], _anlagenElemente.Zoom,
                           AnzeigeTyp.Bearbeiten, (Point)parameter[1], (bool)parameter[2]);
                break;

            case ElementTyp.Entkuppler:
                new Entkuppler(_anlagenElemente, (int)parameter[0], _anlagenElemente.Zoom,
                               AnzeigeTyp.Bearbeiten, (Point)parameter[1]);
                break;

            case ElementTyp.FSS:
                new FSS(_anlagenElemente, (int)parameter[0], _anlagenElemente.Zoom,
                        AnzeigeTyp.Bearbeiten, (Point)parameter[1]);
                break;

            case ElementTyp.Schalter:
                new Schalter(_anlagenElemente, (int)parameter[0], _anlagenElemente.Zoom,
                             AnzeigeTyp.Bearbeiten, (Point)parameter[1]);
                break;

            case ElementTyp.InfoElement:
                new InfoFenster(_anlagenElemente, (int)parameter[0], _anlagenElemente.Zoom,
                                AnzeigeTyp.Bearbeiten, (Point)parameter[1]);
                break;

            case ElementTyp.EingangsSchalter:
                new EingangsSchalter(_anlagenElemente, (int)parameter[0], _anlagenElemente.Zoom,
                                     AnzeigeTyp.Bearbeiten, (Point)parameter[1]);
                break;
            }
            return(true);
        }
Exemplo n.º 15
0
 // ... Constructor ........................................................
 public Biegebalken(string[] eNodeIds, string eCrossSectionId, string eMaterialId, FEModell feModel)
 {
     modell  = feModel;
     NodeIds = eNodeIds;
     ElementCrossSectionId = eCrossSectionId;
     ElementMaterialId     = eMaterialId;
     ElementDof            = 3;
     NodesPerElement       = 2;
     Nodes               = new Knoten[2];
     ElementState        = new double[6];
     ElementDeformations = new double[6];
 }
Exemplo n.º 16
0
 public Element2D2(string id, string[] eNodes, string eMaterialId, FEModell feModell)
 {
     modell             = feModell ?? throw new ArgumentNullException(nameof(feModell));
     ElementId          = id ?? throw new ArgumentNullException(nameof(id));
     NodeIds            = eNodes ?? throw new ArgumentNullException(nameof(eNodes));
     ElementMaterialId  = eMaterialId ?? throw new ArgumentNullException(nameof(eMaterialId));
     ElementDof         = 1;
     NodesPerElement    = 2;
     elementMatrix      = new double[NodesPerElement, NodesPerElement];
     specificHeatMatrix = new double[NodesPerElement];
     Nodes = new Knoten[NodesPerElement];
 }
Exemplo n.º 17
0
        public void DiffEqualTest()
        {
            const string f_alt = @"diff-b1.xml";

            Knoten alt = Knoten.createOf(createDOM(XmlReader.Create(f_alt)));
            Knoten neu = Knoten.createOf(createDOM(XmlReader.Create(f_alt)));

            DiffEngine diff = new DiffEngine();
            Knoten     res  = diff.Diff(alt, neu);

            Assert.IsNull(res);
        }
Exemplo n.º 18
0
        public void DiffEqualShortTest()
        {
            const string xml = "<xml><hallo/></xml>";

            Knoten alt = Knoten.createOf(createDOM(XmlReader.Create(xml.ToStream())));
            Knoten neu = Knoten.createOf(createDOM(XmlReader.Create(xml.ToStream())));

            DiffEngine diff = new DiffEngine();
            Knoten     res  = diff.Diff(alt, neu);

            Assert.IsNull(res);
        }
Exemplo n.º 19
0
 // ... Constructor ........................................................
 public Fachwerk(string[] eNodes, string crossSectionId, string materialId, FEModell feModel)
 {
     modell                = feModel;
     NodeIds               = eNodes;
     ElementMaterialId     = materialId;
     ElementCrossSectionId = crossSectionId;
     ElementDof            = 2;
     NodesPerElement       = 2;
     Nodes               = new Knoten[2];
     ElementState        = new double[2];
     ElementDeformations = new double[2];
 }
Exemplo n.º 20
0
        public Berechnung(FEModell m)
        {
            modell = m;
            if (modell == null)
            {
                throw new BerechnungAusnahme("Modelleingabedaten noch nicht eingelesen");
            }
            // set System Indices
            var k = 0;

            foreach (var item in modell.Knoten)
            {
                node = item.Value;
                k    = node.SetSystemIndices(k);
            }
            SetReferences(m);
        }
Exemplo n.º 21
0
        public void ElementTemperaturZeichnen()
        {
            foreach (var item in modell.Knoten)
            {
                knoten = item.Value;
                temp   = knoten.NodalDof[0];
                if (temp > maxTemp)
                {
                    maxTemp = temp;
                }
                if (temp < minTemp)
                {
                    minTemp = temp;
                }
            }

            foreach (var item in modell.Elemente)
            {
                element = item.Value;
                var pathGeometry       = AktElementZeichnen((Abstrakt2D)element);
                var elementTemperature = element.NodeIds.Where(knotenId
                                                               => modell.Knoten.TryGetValue(knotenId, out knoten)).Sum(knotenId => knoten.NodalDof[0]);
                elementTemperature /= element.NodeIds.Length;
                var intens  = (byte)(255 * (elementTemperature - minTemp) / (maxTemp - minTemp));
                var rot     = FromArgb(intens, 255, 0, 0);
                var myBrush = new SolidColorBrush(rot);

                Shape path = new Path()
                {
                    Stroke          = Blue,
                    StrokeThickness = 1,
                    Fill            = myBrush,
                    Data            = pathGeometry
                };
                TemperaturElemente.Add(path);
                // setz oben/links Position zum Zeichnen auf dem Canvas
                SetLeft(path, RandLinks);
                SetTop(path, RandOben);
                // zeichne Shape
                visualErgebnisse.Children.Add(path);
            }
        }
        private void ZeitschrittGrid_Anzeigen(object sender, RoutedEventArgs e)
        {
            if (Index == 0)
            {
                return;
            }
            var zeitschritt = new List <Knotenverformungen>();
            var dt          = modell.Zeitintegration.Dt;
            var tmax        = modell.Zeitintegration.Tmax;
            var nSteps      = (int)(tmax / dt) + 1;
            var zeit        = new double[nSteps + 1];

            zeit[0] = 0;

            Knotenverformungen knotenverformung = null;

            foreach (var item in modell.Knoten)
            {
                // eingabeEinheit z.B. in m, verformungsEinheit z.B. cm, beschleunigungsEinheit z.B. cm/s/s
                const int verformungsEinheit = 1;
                knoten = item.Value;
                switch (knoten.NodalVariables.Length)
                {
                case 2:
                    knotenverformung = new Knotenverformungen(item.Value.Id,
                                                              knoten.NodalVariables[0][Index] * verformungsEinheit, knoten.NodalVariables[1][Index] * verformungsEinheit,
                                                              knoten.NodalDerivatives[0][Index] * verformungsEinheit, knoten.NodalDerivatives[1][Index] * verformungsEinheit);
                    break;

                case 3:
                    knotenverformung = new Knotenverformungen(item.Value.Id,
                                                              knoten.NodalVariables[0][Index] * verformungsEinheit, knoten.NodalVariables[1][Index] * verformungsEinheit,
                                                              knoten.NodalVariables[2][Index] * verformungsEinheit,
                                                              knoten.NodalDerivatives[0][Index] * verformungsEinheit, knoten.NodalDerivatives[1][Index] * verformungsEinheit,
                                                              knoten.NodalDerivatives[2][Index] * verformungsEinheit);
                    break;
                }
                zeitschritt.Add(knotenverformung);
            }
            ZeitschrittGrid.ItemsSource = zeitschritt;
        }
Exemplo n.º 23
0
 // ....Constructor................................................
 public Element2D4(string[] eNodes, string materialId, FEModell feModell)
 {
     // The null-coalescing operator ?? returns the value of its left-hand operand
     // if it isn't null; otherwise, it evaluates the right-hand operand and returns
     // its result. The ?? operator doesn't evaluate its right-hand operand if the
     // left-hand operand evaluates to non-null.
     Modell          = feModell ?? throw new ArgumentNullException(nameof(feModell));
     ElementDof      = 1;
     NodesPerElement = 4;
     NodeIds         = eNodes ?? throw new ArgumentNullException(nameof(eNodes));
     Nodes           = new Knoten[NodesPerElement];
     for (var i = 0; i < NodesPerElement; i++)
     {
         if (Modell.Knoten.TryGetValue(NodeIds[i], out var node))
         {
         }
         Nodes[i] = node ?? throw new ArgumentNullException(nameof(node));
     }
     ElementMaterialId  = materialId ?? throw new ArgumentNullException(nameof(materialId));
     SpecificHeatMatrix = new double[4];
 }
Exemplo n.º 24
0
        // constructor
        public Element3D8(string[] eNodes, string materialId)
        {
            WärmeStatus = new double[3];
            if (Modell.SpatialDimension != 3)
            {
                _ = MessageBox.Show("Das Modell ist nicht 3D", "Wärmeberechnung");
            }

            ElementDof      = 1;
            NodesPerElement = 8;
            NodeIds         = eNodes;
            Nodes           = new Knoten[NodesPerElement];
            for (var i = 0; i < NodesPerElement; i++)
            {
                if (Modell.Knoten.TryGetValue(NodeIds[i], out var node))
                {
                }
                Nodes[i] = node;
            }
            ElementMaterialId = materialId;
        }
Exemplo n.º 25
0
        public void DiffAddedTest()
        {
            const string f_alt = @"diff-d1.xml";
            const string f_neu = @"diff-d2.xml";

            Knoten alt = Knoten.createOf(createDOM(XmlReader.Create(f_alt)));
            Knoten neu = Knoten.createOf(createDOM(XmlReader.Create(f_neu)));

            DiffEngine diff = new DiffEngine();
            Knoten     res  = diff.Diff(alt, neu);

            Assert.IsNotNull(res);
            Assert.AreEqual(
                "<datenmodell>" +
                "<tabellen>" +
                "<table>" +
                "<columns><!-- ADDED:   column () --></columns>" +
                "</table>" +
                "</tabellen>" +
                "</datenmodell>",
                res.ToString());
        }
Exemplo n.º 26
0
        public void SolveEquations()
        {
            if (!decomposed)
            {
                profileSolver = new ProfillöserStatus(
                    systemEquations.Matrix, systemEquations.Vector,
                    systemEquations.Primal, systemEquations.Dual,
                    systemEquations.Status, systemEquations.Profile);
                profileSolver.Decompose();
                decomposed = true;
            }
            profileSolver.Solve();
            // ... save system unknowns (primal values)
            foreach (var item in modell.Knoten)
            {
                node = item.Value;
                var index = node.SystemIndices;
                node.NodalDof = new double[node.NumberOfNodalDof];
                for (var i = 0; i < node.NodalDof.Length; i++)
                {
                    node.NodalDof[i] = systemEquations.Primal[index[i]];
                }
            }
            // ... save dual values
            var reactions = systemEquations.Dual;

            foreach (var support in modell.Randbedingungen.Select(item => item.Value))
            {
                node = support.Node;
                var index           = node.SystemIndices;
                var supportReaction = new double[node.NumberOfNodalDof];
                for (var i = 0; i < supportReaction.Length; i++)
                {
                    supportReaction[i] = reactions[index[i]];
                }
                node.Reactions = supportReaction;
            }
            modell.Solved = true;
        }
Exemplo n.º 27
0
        public void ReaktionenZeichnen()
        {
            double[] reaktionen;
            double   maxVektor = 0;
            var      knotenIds = new List <string>();

            foreach (var randbedingung in modell.Randbedingungen.Select(item => item.Value))
            {
                if (knotenIds.Contains(randbedingung.NodeId))
                {
                    break;
                }
                knotenIds.Add(randbedingung.NodeId);
                if (!modell.Knoten.TryGetValue(randbedingung.NodeId, out knoten))
                {
                    break;
                }
                reaktionen = knoten.Reactions;
                maxVektor  = reaktionen.Select(Math.Abs).Prepend(maxVektor).Max();
            }

            const double maxPfeillänge = 50;

            vektorskalierung = maxPfeillänge / maxVektor;

            foreach (var randbedingung in modell.Randbedingungen.Select(item => item.Value))
            {
                if (!modell.Knoten.TryGetValue(randbedingung.NodeId, out knoten))
                {
                    break;
                }
                reaktionen = knoten.Reactions;
                var kx = reaktionen[0] * vektorskalierung;
                var ky = reaktionen[1] * vektorskalierung;
                knoten = randbedingung.Node;
                KnotenReaktionen(knoten, kx, ky);
            }
        }
Exemplo n.º 28
0
        private void GetShorttestPath()
        {
            List <Knoten> unsortedKnoten = Einlesen();
            Knoten        startKnoten    = unsortedKnoten.FirstOrDefault(x => x.Bezeichnung.Equals(charastart.Text.ToUpper()));
            Knoten        endKnoten      = unsortedKnoten.FirstOrDefault(x => x.Bezeichnung.Equals("Z"));

            startKnoten.Gesamtentfernung = 0;

            while (startKnoten != endKnoten)
            {
                foreach (Kante k in startKnoten.Kanten)
                {
                    int gesamt = startKnoten.Gesamtentfernung + k.Abstand;


                    if (!k.ZielKnoten.Besucht && k.ZielKnoten.Gesamtentfernung > gesamt)
                    {
                        k.ZielKnoten.Gesamtentfernung = gesamt;
                        k.ZielKnoten.Vorgaenger       = startKnoten;
                    }
                }

                startKnoten.Besucht = true;
                Knoten kuerzester = null;
                foreach (Knoten kn in unsortedKnoten)
                {
                    if (!kn.Besucht && (kuerzester == null || kn.Gesamtentfernung < kuerzester.Gesamtentfernung))
                    {
                        kuerzester = kn;
                    }
                }

                startKnoten = kuerzester;
                libo.Items.Add("-" + startKnoten.Vorgaenger + "->" + startKnoten + " Distanz: " + kuerzester.Gesamtentfernung);
            }
        }
Exemplo n.º 29
0
        private List <Knoten> Einlesen()
        {
            List <Knoten> eingabeList = new List <Knoten>();

            string[] tempArray = File.ReadAllLines("Resourcen\\Knoten.csv");
            foreach (string zeile in tempArray)
            {
                string[] splitStrings = zeile.Split(';');
                if (splitStrings.Length < 3)
                {
                    continue;
                }

                string start = splitStrings[0];
                string ziel  = splitStrings[1];
                int.TryParse(splitStrings[2], out int laenge);

                Knoten startKnoten = eingabeList.FirstOrDefault(x => x.Bezeichnung.Equals(start));
                if (startKnoten == null)
                {
                    startKnoten = new Knoten(start);
                    eingabeList.Add(startKnoten);
                }
                Knoten zielKnoten = eingabeList.FirstOrDefault(x => x.Bezeichnung.Equals(ziel));
                if (zielKnoten == null)
                {
                    zielKnoten = new Knoten(ziel);
                    eingabeList.Add(zielKnoten);
                }
                startKnoten.Kanten.Add(new Kante(laenge, zielKnoten));
                zielKnoten.Kanten.Add(new Kante(laenge, startKnoten));
            }


            return(eingabeList);
        }
Exemplo n.º 30
0
        /// <summary>
        /// löscht alle gegenwärtige Elemente und
        /// lädt eine neue Anlage
        /// </summary>
        public void AnlageLaden(byte[] anlageDaten)
        {
            // this.AnlageZurücksetzen();
            _zeichnenElemente = new AnlagenElemente();
            StreamReader anlageDatenStreamReader = new StreamReader(new MemoryStream(anlageDaten), System.Text.Encoding.UTF8);

            string zeile = "";

            while ((zeile = anlageDatenStreamReader.ReadLine()) != null)
            {
                string[] elem = zeile.Split('\t');

                if (elem[0] == "Anschluss")
                {
                    new Anschluss(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }

                if (elem[0] == "MCSpeicher")
                {
                    new MCSpeicher(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }

                if (elem[0] == "Regler")
                {
                    new Regler(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }

                if (elem[0] == "Knot")
                {
                    new Knoten(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }

                if (elem[0] == "Servo")
                {
                    new Servo(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }
                if (elem[0] == "Gleis")
                {
                    new Gleis(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }
                if (elem[0] == "Weiche")
                {
                    string[] knot = elem[2].Split(' ');
                    Knoten   kn   = _zeichnenElemente.KnotenElemente.Element(Convert.ToInt32(knot[0]));
                    if (kn != null)
                    {
                        Weiche we = kn.Weichen[Convert.ToInt32(knot[1])];
                        if (we != null)
                        {
                            we.Grundstellung          = Convert.ToBoolean(elem[3]);
                            we.ID                     = Convert.ToInt32(elem[1]);
                            we.Ausgang.SpeicherString = elem[4];
                            we.Bezeichnung            = elem[5];
                            if (elem.Length > 6)
                            {
                                we.Stecker = elem[6];
                            }
                            if (elem.Length > 7)
                            {
                                we.KoppelungsString = elem[7];
                            }
                        }
                    }
                }

                if (elem[0] == "Signal")
                {
                    new Signal(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }
                if (elem[0] == "SSG")
                {
                    new StartSignalGruppe(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }
                if (elem[0] == "FSS")
                {
                    new FSS(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }
                if (elem[0] == "Schalter")
                {
                    new Schalter(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }
                if (elem[0] == "Entkuppler")
                {
                    new Entkuppler(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }
                if (elem[0] == "Info")
                {
                    new InfoFenster(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }
                if (elem[0] == "EingSchalter")
                {
                    new EingangsSchalter(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }
                if (elem[0] == "Zug")
                {
                    new Zug(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }
                if (elem[0] == "HS")
                {
                    new Haltestelle(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem);
                }
                if (elem[0] == "FahrstrasseV")
                {
                    string      befehleStart    = anlageDatenStreamReader.ReadLine();
                    string      befehleZiel     = anlageDatenStreamReader.ReadLine();
                    string      knotenListe     = anlageDatenStreamReader.ReadLine();
                    Fahrstrasse neueFahrstrasse = new Fahrstrasse(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem, befehleStart, befehleZiel, knotenListe);
                }
                if (elem[0] == "FahrstrasseN")
                {
                    string befehleStart = anlageDatenStreamReader.ReadLine();
                    string befehleZiel  = anlageDatenStreamReader.ReadLine();
                    string knotenListe  = anlageDatenStreamReader.ReadLine();
                    new FahrstrasseN(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem, befehleStart, befehleZiel, knotenListe);
                }
                if (elem[0] == "FahrstrasseK")
                {
                    string fsListe = anlageDatenStreamReader.ReadLine();
                    string befehle = anlageDatenStreamReader.ReadLine();
                    new FahrstrasseK(_zeichnenElemente, Constanten.STANDARDRASTER, this._anzeigeTyp, elem, fsListe, befehle);
                }
            }
            anlageDatenStreamReader.Dispose();

            this._zeichnenElemente.FSSLaden();
            _zeichnenElemente.FSSAktualisieren();
            _zeichnenElemente.KoppelungenAktivieren();
            this.OnAnlageGrößeInRasterChanged(new Size(65, 35));
        }