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.
108 lines
4.0 KiB
C#
108 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Controls.Base;
|
|
using System.Windows.Forms;
|
|
using Mesnac.Codd.Session;
|
|
using Mesnac.Equips;
|
|
using System.Xml;
|
|
using System.IO;
|
|
|
|
|
|
namespace Mesnac.Action.Feeding
|
|
{
|
|
public class WritePLCAction : DatabaseAction
|
|
{
|
|
|
|
protected bool ProcessWrite(string dataName, int shifting, object[] dataValue)
|
|
{
|
|
bool Result = false;
|
|
foreach (Mesnac.Equips.BaseEquip equip in Factory.Instance.AllEquips.Values)
|
|
{
|
|
foreach (Mesnac.Equips.BaseInfo.Group group in equip.Group.Values)
|
|
{
|
|
if (group.Access == System.IO.FileAccess.Write ||
|
|
group.Access == System.IO.FileAccess.ReadWrite)
|
|
{
|
|
foreach (Mesnac.Equips.BaseInfo.Data data in group.Data.Values)
|
|
{
|
|
if (data.Name == dataName)
|
|
{
|
|
return equip.Write(Convert.ToInt32(group.Block), group.Start + data.Start + shifting, dataValue);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Result;
|
|
}
|
|
protected bool ProcessWrite(string dataName, object[] dataValue)
|
|
{
|
|
return ProcessWrite(dataName, 0, dataValue);
|
|
}
|
|
protected bool ProcessRead(string dataName, out object[] dataValue)
|
|
{
|
|
bool Result = false;
|
|
dataValue = null;
|
|
foreach (Mesnac.Equips.BaseEquip equip in Factory.Instance.AllEquips.Values)
|
|
{
|
|
foreach (Mesnac.Equips.BaseInfo.Group group in equip.Group.Values)
|
|
{
|
|
if (group.Access == System.IO.FileAccess.Read ||
|
|
group.Access == System.IO.FileAccess.ReadWrite)
|
|
{
|
|
foreach (Mesnac.Equips.BaseInfo.Data data in group.Data.Values)
|
|
{
|
|
if (data.Name == dataName)
|
|
{
|
|
return equip.Read(group.Block, group.Start + data.Start, data.Len, out dataValue);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Result;
|
|
}
|
|
}
|
|
|
|
public class FeedingPlcAction : WritePLCAction
|
|
{
|
|
public DataSet CurrentRecipe()
|
|
{
|
|
DataSet Result = new DataSet();
|
|
DataTable dt_recipe = new DataTable();
|
|
DataTable dt_mixing = new DataTable();
|
|
DataTable dt_weight = new DataTable();
|
|
string sqlstr = @"SELECT * FROM dbo.PmtRecipe t1
|
|
INNER JOIN dbo.SysKeyValue t2 ON t1.ObjID = t2.ssValue AND t2.ssKey='RecipeID'";
|
|
DbHelper dbHelper = NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.local);
|
|
dbHelper.CommandType = CommandType.Text;
|
|
dbHelper.CommandText = sqlstr;
|
|
dt_recipe = dbHelper.ToDataTable();
|
|
sqlstr = @"SELECT * FROM dbo.PmtRecipeMixing t1
|
|
INNER JOIN dbo.SysKeyValue t2 ON t1.RecipeObjID= t2.ssValue AND t2.ssKey='RecipeID' ORDER BY MixingStep";
|
|
dbHelper.CommandType = CommandType.Text;
|
|
dbHelper.CommandText = sqlstr;
|
|
dt_mixing = dbHelper.ToDataTable();
|
|
sqlstr = @"SELECT * FROM dbo.PmtRecipeWeight t1
|
|
INNER JOIN dbo.SysKeyValue t2 ON t1.RecipeObjID= t2.ssValue AND t2.ssKey='RecipeID' ORDER BY t1.WeightType,WeightID";
|
|
dbHelper.CommandType = CommandType.Text;
|
|
dbHelper.CommandText = sqlstr;
|
|
dt_weight = dbHelper.ToDataTable();
|
|
Result.Tables.Add(dt_recipe);
|
|
Result.Tables.Add(dt_mixing);
|
|
Result.Tables.Add(dt_weight);
|
|
return Result;
|
|
}
|
|
|
|
public bool IsHaveXiaoliao()
|
|
{
|
|
bool Result = false;
|
|
return Result;
|
|
}
|
|
}
|
|
}
|