|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using Newtonsoft.Json;
|
|
|
using Module.DB.Model;
|
|
|
using Module.Common;
|
|
|
using Module.DB.SQLServerDAL;
|
|
|
|
|
|
namespace Module.Plc.Profinet.Tool
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 通道1日志公共变量应用类
|
|
|
/// </summary>
|
|
|
public class PlcPublicT1LogUtils
|
|
|
{
|
|
|
|
|
|
// private bool preT1StartAssign = false;
|
|
|
// private bool preT1EndAssign = false;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 作业日志相关数据读取并记录
|
|
|
/// </summary>
|
|
|
public void ReadAssignmentData()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
bool reader1 = PlcCommon.DeltaTcpNetClient01.ReadBool("M920").Content;
|
|
|
|
|
|
|
|
|
if (PublicParams.preT1StartAssign != reader1)
|
|
|
{
|
|
|
if (reader1)
|
|
|
{
|
|
|
Assignment.startT1Time = DateTime.Now;
|
|
|
}
|
|
|
PublicParams.preT1StartAssign = reader1;
|
|
|
}
|
|
|
|
|
|
|
|
|
bool reader2 = PlcCommon.DeltaTcpNetClient01.ReadBool("M921").Content;
|
|
|
|
|
|
|
|
|
if (PublicParams.preT1EndAssign != reader2)
|
|
|
{
|
|
|
if (reader2)
|
|
|
{
|
|
|
var service = new AssignmentInfo();
|
|
|
|
|
|
int reader3 = PlcCommon.DeltaTcpNetClient01.ReadInt16("D1652").Content;
|
|
|
bool reader4 = PlcCommon.DeltaTcpNetClient01.ReadBool("M922").Content;
|
|
|
string status = "";
|
|
|
if (reader4)
|
|
|
{
|
|
|
status = "异常";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
status = "成功";
|
|
|
}
|
|
|
|
|
|
string repFileNo = "";
|
|
|
string strJson = RecipeResult.T1CurrentRecipe();
|
|
|
if (strJson != null)
|
|
|
{
|
|
|
MJsonRPCotFileInfo jsonResult = JsonConvert.DeserializeObject<MJsonRPCotFileInfo>(strJson);
|
|
|
if (jsonResult != null)
|
|
|
{
|
|
|
repFileNo = jsonResult.f_rep_file_no;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
service.AddAssignmentInfo(new AssignmentRecord()
|
|
|
{
|
|
|
// todo 生成作业号,规则是什么?现在是JN(job_number首字母大写)+当前时间+随机4位数字
|
|
|
f_job_name = "UID" + DateTime.Now.ToString("yyyyMMddHHmm" + new Random().Next(10, 99)),
|
|
|
f_start_time = Assignment.startT1Time.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
f_end_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
// todo 当前登录用户获取
|
|
|
f_user = PublicParams.currUserInfo.f_user_name,
|
|
|
f_wafer = reader3,
|
|
|
f_status = status,
|
|
|
// todo 配方号获取
|
|
|
f_recipe_no = repFileNo,
|
|
|
f_track_no = 1
|
|
|
}); ;
|
|
|
}
|
|
|
PublicParams.preT1EndAssign = reader2;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ex.ToString();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|