Вроде закончил

This commit is contained in:
2025-07-10 01:07:28 +04:00
parent 4a10e465a8
commit 16718ba551
10 changed files with 590 additions and 341 deletions

View File

@@ -6,8 +6,24 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<title>Модель расчета поковок кольцо раскатное</title>
</head>
<style>
table {
margin: auto;
border-collapse: collapse;
width: 50%;
}
th, td, form, h2 {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
vertical-align: middle;
}
th {
background-color: #f2f2f2;
}
</style>
<body>
</body>
@@ -48,61 +64,5 @@
<label>Напуск на ТО:</label><br />
<input type="text" oninput="validateDecimal(this)" step="any" name="onTO" value="0"/>
</p>
<input type="submit" value="Отправить" />
<input type="submit" value="Расчет" />
</form>
@if (Model.hasResult)
{
<table border="1">
<caption>
<h2>Расчет размеров поковки</h2>
</caption>
<thead>
<tr>
<th> - </th>
<th>Размер</th>
<th>Допуск на размер +-</th>
</tr>
</thead>
<tr>
<td>H заготовки = (Н1+б)+-∆/2</td>
<td>@Model.H_Billet</td>
<td>@Model.limit1</td>
</tr>
<tr>
<td>H заготовки с пробой = (Н2+б)+-∆/2</td>
<td>@Model.H_BilletWithBlank</td>
<td>@Model.limit2</td>
</tr>
<tr>
<td>D дет = D+напуск на ТО</td>
<td>@Model.D_Detail</td>
<td> - </td>
</tr>
<tr>
<td>D заг = (D+б)+-∆/2+напуск на ТО</td>
<td>@Model.D_Billet</td>
<td>@Model.limit3</td>
</tr>
<tr>
<td>D заг с пробой= (D+б)+-∆/2+напуск на ТО</td>
<td>@Model.D_BilletWithBlank</td>
<td>@Model.limit4</td>
</tr>
<tr>
<td>d дет=d-напуск на ТО</td>
<td>@Model.d_Detail</td>
<td> - </td>
</tr>
<tr>
<td>d заг =(dдет-б)+-3б</td>
<td>@Model.d_Billet</td>
<td>@Model.limit5</td>
</tr>
<tr>
<td>d заг с пробой =(dдет-б)+-3б</td>
<td>@Model.d_BilletWithBlank</td>
<td>@Model.limit6</td>
</tr>
</table>
}

View File

