Example #1
0
        private void CreateOutput()
        {
            using (FileCreator fc = new FileCreator(_outputFilePath))
            {
                fc.WriteLine(Slices.Count().ToString());

                foreach (Slice slice in Slices)
                {
                    string strSlice = $"{slice.SliceBegin.Row} {slice.SliceBegin.Column} {slice.SliceEnd.Row} {slice.SliceEnd.Column}";
                    fc.WriteLine(strSlice);
                }
            }
        }
Example #2
0
 private void WriteSteps(Journey journey, FileCreator fileCreator)
 {
     foreach (var junction in journey.Steps)
     {
         fileCreator.WriteLine(junction.Id);
     }
 }
Example #3
0
        private void WriteCarLine(FileCreator fileCreator, Car car)
        {
            var sb = new StringBuilder();

            sb.Append(car.Rides.Count);
            string line = car.Rides.Count.ToString();

            foreach (var ride in car.Rides)
            {
                sb.Append(" ").Append(ride.Id);
            }

            fileCreator.WriteLine(sb.ToString());
        }
Example #4
0
        private void CreateClassFileFromChannels(WagoBK.Channels MyChannels, string ProjectName, Stream OutputFile)
        {
            if (OutputFile == null)
            {
                throw new Exception("output file is null");
            }
            if (MyChannels == null)
            {
                throw new Exception("Channel-Obj is null");
            }
            int[]       Slots     = MyChannels.ProjectCards.GetSlotNumbers();
            FileCreator BKFileOut = new FileCreator(OutputFile);

            BKFileOut.WriteLine("using System;");
            BKFileOut.WriteLine("using System.Collections.Generic;");
            BKFileOut.WriteLine("using System.Text;");
            BKFileOut.WriteLine("using WagoBK;");

            BKFileOut.WriteLine("namespace " + ProjectName);
            BKFileOut.WriteLine("{");
            BKFileOut.WriteLine("public class " + ProjectName + "BK : WagoBKBase");
            BKFileOut.WriteLine("{");
            BKFileOut.WriteLine("public " + ProjectName + "BK(): base() {}");
            BKFileOut.WriteLine("protected override Channels CreateChannels()");
            BKFileOut.WriteLine("{ return new " + ProjectName + "Channels(); }");
            BKFileOut.WriteLine("public override void CheckInterlock(){}");
            BKFileOut.WriteLine("public new " + ProjectName + "Channels Ch()");
            BKFileOut.WriteLine("{ return (" + ProjectName + "Channels)base.Ch(); }");
            BKFileOut.WriteLine("");
            BKFileOut.WriteLine("public class " + ProjectName + "Channels : Channels");
            BKFileOut.WriteLine("{");
            BKFileOut.WriteLine("public " + ProjectName + "Channels() : base()");
            BKFileOut.WriteLine("{ }");
            BKFileOut.WriteLine("protected override void InitChannelList()");
            BKFileOut.WriteLine("{");

            //initialise and add Cards
            BKFileOut.WriteLine("int Slot = 0;");
            foreach (int Slot in Slots)
            {
                BKFileOut.WriteLine(" m_" + MyChannels.ProjectCards.GetCard(Slot).GetType().Name + "_" + Slot.ToString() +
                                    " = new " + MyChannels.ProjectCards.GetCard(Slot).GetType().Name + "();");
                BKFileOut.WriteLine("ProjectCards.AddCard(Slot++, " + MyChannels.ProjectCards.GetCard(Slot).GetType().Name + "_" + Slot.ToString() +
                                    ");");
            }

            // define Channel-List
            foreach (string Name in MyChannels.DIChannels.Keys)
            {
                BKFileOut.WriteLine("DIChannels.Add(\"" + Name + "\", new DIChannelDef(\"" +
                                    MyChannels.DIChannels[Name].GetName() + "\",\"" +
                                    MyChannels.DIChannels[Name].GetBMK() + "\"," +
                                    " m_" + MyChannels.DIChannels[Name].GetCard().GetType().Name +
                                    "_" + MyChannels.ProjectCards.GetCardSlot(MyChannels.DIChannels[Name].GetCard()).ToString() + "," +
                                    MyChannels.DIChannels[Name].GetChannel().ToString() + "));");
            }
            BKFileOut.WriteLine("");
            foreach (string Name in MyChannels.DOChannels.Keys)
            {
                BKFileOut.WriteLine("DOChannels.Add(\"" + Name + "\", new DOChannelDef(\"" +
                                    MyChannels.DOChannels[Name].GetName() + "\",\"" +
                                    MyChannels.DOChannels[Name].GetBMK() + "\"," +
                                    " m_" + MyChannels.DOChannels[Name].GetCard().GetType().Name +
                                    "_" + MyChannels.ProjectCards.GetCardSlot(MyChannels.DOChannels[Name].GetCard()).ToString() + "," +
                                    MyChannels.DOChannels[Name].GetChannel().ToString() + "));");
            }
            BKFileOut.WriteLine("");
            foreach (string Name in MyChannels.AIChannels.Keys)
            {
                BKFileOut.WriteLine("AIChannels.Add(\"" + Name + "\", new AIChannelDef(\"" +
                                    MyChannels.AIChannels[Name].GetName() + "\",\"" +
                                    MyChannels.AIChannels[Name].GetBMK() + "\"," +
                                    " m_" + MyChannels.AIChannels[Name].GetCard().GetType().Name +
                                    "_" + MyChannels.ProjectCards.GetCardSlot(MyChannels.AIChannels[Name].GetCard()).ToString() + "," +
                                    MyChannels.AIChannels[Name].GetChannel().ToString() + "));");
            }
            BKFileOut.WriteLine("");
            foreach (string Name in MyChannels.AOChannels.Keys)
            {
                BKFileOut.WriteLine("AOChannels.Add(\"" + Name + "\", new AOChannelDef(\"" +
                                    MyChannels.AOChannels[Name].GetName() + "\",\"" +
                                    MyChannels.AOChannels[Name].GetBMK() + "\"," +
                                    " m_" + MyChannels.AOChannels[Name].GetCard().GetType().Name +
                                    "_" + MyChannels.ProjectCards.GetCardSlot(MyChannels.AOChannels[Name].GetCard()).ToString() + "," +
                                    MyChannels.AOChannels[Name].GetChannel().ToString() + "));");
            }
            BKFileOut.WriteLine("}");
            //add property for each Channel
            foreach (string Name in MyChannels.DOChannels.Keys)
            {
                BKFileOut.WriteLine("public bool DO_" + Name);
                BKFileOut.WriteLine("{");
                BKFileOut.WriteLine("get { return DOChannels[\"" + Name + "\"].Get(); }");
                BKFileOut.WriteLine("set { DOChannels[\"" + Name + "\"].Set(value); }");
                BKFileOut.WriteLine("}");
            }
            BKFileOut.WriteLine("");
            foreach (string Name in MyChannels.DIChannels.Keys)
            {
                BKFileOut.WriteLine("public bool DI_" + Name);
                BKFileOut.WriteLine("{");
                BKFileOut.WriteLine("get { return DIChannels[\"" + Name + "\"].Get(); }");
                BKFileOut.WriteLine("}");
            }
            BKFileOut.WriteLine("");
            foreach (string Name in MyChannels.AIChannels.Keys)
            {
                BKFileOut.WriteLine("public double AI_" + Name);
                BKFileOut.WriteLine("{");
                BKFileOut.WriteLine("get { return AIChannels[\"" + Name + "\"].Get(); }");
                BKFileOut.WriteLine("}");
            }
            BKFileOut.WriteLine("");
            foreach (string Name in MyChannels.AOChannels.Keys)
            {
                BKFileOut.WriteLine("public double AO_" + Name);
                BKFileOut.WriteLine("{");
                BKFileOut.WriteLine("get { return AOChannels[\"" + Name + "\"].Get(); }");
                BKFileOut.WriteLine("set { AOChannels[\"" + Name + "\"].Set(value); }");
                BKFileOut.WriteLine("}");
            }
            //carddefinition
            foreach (int Slot in Slots)
            {
                BKFileOut.WriteLine("private " + MyChannels.ProjectCards.GetCard(Slot).GetType().Name +
                                    " m_" + MyChannels.ProjectCards.GetCard(Slot).GetType().Name + "_" + Slot.ToString() +
                                    ";");
                BKFileOut.WriteLine("public " + MyChannels.ProjectCards.GetCard(Slot).GetType().Name +
                                    " " + MyChannels.ProjectCards.GetCard(Slot).GetType().Name + "_" + Slot.ToString());
                BKFileOut.WriteLine("{");
                BKFileOut.WriteLine("get { return m_" + MyChannels.ProjectCards.GetCard(Slot).GetType().Name + "_" + Slot.ToString() + "; }");
                BKFileOut.WriteLine("}");
            }

            BKFileOut.WriteLine("}");
            BKFileOut.WriteLine("}");
            BKFileOut.WriteLine("}");

            BKFileOut.CloseFile();
        }
Example #5
0
 private void WriteNumberOfJunctions(Journey journey, FileCreator fileCreator)
 {
     fileCreator.WriteLine(journey.Steps.Count());
 }
Example #6
0
 private static void WriteNbCars(List <Journey> journeys, FileCreator fileCreator)
 {
     fileCreator.WriteLine(journeys.Count());
 }