读取plc计划执行状态

master
wenjy 2 years ago
parent 44e64eaf52
commit 2b60edee67

@ -842,8 +842,8 @@ namespace Mesnac.Action.ChemicalWeighing
//下位机准备信号(上位机下传时读取) //下位机准备信号(上位机下传时读取)
public DataKeyValue ChemicalWeighing_PC_ConfirmRemote = new DataKeyValue("ConfirmRemote"); public DataKeyValue ChemicalWeighing_PC_ConfirmRemote = new DataKeyValue("ConfirmRemote");
//下位机准备信号(上位机下传时读取)
public DataKeyValue ChemicalWeighing_PC_ConfirmReady = new DataKeyValue("ConfirmReady"); public DataKeyValue ChemicalWeighing_PC_ConfirmReady = new DataKeyValue("ConfirmReady");
public DataKeyValue ChemicalWeighing_PC_ConfirmRun = new DataKeyValue("ConfirmRun");
//配方编号、名称 //配方编号、名称
public DataKeyValue ChemicalWeighing_PC_RecipeCode = new DataKeyValue("Recipe_Code"); public DataKeyValue ChemicalWeighing_PC_RecipeCode = new DataKeyValue("Recipe_Code");
@ -867,6 +867,15 @@ namespace Mesnac.Action.ChemicalWeighing
public DataKeyValue ChemicalWeighing_PC_SZJl = new DataKeyValue("sz_jl"); public DataKeyValue ChemicalWeighing_PC_SZJl = new DataKeyValue("sz_jl");
public DataKeyValue ChemicalWeighing_PC_SZJlWc = new DataKeyValue("sz_jlwc"); public DataKeyValue ChemicalWeighing_PC_SZJlWc = new DataKeyValue("sz_jlwc");
//配方下传完成信号
public DataKeyValue ChemicalWeighing_PC_RpFinished = new DataKeyValue("PC_RpFinished");
//计划完成车数
public DataKeyValue ChemicalWeighing_PC_RecipeNum = new DataKeyValue("RecipeNum");
//计划编号PlanNo
public DataKeyValue ChemicalWeighing_PC_PlanNo = new DataKeyValue("PlanNo");
#endregion #endregion

@ -71,6 +71,7 @@ namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan
{ {
ICSharpCode.Core.LoggingService<StopAction>.Info("{生产计划-计划下传} 计划下传成功..."); ICSharpCode.Core.LoggingService<StopAction>.Info("{生产计划-计划下传} 计划下传成功...");
//下传成功后下传RpFinished信号 //下传成功后下传RpFinished信号
bool writeRpFinished = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RpFinished, new object[] { true });
} }
else else
{ {
@ -82,24 +83,40 @@ namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan
//执行完成后判断下一计划执行方式,自动方式则继续执行下发流程 //执行完成后判断下一计划执行方式,自动方式则继续执行下发流程
} }
/// <summary>
/// 读取PLC执行的配方编号
/// </summary>
/// <returns></returns>
public string readRecipeId() public string readRecipeId()
{ {
bool readResult = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeCode, out int[] res); bool readResult = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeCode, out int[] res);
string readRecipeId = ""; string readRecipeId = intArrayToStr(res);
if (res.Length > 0) return readRecipeId;
{
for (int i = 0; i < res.Length; i++)
{
if (res[i] > 0)
{
readRecipeId = readRecipeId + res[i];
}
}
} }
return readRecipeId; /// <summary>
/// 读取plc计划执行状态
/// </summary>
public void readPlanState()
{
var writeResult1 = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.ChemicalWeighing_PC_SetCarNumber, out int[] setAmount );
bool finishAmount = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeNum, out int[] res);
bool planNoResult = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.ChemicalWeighing_PC_PlanNo, out int[] planNo);
string planNoStr = intArrayToStr(planNo);
//根据计划编号修改计划状态、完成数量
Base_PlanInfo planInfo = PlanHelper.getPlanInfoByPlanId(planNoStr);
planInfo.real_Amount = Convert.ToInt32(intArrayToStr(res));
planInfo.plan_State = 1;
string updateResult = PlanHelper.UpdateBasePlanInfo(planInfo);
//读取完成信号
} }
/// <summary> /// <summary>
@ -196,5 +213,21 @@ namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan
#endregion #endregion
} }
public string intArrayToStr(int[] array)
{
string str = "";
if (array.Length > 0)
{
for (int i = 0; i < array.Length; i++)
{
if (array[i] > 0)
{
str = str + array[i];
}
}
}
return str;
}
} }
} }

Loading…
Cancel
Save