@@ -1,289 +1,30 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc;
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 D { get; set; }
public double dd { get; set; }
public double H { get; set; }
public double x { get; set; }
public double y { get; set; }
public double z { get; set; }
public double Q { get; set; }
public double onTO { get; set; }
public double H_Billet { get; private set; }
public int limit1 { get; private set; }
public double H_BilletWithBlank { get; private set; }
public int limit2 { get; private set; }
public double D_Detail { get; private set; }
public double D_Billet { get; private set; }
public int limit3 { get; private set; }
public double D_BilletWithBlank { get; private set; }
public int limit4 { get; private set; }
public double d_Detail { get; private set; }
public double d_Billet { get; private set; }
public int limit5 { get; private set; }
public double d_BilletWithBlank { get; private set; }
public int limit6 { get; private set; }
public double D_nom_1 { get; private set; }
public double r_nom_1 { get; private set; }
public double H_nom_1 { get; private set; }
public double V_nom_1 { get; private set; }
public double mDisk_nom_1 { get; private set; }
public double D_max_1 { get; private set; }
public double r_max_1 { get; private set; }
public double H_max_1 { get; private set; }
public double V_max_1 { get; private set; }
public double mDisk_max_1 { get; private set; }
public double D_O_nom_1 { get; private set; }
public double r_O_nom_1 { get; private set; }
public double H_O_nom_1 { get; private set; }
public double V_O_nom_1 { get; private set; }
public double mDisk_O_nom_1 { get; private set; }
public double D_O_max_1 { get; private set; }
public double r_O_max_1 { get; private set; }
public double H_O_max_1 { get; private set; }
public double V_O_max_1 { get; private set; }
public double mDisk_O_max_1 { get; private set; }
public double mDisk_nom_1_O { get; private set; }
public double mDisk_max_1_O { get; private set; }
public double D_nom_2 { get; private set; }
public double r_nom_2 { get; private set; }
public double H_nom_2 { get; private set; }
public double V_nom_2 { get; private set; }
public double mDisk_nom_2 { get; private set; }
public double D_max_2 { get; private set; }
public double r_max_2 { get; private set; }
public double H_max_2 { get; private set; }
public double V_max_2 { get; private set; }
public double mDisk_max_2 { get; private set; }
public double D_O_nom_2 { get; private set; }
public double r_O_nom_2 { get; private set; }
public double H_O_nom_2 { get; private set; }
public double V_O_nom_2 { get; private set; }
public double mDisk_O_nom_2 { get; private set; }
public double D_O_max_2 { get; private set; }
public double r_O_max_2 { get; private set; }
public double H_O_max_2 { get; private set; }
public double V_O_max_2 { get; private set; }
public double mDisk_O_max_2 { get; private set; }
public double mDisk_nom_2_O { get; private set; }
public double mDisk_max_2_O { get; private set; }
public bool hasResult { get; private set; } = false;
public void OnPost(double D, double dd, double H, double x, double y, double z, double Q, double onTO)
public IActionResult OnPost(double D, double dd, double H, double x, double y, double z, double Q, double onTO)
{
double h1 = H * x + (y * z) + onTO;
double h2 = H * x + (y * z) + Q + onTO;
#region Расчет размеров поковки
// H заготовки = (Н1+б)+-∆/2
// Размер
H_Billet = h1 + SearchLimit(D, h1).Item1;
// Допуск на размер +-
limit1 = SearchLimit(D, h1).Item2;
// H заготовки с пробой = (Н2+б)+-∆/2
H_BilletWithBlank = h2 + SearchLimit(D, h2).Item1;
// Допуск на размер +-
limit2 = SearchLimit(D, h2).Item2;
// D дет = D+напуск на ТО
D_Detail = D + onTO;
// D заг = (D+б)+-∆/2+напуск на ТО
D_Billet = D_Detail + SearchLimit(D, h1).Item1 + onTO;
limit3 = SearchLimit(D, h1).Item2;
// D заг с пробой= (D+б)+-∆/2+напуск на ТО
D_BilletWithBlank = D_Detail + SearchLimit(D, h2).Item1 + onTO;
limit4 = SearchLimit(D, h2).Item2;
// d дет=d-напуск на ТО
d_Detail = dd + onTO;
// d заг =(dдет-б)+-3б
d_Billet = d_Detail - SearchLimit(D, h1).Item1;
limit5 = SearchLimit(D, h1).Item2 * 3;
//d заг с пробой =(dдет-б)+-3б
d_BilletWithBlank = d_Detail - SearchLimit(D, h2).Item1;
limit6 = SearchLimit(D, h2).Item2 * 3;
#endregion
#region Расчет массы поковки без пробы
// Диск номинал
D_nom_1 = D_Billet;
r_nom_1 = D_nom_1 / 2;
H_nom_1 = H_Billet;
V_nom_1 = 3.14 * (r_nom_1 * r_nom_1) * H_nom_1;
mDisk_nom_1 = Math.Round(V_nom_1 * 0.78 / 100000000, 3);
// Диск максимал
D_max_1 = D_Billet + limit3;
r_max_1 = D_max_1 / 2;
H_max_1 = H_Billet + limit1;
V_max_1 = 3.14 * (r_max_1 * r_max_1) * H_max_1;
mDisk_max_1 = Math.Round(V_max_1 * 0.78 / 100000000, 3);
// Отверстие номинал
D_O_nom_1 = d_Billet;
r_O_nom_1 = d_Billet / 2;
H_O_nom_1 = H_Billet;
V_O_nom_1 = 3.14 * (r_O_nom_1 * r_O_nom_1) * H_O_nom_1;
mDisk_O_nom_1 = Math.Round(V_O_nom_1 * 0.78 / 100000000, 3);
// Отверстие максимал
D_O_max_1 = d_Billet - limit5;
r_O_max_1 = D_O_max_1 / 2;
H_O_max_1 = H_Billet + limit1;
V_O_max_1 = 3.14 * (r_O_max_1 * r_O_max_1) * H_O_max_1;
mDisk_O_max_1 = Math.Round(V_O_max_1 * 0.78 / 100000000, 3);
// m диск с отв
mDisk_nom_1_O = mDisk_nom_1 - mDisk_O_nom_1;
mDisk_max_1_O = mDisk_max_1 - mDisk_O_max_1;
#endregion
#region Расчет массы поковки c пробой
// Диск номинал
D_nom_2 = D_BilletWithBlank;
r_nom_2 = D_nom_2 / 2;
H_nom_2 = H_BilletWithBlank;
V_nom_2 = 3.14 * (r_nom_2 * r_nom_2) * H_nom_2;
mDisk_nom_2 = Math.Round(V_nom_2 * 0.78 / 100000000, 3);
// Диск максимал
D_max_2 = D_BilletWithBlank + limit4;
r_max_2 = D_max_2 / 2;
H_max_2 = H_BilletWithBlank + limit2;
V_max_2 = 3.14 * (r_max_2 * r_max_2) * H_max_2;
mDisk_max_2 = Math.Round(V_max_2 * 0.78 / 100000000, 3);
// Отверстие номинал
D_O_nom_2 = d_BilletWithBlank;
r_O_nom_2 = D_O_nom_2 / 2;
H_O_nom_2 = H_BilletWithBlank;
V_O_nom_2 = 3.14 * (r_O_nom_2 * r_O_nom_2) * H_O_nom_2;
mDisk_O_nom_2 = Math.Round(V_O_nom_2 * 0.78 / 100000000, 3);
// Отверстие максимал
D_O_max_2 = d_BilletWithBlank - limit6;
r_O_max_2 = D_O_max_2 / 2;
H_O_max_2 = H_BilletWithBlank + limit2;
V_O_max_2 = 3.14 * (r_O_max_2 * r_O_max_2) * H_O_max_2;
mDisk_O_max_2 = Math.Round(V_O_max_2 * 0.78 / 100000000, 3);
// m диск с отв
mDisk_nom_2_O = mDisk_nom_2 - mDisk_O_nom_2;
mDisk_max_2_O = mDisk_max_2 - mDisk_O_max_2;
#endregion
hasResult = true;
}
private (int, int) SearchLimit(double D, double H)
return RedirectToPage("Results", new
{
// Диапазоны высоты 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];
_D = D,
_dd = dd,
_H = H,
_x = x,
_y = y,
_z = z,
_Q = Q,
_onTO = onTO
});
}
}

