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.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/DownloadAction.cs

163 lines
6.8 KiB
C#

1 year ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.LjMixManager;
using Mesnac.Action.ChemicalWeighing.LjProdcutLine;
namespace Mesnac.Action.ChemicalWeighing.LjPlanning
1 year ago
{
1 year ago
public class DownloadAction:ChemicalWeighingAction, IAction
1 year ago
{
private DbMCControl _materialGridControl = null; //物料列表控件
1 year ago
private RuntimeParameter _runtime;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
this._runtime = runtime;
DbMCControl materialGridControl =
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,
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)
{
LoadingHelper.CloseForm();
MessageBox.Show("PLC通讯失败");
return;
}
if (ljPlanningView != null)
{
var productLineView = ProductLineDb.GetById(ljPlanningView.ProductLineId);
var strings = productLineView.DryId.Split(',').ToArray();
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 id1 = ljPlanningView.Id;
1 year ago
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 :
LjMixManagerPlc.DownD1Recipe(recipePlcViews, recipeSteps);
break;
case 2 :
LjMixManagerPlc.DownD2Recipe(recipePlcViews, recipeSteps);
break;
case 3 :
LjMixManagerPlc.DownD3Recipe(recipePlcViews, recipeSteps);
break;
case 4 :
LjMixManagerPlc.DownD4Recipe(recipePlcViews, recipeSteps);
break;
case 5 :
LjMixManagerPlc.DownG1Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
break;
case 6 :
LjMixManagerPlc.DownG2Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
break;
case 7 :
LjMixManagerPlc.DownG3Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
break;
case 8 :
LjMixManagerPlc.DownG4Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
break;
case 9 :
LjMixManagerPlc.DownG5Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
break;
case 10 :
LjMixManagerPlc.DownG6Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
break;
case 11 :
LjMixManagerPlc.DownG7Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
break;
case 12 :
LjMixManagerPlc.DownG8Recipe(recipePlcViews,recipePlcViews2, recipeSteps);
break;
case 13 :
LjMixManagerPlc.DownM1Recipe(mixSteps);
break;
case 14 :
LjMixManagerPlc.DownM2Recipe(mixSteps);
break;
case 15 :
LjMixManagerPlc.DownM3Recipe(mixSteps);
break;
case 16 :
LjMixManagerPlc.DownM4Recipe(mixSteps);
break;
case 17 :
LjMixManagerPlc.DownM5Recipe(mixSteps);
break;
case 18 :
LjMixManagerPlc.DownM6Recipe(mixSteps);
break;
case 19 :
LjMixManagerPlc.DownM7Recipe(mixSteps);
break;
case 20:
LjMixManagerPlc.DownM8Recipe(mixSteps);
break;
}
}
}
else
{
MessageBox.Show("数据下发失败");
}
LoadingHelper.CloseForm();
}
1 year ago
}
}