Commit 6c23f80f 张东亮

aoi,获取库位时添加料盘总厚度便于分配库位

1 个父辈 919a9f63
正在显示 35 个修改的文件 包含 2523 行增加192 行删除
...@@ -65,10 +65,12 @@ ...@@ -65,10 +65,12 @@
<Compile Include="util\MyWebClient.cs"> <Compile Include="util\MyWebClient.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="util\ProcessUtil.cs" />
<Compile Include="util\TcpClient.cs" /> <Compile Include="util\TcpClient.cs" />
<Compile Include="util\TcpServer.cs" /> <Compile Include="util\TcpServer.cs" />
<Compile Include="util\UdpServer.cs" /> <Compile Include="util\UdpServer.cs" />
<Compile Include="util\WaitUtil.cs" /> <Compile Include="util\WaitUtil.cs" />
<Compile Include="util\WindowUtil.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<WCFMetadata Include="Service References\" /> <WCFMetadata Include="Service References\" />
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Common
{
/// <summary>
/// 软件管理工具
/// </summary>
public class ProcessUtil
{
/// <summary>
/// 设置自动启动
/// </summary>
/// <param name="strName"></param>
/// <param name="value"></param>
public static void AutoRun(string strName, bool value)
{
try
{
//创建启动对象
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
//设置运行文件
startInfo.FileName = System.Windows.Forms.Application.StartupPath + "\\AuToRunManager.exe";
//设置启动参数
startInfo.Arguments = String.Join(" ", new string[2] { strName, value.ToString() });
//设置启动动作,确保以管理员身份运行
startInfo.Verb = "runas";
//如果不是管理员,则启动UAC
System.Diagnostics.Process.Start(startInfo);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
public static Process StartProcess(string appName, string baseDir = @".\",int waitIdle=5000)
{
try
{
Process process = new Process();
process.StartInfo = new System.Diagnostics.ProcessStartInfo();
process.StartInfo.FileName = appName+".exe";
process.StartInfo.WorkingDirectory = baseDir;
process.Start();
process.WaitForInputIdle(waitIdle);
return process;
}
catch (Exception ex)
{
}
return null;
}
public static Process IsRun(Process process)
{
Process processRun = new Process();
try
{
System.Diagnostics.Process[] processList = System.Diagnostics.Process.GetProcesses
();
foreach (System.Diagnostics.Process process2 in processList)
{
if (process2.Id == process.Id)
{
processRun = process;
}
}
}
catch { }
return processRun;
}
public static bool CloseProcess(Process process)
{
bool sc = false;
try
{
System.Diagnostics.Process[] processList = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process process2 in processList)
{
if (process2.Id == process.Id)
{
process.Kill(); //结束进程
sc = process.WaitForExit(100000);
}
}
}
catch { sc = true; }
return sc;
}
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace Common
{
public class WindowUtil
{
public const int WM_CLOSE = 0x0010;
static List<Process> SubProcesses = new List<Process>();
public static Process OpenExe(Panel panel, string appName, string titleName, string baseDir = @".\")
{
if (appName == null || appName == string.Empty) return null;
Process process = null;
IntPtr appWin = IntPtr.Zero;
try
{
process = ProcessUtil.StartProcess(appName, baseDir);
}
catch (Exception ex)
{
// MessageBox.Show(fm, ex.Message, "Error");
return process;
}
return process;
}
public static bool PutIntoForm(Panel panel, string titleName, out IntPtr appWin)
{
appWin = FindWindow(null, titleName);
if (appWin == IntPtr.Zero)
{
appWin = GetDesktopWindows($"{titleName}");
}
// Put it into this form
SetParent(appWin, panel.Handle);
// Remove border and whatnot
// SetWindowLong(appWin, GWL_STYLE, WS_VISIBLE);
// Move the window to overlay it on this window
return MoveWindow(appWin, 0, 0, panel.Width + 2, panel.Height, true);
}
public static void Resize(Panel panel, string titleName)
{
IntPtr appWin = FindWindow(null, titleName);
if (appWin != IntPtr.Zero)
WindowUtil.MoveWindow(appWin, 0, 0, panel.Width, panel.Height, true);
}
public static void RemoveFromForm(string titleName)
{
IntPtr appWin = FindWindow(null, titleName);
// Put it into this form
SetParent(appWin, IntPtr.Zero);
}
/// <summary>
/// 找到某个窗口与给出的类别名和窗口名相同窗口
/// </summary>
/// <param name="lpClassName">类别名</param>
/// <param name="lpWindowName">窗口名</param>
/// <returns>成功找到返回窗口句柄,否则返回null</returns>
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
/// <summary>
/// 切换到窗口并把窗口设入前台,类似 SetForegroundWindow方法的功能
/// </summary>
/// <param name="hWnd">窗口句柄</param>
/// <param name="fAltTab">True代表窗口正在通过Alt/Ctrl +Tab被切换</param>
[DllImport("user32.dll ", SetLastError = true)]
public static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab);
/// <summary>
/// 设置窗口的显示状态
/// </summary>
/// <param name="hWnd">窗口句柄</param>
/// <param name="cmdShow">指示窗口如何被显示</param>
/// <returns>如果窗体之前是可见,返回值为非零;如果窗体之前被隐藏,返回值为零</returns>
[DllImport("user32.dll", EntryPoint = "ShowWindow", CharSet = CharSet.Auto)]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32.dll", SetLastError = true)]
private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
/// <summary>
/// 改变指定窗口的位置和尺寸
/// </summary>
/// <param name="hwnd">窗口句柄</param>
/// <param name="x">窗口左侧的新位置</param>
/// <param name="y">窗口顶部的新位置</param>
/// <param name="nWidth">窗口的新宽度</param>
/// <param name="nHeight">窗口的新高度</param>
/// <param name="bRepaint">指示是否重新绘制窗口。 如果此参数为 TRUE,窗口将收到消息。 如果参数为 FALSE,则不会重新绘制任何类型的参数。 这适用于工作区、非client 区域 (,包括标题栏和滚动条) ,以及由于移动子窗口而发现父窗口的任何部分</param>
/// <returns>该函数成功,则返回值为非零值</returns>
[DllImport("user32.dll", SetLastError = true)]
private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int nWidth, int nHeight, bool bRepaint);
[DllImport("user32.dll")]
private static extern bool EnumWindows(WNDENUMPROC lpEnumFunc, int lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, string lparam);
[DllImport("user32.dll", EntryPoint = "PostMessage")]
public static extern int PostMessage(IntPtr hwnd, int Msg, int wParam, int lParam);
[DllImport("user32.dll")]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")]
private static extern int GetWindowTextW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")]
private static extern int GetClassNameW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpString, int nMaxCount);
private delegate bool WNDENUMPROC(IntPtr hWnd, int lParam);
//寻找系统的全部窗口
public static WindowInfo[] GetAllDesktopWindows()
{
List<WindowInfo> wndList = new List<WindowInfo>();
EnumWindows(delegate (IntPtr hWnd, int lParam)
{
WindowInfo wnd = new WindowInfo();
StringBuilder sb = new StringBuilder(256);
//get hwnd
wnd.hWnd = hWnd;
//get window name
GetWindowTextW(hWnd, sb, sb.Capacity);
wnd.szWindowName = sb.ToString();
//get window class
GetClassNameW(hWnd, sb, sb.Capacity);
wnd.szClassName = sb.ToString();
Console.WriteLine("Window handle=" + wnd.hWnd.ToString().PadRight(20) + " szClassName=" + wnd.szClassName.PadRight(20) + " szWindowName=" + wnd.szWindowName);
//add it into list
wndList.Add(wnd);
return true;
}, 0);
return wndList.ToArray();
}
public static IntPtr GetDesktopWindows(string windowName, StringComparison comparison = StringComparison.Ordinal)
{
WindowInfo[] allWindow = WindowUtil.GetAllDesktopWindows();
var wnd = allWindow.FirstOrDefault(s => s.szWindowName.Equals(windowName, comparison));
return wnd.hWnd;
}
}
public struct WindowInfo
{
public IntPtr hWnd;
public string szWindowName;
public string szClassName;
}
}
{"methodMap":"{\"L01\":\"{\\\"SamePercent\\\":80.0,\\\"MethodName\\\":\\\"L01\\\",\\\"FullTypeName\\\":\\\"AOI.AoiTemplateMethod\\\",\\\"PathDataStr\\\":\\\"{\\\\\\\"Points\\\\\\\":[{\\\\\\\"IsEmpty\\\\\\\":false,\\\\\\\"X\\\\\\\":317.0,\\\\\\\"Y\\\\\\\":483.666626},{\\\\\\\"IsEmpty\\\\\\\":false,\\\\\\\"X\\\\\\\":553.6666,\\\\\\\"Y\\\\\\\":483.666626},{\\\\\\\"IsEmpty\\\\\\\":false,\\\\\\\"X\\\\\\\":553.6666,\\\\\\\"Y\\\\\\\":593.666565},{\\\\\\\"IsEmpty\\\\\\\":false,\\\\\\\"X\\\\\\\":317.0,\\\\\\\"Y\\\\\\\":593.666565}],\\\\\\\"Types\\\\\\\":\\\\\\\"AAEBgQ==\\\\\\\"}\\\"}\"}"}
\ No newline at end of file \ No newline at end of file
{"methodMap":"{\"R01\":\"{\\\"SamePercent\\\":80.0,\\\"MethodName\\\":\\\"R01\\\",\\\"FullTypeName\\\":\\\"AOI.AoiTemplateMethod\\\",\\\"PathDataStr\\\":\\\"{\\\\\\\"Points\\\\\\\":[{\\\\\\\"IsEmpty\\\\\\\":false,\\\\\\\"X\\\\\\\":1452.0,\\\\\\\"Y\\\\\\\":588.0},{\\\\\\\"IsEmpty\\\\\\\":false,\\\\\\\"X\\\\\\\":1692.0,\\\\\\\"Y\\\\\\\":588.0},{\\\\\\\"IsEmpty\\\\\\\":false,\\\\\\\"X\\\\\\\":1692.0,\\\\\\\"Y\\\\\\\":704.0},{\\\\\\\"IsEmpty\\\\\\\":false,\\\\\\\"X\\\\\\\":1452.0,\\\\\\\"Y\\\\\\\":704.0}],\\\\\\\"Types\\\\\\\":\\\\\\\"AAEBgQ==\\\\\\\"}\\\"}\"}"}
\ No newline at end of file \ No newline at end of file
...@@ -38,6 +38,9 @@ ...@@ -38,6 +38,9 @@
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="AOI">
<HintPath>..\XLRStoreClient\bin\Debug\AOI\AOI.dll</HintPath>
</Reference>
<Reference Include="Asa.RFID.HiStation"> <Reference Include="Asa.RFID.HiStation">
<HintPath>..\..\dll\RFID\Asa.RFID.HiStation.dll</HintPath> <HintPath>..\..\dll\RFID\Asa.RFID.HiStation.dll</HintPath>
</Reference> </Reference>
...@@ -81,6 +84,8 @@ ...@@ -81,6 +84,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="deviceLibrary\Msg.cs" /> <Compile Include="deviceLibrary\Msg.cs" />
<Compile Include="deviceLibrary\ReelCheckCamera.cs" />
<Compile Include="deviceLibrary\SignalMonitor.cs" />
<Compile Include="manager\agvClient\AgvClient.cs" /> <Compile Include="manager\agvClient\AgvClient.cs" />
<Compile Include="manager\agvClient\DoorInfo.cs" /> <Compile Include="manager\agvClient\DoorInfo.cs" />
<Compile Include="manager\BufferDataManager.cs" /> <Compile Include="manager\BufferDataManager.cs" />
...@@ -126,8 +131,11 @@ ...@@ -126,8 +131,11 @@
<Compile Include="manager\model\DeviceStep.cs"> <Compile Include="manager\model\DeviceStep.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="WindowManager.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Config\A料口\AOI.bmp" />
<Content Include="Config\B料口\AOI.bmp" />
<Content Include="device_config.xml"> <Content Include="device_config.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
...@@ -219,6 +227,8 @@ ...@@ -219,6 +227,8 @@
<Content Include="Config\linePositions.csv"> <Content Include="Config\linePositions.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<None Include="Config\A料口\AOI.data" />
<None Include="Config\B料口\AOI.data" />
<None Include="packages.config" /> <None Include="packages.config" />
<Content Include="SDK\MotorMaster.config"> <Content Include="SDK\MotorMaster.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
......
using Common;
using DeviceLibrary;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceLibrary
{
public class WindowManager
{
public static List<WindInfo> windInfos = new List<WindInfo>();
public static bool NeedRefresh = false;
static string baseDir = Application.StartupPath + @"\Modules\";
public static void Start()
{
foreach (var item in windInfos)
{
try
{
if (ReelCheckCamera.CheckIPServiceAlive())
{
ReelCheckCamera.CloseIPService();
Thread.Sleep(3000);
}
item.ProcessInfo = ProcessUtil.StartProcess(item.Name, baseDir + $"{item.Name}\\", 60000);
}
catch (Exception ex)
{
LogUtil.error($"程序{item.Name}启动失败", ex);
}
}
NeedRefresh = true;
}
public static void Stop()
{
foreach (var item in windInfos)
{
try
{
ProcessUtil.CloseProcess(item.ProcessInfo);
if (ReelCheckCamera.CheckIPServiceAlive())
{
ReelCheckCamera.CloseIPService();
}
}
catch (Exception ex)
{
LogUtil.error($"程序{item.Name}关闭失败", ex);
}
}
NeedRefresh = true;
}
public static void InitShow()
{
foreach (var item in windInfos)
{
item.MoveWindowIsOk = WindowUtil.PutIntoForm(item.Parent, item.Name, out IntPtr intPtr);
item.WindowHandle = intPtr;
if (intPtr == IntPtr.Zero)
{
if (ReelCheckCamera.CheckIPServiceAlive())
{
ReelCheckCamera.CloseIPService();
}
}
}
}
public static void Show()
{
foreach (var item in windInfos)
{
item.Parent.Invoke(new Action(() =>
{
item.MoveWindowIsOk = WindowUtil.PutIntoForm(item.Parent, item.Name, out IntPtr intPtr);
item.WindowHandle = intPtr;
}));
}
}
}
public class WindInfo
{
public string Name { get; set; }
public IntPtr WindowHandle { get; set; }
public Panel Parent { get; set; }
public Process ProcessInfo { get; set; }
public bool MoveWindowIsOk { get; set; }
public const string IPCamera = "IPCamera";
}
}
using AOI;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace DeviceLibrary
{
public class ReelCheckCamera
{
public static Dictionary<string, IntPtr> CamerHandleMap { get; set; } = null;
static object grabLoc = new object();
static string IPCameraServiceIP = ConfigHelper.Config.Get("IPCamera_ServiceIp", "localhost");
static int IPCameraServicePort = ConfigHelper.Config.Get("IPCamera_ServicePort", 8088);
public static bool GrabOneImg(string camerName, out Bitmap bitmap, out string imgPath)
{
bitmap = null;
imgPath = "";
// if (Monitor.TryEnter(grabLoc, 500))
// {
try
{
bitmap = null;
string url = $"http://{IPCameraServiceIP}:{IPCameraServicePort}/cam/grabOneImg?camName={camerName}";
string result = HttpHelper.Get(url);
if (!string.IsNullOrEmpty(result))
{
var res = JsonHelper.DeserializeJsonToObject<Result>(result);
if (res != null && res.code == 0)
{
using (FileStream fs = new FileStream(res.msg, FileMode.Open, FileAccess.Read))
{
bitmap = (Bitmap)Bitmap.FromStream(fs);
imgPath = res.msg;
return true;
}
}
else
{
LogUtil.LOGGER.Error($"{camerName} 图像采集失败");
}
}
else
{
LogUtil.LOGGER.Error($"{camerName} 图像采集失败");
}
}
finally
{ //Monitor.Exit(grabLoc);
}
//}
//else
//{
// LogUtil.LOGGER.Warn("GrabOneImg 未得到锁");
//}
return false;
//if (!VideoManager.IsOpen(camerName))
//{
// LogUtil.info($"CameraManager 相机{camerName}还未打开,打开相机 ");
// VideoManager.Open(CamerHandleMap);
//}
//if (!VideoManager.IsOpen(camerName))
//{
// LogUtil.info($"CameraManager 相机{camerName} 打开失败 ");
// return false;
//}
//return VideoManager.GrabOneImg(camerName, out bitmap);
return true;
}
public static bool CheckIPServiceAlive()
{
try
{
string url = $"http://{IPCameraServiceIP}:{IPCameraServicePort}/isAlive";
string result = HttpHelper.Get(url);
if (!string.IsNullOrEmpty(result))
{
var res = JsonHelper.DeserializeJsonToObject<Result>(result);
if (res != null && res.code == 0)
{
return true;
}
}
}
catch (Exception ex)
{
}
return false;
}
public static void CloseIPService()
{
try
{
string url = $"http://{IPCameraServiceIP}:{IPCameraServicePort}/closeApp";
HttpHelper.Get(url, Encoding.UTF8);
}
catch (Exception ex)
{
}
}
static Stream BitMapToStream(Bitmap bitmap)
{
try
{
using (MemoryStream ms = new MemoryStream())
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(ms, bitmap);
return ms;
}
}
catch (Exception e)
{
LogUtil.LOGGER.Error("BitMapToStream", e);
}
return null;
}
public static void Close()
{
//VideoManager.Close();
}
private static Dictionary<string, AoiProject> aoiProjectMap = new Dictionary<string, AoiProject>();
private static AoiProject GetAOIProject(string projectName, string machineSide)
{
try
{
string key = $"{machineSide.ToString()}-{projectName}";
if (!aoiProjectMap.ContainsKey(key))
{
string path = Application.StartupPath + $"\\Config\\{machineSide}\\{projectName}";
AoiProject aoiProject = AoiProject.Load(path, out string msg);
if (aoiProject == null || msg != "")
{
LogUtil.LOGGER.Error("加载 AoiProject " + path + " 失败:" + msg);
return null;
}
else
{
LogUtil.LOGGER.Info("加载 AoiProject " + path);
aoiProjectMap.Add(key, aoiProject);
}
}
return aoiProjectMap[key];
}
catch (Exception e)
{
LogUtil.LOGGER.Error("GetAOIProject 出错: " + e.ToString());
}
return null;
}
public static void ClearProject()
{
if (aoiProjectMap != null && aoiProjectMap.Count > 0)
{
aoiProjectMap.Clear();
LogUtil.info("重置 AoiProject");
}
}
static bool autoStart = ConfigHelper.Config.Get($"IPCamera_AutoStartIPCamera", true);
static object aoiLoc = new object();
/// <summary>
/// 检测是否有料
/// </summary>
/// <param name="cameraName"></param>
/// <param name="projectName"></param>
/// <returns>true:有料</returns>
public static bool AOICheck(string deviceName, string projectName, string machineSide, out string resList)
{
resList = "";
string cameraName= ConfigHelper.Config.Get($"IPCamera_CameraName", "cam1");
if (!ConfigHelper.Config.Get("IPCamera_EnableAOI", false))
{
//无料
return false;
}
if (Monitor.TryEnter(aoiLoc, 3000))
{
Bitmap bitmap = null;
try
{
if (autoStart)
{
if (!CheckIPServiceAlive())
{
CloseIPService();
Thread.Sleep(1000);
string baseDir = Application.StartupPath + @"\Modules\";
WindowManager.Start();
LogUtil.error("监控相机未启动,启动相机");
return true;
}
}
else if (!CheckIPServiceAlive())
{
//RobotManage.mainMachine.ShowMsg("检测到监控相机未启动", MsgLevel.warning);
}
bool result = GrabOneImg(cameraName, out _, out string imgPath);
if (result && !string.IsNullOrEmpty(imgPath))
{
AoiProject project = GetAOIProject(projectName, machineSide);
if (project != null)
{
using (FileStream fs = new FileStream(imgPath, FileMode.Open, FileAccess.Read))
{
bitmap = (Bitmap)Bitmap.FromStream(fs);
if (bitmap != null)
{
List<ResultBean> resultBean = project.CheckAll(bitmap, out Image outImage);
bool checkResult = true;
string ngList = deviceName + " AOICheck: " + cameraName + $",{machineSide.ToString()}," + projectName + ",结果: ";
foreach (ResultBean bean in resultBean)
{
ngList += GetShowName(bean) + "\r\n";
if (bean.result.Equals(false))
{
checkResult = false;
}
}
resList = ngList;
LogUtil.LOGGER.Info(ngList);
if (!checkResult)//有料
{
SaveImageToFile("", cameraName, bitmap,"有料", true);
}
else
{
SaveImageToFile("", cameraName, bitmap, "无料", true);
}
//检测失败返回有料
return !checkResult;
}
else
{
LogUtil.LOGGER.Error(deviceName + " AOICheck: " + cameraName + "." + projectName + $", 加载[{imgPath}]图片失败");
return true;
}
}
}
else
{
LogUtil.LOGGER.Error(deviceName + " AOICheck: " + cameraName + "." + projectName + ", 获取AOIProject失败");
}
}
else
{
LogUtil.LOGGER.Error(deviceName + " AOICheck: " + cameraName + "." + projectName + ", 获取图片失败");
}
}
catch (Exception e)
{
LogUtil.LOGGER.Error(deviceName + " AOICheck", e);
}
finally
{
bitmap?.Dispose();
Monitor.Exit(aoiLoc);
}
}
return true;
}
static string SaveImageToFile(string deviceName, string cameraName, Bitmap bitmap,string result, bool deleteCcnt = false)
{
string date = DateTime.Now.ToString("HH-mm-ss-") + DateTime.Now.Millisecond+"-"+result;
string dire = @"\image\aoi\" + deviceName.Trim().Replace('_', '-') + @"\" + cameraName.Trim().Replace('_', '-').Replace(':', '-') + @"\";
string iamgeName = date + ".bmp";
try
{
if (Directory.Exists(dire).Equals(false))
{
Directory.CreateDirectory(dire);
}
int delCnt = ConfigHelper.Config.Get("IPCamera_aoi检测有料图片保存数量", 300);
if (Directory.GetFiles(dire).Length > delCnt)
{
if (deleteCcnt)
Directory.Delete(dire, true);
}
bitmap.Save(dire + iamgeName, ImageFormat.Jpeg);
//bitmap.Dispose();
LogUtil.info(deviceName + " 【" + cameraName + "】扫码完成,保存图片到【" + dire + iamgeName + "】成功");
}
catch (Exception ex)
{
LogUtil.error("保存" + deviceName + " 【" + cameraName + "】的图片到【" + dire + iamgeName + "】出错" + ex.ToString());
}
return dire + iamgeName;
}
private static string GetShowName(ResultBean bean)
{
return (bean.result ? "✔ " : "✘ ") + bean.MethodName + $"({bean.percentValue}%)";
}
}
class Result
{
/// <summary>
/// 状态码,0为正常
/// </summary>
public int code { get; set; } = 0;
/// <summary>
/// 返回数据
/// </summary>
public Dictionary<string, string> data
{
get { return _data; }
set { _data = value; }
}
private Dictionary<string, string> _data = new Dictionary<string, string>();
/// <summary>
/// 提示信息
/// </summary>
public string msg { get; set; } = "ok";
}
}
using System;
using System.Diagnostics;
namespace OnlineStore.DeviceLibrary
{
public class SignalMonitor
{
private readonly Stopwatch _stopwatch;
private bool _lastSignalState;
private long _lastStateChangeTicks;
private long _lastOnDurationTicks;
private long _lastOffDurationTicks;
public SignalMonitor(bool initialSignalState = false)
{
_stopwatch = Stopwatch.StartNew();
_lastSignalState = initialSignalState;
_lastStateChangeTicks = _stopwatch.ElapsedTicks;
_lastOnDurationTicks = 0;
_lastOffDurationTicks = 0;
}
public void UpdateSignalState(bool currentSignalState)
{
if (currentSignalState == _lastSignalState)
return;
long currentTicks = _stopwatch.ElapsedTicks;
long durationTicks = currentTicks - _lastStateChangeTicks;
if (_lastSignalState)
{
_lastOnDurationTicks = durationTicks;
}
else
{
_lastOffDurationTicks = durationTicks;
}
_lastSignalState = currentSignalState;
_lastStateChangeTicks = currentTicks;
}
public TimeSpan GetCurrentOnDuration()
{
if (_lastSignalState)
{
long currentTicks = _stopwatch.ElapsedTicks;
return TicksToTimeSpan(currentTicks - _lastStateChangeTicks);
}
return TicksToTimeSpan(_lastOnDurationTicks);
}
public TimeSpan GetCurrentOffDuration()
{
if (!_lastSignalState)
{
long currentTicks = _stopwatch.ElapsedTicks;
return TicksToTimeSpan(currentTicks - _lastStateChangeTicks);
}
return TicksToTimeSpan(_lastOffDurationTicks);
}
private TimeSpan TicksToTimeSpan(long ticks)
{
return TimeSpan.FromTicks(ticks * TimeSpan.TicksPerSecond / Stopwatch.Frequency);
}
}
}
...@@ -59,7 +59,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -59,7 +59,7 @@ namespace OnlineStore.DeviceLibrary
/// <param name="barcode"></param> /// <param name="barcode"></param>
/// <param name="poid"></param> /// <param name="poid"></param>
/// <returns></returns> /// <returns></returns>
public static string DisablePos(string deviceName, string barcode,string poid) public static string DisablePos(string deviceName, string barcode, string poid)
{ {
string msg = ""; string msg = "";
try try
...@@ -141,7 +141,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -141,7 +141,7 @@ namespace OnlineStore.DeviceLibrary
} }
//## 100 循环获取库位。服务器超时:循环获取库位 //## 100 循环获取库位。服务器超时:循环获取库位
private static string spiltStr = "##"; private static string spiltStr = "##";
public static string ProcessCodeList(List<string> codeList) public static string ProcessCodeList(List<string> codeList)
{ {
string codeStr = ""; string codeStr = "";
...@@ -197,7 +197,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -197,7 +197,7 @@ namespace OnlineStore.DeviceLibrary
return msg; return msg;
} }
public static GetPosResult GetPosId(string deviceName, List<string> codeList, int height, int width, string rfid, string lastPosId) public static GetPosResult GetPosId(string deviceName, List<string> codeList, int height, int width, string rfid, string lastPosId,int totalHeight)
{ {
GetPosResult result = new GetPosResult(); GetPosResult result = new GetPosResult();
try try
...@@ -221,22 +221,26 @@ namespace OnlineStore.DeviceLibrary ...@@ -221,22 +221,26 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.error(deviceName + "GetPosId[" + codeStr + "][" + width + "][" + height + "]:未找到服务器地址 "); LogUtil.error(deviceName + "GetPosId[" + codeStr + "][" + width + "][" + height + "]:未找到服务器地址 ");
result.Msg = "未找到服务器地址"; result.Msg = "未找到服务器地址";
result.Param = InOutPosInfo.NewNgPos(codeStr, "", width , height, ""); result.Param = InOutPosInfo.NewNgPos(codeStr, "", width, height, "");
return result; return result;
} }
string addHeight = totalHeight.ToString();
//http://localhost/myproject/service/store/emptyPosForPutin //http://localhost/myproject/service/store/emptyPosForPutin
// 参数:cids: 多个 cid // 参数:cids: 多个 cid
//code: 条码内容 //code: 条码内容
Dictionary<string, string> paramMap = new Dictionary<string, string>(); Dictionary<string, string> paramMap = new Dictionary<string, string>
paramMap.Add("cids", StoreManager.Config.CID); {
paramMap.Add("code", codeStr); { "cids", StoreManager.Config.CID },
paramMap.Add(ParamDefine.rfid, rfid); { "code", codeStr },
paramMap.Add(ParamDefine.lastPosId, lastPosId); { "addHeight", addHeight },
{ ParamDefine.rfid, rfid },
{ ParamDefine.lastPosId, lastPosId }
};
string server = GetAddr(Addr_PosForPutin, paramMap); string server = GetAddr(Addr_PosForPutin, paramMap);
DateTime startTime = DateTime.Now; DateTime startTime = DateTime.Now;
LogUtil.info(deviceName + "【" + rfid + "】【 " + codeStr + "】【"+ lastPosId + "】 ,获取入库库位:"); LogUtil.info(deviceName + "【" + rfid + "】【 " + codeStr + $"】【{addHeight}】【" + lastPosId + "】 ,获取入库库位:");
string resultStr = HttpHelper.Post(server, "", Encoding.UTF8, 10000, out result.IsTimeOut); string resultStr = HttpHelper.Post(server, "", Encoding.UTF8, 10000, out result.IsTimeOut);
...@@ -271,12 +275,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -271,12 +275,12 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(deviceName + " 【" + codeStr + "】结果入库NG:收到出库信息: " + result.Param.ToStr() + " "); LogUtil.error(deviceName + " 【" + codeStr + "】结果入库NG:收到出库信息: " + result.Param.ToStr() + " ");
result.Msg ="收到出库信息["+ serverResult.barcode + "][" + serverResult.posId + "] "; result.Msg = "收到出库信息[" + serverResult.barcode + "][" + serverResult.posId + "] ";
cancelPutInTask(deviceName, codeStr); cancelPutInTask(deviceName, codeStr);
result.Param = InOutPosInfo.NewNgPos(codeStr, "", width , height, "收到出库信息[" + serverResult.barcode + "][" + serverResult.posId + "]"); result.Param = InOutPosInfo.NewNgPos(codeStr, "", width, height, "收到出库信息[" + serverResult.barcode + "][" + serverResult.posId + "]");
result.Param.rfid = rfid; result.Param.rfid = rfid;
result.Param.IsNG = true; result.Param.IsNG = true;
return result; return result;
} }
else if ((!string.IsNullOrEmpty(serverResult.msg)) || serverResult.result.Equals(0).Equals(false)) else if ((!string.IsNullOrEmpty(serverResult.msg)) || serverResult.result.Equals(0).Equals(false))
{ {
...@@ -309,8 +313,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -309,8 +313,8 @@ namespace OnlineStore.DeviceLibrary
{ {
result.Param.IsNG = true; result.Param.IsNG = true;
result.Param.NgMsg = "未找到库位[" + position + "]"; result.Param.NgMsg = "未找到库位[" + position + "]";
result.Msg = "未找到库位: " + result.Param.ToStr() + " ,入库失败"; result.Msg = "未找到库位: " + result.Param.ToStr() + " ,入库失败";
LogUtil.error( deviceName + ("收到服务器入库命令 " + ",未找到库位: " + result.Param.ToStr() + " ,入库失败!")); LogUtil.error(deviceName + ("收到服务器入库命令 " + ",未找到库位: " + result.Param.ToStr() + " ,入库失败!"));
return result; return result;
} }
else else
...@@ -330,7 +334,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -330,7 +334,7 @@ namespace OnlineStore.DeviceLibrary
public static int GetOutTaskCount(string hSerial) public static int GetOutTaskCount(string hSerial)
{ {
try try
{ {
Dictionary<string, string> paramMap = new Dictionary<string, string>(); Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("cid", StoreManager.Config.CID); paramMap.Add("cid", StoreManager.Config.CID);
paramMap.Add("hSerial", hSerial); paramMap.Add("hSerial", hSerial);
...@@ -363,7 +367,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -363,7 +367,7 @@ namespace OnlineStore.DeviceLibrary
/// <param name="posName"></param> /// <param name="posName"></param>
/// <param name="barcode"></param> /// <param name="barcode"></param>
/// <returns></returns> /// <returns></returns>
public static bool InstorePosCheck(string posName,string barcode) public static bool InstorePosCheck(string posName, string barcode)
{ {
try try
{ {
...@@ -396,7 +400,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -396,7 +400,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error($"InstorePosCheck:{posName},{barcode}",ex); LogUtil.error($"InstorePosCheck:{posName},{barcode}", ex);
} }
return false; return false;
} }
...@@ -426,7 +430,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -426,7 +430,7 @@ namespace OnlineStore.DeviceLibrary
try try
{ {
if (string.IsNullOrEmpty(serverAddr)) if (string.IsNullOrEmpty(serverAddr))
{ {
return msg; return msg;
} }
Dictionary<string, string> paramMap = new Dictionary<string, string>(); Dictionary<string, string> paramMap = new Dictionary<string, string>();
...@@ -434,7 +438,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -434,7 +438,7 @@ namespace OnlineStore.DeviceLibrary
paramMap.Add("deviceAlarmList", msgListStr); paramMap.Add("deviceAlarmList", msgListStr);
string server = GetAddr(Addr_updateDeviceAlarmMsg, paramMap); string server = GetAddr(Addr_updateDeviceAlarmMsg, paramMap);
DateTime startTime = DateTime.Now; DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "",5000); string resultStr = HttpHelper.Post(server, "", 5000);
LogUtil.debug("updateDeviceAlarmMsg " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】"); LogUtil.debug("updateDeviceAlarmMsg " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
RfidData data = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr); RfidData data = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);
...@@ -465,63 +469,63 @@ namespace OnlineStore.DeviceLibrary ...@@ -465,63 +469,63 @@ namespace OnlineStore.DeviceLibrary
ShelfTaskInfo task = new ShelfTaskInfo(); ShelfTaskInfo task = new ShelfTaskInfo();
task.rfid = rfid; task.rfid = rfid;
return task; return task;
// DateTime startTime = DateTime.Now; // DateTime startTime = DateTime.Now;
// try // try
// { // {
// string api = Addr_ShelfFinish; // string api = Addr_ShelfFinish;
// Dictionary<string, string> paramMap = new Dictionary<string, string>(); // Dictionary<string, string> paramMap = new Dictionary<string, string>();
// paramMap.Add("barcode", barcode); // paramMap.Add("barcode", barcode);
// paramMap.Add("rfid", rfid); // paramMap.Add("rfid", rfid);
// paramMap.Add("rfidLoc", rfidLoc); // paramMap.Add("rfidLoc", rfidLoc);
// paramMap.Add("robotIndex", robotIndex); // paramMap.Add("robotIndex", robotIndex);
// //string url = httpAddr + api + "?barcode=" + barcode + "&rfid=" + rfid + "&rfidLoc=" + rfidLoc + "&robotIndex=" + robotIndex; // //string url = httpAddr + api + "?barcode=" + barcode + "&rfid=" + rfid + "&rfidLoc=" + rfidLoc + "&robotIndex=" + robotIndex;
// string url = GetAddr(api, paramMap); // string url = GetAddr(api, paramMap);
// LogUtil.debug("http :URL:" + url); // LogUtil.debug("http :URL:" + url);
// string json = HttpHelper.Post(url, "", 10000); // string json = HttpHelper.Post(url, "", 10000);
// if (barcode != "") // if (barcode != "")
// { // {
// LogUtil.info("http :URL:" + url + " :Response:" + json + " 耗时[" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "]"); // LogUtil.info("http :URL:" + url + " :Response:" + json + " 耗时[" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "]");
// } // }
// else // else
// { // {
// LogUtil.debug("http :URL:" + url + " :Response:" + json); // LogUtil.debug("http :URL:" + url + " :Response:" + json);
// } // }
// if (string.IsNullOrWhiteSpace(json)) return task; // if (string.IsNullOrWhiteSpace(json)) return task;
// //行 2234: [2021 - 04 - 07 15:09:31,412][9]INFO - http :URL: // //行 2234: [2021 - 04 - 07 15:09:31,412][9]INFO - http :URL:
// //http://192.168.100.14/myproject/rest/api/qisda/device/putShelfFinished?barcode=640253A*34005600000309*QG00006*5000*23C4&rfid=F103&rfidLoc=8&robotIndex=1 : // //http://192.168.100.14/myproject/rest/api/qisda/device/putShelfFinished?barcode=640253A*34005600000309*QG00006*5000*23C4&rfid=F103&rfidLoc=8&robotIndex=1 :
// //Response:{"code":0,"msg":"ok","data":{"smallTask":"0","cutPackageTask":"0","packageTask":"0","bigTask":"0","smallEmpty":"0","bigEmpty":"5","packageEmpty":"0","rfid":"F103","usedRfidList":"F106,F105,F103","barcode":"640253A*34005600000309*QG00006*5000*23C4","cutTask":"0"}} 耗时[00:00:00.1] // //Response:{"code":0,"msg":"ok","data":{"smallTask":"0","cutPackageTask":"0","packageTask":"0","bigTask":"0","smallEmpty":"0","bigEmpty":"5","packageEmpty":"0","rfid":"F103","usedRfidList":"F106,F105,F103","barcode":"640253A*34005600000309*QG00006*5000*23C4","cutTask":"0"}} 耗时[00:00:00.1]
// JavaScriptSerializer serializer = new JavaScriptSerializer(); // JavaScriptSerializer serializer = new JavaScriptSerializer();
// Dictionary<string, object> obj = (Dictionary<string, object>)serializer.DeserializeObject(json); // Dictionary<string, object> obj = (Dictionary<string, object>)serializer.DeserializeObject(json);
// if (!obj.TryGetValue("code", out object value)) return task; // if (!obj.TryGetValue("code", out object value)) return task;
// if (value.ToString() != "0") // if (value.ToString() != "0")
// { // {
// if (obj.TryGetValue("msg", out value)) // if (obj.TryGetValue("msg", out value))
// LogUtil.error("http" + api + ": " + value.ToString()); // LogUtil.error("http" + api + ": " + value.ToString());
// return task; // return task;
// } // }
// if (!obj.TryGetValue("data", out value)) return task; // if (!obj.TryGetValue("data", out value)) return task;
// Dictionary<string, object> dict = (Dictionary<string, object>)value; // Dictionary<string, object> dict = (Dictionary<string, object>)value;
// if (dict == null) // if (dict == null)
// { // {
// LogUtil.info("http" + api + ": data=null"); // LogUtil.info("http" + api + ": data=null");
// return task; // return task;
// } // }
// if (dict.TryGetValue("bigEmpty", out value)) // if (dict.TryGetValue("bigEmpty", out value))
// int.TryParse(value.ToString(), out task.bigEmpty); // int.TryParse(value.ToString(), out task.bigEmpty);
// if (dict.TryGetValue("smallEmpty", out value)) // if (dict.TryGetValue("smallEmpty", out value))
// int.TryParse(value.ToString(), out task.smallEmpty); // int.TryParse(value.ToString(), out task.smallEmpty);
// if (dict.TryGetValue("usedRfidList", out value)) // if (dict.TryGetValue("usedRfidList", out value))
// task.usedRfidList = value.ToString(); // task.usedRfidList = value.ToString();
// } // }
// catch (Exception ex) // catch (Exception ex)
// { // {
// LogUtil.error("http error : " + ex.ToString()); // LogUtil.error("http error : " + ex.ToString());
// } // }
// return task; // return task;
} }
} }
public class ShelfTaskInfo public class ShelfTaskInfo
...@@ -555,7 +559,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -555,7 +559,7 @@ namespace OnlineStore.DeviceLibrary
//>>>msgValue : 异常信息 //>>>msgValue : 异常信息
public string msgValue = ""; public string msgValue = "";
public AlarmMsg(string n ,string key,string value) public AlarmMsg(string n, string key, string value)
{ {
this.name = n; this.name = n;
this.msgKey = key; this.msgKey = key;
...@@ -601,7 +605,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -601,7 +605,7 @@ namespace OnlineStore.DeviceLibrary
public string msg { get; set; } public string msg { get; set; }
public string data { get; set; } public string data { get; set; }
} }
public class AfterPutData public class AfterPutData
{ {
...@@ -641,10 +645,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -641,10 +645,10 @@ namespace OnlineStore.DeviceLibrary
public string ToStr() public string ToStr()
{ {
return "[分盘料=" + cutTask + "][紧急料=" + urgentTask+"]"; return "[分盘料=" + cutTask + "][紧急料=" + urgentTask + "]";
} }
} }
} }
...@@ -107,7 +107,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -107,7 +107,10 @@ namespace OnlineStore.DeviceLibrary
/// 料盘高 /// 料盘高
/// </summary> /// </summary>
public int PlateH { get; set; } public int PlateH { get; set; }
/// <summary>
/// 料盘总高
/// </summary>
public int PlateTotalH { get; set; }
/// <summary> /// <summary>
/// urgentReel: true 表示紧急料, /// urgentReel: true 表示紧急料,
/// </summary> /// </summary>
......
 
