add - 湿混糊化plc下发验证

wangsr
wangsr 1 year ago
parent 2e2603aae2
commit 0eadc42fff

@ -1,4 +1,5 @@
using DataBlockHelper.DBHelpers;
using DevExpress.Utils.Serializing.Helpers;
using DevExpress.XtraEditors.Filtering.Templates;
using Mesnac.Action.ChemicalWeighing.AutoControl.DB;
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
@ -11,8 +12,10 @@ using Mesnac.Controls.ChemicalWeighing;
using Mesnac.Controls.Default;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@ -21,7 +24,6 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
{
public class ControlsHelper : ControlsImprot
{
/// <summary>
/// 单选选择
/// </summary>
@ -251,5 +253,40 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
TextE.WetOutDelayTime.MCValue = Wet[4].MixTime;
}
/// <summary>
/// 将C#数据实体转化为JSON数据
/// </summary>
/// <param name="obj">要转化的数据实体</param>
/// <returns>JSON格式字符串</returns>
public static string JsonSerialize<T>(T obj)
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));
MemoryStream stream = new MemoryStream();
serializer.WriteObject(stream, obj);
stream.Position = 0;
StreamReader sr = new StreamReader(stream);
string resultStr = sr.ReadToEnd();
sr.Close();
stream.Close();
return resultStr;
}
/// <summary>
/// 将JSON数据转化为C#数据实体
/// </summary>
/// <param name="json">符合JSON格式的字符串</param>
/// <returns>T类型的对象</returns>
public static T JsonDeserialize<T>(string json)
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));
MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(json.ToCharArray()));
T obj = (T)serializer.ReadObject(ms);
ms.Close();
return obj;
}
}
}

