| | |
| | | float zoomFactor = (float)((double)surfaceMsg.YResolution / (double)surfaceMsg.XResolution); |
| | | int zoomHeight = (int)(zoomFactor * height); |
| | | |
| | | IntPtr zoomPtr = Marshal.AllocHGlobal(zoomHeight * (int)width * 2); |
| | | //IntPtr zoomPtr = Marshal.AllocHGlobal(zoomHeight * (int)width * 2); |
| | | //IntPtr zoomPtr = Marshal.AllocHGlobal(zoomHeight * (int)width * 4); |
| | | IntPtr zoomPtr = Marshal.AllocHGlobal(zoomHeight * (int)width * (int)IIConfig.ByteNums); |
| | | |
| | | //没有插值,默认0 |
| | | //Parallel.For(0, height, h => |
| | |
| | | // CopyMemory((IntPtr)((long)zoomPtr + width * 2 * Math.Floor(h * zoomFactor)), (IntPtr)((long)bufferPointer + width * 2 * h), width * 2); |
| | | // }); |
| | | |
| | | if (IIConfig.ByteNums == GocatorDataByteNums.Byte2) |
| | | { |
| | | //使用上一行原有数据 |
| | | Parallel.For(0, zoomHeight, h => |
| | | { |
| | |
| | | |
| | | CopyMemory((IntPtr)((long)zoomPtr + width * 2 * h), (IntPtr)((long)bufferPointer + width * 2 * originHeightIndex), width * 2); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | //使用上一行原有数据 |
| | | Parallel.For(0, zoomHeight, h => |
| | | { |
| | | int originHeightIndex = (int)Math.Floor((double)height * h / (double)zoomHeight); |
| | | |
| | | ////使用上一行原有数据 |
| | | //Parallel.For(0, zoomHeight, h => |
| | | //{ |
| | | // int originHeightIndex = (int)Math.Floor((double)height * h / (double)zoomHeight); |
| | | byte[] rowBuffer = new byte[width * 4]; |
| | | Parallel.For(0, width, w => |
| | | { |
| | | rowBuffer[w * 4 + 2] = Marshal.ReadByte(bufferPointer, (int)(width * 2 * originHeightIndex + w * 2)); |
| | | rowBuffer[w * 4 + 3] = Marshal.ReadByte(bufferPointer, (int)(width * 2 * originHeightIndex + w * 2 + 1)); |
| | | }); |
| | | |
| | | // byte[] rowBuffer = new byte[width * 4]; |
| | | // Parallel.For(0, width, w => |
| | | // { |
| | | // rowBuffer[w * 4 + 2] = Marshal.ReadByte(bufferPointer, (int)(width * 2 * originHeightIndex + w * 2)); |
| | | // rowBuffer[w * 4 + 3] = Marshal.ReadByte(bufferPointer, (int)(width * 2 * originHeightIndex + w * 2 + 1)); |
| | | // }); |
| | | |
| | | // Marshal.Copy(rowBuffer, 0, (IntPtr)((long)zoomPtr + width * 2 * h), rowBuffer.Length); |
| | | //}); |
| | | Marshal.Copy(rowBuffer, 0, (IntPtr)((long)zoomPtr + width * 2 * h), rowBuffer.Length); |
| | | }); |
| | | } |
| | | |
| | | if (imgSet != null) |
| | | { |
| | | imgSet.HImage = new HImage(); |
| | | imgSet.HImage.GenImage1("uint2", (int)width, zoomHeight, zoomPtr); |
| | | |
| | | //imgSet.HImage.GenImage1("uint2", (int)width, zoomHeight, zoomPtr); |
| | | //imgSet.HImage.GenImage1("int4", (int)width, zoomHeight, zoomPtr); |
| | | imgSet.HImage.GenImage1(IIConfig.ByteNums == GocatorDataByteNums.Byte2 ? "uint2" : "int4", (int)width, zoomHeight, zoomPtr); |
| | | |
| | | imgSet.HImage_2 = new HImage(); |
| | | imgSet.HImage_2.GenImage1("uint2", (int)width, zoomHeight, zoomPtr); |
| | | |
| | | imgSet.HImage_2 = imgSet.HImage.Clone(); |
| | | //imgSet.HImage_2.GenImage1("uint2", (int)width, zoomHeight, zoomPtr); |
| | | //imgSet.HImage_2.GenImage1("int4", (int)width, zoomHeight, zoomPtr); |
| | | //imgSet.HImage_2.GenImage1(IIConfig.ByteNums == GocatorDataByteNums.Byte2 ? "uint2" : "int4", (int)width, zoomHeight, zoomPtr); |
| | | |
| | | LaserScanParam para = new LaserScanParam() |
| | | { |
| | |
| | | |
| | | if (!string.IsNullOrWhiteSpace(opConfig.JobName) && _currentJob != opConfig.JobName) |
| | | { |
| | | _currentJob = sensor.DefaultJob = opConfig.JobName; |
| | | LogAsync(DateTime.Now, $"{Name}切换当前任务为{opConfig.JobName}", ""); |
| | | sensor.CopyFile(_currentJob, "_live.job"); |
| | | |
| | | bool isChanged = false; |
| | | sensor.LoadedJob(ref _currentJob, ref isChanged); |
| | | LogAsync(DateTime.Now, $"{Name}当前任务{_currentJob}", ""); |
| | | } |
| | | |
| | | sensor.Flush(); |
| | |
| | | _currentExposure = (float)sensor.Setup.GetExposure(GoRole.Main); |
| | | } |
| | | |
| | | _currentJob = sensor.DefaultJob; |
| | | if (!string.IsNullOrWhiteSpace(IIConfig.DefaultJob) && _currentJob != IIConfig.DefaultJob) |
| | | { |
| | | //_currentJob = sensor.DefaultJob = IIConfig.DefaultJob; |
| | | string currentJob = IIConfig.DefaultJob; |
| | | bool isChanged = false; |
| | | sensor.LoadedJob(ref currentJob, ref isChanged); |
| | | sensor.LoadedJob(ref _currentJob, ref isChanged); |
| | | LogAsync(DateTime.Now, $"{Name}当前任务{_currentJob}", ""); |
| | | |
| | | if (!isChanged) |
| | | if (!string.IsNullOrWhiteSpace(IIConfig.DefaultJob) && IIConfig.DefaultJob != _currentJob) |
| | | { |
| | | throw new ProcessException($"{Name}未成功切换至任务{IIConfig.DefaultJob}"); |
| | | } |
| | | sensor.CopyFile(IIConfig.DefaultJob, "_live.job"); |
| | | //_currentJob = IIConfig.DefaultJob; |
| | | |
| | | sensor.LoadedJob(ref _currentJob, ref isChanged); |
| | | LogAsync(DateTime.Now, $"{Name}当前任务{_currentJob}", ""); |
| | | } |
| | | |
| | | sensor.Flush(); |