| | |
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using System.ComponentModel;
|
| | | using System.Linq;
|
| | | using System.Reflection;
|
| | | using System.Text;
|
| | | using System.Threading.Tasks;
|
| | | using Autofac.Core;
|
| | | using HslCommunication;
|
| | | using HslCommunication.Core;
|
| | | using Microsoft.VisualBasic.FileIO;
|
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
|
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
|
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
|
| | | using Quartz;
|
| | | using SixLabors.ImageSharp.PixelFormats;
|
| | | using System.Linq;
|
| | | using System.Text;
|
| | | using WIDESEAWCS_BasicInfoService;
|
| | | using WIDESEAWCS_Common;
|
| | | using WIDESEAWCS_Common.PLCEnum;
|
| | | using WIDESEAWCS_Communicator;
|
| | | using WIDESEAWCS_Core;
|
| | | using WIDESEAWCS_Core.BaseRepository;
|
| | | using WIDESEAWCS_Core.Helper;
|
| | | using WIDESEAWCS_DTO.BasicInfo;
|
| | | using WIDESEAWCS_IBasicInfoService;
|
| | | using WIDESEAWCS_Model.Models;
|
| | | using WIDESEAWCS_QuartzJob;
|
| | | using WIDESEAWCS_QuartzJob.DeviceBase;
|
| | | using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
|
| | |
|
| | | namespace WIDESEAWCS_Tasks
|
| | | {
|
| | |
| | | private readonly IFormulaService _formulaService;
|
| | | private readonly IFormulaDetailService _formulaDetailService;
|
| | | private readonly IProcessInfoService _processInfoService;
|
| | | private readonly IProcessInfoDetailService _processDetailInfoService;
|
| | | private readonly IUnitOfWorkManage _unitOfWorkManage;
|
| | | public PLCJob(IBoxingService boxingService, IBoxingDetailService boxingDetailService, IFormulaService formulaService, IFormulaDetailService formulaDetailService, IProcessInfoService processInfoService, IUnitOfWorkManage unitOfWorkManage)
|
| | | private readonly IScanStationService _scanStationService;
|
| | |
|
| | | public PLCJob(IBoxingService boxingService,
|
| | | IBoxingDetailService boxingDetailService,
|
| | | IFormulaService formulaService,
|
| | | IFormulaDetailService formulaDetailService,
|
| | | IProcessInfoService processInfoService,
|
| | | IProcessInfoDetailService processDetailInfoService,
|
| | | IUnitOfWorkManage unitOfWorkManage,
|
| | | IScanStationService scanStationService
|
| | | )
|
| | | {
|
| | | _boxingService = boxingService;
|
| | | _boxingDetailService = boxingDetailService;
|
| | | _formulaService = formulaService;
|
| | | _formulaDetailService = formulaDetailService;
|
| | | _processInfoService = processInfoService;
|
| | | _processDetailInfoService = processDetailInfoService;
|
| | | _unitOfWorkManage = unitOfWorkManage;
|
| | | _scanStationService = scanStationService;
|
| | | }
|
| | | private readonly string set = "0x16,0x4D,0x0D,0x30,0x34,0x30,0x31,0x44,0x30,0x35,0x2E";//主æºåéè®¾ç½®æ«ææ¨¡å¼ä¸ºä¸»æºæ¨¡å¼çå½ä»¤,æ«æå¨è¿åæ¥æ¶å°çå½ä»¤å<ACK>ï¼0x06ï¼åï¼å°æ«ææ¨¡å¼æ´æ¹ä¸ºä¸»æºæ¨¡å¼
|
| | | private readonly string Text = "å¼å¯æ«ç ";//主æºåéè®¾ç½®æ«ææ¨¡å¼ä¸ºä¸»æºæ¨¡å¼çå½ä»¤,æ«æå¨è¿åæ¥æ¶å°çå½ä»¤å<ACK>ï¼0x06ï¼åï¼å°æ«ææ¨¡å¼æ´æ¹ä¸ºä¸»æºæ¨¡å¼
|
| | | private readonly string command = "0x16,0x54,0x0D";//åéå¼å§è§£ç å½ä»¤ï¼"0x16,0x55,0x0D"åéåæ¢è§£ç å½ä»¤
|
| | | public Task Execute(IJobExecutionContext context)
|
| | | {
|
| | |
|
| | |
| | | OtherDevice device = (OtherDevice)value;
|
| | | try
|
| | | {
|
| | |
|
| | | if (!device.IsConnected) throw new Exception(device.DeviceName + "è¿æ¥å¤±è´¥");
|
| | | var Heart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolHeart);
|
| | | var EMG = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolEMG);
|
| | | var AutoExecuting = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolAutoExecuting);
|
| | | var OnlineExecuting = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolOnlineExecuting);
|
| | | var Error = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolError);
|
| | | if (Heart && !EMG && AutoExecuting && OnlineExecuting && !Error)
|
| | |
|
| | | if (/*Heart &&*/ !EMG && AutoExecuting && OnlineExecuting && !Error)
|
| | | {
|
| | | #region ä¸çº¿æ«ç
|
| | | HandleOnlineScan(device);
|
| | | #endregion
|
| | | //#region é¶ä»¶æ£æµ
|
| | | //HandlePartDetection(device);
|
| | | //#endregion
|
| | |
|
| | | //#region ä¸çº¿æ«ç
|
| | | //HandleOnlineScan(device);
|
| | | //#endregion
|
| | |
|
| | | #region åè£
æ«ç
|
| | | HandlePressScan(device);
|
| | | #endregion
|
| | |
|
| | | #region åè£
ä¿¡æ¯ä¸ä¼
|
| | | HandlePressInfoUpload(device);
|
| | | #endregion
|
| | |
|
| | | #region æ£æµæ«ç
|
| | | HandleDetectScan(device);
|
| | | #endregion
|
| | |
|
| | | #region æ£æµä¿¡æ¯ä¸ä¼
|
| | | HandleDetectInfoUpload(device);
|
| | | #endregion
|
| | |
|
| | | #region ä¸çº¿æ«ç
|
| | | HandleOfflineScan(device);
|
| | |
|
| | | #endregion
|
| | | }
|
| | |
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | |
| | | return Task.CompletedTask;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | /// <summary>
|
| | | /// é¶ä»¶æ£æµ
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <exception cref="InvalidOperationException"></exception>
|
| | | private void HandlePartDetection(OtherDevice device)
|
| | | {
|
| | | //DB800.1.4
|
| | | var Location5ScanStart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolLocation5ScanStart);
|
| | | var Location5ScanDone = device.GetValue<W_PLCDBName, bool>(W_PLCDBName.wboolLocation5ScanDone);
|
| | | if (Location5ScanStart && !Location5ScanDone)
|
| | | {
|
| | | try
|
| | | {
|
| | | if (_scanStationService.Repository.QueryFirst(x => x.StationCode == "001").IsScanned == 0)
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation5ScanDone, true);
|
| | | return;
|
| | | }
|
| | | Dt_Boxing dt_Boxing = _boxingService.Repository.QueryData(x => true, 1, "Id desc").FirstOrDefault();
|
| | | if (dt_Boxing == null)
|
| | | {
|
| | | throw new InvalidOperationException("æ ç»çæ°æ®");
|
| | | }
|
| | | Dt_Formula dt_Formula = _formulaService.Repository.QueryFirst(x => x.ProductCode == dt_Boxing.ProductCode);
|
| | | if (dt_Formula == null)
|
| | | {
|
| | | throw new InvalidOperationException("æ æåé
æ¹");
|
| | | }
|
| | | List<Dt_BoxingDetail> dt_BoxingDetails = _boxingDetailService.Repository.QueryData(x => x.BoxingId == dt_Boxing.Id);
|
| | | List<Dt_FormulaDetail> dt_FormulaDetails = _formulaDetailService.Repository.QueryData(x => x.FormulaId == dt_Formula.Id && x.IsScanned == 1);
|
| | | if (!_boxingDetailService.CheckComponentsMatchExactly(dt_BoxingDetails.Select(x => x.ComponentCode).ToList(), dt_FormulaDetails.Select(x => x.ComponentCode).ToList()))
|
| | | {
|
| | | throw new InvalidOperationException("é¶ä»¶ä¸é
æ¹è¡¨ä¸ä¸å");
|
| | | }
|
| | | device.SetValue(W_PLCDBName.wboolLocation5ScanDone, true);
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | WriteError(device.DeviceName, "æ£æµé¶ä»¶æµç¨æ§è¡å¼å¸¸", ex);
|
| | | }
|
| | | }
|
| | | else if (!Location5ScanStart && Location5ScanDone)
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation5ScanDone, false);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// ä¸çº¿æ«ç
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | private void HandleOnlineScan(OtherDevice device)
|
| | | {
|
| | | var Location1ScanStart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolLocation1ScanStart);
|
| | | var Location1ScanDone = device.GetValue<W_PLCDBName, bool>(W_PLCDBName.wboolLocation1ScanDone);
|
| | | if (Location1ScanStart && !Location1ScanDone)//æ§å¶æ«ç æªæ«ææçç ï¼æ ¹æ®æçç æ¥è¯¢ç»çæ°æ®ï¼å¤ææçç»å®æåæ¯å¦å·²ç»å®æææéé¶ä»¶
|
| | | //DB800.1.4
|
| | | var Location5ScanStart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolLocation5ScanStart);
|
| | | var Location5ScanDone = device.GetValue<W_PLCDBName, bool>(W_PLCDBName.wboolLocation5ScanDone);
|
| | | if (Location5ScanStart && !Location5ScanDone)//æ§å¶æ«ç æªæ«ææçç ï¼æ ¹æ®æçç æ¥è¯¢ç»çæ°æ®ï¼å¤ææçç»å®æåæ¯å¦å·²ç»å®æææéé¶ä»¶
|
| | | {
|
| | | #region 串å£è¿æ¥
|
| | | SerialPortCommunicator portCommunicator1 = new SerialPortCommunicator("COM1", 9600, "ä¸çº¿æ«ç æª");
|
| | | bool IsConnected1 = false;
|
| | | SerialPortCommunicator portCommunicator2 = new SerialPortCommunicator("COM2", 9600, "ä¸çº¿æ«ç æª");
|
| | | bool IsConnected2 = false;
|
| | | if (!IsConnected1) IsConnected1 = portCommunicator1.Connect();
|
| | | if (!IsConnected2) IsConnected2 = portCommunicator2.Connect();
|
| | | byte[] dataToSend1 = Encoding.ASCII.GetBytes(command);//转æåèæ°ç»
|
| | | portCommunicator1.Write(dataToSend1);
|
| | | string receiveData = portCommunicator2.ToString(Encoding.UTF8);
|
| | | //if (receiveData == "0x16,0x54,0x0D")
|
| | | //{
|
| | | // Console.WriteLine(receiveData);
|
| | | byte[] dataToSend2 = Encoding.ASCII.GetBytes("PL106");//转æåèæ°ç»
|
| | | portCommunicator2.Write(dataToSend2);
|
| | | //}
|
| | | string PalletCode = portCommunicator1.ToString(Encoding.UTF8);
|
| | | using (var uow = _unitOfWorkManage.CreateUnitOfWork())
|
| | | Dt_Boxing dt_Boxing1 = _boxingService.Repository.QueryData(x => true, 1, "Id desc").FirstOrDefault();
|
| | | if (dt_Boxing1 != null && dt_Boxing1.ProductCode == null)
|
| | | {
|
| | | try
|
| | | return;
|
| | | }
|
| | | //var PalletCode = "PL111";
|
| | | var PalletCode = TcpClientExample.Start("192.168.2.120", 2001);
|
| | | try
|
| | | {
|
| | | if (!PalletCode.IsNotEmptyOrNull() || PalletCode == "NoRead")
|
| | | {
|
| | | if (PalletCode.IsNotEmptyOrNull())
|
| | | {
|
| | | var boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | if (boxing == null)
|
| | | {
|
| | | WriteError(device.DeviceName, "空æç");
|
| | | return;
|
| | | }
|
| | | List<Dt_BoxingDetail> dt_BoxingDetails = _boxingDetailService.Repository.QueryData(x => x.BoxingId == boxing.Id);
|
| | | Dt_Formula dt_Formula = _formulaService.Repository.QueryFirst(x => x.ProductCode == boxing.ProductCode);
|
| | | if (dt_Formula == null)
|
| | | {
|
| | | WriteError(device.DeviceName, "æ æåé
æ¹");
|
| | | return;
|
| | | }
|
| | | List<Dt_FormulaDetail> dt_FormulaDetails = _formulaDetailService.Repository.QueryData(x => x.FormulaId == dt_Formula.Id);
|
| | | //æ¯è¾é¶ä»¶æ¯å¦é½å
¨
|
| | | if (!_boxingDetailService.IsComponentCodesEqual(dt_BoxingDetails, dt_FormulaDetails))
|
| | | {
|
| | | WriteError(device.DeviceName, "é¶ä»¶æé®é¢ï¼è¯·å¤ç");
|
| | | return;
|
| | | }
|
| | | }
|
| | | //æäº¤äºå¡
|
| | | uow.Commit();
|
| | |
|
| | | IsConnected1 = !portCommunicator1.Disconnect();
|
| | | IsConnected2 = !portCommunicator2.Disconnect();
|
| | | #endregion
|
| | | device.SetValue(W_PLCDBName.wboolLocation1ScanDone, true);
|
| | | |
| | |
|
| | | throw new InvalidOperationException("æç为空");
|
| | | }
|
| | | catch (Exception ex)
|
| | |
|
| | | if (_boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode && x.ProductCode != null) != null)
|
| | | {
|
| | | WriteError(device.DeviceName, "ä¸çº¿æ«ç æµç¨æ§è¡å¼å¸¸", ex);
|
| | | device.SetValue(W_PLCDBName.wboolLocation5ScanDone, true);
|
| | | throw new InvalidOperationException("æç以åå¨");
|
| | | }
|
| | |
|
| | | Dt_Boxing dt_Boxing = new Dt_Boxing();
|
| | | dt_Boxing.PalletCode = PalletCode;
|
| | | _boxingService.Repository.AddData(dt_Boxing);
|
| | |
|
| | |
|
| | |
|
| | | //Dt_ScanStation dt_ScanStation = _scanStationService.Repository.QueryFirst(x => x.StationCode == "001");
|
| | | //if (dt_ScanStation == null)
|
| | | //{
|
| | | // throw new InvalidOperationException("æ 工使°æ®");
|
| | | //}
|
| | | //Dt_Formula dt_Formula = _formulaService.Repository.QueryFirst(x => x.ProductCode == dt_ScanStation.StationEndProduct);
|
| | |
|
| | | //if (dt_Formula == null)
|
| | | //{
|
| | | // throw new InvalidOperationException("æ æåé
æ¹");
|
| | | //}
|
| | |
|
| | | //List<Dt_FormulaDetail> dt_FormulaDetails = _formulaDetailService.Repository.QueryData(x => x.FormulaId == dt_Formula.Id && x.IsScanned == 1);
|
| | | //if (dt_ScanStation.IsScanned == 0)
|
| | | //{ |
| | | // Dt_Boxing dt_Boxing = new Dt_Boxing
|
| | | // {
|
| | | // PalletCode = PalletCode,
|
| | | // ProductCode = dt_Formula.ProductCode,
|
| | | // ProductName = dt_Formula.ProductName,
|
| | | // Creater = "admin",
|
| | | // CreateDate = new DateTime()
|
| | | // };
|
| | |
|
| | | // int id = _boxingService.Repository.AddData(dt_Boxing);
|
| | | // foreach (var item in dt_FormulaDetails)
|
| | | // {
|
| | | // Dt_BoxingDetail dt_BoxingDetail = new Dt_BoxingDetail()
|
| | | // {
|
| | | // BoxingId = id,
|
| | | // ComponentCode = item.ComponentCode,
|
| | | // ComponentName = item.ComponentName,
|
| | | // Creater = "admin",
|
| | | // CreateDate = new DateTime()
|
| | | // };
|
| | | // _boxingDetailService.Repository.AddData(dt_BoxingDetail);
|
| | | // }
|
| | | // device.SetValue(W_PLCDBName.wboolLocation5ScanDone, true);
|
| | | // return;
|
| | | //}
|
| | |
|
| | | //var boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | //if (boxing == null)
|
| | | //{
|
| | | // throw new InvalidOperationException("æªæ·»å ç»çä¿¡æ¯");
|
| | | //}
|
| | |
|
| | | //List<Dt_BoxingDetail> dt_BoxingDetails = _boxingDetailService.Repository.QueryData(x => x.BoxingId == boxing.Id);
|
| | |
|
| | |
|
| | | //if (!_boxingDetailService.CheckComponentsMatchExactly(dt_BoxingDetails.Select(x => x.ComponentCode).ToList(), dt_FormulaDetails.Select(x => x.ComponentCode).ToList()))
|
| | | //{
|
| | | // throw new InvalidOperationException("é¶ä»¶ä¸é
æ¹è¡¨ä¸ä¸å");
|
| | | //}
|
| | |
|
| | |
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | WriteError(device.DeviceName, "ä¸çº¿æ«ç æµç¨æ§è¡å¼å¸¸", ex);
|
| | | }
|
| | | }
|
| | | else if (!Location1ScanStart && Location1ScanDone)
|
| | | else if (!Location5ScanStart && Location5ScanDone)
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation1ScanDone, false);
|
| | | device.SetValue(W_PLCDBName.wboolLocation5ScanDone, false);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | /// <param name="device"></param>
|
| | | private void HandlePressScan(OtherDevice device)
|
| | | {
|
| | | //DB800.1.1
|
| | | var Location2ScanStart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolLocation2ScanStart);
|
| | | var Location2ScanDone = device.GetValue<W_PLCDBName, bool>(W_PLCDBName.wboolLocation2ScanDone);
|
| | | if (Location2ScanStart && !Location2ScanDone)//æ§å¶æ«ç æªæ«ææçç ï¼æ ¹æ®æçç æ¥è¯¢æçç»å®æåå å·¥æéæ°æ®ï¼åå
¥PLC
|
| | | {
|
| | | #region MyRegion
|
| | | #region 串å£è¿æ¥
|
| | | SerialPortCommunicator portCommunicator17 = new SerialPortCommunicator("COM17", 9600, "åè£
æ«ç æª");
|
| | | bool IsConnected17 = false;
|
| | | SerialPortCommunicator portCommunicator18 = new SerialPortCommunicator("COM18", 9600, "åè£
æ«ç æª");
|
| | | bool IsConnected18 = false;
|
| | | if (!IsConnected17) IsConnected17 = portCommunicator17.Connect();
|
| | | if (!IsConnected18) IsConnected18 = portCommunicator18.Connect();
|
| | | byte[] dataToSend1 = Encoding.ASCII.GetBytes(command);//转æåèæ°ç»
|
| | | portCommunicator17.Write(dataToSend1);
|
| | | string receiveData = portCommunicator18.ToString(Encoding.UTF8);
|
| | | byte[] dataToSend2 = Encoding.ASCII.GetBytes("PL106");//转æåèæ°ç»
|
| | | portCommunicator18.Write(dataToSend2);
|
| | | //}
|
| | | string PalletCode = portCommunicator17.ToString(Encoding.UTF8);
|
| | | using (var uow = _unitOfWorkManage.CreateUnitOfWork())
|
| | | var PalletCode = TcpClientExample.Start("192.168.2.121", 2001);
|
| | |
|
| | | try
|
| | | {
|
| | | try
|
| | | if (!PalletCode.IsNotEmptyOrNull() || PalletCode == "NoRead")
|
| | | {
|
| | | if (PalletCode.IsNotEmptyOrNull())
|
| | | {
|
| | | Dt_Boxing dt_Boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | Dt_Formula dt_Formula = _formulaService.Repository.QueryFirst(x => x.ProductCode == dt_Boxing.ProductCode);
|
| | | //åå
¥PLC
|
| | | device.SetValue(W_PLCDBName.wrealProductLength, dt_Formula.ProductLength);
|
| | | device.SetValue(W_PLCDBName.wrealProductWidth, dt_Formula.ProductWidth);
|
| | | device.SetValue(W_PLCDBName.wrealProductHeight, dt_Formula.ProductHeight);
|
| | | device.SetValue(W_PLCDBName.wrealScrewDownsetDistance, dt_Formula.ScrewDownsetDistance);
|
| | | device.SetValue(W_PLCDBName.wrealScrewTorqueOutput, dt_Formula.ScrewTorqueOutput);
|
| | | device.SetValue(W_PLCDBName.wDintAutoScrewOn, dt_Formula.DintAutoScrewOn);
|
| | |
|
| | | //åè£
æ«ç 宿
|
| | | device.SetValue(W_PLCDBName.wboolLocation2ScanDone, true);
|
| | |
|
| | | //æ¥æ¶æ°æ®
|
| | | float PressHeight = device.GetValue<R_PLCDBName, float>(R_PLCDBName.rrealDetectPressHeight);
|
| | | float ScrewTorque = device.GetValue<R_PLCDBName, float>(R_PLCDBName.rrealDetectScrewTorque);
|
| | | float ScrewAngle = device.GetValue<R_PLCDBName, float>(R_PLCDBName.rrealDetectScrewAngle);
|
| | |
|
| | | //æ·»å å°æ°æ®åº
|
| | | Dt_ProcessInfo dt_ProcessInfo = new Dt_ProcessInfo()
|
| | | {
|
| | | PalletCode = PalletCode,
|
| | | ProductCode = dt_Formula.ProductCode,
|
| | | ProductName = dt_Formula.ProductName,
|
| | | PressHeight = PressHeight,
|
| | | ScrewTorque = ScrewTorque,
|
| | | ScrewAngle = ScrewAngle
|
| | |
|
| | | };
|
| | | _processInfoService.Repository.AddData(dt_ProcessInfo);
|
| | | }
|
| | | //æäº¤äºå¡
|
| | | uow.Commit();
|
| | |
|
| | | IsConnected17 = !portCommunicator17.Disconnect();
|
| | | IsConnected18 = !portCommunicator18.Disconnect();
|
| | | #endregion
|
| | | #endregion
|
| | |
|
| | | throw new InvalidOperationException("æçå·ä¸ºç©º");
|
| | | }
|
| | | catch (Exception ex)
|
| | | Dt_Boxing dt_Boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | if (dt_Boxing == null)
|
| | | {
|
| | | WriteError(device.DeviceName, "åè£
æ«ç æµç¨æ§è¡å¼å¸¸", ex);
|
| | | device.SetValue(W_PLCDBName.wboolLocation2ScanDone, true);
|
| | | throw new InvalidOperationException("æç为空");
|
| | | }
|
| | | if (dt_Boxing.ProductCode == null && dt_Boxing.BoxingNo == null)
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation2ScanDone, true);
|
| | | return;
|
| | | }
|
| | |
|
| | | Dt_Formula dt_Formula = _formulaService.Repository.QueryFirst(x => x.ProductCode == dt_Boxing.ProductCode);
|
| | | //åå
¥PLC
|
| | | device.SetValue(W_PLCDBName.wrealPressPalletCode, dt_Boxing.Id % 100);
|
| | | if(dt_Formula.PressNoTighten == 1)
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation8ScanDone,true);
|
| | | }
|
| | | else
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation8ScanDone, false);
|
| | | }
|
| | |
|
| | | device.SetValue(W_PLCDBName.wrealProductLength, dt_Formula.ProductLength);
|
| | | device.SetValue(W_PLCDBName.wrealProductWidth, dt_Formula.ProductWidth);
|
| | | device.SetValue(W_PLCDBName.wrealProductHeight, dt_Formula.ProductHeight + dt_Formula.GasketHeight);
|
| | | device.SetValue(W_PLCDBName.wrealScrewDownsetDistance, dt_Formula.ScrewDownsetDistance);
|
| | | //ä¸å¿é«åº¦
|
| | | device.SetValue(W_PLCDBName.wrealScrewTorque, dt_Formula.ScrewTorqueOutput + dt_Formula.GasketHeight);
|
| | | device.SetValue(W_PLCDBName.wrealAutoScrewProgramNo, dt_Formula.DintAutoScrewOn);
|
| | | device.SetValue(W_PLCDBName.wrealPressPressure, dt_Formula.PressPressureDiff);
|
| | | device.SetValue(W_PLCDBName.wrealTighteningTorque, dt_Formula.PressTorqueDiff);
|
| | | device.SetValue(W_PLCDBName.wrealFastenTorque, dt_Formula.PressFastenTorque);
|
| | |
|
| | |
|
| | | //åè£
æ«ç 宿
|
| | | device.SetValue(W_PLCDBName.wboolLocation2ScanDone, true);
|
| | |
|
| | |
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | WriteError(device.DeviceName, "åè£
æ«ç æµç¨æ§è¡å¼å¸¸", ex);
|
| | | }
|
| | | }
|
| | | else if (!Location2ScanStart && Location2ScanDone)
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /// <summary>
|
| | | /// åè£
ä¿¡æ¯ä¸ä¼
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <exception cref="NotImplementedException"></exception>
|
| | | private void HandlePressInfoUpload(OtherDevice device)
|
| | | {
|
| | | //DB800.1.5
|
| | | var Location6ScanStart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolLocation6ScanStart);
|
| | | var Location6ScanDone = device.GetValue<W_PLCDBName, bool>(W_PLCDBName.wboolLocation6ScanDone);
|
| | | if (Location6ScanStart && !Location6ScanDone)//æ§å¶æ«ç æªæ«ææçç ï¼æ ¹æ®æçç æ¥è¯¢æçç»å®æåå å·¥æéæ°æ®ï¼åå
¥PLC
|
| | | {
|
| | |
|
| | | var PalletNum = device.GetValue<R_PLCDBName, int>(R_PLCDBName.rrealPressPalletCode);
|
| | | try
|
| | | {
|
| | | if (!PalletNum.IsNotEmptyOrNull())
|
| | | {
|
| | | throw new InvalidOperationException("æç为空");
|
| | | }
|
| | | Dt_Boxing dt_Boxing = _boxingService.Repository.QueryFirst(x => x.Id % 100 == PalletNum);
|
| | | if (dt_Boxing == null)
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation6ScanDone, true);
|
| | | throw new InvalidOperationException("æªæ¾å°ç»çæ°æ®");
|
| | | }
|
| | | Dt_Formula dt_Formula = _formulaService.Repository.QueryFirst(x => x.ProductCode == dt_Boxing.ProductCode);
|
| | |
|
| | |
|
| | | //æ¥æ¶æ°æ®
|
| | | decimal ScrewTorque = (decimal)device.GetValue<R_PLCDBName, float>(R_PLCDBName.rrealDetectScrewTorque);
|
| | | decimal ScrewAngle = (decimal)device.GetValue<R_PLCDBName, float>(R_PLCDBName.rrealDetectScrewAngle);
|
| | | decimal PressPressure = (decimal)device.GetValue<R_PLCDBName, float>(R_PLCDBName.rrealDetectPressForce);
|
| | | bool PressTightenOk = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rrealPressScrewByScrewOK);
|
| | | bool PressTightenUnfinished = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rrealPressScrewByProcessUnfinished);
|
| | |
|
| | |
|
| | |
|
| | | //æ·»å å°æ°æ®åº
|
| | | Dt_ProcessInfo dt_ProcessInfo = new Dt_ProcessInfo()
|
| | | {
|
| | | PalletCode = dt_Boxing.PalletCode,
|
| | | ProductCode = dt_Formula.ProductCode,
|
| | | ProductName = dt_Formula.ProductName,
|
| | | ProductSn = dt_Boxing.BoxingNo,
|
| | | ProductStatus = 1,
|
| | | PressTightenOk = PressTightenOk ? 1 : 0,
|
| | | PressTightenUnfinished = PressTightenUnfinished ? 1 : 0,
|
| | | ScrewTorque = ScrewTorque,
|
| | | ScrewAngle = ScrewAngle,
|
| | | PressPressure = PressPressure,
|
| | | };
|
| | |
|
| | | if (
|
| | | PressPressure > dt_Formula.ScrewDownsetDistance + dt_Formula.PressPressureDiff || PressPressure < dt_Formula.ScrewDownsetDistance - dt_Formula.PressPressureDiff ||
|
| | | ScrewTorque > dt_Formula.PressFastenTorque + dt_Formula.PressTorqueDiff || ScrewTorque < dt_Formula.PressFastenTorque - dt_Formula.PressTorqueDiff
|
| | | )
|
| | | {
|
| | | dt_ProcessInfo.ProductStatus = 0;
|
| | | }
|
| | |
|
| | | _processInfoService.Repository.AddData(dt_ProcessInfo);
|
| | |
|
| | | // åè£
ä¿¡æ¯ä¸ä¼ 宿
|
| | | device.SetValue(W_PLCDBName.wboolLocation6ScanDone, true);
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | WriteError(device.DeviceName, "åè£
ä¿¡æ¯ä¸ä¼ æµç¨æ§è¡å¼å¸¸", ex);
|
| | | }
|
| | | }
|
| | | else if (!Location6ScanStart && Location6ScanDone)
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation6ScanDone, false);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /// <summary>
|
| | | /// æ£æµæ«ç
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | private void HandleDetectScan(OtherDevice device)
|
| | | {
|
| | | //DB800.1.2
|
| | | var Location3ScanStart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolLocation3ScanStart);
|
| | | var Location3ScanDone = device.GetValue<W_PLCDBName, bool>(W_PLCDBName.wboolLocation3ScanDone);
|
| | | if (Location3ScanStart && !Location3ScanDone)
|
| | | {
|
| | | #region MyRegion
|
| | | #region 串å£è¿æ¥
|
| | | SerialPortCommunicator portCommunicator19 = new SerialPortCommunicator("COM19", 9600, "æ£æµæ«ç æª");
|
| | | bool IsConnected19 = false;
|
| | | SerialPortCommunicator portCommunicator20 = new SerialPortCommunicator("COM20", 9600, "æ£æµæ«ç æª");
|
| | | bool IsConnected20 = false;
|
| | | if (!IsConnected19) IsConnected19 = portCommunicator19.Connect();
|
| | | if (!IsConnected20) IsConnected20 = portCommunicator20.Connect();
|
| | | byte[] dataToSend1 = Encoding.ASCII.GetBytes(command);//转æåèæ°ç»
|
| | | portCommunicator19.Write(dataToSend1);
|
| | | string receiveData = portCommunicator20.ToString(Encoding.UTF8);
|
| | | byte[] dataToSend2 = Encoding.ASCII.GetBytes("PL106");//转æåèæ°ç»
|
| | | portCommunicator20.Write(dataToSend2);
|
| | | //}
|
| | | string PalletCode = portCommunicator19.ToString(Encoding.UTF8);
|
| | | var PalletCode = TcpClientExample.Start("192.168.2.122", 2001);
|
| | |
|
| | | using (var uow = _unitOfWorkManage.CreateUnitOfWork())
|
| | | try
|
| | | {
|
| | | try
|
| | | if (!PalletCode.IsNotEmptyOrNull() || PalletCode == "NoRead")
|
| | | {
|
| | | if (PalletCode.IsNotEmptyOrNull())
|
| | | {
|
| | | Dt_Boxing dt_Boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | Dt_Formula dt_Formula = _formulaService.Repository.QueryFirst(x => x.ProductCode == dt_Boxing.ProductCode);
|
| | | //åå
¥PLC
|
| | | device.SetValue(W_PLCDBName.wrealXDirectionDistance1, dt_Formula.XDirectionDistance1);
|
| | | device.SetValue(W_PLCDBName.wrealYDirectionHeight1, dt_Formula.YDirectionHeight1);
|
| | | device.SetValue(W_PLCDBName.wrealXDirectionDistance2, dt_Formula.XDirectionDistance2);
|
| | | device.SetValue(W_PLCDBName.wrealYDirectionHeight2, dt_Formula.YDirectionHeight2);
|
| | | device.SetValue(W_PLCDBName.wrealXDirectionDistance3, dt_Formula.XDirectionDistance3);
|
| | | device.SetValue(W_PLCDBName.wrealYDirectionHeight3, dt_Formula.YDirectionHeight3);
|
| | |
|
| | | //æ£æµæ«ç 宿
|
| | | device.SetValue(W_PLCDBName.wboolLocation3ScanDone, true);
|
| | |
|
| | | //æ¥æ¶æ°æ®
|
| | | float Height1 = device.GetValue<R_PLCDBName, float>(R_PLCDBName.rrealDetectHeight1);
|
| | | float Height2 = device.GetValue<R_PLCDBName, float>(R_PLCDBName.rrealDetectHeight2);
|
| | | float Height3 = device.GetValue<R_PLCDBName, float>(R_PLCDBName.rrealDetectHeight3);
|
| | |
|
| | | Dt_ProcessInfo dt_ProcessInfo = _processInfoService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | if (dt_ProcessInfo == null)
|
| | | {
|
| | | WriteInfo(device.DeviceName, "æåæªåè£
");
|
| | | device.SetValue(W_PLCDBName.wboolLocation1ScanDone, true);
|
| | | return;
|
| | | }
|
| | | dt_ProcessInfo.Height1 = Height1;
|
| | | dt_ProcessInfo.Height2 = Height2;
|
| | | dt_ProcessInfo.Height3 = Height3;
|
| | | _processInfoService.Repository.UpdateData(dt_ProcessInfo);
|
| | |
|
| | | }
|
| | | //æäº¤äºå¡
|
| | | uow.Commit();
|
| | |
|
| | | IsConnected19 = !portCommunicator19.Disconnect();
|
| | | IsConnected20 = !portCommunicator20.Disconnect();
|
| | | #endregion
|
| | | #endregion
|
| | | throw new InvalidOperationException("æç为空");
|
| | | }
|
| | | catch (Exception ex)
|
| | | Dt_Boxing dt_Boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | if (dt_Boxing == null)
|
| | | {
|
| | | WriteError(device.DeviceName, "æ£æµæ«ç æµç¨æ§è¡å¼å¸¸", ex);
|
| | | device.SetValue(W_PLCDBName.wboolLocation3ScanDone, true);
|
| | | throw new InvalidOperationException("æç为空");
|
| | | }
|
| | | if (dt_Boxing.ProductCode == null && dt_Boxing.BoxingNo == null)
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation3ScanDone, true);
|
| | | return;
|
| | | }
|
| | | Dt_Formula dt_Formula = _formulaService.Repository.QueryFirst(x => x.ProductCode == dt_Boxing.ProductCode);
|
| | | if(dt_Formula.PressNoCheckBottomPlate == 1)
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation9ScanDone, true);
|
| | | }
|
| | | else
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation9ScanDone, false);
|
| | | }
|
| | |
|
| | | //åå
¥PLC
|
| | | device.SetValue(W_PLCDBName.wrealCheckPalletCode, dt_Boxing.Id % 100);
|
| | | device.SetValue(W_PLCDBName.wrealP0P1Width, dt_Formula.P0P1Width);
|
| | | device.SetValue(W_PLCDBName.wrealP0P2Width, dt_Formula.P0P2Width);
|
| | | device.SetValue(W_PLCDBName.wrealP0P3Width, dt_Formula.P0P3Width);
|
| | | device.SetValue(W_PLCDBName.wrealP1P3Height, dt_Formula.ScrewTorqueOutput + dt_Formula.GasketHeight);
|
| | | device.SetValue(W_PLCDBName.wrealP2P3Height, dt_Formula.ProductHeight + dt_Formula.GasketHeight);
|
| | | device.SetValue(W_PLCDBName.wrealProdHeightDiff, dt_Formula.DetectHeightDiff);
|
| | | device.SetValue(W_PLCDBName.wrealScrewHeight, dt_Formula.ScrewPositionDiff);
|
| | | |
| | |
|
| | |
|
| | |
|
| | | //æ£æµæ«ç 宿
|
| | | device.SetValue(W_PLCDBName.wboolLocation3ScanDone, true);
|
| | |
|
| | |
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | WriteError(device.DeviceName, "æ£æµæ«ç æµç¨æ§è¡å¼å¸¸", ex);
|
| | | }
|
| | | }
|
| | | else if (!Location3ScanStart && Location3ScanDone)
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// æ£æµä¿¡æ¯ä¸ä¼
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <exception cref="NotImplementedException"></exception>
|
| | | private void HandleDetectInfoUpload(OtherDevice device)
|
| | | {
|
| | |
|
| | | //DB800.1.6
|
| | | var Location7ScanStart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolLocation7ScanStart);
|
| | | var Location7ScanDone = device.GetValue<W_PLCDBName, bool>(W_PLCDBName.wboolLocation7ScanDone);
|
| | | if (Location7ScanStart && !Location7ScanDone)
|
| | | {
|
| | | var PalletNum = device.GetValue<R_PLCDBName, int>(R_PLCDBName.rrealCheckPalletCode);
|
| | |
|
| | | try
|
| | | {
|
| | | if (!PalletNum.IsNotEmptyOrNull())
|
| | | {
|
| | | throw new InvalidOperationException("æç为空");
|
| | | }
|
| | | Dt_Boxing dt_Boxing = _boxingService.Repository.QueryFirst(x => x.Id % 100 == PalletNum);
|
| | |
|
| | | if (dt_Boxing == null)
|
| | | {
|
| | | throw new InvalidOperationException("æªæ¾å°ç»çæ°æ®");
|
| | | }
|
| | | Dt_Formula dt_Formula = _formulaService.Repository.QueryFirst(x => x.ProductCode == dt_Boxing.ProductCode);
|
| | |
|
| | | //æ¥æ¶æ°æ®
|
| | | decimal Height1 = (decimal)device.GetValue<R_PLCDBName, float>(R_PLCDBName.rrealDetectHeight1);//113
|
| | | decimal Height2 = (decimal)device.GetValue<R_PLCDBName, float>(R_PLCDBName.rrealDetectHeight2);//92
|
| | | decimal Height3 = (decimal)device.GetValue<R_PLCDBName, float>(R_PLCDBName.rrealDetectHeight3);//11
|
| | | if(dt_Formula.PressNoCheckBottomPlate == 1)
|
| | | {
|
| | | Height3 = 0;
|
| | | }
|
| | |
|
| | | //bool CheckUnfinished = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rrealDetectByInspectUnfinished);
|
| | |
|
| | | |
| | |
|
| | | Dt_ProcessInfo dt_ProcessInfo = _processInfoService.Repository.QueryFirst(x => x.PalletCode == dt_Boxing.PalletCode);
|
| | | int id = 0;
|
| | | if (dt_ProcessInfo == null)
|
| | | {
|
| | | dt_ProcessInfo = new Dt_ProcessInfo()
|
| | | {
|
| | | PalletCode = dt_Boxing.PalletCode,
|
| | | ProductCode = dt_Formula.ProductCode,
|
| | | ProductName = dt_Formula.ProductName,
|
| | | ProductSn = dt_Boxing.BoxingNo,
|
| | | };
|
| | | id = _processInfoService.Repository.AddData(dt_ProcessInfo);
|
| | | }
|
| | | else
|
| | | {
|
| | | id = dt_ProcessInfo.Id;
|
| | | }
|
| | | decimal? ThreadPositionHeight = Height1 - Height3 - dt_Formula.GasketHeight;
|
| | | decimal? ProductCheckHeight = Height2 - Height3 - dt_Formula.GasketHeight;
|
| | |
|
| | | dt_ProcessInfo.Id = id;
|
| | | dt_ProcessInfo.ThreadPositionHeight = ThreadPositionHeight;
|
| | | dt_ProcessInfo.ProductCheckHeight = ProductCheckHeight;
|
| | | dt_ProcessInfo.Height1 = Height1;
|
| | | dt_ProcessInfo.Height2 = Height2;
|
| | | dt_ProcessInfo.Height3 = Height3;
|
| | |
|
| | | if(
|
| | | ProductCheckHeight > dt_Formula.ProductHeight + dt_Formula.DetectHeightDiff || ProductCheckHeight < dt_Formula.ProductHeight - dt_Formula.DetectHeightDiff ||
|
| | | ThreadPositionHeight > dt_Formula.ScrewTorqueOutput + dt_Formula.ScrewPositionDiff || ThreadPositionHeight < dt_Formula.ScrewTorqueOutput - dt_Formula.ScrewPositionDiff
|
| | | )
|
| | | {
|
| | | dt_ProcessInfo.ProductStatus = 0;
|
| | | }
|
| | |
|
| | | _processInfoService.Repository.UpdateData(dt_ProcessInfo);
|
| | | //æ£æµä¿¡æ¯ä¸ä¼ 宿
|
| | | device.SetValue(W_PLCDBName.wboolLocation7ScanDone, true);
|
| | |
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | WriteError(device.DeviceName, "æ£æµæ«ç æµç¨æ§è¡å¼å¸¸", ex);
|
| | | }
|
| | | }
|
| | | else if (!Location7ScanStart && Location7ScanDone)
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation7ScanDone, false);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | /// <summary>
|
| | | /// ä¸çº¿æ«ç
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | private void HandleOfflineScan(OtherDevice device)
|
| | | {
|
| | | //DB800.1.3
|
| | |
|
| | | var Location4ScanStart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolLocation4ScanStart);
|
| | | var Location4ScanDone = device.GetValue<W_PLCDBName, bool>(W_PLCDBName.wboolLocation4ScanDone);
|
| | | if (Location4ScanStart && !Location4ScanDone)//æ§å¶æ«ç æªæ«ææçç ï¼æ ¹æ®æçç æ¥è¯¢ç»çæ°æ®ï¼å¤ææçç»å®æåæ¯å¦å·²ç»å®æææéé¶ä»¶
|
| | | {
|
| | | SerialPortCommunicator portCommunicator21 = new SerialPortCommunicator("COM21", 9600, "ä¸çº¿æ«ç æª");
|
| | | bool IsConnected21 = false;
|
| | | SerialPortCommunicator portCommunicator22 = new SerialPortCommunicator("COM22", 9600, "ä¸çº¿æ«ç æª");
|
| | | bool IsConnected22 = false;
|
| | | if (!IsConnected21) IsConnected21 = portCommunicator21.Connect();
|
| | | if (!IsConnected22) IsConnected22 = portCommunicator22.Connect();
|
| | | byte[] dataToSend1 = Encoding.ASCII.GetBytes(command);//转æåèæ°ç»
|
| | | portCommunicator21.Write(dataToSend1);
|
| | | string receiveData = portCommunicator22.ToString(Encoding.UTF8);
|
| | | byte[] dataToSend2 = Encoding.ASCII.GetBytes("PL106");//转æåèæ°ç»
|
| | | portCommunicator22.Write(dataToSend2);
|
| | | //}
|
| | | string PalletCode = portCommunicator21.ToString(Encoding.UTF8);
|
| | | var PalletCode = TcpClientExample.Start("192.168.2.123", 2001);
|
| | | using (var uow = _unitOfWorkManage.CreateUnitOfWork())
|
| | | {
|
| | | try
|
| | | {
|
| | | if (PalletCode.IsNotEmptyOrNull())
|
| | | if (!PalletCode.IsNotEmptyOrNull() || PalletCode == "NoRead")
|
| | | {
|
| | | Dt_Boxing dt_Boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | _boxingService.Repository.DeleteData(dt_Boxing);
|
| | | List<Dt_BoxingDetail> dt_BoxingDetails = _boxingDetailService.Repository.QueryData(x => x.BoxingId == dt_Boxing.Id);
|
| | | foreach (Dt_BoxingDetail dt_BoxingDetail in dt_BoxingDetails)
|
| | | {
|
| | | _boxingDetailService.Repository.DeleteDataById(dt_BoxingDetail.Id);
|
| | | }
|
| | | uow.Commit();
|
| | | //ä¸çº¿æ«ç 宿
|
| | | device.SetValue(W_PLCDBName.wboolLocation4ScanDone, true);
|
| | | throw new InvalidOperationException("æç为空");
|
| | | }
|
| | | IsConnected21 = !portCommunicator21.Disconnect();
|
| | | IsConnected22 = !portCommunicator22.Disconnect();
|
| | | Dt_Boxing dt_Boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | WriteInfo("ä¸çº¿æ«ç ç»çæ°æ®",$"{PalletCode}_boxingServiceæ¥è¯¢{dt_Boxing}");
|
| | |
|
| | | if (dt_Boxing != null)
|
| | | {
|
| | | WriteInfo("ä¸çº¿æ«ç ç»çæ°æ®", $"{PalletCode}_boxingServiceå é¤{dt_Boxing}");
|
| | | _boxingService.Repository.DeleteData(dt_Boxing);
|
| | | |
| | | List<Dt_BoxingDetail> dt_BoxingDetails = _boxingDetailService.Repository.QueryData(x => x.BoxingId == dt_Boxing.Id);
|
| | | if (dt_BoxingDetails != null)
|
| | | {
|
| | | WriteInfo("ä¸çº¿æ«ç ç»çæ°æ®", $"{PalletCode}_boxingServiceå é¤{dt_BoxingDetails}");
|
| | | _boxingDetailService.Repository.DeleteData(dt_BoxingDetails);
|
| | | }
|
| | | }
|
| | | Dt_ProcessInfo dt_ProcessInfo = _processInfoService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | WriteInfo("ä¸çº¿æ«ç ç»çæ°æ®", $"{PalletCode}_processInfoServiceæ¥è¯¢{dt_ProcessInfo}");
|
| | | if (dt_ProcessInfo != null)
|
| | | {
|
| | | Dt_ProcessInfoDetail dt_ProcessInfoDetail = new Dt_ProcessInfoDetail()
|
| | | {
|
| | | PalletCode = PalletCode,
|
| | | ProductCode = dt_ProcessInfo.ProductCode?.ToString() ?? "",
|
| | | ProductName = dt_ProcessInfo.ProductName?.ToString() ?? "",
|
| | | ProductSn = dt_ProcessInfo.ProductSn,
|
| | | PressTightenOk = dt_ProcessInfo.PressTightenOk,
|
| | | PressTightenUnfinished = dt_ProcessInfo.PressTightenUnfinished,
|
| | | ProductStatus = dt_ProcessInfo.ProductStatus,
|
| | | ScrewTorque = dt_ProcessInfo.ScrewTorque,
|
| | | ScrewAngle = dt_ProcessInfo.ScrewAngle,
|
| | | PressPressure = dt_ProcessInfo.PressPressure,
|
| | | ThreadPositionHeight = dt_ProcessInfo.ThreadPositionHeight,
|
| | | ProductCheckHeight = dt_ProcessInfo.ProductCheckHeight,
|
| | | Height1 = dt_ProcessInfo.Height1,
|
| | | Height2 = dt_ProcessInfo.Height2,
|
| | | Height3 = dt_ProcessInfo.Height3,
|
| | | Creater = "admin",
|
| | | CreateDate = DateTime.Now
|
| | | };
|
| | | _processDetailInfoService.Repository.AddData(dt_ProcessInfoDetail);
|
| | | WriteInfo("ä¸çº¿æ«ç ç»çæ°æ®", $"{PalletCode}_processInfoServiceå é¤{dt_ProcessInfo}");
|
| | | _processInfoService.DeleteData(dt_ProcessInfo);
|
| | | |
| | | }
|
| | | uow.Commit();
|
| | | //ä¸çº¿æ«ç 宿
|
| | | device.SetValue(W_PLCDBName.wboolLocation4ScanDone, true);
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | WriteError(device.DeviceName, "ä¸çº¿æ«ç æµç¨æ§è¡å¼å¸¸", ex);
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | else if (!Location4ScanStart && Location4ScanDone)
|
| | | {
|
| | | device.SetValue(W_PLCDBName.wboolLocation2ScanDone, false);
|
| | | device.SetValue(W_PLCDBName.wboolLocation4ScanDone, false);
|
| | | }
|
| | | }
|
| | | }
|