blob: e0bff121ea3c34f15bd80df60ed5072b2906ca1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using Tango.PPC.Common.Build;
namespace Tango.PPC.UI.Converters
{
public class ProgressWeightSpoolConverter : IMultiValueConverter
{
private static IBuildProvider _buildProvider;
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
try
{
if (_buildProvider == null)
{
_buildProvider = Core.DI.TangoIOC.Default.GetInstance<IBuildProvider>();
}
if (values.Count() == 4)
{
double length = System.Convert.ToDouble(values[0]);
bool forOneSpool = System.Convert.ToBoolean(values[1]);
double coef = System.Convert.ToDouble(values[2]);
int number_of_spools = System.Convert.ToInt16(values[3]);
if (_buildProvider.MachineType == BL.Enumerations.MachineTypes.Eureka)
{
var totalBy4Spools = (double)length * number_of_spools;
var weight = ((double)totalBy4Spools * coef) / (1000);//(g)
if (forOneSpool)
{
return (double)weight / number_of_spools;
}
return weight;
}
else
{
double weight = ((double)length * coef) / (1000);//(g)
if (forOneSpool)
{
weight = ((double)length / (double)number_of_spools * coef) / (1000);//(g)
}
return weight;
}
}
if (values.Count() == 5)
{
double length = System.Convert.ToDouble(values[0]);
bool forOneSpool = System.Convert.ToBoolean(values[1]);
double currentProgresslength = System.Convert.ToDouble(values[2]);
double coef = System.Convert.ToDouble(values[3]);
int number_of_spools = System.Convert.ToInt16(values[4]);
if (_buildProvider.MachineType == BL.Enumerations.MachineTypes.Eureka)
{
var totalBy4Spools = (double)length * number_of_spools;
var currentProgressBy4Spools = (double)currentProgresslength * number_of_spools;
int coeff = (int)currentProgressBy4Spools / (int)totalBy4Spools;
var progressCurrent = (coeff == 0 || coeff == 1) ? currentProgressBy4Spools : currentProgressBy4Spools % (coeff * totalBy4Spools);//show for progress
var weight = ((double)progressCurrent * coef) / (1000);//(g)
if (forOneSpool)
{
return (double)weight / number_of_spools;
}
return weight;
}
else
{
double weight = 0;
if (forOneSpool)
{
double lengthPerSpool = length / number_of_spools;
// Get the current spool
int currentSpool = (int)(Math.Floor(currentProgresslength / lengthPerSpool)) + 1;
// Calculate progress on the current spool
double spoolProgress = currentProgresslength % lengthPerSpool;
if (currentSpool > number_of_spools)
{
currentSpool = number_of_spools;
spoolProgress = lengthPerSpool;
}
weight = ((double)spoolProgress * coef) / (1000);//(g)
}
else
{
weight = ((double)currentProgresslength * coef) / (1000);//(g)
}
return weight;
}
}
return "-";
}
catch
{
return "-";
}
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
|