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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using FLY.Weight.Common;
using System.Collections.ObjectModel;
namespace FLY.Weight.UI.Client.UnitTests
{
public class WeighterCsService
{
/// <summary>
/// 称重其它附件
/// </summary>
public WeighterAccessory Accessory { get; } = new WeighterAccessory();
/// <summary>
/// 各层称重
/// </summary>
public ObservableCollection<WeighterC> Items { get; } = new ObservableCollection<WeighterC>();
}
public class UnitTests_Weights : WeighterCsService
{
public UnitTests_Weights()
{
Random random = new Random();
Items.Add(new FLY.Weight.Common.WeighterC("A", 0, 6)
{
CurrentFlow = 150,
FlowSetting = 140,
CumulativeProduction = 1000,
BinWeight = 15,
MixBucketWeight = 4
});
Items.Add(new FLY.Weight.Common.WeighterC("B", 1, 2)
{
CurrentFlow = 100,
FlowSetting = 100,
CumulativeProduction = 1200,
BinWeight = 10,
MixBucketWeight = 4
});
Items.Add(new FLY.Weight.Common.WeighterC("C", 2, 0)
{
CurrentFlow = 50,
FlowSetting = 50,
CumulativeProduction = 500,
BinWeight = 5,
MixBucketWeight = 4
});
Items.Add(new FLY.Weight.Common.WeighterC("D", 3, 2)
{
CurrentFlow = 10,
CumulativeProduction = 200,
BinWeight = 1,
MixBucketWeight = 4
});
Items.Add(new FLY.Weight.Common.WeighterC("E", 4, 6)
{
CurrentFlow = 10,
CumulativeProduction = 100,
BinWeight = 1,
MixBucketWeight = 4
});
//Items.Add(new FLY.Weight.Common.WeighterC("F", 5, 2)
//{
// CurrentFlow = 10,
// CumulativeProduction = 200,
// BinWeight = 1,
// MixBucketWeight = 4
//});
//Items.Add(new FLY.Weight.Common.WeighterC("G", 6, 6)
//{
// CurrentFlow = 10,
// CumulativeProduction = 100,
// BinWeight = 1,
// MixBucketWeight = 4
//});
foreach (FLY.Weight.Common.WeighterC w in Items) {
w.Color = WeighterColorDB.GetSelf(w.Index);
}
Accessory.TotalFlow = (UInt16)Items.Sum((w) => { return w.CurrentFlow; });
Accessory.TotalProduction = (UInt16)Items.Sum((w) => { return w.CumulativeProduction; });
Accessory.TotalFlowSetting = Accessory.TotalFlow;
foreach (FLY.Weight.Common.WeighterC w in Items) {
w.ScrewPDisp = (UInt16)(w.CurrentFlow * 100 / Accessory.TotalFlow);
w.ScrewPSet = w.ScrewPDisp;
}
Accessory.WheelPerimeter = 378;
Accessory.WheelPulse = 3000;
Accessory.Density = 1;
Accessory.RimCharge = 30;
Accessory.Thickness = 80;
Accessory.CurrentVelocity = 50.3f;
Accessory.TotalFilmWidth = 2134;
Accessory.RimWidth = 20;
Accessory.ActFilmWidth = Accessory.TotalFilmWidth - Accessory.RimWidth * 2;
Accessory.SetThickness = 79;
Accessory.TargetVelocity = 50.1f;
Accessory.ACurrentLen = 200;
Accessory.ACurrent = 200;
Accessory.ALast = 230;
Accessory.BCurrentLen = 300;
Accessory.BLast = 290;
//Ingredients
foreach (WeighterC w in Items)
{
if (w.IsSingle)
continue;
for (int i = 0; i < w.Ingredients.Count(); i++)
{
w.Ingredients[i].Color = WeighterColorDB.GetItem(w.Index, i);
w.Ingredients[i].MixDisp = 0.3f * (i + 1);
w.Ingredients[i].MixSet = 0.3f * (i + 1);
w.Ingredients[i].MixCum = (float)(10 * Math.Pow(i + 1, 2));
}
float t_mixdisp = w.Ingredients.Sum(i => i.MixDisp);
float t_mixset = w.Ingredients.Sum(i => i.MixSet);
float t_mixcum = w.Ingredients.Sum(i => i.MixCum);
for (int i = 0; i < w.Ingredients.Count(); i++)
{
w.Ingredients[i].MixPDisp = 100.0f * w.Ingredients[i].MixDisp / t_mixdisp;
w.Ingredients[i].MixPSet = 100.0f * w.Ingredients[i].MixSet / t_mixset;
w.Ingredients[i].MixCumPercent = 100.0f * w.Ingredients[i].MixCum / t_mixcum;
w.Ingredients[i].FeedingDeviation = 0.3f * (i + 1);
w.Ingredients[i].FeedSet = 0.3f * (i + 1);
w.Ingredients[i].InitTime = 0;
w.Ingredients[i].MinTime = 10;
w.Ingredients[i].StableTime = 20;
}
w.Ingredients[random.Next(w.Ingredients.Count() - 1)].MixLight = true;
}
}
}
}