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.
194 lines
7.9 KiB
C#
194 lines
7.9 KiB
C#
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.LjPlanning.Db;
|
|
using Mesnac.Action.ChemicalWeighing.LjProdcutLine;
|
|
|
|
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
|
|
{
|
|
|
|
private DbMCControl _materialGridControl = null; //物料列表控件
|
|
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)
|
|
{
|
|
|
|
|
|
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 unit = ljPlanningView.Unit;
|
|
|
|
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()
|
|
{
|
|
Bin = x.BinNo,
|
|
Set = x.SetValue,
|
|
TolErance = x.Tolerance
|
|
}).ToList();
|
|
|
|
break;
|
|
case 2:
|
|
break;
|
|
case 3:
|
|
break;
|
|
case 4:
|
|
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();
|
|
|
|
}
|
|
}
|
|
} |