master
nodyang 1 year ago
parent 9f13b74e6d
commit 7848b05546

@ -96,9 +96,9 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning.Db
detail.Machine = Convert.ToString(item["Machine"]);
detail.MachineType = item["MachineType"].ToString();
detail.FormulaType = Convert.ToInt32(item["FormulaType"]);
detail.ActionCode = Convert.ToSingle(item["ActionCode"]);
detail.ActionCode = Convert.ToInt32(item["ActionCode"]);
detail.ActionName = item["ActionName"].ToString();
detail.TimeInfo = Convert.ToSingle(item["TimeInfo"].ToString());
detail.TimeInfo = Convert.ToInt32(item["TimeInfo"].ToString());
detail.Temp = Convert.ToSingle(item["Temp"].ToString());
detail.Speed = Convert.ToSingle(item["Speed"].ToString());
detail.SetValue = Convert.ToSingle(item["SetValue"].ToString());

@ -2,22 +2,26 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraRichEdit.Import.OpenXml;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.Entity;
using Mesnac.Action.ChemicalWeighing.LjMixManager;
using Mesnac.Action.ChemicalWeighing.LjPlanning.Db;
using Mesnac.Action.ChemicalWeighing.LjPlanning.Db;
using Mesnac.Action.ChemicalWeighing.LjPlanning.Entity;
using Mesnac.Action.ChemicalWeighing.LjProdcutLine;
using Mesnac.PlcUtils;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
namespace Mesnac.Action.ChemicalWeighing.LjPlanning
{
public class DownloadAction:ChemicalWeighingAction, IAction
public class DownloadAction : ChemicalWeighingAction, IAction
{
private DbMCControl _materialGridControl = null; //物料列表控件
private RuntimeParameter _runtime;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
@ -26,23 +30,23 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "lj_planning")
.FirstOrDefault(); //获取物料数据控件
this._materialGridControl = materialGridControl;
DataGridView clientGridView = this._materialGridControl.BaseControl as DataGridView;
//验证是否选中某物料
if (clientGridView.SelectedRows.Count != 1)
{
MessageBox.Show("请选择要下发的数据", Mesnac.Basic.LanguageHelper.Caption,
MessageBox.Show("请选择要下发的数据", Mesnac.Basic.LanguageHelper.Caption,
MessageBoxButtons.OK, MessageBoxIcon.Information);
this._runtime.IsReturn = true;
return;
}
var dataGridViewRow = clientGridView.SelectedRows[0];
var id = Convert.ToInt32(dataGridViewRow.Cells["Id"].Value);
var ljPlanningView = LjPlanningDb.GetById(id);
LoadingHelper.ShowLoadingScreen();
var watchDog = LjHelp.WatchDog;
if (watchDog == 0)
@ -54,141 +58,385 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
if (ljPlanningView != null)
{
List<RecipePlcView> recipePlcViews = new List<RecipePlcView>();
List<RecipePlcView> recipePlcViews2 = new List<RecipePlcView>();
List<Step> recipeSteps = new List<Step>();
List<MixStep> mixSteps = new List<MixStep>();
//List<RecipePlcView> recipePlcViews = new List<RecipePlcView>();
//List<RecipePlcView> recipePlcViews2 = new List<RecipePlcView>();
//List<Step> recipeSteps = new List<Step>();
//List<MixStep> mixSteps = new List<MixStep>();
//配方名称
var formulaId= ljPlanningView.FormulaId;
var formulaId = ljPlanningView.FormulaId;
var unit = ljPlanningView.Unit;
var plc = BasePlcHelper.Instance;
var formulDetail=LjFormulaDb.GetDetail(formulaId);
var formulDetail = LjFormulaDb.GetDetail(formulaId);
//单元
switch (unit)
{
case 1:
//获取干混机1
var dataDry1C = formulDetail.Where(x => x.MachineType == "Dry" && x.FormulaType == 1 && x.Machine == "A").ToList();
var dataDry1CPlcView = dataDry1C.Select(x => new RecipePlcView()
//单元1 干混1 糊化1 2 湿混 1 2
var dataDry1 = GetUnitDryView(formulDetail);
LjPlanningPlcHelp.DownD1Recipe(dataDry1.H1, dataDry1.R1);
if (dataDry1.H1 != null)
{
WriteEnbale(plc.EnableDryD1);
}
var dataSilo1A = GetUnitSiloView(formulDetail, "A");
LjPlanningPlcHelp.DownG1Recipe(dataSilo1A.H1, dataSilo1A.H2, dataSilo1A.R1);
if (dataSilo1A.H1 != null)
{
WriteEnbale(plc.EnableDryG1);
}
var dataSilo1B = GetUnitSiloView(formulDetail, "B");
LjPlanningPlcHelp.DownG2Recipe(dataSilo1B.H1, dataSilo1B.H2, dataSilo1B.R1);
if (dataSilo1B.H1 != null)
{
Bin = x.BinNo,
Set = x.SetValue,
TolErance = x.Tolerance
}).ToList();
WriteEnbale(plc.EnableDryG2);
}
var dataWeter1A = GetUnitWeterView(formulDetail, "A");
LjPlanningPlcHelp.DownM1Recipe(dataWeter1A.R2);
if (dataWeter1A.R2 != null)
{
WriteEnbale(plc.EnableDryM1);
}
var dataWeter1B = GetUnitWeterView(formulDetail, "B");
LjPlanningPlcHelp.DownM1Recipe(dataWeter1B.R2);
if (dataWeter1B.R2 != null)
{
WriteEnbale(plc.EnableDryM2);
}
plc.PlcWriteByDataKey(plc.Plan0_RecipeCode, new object[] { formulaId });
plc.PlcWriteByDataKey(plc.Plan0_RecipeCode, new object[] { ljPlanningView.Id });
plc.PlcWriteByDataKey(plc.Plan0_Batch, new object[] { ljPlanningView.NumCar });
plc.PlcWriteByDataKey(plc.Plan0_Start, new object[] { 1 });
break;
case 2:
//单元2 干混2 糊化3 4 湿混 3 4
var dataDry2 = GetUnitDryView(formulDetail);
LjPlanningPlcHelp.DownD2Recipe(dataDry2.H1, dataDry2.R1);
if (dataDry2.H1 != null)
{
WriteEnbale(plc.EnableDryD2);
}
var dataSilo2A = GetUnitSiloView(formulDetail, "A");
LjPlanningPlcHelp.DownG3Recipe(dataSilo2A.H1, dataSilo2A.H2, dataSilo2A.R1);
if (dataSilo2A.H1 != null)
{
WriteEnbale(plc.EnableDryG3);
}
var dataSilo2B = GetUnitSiloView(formulDetail, "B");
LjPlanningPlcHelp.DownG4Recipe(dataSilo2B.H1, dataSilo2B.H2, dataSilo2B.R1);
if (dataSilo2B.H1 != null)
{
WriteEnbale(plc.EnableDryG4);
}
var dataWeter2A = GetUnitWeterView(formulDetail, "A");
LjPlanningPlcHelp.DownM3Recipe(dataWeter2A.R2);
if (dataWeter2A.R2 != null)
{
WriteEnbale(plc.EnableDryM3);
}
var dataWeter2B = GetUnitWeterView(formulDetail, "B");
LjPlanningPlcHelp.DownM4Recipe(dataWeter2B.R2);
if (dataWeter2B.R2 != null)
{
WriteEnbale(plc.EnableDryM4);
}
plc.PlcWriteByDataKey(plc.Plan1_RecipeCode, new object[] { formulaId });
plc.PlcWriteByDataKey(plc.Plan1_RecipeCode, new object[] { ljPlanningView.Id });
plc.PlcWriteByDataKey(plc.Plan1_Batch, new object[] { ljPlanningView.NumCar });
plc.PlcWriteByDataKey(plc.Plan1_Start, new object[] { 1 });
break;
case 3:
//单元3 干混3 糊化5 6 湿混 5 6
var dataDry3 = GetUnitDryView(formulDetail);
LjPlanningPlcHelp.DownD3Recipe(dataDry3.H1, dataDry3.R1);
if (dataDry3.H1 != null)
{
WriteEnbale(plc.EnableDryD3);
}
var dataSilo3A = GetUnitSiloView(formulDetail, "A");
LjPlanningPlcHelp.DownG5Recipe(dataSilo3A.H1, dataSilo3A.H2, dataSilo3A.R1);
if (dataSilo3A.H1 != null)
{
WriteEnbale(plc.EnableDryG5);
}
var dataSilo3B = GetUnitSiloView(formulDetail, "B");
LjPlanningPlcHelp.DownG6Recipe(dataSilo3B.H1, dataSilo3B.H2, dataSilo3B.R1);
if (dataSilo3B.H1 != null)
{
WriteEnbale(plc.EnableDryG6);
}
var dataWeter3A = GetUnitWeterView(formulDetail, "A");
LjPlanningPlcHelp.DownM5Recipe(dataWeter3A.R2);
if (dataWeter3A.R2 != null)
{
WriteEnbale(plc.EnableDryM5);
}
var dataWeter3B = GetUnitWeterView(formulDetail, "B");
LjPlanningPlcHelp.DownM6Recipe(dataWeter3B.R2);
if (dataWeter3B.R2 != null)
{
WriteEnbale(plc.EnableDryM6);
}
plc.PlcWriteByDataKey(plc.Plan2_RecipeCode, new object[] { formulaId });
plc.PlcWriteByDataKey(plc.Plan2_RecipeCode, new object[] { ljPlanningView.Id });
plc.PlcWriteByDataKey(plc.Plan2_Batch, new object[] { ljPlanningView.NumCar });
plc.PlcWriteByDataKey(plc.Plan2_Start, new object[] { 1 });
break;
case 4:
//单元4 干混4 糊化7 8 湿混 7 8
var dataDry4 = GetUnitDryView(formulDetail);
LjPlanningPlcHelp.DownD4Recipe(dataDry4.H1, dataDry4.R1);
if (dataDry4.H1 != null)
{
WriteEnbale(plc.EnableDryD4);
}
var dataSilo4A = GetUnitSiloView(formulDetail, "A");
LjPlanningPlcHelp.DownG7Recipe(dataSilo4A.H1, dataSilo4A.H2, dataSilo4A.R1);
if (dataSilo4A.H1 != null)
{
WriteEnbale(plc.EnableDryG7);
}
var dataSilo4B = GetUnitSiloView(formulDetail, "B");
LjPlanningPlcHelp.DownG8Recipe(dataSilo4B.H1, dataSilo4B.H2, dataSilo4B.R1);
if (dataSilo4B.H1 != null)
{
WriteEnbale(plc.EnableDryG8);
}
var dataWeter4A = GetUnitWeterView(formulDetail, "A");
LjPlanningPlcHelp.DownM7Recipe(dataWeter4A.R2);
if (dataWeter4A.R2 != null)
{
WriteEnbale(plc.EnableDryM7);
}
var dataWeter4B = GetUnitWeterView(formulDetail, "B");
LjPlanningPlcHelp.DownM8Recipe(dataWeter4B.R2);
if (dataWeter4B.R2 != null)
{
WriteEnbale(plc.EnableDryM8);
}
plc.PlcWriteByDataKey(plc.Plan3_RecipeCode, new object[] { formulaId });
plc.PlcWriteByDataKey(plc.Plan3_RecipeCode, new object[] { ljPlanningView.Id });
plc.PlcWriteByDataKey(plc.Plan3_Batch, new object[] { ljPlanningView.NumCar });
plc.PlcWriteByDataKey(plc.Plan3_Start, new object[] { 1 });
break;
}
//foreach (var s in strings)
//{
// int i = Convert.ToInt32(s);
// if (i < 5)
// {
// recipePlcViews = LjMixManagerDb.GetRecip(ljPlanningView.MetageAId);
// recipeSteps=LjMixManagerDb.GetStep(ljPlanningView.MetageAId);
// }
// else
// {
// if (id < 13)
// {
// recipePlcViews = LjMixManagerDb.GetRecip(ljPlanningView.MetageB1Id);
// recipePlcViews2 = LjMixManagerDb.GetRecip(ljPlanningView.MetageB2Id);
// recipeSteps=LjMixManagerDb.GetStep( ljPlanningView.MixBId);
// }
// else
// {
// mixSteps = LjMixManagerDb.GetMixStep(ljPlanningView.MixBId);
// }
// }
// switch (i)
// {
// case 1 :
// LjPlanningPlcHelp.DownD1Recipe(recipePlcViews, recipeSteps);
// break;
// case 2 :
// LjPlanningPlcHelp.DownD2Recipe(recipePlcViews, recipeSteps);
// break;
// case 3 :
// LjPlanningPlcHelp.DownD3Recipe(recipePlcViews, recipeSteps);
// break;
// case 4 :
// LjPlanningPlcHelp.DownD4Recipe(recipePlcViews, recipeSteps);
// break;
// case 5 :
// LjPlanningPlcHelp.DownG1Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
// break;
// case 6 :
// LjPlanningPlcHelp.DownG2Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
// break;
// case 7 :
// LjPlanningPlcHelp.DownG3Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
// break;
// case 8 :
// LjPlanningPlcHelp.DownG4Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
// break;
// case 9 :
// LjPlanningPlcHelp.DownG5Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
// break;
// case 10 :
// LjPlanningPlcHelp.DownG6Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
// break;
// case 11 :
// LjPlanningPlcHelp.DownG7Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
// break;
// case 12 :
// LjPlanningPlcHelp.DownG8Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
// break;
// case 13 :
// LjPlanningPlcHelp.DownM1Recipe(mixSteps);
// break;
// case 14 :
// LjPlanningPlcHelp.DownM2Recipe(mixSteps);
// break;
// case 15 :
// LjPlanningPlcHelp.DownM3Recipe(mixSteps);
// break;
// case 16 :
// LjPlanningPlcHelp.DownM4Recipe(mixSteps);
// break;
// case 17 :
// LjPlanningPlcHelp.DownM5Recipe(mixSteps);
// break;
// case 18 :
// LjPlanningPlcHelp.DownM6Recipe(mixSteps);
// break;
// case 19 :
// LjPlanningPlcHelp.DownM7Recipe(mixSteps);
// break;
// case 20:
// LjPlanningPlcHelp.DownM8Recipe(mixSteps);
// break;
// }
//}
}
else
{
MessageBox.Show("数据下发失败");
}
LoadingHelper.CloseForm();
}
public void WriteEnbale(DataKeyValue key)
{
var plc = BasePlcHelper.Instance;
plc.PlcVarWriteByDataKey(key, new object[] { 1 });
}
public UnitView GetUnitDryView(List<LjFormulaDetail> formulDetail)
{
UnitView unitView = new UnitView();
//获取干混机1
var dataDry1C = formulDetail.Where(x => x.MachineType == "Dry" && x.FormulaType == 1 && x.Machine == "A").ToList();
var dataDry1CPlcView = dataDry1C.Select(x => new RecipePlcView()
{
Bin = x.BinNo,
Set = x.SetValue,
TolErance = x.Tolerance
}).ToList();
unitView.H1 = dataDry1CPlcView;
var dataDry1H = formulDetail.Where(x => x.MachineType == "Dry" && x.FormulaType == 2 && x.Machine == "A").ToList();
var dataDry1HPlcView = dataDry1H.Select(x => new Step()
{
MixCode = x.ActionCode,
MixSpeed = x.Speed,
MixTemp = x.Temp,
MixTime = x.TimeInfo
}).ToList();
unitView.R1 = dataDry1HPlcView;
return unitView;
}
public UnitView GetUnitSiloView(List<LjFormulaDetail> formulDetail, string machine)
{
UnitView unitView = new UnitView();
// 糊化1 水 称量 称量
var dataSilo1C = formulDetail.Where(x => x.MachineType == "Silo" && x.FormulaType == 1 && x.Machine == machine).ToList();
var dataSilo1CPlcView = dataSilo1C.Select(x => new RecipePlcView()
{
Bin = x.BinNo,
Set = x.SetValue,
TolErance = x.Tolerance
}).ToList();
unitView.H1 = dataSilo1CPlcView;
var dataSilo1CWater = formulDetail.Where(x => x.MachineType == "Silo_Water" && x.FormulaType == 1 && x.Machine == machine).ToList();
var dataSilo1CWaterPlcView = dataSilo1CWater.Select(x => new RecipePlcView()
{
Bin = x.BinNo,
Set = x.SetValue,
TolErance = x.Tolerance
}).ToList();
unitView.H2 = dataSilo1CWaterPlcView;
var dataSilo1H = formulDetail.Where(x => x.MachineType == "Silo" && x.FormulaType == 2 && x.Machine == machine).ToList();
var dataSilo1HPlcView = dataSilo1H.Select(x => new Step()
{
MixCode = x.ActionCode,
MixSpeed = x.Speed,
MixTemp = x.Temp,
MixTime = x.TimeInfo
}).ToList();
unitView.R1 = dataSilo1HPlcView;
return unitView;
}
public UnitView GetUnitWeterView(List<LjFormulaDetail> formulDetail, string machine)
{
//单元1 干混1 糊化1 2 湿混 1 2
UnitView unitView = new UnitView();
// 糊化2 水 称量 称量
var dataSilo2C = formulDetail.Where(x => x.MachineType == "Weter" && x.FormulaType == 1 && x.Machine == machine).ToList();
var dataSilo2CPlcView = dataSilo2C.Select(x => new RecipePlcView()
{
Bin = x.BinNo,
Set = x.SetValue,
TolErance = x.Tolerance
}).ToList();
unitView.H1 = dataSilo2CPlcView;
var dataSilo2H = formulDetail.Where(x => x.MachineType == "Weter" && x.FormulaType == 2 && x.Machine == machine).ToList();
var dataSilo2HPlcView = dataSilo2H.Select(x => new MixStep()
{
MixCode = x.ActionCode,
MixSpeed = x.Speed,
MixTemp = x.Temp,
MixTime = x.TimeInfo,
SetValue = x.SetValue,
Tolerance = x.Tolerance
}).ToList();
unitView.R2 = dataSilo2HPlcView;
return unitView;
}
}
}

