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.
114 lines
3.9 KiB
C#
114 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net.NetworkInformation;
|
|
using System.Text;
|
|
using System.Linq;
|
|
using System.Data;
|
|
using System.Threading;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Controls.Base;
|
|
using System.Windows.Forms;
|
|
using Mesnac.Codd.Session;
|
|
using System.IO;
|
|
using Mesnac.Action.Feeding.BasicInfo;
|
|
|
|
namespace Mesnac.Action.Feeding.FeedingPlc
|
|
{
|
|
public class RecipeToPlc : FeedingAction, IAction
|
|
{
|
|
private bool IsNet()
|
|
{
|
|
bool Result = false;
|
|
Result = base.NetType == NetTypes.Net;
|
|
return Result;
|
|
}
|
|
private DateTime Now()
|
|
{
|
|
if (IsNet())
|
|
{
|
|
try
|
|
{
|
|
DbHelper dbHelper = NewDbHelper(Basic.DataSourceFactory.MCDbType.Server);
|
|
dbHelper.CommandType = CommandType.Text;
|
|
dbHelper.ClearParameter();
|
|
dbHelper.CommandText = "select getdate();";
|
|
DateTime time = (DateTime)dbHelper.ToScalar();
|
|
new Basic.LocalTime().Set(time);
|
|
return time;
|
|
}
|
|
catch
|
|
{
|
|
return DateTime.Now;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return DateTime.Now;
|
|
}
|
|
}
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
BasicInfo.RecipeData recipeData = new BasicInfo.RecipeData();
|
|
|
|
if (PlcData.Instance.MixerAuto.LastValue.ToInt() == 0)
|
|
{
|
|
MessageBox.Show("密炼机本控", "系统提示");
|
|
}
|
|
if (PlcData.Instance.MixerNormal.LastValue.ToInt() == 0)
|
|
{
|
|
MessageBox.Show("密炼机故障", "系统提示");
|
|
}
|
|
#region RecipeWeightInfo
|
|
List<BasicInfo.RecipeData.RecipeWeightInfo> weightlst = recipeData.GetCurrentRecipeWeightInfo();
|
|
bool isExists = false;
|
|
foreach (BasicInfo.RecipeData.RecipeWeightInfo weight in weightlst)
|
|
{
|
|
if (weight.WeightType == 0)
|
|
{
|
|
isExists = true;
|
|
break;
|
|
}
|
|
}
|
|
if (isExists)
|
|
{
|
|
if (PlcData.Instance.CarbonNormal.LastValue.ToInt() == 0) { MessageBox.Show("炭黑称故障", "系统提示"); }
|
|
if (PlcData.Instance.CarbonAuto.LastValue.ToInt() == 0) { MessageBox.Show("炭黑称手动", "系统提示"); }
|
|
}
|
|
isExists = false;
|
|
foreach (BasicInfo.RecipeData.RecipeWeightInfo weight in weightlst)
|
|
{
|
|
if (weight.WeightType == 1)
|
|
{
|
|
isExists = true;
|
|
break;
|
|
}
|
|
}
|
|
if (isExists)
|
|
{
|
|
if (PlcData.Instance.OilNormal.LastValue.ToInt() == 0) { MessageBox.Show("油称故障", "系统提示"); }
|
|
if (PlcData.Instance.OilAuto.LastValue.ToInt() == 0) { MessageBox.Show("油称手动", "系统提示"); }
|
|
}
|
|
isExists = false;
|
|
foreach (BasicInfo.RecipeData.RecipeWeightInfo weight in weightlst)
|
|
{
|
|
if (weight.WeightType == 3)
|
|
{
|
|
isExists = true;
|
|
break;
|
|
}
|
|
}
|
|
if (isExists)
|
|
{
|
|
if (PlcData.Instance.FenLiaoNormal.LastValue.ToInt() == 0) { MessageBox.Show("粉料秤故障", "系统提示"); }
|
|
if (PlcData.Instance.FenLiaoAuto.LastValue.ToInt() == 0) { MessageBox.Show("粉料秤手动", "系统提示"); }
|
|
}
|
|
#endregion
|
|
bool IsSuccess = true;
|
|
if (IsSuccess)
|
|
{
|
|
IsSuccess = recipeData.DownloadCurrentRecipeInfo();
|
|
}
|
|
}
|
|
}
|
|
}
|