| | |
| | | using HslCommunication; |
| | | using HslCommunication.Core; |
| | | using Microsoft.VisualBasic.FileIO; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
| | | using Quartz; |
| | | using SixLabors.ImageSharp.PixelFormats; |
| | | using System; |
| | |
| | | _formulaDetailService = formulaDetailService; |
| | | _processInfoService = processInfoService; |
| | | } |
| | | |
| | | 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"åéåæ¢è§£ç å½ä»¤ |
| | | SerialPortCommunicator portCommunicator1 = new SerialPortCommunicator("COM1", 9600, "ä¸çº¿æ«ç æª"); |
| | | static bool IsConnected1 = false; |
| | | SerialPortCommunicator portCommunicator2 = new SerialPortCommunicator("COM2", 9600, "ä¸çº¿æ«ç æª"); |
| | | static bool IsConnected2 = false; |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | |
| | |
| | | OtherDevice device = (OtherDevice)value; |
| | | try |
| | | { |
| | | |
| | | 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 Location1ScanDone = device.GetValue<W_PLCDBName, bool>(W_PLCDBName.wboolLocation1ScanDone); |
| | | if (Location1ScanStart && !Location1ScanDone)//æ§å¶æ«ç æªæ«ææçç ï¼æ ¹æ®æçç æ¥è¯¢ç»çæ°æ®ï¼å¤ææçç»å®æåæ¯å¦å·²ç»å®æææéé¶ä»¶ |
| | | { |
| | | #region MyRegion |
| | | #region 串å£è¿æ¥ |
| | | 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); |
| | | if (PalletCode.IsNotEmptyOrNull()) |
| | | { |
| | | var boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode); |
| | | } |
| | | IsConnected1 = !portCommunicator1.Disconnect(); |
| | | IsConnected2 = !portCommunicator2.Disconnect(); |
| | | #endregion |
| | | #endregion |
| | | |
| | | device.SetValue(W_PLCDBName.wboolLocation1ScanDone, true); |
| | | } |
| | | else if (!Location1ScanDone && Location1ScanStart) |
| | | else if (!Location1ScanStart && Location1ScanDone) |
| | | { |
| | | device.SetValue(W_PLCDBName.wboolLocation1ScanDone, false); |
| | | } |