using DeviceLibrary;
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary; using OnlineStore.LoadCSVLibrary;
using System; using System;
...@@ -62,6 +63,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -62,6 +63,15 @@ namespace OnlineStore.DeviceLibrary
Config.LoadIO(ioAdd); Config.LoadIO(ioAdd);
MoveInfo = new DeviceMoveInfo(Name); MoveInfo = new DeviceMoveInfo(Name);
cames = ConfigHelper.Config.Get<string[]>($"{Name}_HeightCams"); cames = ConfigHelper.Config.Get<string[]>($"{Name}_HeightCams");
lineInSigMonitor = new SignalMonitor(false);
}
DeviceLibrary.SignalMonitor lineInSigMonitor;
DateTime LineIn_Check_ONTime = DateTime.MaxValue;
//出料口线体料盘检测,true:有料盘
public bool CameraCheck(string deviceName, out string ngList)
{
return ReelCheckCamera.AOICheck(deviceName, $"AOI.data", Name, out ngList);
} }
public void TimerProcess() public void TimerProcess()
{ {
...@@ -70,7 +80,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -70,7 +80,7 @@ namespace OnlineStore.DeviceLibrary
{ {
return; return;
} }
lineInSigMonitor.UpdateSignalState(Robot.IOValue(Config.IO_LineIn_Check).Equals(IO_VALUE.HIGH));
if (!MoveStop) if (!MoveStop)
{ {
if (MoveInfo.MoveType.Equals(MoveType.None)) if (MoveInfo.MoveType.Equals(MoveType.None))
...@@ -88,14 +98,19 @@ namespace OnlineStore.DeviceLibrary ...@@ -88,14 +98,19 @@ namespace OnlineStore.DeviceLibrary
} }
else if (Robot.AutoInput && Robot.IOValue(Config.IO_LineIn_Check).Equals(IO_VALUE.HIGH)) else if (Robot.AutoInput && Robot.IOValue(Config.IO_LineIn_Check).Equals(IO_VALUE.HIGH))
{ {
ResetShelf = false; if(lineInSigMonitor.GetCurrentOnDuration().TotalMilliseconds > 500)
LogUtil.debug($"{Name} 处理2"); {
StartInstore(new InOutParam()); ResetShelf = false;
LogUtil.debug($"{Name} 处理2");
WorkLog("前端信号亮,开始入库");
StartInstore(new InOutParam());
}
} }
else if (Robot.AutoInput && Robot.IOValue(Config.IO_LineEnd_Check).Equals(IO_VALUE.HIGH)) else if (Robot.AutoInput && Robot.IOValue(Config.IO_LineEnd_Check).Equals(IO_VALUE.HIGH))
{ {
if(!ResetShelf) if(!ResetShelf)
{ {
WorkLog("末端信号亮,开始入库");
LogUtil.debug($"{Name} 处理3"); LogUtil.debug($"{Name} 处理3");
StartInstore(new InOutParam()); StartInstore(new InOutParam());
} }
......
...@@ -320,7 +320,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -320,7 +320,9 @@ namespace OnlineStore.DeviceLibrary
{ {
width = 13; width = 13;
} }
LastHeight = GetHeight(width); var height = GetHeight(width);
LastHeight = height.Item1;
LastTotalHeight = height.Item2;
} }
else if (MoveInfo.IsStep(StepEnum.IB17_WaitReelLeave)) else if (MoveInfo.IsStep(StepEnum.IB17_WaitReelLeave))
{ {
...@@ -565,13 +567,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -565,13 +567,15 @@ namespace OnlineStore.DeviceLibrary
public int StartMovePosition = 0; public int StartMovePosition = 0;
public int EndMovePosition = 0; public int EndMovePosition = 0;
internal int LastHeight = 0; internal int LastHeight = 0;
internal int LastTotalHeight = 0;
string[] cames; string[] cames;
public int GetHeight(int width=7) public (int, int) GetHeight(int width = 7)
{ {
CodeManager.CameraCheckHeight(cames?.ToList(), Name); CodeManager.CameraCheckHeight(cames?.ToList(), Name);
LogUtil.info($"{Name} 采集料盘抓走后的图片,开始计算高度"); LogUtil.info($"{Name} 采集料盘抓走后的图片,开始计算高度");
int lastReelAddVal = ConfigHelper.Config.Get($"{Name}_lastReelSelfAddVal", 4); int lastReelAddVal = ConfigHelper.Config.Get($"{Name}_lastReelSelfAddVal", 4);
LastHeight = 0; LastHeight = 0;
LastTotalHeight = 0;
int AxisChangeValue = Robot.Config.Height_ChangeValue; int AxisChangeValue = Robot.Config.Height_ChangeValue;
//计算高度 //计算高度
EndMovePosition = BatchAxis.GetAclPosition(); EndMovePosition = BatchAxis.GetAclPosition();
...@@ -583,15 +587,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -583,15 +587,13 @@ namespace OnlineStore.DeviceLibrary
} }
float height = (float)(1F * Math.Abs(EndMovePosition - StartMovePosition) / AxisChangeValue);//Math.Ceiling float height = (float)(1F * Math.Abs(EndMovePosition - StartMovePosition) / AxisChangeValue);//Math.Ceiling
string buchongStr = ""; string buchongStr = "";
if (isLast) if (isLast)
{ {
buchongStr = $"(最后一盘料)加{lastReelAddVal};"; buchongStr = $"(最后一盘料)加{lastReelAddVal};";
height += lastReelAddVal; height += lastReelAddVal;
} }
LastTotalHeight = (int)Math.Ceiling(height);
//如果检测出<=15,都按照8计算 //如果检测出<=15,都按照8计算
if (height <= 12) if (height <= 12)
{ {
...@@ -611,6 +613,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -611,6 +613,7 @@ namespace OnlineStore.DeviceLibrary
if (width >= 13) if (width >= 13)
{ {
height = height - 2; height = height - 2;
LastTotalHeight = LastTotalHeight - 2;
LogUtil.info($"检测为13寸高度-2={height}"); LogUtil.info($"检测为13寸高度-2={height}");
} }
...@@ -631,11 +634,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -631,11 +634,11 @@ namespace OnlineStore.DeviceLibrary
if (LastHeight <= 8) { LastHeight = 8; } if (LastHeight <= 8) { LastHeight = 8; }
string code = CodeManager.ProcessCode(LastCodeList); string code = CodeManager.ProcessCode(LastCodeList);
Thread.Sleep(500); Thread.Sleep(500);
string msg = $"{Name} 上升前 [{StartMovePosition}]实时[{ EndMovePosition}]差值[{(EndMovePosition - StartMovePosition)}]" + string msg = $"{Name} 上升前 [{StartMovePosition}]实时[{EndMovePosition}]差值[{(EndMovePosition - StartMovePosition)}]" +
$"系数[{AxisChangeValue}] 计算后{buchongStr}[{height}]条码【{code}】"; $"系数[{AxisChangeValue}] 计算后{buchongStr}[{height}]条码【{code}】";
LogUtil.info(msg); LogUtil.info(msg);
LogUtil.info($"{Name} 视觉计算的盘高结果:{height}mm,归类为{LastHeight}mm"); LogUtil.info($"{Name} 视觉计算的盘高结果:{height}mm,总厚度为{LastTotalHeight}mm,归类为{LastHeight}mm");
return LastHeight; return (LastHeight, LastTotalHeight);
} }
#endregion #endregion
......
...@@ -267,7 +267,22 @@ namespace OnlineStore.DeviceLibrary ...@@ -267,7 +267,22 @@ namespace OnlineStore.DeviceLibrary
{ {
width = 13; width = 13;
} }
if (ConfigHelper.Config.Get("IPCamera_EnableAOI", false))
{
var check13 = moveBean.CameraCheck(MoveInfo.Name, out string err);
if (check13)
{
width = 13;
MoveLog($"入库取料{shelf}{MoveInfo.SLog}: 检测到有料,认为13寸:{err}");
}
else
{
width = 7;
MoveLog($"入库取料{shelf}{MoveInfo.SLog}: 检测到无料,认为7寸:{err}");
}
}
MoveInfo.MoveParam.PosInfo.PlateH = Height; MoveInfo.MoveParam.PosInfo.PlateH = Height;
MoveInfo.MoveParam.PosInfo.PlateTotalH = moveBean.LastTotalHeight;
MoveInfo.MoveParam.PosInfo.PlateW = width; MoveInfo.MoveParam.PosInfo.PlateW = width;
MoveLog($"入库取料{shelf}{MoveInfo.SLog}: 料盘尺寸{width}X{Height}"); MoveLog($"入库取料{shelf}{MoveInfo.SLog}: 料盘尺寸{width}X{Height}");
...@@ -383,7 +398,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -383,7 +398,6 @@ namespace OnlineStore.DeviceLibrary
} }
else if (MoveInfo.IsStep(StepEnum.II47_MiddleToP1)) else if (MoveInfo.IsStep(StepEnum.II47_MiddleToP1))
{ {
ClearTimeoutAlarm("扫码结束");
TimeSpan span = DateTime.Now - startInTime; TimeSpan span = DateTime.Now - startInTime;
MoveLog($" 入料->A侧放料结束,更新A上暂存区物料{MoveInfo.MoveParam.PosInfo.ToStr()},耗时【{FormUtil.GetSpanStr(span)}】"); MoveLog($" 入料->A侧放料结束,更新A上暂存区物料{MoveInfo.MoveParam.PosInfo.ToStr()},耗时【{FormUtil.GetSpanStr(span)}】");
BufferDataManager.AInStoreInfo = MoveInfo.MoveParam.PosInfo; BufferDataManager.AInStoreInfo = MoveInfo.MoveParam.PosInfo;
...@@ -477,14 +491,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -477,14 +491,13 @@ namespace OnlineStore.DeviceLibrary
//MoveLog($" 入料->B侧 {MoveInfo.SLog}: 旋转轴 到P1(待机点){Config.Middle_P1}"); //MoveLog($" 入料->B侧 {MoveInfo.SLog}: 旋转轴 到P1(待机点){Config.Middle_P1}");
//MiddleAxis.AbsMove(MoveInfo, Config.Middle_P1, Config.Middle_P1_Speed); //MiddleAxis.AbsMove(MoveInfo, Config.Middle_P1, Config.Middle_P1_Speed);
} }
else if (MoveInfo.IsTimeOut(20)) else if (MoveInfo.IsTimeOut(30))
{ {
SetWarnMsg("等待" + BatchMove_B.Name + "扫码结束"); Msg.add("等待" + BatchMove_B.Name + "扫码结束", MsgLevel.warning);
} }
} }
else if (MoveInfo.IsStep(StepEnum.II67_MiddleToP1)) else if (MoveInfo.IsStep(StepEnum.II67_MiddleToP1))
{ {
ClearTimeoutAlarm("扫码结束");
TimeSpan span = DateTime.Now - startInTime; TimeSpan span = DateTime.Now - startInTime;
MoveLog($" 入料->B侧放料结束,更新B上暂存区物料{MoveInfo.MoveParam.PosInfo.ToStr()},耗时【{FormUtil.GetSpanStr(span)}】"); MoveLog($" 入料->B侧放料结束,更新B上暂存区物料{MoveInfo.MoveParam.PosInfo.ToStr()},耗时【{FormUtil.GetSpanStr(span)}】");
BufferDataManager.BInStoreInfo = MoveInfo.MoveParam.PosInfo; BufferDataManager.BInStoreInfo = MoveInfo.MoveParam.PosInfo;
...@@ -734,7 +747,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -734,7 +747,7 @@ namespace OnlineStore.DeviceLibrary
} }
//从服务器获取库位号 //从服务器获取库位号
GetPosResult result = SServerManager.GetPosId(Name, codeList, pos.PlateH, pos.PlateW, pos.rfid, lastPosId); GetPosResult result = SServerManager.GetPosId(Name, codeList, pos.PlateH, pos.PlateW, pos.rfid, lastPosId,pos.PlateTotalH);
LastResult = result.Result; LastResult = result.Result;
if (result.IsTimeOut) if (result.IsTimeOut)
{ {
......
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
</configuration>
\ No newline at end of file \ No newline at end of file
namespace ImgCheckReel
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.txtTotalCover = new System.Windows.Forms.TextBox();
this.lblHL = new System.Windows.Forms.Label();
this.lblHH = new System.Windows.Forms.Label();
this.lblLL = new System.Windows.Forms.Label();
this.lblLH = new System.Windows.Forms.Label();
this.lblSL = new System.Windows.Forms.Label();
this.lblSH = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.txtHL = new System.Windows.Forms.TrackBar();
this.txtSH = new System.Windows.Forms.TrackBar();
this.txtSL = new System.Windows.Forms.TrackBar();
this.txtLH = new System.Windows.Forms.TrackBar();
this.txtLL = new System.Windows.Forms.TrackBar();
this.txtHH = new System.Windows.Forms.TrackBar();
this.txtthreshold = new System.Windows.Forms.TextBox();
this.button3 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txtHL)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txtSH)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txtSL)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txtLH)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txtLL)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txtHH)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(287, 265);
this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(143, 12);
this.label1.TabIndex = 0;
this.label1.Text = "CamTestReel_totalcover:";
//
// txtTotalCover
//
this.txtTotalCover.Location = new System.Drawing.Point(436, 258);
this.txtTotalCover.Margin = new System.Windows.Forms.Padding(2);
this.txtTotalCover.Name = "txtTotalCover";
this.txtTotalCover.Size = new System.Drawing.Size(107, 21);
this.txtTotalCover.TabIndex = 1;
this.txtTotalCover.TextChanged += new System.EventHandler(this.txtTotalCover_TextChanged);
//
// lblHL
//
this.lblHL.AutoSize = true;
this.lblHL.Location = new System.Drawing.Point(10, 11);
this.lblHL.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblHL.Name = "lblHL";
this.lblHL.Size = new System.Drawing.Size(143, 12);
this.lblHL.TabIndex = 2;
this.lblHL.Text = "CamTestReel_HL(色相):";
//
// lblHH
//
this.lblHH.AutoSize = true;
this.lblHH.Location = new System.Drawing.Point(298, 11);
this.lblHH.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblHH.Name = "lblHH";
this.lblHH.Size = new System.Drawing.Size(143, 12);
this.lblHH.TabIndex = 4;
this.lblHH.Text = "CamTestReel_HH(色相):";
//
// lblLL
//
this.lblLL.AutoSize = true;
this.lblLL.Location = new System.Drawing.Point(9, 85);
this.lblLL.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblLL.Name = "lblLL";
this.lblLL.Size = new System.Drawing.Size(143, 12);
this.lblLL.TabIndex = 6;
this.lblLL.Text = "CamTestReel_LL(亮度):";
//
// lblLH
//
this.lblLH.AutoSize = true;
this.lblLH.Location = new System.Drawing.Point(298, 85);
this.lblLH.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblLH.Name = "lblLH";
this.lblLH.Size = new System.Drawing.Size(143, 12);
this.lblLH.TabIndex = 8;
this.lblLH.Text = "CamTestReel_LH(亮度):";
//
// lblSL
//
this.lblSL.AutoSize = true;
this.lblSL.Location = new System.Drawing.Point(17, 176);
this.lblSL.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblSL.Name = "lblSL";
this.lblSL.Size = new System.Drawing.Size(155, 12);
this.lblSL.TabIndex = 10;
this.lblSL.Text = "CamTestReel_SL(饱和度):";
//
// lblSH
//
this.lblSH.AutoSize = true;
this.lblSH.Location = new System.Drawing.Point(287, 176);
this.lblSH.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblSH.Name = "lblSH";
this.lblSH.Size = new System.Drawing.Size(155, 12);
this.lblSH.TabIndex = 12;
this.lblSH.Text = "CamTestReel_SH(饱和度):";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(9, 261);
this.label8.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(137, 12);
this.label8.TabIndex = 14;
this.label8.Text = "CamTestReel_threshold:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(20, 297);
this.textBox1.Margin = new System.Windows.Forms.Padding(2);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(473, 70);
this.textBox1.TabIndex = 16;
//
// pictureBox1
//
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.pictureBox1.Location = new System.Drawing.Point(12, 371);
this.pictureBox1.Margin = new System.Windows.Forms.Padding(2);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(481, 347);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 17;
this.pictureBox1.TabStop = false;
//
// pictureBox2
//
this.pictureBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pictureBox2.Location = new System.Drawing.Point(529, 371);
this.pictureBox2.Margin = new System.Windows.Forms.Padding(2);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(468, 347);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox2.TabIndex = 18;
this.pictureBox2.TabStop = false;
//
// button1
//
this.button1.Location = new System.Drawing.Point(554, 34);
this.button1.Margin = new System.Windows.Forms.Padding(2);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(108, 44);
this.button1.TabIndex = 19;
this.button1.Text = "打开图片";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(619, 161);
this.textBox2.Margin = new System.Windows.Forms.Padding(2);
this.textBox2.Multiline = true;
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(254, 206);
this.textBox2.TabIndex = 20;
//
// button2
//
this.button2.Location = new System.Drawing.Point(856, 32);
this.button2.Margin = new System.Windows.Forms.Padding(2);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(108, 44);
this.button2.TabIndex = 21;
this.button2.Text = "保存ROI";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click_1);
//
// txtHL
//
this.txtHL.LargeChange = 1;
this.txtHL.Location = new System.Drawing.Point(12, 34);
this.txtHL.Margin = new System.Windows.Forms.Padding(2);
this.txtHL.Maximum = 360;
this.txtHL.Name = "txtHL";
this.txtHL.Size = new System.Drawing.Size(250, 45);
this.txtHL.TabIndex = 22;
this.txtHL.Scroll += new System.EventHandler(this.txtHL_Scroll);
//
// txtSH
//
this.txtSH.LargeChange = 1;
this.txtSH.Location = new System.Drawing.Point(290, 199);
this.txtSH.Margin = new System.Windows.Forms.Padding(2);
this.txtSH.Maximum = 255;
this.txtSH.Name = "txtSH";
this.txtSH.Size = new System.Drawing.Size(245, 45);
this.txtSH.TabIndex = 23;
this.txtSH.Scroll += new System.EventHandler(this.txtSH_Scroll);
//
// txtSL
//
this.txtSL.LargeChange = 1;
this.txtSL.Location = new System.Drawing.Point(20, 199);
this.txtSL.Margin = new System.Windows.Forms.Padding(2);
this.txtSL.Maximum = 255;
this.txtSL.Name = "txtSL";
this.txtSL.Size = new System.Drawing.Size(245, 45);
this.txtSL.TabIndex = 24;
this.txtSL.Scroll += new System.EventHandler(this.txtSL_Scroll);
//
// txtLH
//
this.txtLH.LargeChange = 1;
this.txtLH.Location = new System.Drawing.Point(290, 112);
this.txtLH.Margin = new System.Windows.Forms.Padding(2);
this.txtLH.Maximum = 255;
this.txtLH.Name = "txtLH";
this.txtLH.Size = new System.Drawing.Size(245, 45);
this.txtLH.TabIndex = 25;
this.txtLH.Scroll += new System.EventHandler(this.txtLH_Scroll);
//
// txtLL
//
this.txtLL.LargeChange = 1;
this.txtLL.Location = new System.Drawing.Point(12, 112);
this.txtLL.Margin = new System.Windows.Forms.Padding(2);
this.txtLL.Maximum = 255;
this.txtLL.Name = "txtLL";
this.txtLL.Size = new System.Drawing.Size(250, 45);
this.txtLL.TabIndex = 26;
this.txtLL.Scroll += new System.EventHandler(this.txtLL_Scroll);
//
// txtHH
//
this.txtHH.LargeChange = 1;
this.txtHH.Location = new System.Drawing.Point(290, 34);
this.txtHH.Margin = new System.Windows.Forms.Padding(2);
this.txtHH.Maximum = 360;
this.txtHH.Name = "txtHH";
this.txtHH.Size = new System.Drawing.Size(245, 45);
this.txtHH.TabIndex = 27;
this.txtHH.Scroll += new System.EventHandler(this.txtHH_Scroll);
//
// txtthreshold
//
this.txtthreshold.Location = new System.Drawing.Point(156, 258);
this.txtthreshold.Margin = new System.Windows.Forms.Padding(2);
this.txtthreshold.Name = "txtthreshold";
this.txtthreshold.Size = new System.Drawing.Size(107, 21);
this.txtthreshold.TabIndex = 28;
this.txtthreshold.TextChanged += new System.EventHandler(this.txtthreshold_TextChanged);
//
// button3
//
this.button3.Location = new System.Drawing.Point(709, 32);
this.button3.Margin = new System.Windows.Forms.Padding(2);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(108, 44);
this.button3.TabIndex = 29;
this.button3.Text = "加载ROI";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1008, 729);
this.Controls.Add(this.button3);
this.Controls.Add(this.txtthreshold);
this.Controls.Add(this.txtHH);
this.Controls.Add(this.txtLL);
this.Controls.Add(this.txtLH);
this.Controls.Add(this.txtSL);
this.Controls.Add(this.txtSH);
this.Controls.Add(this.txtHL);
this.Controls.Add(this.button2);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label8);
this.Controls.Add(this.lblSH);
this.Controls.Add(this.lblSL);
this.Controls.Add(this.lblLH);
this.Controls.Add(this.lblLL);
this.Controls.Add(this.lblHH);
this.Controls.Add(this.lblHL);
this.Controls.Add(this.txtTotalCover);
this.Controls.Add(this.label1);
this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "Form1";
this.Text = "视觉检测料盘调试";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtHL)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtSH)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtSL)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtLH)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtLL)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtHH)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtTotalCover;
private System.Windows.Forms.Label lblHL;
private System.Windows.Forms.Label lblHH;
private System.Windows.Forms.Label lblLL;
private System.Windows.Forms.Label lblLH;
private System.Windows.Forms.Label lblSL;
private System.Windows.Forms.Label lblSH;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TrackBar txtHL;
private System.Windows.Forms.TrackBar txtSH;
private System.Windows.Forms.TrackBar txtSL;
private System.Windows.Forms.TrackBar txtLH;
private System.Windows.Forms.TrackBar txtLL;
private System.Windows.Forms.TrackBar txtHH;
private System.Windows.Forms.TextBox txtthreshold;
private System.Windows.Forms.Button button3;
}
}
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
namespace ImgCheckReel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ConfigHelper.Config.PropertyBind("CamTestReel_totalcover", txtTotalCover, "Text", "TextChanged", "100");
ConfigHelper.Config.PropertyBind("CamTestReel_threshold", txtthreshold, "Text", "TextChanged", "0.6");
ConfigHelper.Config.PropertyBind("CamTestReel_HL", txtHL, "Value", "Scroll", "40");
ConfigHelper.Config.PropertyBind("CamTestReel_HH", txtHH, "Value", "Scroll", "70");
ConfigHelper.Config.PropertyBind("CamTestReel_LL", txtLL, "Value", "Scroll", "15");
ConfigHelper.Config.PropertyBind("CamTestReel_LH", txtLH, "Value", "Scroll", "100");
ConfigHelper.Config.PropertyBind("CamTestReel_SL", txtSL, "Value", "Scroll", "20");
ConfigHelper.Config.PropertyBind("CamTestReel_SH", txtSH, "Value", "Scroll", "100");
UpdateValue();
}
[HandleProcessCorruptedStateExceptions]
public bool? TestHasReel(string filename, out string msg)
{
msg = "";
DateTime startTime = DateTime.Now;
Bitmap bmp = null;
textBox1.Text = "";
pictureBox1.Image = null;
pictureBox2.Image = null;
using (var s = File.Open(filename, FileMode.Open))
{
bmp = (Bitmap)Bitmap.FromStream(s);
}
try
{
if (bmp == null)
{
return false;
}
pictureBox1.Image = (Image)bmp.Clone();
var b = new Bitmap(bmp.Width / 2, bmp.Height / 2, bmp.PixelFormat);
bool hasReel = false;
using (var g = Graphics.FromImage(b))
{
g.InterpolationMode = InterpolationMode.Low;
g.DrawImage(bmp, 0, 0, b.Width, b.Height);
ImageLockMode imageLockMode = ImageLockMode.ReadWrite;
var bd = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), imageLockMode, b.PixelFormat);
var rois = TestRoi.GetRois();
if (rois == null || rois.Count == 0)
{
rois = new List<TestRoi>() { new TestRoi() };
rois[0].CoverCount = totalcover;
rois[0].RoiPath.Add(new Point(0, 0));
rois[0].RoiPath.Add(new Point(bmp.Width, 0));
rois[0].RoiPath.Add(new Point(bmp.Width, bmp.Height));
rois[0].RoiPath.Add(new Point(0, bmp.Height));
TestRoi.SaveConfig(rois);
}
for (int i = 0; i < rois.Count; i++)
{
// rois[i].CoverCount = totalcover;
double maskcout = 0;
var roi = rois[i];
var rp = roi.RoiPath.Select(r => new Point(r.X / 2, r.Y / 2)).ToList();
// rp.ForEach(s => g.DrawString("新的角点", new Font("黑体", 9), new SolidBrush(Color.FromArgb(0, 255, 0)), s));
var fp = GetFilledPoints(rp);
var nfp = fp.Where(f => IsPointInPath(f.X, f.Y, rp)).ToList();
foreach (var xy in nfp)
{
int x = (xy.Y * bd.Width + xy.X) * 3;
//Marshal.WriteByte(bd.Scan0, x, 0);
//Marshal.WriteByte(bd.Scan0, x + 1, 0);
//Marshal.WriteByte(bd.Scan0, x + 2, 255);
var cr = (int)Marshal.ReadByte(bd.Scan0, x + 2);
var cg = (int)Marshal.ReadByte(bd.Scan0, x + 1);
var cb = (int)Marshal.ReadByte(bd.Scan0, x);
var h = RgbToHsv(new ColorRGB(cr, cg, cb));
if (h.H >= hl && h.H <= hh && h.V >= ll && h.V <= lh && h.S >= sl && h.S <= sh)
{
maskcout++;
Marshal.WriteByte(bd.Scan0, x, 0);
Marshal.WriteByte(bd.Scan0, x + 1, 0);
Marshal.WriteByte(bd.Scan0, x + 2, 255);
}
else
{
Marshal.WriteByte(bd.Scan0, x, 255);
Marshal.WriteByte(bd.Scan0, x + 1, 255);
Marshal.WriteByte(bd.Scan0, x + 2, 255);
}
}
double calc = maskcout / (double)roi.CoverCount;
textBox1.Text += $" 检测到Roi[{i}]覆盖面积计数:maskcout:{maskcout}/{roi.CoverCount}={calc}<{threshold},result:{(calc <= threshold ? "有料" : "无料")}\r\n";
if (calc <= threshold)
{
hasReel = true;
//break;
}
}
b.UnlockBits(bd);
pictureBox2.Image = (Image)b.Clone();
}
b.Dispose();
return hasReel;
}
catch (AccessViolationException e)
{
MessageBox.Show(" 扫码出现AccessViolationException异常:" + e.ToString());
return null;
}
catch (Exception ex)
{
MessageBox.Show(" 扫码出错:" + ex.ToString());
return null;
}
finally
{
if (bmp != null)
bmp.Dispose();
}
}
int totalcover, hh, hl, ll, lh, sl, sh;
double threshold;
string fName;
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = "c:\\";//注意这里写路径时要用c:\\而不是c:\
openFileDialog.Filter = "图片|*.*";
openFileDialog.RestoreDirectory = true;
openFileDialog.FilterIndex = 1;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
fName = openFileDialog.FileName;
TestHasReel(fName, out string msg);
}
}
private void button2_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(fName))
{
TestHasReel(fName, out string msg);
}
}
void UpdateValue()
{
lblHL.Text = $"CamTestReel_HL(色相):{txtHL.Value}";
hl = txtHL.Value;
lblHH.Text = $"CamTestReel_HH(色相):{txtHH.Value}";
hh = txtHH.Value;
lblLL.Text = $"CamTestReel_LL(亮度):{txtLL.Value}";
ll = txtLL.Value;
lblLH.Text = $"CamTestReel_LH(亮度):{txtLH.Value}";
lh = txtLH.Value;
lblSL.Text = $"CamTestReel_SL(饱和度):{txtSL.Value}";
sl = txtSL.Value;
lblSH.Text = $"CamTestReel_SH(饱和度):{txtSH.Value}";
sh = txtSH.Value;
}
private void button2_Click_1(object sender, EventArgs e)
{
TestRoi.SaveConfig(textBox2.Text);
TestHasReel(fName, out string msg);
}
private void txtHL_Scroll(object sender, EventArgs e)
{
UpdateValue();
button2_Click(null, null);
}
private void txtHH_Scroll(object sender, EventArgs e)
{
UpdateValue();
button2_Click(null, null);
}
private void txtLL_Scroll(object sender, EventArgs e)
{
UpdateValue();
button2_Click(null, null);
}
private void txtLH_Scroll(object sender, EventArgs e)
{
UpdateValue();
button2_Click(null, null);
}
private void button3_Click(object sender, EventArgs e)
{
textBox2.Text = TestRoi.LoadConfig();
}
private void txtthreshold_TextChanged(object sender, EventArgs e)
{
double.TryParse(txtthreshold.Text, out threshold);
button2_Click(null, null);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void txtSL_Scroll(object sender, EventArgs e)
{
UpdateValue();
button2_Click(null, null);
}
private void txtSH_Scroll(object sender, EventArgs e)
{
UpdateValue(); ;
button2_Click(null, null);
}
private void txtTotalCover_TextChanged(object sender, EventArgs e)
{
int.TryParse(txtTotalCover.Text, out totalcover);
button2_Click(null, null);
}
private static List<Point> GetFilledPoints(List<Point> points)
{
List<Point> filledPoints = new List<Point>();
// 获取路径的边界框
int minX = int.MaxValue;
int minY = int.MaxValue;
int maxX = int.MinValue;
int maxY = int.MinValue;
foreach (Point point in points)
{
if (point.X < minX)
{
minX = point.X;
}
if (point.Y < minY)
{
minY = point.Y;
}
if (point.X > maxX)
{
maxX = point.X;
}
if (point.Y > maxY)
{
maxY = point.Y;
}
}
// 遍历边界框内的每个像素点
for (int y = minY; y <= maxY; y++)
{
for (int x = minX; x <= maxX; x++)
{
if (IsPointInPath(x, y, points))
{
filledPoints.Add(new Point(x, y));
}
}
}
return filledPoints;
}
private static bool IsPointInPath(int x, int y, List<Point> points)
{
bool inside = false;
for (int i = 0, j = points.Count - 1; i < points.Count; j = i++)
{
if (((points[i].Y > y) != (points[j].Y > y)) &&
(x < (points[j].X - points[i].X) * (y - points[i].Y) / (points[j].Y - points[i].Y) + points[i].X))
{
inside = !inside;
}
}
return inside;
}
/// <summary>
/// RGB转换HSV
/// </summary>
/// <param name="rgb"></param>
/// <returns></returns>
public static ColorHSV RgbToHsv(ColorRGB rgb)
{
float min, max, tmp, H, S, V;
float R = rgb.R * 1.0f / 255, G = rgb.G * 1.0f / 255, B = rgb.B * 1.0f / 255;
tmp = Math.Min(R, G);
min = Math.Min(tmp, B);
tmp = Math.Max(R, G);
max = Math.Max(tmp, B);
// H
H = 0;
if (max == min)
{
H = 0;
}
else if (max == R && G > B)
{
H = 60 * (G - B) * 1.0f / (max - min) + 0;
}
else if (max == R && G < B)
{
H = 60 * (G - B) * 1.0f / (max - min) + 360;
}
else if (max == G)
{
H = H = 60 * (B - R) * 1.0f / (max - min) + 120;
}
else if (max == B)
{
H = H = 60 * (R - G) * 1.0f / (max - min) + 240;
}
// S
if (max == 0)
{
S = 0;
}
else
{
S = (max - min) * 1.0f / max;
}
// V
V = max;
return new ColorHSV((int)H, (int)(S * 100), (int)(V * 100));
}
}
/// <summary>
/// 类 名:ColorRGB
/// 功 能:R 红色 \ G 绿色 \ B 蓝色 颜色模型
/// 所有颜色模型的基类,RGB是用于输出到屏幕的颜色模式,所以所有模型都将转换成RGB输出
/// 日 期:2015-01-22
/// 修 改:2015-03-20
/// 作 者:ls9512
/// </summary>
public class ColorRGB
{
/// <summary>
/// 构造方法
/// </summary>
/// <param name="r"></param>
/// <param name="g"></param>
/// <param name="b"></param>
public ColorRGB(int r, int g, int b)
{
this._r = r;
this._g = g;
this._b = b;
}
private int _r;
private int _g;
private int _b;
/// <summary>
/// 红色
/// </summary>
public int R
{
get { return this._r; }
set
{
this._r = value;
this._r = this._r > 255 ? 255 : this._r;
this._r = this._r < 0 ? 0 : this._r;
}
}
/// <summary>
/// 绿色
/// </summary>
public int G
{
get { return this._g; }
set
{
this._g = value;
this._g = this._g > 255 ? 255 : this._g;
this._g = this._g < 0 ? 0 : this._g;
}
}
/// <summary>
/// 蓝色
/// </summary>
public int B
{
get { return this._b; }
set
{
this._b = value;
this._b = this._b > 255 ? 255 : this._b;
this._b = this._b < 0 ? 0 : this._b;
}
}
/// <summary>
/// 获取实际颜色
/// </summary>
/// <returns></returns>
public Color GetColor()
{
return Color.FromArgb(this._r, this._g, this._b);
}
}
internal class TestRoi
{
public int CoverCount = 1;
public List<Point> RoiPath = new List<Point>();
const string roifile = "Config\\coverroi.json";
static List<TestRoi> listroi = null;
public static List<TestRoi> GetRois()
{
return listroi;
}
static TestRoi()
{
ReloadConfig();
}
public static string LoadConfig()
{
if (!File.Exists(roifile))
return "";
return File.ReadAllText(roifile);
}
public static void ReloadConfig()
{
if (!File.Exists(roifile))
return;
var roidata = File.ReadAllText(roifile);
listroi = JsonConvert.DeserializeObject<List<TestRoi>>(roidata);
return;
}
public static void SaveConfig(List<TestRoi> data)
{
//if (!File.Exists(roifile))
// return;
var settings = new JsonSerializerSettings
{
Formatting = Newtonsoft.Json.Formatting.Indented,
NullValueHandling = NullValueHandling.Include,
//MissingMemberHandling = MissingMemberHandling.Ignore
};
var dataStr = JsonConvert.SerializeObject(data, settings);
File.WriteAllText(roifile, dataStr);
ReloadConfig();
}
public static void SaveConfig(string data)
{
if (!File.Exists(roifile))
return;
File.WriteAllText(roifile, data);
ReloadConfig();
}
}
/// <summary>
/// 类 名:ColorHSV
/// 功 能:H 色相 \ S 饱和度(纯度) \ V 明度 颜色模型
/// 日 期:2015-01-22
/// 修 改:2015-03-20
/// 作 者:ls9512
/// </summary>
public class ColorHSV
{
/// <summary>
/// 构造方法
/// </summary>
/// <param name="h"></param>
/// <param name="s"></param>
/// <param name="v"></param>
public ColorHSV(int h, int s, int v)
{
this._h = h;
this._s = s;
this._v = v;
}
private int _h;
private int _s;
private int _v;
/// <summary>
/// 色相
/// </summary>
public int H
{
get { return this._h; }
set
{
this._h = value;
this._h = this._h > 360 ? 360 : this._h;
this._h = this._h < 0 ? 0 : this._h;
}
}
/// <summary>
/// 饱和度(纯度)
/// </summary>
public int S
{
get { return this._s; }
set
{
this._s = value;
this._s = this._s > 255 ? 255 : this._s;
this._s = this._s < 0 ? 0 : this._s;
}
}
/// <summary>
/// 明度
/// </summary>
public int V
{
get { return this._v; }
set
{
this._v = value;
this._v = this._v > 255 ? 255 : this._v;
this._v = this._v < 0 ? 0 : this._v;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2BA382F5-D68E-4B03-B6E0-A75662B3938A}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>ImgCheckReel</RootNamespace>
<AssemblyName>ImgCheckReel</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ConfigHelper">
<HintPath>..\..\..\..\..\SharedRefDll\Neotel\ConfigHelper\Debug\net461\ConfigHelper.dll</HintPath>
</Reference>
<Reference Include="Cyotek.Windows.Forms.ImageBox">
<HintPath>.\Cyotek.Windows.Forms.ImageBox.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ImgCheckReel
{
internal static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("ImgCheckReel")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ImgCheckReel")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("2ba382f5-d68e-4b03-b6e0-a75662b3938a")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace ImgCheckReel.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ImgCheckReel.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ImgCheckReel.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
</packages>
\ No newline at end of file \ No newline at end of file
using CodeLibrary; using CodeLibrary;
using DeviceLibrary;
using log4net; using log4net;
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.DeviceLibrary; using OnlineStore.DeviceLibrary;
...@@ -71,6 +72,7 @@ namespace OnlineStore.XLRStore ...@@ -71,6 +72,7 @@ namespace OnlineStore.XLRStore
tabControl1.TabPages.Remove(tabPage1); tabControl1.TabPages.Remove(tabPage1);
timer1.Start(); timer1.Start();
启用配置模式ToolStripMenuItem.Enabled = true; 启用配置模式ToolStripMenuItem.Enabled = true;
WindowManager.Start();
} }
private FrmInputEquip inputEquip = null; private FrmInputEquip inputEquip = null;
private FrmBoxEquip box = null; private FrmBoxEquip box = null;
...@@ -302,6 +304,7 @@ namespace OnlineStore.XLRStore ...@@ -302,6 +304,7 @@ namespace OnlineStore.XLRStore
{ {
Camera._cam.CloseAll(); Camera._cam.CloseAll();
} }
WindowManager.Stop();
System.Environment.Exit(System.Environment.ExitCode); System.Environment.Exit(System.Environment.ExitCode);
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.btnScan = new System.Windows.Forms.Button(); this.btnScan = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel();
this.lblCameraRes = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox(); this.groupBox3 = new System.Windows.Forms.GroupBox();
this.LineStop_A = new System.Windows.Forms.Button(); this.LineStop_A = new System.Windows.Forms.Button();
this.LineBack_A = new System.Windows.Forms.Button(); this.LineBack_A = new System.Windows.Forms.Button();
...@@ -74,6 +77,9 @@ ...@@ -74,6 +77,9 @@
// panel2 // panel2
// //
this.panel2.AutoScroll = true; this.panel2.AutoScroll = true;
this.panel2.Controls.Add(this.lblCameraRes);
this.panel2.Controls.Add(this.button2);
this.panel2.Controls.Add(this.button1);
this.panel2.Controls.Add(this.groupBox3); this.panel2.Controls.Add(this.groupBox3);
this.panel2.Controls.Add(this.groupBox2); this.panel2.Controls.Add(this.groupBox2);
this.panel2.Controls.Add(this.groupBox1); this.panel2.Controls.Add(this.groupBox1);
...@@ -83,9 +89,38 @@ ...@@ -83,9 +89,38 @@
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 0); this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2"; this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(949, 506); this.panel2.Size = new System.Drawing.Size(949, 718);
this.panel2.TabIndex = 324; this.panel2.TabIndex = 324;
// //
// lblCameraRes
//
this.lblCameraRes.AutoSize = true;
this.lblCameraRes.Location = new System.Drawing.Point(28, 611);
this.lblCameraRes.Name = "lblCameraRes";
this.lblCameraRes.Size = new System.Drawing.Size(43, 17);
this.lblCameraRes.TabIndex = 284;
this.lblCameraRes.Text = "label1";
//
// button2
//
this.button2.Location = new System.Drawing.Point(218, 545);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(139, 43);
this.button2.TabIndex = 283;
this.button2.Text = "重新加载AOI配置";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(28, 545);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(139, 43);
this.button1.TabIndex = 282;
this.button1.Text = "料盘检测";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// groupBox3 // groupBox3
// //
this.groupBox3.Controls.Add(this.LineStop_A); this.groupBox3.Controls.Add(this.LineStop_A);
...@@ -309,9 +344,9 @@ ...@@ -309,9 +344,9 @@
this.chbMoveStop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.chbMoveStop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chbMoveStop.AutoSize = true; this.chbMoveStop.AutoSize = true;
this.chbMoveStop.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.chbMoveStop.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbMoveStop.Location = new System.Drawing.Point(302, 86); this.chbMoveStop.Location = new System.Drawing.Point(322, 86);
this.chbMoveStop.Name = "chbMoveStop"; this.chbMoveStop.Name = "chbMoveStop";
this.chbMoveStop.Size = new System.Drawing.Size(104, 28); this.chbMoveStop.Size = new System.Drawing.Size(84, 24);
this.chbMoveStop.TabIndex = 327; this.chbMoveStop.TabIndex = 327;
this.chbMoveStop.Text = "暂停运动"; this.chbMoveStop.Text = "暂停运动";
this.chbMoveStop.UseVisualStyleBackColor = true; this.chbMoveStop.UseVisualStyleBackColor = true;
...@@ -350,9 +385,9 @@ ...@@ -350,9 +385,9 @@
this.chbDebug.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.chbDebug.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chbDebug.AutoSize = true; this.chbDebug.AutoSize = true;
this.chbDebug.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.chbDebug.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbDebug.Location = new System.Drawing.Point(193, 86); this.chbDebug.Location = new System.Drawing.Point(213, 86);
this.chbDebug.Name = "chbDebug"; this.chbDebug.Name = "chbDebug";
this.chbDebug.Size = new System.Drawing.Size(104, 28); this.chbDebug.Size = new System.Drawing.Size(84, 24);
this.chbDebug.TabIndex = 325; this.chbDebug.TabIndex = 325;
this.chbDebug.Text = "调试状态"; this.chbDebug.Text = "调试状态";
this.chbDebug.UseVisualStyleBackColor = true; this.chbDebug.UseVisualStyleBackColor = true;
...@@ -378,7 +413,7 @@ ...@@ -378,7 +413,7 @@
this.lblAgvInfo.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.lblAgvInfo.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.lblAgvInfo.Location = new System.Drawing.Point(5, 62); this.lblAgvInfo.Location = new System.Drawing.Point(5, 62);
this.lblAgvInfo.Name = "lblAgvInfo"; this.lblAgvInfo.Name = "lblAgvInfo";
this.lblAgvInfo.Size = new System.Drawing.Size(75, 20); this.lblAgvInfo.Size = new System.Drawing.Size(61, 17);
this.lblAgvInfo.TabIndex = 282; this.lblAgvInfo.TabIndex = 282;
this.lblAgvInfo.Text = "AGV 状态"; this.lblAgvInfo.Text = "AGV 状态";
// //
...@@ -436,9 +471,9 @@ ...@@ -436,9 +471,9 @@
this.chbAutoOut.Checked = true; this.chbAutoOut.Checked = true;
this.chbAutoOut.CheckState = System.Windows.Forms.CheckState.Checked; this.chbAutoOut.CheckState = System.Windows.Forms.CheckState.Checked;
this.chbAutoOut.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.chbAutoOut.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbAutoOut.Location = new System.Drawing.Point(453, 510); this.chbAutoOut.Location = new System.Drawing.Point(492, 510);
this.chbAutoOut.Name = "chbAutoOut"; this.chbAutoOut.Name = "chbAutoOut";
this.chbAutoOut.Size = new System.Drawing.Size(212, 28); this.chbAutoOut.Size = new System.Drawing.Size(168, 24);
this.chbAutoOut.TabIndex = 280; this.chbAutoOut.TabIndex = 280;
this.chbAutoOut.Text = "入料完成自动开始出库"; this.chbAutoOut.Text = "入料完成自动开始出库";
this.chbAutoOut.UseVisualStyleBackColor = true; this.chbAutoOut.UseVisualStyleBackColor = true;
...@@ -446,9 +481,9 @@ ...@@ -446,9 +481,9 @@
// //
// FrmBatchMove // FrmBatchMove
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(949, 506); this.ClientSize = new System.Drawing.Size(949, 718);
this.Controls.Add(this.panel2); this.Controls.Add(this.panel2);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false; this.MaximizeBox = false;
...@@ -501,6 +536,9 @@ ...@@ -501,6 +536,9 @@
protected System.Windows.Forms.Button btnResetShelf; protected System.Windows.Forms.Button btnResetShelf;
protected System.Windows.Forms.CheckBox chbMoveStop; protected System.Windows.Forms.CheckBox chbMoveStop;
private useControl.AxisPointControl batchAxisP4; private useControl.AxisPointControl batchAxisP4;
private System.Windows.Forms.Label lblCameraRes;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
} }
} }
using System; using DeviceLibrary;
using log4net;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Reflection;
using System.Windows.Forms;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using OnlineStore.DeviceLibrary; using System.Text;
using log4net; using System.Threading;
using System.Reflection; using System.Windows.Forms;
using UserFromControl; using UserFromControl;
using OnlineStore.LoadCSVLibrary;
using OnlineStore.Common;
namespace OnlineStore.XLRStore namespace OnlineStore.XLRStore
{ {
...@@ -174,63 +175,63 @@ namespace OnlineStore.XLRStore ...@@ -174,63 +175,63 @@ namespace OnlineStore.XLRStore
moveBean.BatchAxis.SuddenStop(); moveBean.BatchAxis.SuddenStop();
} }
private void BatchTimerPro() //private void BatchTimerPro()
{ //{
if (moveBean.BatchAxis.IsBatchMove()) // if (moveBean.BatchAxis.IsBatchMove())
{ // {
btnStartTest.Enabled = false; // btnStartTest.Enabled = false;
if (moveBean.LastMoveIsTest) // if (moveBean.LastMoveIsTest)
{ // {
ConfigMoveAxis moveAxis = moveBean.BatchAxis.Config; // ConfigMoveAxis moveAxis = moveBean.BatchAxis.Config;
bool countError = false; // bool countError = false;
bool isStop = false; // bool isStop = false;
bool result = AxisManager.instance.AbsMoveIsEnd(moveAxis.DeviceName, moveAxis.GetAxisValue(), TargetP2, moveAxis.CanErrorCountMax, out countError); // bool result = AxisManager.instance.AbsMoveIsEnd(moveAxis.DeviceName, moveAxis.GetAxisValue(), TargetP2, moveAxis.CanErrorCountMax, out countError);
if (result) // if (result)
{ // {
isStop = true; // isStop = true;
LogUtil.info(moveBean.Name + "提升轴上料功能测试,发现提升轴已到达目标位置【" + TargetP2 + "】,停止上料测试 "); // LogUtil.info(moveBean.Name + "提升轴上料功能测试,发现提升轴已到达目标位置【" + TargetP2 + "】,停止上料测试 ");
} // }
else // else
{ // {
bool axisMoveIsEnd = HuichuanLibrary.HCBoardManager.MoveIsEnd(moveBean.BatchAxis.Config.GetAxisValue()); // bool axisMoveIsEnd = HuichuanLibrary.HCBoardManager.MoveIsEnd(moveBean.BatchAxis.Config.GetAxisValue());
if (axisMoveIsEnd) // if (axisMoveIsEnd)
{ // {
isStop = true; // isStop = true;
LogUtil.info(moveBean.Name + "提升轴上料功能测试,发现提升轴已停止运动,停止上料测试"); // LogUtil.info(moveBean.Name + "提升轴上料功能测试,发现提升轴已停止运动,停止上料测试");
} // }
} // }
if (isStop) // if (isStop)
{ // {
StartTest = false; // StartTest = false;
moveBean.BatchAxis.AxisStopCheckMove(); // moveBean.BatchAxis.AxisStopCheckMove();
btnStartTest.Enabled = true; // btnStartTest.Enabled = true;
btnTestStop.Enabled = false; // btnTestStop.Enabled = false;
int height = moveBean.GetHeight(); // int height = moveBean.GetHeight();
lblTestMsg.Text = "目标位置[" + TargetP2 + "] ,开始位置[" + moveBean.StartMovePosition + "],停止位置[" + moveBean.EndMovePosition + "],高度[" + height + "]mm"; // lblTestMsg.Text = "目标位置[" + TargetP2 + "] ,开始位置[" + moveBean.StartMovePosition + "],停止位置[" + moveBean.EndMovePosition + "],高度[" + height + "]mm";
} // }
else // else
{ // {
btnTestStop.Enabled = true; // btnTestStop.Enabled = true;
} // }
} // }
else // else
{ // {
btnTestStop.Enabled = false; // btnTestStop.Enabled = false;
} // }
} // }
else // else
{ // {
if (StartTest) // if (StartTest)
{ // {
StartTest = false; // StartTest = false;
int height = moveBean.GetHeight(); // int height = moveBean.GetHeight();
lblTestMsg.Text = "目标位置[" + TargetP2 + "] ,开始位置[" + moveBean.StartMovePosition + "],停止位置[" + moveBean.EndMovePosition + "],高度[" + height + "]mm"; // lblTestMsg.Text = "目标位置[" + TargetP2 + "] ,开始位置[" + moveBean.StartMovePosition + "],停止位置[" + moveBean.EndMovePosition + "],高度[" + height + "]mm";
} // }
btnStartTest.Enabled = true; // btnStartTest.Enabled = true;
btnTestStop.Enabled = false; // btnTestStop.Enabled = false;
} // }
} //}
private void chbAutoOut_CheckedChanged(object sender, EventArgs e) private void chbAutoOut_CheckedChanged(object sender, EventArgs e)
{ {
...@@ -323,6 +324,20 @@ namespace OnlineStore.XLRStore ...@@ -323,6 +324,20 @@ namespace OnlineStore.XLRStore
groupBox3.Visible = state; groupBox3.Visible = state;
chbAutoOut.Visible = state; chbAutoOut.Visible = state;
} }
private void button1_Click(object sender, EventArgs e)
{
bool rtn = moveBean.CameraCheck("手动", out string res);
lblCameraRes.Invoke(new Action(() =>
{
lblCameraRes.Text = $"{(rtn ? "检测有料盘" : "检测无料盘")}\r\n{res}";
}));
}
private void button2_Click(object sender, EventArgs e)
{
ReelCheckCamera.ClearProject();
}
} }
} }
......
...@@ -76,9 +76,9 @@ namespace OnlineStore.XLRStore ...@@ -76,9 +76,9 @@ namespace OnlineStore.XLRStore
// //
this.tabPage3.Controls.Add(this.panBase); this.tabPage3.Controls.Add(this.panBase);
this.tabPage3.Controls.Add(this.groupBox6); this.tabPage3.Controls.Add(this.groupBox6);
this.tabPage3.Location = new System.Drawing.Point(4, 29); this.tabPage3.Location = new System.Drawing.Point(4, 26);
this.tabPage3.Name = "tabPage3"; this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(986, 558); this.tabPage3.Size = new System.Drawing.Size(986, 561);
this.tabPage3.TabIndex = 2; this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "状态信息"; this.tabPage3.Text = "状态信息";
this.tabPage3.UseVisualStyleBackColor = true; this.tabPage3.UseVisualStyleBackColor = true;
...@@ -133,7 +133,7 @@ namespace OnlineStore.XLRStore ...@@ -133,7 +133,7 @@ namespace OnlineStore.XLRStore
this.chbMoveStop.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.chbMoveStop.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbMoveStop.Location = new System.Drawing.Point(562, 11); this.chbMoveStop.Location = new System.Drawing.Point(562, 11);
this.chbMoveStop.Name = "chbMoveStop"; this.chbMoveStop.Name = "chbMoveStop";
this.chbMoveStop.Size = new System.Drawing.Size(104, 28); this.chbMoveStop.Size = new System.Drawing.Size(84, 24);
this.chbMoveStop.TabIndex = 262; this.chbMoveStop.TabIndex = 262;
this.chbMoveStop.Text = "暂停运动"; this.chbMoveStop.Text = "暂停运动";
this.chbMoveStop.UseVisualStyleBackColor = true; this.chbMoveStop.UseVisualStyleBackColor = true;
...@@ -157,7 +157,7 @@ namespace OnlineStore.XLRStore ...@@ -157,7 +157,7 @@ namespace OnlineStore.XLRStore
this.chbDebug.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.chbDebug.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbDebug.Location = new System.Drawing.Point(465, 11); this.chbDebug.Location = new System.Drawing.Point(465, 11);
this.chbDebug.Name = "chbDebug"; this.chbDebug.Name = "chbDebug";
this.chbDebug.Size = new System.Drawing.Size(104, 28); this.chbDebug.Size = new System.Drawing.Size(84, 24);
this.chbDebug.TabIndex = 247; this.chbDebug.TabIndex = 247;
this.chbDebug.Text = "调试状态"; this.chbDebug.Text = "调试状态";
this.chbDebug.UseVisualStyleBackColor = true; this.chbDebug.UseVisualStyleBackColor = true;
...@@ -172,7 +172,7 @@ namespace OnlineStore.XLRStore ...@@ -172,7 +172,7 @@ namespace OnlineStore.XLRStore
this.lblStoreStatus.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.lblStoreStatus.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.lblStoreStatus.Location = new System.Drawing.Point(664, 13); this.lblStoreStatus.Location = new System.Drawing.Point(664, 13);
this.lblStoreStatus.Name = "lblStoreStatus"; this.lblStoreStatus.Name = "lblStoreStatus";
this.lblStoreStatus.Size = new System.Drawing.Size(82, 24); this.lblStoreStatus.Size = new System.Drawing.Size(65, 20);
this.lblStoreStatus.TabIndex = 245; this.lblStoreStatus.TabIndex = 245;
this.lblStoreStatus.Text = "等待启动"; this.lblStoreStatus.Text = "等待启动";
this.lblStoreStatus.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.lblStoreStatus.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
...@@ -226,7 +226,7 @@ namespace OnlineStore.XLRStore ...@@ -226,7 +226,7 @@ namespace OnlineStore.XLRStore
this.checkBox1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.checkBox1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.checkBox1.Location = new System.Drawing.Point(10, 328); this.checkBox1.Location = new System.Drawing.Point(10, 328);
this.checkBox1.Name = "checkBox1"; this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(194, 28); this.checkBox1.Size = new System.Drawing.Size(154, 24);
this.checkBox1.TabIndex = 291; this.checkBox1.TabIndex = 291;
this.checkBox1.Text = "检测到料串自动入库"; this.checkBox1.Text = "检测到料串自动入库";
this.checkBox1.UseVisualStyleBackColor = true; this.checkBox1.UseVisualStyleBackColor = true;
...@@ -260,7 +260,7 @@ namespace OnlineStore.XLRStore ...@@ -260,7 +260,7 @@ namespace OnlineStore.XLRStore
this.cmbOutstorePos.FormattingEnabled = true; this.cmbOutstorePos.FormattingEnabled = true;
this.cmbOutstorePos.Location = new System.Drawing.Point(104, 70); this.cmbOutstorePos.Location = new System.Drawing.Point(104, 70);
this.cmbOutstorePos.Name = "cmbOutstorePos"; this.cmbOutstorePos.Name = "cmbOutstorePos";
this.cmbOutstorePos.Size = new System.Drawing.Size(142, 31); this.cmbOutstorePos.Size = new System.Drawing.Size(142, 28);
this.cmbOutstorePos.TabIndex = 290; this.cmbOutstorePos.TabIndex = 290;
// //
// cmbInstorePos // cmbInstorePos
...@@ -270,7 +270,7 @@ namespace OnlineStore.XLRStore ...@@ -270,7 +270,7 @@ namespace OnlineStore.XLRStore
this.cmbInstorePos.FormattingEnabled = true; this.cmbInstorePos.FormattingEnabled = true;
this.cmbInstorePos.Location = new System.Drawing.Point(266, 28); this.cmbInstorePos.Location = new System.Drawing.Point(266, 28);
this.cmbInstorePos.Name = "cmbInstorePos"; this.cmbInstorePos.Name = "cmbInstorePos";
this.cmbInstorePos.Size = new System.Drawing.Size(142, 31); this.cmbInstorePos.Size = new System.Drawing.Size(142, 28);
this.cmbInstorePos.TabIndex = 289; this.cmbInstorePos.TabIndex = 289;
// //
// btnOutStoreTest // btnOutStoreTest
...@@ -296,7 +296,7 @@ namespace OnlineStore.XLRStore ...@@ -296,7 +296,7 @@ namespace OnlineStore.XLRStore
"B下暂存区"}); "B下暂存区"});
this.cmbOutStartP.Location = new System.Drawing.Point(9, 70); this.cmbOutStartP.Location = new System.Drawing.Point(9, 70);
this.cmbOutStartP.Name = "cmbOutStartP"; this.cmbOutStartP.Name = "cmbOutStartP";
this.cmbOutStartP.Size = new System.Drawing.Size(90, 31); this.cmbOutStartP.Size = new System.Drawing.Size(90, 28);
this.cmbOutStartP.TabIndex = 287; this.cmbOutStartP.TabIndex = 287;
this.cmbOutStartP.SelectedIndexChanged += new System.EventHandler(this.cmbOutShelf_SelectedIndexChanged); this.cmbOutStartP.SelectedIndexChanged += new System.EventHandler(this.cmbOutShelf_SelectedIndexChanged);
// //
...@@ -306,7 +306,7 @@ namespace OnlineStore.XLRStore ...@@ -306,7 +306,7 @@ namespace OnlineStore.XLRStore
this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(251, 74); this.label2.Location = new System.Drawing.Point(251, 74);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(39, 24); this.label2.Size = new System.Drawing.Size(31, 20);
this.label2.TabIndex = 286; this.label2.TabIndex = 286;
this.label2.Text = "-->"; this.label2.Text = "-->";
// //
...@@ -320,7 +320,7 @@ namespace OnlineStore.XLRStore ...@@ -320,7 +320,7 @@ namespace OnlineStore.XLRStore
"B料口"}); "B料口"});
this.cmbOutShelf.Location = new System.Drawing.Point(287, 70); this.cmbOutShelf.Location = new System.Drawing.Point(287, 70);
this.cmbOutShelf.Name = "cmbOutShelf"; this.cmbOutShelf.Name = "cmbOutShelf";
this.cmbOutShelf.Size = new System.Drawing.Size(121, 31); this.cmbOutShelf.Size = new System.Drawing.Size(121, 28);
this.cmbOutShelf.TabIndex = 285; this.cmbOutShelf.TabIndex = 285;
// //
// BtnInStoreTest // BtnInStoreTest
...@@ -346,7 +346,7 @@ namespace OnlineStore.XLRStore ...@@ -346,7 +346,7 @@ namespace OnlineStore.XLRStore
"B上暂存区"}); "B上暂存区"});
this.cmbInstoreTargetP.Location = new System.Drawing.Point(171, 28); this.cmbInstoreTargetP.Location = new System.Drawing.Point(171, 28);
this.cmbInstoreTargetP.Name = "cmbInstoreTargetP"; this.cmbInstoreTargetP.Name = "cmbInstoreTargetP";
this.cmbInstoreTargetP.Size = new System.Drawing.Size(90, 31); this.cmbInstoreTargetP.Size = new System.Drawing.Size(90, 28);
this.cmbInstoreTargetP.TabIndex = 2; this.cmbInstoreTargetP.TabIndex = 2;
this.cmbInstoreTargetP.SelectedIndexChanged += new System.EventHandler(this.cmbInstoreTargetP_SelectedIndexChanged); this.cmbInstoreTargetP.SelectedIndexChanged += new System.EventHandler(this.cmbInstoreTargetP_SelectedIndexChanged);
// //
...@@ -356,7 +356,7 @@ namespace OnlineStore.XLRStore ...@@ -356,7 +356,7 @@ namespace OnlineStore.XLRStore
this.label1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(135, 32); this.label1.Location = new System.Drawing.Point(135, 32);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(39, 24); this.label1.Size = new System.Drawing.Size(31, 20);
this.label1.TabIndex = 1; this.label1.TabIndex = 1;
this.label1.Text = "-->"; this.label1.Text = "-->";
// //
...@@ -370,7 +370,7 @@ namespace OnlineStore.XLRStore ...@@ -370,7 +370,7 @@ namespace OnlineStore.XLRStore
"B料口"}); "B料口"});
this.cmbInstoreShelf.Location = new System.Drawing.Point(9, 28); this.cmbInstoreShelf.Location = new System.Drawing.Point(9, 28);
this.cmbInstoreShelf.Name = "cmbInstoreShelf"; this.cmbInstoreShelf.Name = "cmbInstoreShelf";
this.cmbInstoreShelf.Size = new System.Drawing.Size(121, 31); this.cmbInstoreShelf.Size = new System.Drawing.Size(121, 28);
this.cmbInstoreShelf.TabIndex = 0; this.cmbInstoreShelf.TabIndex = 0;
// //
// lblwidth // lblwidth
...@@ -392,7 +392,7 @@ namespace OnlineStore.XLRStore ...@@ -392,7 +392,7 @@ namespace OnlineStore.XLRStore
this.lblMoveInfo.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.lblMoveInfo.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.lblMoveInfo.Location = new System.Drawing.Point(8, 109); this.lblMoveInfo.Location = new System.Drawing.Point(8, 109);
this.lblMoveInfo.Name = "lblMoveInfo"; this.lblMoveInfo.Name = "lblMoveInfo";
this.lblMoveInfo.Size = new System.Drawing.Size(73, 20); this.lblMoveInfo.Size = new System.Drawing.Size(59, 17);
this.lblMoveInfo.TabIndex = 278; this.lblMoveInfo.TabIndex = 278;
this.lblMoveInfo.Text = "运动信息:"; this.lblMoveInfo.Text = "运动信息:";
// //
...@@ -425,7 +425,7 @@ namespace OnlineStore.XLRStore ...@@ -425,7 +425,7 @@ namespace OnlineStore.XLRStore
// //
// FrmInputEquip // FrmInputEquip
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1000, 596); this.ClientSize = new System.Drawing.Size(1000, 596);
this.Controls.Add(this.tabControl1); this.Controls.Add(this.tabControl1);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!