@ -23,19 +23,19 @@
public int FormulaType { get; set; }
public float? ActionCode { get; set; }
public int ActionCode { get; set; }
public string ActionName { get; set; }
public float? TimeInfo { get; set; }
public int TimeInfo { get; set; }
public float? Temp { get; set; }
public float Temp { get; set; }
public float? Speed { get; set; }
public float Speed { get; set; }
public float SetValue { get; set; }
public float? SetTolerance { get; set; }
public float SetTolerance { get; set; }
public int StockMaterialId { get; set; }

@ -161,7 +161,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
if (dr["FormulaId"] != null)
if (dr["FormulaId"] != null)
{
view.FormulaId = Convert.ToInt32(dr["FormulaId"]);
}

@ -2,6 +2,8 @@
using System.Linq;
using System.Windows.Forms;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.LjPlanning.Db;
using Mesnac.PlcUtils;
namespace Mesnac.Action.ChemicalWeighing.LjPlanning
{
@ -9,8 +11,8 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
{
private DbMCControl _materialGridControl = null; //物料列表控件
private RuntimeParameter _runtime;
public static event EventHandler OnPause;
public void Run(RuntimeParameter runtime)
@ -41,24 +43,35 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
//Pause
var i = BasePlcHelper.Instance.RecipePause.LastValue.ToInt();
string message = "";
if (i == 1)
{
MessageBox.Show("");
message = "系统已经暂停 是否恢复系统";
}
else
{
message = "是否暂停系统";
}
string message = "是否暂停系统";
var formul = LjFormulaDb.GetById(id);
var plc = BasePlcHelper.Instance;
if (MessageBox.Show(message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) ==
DialogResult.OK)
{
i = BasePlcHelper.Instance.Pause.LastValue.ToInt();
var bo = !Convert.ToBoolean(i);
BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.Pause, new object[] { bo });
}
var unit= formul.Unit;
switch (unit)
{
case 1:
plc.PlcWriteByDataKey(plc.Plan0_Pause, new object[] { 1 });
break;
case 2:
plc.PlcWriteByDataKey(plc.Plan1_Pause, new object[] { 1 });
break;
case 3:
plc.PlcWriteByDataKey(plc.Plan2_Pause, new object[] { 1 });
break;
case 4:
plc.PlcWriteByDataKey(plc.Plan3_Pause, new object[] { 1 });
break;
default:
break;
}
}
if (OnPause != null)
{

@ -0,0 +1,21 @@
using Mesnac.Action.ChemicalWeighing.LjMixManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mesnac.Action.ChemicalWeighing.LjPlanning
{
public class UnitView
{
public List<RecipePlcView> H1 { get; set; }
public List<RecipePlcView> H2 { get; set; }
public List<Step> R1 { get; set; }
public List<MixStep> R2 { get; set; }
}
}

@ -445,6 +445,7 @@
<Compile Include="LjPlanning\LjPlanningView.cs" />
<Compile Include="LjPlanning\PauseAction.cs" />
<Compile Include="LjPlanning\RestartAction.cs" />
<Compile Include="LjPlanning\UnitView.cs" />
<Compile Include="LjPlanning\UpdateAction.cs" />
<Compile Include="LjPressure\DownAction.cs" />
<Compile Include="LjPressure\FrmPressureUpdate.cs">

@ -1,3 +1,3 @@
<DataSources>
<DataSourceItem Name="DataSource1" Driver="MS SQL Server" Server="192.168.0.222" UserName="sa" Password="123456" DataBase="CWSSHG" ConnectionTimeout="5" DriverAssembly="ICSharpCode.Data.SQLServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DriverClass="ICSharpCode.Data.Core.DatabaseDrivers.SQLServer.SQLServerDatabaseDriver" DataSourceClass="ICSharpCode.Data.Core.DatabaseObjects.Database" />
<DataSourceItem Name="DataSource1" Driver="MS SQL Server" Server="127.0.0.1" UserName="sa" Password="123456" DataBase="CWSSHG" ConnectionTimeout="5" DriverAssembly="ICSharpCode.Data.SQLServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DriverClass="ICSharpCode.Data.Core.DatabaseDrivers.SQLServer.SQLServerDatabaseDriver" DataSourceClass="ICSharpCode.Data.Core.DatabaseObjects.Database" />
</DataSources>
Loading…
Cancel
Save