| | |
| | | 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;
|
| | | SerialPortCommunicator portCommunicator17 = new SerialPortCommunicator("COM17", 9600, "åè£
æ«ç æª");
|
| | | static bool IsConnected17 = false;
|
| | | SerialPortCommunicator portCommunicator18 = new SerialPortCommunicator("COM18", 9600, "åè£
æ«ç æª");
|
| | | static bool IsConnected18 = false;
|
| | | SerialPortCommunicator portCommunicator19 = new SerialPortCommunicator("COM19", 9600, "åè£
æ«ç æª");
|
| | | static bool IsConnected19 = false;
|
| | | SerialPortCommunicator portCommunicator20 = new SerialPortCommunicator("COM20", 9600, "åè£
æ«ç æª");
|
| | | static bool IsConnected20 = false;
|
| | | public Task Execute(IJobExecutionContext context)
|
| | | {
|
| | |
|
| | |
| | | if (Location1ScanStart && !Location1ScanDone)//æ§å¶æ«ç æªæ«ææçç ï¼æ ¹æ®æçç æ¥è¯¢ç»çæ°æ®ï¼å¤ææçç»å®æåæ¯å¦å·²ç»å®æææéé¶ä»¶
|
| | | {
|
| | | #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);//转æåèæ°ç»
|
| | |
| | | var boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | if (boxing == null)
|
| | | {
|
| | | WriteInfo(device.DeviceName, "空æç");
|
| | | device.SetValue(W_PLCDBName.wboolLocation1ScanDone, true);
|
| | | WriteError(device.DeviceName, "空æç");
|
| | | return;
|
| | | }
|
| | | List<Dt_BoxingDetail> dt_BoxingDetails = _boxingDetailService.Repository.QueryData(x => x.BoxingId == boxing.Id);
|
| | |
| | | if (dt_Formula == null)
|
| | | {
|
| | | WriteError(device.DeviceName, "æ æåé
æ¹");
|
| | | device.SetValue(W_PLCDBName.wboolLocation1ScanDone, true);
|
| | | 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, "é¶ä»¶æé®é¢ï¼è¯·å¤ç");
|
| | | device.SetValue(W_PLCDBName.wboolLocation1ScanDone, true);
|
| | | return;
|
| | | }
|
| | | }
|
| | |
| | | {
|
| | | #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);//转æåèæ°ç»
|
| | |
| | | if (PalletCode.IsNotEmptyOrNull())
|
| | | {
|
| | | Dt_Boxing dt_Boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | if (dt_Boxing == null)
|
| | | {
|
| | | WriteInfo(device.DeviceName, "空æç");
|
| | | 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.wrealProductLength, dt_Formula.ProductLength);
|
| | |
| | | {
|
| | | #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);//转æåèæ°ç»
|
| | |
| | | if (PalletCode.IsNotEmptyOrNull())
|
| | | {
|
| | | Dt_Boxing dt_Boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | if (dt_Boxing == null)
|
| | | {
|
| | | WriteInfo(device.DeviceName, "空æç");
|
| | | device.SetValue(W_PLCDBName.wboolLocation1ScanDone, true);
|
| | | return;
|
| | | }
|
| | | Dt_Formula dt_Formula = _formulaService.Repository.QueryFirst(x => x.ProductCode == dt_Boxing.ProductCode);
|
| | | //åå
¥PLC
|
| | | device.SetValue(W_PLCDBName.wrealXDirectionDistance1, dt_Formula.XDirectionDistance1);
|
| | |
| | | var Location4ScanDone = device.GetValue<W_PLCDBName, bool>(W_PLCDBName.wboolLocation4ScanDone);
|
| | | if (Location4ScanStart && !Location4ScanDone)//æ§å¶æ«ç æªæ«ææçç ï¼æ ¹æ®æçç æ¥è¯¢ç»çæ°æ®ï¼å¤ææçç»å®æåæ¯å¦å·²ç»å®æææéé¶ä»¶
|
| | | {
|
| | | if (!IsConnected17) IsConnected17 = portCommunicator17.Connect();
|
| | | if (!IsConnected18) IsConnected18 = portCommunicator18.Connect();
|
| | | 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);//转æåèæ°ç»
|
| | | portCommunicator17.Write(dataToSend1);
|
| | | string receiveData = portCommunicator18.ToString(Encoding.UTF8);
|
| | | portCommunicator21.Write(dataToSend1);
|
| | | string receiveData = portCommunicator22.ToString(Encoding.UTF8);
|
| | | byte[] dataToSend2 = Encoding.ASCII.GetBytes("PL106");//转æåèæ°ç»
|
| | | portCommunicator18.Write(dataToSend2);
|
| | | portCommunicator22.Write(dataToSend2);
|
| | | //}
|
| | | string PalletCode = portCommunicator17.ToString(Encoding.UTF8);
|
| | | string PalletCode = portCommunicator21.ToString(Encoding.UTF8);
|
| | | using (var uow = _unitOfWorkManage.CreateUnitOfWork())
|
| | | {
|
| | | try
|
| | |
| | | if (PalletCode.IsNotEmptyOrNull())
|
| | | {
|
| | | Dt_Boxing dt_Boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
|
| | | if (dt_Boxing == null)
|
| | | {
|
| | | WriteInfo(device.DeviceName, "该æç为空æç");
|
| | | device.SetValue(W_PLCDBName.wboolLocation4ScanDone, true);
|
| | | return;
|
| | | }
|
| | |
|
| | | _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)
|
| | |
| | | //ä¸çº¿æ«ç 宿
|
| | | device.SetValue(W_PLCDBName.wboolLocation4ScanDone, true);
|
| | | }
|
| | | IsConnected17 = !portCommunicator17.Disconnect();
|
| | | IsConnected18 = !portCommunicator18.Disconnect();
|
| | | IsConnected21 = !portCommunicator21.Disconnect();
|
| | | IsConnected22 = !portCommunicator22.Disconnect();
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|