更新提交
This commit is contained in:
		
							parent
							
								
									3c8f5c2151
								
							
						
					
					
						commit
						bfc82a5d8f
					
				| 
						 | 
					@ -23,6 +23,7 @@ using Unity;
 | 
				
			||||||
using DM_Weight.msg;
 | 
					using DM_Weight.msg;
 | 
				
			||||||
using DM_Weight.Views;
 | 
					using DM_Weight.Views;
 | 
				
			||||||
using System.Reflection;
 | 
					using System.Reflection;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.Port
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -646,8 +647,9 @@ namespace DM_Weight.Port
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private byte[] GetBufferByPort(SerialPort serialPort, int length, int timeout)
 | 
					        private byte[] GetBufferByPort(SerialPort serialPort, int length, int timeout, string operation = "")
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
            byte[] buffer = new byte[length];
 | 
					            byte[] buffer = new byte[length];
 | 
				
			||||||
            //try
 | 
					            //try
 | 
				
			||||||
            //{
 | 
					            //{
 | 
				
			||||||
| 
						 | 
					@ -657,10 +659,25 @@ namespace DM_Weight.Port
 | 
				
			||||||
            while (_length != length && end.Subtract(start).TotalMilliseconds < timeout)
 | 
					            while (_length != length && end.Subtract(start).TotalMilliseconds < timeout)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                _length = serialPort.BytesToRead;
 | 
					                _length = serialPort.BytesToRead;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (_length == 0 && operation.Equals("单支查数"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Thread.Sleep(500);
 | 
				
			||||||
 | 
					                    byte[] bufferWrite = new byte[] { 0xaa, (byte)(0xf0 + DrawerNo), 0x01, 0x00, 0x00, 0x00, 0x00, 0xee };
 | 
				
			||||||
 | 
					                    canBusSerial.Write(bufferWrite, 0, 8);
 | 
				
			||||||
 | 
					                    logger.Info($"再次发送OpenStorage:{Convert.ToHexString(bufferWrite)};{end}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                end = DateTime.Now;
 | 
					                end = DateTime.Now;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_length != length)
 | 
					            if (_length != length)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					                if (_length != 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    byte[] _buffer = new byte[_length];
 | 
				
			||||||
 | 
					                    serialPort.Read(_buffer, 0, _length);
 | 
				
			||||||
 | 
					                    logger.Info($"交互超时回复:{Convert.ToHexString(buffer)}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
 | 
					                throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            serialPort.Read(buffer, 0, length);
 | 
					            serialPort.Read(buffer, 0, length);
 | 
				
			||||||
| 
						 | 
					@ -671,10 +688,10 @@ namespace DM_Weight.Port
 | 
				
			||||||
            //}
 | 
					            //}
 | 
				
			||||||
            return buffer;
 | 
					            return buffer;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        private Task<byte[]> GetBufferByPort(SerialPort serialPort, int length)
 | 
					        private Task<byte[]> GetBufferByPort(SerialPort serialPort, int length,string operation="")
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return Task.Run(() => GetBufferByPort(serialPort, length, 3000));
 | 
					            return Task.Run(() => GetBufferByPort(serialPort, length, 3000,operation));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -818,7 +835,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
            logger.Info($"单支板发送库位数量查询【{string.Join(",", buffer)}】");
 | 
					            logger.Info($"单支板发送库位数量查询【{string.Join(",", buffer)}】");
 | 
				
			||||||
            canBusSerial.Write(buffer, 0, 8);
 | 
					            canBusSerial.Write(buffer, 0, 8);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return await GetBufferByPort(canBusSerial, 13);
 | 
					            return await GetBufferByPort(canBusSerial, 13, "单支查数");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // 获取单个单支板药品数量
 | 
					        // 获取单个单支板药品数量
 | 
				
			||||||
        public async Task<byte[]> CheckQuantityByCol(int DrawerNo, int colNo)
 | 
					        public async Task<byte[]> CheckQuantityByCol(int DrawerNo, int colNo)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue