add - 自动控制准备编辑写入plc部分 准备合并

wangsr
wangsr 1 year ago
parent 72862134be
commit 2a39faf545

@ -69,14 +69,16 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
HotB.Set = hotBSet; HotB.Set = hotBSet;
ColdA.Set = coldASet; ColdA.Set = coldASet;
ColdB.Set = coldBSet; ColdB.Set = coldBSet;
HotA.TolErance = hotATol; HotA.Tolerance = hotATol;
HotB.TolErance = hotBTol; HotB.Tolerance = hotBTol;
ColdA.TolErance = coldATol; ColdA.Tolerance = coldATol;
ColdB.TolErance = coldBTol; ColdB.Tolerance = coldBTol;
Db2104WriteHelper.WriteAHostWater(HotA); Db2104WriteHelper.WriteAHostWater(HotA);
Db2104WriteHelper.WriteBHostWater(HotB); Db2104WriteHelper.WriteBHostWater(HotB);
Db2104WriteHelper.WriteAColWater(ColdA); Db2104WriteHelper.WriteAColWater(ColdA);
Db2104WriteHelper.WriteBColWater(ColdB); Db2104WriteHelper.WriteBColWater(ColdB);
MesnacServiceManager.Instance.LoggingService.Info("水称数据下发成功!");
MessageBox.Show("水称数据下发成功");
} }
else else
{ {

@ -1,8 +1,10 @@
using DataBlockHelper.Entity.DB2104Entity; using DataBlockHelper.DBHelpers;
using DataBlockHelper.Entity.DB2104Entity;
using DataBlockHelper.Entity.DB2106Entity; using DataBlockHelper.Entity.DB2106Entity;
using Mesnac.Action.Base; using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity; using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
using Mesnac.Controls.Base; using Mesnac.Controls.Base;
using Mesnac.Core.Service;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -118,7 +120,37 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
if (ControlsEntity.Download == runtime.Sender) if (ControlsEntity.Download == runtime.Sender)
{ {
WaterEntity HotA = new WaterEntity();
WaterEntity ColdA = new WaterEntity();
WaterEntity HotB = new WaterEntity();
WaterEntity ColdB = new WaterEntity();
float hotASet, hotBSet, coldASet, coldBSet, hotATol, hotBTol, coldATol, coldBTol;
if (float.TryParse(Convert.ToString(ControlsEntity.ChooseMaterial1.MCValue), out hotASet) &&
)
{
HotA.Set = hotASet;
HotB.Set = hotBSet;
ColdA.Set = coldASet;
ColdB.Set = coldBSet;
HotA.TolErance = hotATol;
HotB.TolErance = hotBTol;
ColdA.TolErance = coldATol;
ColdB.TolErance = coldBTol;
Db2104WriteHelper.WriteAHostWater(HotA);
Db2104WriteHelper.WriteBHostWater(HotB);
Db2104WriteHelper.WriteAColWater(ColdA);
Db2104WriteHelper.WriteBColWater(ColdB);
MesnacServiceManager.Instance.LoggingService.Info("水称数据下发成功!");
MessageBox.Show("水称数据下发成功");
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
} }
if (ControlsEntity.LineStart == runtime.Sender) if (ControlsEntity.LineStart == runtime.Sender)

@ -4,7 +4,7 @@
{ {
public ushort Bin { get; set; } public ushort Bin { get; set; }
public float Set { get; set; } public float Set { get; set; }
public float TolErance { get; set; } public float Tolerance { get; set; }
} }
public class Step public class Step

@ -9,112 +9,6 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
public class LjPlanningPlcHelp public class LjPlanningPlcHelp
{ {
private static void Dowd(int start, RecipePlcView view)
{
int bin = start;
PlcConnect.Instance.Write($"DB2104.{bin}.0", view.Bin);
int set = start+2;
PlcConnect.Instance.Write($"DB2104.{set}.0",view.Set);
int tolerance = start+6;
PlcConnect.Instance.Write($"DB2104.{tolerance}.0", view.TolErance);
}
private static void DowSteps(int start, Step step)
{
int mixCode = start;
PlcConnect.Instance.Write($"DB2104.{mixCode}.0", step.MixCode);
int mixTime = start + 2;
PlcConnect.Instance.Write($"DB2104.{mixTime}.0", step.MixTime);
int mixTemp = start + 4;
PlcConnect.Instance.Write($"DB2104.{mixTemp}.0", step.MixTemp);
int mixSpeed = start + 8;
PlcConnect.Instance.Write($"DB2104.{mixSpeed}.0", step.MixSpeed);
}
private static void DowMSteps(int start, MixStep step)
{
int mixCode = start;
PlcConnect.Instance.Write($"DB2104.{mixCode}.0", step.MixCode);
int mixTime = start + 2;
PlcConnect.Instance.Write($"DB2104.{mixTime}.0", step.MixTime);
int mixTemp = start + 4;
PlcConnect.Instance.Write($"DB2104.{mixTemp}.0", step.MixTemp);
int mixSpeed = start + 8;
PlcConnect.Instance.Write($"DB2104.{mixSpeed}.0", step.MixSpeed);
int setValue = start + 12;
PlcConnect.Instance.Write($"DB2104.{setValue}.0", step.SetValue);
int tolerance = start + 16;
PlcConnect.Instance.Write($"DB2104.{tolerance}.0", step.SetTolerance);
}
private static List<RecipePlcView> GetClean(int num)
{
List<RecipePlcView> ls = new List<RecipePlcView>(num);
for (int i = 0; i < num; i++)
{
ls.Add(new RecipePlcView()
{
Bin = 0,
TolErance = 0,
Set = 0
});
}
return ls;
}
private static List<Step> GetCleanStep(int num)
{
List<Step> ls = new List<Step>(num);
for (int i = 0; i < num; i++)
{
ls.Add(new Step()
{
MixCode = 0,
MixSpeed = 0,
MixTemp = 0,
MixTime = 0
});
}
return ls;
}
private static List<MixStep> GetCleanMixStep(int num)
{
List<MixStep> ls = new List<MixStep>(num);
for (int i = 0; i < num; i++)
{
ls.Add(new MixStep()
{
MixCode = 0,
MixSpeed = 0,
MixTemp = 0,
MixTime = 0,
SetTolerance =0,
SetValue = 0
});
}
return ls;
}
/// <summary> /// <summary>
/// 干混机1 /// 干混机1
/// </summary> /// </summary>
@ -144,68 +38,6 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
PlcConnect.Instance.Write($"DB2104.53.6",true); PlcConnect.Instance.Write($"DB2104.53.6",true);
} }
private static void DownCleanD1Recipe(int begin)
{
List<RecipePlcView> recipePlcViews = GetClean(12);
List<Step> recipeSteps = GetCleanStep(10);
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
begin += 10;
}
begin +=120;
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
begin += 12;
}
}
private static void DownCleanG1Recipe(int begin)
{
List<RecipePlcView> recipePlcViews = GetClean(2);
List<Step> recipeSteps = GetCleanStep(10);
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
begin += 10;
}
begin +=20;
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
begin += 12;
}
}
private static void DownM1CleanRecipe(int begin)
{
List<MixStep> recipeSteps = GetCleanMixStep(10);
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowMSteps(begin, view);
begin += 20;
}
}
@ -317,8 +149,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
} }
public static void DownG2Recipe(List<RecipePlcView> recipePlcViews, public static void DownG2Recipe(List<RecipePlcView> recipePlcViews, List<Step> recipeSteps)
List<Step> recipeSteps)
{ {
int begin = 1158; int begin = 1158;
DownCleanG1Recipe(begin); DownCleanG1Recipe(begin);
@ -344,8 +175,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
PlcConnect.Instance.Write($"DB2104.54.2", true); PlcConnect.Instance.Write($"DB2104.54.2", true);
} }
public static void DownG3Recipe(List<RecipePlcView> recipePlcViews, public static void DownG3Recipe(List<RecipePlcView> recipePlcViews, List<Step> recipeSteps)
List<Step> recipeSteps)
{ {
int begin = 1298; int begin = 1298;
DownCleanG1Recipe(begin); DownCleanG1Recipe(begin);
@ -370,8 +200,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
PlcConnect.Instance.Write($"DB2104.53.7", true); PlcConnect.Instance.Write($"DB2104.53.7", true);
} }
public static void DownG4Recipe(List<RecipePlcView> recipePlcViews, public static void DownG4Recipe(List<RecipePlcView> recipePlcViews, List<Step> recipeSteps)
List<Step> recipeSteps)
{ {
int begin = 1438; int begin = 1438;
DownCleanG1Recipe(begin); DownCleanG1Recipe(begin);
@ -397,8 +226,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
} }
public static void DownG5Recipe(List<RecipePlcView> recipePlcViews, public static void DownG5Recipe(List<RecipePlcView> recipePlcViews, List<Step> recipeSteps)
List<Step> recipeSteps)
{ {
int begin = 1578; int begin = 1578;
DownCleanG1Recipe(begin); DownCleanG1Recipe(begin);
@ -423,8 +251,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
PlcConnect.Instance.Write($"DB2104.54.6", true); PlcConnect.Instance.Write($"DB2104.54.6", true);
} }
public static void DownG6Recipe(List<RecipePlcView> recipePlcViews, public static void DownG6Recipe(List<RecipePlcView> recipePlcViews, List<Step> recipeSteps)
List<Step> recipeSteps)
{ {
int begin =1718; int begin =1718;
@ -451,8 +278,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
PlcConnect.Instance.Write($"DB2104.54.7", true); PlcConnect.Instance.Write($"DB2104.54.7", true);
} }
public static void DownG7Recipe(List<RecipePlcView> recipePlcViews, public static void DownG7Recipe(List<RecipePlcView> recipePlcViews, List<Step> recipeSteps)
List<Step> recipeSteps)
{ {
int begin =1858; int begin =1858;
@ -478,8 +304,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
PlcConnect.Instance.Write($"DB2104.55.0", true); PlcConnect.Instance.Write($"DB2104.55.0", true);
} }
public static void DownG8Recipe(List<RecipePlcView> recipePlcViews, public static void DownG8Recipe(List<RecipePlcView> recipePlcViews, List<Step> recipeSteps)
List<Step> recipeSteps)
{ {
@ -622,6 +447,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
} }
#region 辅助方法
public static DryerView GetDryerD1 => GetDryerView(58); public static DryerView GetDryerD1 => GetDryerView(58);
public static DryerView GetDryerD2 => GetDryerView(298); public static DryerView GetDryerD2 => GetDryerView(298);
@ -683,7 +509,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
MixCode = byteTransform.TransUInt16(bytes, 0), MixCode = byteTransform.TransUInt16(bytes, 0),
MixTime = byteTransform.TransUInt16(bytes, 2), MixTime = byteTransform.TransUInt16(bytes, 2),
MixTemp = byteTransform.TransSingle(bytes, 4), MixTemp = byteTransform.TransSingle(bytes, 4),
MixSpeed =byteTransform.TransSingle(bytes,8) MixSpeed = byteTransform.TransSingle(bytes, 8)
}; };
lsSteps.Add(step); lsSteps.Add(step);
} }
@ -731,7 +557,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
MixCode = byteTransform.TransUInt16(bytes, 0), MixCode = byteTransform.TransUInt16(bytes, 0),
MixTime = byteTransform.TransUInt16(bytes, 2), MixTime = byteTransform.TransUInt16(bytes, 2),
MixTemp = byteTransform.TransSingle(bytes, 4), MixTemp = byteTransform.TransSingle(bytes, 4),
MixSpeed =byteTransform.TransSingle(bytes,8) MixSpeed = byteTransform.TransSingle(bytes, 8)
}; };
lsSteps.Add(step); lsSteps.Add(step);
} }
@ -767,9 +593,9 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
MixCode = byteTransform.TransUInt16(bytes, 0), MixCode = byteTransform.TransUInt16(bytes, 0),
MixTime = byteTransform.TransUInt16(bytes, 2), MixTime = byteTransform.TransUInt16(bytes, 2),
MixTemp = byteTransform.TransSingle(bytes, 4), MixTemp = byteTransform.TransSingle(bytes, 4),
MixSpeed =byteTransform.TransSingle(bytes,8), MixSpeed = byteTransform.TransSingle(bytes, 8),
SetValue = byteTransform.TransSingle(bytes,12), SetValue = byteTransform.TransSingle(bytes, 12),
SetTolerance = byteTransform.TransSingle(bytes,16) SetTolerance = byteTransform.TransSingle(bytes, 16)
}; };
lsSteps.Add(step); lsSteps.Add(step);
} }
@ -778,5 +604,175 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
return lsSteps; return lsSteps;
} }
private static void DownCleanD1Recipe(int begin)
{
List<RecipePlcView> recipePlcViews = GetClean(12);
List<Step> recipeSteps = GetCleanStep(10);
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
begin += 10;
}
begin += 120;
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
begin += 12;
}
}
private static void DownCleanG1Recipe(int begin)
{
List<RecipePlcView> recipePlcViews = GetClean(2);
List<Step> recipeSteps = GetCleanStep(10);
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
begin += 10;
}
begin += 20;
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
begin += 12;
}
}
private static void DownM1CleanRecipe(int begin)
{
List<MixStep> recipeSteps = GetCleanMixStep(10);
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowMSteps(begin, view);
begin += 20;
}
}
private static void Dowd(int start, RecipePlcView view)
{
int bin = start;
PlcConnect.Instance.Write($"DB2104.{bin}.0", view.Bin);
int set = start + 2;
PlcConnect.Instance.Write($"DB2104.{set}.0", view.Set);
int tolerance = start + 6;
PlcConnect.Instance.Write($"DB2104.{tolerance}.0", view.TolErance);
}
private static void DowSteps(int start, Step step)
{
int mixCode = start;
PlcConnect.Instance.Write($"DB2104.{mixCode}.0", step.MixCode);
int mixTime = start + 2;
PlcConnect.Instance.Write($"DB2104.{mixTime}.0", step.MixTime);
int mixTemp = start + 4;
PlcConnect.Instance.Write($"DB2104.{mixTemp}.0", step.MixTemp);
int mixSpeed = start + 8;
PlcConnect.Instance.Write($"DB2104.{mixSpeed}.0", step.MixSpeed);
}
private static void DowMSteps(int start, MixStep step)
{
int mixCode = start;
PlcConnect.Instance.Write($"DB2104.{mixCode}.0", step.MixCode);
int mixTime = start + 2;
PlcConnect.Instance.Write($"DB2104.{mixTime}.0", step.MixTime);
int mixTemp = start + 4;
PlcConnect.Instance.Write($"DB2104.{mixTemp}.0", step.MixTemp);
int mixSpeed = start + 8;
PlcConnect.Instance.Write($"DB2104.{mixSpeed}.0", step.MixSpeed);
int setValue = start + 12;
PlcConnect.Instance.Write($"DB2104.{setValue}.0", step.SetValue);
int tolerance = start + 16;
PlcConnect.Instance.Write($"DB2104.{tolerance}.0", step.SetTolerance);
}
private static List<RecipePlcView> GetClean(int num)
{
List<RecipePlcView> ls = new List<RecipePlcView>(num);
for (int i = 0; i < num; i++)
{
ls.Add(new RecipePlcView()
{
Bin = 0,
TolErance = 0,
Set = 0
});
}
return ls;
}
private static List<Step> GetCleanStep(int num)
{
List<Step> ls = new List<Step>(num);
for (int i = 0; i < num; i++)
{
ls.Add(new Step()
{
MixCode = 0,
MixSpeed = 0,
MixTemp = 0,
MixTime = 0
});
}
return ls;
}
private static List<MixStep> GetCleanMixStep(int num)
{
List<MixStep> ls = new List<MixStep>(num);
for (int i = 0; i < num; i++)
{
ls.Add(new MixStep()
{
MixCode = 0,
MixSpeed = 0,
MixTemp = 0,
MixTime = 0,
SetTolerance = 0,
SetValue = 0
});
}
return ls;
}
#endregion
} }
} }

