Files
TestApp/Pages/Index.cshtml.cs
2025-07-09 16:15:14 +04:00

161 lines
6.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Microsoft.AspNetCore.Mvc.RazorPages;
public class IndexModel : PageModel
{
public double D { get; private set; }
public double dd { get; private set; }
public double H { get; private set; }
public double x { get; private set; }
public double y { get; private set; }
public double z { get; private set; }
public double Q { get; private set; }
public double onTO { get; private set; }
public double h1 { get; private set; }
public double h2 { get; private set; }
public void OnPost(double D, double dd, double H, double x, double y, double z, double Q, double onTO)
{
h1 = H * x + (y * z) + onTO;
h2 = H * x + (y * z) + Q + onTO;
#region Расчет размеров поковки
// H заготовки = (Н1+б)+-∆/2
// Размер
double H_Billet = h1 + SearchLimit(D, h1).Item1;
// Допуск на размер +-
int limit1 = SearchLimit(D, h1).Item2;
// H заготовки с пробой = (Н2+б)+-∆/2
double H_BilletWithBlank = h2 + SearchLimit(D, h2).Item1;
// Допуск на размер +-
int limit2 = SearchLimit(D, h2).Item2;
// D дет = D+напуск на ТО
double D_Detail = D + onTO;
// D заг = (D+б)+-∆/2+напуск на ТО
double D_Billet = D_Detail + SearchLimit(D, h1).Item1 + onTO;
int limit3 = SearchLimit(D, h1).Item2;
// D заг с пробой= (D+б)+-∆/2+напуск на ТО
double D_BilletWithBlank = D_Detail + SearchLimit(D, h2).Item1 + onTO;
int limit4 = SearchLimit(D, h2).Item2;
// d дет=d-напуск на ТО
double d_Detail = dd + onTO;
// d заг =(dдет-б)+-3б
double d_Billet = d_Detail - SearchLimit(D, h1).Item1;
int limit5 = SearchLimit(D, h1).Item2 * 3;
//d заг с пробой =(dдет-б)+-3б
double d_BilletWithBlank = d_Detail - SearchLimit(D, h2).Item1;
int limit6 = SearchLimit(D, h2).Item2 * 3;
#endregion
#region Расчет массы поковки без пробы
// Диск номинал
double D_calc =
#endregion
#region Расчет массы поковки c пробой
#endregion
}
private (int, int) SearchLimit(double D, double H)
{
// Диапазоны высоты H
double[] heightRanges = new double[]
{
100, 150, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1400, 1600, 1800, 2000, 2250, 2500
};
// Диапазоны диаметра D
double[] diameterRanges = new double[]
{
499, 500, 630, 800, 1000, 1250, 1400, 1600, 1800, 2000, 2250, 2500, 2800, 3150, 3500, 4000, 4500, 5000
};
(int, int)[,] limits = new (int, int)[,]
{
// Св. 100 до 150 включ.
{ (24,9), (25,9), (27,10), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1) },
// Св. 150 до 200
{ (24,9), (25,9), (27,10), (29,11), (31,11), (35,13), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1) },
// Св. 200 до 250
{ (25,9), (26,9), (28,10), (30,11), (32,12), (36,13), (38,14), (40,15), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1) },
// Св. 250 до 315
{ (27,10), (28,10), (30,11), (32,12), (34,13), (38,14), (41,15), (44,16), (47,18), (51,19), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1) },
// Св. 315 до 400
{ (28,10), (29,11), (31,11), (33,12), (35,13), (40,15), (42,16), (46,17), (49,19), (53,20), (57,21), (61,23), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1) },
// Св. 400 до 500
{ (29,11), (30,11), (31,11), (34,13), (36,13), (41,15), (44,16), (48,18), (51,19), (55,21), (59,22), (63,24), (67,25), (71,27), (-1,-1), (-1,-1), (-1,-1) },
// Св. 500 до 630
{ (30,11), (31,11), (33,12), (35,13), (37,14), (43,16), (46,17), (50,19), (53,20), (57,21), (61,23), (65,25), (69,26), (75,28), (80,30), (95,37), (-1,-1) },
// Св. 630 до 800
{ (-1,-1), (33,12), (36,13), (38,14), (41,15), (46,17), (50,19), (54,20), (57,21), (61,23), (65,25), (71,27), (77,29), (83,31), (89,34), (98,39), (105,43) },
// Св. 800 до 1000
{ (-1,-1), (-1,-1), (37,14), (40,15), (43,16), (48,18), (52,20), (56,21), (59,22), (63,24), (68,26), (74,28), (80,30), (86,33), (92,36), (101,41), (108,46) },
// Св. 1000 до 1250
{ (-1,-1), (-1,-1), (-1,-1), (44,16), (46,17), (52,20), (56,21), (60,23), (64,24), (68,26), (74,28), (81,30), (86,33), (92,36), (98,39), (105,43), (112,48) },
// Св. 1250 до 1400
{ (-1,-1), (-1,-1), (-1,-1), (-1,-1), (47,18), (54,20), (58,22), (62,23), (67,25), (72,27), (78,29), (83,31), (89,34), (95,37), (101,41), (108,45), (115,50) },
// Св. 1400 до 1600
{ (-1,-1), (-1,-1), (-1,-1), (-1,-1), (48,18), (56,21), (60,23), (65,24), (69,26), (75,28), (81,30), (87,34), (93,36), (99,39), (104,42), (110,47), (119,51) },
// Св. 1600 до 1800
{ (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (58,22), (63,23), (67,25), (73,27), (79,29), (85,33), (91,35), (97,38), (102,41), (106,43), (113,48), (120,52) },
// Св. 1800 до 2000
{ (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (64,23), (68,25), (75,28), (81,30), (87,34), (92,36), (98,38), (103,41), (107,43), (115,50), (121,52) },
// Св. 2000 до 2250
{ (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (69,26), (76,28), (82,30), (88,34), (94,37), (100,40), (104,42), (110,47), (116,50), (122,52) },
// Св. 2250 до 2500
{ (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (-1,-1), (82,30), (85,32), (91,35), (97,38), (100,41), (108,43), (114,49), (119,51), (125,53) }
};
int FindIndex(double val, double[] ranges)
{
for (int i = 0; i < ranges.Length; i++)
{
if (val <= ranges[i])
return i - 1;
}
return -1;
}
int hIndex = FindIndex(H, heightRanges);
int dIndex = FindIndex(D, diameterRanges);
if (D < 499)
dIndex = 0;
if (hIndex == -1 || dIndex == -1)
return (-1, -1);
return limits[hIndex, dIndex];
}
}