You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
3.3 KiB
C#
139 lines
3.3 KiB
C#
using DevExpress.Data.Filtering.Helpers;
|
|
using DevExpress.Utils.FormShadow;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Action.ChemicalWeighing.LjDeliver.Entity;
|
|
using Mesnac.Controls.ChemicalWeighing;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjDeliver
|
|
{
|
|
public class DeliverInitAction : ChemicalWeighingAction, IAction
|
|
{
|
|
List<Control> Controls;
|
|
|
|
HslBottleEntity bottleE = new HslBottleEntity();
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
base.RunIni(runtime); //必须调用
|
|
|
|
Controls = GetAllControls();
|
|
|
|
ControlsHelper.ControlImport<HslBottle>(bottleE, Controls);
|
|
|
|
//wangsr();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//测试程序
|
|
private void wangsr()
|
|
{
|
|
Random rd = new Random();
|
|
|
|
bool[] bottleFlag = new bool[15];
|
|
|
|
for (int i = 0; i < bottleFlag.Length; i++)
|
|
{
|
|
bottleFlag[i] = Convert.ToBoolean(rd.Next(0, 2));
|
|
}
|
|
|
|
Type bottleType = bottleE.GetType();
|
|
PropertyInfo[] properties = bottleType.GetProperties();
|
|
|
|
ThreadStart threadStart = new ThreadStart(() =>
|
|
{
|
|
double n = 100 / 15;
|
|
|
|
int i = 0;
|
|
|
|
foreach (PropertyInfo sourceProperty in properties)
|
|
{
|
|
string name = sourceProperty.Name;
|
|
PropertyInfo property = bottleType.GetProperty(name);
|
|
HslBottle bottle = (HslBottle)property.GetValue(bottleE);
|
|
//bottle.Value = n * i++;
|
|
bottle.Value = rd.Next(100);
|
|
property.SetValue(bottleE, bottle);
|
|
}
|
|
|
|
int num;
|
|
var obj = Application.OpenForms["LjDeliver"];
|
|
while (obj != null)
|
|
{
|
|
num = 0;
|
|
|
|
foreach (PropertyInfo sourceProperty in properties)
|
|
{
|
|
string name = sourceProperty.Name;
|
|
PropertyInfo property = bottleType.GetProperty(name);
|
|
HslBottle bottle = (HslBottle)property.GetValue(bottleE);
|
|
|
|
if (bottle.Value <= 0.2)
|
|
{
|
|
bottleFlag[num] = true;
|
|
}
|
|
if (bottle.Value >= 99.8)
|
|
{
|
|
bottleFlag[num] = false;
|
|
}
|
|
|
|
if (bottleFlag[num])
|
|
{
|
|
bottle.Value += 0.2;
|
|
}
|
|
else
|
|
{
|
|
bottle.Value -= 0.2;
|
|
}
|
|
|
|
property.SetValue(bottleE, bottle);
|
|
|
|
num++;
|
|
}
|
|
Thread.Sleep(1);
|
|
|
|
obj = Application.OpenForms["LjDeliver"];
|
|
}
|
|
});
|
|
Thread thread = new Thread(threadStart);
|
|
thread.Start();
|
|
}
|
|
}
|
|
}
|