public void Update(IEnumerable <Point> shell, IEnumerable <IEnumerable <Point> > holes)
        {
            if (shell == null || shell.Count() <= 2)
            {
                return;
            }

            Shell = shell.ToList();
            if (Shell.First() != Shell.Last())
            {
                Shell.Add(Shell.First());
            }

            Holes = holes.Select(h => h.ToList()).ToList();

            var pathGeom = new PathGeometry();
            var figures  = new PathFigureCollection();

            foreach (var component in holes.Union(new IEnumerable <Point>[] { shell }))
            {
                var figure = new PathFigure(component.First(), component.Skip(1).Select(p => new LineSegment(p, true)), true);
                figures.Add(figure);
            }
            pathGeom.Figures = figures;
            Geometry         = pathGeom;
        }
Example #2
0
        public static void Main (string[] args)
        {
            var s = new Shell(()=>"jmaxxzshell> ")
            {
                {"echo", new Echo()},
                {"sleep", new Sleep()},
                {"pause", new Pause("Press any key to continue...")},
                {"beep", new Beep()},
                {"wget", new Download()},
            };
            s.Add("exit", new Exit(s));


            s.Start(new Cli(Console.In, Console.Out));
        }
Example #3
0
        public static void Main(string[] args)
        {
            var s = new Shell(() => "jmaxxzshell> ")
            {
                { "echo", new Echo() },
                { "sleep", new Sleep() },
                { "pause", new Pause("Press any key to continue...") },
                { "beep", new Beep() },
                { "wget", new Download() },
            };

            s.Add("exit", new Exit(s));


            s.Start(new Cli(Console.In, Console.Out));
        }
        public void Update(IEnumerable <Point> shell)
        {
            if (shell == null || shell.Count() <= 2)
            {
                return;
            }

            Shell = shell.ToList();
            if (Shell.First() != Shell.Last())
            {
                Shell.Add(Shell.First());
            }

            var pathGeom = new PathGeometry();
            var figure   = new PathFigure(shell.First(), shell.Skip(1).Select(p => new LineSegment(p, true)), true);

            pathGeom.Figures = new PathFigureCollection {
                figure
            };
            Geometry = pathGeom;
        }
        public ShellAndTubeHeatExchanger Configure()
        {
            if (!FindMaterialPort("TubeIn").IsConnected ||
                !FindMaterialPort("TubeOut").IsConnected ||
                !FindMaterialPort("ShellIn").IsConnected ||
                !FindMaterialPort("ShellOut").IsConnected)
            {
                throw new InvalidOperationException("Shell&Tube heat Exchanger not connected correctly");
            }


            var TubeIn  = FindMaterialPort("TubeIn").Streams[0];
            var TubeOut = FindMaterialPort("TubeOut").Streams[0];

            var ShellIn  = FindMaterialPort("ShellIn").Streams[0];
            var ShellOut = FindMaterialPort("ShellOut").Streams[0];

            var shellSystem = ShellIn.System;
            var tubeSystem  = TubeIn.System;

            TubeStreams.Add(TubeIn);
            ShellStreams.Add(ShellIn);
            var numTotalCells = NumberOfPasses * Discretization;


            for (int i = 0; i < numTotalCells; i++)
            {
                if (i < numTotalCells - 1)
                {
                    TubeStreams.Add(new MaterialStream(Name + ".TubeStream[" + (i + 1) + "]", tubeSystem));
                    ShellStreams.Add(new MaterialStream(Name + ".ShellStream[" + (i + 1) + "]", shellSystem));
                }
                else
                {
                    TubeStreams.Add(TubeOut);
                    ShellStreams.Add(ShellOut);
                }


                QExchanged.Add(new HeatStream(Name + ".Q[" + (i + 1) + "]", System));

                var currentTubeCell = new HeatExchangerCell(Name + ".TubeWall[" + (i + 1) + "]", tubeSystem);
                Tube.Add(currentTubeCell);
                var currentShellCell = new HeatExchangerCell(Name + ".ShellWall[" + (i + 1) + "]", shellSystem);
                Shell.Add(currentShellCell);

                currentTubeCell.Connect("In", TubeStreams[i]);
                currentShellCell.Connect("In", ShellStreams[i]);

                if (i < numTotalCells - 1)
                {
                    currentTubeCell.Connect("Out", TubeStreams[i + 1]);
                    currentShellCell.Connect("Out", ShellStreams[i + 1]);
                }
                else
                {
                    currentTubeCell.Connect("Out", TubeStreams[i + 1]);
                    currentShellCell.Connect("Out", ShellStreams[i + 1]);
                }
            }

            switch (FlowPattern)
            {
            case FlowPattern.CounterCurrent:
                for (int i = 0; i < numTotalCells; i++)
                {
                    Tube[i].Connect("Duty", QExchanged[i]);
                    Tube[i].FindHeatPort("Duty").Direction = PortDirection.Out;
                    Shell[numTotalCells - i - 1].Connect("Duty", QExchanged[i]);
                }
                break;

            case FlowPattern.CoCurrent:
                for (int i = 0; i < numTotalCells; i++)
                {
                    Tube[i].Connect("Duty", QExchanged[i]);
                    Tube[i].FindHeatPort("Duty").Direction = PortDirection.Out;
                    Shell[i].Connect("Duty", QExchanged[i]);
                }
                break;

            default:
                throw new NotSupportedException("Flow pattern " + FlowPattern + " is not supported.");
            }


            for (int i = 0; i < numTotalCells; i++)
            {
                //AddVariables(Tube[i].Variables.ToArray());
                // AddVariables(Shell[i].Variables.ToArray());
                //AddVariables(QExchanged[i].Q);
            }

            return(this);
        }
Example #6
0
		private static void Handle_Add (
					Shell Dispatch, string[] args, int index) {
			Add		Options = new Add ();

			var Registry = new Goedel.Registry.Registry ();



#pragma warning disable 162
			for (int i = index; i< args.Length; i++) {
				if 	(!IsFlag (args [i][0] )) {
					throw new System.Exception ("Unexpected parameter: " + args[i]);}			
				string Rest = args [i].Substring (1);

				TagType_Add TagType = (TagType_Add) Registry.Find (Rest);

				// here have the cases for what to do with it.

				switch (TagType) {
					default : throw new System.Exception ("Internal error");
					}
				}

#pragma warning restore 162
			Dispatch.Add (Options);

			}