@ -1,5 +1,6 @@
using DataBlockHelper.DBHelpers;
using DataBlockHelper.Entity.DB2104Entity;
using DevExpress.DataAccess.Native.Web;
using DevExpress.XtraEditors.Filtering.Templates;
using Mesnac.Action.ChemicalWeighing.AutoControl.DB;
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
@ -16,7 +17,8 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Serialization;
using static Mesnac.Action.ChemicalWeighing.AutoControl.AutoLogHelper;
using Newtonsoft.Json;
using DevExpress.DataAccess.Native.Json;
namespace Mesnac.Action.ChemicalWeighing.AutoControl
{
@ -129,6 +131,7 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
MixTime = GelCloseHeat,
MixTemp = GelDelayTime
};
Step step9 = new Step();
steps.Add(step1);
steps.Add(step2);
@ -138,6 +141,8 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
steps.Add(step6);
steps.Add(step7);
steps.Add(step8);
steps.Add(step9);
steps.Add(step9);
float WetDryWei = Convert.ToSingle(TextE.WetDryWeight.MCValue.ToString());
short WetMix = Convert.ToInt16(TextE.WetMixTime.MCValue.ToString());
@ -168,12 +173,19 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
MixCode = 5,
MixTime = WetOutDelay
};
MixStep mixStep6 = new MixStep();
mixSteps.Add(mixStep1);
mixSteps.Add(mixStep2);
mixSteps.Add(mixStep3);
mixSteps.Add(mixStep4);
mixSteps.Add(mixStep5);
mixSteps.Add(mixStep6);
mixSteps.Add(mixStep6);
mixSteps.Add(mixStep6);
mixSteps.Add(mixStep6);
mixSteps.Add(mixStep6);
List<DeviceMaterrial> materials = new List<DeviceMaterrial>();
@ -245,10 +257,10 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
GWlog(recipes, steps, mixSteps, RadioE);
//if(!GWComparePLC(recipes, steps, mixSteps, RadioE))
//{
// MessageBox.Show("下传数据不完整,请重新下传数据!");
//}
if (!GWComparePLC(recipes, steps, mixSteps, RadioE))
{
MessageBox.Show("下传数据不完整,请重新下传数据!");
}
}
@ -272,24 +284,44 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
var getGelatG8 = LjPlanningPlcHelp.GetGelatG8;
var getWeterM8 = LjPlanningPlcHelp.GetWeterM8;
string j1 = ControlsHelper.JsonSerialize(recipes);
string j2 = ControlsHelper.JsonSerialize(steps);
string j3 = ControlsHelper.JsonSerialize(mixSteps);
switch (ControlsHelper.SingleSelect(RadioE))
{
case 1:
return getGelatG1.RecipePlcViews.SequenceEqual(recipes) && getGelatG1.RecipeSteps.SequenceEqual(steps) && getWeterM1.SequenceEqual(mixSteps);
return j1 == ControlsHelper.JsonSerialize(getGelatG1.RecipePlcViews)
&& j2 == ControlsHelper.JsonSerialize(getGelatG1.RecipeSteps)
&& j3 == ControlsHelper.JsonSerialize(getWeterM1);
case 2:
return getGelatG2.RecipePlcViews.SequenceEqual(recipes) && getGelatG2.RecipeSteps.SequenceEqual(steps) && getWeterM2.SequenceEqual(mixSteps);
return j1 == ControlsHelper.JsonSerialize(getGelatG2.RecipePlcViews)
&& j2 == ControlsHelper.JsonSerialize(getGelatG2.RecipeSteps)
&& j3 == ControlsHelper.JsonSerialize(getWeterM2);
case 3:
return getGelatG3.RecipePlcViews.SequenceEqual(recipes) && getGelatG3.RecipeSteps.SequenceEqual(steps) && getWeterM3.SequenceEqual(mixSteps);
return j1 == ControlsHelper.JsonSerialize(getGelatG3.RecipePlcViews)
&& j2 == ControlsHelper.JsonSerialize(getGelatG3.RecipeSteps)
&& j3 == ControlsHelper.JsonSerialize(getWeterM3);
case 4:
return getGelatG4.RecipePlcViews.SequenceEqual(recipes) && getGelatG4.RecipeSteps.SequenceEqual(steps) && getWeterM4.SequenceEqual(mixSteps);
return j1 == ControlsHelper.JsonSerialize(getGelatG4.RecipePlcViews)
&& j2 == ControlsHelper.JsonSerialize(getGelatG4.RecipeSteps)
&& j3 == ControlsHelper.JsonSerialize(getWeterM4);
case 5:
return getGelatG5.RecipePlcViews.SequenceEqual(recipes) && getGelatG5.RecipeSteps.SequenceEqual(steps) && getWeterM5.SequenceEqual(mixSteps);
return j1 == ControlsHelper.JsonSerialize(getGelatG5.RecipePlcViews)
&& j2 == ControlsHelper.JsonSerialize(getGelatG5.RecipeSteps)
&& j3 == ControlsHelper.JsonSerialize(getWeterM5);
case 6:
return getGelatG6.RecipePlcViews.SequenceEqual(recipes) && getGelatG6.RecipeSteps.SequenceEqual(steps) && getWeterM6.SequenceEqual(mixSteps);
return j1 == ControlsHelper.JsonSerialize(getGelatG6.RecipePlcViews)
&& j2 == ControlsHelper.JsonSerialize(getGelatG6.RecipeSteps)
&& j3 == ControlsHelper.JsonSerialize(getWeterM6);
case 7:
return getGelatG7.RecipePlcViews.SequenceEqual(recipes) && getGelatG7.RecipeSteps.SequenceEqual(steps) && getWeterM7.SequenceEqual(mixSteps);
return j1 == ControlsHelper.JsonSerialize(getGelatG7.RecipePlcViews)
&& j2 == ControlsHelper.JsonSerialize(getGelatG7.RecipeSteps)
&& j3 == ControlsHelper.JsonSerialize(getWeterM7);
case 8:
return getGelatG8.RecipePlcViews.SequenceEqual(recipes) && getGelatG8.RecipeSteps.SequenceEqual(steps) && getWeterM8.SequenceEqual(mixSteps);
return j1 == ControlsHelper.JsonSerialize(getGelatG8.RecipePlcViews)
&& j2 == ControlsHelper.JsonSerialize(getGelatG8.RecipeSteps)
&& j3 == ControlsHelper.JsonSerialize(getWeterM8);
default:
MessageBox.Show("未选择产线!");
return true;

@ -176,6 +176,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\PlugInPlatform\Mesnac.PlugIn.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\A3Lib\Json\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
@ -186,6 +190,7 @@
<HintPath>..\..\..\packages\System.Data.SqlClient.4.8.5\lib\net451\System.Data.SqlClient.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Runtime.Serialization.Formatters.Soap" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />

Loading…
Cancel
Save