201
Pages/Results.cshtml Normal file
View File

@@ -0,0 +1,201 @@
@page
@model ResultsModel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Модель расчета поковок кольцо раскатное</title>
</head>
<style>
.aligncenter {
text-align: center;
}
table {
margin: auto;
border-collapse: collapse;
width: 50%;
}
th,
td,
form,
h2,
h3,
img {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
vertical-align: middle;
}
th {
background-color: #f2f2f2;
}
</style>
<body>
<table border="1">
<caption>
<h2>Расчет размеров поковки</h2>
</caption>
<thead>
<tr>
<th> - </th>
<th>Размер</th>
<th>Допуск на размер +-</th>
</tr>
</thead>
<tr>
<td>H заготовки = (Н1+б)+-∆/2</td>
<td>@Model.H_Billet</td>
<td>@Model.limit1</td>
</tr>
<tr>
<td>H заготовки с пробой = (Н2+б)+-∆/2</td>
<td>@Model.H_BilletWithBlank</td>
<td>@Model.limit2</td>
</tr>
<tr>
<td>D дет = D+напуск на ТО</td>
<td>@Model.D_Detail</td>
<td> - </td>
</tr>
<tr>
<td>D заг = (D+б)+-∆/2+напуск на ТО</td>
<td>@Model.D_Billet</td>
<td>@Model.limit3</td>
</tr>
<tr>
<td>D заг с пробой= (D+б)+-∆/2+напуск на ТО</td>
<td>@Model.D_BilletWithBlank</td>
<td>@Model.limit4</td>
</tr>
<tr>
<td>d дет=d-напуск на ТО</td>
<td>@Model.d_Detail</td>
<td> - </td>
</tr>
<tr>
<td>d заг =(dдет-б)+-3б</td>
<td>@Model.d_Billet</td>
<td>@Model.limit5</td>
</tr>
<tr>
<td>d заг с пробой =(dдет-б)+-3б</td>
<td>@Model.d_BilletWithBlank</td>
<td>@Model.limit6</td>
</tr>
</table>
<br>
<table border="1">
<h2>Расчет массы поковки без пробы</h2>
</caption>
<thead>
<tr>
<th> - </th>
<th>D</th>
<th>r</th>
<th>H</th>
<th>V</th>
<th>m диск</th>
<th>m диск с отв.</th>
</tr>
<tr>
<td>Диск номинал</td>
<td>@Model.D_nom_1</td>
<td>@Model.r_nom_1</td>
<td>@Model.H_nom_1</td>
<td>@Model.V_nom_1</td>
<td>@Model.mDisk_nom_1</td>
<td>@Model.mDisk_nom_1_O</td>
</tr>
<td>Диск максимал</td>
<td>@Model.D_max_1</td>
<td>@Model.r_max_1</td>
<td>@Model.H_max_1</td>
<td>@Model.V_max_1</td>
<td>@Model.mDisk_max_1</td>
<td>@Model.mDisk_max_1_O</td>
</tr>
<td>Отверстие номинал</td>
<td>@Model.D_O_nom_1</td>
<td>@Model.r_O_nom_1</td>
<td>@Model.H_O_nom_1</td>
<td>@Model.V_O_nom_1</td>
<td>@Model.mDisk_O_nom_1</td>
<td> - </td>
</tr>
<td>Отверстие максимал</td>
<td>@Model.D_O_max_1</td>
<td>@Model.r_O_max_1</td>
<td>@Model.H_O_max_1</td>
<td>@Model.V_O_max_1</td>
<td>@Model.mDisk_O_max_1</td>
<td> - </td>
</tr>
</thead>
</table>
<br>
<table border="1">
<h2>Расчет массы поковки с пробой</h2>
</caption>
<thead>
<tr>
<th> - </th>
<th>D</th>
<th>r</th>
<th>H</th>
<th>V</th>
<th>m диск</th>
<th>m диск с отв.</th>
</tr>
<tr>
<td>Диск номинал</td>
<td>@Model.D_nom_2</td>
<td>@Model.r_nom_2</td>
<td>@Model.H_nom_2</td>
<td>@Model.V_nom_2</td>
<td>@Model.mDisk_nom_2</td>
<td>@Model.mDisk_nom_2_O</td>
</tr>
<td>Диск максимал</td>
<td>@Model.D_max_2</td>
<td>@Model.r_max_2</td>
<td>@Model.H_max_2</td>
<td>@Model.V_max_2</td>
<td>@Model.mDisk_max_2</td>
<td>@Model.mDisk_max_2_O</td>
</tr>
<td>Отверстие номинал</td>
<td>@Model.D_O_nom_2</td>
<td>@Model.r_O_nom_2</td>
<td>@Model.H_O_nom_2</td>
<td>@Model.V_O_nom_2</td>
<td>@Model.mDisk_O_nom_2</td>
<td> - </td>
</tr>
<td>Отверстие максимал</td>
<td>@Model.D_O_max_2</td>
<td>@Model.r_O_max_2</td>
<td>@Model.H_O_max_2</td>
<td>@Model.V_O_max_2</td>
<td>@Model.mDisk_O_max_2</td>
<td> - </td>
</tr>
</thead>
</table>
<br>
<h3>Результат без пробы</h3>
<p class="aligncenter"><img src="/images/Result_WithoutBlank.png" alt="Результат без пробы"></p>
<br>
<h3>Результат с пробой</h3>
<p class="aligncenter"><img src="/images/Result_WithBlank.png" alt="Результат с пробой"></p>
</body>
</html>

