using Yw.WpfUI.Hydro;
|
|
namespace HStation.WinFrmUI
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public static class HydroL3d2TransferHelper
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public static NetworkL3d ToL3d2NetworkViewModel(this Yw.Model.HydroModelInfo rhs)
|
{
|
if (rhs == null)
|
{
|
return default;
|
}
|
var vm = new NetworkL3d();
|
if (rhs.Junctions != null && rhs.Junctions.Count > 0)
|
{
|
foreach (var junction in rhs.Junctions)
|
{
|
var junctionViewModel = new JunctionL3d();
|
junctionViewModel.Id = junction.Code;
|
junctionViewModel.Name = junction.Name;
|
junctionViewModel.Position = new PointL3d(junction.Position3d.X, junction.Position3d.Y, junction.Position3d.Z);
|
vm.Append(junctionViewModel, out _);
|
}
|
}
|
if (rhs.Nozzles != null && rhs.Nozzles.Count > 0)
|
{
|
foreach (var nozzle in rhs.Nozzles)
|
{
|
var nozzleViewModel = new JunctionL3d();
|
nozzleViewModel.Id = nozzle.Code;
|
nozzleViewModel.Name = nozzle.Name;
|
nozzleViewModel.Position = new PointL3d(nozzle.Position3d.X, nozzle.Position3d.Y, nozzle.Position3d.Z);
|
vm.Append(nozzleViewModel, out _);
|
}
|
}
|
if (rhs.Hydrants != null && rhs.Hydrants.Count > 0)
|
{
|
foreach (var hydrant in rhs.Hydrants)
|
{
|
var hydrantViewModel = new JunctionL3d();
|
hydrantViewModel.Id = hydrant.Code;
|
hydrantViewModel.Name = hydrant.Name;
|
hydrantViewModel.Position = new PointL3d(hydrant.Position3d.X, hydrant.Position3d.Y, hydrant.Position3d.Z);
|
vm.Append(hydrantViewModel, out _);
|
}
|
}
|
if (rhs.Elbows != null && rhs.Elbows.Count > 0)
|
{
|
foreach (var elbow in rhs.Elbows)
|
{
|
var elbowViewModel = new JunctionL3d();
|
elbowViewModel.Id = elbow.Code;
|
elbowViewModel.Name = elbow.Name;
|
elbowViewModel.Position = new PointL3d(elbow.Position3d.X, elbow.Position3d.Y, elbow.Position3d.Z);
|
vm.Append(elbowViewModel, out _);
|
}
|
}
|
if (rhs.Threelinks != null && rhs.Threelinks.Count > 0)
|
{
|
foreach (var threelink in rhs.Threelinks)
|
{
|
var threelinkViewModel = new JunctionL3d();
|
threelinkViewModel.Id = threelink.Code;
|
threelinkViewModel.Name = threelink.Name;
|
threelinkViewModel.Position = new PointL3d(threelink.Position3d.X, threelink.Position3d.Y, threelink.Position3d.Z);
|
vm.Append(threelinkViewModel, out _);
|
}
|
}
|
if (rhs.Fourlinks != null && rhs.Fourlinks.Count > 0)
|
{
|
foreach (var fourlink in rhs.Fourlinks)
|
{
|
var fourlinkViewModel = new JunctionL3d();
|
fourlinkViewModel.Id = fourlink.Code;
|
fourlinkViewModel.Name = fourlink.Name;
|
fourlinkViewModel.Position = new PointL3d(fourlink.Position3d.X, fourlink.Position3d.Y, fourlink.Position3d.Z);
|
vm.Append(fourlinkViewModel, out _);
|
}
|
}
|
if (rhs.Meters != null && rhs.Meters.Count > 0)
|
{
|
foreach (var meter in rhs.Meters)
|
{
|
var meterViewModel = new JunctionL3d();
|
meterViewModel.Id = meter.Code;
|
meterViewModel.Name = meter.Name;
|
meterViewModel.Position = new PointL3d(meter.Position3d.X, meter.Position3d.Y, meter.Position3d.Z);
|
vm.Append(meterViewModel, out _);
|
}
|
}
|
if (rhs.Flowmeters != null && rhs.Flowmeters.Count > 0)
|
{
|
foreach (var flowmeter in rhs.Flowmeters)
|
{
|
var flowmeterViewModel = new JunctionL3d();
|
flowmeterViewModel.Id = flowmeter.Code;
|
flowmeterViewModel.Name = flowmeter.Name;
|
flowmeterViewModel.Position = new PointL3d(flowmeter.Position3d.X, flowmeter.Position3d.Y, flowmeter.Position3d.Z);
|
vm.Append(flowmeterViewModel, out _);
|
}
|
}
|
if (rhs.Pressmeters != null && rhs.Pressmeters.Count > 0)
|
{
|
foreach (var pressmeter in rhs.Pressmeters)
|
{
|
var pressmeterViewModel = new JunctionL3d();
|
pressmeterViewModel.Id = pressmeter.Code;
|
pressmeterViewModel.Name = pressmeter.Name;
|
pressmeterViewModel.Position = new PointL3d(pressmeter.Position3d.X, pressmeter.Position3d.Y, pressmeter.Position3d.Z);
|
vm.Append(pressmeterViewModel, out _);
|
}
|
}
|
if (rhs.Bluntheads != null && rhs.Bluntheads.Count > 0)
|
{
|
foreach (var blunthead in rhs.Bluntheads)
|
{
|
var bluntheadViewModel = new JunctionL3d();
|
bluntheadViewModel.Id = blunthead.Code;
|
bluntheadViewModel.Name = blunthead.Name;
|
bluntheadViewModel.Position = new PointL3d(blunthead.Position3d.X, blunthead.Position3d.Y, blunthead.Position3d.Z);
|
vm.Append(bluntheadViewModel, out _);
|
}
|
}
|
|
if (rhs.Reservoirs != null && rhs.Reservoirs.Count > 0)
|
{
|
foreach (var reservoir in rhs.Reservoirs)
|
{
|
var reservoirViewModel = new ReservoirL3d();
|
reservoirViewModel.Id = reservoir.Code;
|
reservoirViewModel.Name = reservoir.Name;
|
reservoirViewModel.Position = new PointL3d(reservoir.Position3d.X, reservoir.Position3d.Y, reservoir.Position3d.Z);
|
vm.Append(reservoirViewModel, out _);
|
}
|
}
|
if (rhs.Tanks != null && rhs.Tanks.Count > 0)
|
{
|
foreach (var tank in rhs.Tanks)
|
{
|
var tankViewModel = new TankL3d();
|
tankViewModel.Id = tank.Code;
|
tankViewModel.Name = tank.Name;
|
tankViewModel.Position = new PointL3d(tank.Position3d.X, tank.Position3d.Y, tank.Position3d.Z);
|
vm.Append(tankViewModel, out _);
|
}
|
}
|
if (rhs.Waterboxs != null && rhs.Waterboxs.Count > 0)
|
{
|
foreach (var waterbox in rhs.Waterboxs)
|
{
|
var waterboxViewModel = new TankL3d();
|
waterboxViewModel.Id = waterbox.Code;
|
waterboxViewModel.Name = waterbox.Name;
|
waterboxViewModel.Position = new PointL3d(waterbox.Position3d.X, waterbox.Position3d.Y, waterbox.Position3d.Z);
|
vm.Append(waterboxViewModel, out _);
|
}
|
}
|
|
if (rhs.Pipes != null && rhs.Pipes.Count > 0)
|
{
|
foreach (var pipe in rhs.Pipes)
|
{
|
var startNode = rhs.GetAllNodes().Find(x => x.Code == pipe.StartCode);
|
var endNode = rhs.GetAllNodes().Find(x => x.Code == pipe.EndCode);
|
var pipeViewModel = new PipeL3d();
|
pipeViewModel.Id = pipe.Code;
|
pipeViewModel.Name = pipe.Name;
|
pipeViewModel.StartPosition = new PointL3d(startNode.Position3d.X, startNode.Position3d.Y, startNode.Position3d.Z);
|
pipeViewModel.EndPosition = new PointL3d(endNode.Position3d.X, endNode.Position3d.Y, endNode.Position3d.Z);
|
vm.Append(pipeViewModel, out _);
|
}
|
}
|
if (rhs.Translations != null && rhs.Translations.Count > 0)
|
{
|
foreach (var translation in rhs.Translations)
|
{
|
var startNode = rhs.GetAllNodes().Find(x => x.Code == translation.StartCode);
|
var endNode = rhs.GetAllNodes().Find(x => x.Code == translation.EndCode);
|
var pipeViewModel = new PipeL3d();
|
pipeViewModel.Id = translation.Code;
|
pipeViewModel.Name = translation.Name;
|
pipeViewModel.StartPosition = new PointL3d(startNode.Position3d.X, startNode.Position3d.Y, startNode.Position3d.Z);
|
pipeViewModel.EndPosition = new PointL3d(endNode.Position3d.X, endNode.Position3d.Y, endNode.Position3d.Z);
|
vm.Append(pipeViewModel, out _);
|
}
|
}
|
if (rhs.Exchangers != null && rhs.Exchangers.Count > 0)
|
{
|
foreach (var exchanger in rhs.Exchangers)
|
{
|
var startNode = rhs.GetAllNodes().Find(x => x.Code == exchanger.StartCode);
|
var endNode = rhs.GetAllNodes().Find(x => x.Code == exchanger.EndCode);
|
var pipeViewModel = new ValveL3d();
|
pipeViewModel.Id = exchanger.Code;
|
pipeViewModel.Name = exchanger.Name;
|
pipeViewModel.StartPosition = new PointL3d(startNode.Position3d.X, startNode.Position3d.Y, startNode.Position3d.Z);
|
pipeViewModel.EndPosition = new PointL3d(endNode.Position3d.X, endNode.Position3d.Y, endNode.Position3d.Z);
|
vm.Append(pipeViewModel, out _);
|
}
|
}
|
|
if (rhs.Pumps != null && rhs.Pumps.Count > 0)
|
{
|
foreach (var pump in rhs.Pumps)
|
{
|
var startNode = rhs.GetAllNodes().Find(x => x.Code == pump.StartCode);
|
var endNode = rhs.GetAllNodes().Find(x => x.Code == pump.EndCode);
|
var pipeViewModel = new PumpL3d();
|
pipeViewModel.Id = pump.Code;
|
pipeViewModel.Name = pump.Name;
|
pipeViewModel.StartPosition = new PointL3d(startNode.Position3d.X, startNode.Position3d.Y, startNode.Position3d.Z);
|
pipeViewModel.EndPosition = new PointL3d(endNode.Position3d.X, endNode.Position3d.Y, endNode.Position3d.Z);
|
vm.Append(pipeViewModel, msg: out _);
|
}
|
}
|
if (rhs.Valves != null && rhs.Valves.Count > 0)
|
{
|
foreach (var valve in rhs.Valves)
|
{
|
var startNode = rhs.GetAllNodes().Find(x => x.Code == valve.StartCode);
|
var endNode = rhs.GetAllNodes().Find(x => x.Code == valve.EndCode);
|
var pipeViewModel = new ValveL3d();
|
pipeViewModel.Id = valve.Code;
|
pipeViewModel.Name = valve.Name;
|
pipeViewModel.StartPosition = new PointL3d(startNode.Position3d.X, startNode.Position3d.Y, startNode.Position3d.Z);
|
pipeViewModel.EndPosition = new PointL3d(endNode.Position3d.X, endNode.Position3d.Y, endNode.Position3d.Z);
|
vm.Append(pipeViewModel, out _);
|
}
|
}
|
|
return vm;
|
|
}
|
}
|
}
|