@ -219,6 +219,8 @@
<Compile Include="Alarm\PmtAlarm\InsertAction.cs" /> <Compile Include="Alarm\PmtAlarm\InsertAction.cs" />
<Compile Include="Alarm\PmtAlarm\ModifyAction.cs" /> <Compile Include="Alarm\PmtAlarm\ModifyAction.cs" />
<Compile Include="Alarm\PmtAlarm\SelectAction.cs" /> <Compile Include="Alarm\PmtAlarm\SelectAction.cs" />
<Compile Include="AutoControl\DB\DeviceMaterrial.cs" />
<Compile Include="AutoControl\DB\StockMaterrialDBHelp.cs" />
<Compile Include="AutoControl\DryerWaterControl.cs" /> <Compile Include="AutoControl\DryerWaterControl.cs" />
<Compile Include="AutoControl\Entity\DryerWaterControlsEntity.cs" /> <Compile Include="AutoControl\Entity\DryerWaterControlsEntity.cs" />
<Compile Include="AutoControl\Entity\GelerWeterControlsEntity.cs" /> <Compile Include="AutoControl\Entity\GelerWeterControlsEntity.cs" />

@ -4,6 +4,6 @@
{ {
public short Bin { get; set; } public short Bin { get; set; }
public float Set { get; set; } public float Set { get; set; }
public float TolErance { get; set; } public float Tolerance { get; set; }
} }
} }

@ -19,7 +19,7 @@
<Property name="TextName" /> <Property name="TextName" />
<Property name="NewFillColor">Red</Property> <Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property> <Property name="OldFillColor">DarkGray</Property>
<Property name="Text">确定</Property> <Property name="Text">下传</Property>
<Property name="Location">38, 441</Property> <Property name="Location">38, 441</Property>
<Property name="Name">WaterConfrim</Property> <Property name="Name">WaterConfrim</Property>
<Property name="Size">98, 41</Property> <Property name="Size">98, 41</Property>

Loading…
Cancel
Save