整理代码 add 读取配置和 下工艺

dep_nodyang
nodyang 1 year ago
parent 561213fe66
commit d7cd1d90bc

@ -0,0 +1,19 @@
using System.Collections.Generic;
using Mesnac.Action.ChemicalWeighing.LjMixManager;
namespace Mesnac.Action.ChemicalWeighing.LjPlanning
{
public class DryerView
{
public DryerView()
{
RecipePlcViews = new List<RecipePlcView>();
RecipeSteps = new List<Step>();
}
public List<RecipePlcView> RecipePlcViews { get; set; }
public List<Step> RecipeSteps { get; set; }
}
}

@ -123,7 +123,6 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
public static void DownD1Recipe(List<RecipePlcView> recipePlcViews, List<Step> recipeSteps) public static void DownD1Recipe(List<RecipePlcView> recipePlcViews, List<Step> recipeSteps)
{ {
int begin = 58; int begin = 58;
DownCleanD1Recipe(begin); DownCleanD1Recipe(begin);
for (int i = 0; i < recipePlcViews.Count(); i++) for (int i = 0; i < recipePlcViews.Count(); i++)
@ -625,5 +624,175 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
PlcConnect.Instance.Write($"DB2104.56.1", true); PlcConnect.Instance.Write($"DB2104.56.1", true);
} }
public static DryerView GetDryerD1 => GetDryerView(58);
public static DryerView GetDryerD2 => GetDryerView(298);
public static DryerView GetDryerD3 => GetDryerView(538);
public static DryerView GetDryerD4 => GetDryerView(778);
public static DryerView GetGelatG1 => GetGelatView(1018);
public static DryerView GetGelatG2 => GetGelatView(1158);
public static DryerView GetGelatG3 => GetGelatView(1298);
public static DryerView GetGelatG4 => GetGelatView(1438);
public static DryerView GetGelatG5 => GetGelatView(1578);
public static DryerView GetGelatG6 => GetGelatView(1718);
public static DryerView GetGelatG7 => GetGelatView(1858);
public static DryerView GetGelatG8 => GetGelatView(1998);
public static List<MixStep> GetWeterM1 = GetWeterView(2138);
public static List<MixStep> GetWeterM2 = GetWeterView(2338);
public static List<MixStep> GetWeterM3 = GetWeterView(2538);
public static List<MixStep> GetWeterM4 = GetWeterView(2738);
public static List<MixStep> GetWeterM5 = GetWeterView(2938);
public static List<MixStep> GetWeterM6 = GetWeterView(3138);
public static List<MixStep> GetWeterM7 = GetWeterView(3338);
public static List<MixStep> GetWeterM8 = GetWeterView(3538);
private static DryerView GetDryerView(int start)
{
var byteTransform = PlcConnect.Instance.ByteTransform;
DryerView view = new DryerView();
var operateResult = PlcConnect.Instance.Read($"DB2104.{start}.0", 240);
if (operateResult.IsSuccess)
{
List<RecipePlcView> ls = new List<RecipePlcView>();
var convert = operateResult.Content;
var data = convert.Skip(0).Take(120);
for (int i = 0; i < 12; i++)
{
var bytes = data.Skip(i * 10).Take(10).ToArray();
RecipePlcView plcView = new RecipePlcView
{
Bin = byteTransform.TransUInt16(bytes, 0),
Set = byteTransform.TransSingle(bytes, 2),
TolErance = byteTransform.TransSingle(bytes, 6)
};
ls.Add(plcView);
}
view.RecipePlcViews = ls;
data = convert.Skip(120).Take(120);
List<Step> lsSteps = new List<Step>();
for (int i = 0; i < 10; i++)
{
var bytes = data.Skip(i * 10).Take(12).ToArray();
Step step = new Step()
{
MixCode = byteTransform.TransUInt16(bytes, 0),
MixTime = byteTransform.TransUInt16(bytes, 2),
MixTemp = byteTransform.TransSingle(bytes, 4),
MixSpeed =byteTransform.TransSingle(bytes,8)
};
lsSteps.Add(step);
}
view.RecipeSteps = lsSteps;
}
return view;
}
private static DryerView GetGelatView(int start)
{
var byteTransform = PlcConnect.Instance.ByteTransform;
DryerView view = new DryerView();
var operateResult = PlcConnect.Instance.Read($"DB2104.{start}.0", 140);
if (operateResult.IsSuccess)
{
List<RecipePlcView> ls = new List<RecipePlcView>();
var convert = operateResult.Content;
var data = convert.Skip(0).Take(20);
for (int i = 0; i < 2; i++)
{
var bytes = data.Skip(i * 10).Take(10).ToArray();
RecipePlcView plcView = new RecipePlcView
{
Bin = byteTransform.TransUInt16(bytes, 0),
Set = byteTransform.TransSingle(bytes, 2),
TolErance = byteTransform.TransSingle(bytes, 6)
};
ls.Add(plcView);
}
view.RecipePlcViews = ls;
data = convert.Skip(20).Take(120);
List<Step> lsSteps = new List<Step>();
for (int i = 0; i < 10; i++)
{
var bytes = data.Skip(i * 10).Take(12).ToArray();
Step step = new Step()
{
MixCode = byteTransform.TransUInt16(bytes, 0),
MixTime = byteTransform.TransUInt16(bytes, 2),
MixTemp = byteTransform.TransSingle(bytes, 4),
MixSpeed =byteTransform.TransSingle(bytes,8)
};
lsSteps.Add(step);
}
view.RecipeSteps = lsSteps;
}
return view;
}
private static List<MixStep> GetWeterView(int start)
{
var byteTransform = PlcConnect.Instance.ByteTransform;
List<MixStep> ls = new List<MixStep>();
var operateResult = PlcConnect.Instance.Read($"DB2104.{start}.0", 200);
List<MixStep> lsSteps = new List<MixStep>();
if (operateResult.IsSuccess)
{
var data = operateResult.Content;
for (int i = 0; i < 10; i++)
{
var bytes = data.Skip(i * 10).Take(20).ToArray();
MixStep step = new MixStep()
{
MixCode = byteTransform.TransUInt16(bytes, 0),
MixTime = byteTransform.TransUInt16(bytes, 2),
MixTemp = byteTransform.TransSingle(bytes, 4),
MixSpeed =byteTransform.TransSingle(bytes,8),
SetValue = byteTransform.TransSingle(bytes,12),
SetTolerance = byteTransform.TransSingle(bytes,16)
};
lsSteps.Add(step);
}
}
return lsSteps;
}
} }
} }

@ -176,6 +176,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\PlugInPlatform\Mesnac.PlugIn.dll</HintPath> <HintPath>..\..\..\PlugInPlatform\Mesnac.PlugIn.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Office.Interop.Excel">
<HintPath>..\..\Microsoft.Office.Interop.Excel.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -395,6 +398,7 @@
<Compile Include="LjMixManager\UpdateAction.cs" /> <Compile Include="LjMixManager\UpdateAction.cs" />
<Compile Include="LjPlanning\AddAction.cs" /> <Compile Include="LjPlanning\AddAction.cs" />
<Compile Include="LjPlanning\DownToDatabase.cs" /> <Compile Include="LjPlanning\DownToDatabase.cs" />
<Compile Include="LjPlanning\DryerView.cs" />
<Compile Include="LjPlanning\SelectAction.cs" /> <Compile Include="LjPlanning\SelectAction.cs" />
<Compile Include="LjPlanning\Db\LjFormulaDb.cs" /> <Compile Include="LjPlanning\Db\LjFormulaDb.cs" />
<Compile Include="LjPlanning\DelAction.cs" /> <Compile Include="LjPlanning\DelAction.cs" />

Loading…
Cancel
Save