339
Pages/Results.cshtml.cs Normal file
View File

@@ -0,0 +1,339 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.IO;
public class ResultsModel : PageModel
{
public double _D { get; set; }
public double _dd { get; set; }
public double _H { get; set; }
public double _x { get; set; }
public double _y { get; set; }
public double _z { get; set; }
public double _Q { get; set; }
public double _onTO { get; set; }
public double H_Billet { get; private set; }
public int limit1 { get; private set; }
public double H_BilletWithBlank { get; private set; }
public int limit2 { get; private set; }
public double D_Detail { get; private set; }
public double D_Billet { get; private set; }
public int limit3 { get; private set; }
public double D_BilletWithBlank { get; private set; }
public int limit4 { get; private set; }
public double d_Detail { get; private set; }
public double d_Billet { get; private set; }
public int limit5 { get; private set; }
public double d_BilletWithBlank { get; private set; }
public int limit6 { get; private set; }
public double D_nom_1 { get; private set; }
public double r_nom_1 { get; private set; }
public double H_nom_1 { get; private set; }
public double V_nom_1 { get; private set; }
public double mDisk_nom_1 { get; private set; }
public double D_max_1 { get; private set; }
public double r_max_1 { get; private set; }
public double H_max_1 { get; private set; }
public double V_max_1 { get; private set; }
public double mDisk_max_1 { get; private set; }
public double D_O_nom_1 { get; private set; }
public double r_O_nom_1 { get; private set; }
public double H_O_nom_1 { get; private set; }
public double V_O_nom_1 { get; private set; }
public double mDisk_O_nom_1 { get; private set; }
public double D_O_max_1 { get; private set; }
public double r_O_max_1 { get; private set; }
public double H_O_max_1 { get; private set; }
public double V_O_max_1 { get; private set; }
public double mDisk_O_max_1 { get; private set; }
public double mDisk_nom_1_O { get; private set; }
public double mDisk_max_1_O { get; private set; }
public double D_nom_2 { get; private set; }
public double r_nom_2 { get; private set; }
public double H_nom_2 { get; private set; }
public double V_nom_2 { get; private set; }
public double mDisk_nom_2 { get; private set; }
public double D_max_2 { get; private set; }
public double r_max_2 { get; private set; }
public double H_max_2 { get; private set; }
public double V_max_2 { get; private set; }
public double mDisk_max_2 { get; private set; }
public double D_O_nom_2 { get; private set; }
public double r_O_nom_2 { get; private set; }
public double H_O_nom_2 { get; private set; }
public double V_O_nom_2 { get; private set; }
public double mDisk_O_nom_2 { get; private set; }
public double D_O_max_2 { get; private set; }
public double r_O_max_2 { get; private set; }
public double H_O_max_2 { get; private set; }
public double V_O_max_2 { get; private set; }
public double mDisk_O_max_2 { get; private set; }
public double mDisk_nom_2_O { get; private set; }
public double mDisk_max_2_O { get; private set; }
public string? ResultImagePath { get; set; }
public void OnGet(double _D, double _dd, double _H, double _x, double _y, double _z, double _Q, double _onTO)
{
double h1 = _H * _x + (_y * _z) + _onTO;
double h2 = _H * _x + (_y * _z) + _Q + _onTO;
#region Расчет размеров поковки
// H заготовки = (Н1+б)+-∆/2
// Размер
H_Billet = h1 + SearchLimit(_D, h1).Item1;
// Допуск на размер +-
limit1 = SearchLimit(_D, h1).Item2;
// H заготовки с пробой = (Н2+б)+-∆/2
H_BilletWithBlank = h2 + SearchLimit(_D, h2).Item1;
// Допуск на размер +-
limit2 = SearchLimit(_D, h2).Item2;
// D дет = D+напуск на ТО
D_Detail = _D + _onTO;
// D заг = (D+б)+-∆/2+напуск на ТО
D_Billet = D_Detail + SearchLimit(_D, h1).Item1 + _onTO;
limit3 = SearchLimit(_D, h1).Item2;
// D заг с пробой= (D+б)+-∆/2+напуск на ТО
D_BilletWithBlank = D_Detail + SearchLimit(_D, h2).Item1 + _onTO;
limit4 = SearchLimit(_D, h2).Item2;
// d дет=d-напуск на ТО
d_Detail = _dd + _onTO;
// d заг =(dдет-б)+-3б
d_Billet = d_Detail - SearchLimit(_D, h1).Item1;
limit5 = SearchLimit(_D, h1).Item2 * 3;
//d заг с пробой =(dдет-б)+-3б
d_BilletWithBlank = d_Detail - SearchLimit(_D, h2).Item1;
limit6 = SearchLimit(_D, h2).Item2 * 3;
#endregion
#region Расчет массы поковки без пробы
// Диск номинал
D_nom_1 = D_Billet;
r_nom_1 = D_nom_1 / 2;
H_nom_1 = H_Billet;
V_nom_1 = 3.14 * (r_nom_1 * r_nom_1) * H_nom_1;
mDisk_nom_1 = Math.Round(V_nom_1 * 0.78 / 100000000, 3);
// Диск максимал
D_max_1 = D_Billet + limit3;
r_max_1 = D_max_1 / 2;
H_max_1 = H_Billet + limit1;
V_max_1 = 3.14 * (r_max_1 * r_max_1) * H_max_1;
mDisk_max_1 = Math.Round(V_max_1 * 0.78 / 100000000, 3);
// Отверстие номинал
D_O_nom_1 = d_Billet;
r_O_nom_1 = d_Billet / 2;
H_O_nom_1 = H_Billet;
V_O_nom_1 = 3.14 * (r_O_nom_1 * r_O_nom_1) * H_O_nom_1;
mDisk_O_nom_1 = Math.Round(V_O_nom_1 * 0.78 / 100000000, 3);
// Отверстие максимал
D_O_max_1 = d_Billet - limit5;
r_O_max_1 = D_O_max_1 / 2;
H_O_max_1 = H_Billet + limit1;
V_O_max_1 = 3.14 * (r_O_max_1 * r_O_max_1) * H_O_max_1;
mDisk_O_max_1 = Math.Round(V_O_max_1 * 0.78 / 100000000, 3);
// m диск с отв
mDisk_nom_1_O = mDisk_nom_1 - mDisk_O_nom_1;
mDisk_max_1_O = mDisk_max_1 - mDisk_O_max_1;
#endregion
#region Расчет массы поковки c пробой
// Диск номинал
D_nom_2 = D_BilletWithBlank;
r_nom_2 = D_nom_2 / 2;
H_nom_2 = H_BilletWithBlank;
V_nom_2 = 3.14 * (r_nom_2 * r_nom_2) * H_nom_2;
mDisk_nom_2 = Math.Round(V_nom_2 * 0.78 / 100000000, 3);
// Диск максимал
D_max_2 = D_BilletWithBlank + limit4;
r_max_2 = D_max_2 / 2;
H_max_2 = H_BilletWithBlank + limit2;
V_max_2 = 3.14 * (r_max_2 * r_max_2) * H_max_2;
mDisk_max_2 = Math.Round(V_max_2 * 0.78 / 100000000, 3);
// Отверстие номинал
D_O_nom_2 = d_BilletWithBlank;
r_O_nom_2 = D_O_nom_2 / 2;
H_O_nom_2 = H_BilletWithBlank;
V_O_nom_2 = 3.14 * (r_O_nom_2 * r_O_nom_2) * H_O_nom_2;
mDisk_O_nom_2 = Math.Round(V_O_nom_2 * 0.78 / 100000000, 3);
// Отверстие максимал
D_O_max_2 = d_BilletWithBlank - limit6;
r_O_max_2 = D_O_max_2 / 2;
H_O_max_2 = H_BilletWithBlank + limit2;
V_O_max_2 = 3.14 * (r_O_max_2 * r_O_max_2) * H_O_max_2;
mDisk_O_max_2 = Math.Round(V_O_max_2 * 0.78 / 100000000, 3);
// m диск с отв
mDisk_nom_2_O = mDisk_nom_2 - mDisk_O_nom_2;
mDisk_max_2_O = mDisk_max_2 - mDisk_O_max_2;
#endregion
ResultImage("Result_WithoutBlank", mDisk_nom_1_O, mDisk_max_1_O, _dd, d_Billet, limit5, _H, H_Billet, _D, D_Billet, limit3);
ResultImage("Result_WithBlank", mDisk_nom_2_O, mDisk_max_2_O, _dd, d_BilletWithBlank, limit6, _H, H_BilletWithBlank, _D, D_BilletWithBlank, limit4);
}
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];
}
private string ResultImage(string imageName, double weightNom, double weightMax, double d, double d_Billet,
double limit5, double H, double H_Billet, double D, double D_Billet, double limit3)
{
string templatePath = Path.Combine("wwwroot", "images", "Template.png");
string outputPath = Path.Combine("wwwroot", "images", $"{imageName}.png");
#pragma warning disable CA1416
using (var image = Image.FromFile(templatePath) as Bitmap)
{
var privateFontCollection = new PrivateFontCollection();
string fontPath = Path.Combine("wwwroot", "fonts", "MyFont.ttf");
privateFontCollection.AddFontFile(fontPath);
var fontFamily = privateFontCollection.Families[0];
var font = new Font(fontFamily, 12);
using (var graphics = Graphics.FromImage(image))
{
var brush = new SolidBrush(Color.Black);
graphics.DrawString("Выше стрелки - размеры детали,", font, brush, new PointF(30, 20));
graphics.DrawString("Ниже стрелки - размеры поковки", font, brush, new PointF(30, 35));
graphics.DrawString($"Масса номинал: {Math.Round(weightNom, 3)} тонн", font, brush, new PointF(510, 20));
graphics.DrawString($"Масса максимал: {Math.Round(weightMax, 3)} тонн", font, brush, new PointF(510, 35));
graphics.DrawString($"⌀{Math.Round(d)}", font, brush, new PointF(355, 50));
graphics.DrawString($"{Math.Round(d_Billet)} +-{limit5}", font, brush, new PointF(340, 70));
graphics.DrawString($"⌀{Math.Round(D)}", font, brush, new PointF(350, 210));
graphics.DrawString($"{Math.Round(D_Billet)} +-{limit3}", font, brush, new PointF(335, 230));
graphics.TranslateTransform(710, 155);
graphics.RotateTransform(270);
graphics.DrawString($"{Math.Round(H)}", font, brush, new PointF(0, 0));
graphics.DrawString($"{Math.Round(H_Billet)}", font, brush, new PointF(-5, 25));
}
image.Save(outputPath, ImageFormat.Png);
}
#pragma warning restore CA1416
return outputPath.Replace("wwwroot", "");
}
}

View File

@@ -7,8 +7,12 @@ builder.Services.AddRazorPages(options =>
options.Conventions.ConfigureFilter(new IgnoreAntiforgeryTokenAttribute());
});
builder.WebHost.ConfigureKestrel(serverOptions =>
{
serverOptions.ListenAnyIP(5146);
});
var app = builder.Build();
app.MapRazorPages();
app.UseStaticFiles();
app.Run();

View File

@@ -6,4 +6,8 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="9.0.7" />
</ItemGroup>
</Project>

BIN
wwwroot/fonts/MyFont.ttf Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
wwwroot/images/Template.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB