private static float GetLimitForAxisesBlock(RoadType roadType, AxisBlockType blockType, bool isDouble, bool isPnevno, float distanceToNext) { string distance = distanceToNext.ToString(NumberFormatInfo.InvariantInfo); DataRow maxAxisRow = Program.GetAccess("SELECT TOP 1 * FROM (SELECT * FROM MaxAxis" + $" WHERE {distance} <= Distance" + $" AND TypeAxisId = {(int)blockType} )" + " ORDER BY Distance ASC").Rows[0]; string columnStart = string.Empty; if (roadType == RoadType.R10Tc) { columnStart = "R10"; } else if (roadType == RoadType.R115Tc) { columnStart = "R115"; } else if (roadType == RoadType.R6Tc) { columnStart = "R6"; } else if (roadType == RoadType.R5Tc) { if (blockType == AxisBlockType.Single) { return(5); } throw new ArgumentException(); } string singleColumn = $"{columnStart}_Single"; string pnevmoColumn = $"{columnStart}_Pnevmo"; string doubleColumn = $"{columnStart}_Double"; if (isPnevno && !string.IsNullOrEmpty(maxAxisRow[pnevmoColumn].ToString())) { return(float.Parse(maxAxisRow[pnevmoColumn].ToString())); } if (isDouble && !string.IsNullOrEmpty(maxAxisRow[doubleColumn].ToString())) { return(float.Parse(maxAxisRow[doubleColumn].ToString())); } return(float.Parse(maxAxisRow[singleColumn].ToString())); }
public AxisBlock(AxisBlockType blockType, Axis[] axises) { BlockType = blockType; Axises = axises; Array.ForEach(axises, a => a.BlockType = blockType); }
private static void PopulateAxisBlockLoadLimitsAndDamage(IEnumerable <AxisBlock> axisBlocks, AutoRoad road) { RoadType roadType = road.RoadType; foreach (AxisBlock axisBlock in axisBlocks) { Axis[] axises = axisBlock.Axises; AxisBlockType blockType = axisBlock.BlockType; if (roadType == RoadType.R5Tc) { Array.ForEach(axises, a => a.LoadLimit = 5); Array.ForEach(axises, a => a.Damage = GetAxisDamage(road, a)); continue; } string blockInfo = $"Группа осей ({string.Join(",", axises.Select(a => a.Index + 1))}){Environment.NewLine}"; switch (blockType) { case AxisBlockType.Single: { Axis singleAxis = axises.Single(); singleAxis.LoadLimit = GetLimitForAxisesBlock(roadType, AxisBlockType.Single, singleAxis.IsDouble, singleAxis.IsPnevmo, distanceToNext: 0); singleAxis.Damage = GetAxisDamage(road, singleAxis); break; } case AxisBlockType.Dual: case AxisBlockType.Triple: { bool blockIsDouble = axises.All(a => a.IsDouble); bool blockIsPnevmo = axises.All(a => a.IsPnevmo); float blockWeight = axises.Sum(a => a.WeightValueWithInaccuracy); float maxAxisWeight = axises.Max(a => a.WeightValueWithInaccuracy); float singleAxisLimit = GetLimitForAxisesBlock(road.RoadType, AxisBlockType.Single, blockIsDouble, blockIsPnevmo, distanceToNext: 0); int distanceCount = axises.Length - 1; float averageDistance = axises.Take(distanceCount).Sum(a => a.DistanceToNextWithInaccuracy) / distanceCount; float blockLimit = GetLimitForAxisesBlock(roadType, blockType, blockIsDouble, blockIsPnevmo, averageDistance); if (blockWeight <= blockLimit && maxAxisWeight <= singleAxisLimit) { Array.ForEach(axises, a => a.LoadLimit = 0); Array.ForEach(axises, a => a.Damage = 0); } else { float axisLimit = blockLimit / axises.Length; Array.ForEach(axises, a => a.LoadLimit = axisLimit); Array.ForEach(axises, a => a.Damage = GetAxisDamage(road, a)); } blockInfo += $" - Нагрузка на группу осей (Фактическая/Допустимая): {blockWeight}т./{blockLimit}т.{Environment.NewLine}" + $" - Нагрузка на наиболее нагруженную ось (Фактическая/Допустимая): {maxAxisWeight}т./{singleAxisLimit}т.{Environment.NewLine}"; break; } case AxisBlockType.MoreThree: case AxisBlockType.MultiWheeled: { for (int i = 0; i < axises.Length; i++) { Axis axis = axises[i]; float dist; if (i == 0) { dist = axis.DistanceToNextWithInaccuracy; } else if (i == axises.Length - 1) { dist = axises[i - 1].DistanceToNextWithInaccuracy; } else { dist = Math.Min(axis.DistanceToNextWithInaccuracy, axises[i - 1].DistanceToNextWithInaccuracy); } axis.LoadLimit = GetLimitForAxisesBlock(roadType, blockType, axis.IsDouble, axis.IsPnevmo, dist); axis.Damage = GetAxisDamage(road, axis); } break; } default: throw new NotImplementedException(); } Array.ForEach(axises, a => a.BlockInfo = blockInfo); } }