public void NullString() { InitCompiler("null", 0); Assert.IsTrue(parser.Parse(compiler)); Assert.AreSame(root, compiler.Parent); Assert.AreEqual(1, root.Children.Count); Assert.AreEqual(new NullToken(0), root.Children[0]); Assert.AreEqual(4, compiler.Pos); }
public static void main(string[] args) { int i; var net = new EpanetNetwork(); //Tank Tank tank = new Tank("0") { Elevation = 210 }; net.Nodes.Add(tank); //Nodes Node[] node = new Node[7]; for (i = 1; i < 7; i++) { node[i] = new Node(i.ToString()); } node[1].Elevation = 150; node[1].Demands.Add(new Demand(100, null)); node[2].Elevation = 160; node[2].Demands.Add(new Demand(100, null)); node[3].Elevation = 155; node[3].Demands.Add(new Demand(120, null)); node[4].Elevation = 150; node[4].Demands.Add(new Demand(270, null)); node[5].Elevation = 165; node[5].Demands.Add(new Demand(330, null)); node[6].Elevation = 160; node[6].Demands.Add(new Demand(200, null)); //Links Link[] pipe = new Link[8]; for (i = 0; i < 8; i++) { pipe[i] = new Link(i.ToString()) { Lenght = 1000 }; } pipe[0].FirstNode = tank; pipe[0].SecondNode = node[1]; pipe[1].FirstNode = node[1]; pipe[1].SecondNode = node[2]; pipe[2].FirstNode = node[1]; pipe[2].SecondNode = node[3]; pipe[3].FirstNode = node[3]; pipe[3].SecondNode = node[4]; pipe[4].FirstNode = node[3]; pipe[4].SecondNode = node[5]; pipe[5].FirstNode = node[5]; pipe[5].SecondNode = node[6]; pipe[6].FirstNode = node[2]; pipe[6].SecondNode = node[4]; pipe[7].FirstNode = node[4]; pipe[7].SecondNode = node[6]; for (i = 1; i < 7; i++) { net.Nodes.Add(node[i]); } for (i = 0; i < 8; i++) { net.Links.Add(pipe[i]); } //Prepare Network TraceSource log = new TraceSource(typeof(SampleOOPNetwork2).FullName, SourceLevels.All); NullParser nP = (NullParser)InputParser.Create(FileType.NULL_FILE); Debug.Assert(nP != null); nP.Parse(new EpanetNetwork(), null); //// Simulate hydraulics string hydFile = Path.GetTempFileName(); // ("hydSim", "bin"); HydraulicSim hydSim = new HydraulicSim(net, log); hydSim.Simulate(hydFile); // Read hydraulic results HydraulicReader hydReader = new HydraulicReader(hydFile); for (long time = net.RStart; time <= net.Duration; time += net.RStep) { AwareStep step = hydReader.GetStep((int)time); Console.WriteLine("Time : " + step.Time.GetClockTime() + ", nodes heads : "); i = 0; foreach (Node inode in net.Nodes) { Console.Write("{0:F2}\t", step.GetNodeHead(i++, inode, null)); } Console.WriteLine(); } hydReader.Close(); }
public static void main(string[] args) { var net = new EpanetNetwork(); //Tank Tank tank = new Tank("0") { Elevation = 210 }; net.Nodes.Add(tank); //Nodes Node[] node = new Node[7]; for (int i = 1; i < 7; i++) { node[i] = new Node(i.ToString()); } node[1].Elevation = 150; node[1].Demands.Add(new Demand(100, null)); node[2].Elevation = 160; node[2].Demands.Add(new Demand(100, null)); node[3].Elevation = 155; node[3].Demands.Add(new Demand(120, null)); node[4].Elevation = 150; node[4].Demands.Add(new Demand(270, null)); node[5].Elevation = 165; node[5].Demands.Add(new Demand(330, null)); node[6].Elevation = 160; node[6].Demands.Add(new Demand(200, null)); //Links Link[] pipe = new Link[8]; for (int i = 0; i < 8; i++) { pipe[i] = new Link(i.ToString()) { Lenght = 1000 }; } pipe[0].FirstNode = tank; pipe[0].SecondNode = node[1]; pipe[1].FirstNode = node[1]; pipe[1].SecondNode = node[2]; pipe[2].FirstNode = node[1]; pipe[2].SecondNode = node[3]; pipe[3].FirstNode = node[3]; pipe[3].SecondNode = node[4]; pipe[4].FirstNode = node[3]; pipe[4].SecondNode = node[5]; pipe[5].FirstNode = node[5]; pipe[5].SecondNode = node[6]; pipe[6].FirstNode = node[2]; pipe[6].SecondNode = node[4]; pipe[7].FirstNode = node[4]; pipe[7].SecondNode = node[6]; for (int i = 1; i < 7; i++) { net.Nodes.Add(node[i]); } for (int i = 0; i < 8; i++) { net.Links.Add(pipe[i]); } //Prepare Network TraceSource log = new TraceSource(typeof(SampleOOPNetwork2).FullName, SourceLevels.All); NullParser nP = (NullParser)InputParser.Create(FileType.NULL_FILE); Debug.Assert(nP != null); nP.Parse(new EpanetNetwork(), null); //// Simulate hydraulics and get streaming/dynamic results new DynamicSimulation(net, log).Simulate(); }