Commit 071e1423 张东亮

监控相机

1 个父辈 e42f8115
此文件类型无法预览
...@@ -62,10 +62,12 @@ ...@@ -62,10 +62,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 log4net.Util;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
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 IntPtr PutIntoForm(Panel panel, string titleName)
{
IntPtr 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
MoveWindow(appWin, 0, 0, panel.Width + 2, panel.Height, true);
return appWin;
}
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;
}
}
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.DeviceLibrary</RootNamespace> <RootNamespace>OnlineStore.DeviceLibrary</RootNamespace>
<AssemblyName>DeviceLibrary</AssemblyName> <AssemblyName>DeviceLibrary</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
......
...@@ -8,4 +8,4 @@ ...@@ -8,4 +8,4 @@
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
...@@ -14,37 +14,17 @@ namespace OnlineStore.DeviceLibrary ...@@ -14,37 +14,17 @@ namespace OnlineStore.DeviceLibrary
{ {
public class IPCameraHelper public class IPCameraHelper
{ {
//"E:\\Codes\\CSharp-Workspace\\MyProject\\WindowsService\\IPCamService\\bin\\Debug\\IPCamService.exe"
static string baseDir = ConfigHelper.Config.Get("IPCamService_HttpServer", "http://localhost:8088");
public static void StartIPCamService() public static void StartIPCamService()
{ {
string appFilePath = ConfigHelper.Config.Get("IPCamService_FilePath", @"D:\IPCamera");
if (Directory.Exists(appFilePath))
{
var exe = "IPCamera.exe";
try
{
Process process = new Process();
process.StartInfo = new ProcessStartInfo();
process.StartInfo.FileName = exe;
process.StartInfo.WorkingDirectory = appFilePath;
process.Start();
LogUtil.info($"启动软件:{appFilePath}\\{exe}");
}
catch (Exception ex)
{
LogUtil.error($"启动软件失败:{appFilePath}\\{exe}",ex);
}
}
} }
public static void StartRecord(string camName, string fileName = "") public static void StartRecord(string camName, string fileName = "")
{ {
Task.Factory.StartNew(delegate Task.Factory.StartNew(delegate
{ {
string url = $"{baseDir}/cam/startRecord?camName={camName}&filename={fileName}"; //string url = $"{baseDir}/cam/startRecord?camName={camName}&filename={fileName}";
string res = HttpHelper.Get(url); //string res = HttpHelper.Get(url);
LogUtil.info($"开始记录视频:{fileName},{res}"); LogUtil.info($"视频开始:{camName},{fileName}");
}); });
} }
...@@ -52,9 +32,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -52,9 +32,9 @@ namespace OnlineStore.DeviceLibrary
{ {
Task.Factory.StartNew(delegate Task.Factory.StartNew(delegate
{ {
string url = $"{baseDir}/cam/stopRecord?camName={camName}"; //string url = $"{baseDir}/cam/stopRecord?camName={camName}";
string res = HttpHelper.Get(url); //string res = HttpHelper.Get(url);
LogUtil.info($"停止记录视频:{res}"); LogUtil.info($"视频结束:{camName}");
}); });
} }
......
using CodeLibrary; using CodeLibrary;
using OnlineStore.Common; using OnlineStore.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -44,7 +44,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -44,7 +44,6 @@ namespace OnlineStore.DeviceLibrary
LoadCamera(false); LoadCamera(false);
CodeLibrary.HDCodeLearnHelper.LoadConfig("", codeStr); CodeLibrary.HDCodeLearnHelper.LoadConfig("", codeStr);
CodeLibrary.EyemDecode.InitModel();
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -147,17 +146,24 @@ namespace OnlineStore.DeviceLibrary ...@@ -147,17 +146,24 @@ namespace OnlineStore.DeviceLibrary
LogUtil.debug(deviceName + " 【" + cameraName + "】取图片完成,开始扫码"); LogUtil.debug(deviceName + " 【" + cameraName + "】取图片完成,开始扫码");
string r = ""; string r = "";
bool eyemNoCode = false; Task eyemtask = Task.Factory.StartNew(delegate
Task eyemtask = Task.Factory.StartNew(delegate { {
List<CodeInfo> tlci = EyemDecode.ModelDecoder(ref bmp); RemoteDecodeHelper.RemoteDecodeParam remoteDecodeParam = new RemoteDecodeHelper.RemoteDecodeParam
{
codeTypeList = codeTypeList.ToArray(),
codeCount = codeCount,
timeout = timeOut
};
List<CodeInfo> tlci = new List<CodeInfo>();
tlci = RemoteDecodeHelper.DecodeRequest(bmp, remoteDecodeParam);
foreach (CodeInfo code in tlci) foreach (CodeInfo code in tlci)
{ {
//LogUtil.info(deviceName + " 【" + cameraName + "】[eyemDecode]" + code.CodeType + "(X: " + code.X + ",Y: " + code.Y + ") " + code.CodeStr);
string str = CodeManager.ReplaceCode(code.CodeStr); string str = CodeManager.ReplaceCode(code.CodeStr);
if (!codeList.Contains(str)) if (!codeList.Contains(str))
{ {
codeList.Add(str); codeList.Add(str);
r = r + "##eyem|" + code.CodeType + "|" + str; r = r + "##remote|" + code.CodeType + "|" + str;
if (!findRightCode) if (!findRightCode)
{ {
findRightCode = HasRightCode(str); findRightCode = HasRightCode(str);
...@@ -169,65 +175,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -169,65 +175,14 @@ namespace OnlineStore.DeviceLibrary
bool taskResult = eyemtask.Wait(60000); bool taskResult = eyemtask.Wait(60000);
if (!taskResult) if (!taskResult)
{ {
LogUtil.error(deviceName + " 【" + cameraName + "】eyem扫码超时"); LogUtil.error(deviceName + " 【" + cameraName + "】扫码超时");
eyemNoCode = true;
} }
if (!isPreScan) if (!findRightCode)
{ {
if (!findRightCode) SaveImageToFile(deviceName, cameraName, bmp);
{
List<CodeInfo> cc = new List<CodeInfo>();
eyemNoCode = true;
foreach (string codeType in codeTypeList)
{
//判断是否是一维码
if (codeType.ToLower().Equals("barcode"))
{
cc = HDCodeHelper.DecodeBarCode(ho_Image);
}
else
{
cc = HDCodeHelper.DecodeCode(ho_Image, codeType, GetCodeParamFilePath(codeType), codeCount, timeOut);
}
foreach (CodeInfo c in cc)
{
string str = CodeManager.ReplaceCode(c.CodeStr);
if (!codeList.Contains(str))
{
codeList.Add(str);
r = r + "##halcon|" + codeType + "|" + str;
if (!findRightCode)
{
findRightCode = HasRightCode(str);
}
}
}
if (findRightCodeBreak && findRightCode)
{
break;
}
}
}
//if (!findRightCode && SaveErrorImageToFile.Equals(1))
if ((!findRightCode) || eyemNoCode)
{
//如果halcon没扫出的,
string nameStr = "";
if (findRightCode && eyemNoCode)
{
nameStr = "eyem";
}
if (!taskResult)
{
nameStr = "eyemTimeOut";
}
SaveImageToFile(deviceName, cameraName + nameStr, bmp);
}
} }
if (deviceName != "" || r != "") if (deviceName != "" || r != "")
{ {
LogUtil.info(deviceName + " 【" + cameraName + "】扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】[" + findRightCode + "]" + ScanCount + " :" + r); LogUtil.info(deviceName + " 【" + cameraName + "】扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】[" + findRightCode + "]" + ScanCount + " :" + r);
...@@ -316,14 +271,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -316,14 +271,14 @@ namespace OnlineStore.DeviceLibrary
//640104 * 3331001202 * 210417624 * 600 * 0011 //640104 * 3331001202 * 210417624 * 600 * 0011
//分号分割后长度=4,L,E,B,R //分号分割后长度=4,L,E,B,R
//TJM211030000146 & 10446500228 & 15000 & 2021 - 06 - 28 & 59K0646169 && 10446 && R02472021102600281 //TJM211030000146 & 10446500228 & 15000 & 2021 - 06 - 28 & 59K0646169 && 10446 && R02472021102600281
// RI & PN & QTY & 4 & BATCH & 5 & 6 & 7 & 8 // RI & PN & QTY & 4 & BATCH & 5 & 6 & 7 & 8
// RI & PN & QTY & PRODATEyyyy - MM - dd & 5 & 6 & 7 & 8 & 9 // RI & PN & QTY & PRODATEyyyy - MM - dd & 5 & 6 & 7 & 8 & 9
try try
{ {
foreach (string code in codes) foreach (string code in codes)
{ {
string[] strarray = code.Split('&'); string[] strarray = code.Split('&');
if (strarray.Length >=5) if (strarray.Length >= 5)
{ {
try try
{ {
...@@ -336,7 +291,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -336,7 +291,7 @@ namespace OnlineStore.DeviceLibrary
if (QTY > 0) if (QTY > 0)
{ {
return true; return true;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -111,7 +111,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -111,7 +111,6 @@ namespace OnlineStore.DeviceLibrary
//CSVPositionReader<DrawerPosition>.AddCSVFile(drawConfigFile); //CSVPositionReader<DrawerPosition>.AddCSVFile(drawConfigFile);
XLRStore = new XLRStoreBean(Config, inputConfig, boxConfig); XLRStore = new XLRStoreBean(Config, inputConfig, boxConfig);
IPCameraHelper.StartIPCamService();
LogUtil.info("加载 完成!"); LogUtil.info("加载 完成!");
return true; return true;
} }
......
...@@ -25,16 +25,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -25,16 +25,16 @@ namespace OnlineStore.DeviceLibrary
{ {
if (loadCameraState) if (loadCameraState)
return; return;
string path = @".\Config\Camera.json"; //string path = @".\Config\Camera.json";
if (!File.Exists(path)) //if (!File.Exists(path))
{ //{
LogUtil.error(Name + "找不到监控相机配置文件" + path); // LogUtil.error(Name + "找不到监控相机配置文件" + path);
} //}
camera = new Asa.Camera.VisionLib(path); //camera = new Asa.Camera.VisionLib(path);
camerathread = new Thread[2]; //camerathread = new Thread[2];
//pictureBox1.Image = bmp; ////pictureBox1.Image = bmp;
StartCamera(); //StartCamera();
loadCameraState = true; loadCameraState = true;
} }
void StartCamera() void StartCamera()
...@@ -50,22 +50,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -50,22 +50,6 @@ namespace OnlineStore.DeviceLibrary
//camerathread[1].Start("box_B"); //camerathread[1].Start("box_B");
} }
void startMonitor(object obj)
{
if (!loadCameraState)
{
LogUtil.error(Name + "监控相机初始化失败,无法开启");
return;
}
string name = (string)obj;
while (IsOpen)
{
Bitmap bmp = AcqImage(name);
if (bmp != null)
camera_event?.Invoke(new CameraArgs(name, bmp));
Thread.Sleep(300);
}
}
public Bitmap AcqImage(string camName) public Bitmap AcqImage(string camName)
{ {
Bitmap bitmap = camera.GetImage(camName); Bitmap bitmap = camera.GetImage(camName);
...@@ -74,45 +58,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -74,45 +58,6 @@ namespace OnlineStore.DeviceLibrary
string imgPath = ConfigAppSettings.GetValue(Setting_Init.ImagePath); string imgPath = ConfigAppSettings.GetValue(Setting_Init.ImagePath);
public void SaveImage(string camName) public void SaveImage(string camName)
{ {
try
{
if (MoveInfo.MoveParam == null)
{
string path = Application.StartupPath + imgPath + "Records\\" + DateTime.Now.ToString("yyyyMMdd");
if (AutoSaveImage)
{
if (!System.IO.Directory.Exists(path))
Directory.CreateDirectory(path);
Task.Factory.StartNew(() =>
{
camera.SaveImage(camName, path, $"{camName}-{DateTime.Now.ToString("hhmmssfff")}", System.Drawing.Imaging.ImageFormat.Bmp);
});
}
}
else
{
if (MoveInfo.MoveParam.PosInfo != null)
{
InOutPosInfo inOutPosInfo = MoveInfo.MoveParam.PosInfo;
string path = Application.StartupPath + imgPath + "Records\\" + DateTime.Now.ToString("yyyyMMdd") + "\\" + inOutPosInfo.PosId;
if (AutoSaveImage)
{
if (!System.IO.Directory.Exists(path))
Directory.CreateDirectory(path);
Task.Factory.StartNew(() =>
{
camera.SaveImage(camName, path, $"{camName}-{inOutPosInfo.barcode}-{MoveInfo.MoveType}-{DateTime.Now.ToString("hhmmssfff")}", System.Drawing.Imaging.ImageFormat.Bmp);
});
}
}
}
}
catch (Exception ex)
{
LogUtil.error($"保存{camName}图片失败", ex);
}
} }
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<configSections> <configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections> </configSections>
<log4net> <log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs/XLR-SO908.log" /> <file value="logs/XLR-SO908.log"/>
<param name="Encoding" value="UTF-8" /> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true" /> <appendToFile value="true"/>
<rollingStyle value="Date" /> <rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd" /> <datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" /> <conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout> </layout>
</appender> </appender>
<appender name="TheRFID" type="log4net.Appender.RollingFileAppender"> <appender name="TheRFID" type="log4net.Appender.RollingFileAppender">
<file value="logs/rfid/TheRFID-line.log" /> <file value="logs/rfid/TheRFID-line.log"/>
<param name="Encoding" value="UTF-8" /> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true" /> <appendToFile value="true"/>
<rollingStyle value="Date" /> <rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd" /> <datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" /> <conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout> </layout>
</appender> </appender>
<appender name="Rmaxis" type="log4net.Appender.RollingFileAppender"> <appender name="Rmaxis" type="log4net.Appender.RollingFileAppender">
<file value="logs/rmaix/Rmaxis-line.log" /> <file value="logs/rmaix/Rmaxis-line.log"/>
<param name="Encoding" value="UTF-8" /> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true" /> <appendToFile value="true"/>
<rollingStyle value="Date" /> <rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd" /> <datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" /> <conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout> </layout>
</appender> </appender>
<logger name="RollingLogFileAppender"> <logger name="RollingLogFileAppender">
<level value="Info" /> <level value="Info"/>
<appender-ref ref="RollingLogFileAppender" /> <appender-ref ref="RollingLogFileAppender"/>
</logger> </logger>
<logger name="TheRFID"> <logger name="TheRFID">
<level value="Info" /> <level value="Info"/>
<appender-ref ref="TheRFID" /> <appender-ref ref="TheRFID"/>
</logger> </logger>
<logger name="Rmaxis"> <logger name="Rmaxis">
<level value="Info" /> <level value="Info"/>
<appender-ref ref="Rmaxis" /> <appender-ref ref="Rmaxis"/>
</logger> </logger>
<!--<root> <!--<root>
<level value="Info" /> <level value="Info" />
...@@ -52,14 +52,14 @@ ...@@ -52,14 +52,14 @@
</root>--> </root>-->
</log4net> </log4net>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup> </startup>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" /> <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.12.0" newVersion="2.0.12.0" /> <bindingRedirect oldVersion="0.0.0.0-2.0.12.0" newVersion="2.0.12.0"/>
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
</configuration>
\ No newline at end of file \ No newline at end of file
</configuration>
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
this.BoxControl = new OnlineStore.XLRStore.EquipControl(); this.BoxControl = new OnlineStore.XLRStore.EquipControl();
this.ShelfAControl = new OnlineStore.XLRStore.EquipControl(); this.ShelfAControl = new OnlineStore.XLRStore.EquipControl();
this.ShelfBControl = new OnlineStore.XLRStore.EquipControl(); this.ShelfBControl = new OnlineStore.XLRStore.EquipControl();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.panelVideo = new System.Windows.Forms.Panel();
this.lblStatus = new System.Windows.Forms.Label(); this.lblStatus = new System.Windows.Forms.Label();
this.lblWarnMsg = new System.Windows.Forms.Label(); this.lblWarnMsg = new System.Windows.Forms.Label();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
...@@ -69,6 +71,7 @@ ...@@ -69,6 +71,7 @@
this.托盘初始化ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.托盘初始化ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator16 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator16 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.查看监控ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.帮助ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.帮助ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.清空日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.清空日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
...@@ -85,12 +88,12 @@ ...@@ -85,12 +88,12 @@
this.toolStripSeparator17 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator17 = new System.Windows.Forms.ToolStripSeparator();
this.禁用安全光栅ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.禁用安全光栅ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.启用门禁ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.启用门禁ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.查看监控ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout(); this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout(); this.tabPage2.SuspendLayout();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
this.tabPage3.SuspendLayout();
this.contextMenuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
...@@ -102,6 +105,7 @@ ...@@ -102,6 +105,7 @@
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.tabControl1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tabControl1.Location = new System.Drawing.Point(4, 78); this.tabControl1.Location = new System.Drawing.Point(4, 78);
this.tabControl1.Multiline = true; this.tabControl1.Multiline = true;
...@@ -293,6 +297,24 @@ ...@@ -293,6 +297,24 @@
this.ShelfBControl.TabIndex = 7; this.ShelfBControl.TabIndex = 7;
this.ShelfBControl.WorkStatus = "暂未启动"; this.ShelfBControl.WorkStatus = "暂未启动";
// //
// tabPage3
//
this.tabPage3.Controls.Add(this.panelVideo);
this.tabPage3.Location = new System.Drawing.Point(4, 60);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(192, 36);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "监控";
this.tabPage3.UseVisualStyleBackColor = true;
//
// panelVideo
//
this.panelVideo.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelVideo.Location = new System.Drawing.Point(0, 0);
this.panelVideo.Name = "panelVideo";
this.panelVideo.Size = new System.Drawing.Size(192, 36);
this.panelVideo.TabIndex = 0;
//
// lblStatus // lblStatus
// //
this.lblStatus.AutoSize = true; this.lblStatus.AutoSize = true;
...@@ -447,39 +469,46 @@ ...@@ -447,39 +469,46 @@
// toolStripSeparator6 // toolStripSeparator6
// //
this.toolStripSeparator6.Name = "toolStripSeparator6"; this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(221, 6); this.toolStripSeparator6.Size = new System.Drawing.Size(215, 6);
this.toolStripSeparator6.Visible = false; this.toolStripSeparator6.Visible = false;
// //
// 二维码学习ToolStripMenuItem // 二维码学习ToolStripMenuItem
// //
this.二维码学习ToolStripMenuItem.Name = "二维码学习ToolStripMenuItem"; this.二维码学习ToolStripMenuItem.Name = "二维码学习ToolStripMenuItem";
this.二维码学习ToolStripMenuItem.Size = new System.Drawing.Size(224, 32); this.二维码学习ToolStripMenuItem.Size = new System.Drawing.Size(218, 32);
this.二维码学习ToolStripMenuItem.Text = "二维码学习"; this.二维码学习ToolStripMenuItem.Text = "二维码学习";
this.二维码学习ToolStripMenuItem.Click += new System.EventHandler(this.二维码学习ToolStripMenuItem_Click); this.二维码学习ToolStripMenuItem.Click += new System.EventHandler(this.二维码学习ToolStripMenuItem_Click);
// //
// toolStripSeparator7 // toolStripSeparator7
// //
this.toolStripSeparator7.Name = "toolStripSeparator7"; this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(221, 6); this.toolStripSeparator7.Size = new System.Drawing.Size(215, 6);
// //
// 托盘初始化ToolStripMenuItem // 托盘初始化ToolStripMenuItem
// //
this.托盘初始化ToolStripMenuItem.Name = "托盘初始化ToolStripMenuItem"; this.托盘初始化ToolStripMenuItem.Name = "托盘初始化ToolStripMenuItem";
this.托盘初始化ToolStripMenuItem.Size = new System.Drawing.Size(224, 32); this.托盘初始化ToolStripMenuItem.Size = new System.Drawing.Size(218, 32);
this.托盘初始化ToolStripMenuItem.Text = "托盘编码"; this.托盘初始化ToolStripMenuItem.Text = "托盘编码";
// //
// toolStripSeparator16 // toolStripSeparator16
// //
this.toolStripSeparator16.Name = "toolStripSeparator16"; this.toolStripSeparator16.Name = "toolStripSeparator16";
this.toolStripSeparator16.Size = new System.Drawing.Size(221, 6); this.toolStripSeparator16.Size = new System.Drawing.Size(215, 6);
// //
// toolStripMenuItem3 // toolStripMenuItem3
// //
this.toolStripMenuItem3.Name = "toolStripMenuItem3"; this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(224, 32); this.toolStripMenuItem3.Size = new System.Drawing.Size(218, 32);
this.toolStripMenuItem3.Text = "脆盘料号配置"; this.toolStripMenuItem3.Text = "脆盘料号配置";
this.toolStripMenuItem3.Click += new System.EventHandler(this.toolStripMenuItem3_Click); this.toolStripMenuItem3.Click += new System.EventHandler(this.toolStripMenuItem3_Click);
// //
// 查看监控ToolStripMenuItem
//
this.查看监控ToolStripMenuItem.Name = "查看监控ToolStripMenuItem";
this.查看监控ToolStripMenuItem.Size = new System.Drawing.Size(218, 32);
this.查看监控ToolStripMenuItem.Text = "查看监控";
this.查看监控ToolStripMenuItem.Click += new System.EventHandler(this.查看监控ToolStripMenuItem_Click);
//
// 帮助ToolStripMenuItem // 帮助ToolStripMenuItem
// //
this.帮助ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.帮助ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
...@@ -606,13 +635,6 @@ ...@@ -606,13 +635,6 @@
this.启用门禁ToolStripMenuItem.Text = "启用门禁"; this.启用门禁ToolStripMenuItem.Text = "启用门禁";
this.启用门禁ToolStripMenuItem.Click += new System.EventHandler(this.启用门禁ToolStripMenuItem_Click); this.启用门禁ToolStripMenuItem.Click += new System.EventHandler(this.启用门禁ToolStripMenuItem_Click);
// //
// 查看监控ToolStripMenuItem
//
this.查看监控ToolStripMenuItem.Name = "查看监控ToolStripMenuItem";
this.查看监控ToolStripMenuItem.Size = new System.Drawing.Size(224, 32);
this.查看监控ToolStripMenuItem.Text = "查看监控";
this.查看监控ToolStripMenuItem.Click += new System.EventHandler(this.查看监控ToolStripMenuItem_Click);
//
// FrmXLRStore // FrmXLRStore
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
...@@ -638,6 +660,7 @@ ...@@ -638,6 +660,7 @@
this.tabPage2.ResumeLayout(false); this.tabPage2.ResumeLayout(false);
this.panel1.ResumeLayout(false); this.panel1.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
this.contextMenuStrip1.ResumeLayout(false); this.contextMenuStrip1.ResumeLayout(false);
this.menuStrip1.ResumeLayout(false); this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout(); this.menuStrip1.PerformLayout();
...@@ -704,6 +727,8 @@ ...@@ -704,6 +727,8 @@
private System.Windows.Forms.ToolStripMenuItem 禁用安全光栅ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 禁用安全光栅ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 启用门禁ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 启用门禁ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 查看监控ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 查看监控ToolStripMenuItem;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.Panel panelVideo;
} }
} }
using CodeLibrary; using CodeLibrary;
using Common;
using log4net; using log4net;
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.DeviceLibrary; using OnlineStore.DeviceLibrary;
...@@ -19,7 +20,7 @@ using System.Windows.Forms; ...@@ -19,7 +20,7 @@ using System.Windows.Forms;
namespace OnlineStore.XLRStore namespace OnlineStore.XLRStore
{ {
internal partial class FrmXLRStore : FrmBase internal partial class FrmXLRStore : FrmBase
{ {
private XLRStoreBean StoreBean = null; private XLRStoreBean StoreBean = null;
private List<TabPage> tabPageList = new List<TabPage>(); private List<TabPage> tabPageList = new List<TabPage>();
private bool LoadOk = false; private bool LoadOk = false;
...@@ -28,6 +29,7 @@ namespace OnlineStore.XLRStore ...@@ -28,6 +29,7 @@ namespace OnlineStore.XLRStore
{ {
CheckForIllegalCrossThreadCalls = false; CheckForIllegalCrossThreadCalls = false;
InitializeComponent(); InitializeComponent();
LoadWindow();
startTimer = new System.Timers.Timer(); startTimer = new System.Timers.Timer();
startTimer.Interval = 1000; startTimer.Interval = 1000;
startTimer.Enabled = false; startTimer.Enabled = false;
...@@ -44,8 +46,8 @@ namespace OnlineStore.XLRStore ...@@ -44,8 +46,8 @@ namespace OnlineStore.XLRStore
Application.Exit(); Application.Exit();
return; return;
} }
LoadStoreData(); LoadStoreData();
this.Opacity = 100; this.Opacity = 100;
this.Visible = true; this.Visible = true;
...@@ -61,13 +63,13 @@ namespace OnlineStore.XLRStore ...@@ -61,13 +63,13 @@ namespace OnlineStore.XLRStore
{ {
禁用安全光栅ToolStripMenuItem.Text = "禁用安全光栅"; 禁用安全光栅ToolStripMenuItem.Text = "禁用安全光栅";
} }
if(StoreManager.DisBoxSecurityAccess) if (StoreManager.DisBoxSecurityAccess)
{ {
启用门禁ToolStripMenuItem.Text = gouStr + "禁用门禁"; 启用门禁ToolStripMenuItem.Text = gouStr + "禁用门禁";
} }
else else
{ {
启用门禁ToolStripMenuItem.Text= "禁用门禁"; 启用门禁ToolStripMenuItem.Text = "禁用门禁";
} }
//tabControl1.TabPages.Remove(tabPage5); //tabControl1.TabPages.Remove(tabPage5);
timer1.Start(); timer1.Start();
...@@ -116,7 +118,7 @@ namespace OnlineStore.XLRStore ...@@ -116,7 +118,7 @@ namespace OnlineStore.XLRStore
lastLogTime = DateTime.Now.AddMinutes(-10); lastLogTime = DateTime.Now.AddMinutes(-10);
this.Opacity = 100; this.Opacity = 100;
ReelControlA1.ShowData("A上暂存区物料", BufferDataManager.AInStoreInfo,IO_VALUE.HIGH); ReelControlA1.ShowData("A上暂存区物料", BufferDataManager.AInStoreInfo, IO_VALUE.HIGH);
ReelControlA2.ShowData("A下暂存区物料", BufferDataManager.AOutStoreInfo, IO_VALUE.LOW); ReelControlA2.ShowData("A下暂存区物料", BufferDataManager.AOutStoreInfo, IO_VALUE.LOW);
ReelControlB1.ShowData("B上暂存区物料", BufferDataManager.BInStoreInfo, IO_VALUE.LOW); ReelControlB1.ShowData("B上暂存区物料", BufferDataManager.BInStoreInfo, IO_VALUE.LOW);
ReelControlB2.ShowData("B下暂存区物料", BufferDataManager.BOutStoreInfo, IO_VALUE.LOW); ReelControlB2.ShowData("B下暂存区物料", BufferDataManager.BOutStoreInfo, IO_VALUE.LOW);
...@@ -217,7 +219,7 @@ namespace OnlineStore.XLRStore ...@@ -217,7 +219,7 @@ namespace OnlineStore.XLRStore
/// </summary> /// </summary>
/// <param name="posId"></param> /// <param name="posId"></param>
/// <param name="barcode"></param> /// <param name="barcode"></param>
private void DisablePos(string posId,string barcode) private void DisablePos(string posId, string barcode)
{ {
SServerManager.DisablePos(StoreManager.XLRStore.Name, barcode, posId); SServerManager.DisablePos(StoreManager.XLRStore.Name, barcode, posId);
} }
...@@ -241,13 +243,13 @@ namespace OnlineStore.XLRStore ...@@ -241,13 +243,13 @@ namespace OnlineStore.XLRStore
tabPageList.Add(lineTabPage); tabPageList.Add(lineTabPage);
tabControl1.Controls.Add(lineTabPage); tabControl1.Controls.Add(lineTabPage);
} }
private void HideForm() private void HideForm()
{ {
this.Opacity = 0; this.Opacity = 0;
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.notifyIcon1.Visible = true; this.notifyIcon1.Visible = true;
this.Hide(); this.Hide();
GC.Collect(); GC.Collect();
} }
...@@ -286,7 +288,7 @@ namespace OnlineStore.XLRStore ...@@ -286,7 +288,7 @@ namespace OnlineStore.XLRStore
if (!StoreBean.runStatus.Equals(RunStatus.Wait)) if (!StoreBean.runStatus.Equals(RunStatus.Wait))
{ {
LogUtil.info("即将退出程序,停止" + StoreBean.Name + "运行 "); LogUtil.info("即将退出程序,停止" + StoreBean.Name + "运行 ");
StoreBean.StopRun(); StoreBean.StopRun();
} }
IOManager.instance.CloseAllDO(); IOManager.instance.CloseAllDO();
IOManager.instance.CloseAllConnection(); IOManager.instance.CloseAllConnection();
...@@ -296,7 +298,30 @@ namespace OnlineStore.XLRStore ...@@ -296,7 +298,30 @@ namespace OnlineStore.XLRStore
if (Camera._cam != null) if (Camera._cam != null)
{ {
Camera._cam.CloseAll(); Camera._cam.CloseAll();
} }
try
{
foreach (var wnd in WindowManager.windInfos)
{
if (wnd.WindowHandle != IntPtr.Zero)
{
WindowUtil.PostMessage(wnd.WindowHandle, WindowUtil.WM_CLOSE, 0, 0);
// Delay for it to get the message
System.Threading.Thread.Sleep(1000);
// Clear internal handle
wnd.WindowHandle = IntPtr.Zero;
}
else if (wnd.ProcessInfo != null)
{
wnd.ProcessInfo.Close();
}
}
}catch(Exception ex)
{
LogUtil.error("释放监控相机异常",ex);
}
System.Environment.Exit(System.Environment.ExitCode); System.Environment.Exit(System.Environment.ExitCode);
} }
catch (Exception ex) catch (Exception ex)
...@@ -324,7 +349,7 @@ namespace OnlineStore.XLRStore ...@@ -324,7 +349,7 @@ namespace OnlineStore.XLRStore
this.notifyIcon1.Visible = false; this.notifyIcon1.Visible = false;
this.ShowInTaskbar = true; this.ShowInTaskbar = true;
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -336,7 +361,7 @@ namespace OnlineStore.XLRStore ...@@ -336,7 +361,7 @@ namespace OnlineStore.XLRStore
{ {
if (StoreBean.runStatus != RunStatus.Wait) if (StoreBean.runStatus != RunStatus.Wait)
{ {
MessageBox.Show(StoreBean.Name + "当前状态:" + StoreBean.runStatus + ",不能启动!","提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show(StoreBean.Name + "当前状态:" + StoreBean.runStatus + ",不能启动!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return; return;
} }
LogUtil.info("点击 开始启动"); LogUtil.info("点击 开始启动");
...@@ -365,9 +390,9 @@ namespace OnlineStore.XLRStore ...@@ -365,9 +390,9 @@ namespace OnlineStore.XLRStore
} }
private void formLineStatus(bool isStart) private void formLineStatus(bool isStart)
{ {
启动AToolStripMenuItem.Enabled = !isStart; 启动AToolStripMenuItem.Enabled = !isStart;
停止TToolStripMenuItem.Enabled = isStart; 停止TToolStripMenuItem.Enabled = isStart;
} }
private void 停止所有料仓TToolStripMenuItem_Click(object sender, EventArgs e) private void 停止所有料仓TToolStripMenuItem_Click(object sender, EventArgs e)
{ {
...@@ -426,7 +451,7 @@ namespace OnlineStore.XLRStore ...@@ -426,7 +451,7 @@ namespace OnlineStore.XLRStore
#region 内存回收 #region 内存回收
[DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")] [DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize); public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
public static void ClearMemory() public static void ClearMemory()
{ {
try try
...@@ -479,33 +504,33 @@ namespace OnlineStore.XLRStore ...@@ -479,33 +504,33 @@ namespace OnlineStore.XLRStore
} }
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
{ {
LogM(); LogM();
string canScanCode = ""; string canScanCode = "";
lblStatus.Text = StoreBean.GetRunStr() + canScanCode; lblStatus.Text = StoreBean.GetRunStr() + canScanCode;
string warnMsg = ""; string warnMsg = "";
List<DeviceBase> deviceBases = new List<DeviceBase>() { StoreManager.XLRStore, StoreManager.XLRStore.inputEquip, StoreManager.XLRStore.boxEquip }; List<DeviceBase> deviceBases = new List<DeviceBase>() { StoreManager.XLRStore, StoreManager.XLRStore.inputEquip, StoreManager.XLRStore.boxEquip };
//if (StoreManager.XLRStore.runStatus > RunStatus.Wait) //if (StoreManager.XLRStore.runStatus > RunStatus.Wait)
//{ //{
// string time = StoreManager.XLRStore.alarmType.Equals(AlarmType.None) ? "" : StoreManager.XLRStore.LastAlarmTime.ToLongTimeString(); // string time = StoreManager.XLRStore.alarmType.Equals(AlarmType.None) ? "" : StoreManager.XLRStore.LastAlarmTime.ToLongTimeString();
// warnMsg = StoreManager.XLRStore.WarnMsg.Equals("") ? "" : (time + StoreManager.XLRStore.WarnMsg + "\r\n"); // warnMsg = StoreManager.XLRStore.WarnMsg.Equals("") ? "" : (time + StoreManager.XLRStore.WarnMsg + "\r\n");
//} //}
foreach(DeviceBase device in deviceBases) foreach (DeviceBase device in deviceBases)
{ {
if (device.runStatus > RunStatus.Wait) if (device.runStatus > RunStatus.Wait)
{ {
if (!device.WarnMsg.Equals("")) if (!device.WarnMsg.Equals(""))
{ {
string time = device.alarmType.Equals(AlarmType.None) ? "" : device.LastAlarmTime.ToLongTimeString(); string time = device.alarmType.Equals(AlarmType.None) ? "" : device.LastAlarmTime.ToLongTimeString();
warnMsg += device.WarnMsg.Equals("") ? "" : (time + device.WarnMsg + "\r\n"); warnMsg += device.WarnMsg.Equals("") ? "" : (time + device.WarnMsg + "\r\n");
} }
} }
} }
lblWarnMsg.Text = warnMsg; lblWarnMsg.Text = warnMsg;
BoxEquip box = StoreManager.XLRStore.boxEquip; BoxEquip box = StoreManager.XLRStore.boxEquip;
BoxControl.ShowData(box.IsDebug, box.GetRunStr(), box.WarnMsg, box.MoveInfo, box.GetShowColor()); BoxControl.ShowData(box.IsDebug, box.GetRunStr(), box.WarnMsg, box.MoveInfo, box.GetShowColor());
InputEquip input = StoreManager.XLRStore.inputEquip; InputEquip input = StoreManager.XLRStore.inputEquip;
...@@ -514,7 +539,7 @@ namespace OnlineStore.XLRStore ...@@ -514,7 +539,7 @@ namespace OnlineStore.XLRStore
ShelfBControl.ShowData(true, "", input.BatchMove_B.WarnMsg, input.BatchMove_B.MoveInfo, input.BatchMove_B.GetShowColor(), input.BatchMove_B.CurrShelf?.ToStr()); ShelfBControl.ShowData(true, "", input.BatchMove_B.WarnMsg, input.BatchMove_B.MoveInfo, input.BatchMove_B.GetShowColor(), input.BatchMove_B.CurrShelf?.ToStr());
ReelControlA1.ShowData("A上暂存区物料", BufferDataManager.AInStoreInfo,input.IOValue(IO_Type.UpperArea_Check_A)); ReelControlA1.ShowData("A上暂存区物料", BufferDataManager.AInStoreInfo, input.IOValue(IO_Type.UpperArea_Check_A));
ReelControlA2.ShowData("A下暂存区物料", BufferDataManager.AOutStoreInfo, input.IOValue(IO_Type.UnderArea_Check_A)); ReelControlA2.ShowData("A下暂存区物料", BufferDataManager.AOutStoreInfo, input.IOValue(IO_Type.UnderArea_Check_A));
ReelControlB1.ShowData("B上暂存区物料", BufferDataManager.BInStoreInfo, input.IOValue(IO_Type.UpperArea_Check_B)); ReelControlB1.ShowData("B上暂存区物料", BufferDataManager.BInStoreInfo, input.IOValue(IO_Type.UpperArea_Check_B));
ReelControlB2.ShowData("B下暂存区物料", BufferDataManager.BOutStoreInfo, input.IOValue(IO_Type.UnderArea_Check_B)); ReelControlB2.ShowData("B下暂存区物料", BufferDataManager.BOutStoreInfo, input.IOValue(IO_Type.UnderArea_Check_B));
...@@ -541,7 +566,7 @@ namespace OnlineStore.XLRStore ...@@ -541,7 +566,7 @@ namespace OnlineStore.XLRStore
SetMenuS(启动AToolStripMenuItem, true); SetMenuS(启动AToolStripMenuItem, true);
SetMenuS(复位RToolStripMenuItem, false); SetMenuS(复位RToolStripMenuItem, false);
SetMenuS(停止TToolStripMenuItem, false); SetMenuS(停止TToolStripMenuItem, false);
} }
} }
private void SetMenuS(ToolStripMenuItem toolMenu, bool isEn) private void SetMenuS(ToolStripMenuItem toolMenu, bool isEn)
{ {
...@@ -581,19 +606,19 @@ namespace OnlineStore.XLRStore ...@@ -581,19 +606,19 @@ namespace OnlineStore.XLRStore
FrmAbout about = new FrmAbout(); FrmAbout about = new FrmAbout();
about.ShowDialog(); about.ShowDialog();
} }
private void 二维码学习ToolStripMenuItem_Click(object sender, EventArgs e) private void 二维码学习ToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (Camera._cam != null) if (Camera._cam != null)
{ {
Camera._cam.CloseAll(); Camera._cam.CloseAll();
}
CodeLibrary.FrmCodeDecode frm = new CodeLibrary.FrmCodeDecode(false);
frm.ShowDialog();
frm.Dispose();
} }
CodeLibrary.FrmCodeDecode frm = new CodeLibrary.FrmCodeDecode();
frm.ShowDialog();
frm.Dispose();
}
private void 退出ToolStripMenuItem_Click_1(object sender, EventArgs e) private void 退出ToolStripMenuItem_Click_1(object sender, EventArgs e)
{ {
...@@ -605,8 +630,8 @@ namespace OnlineStore.XLRStore ...@@ -605,8 +630,8 @@ namespace OnlineStore.XLRStore
{ {
ExitApp(); ExitApp();
} }
private void logBox_VisibleChanged(object sender, EventArgs e) private void logBox_VisibleChanged(object sender, EventArgs e)
{ {
...@@ -622,15 +647,15 @@ namespace OnlineStore.XLRStore ...@@ -622,15 +647,15 @@ namespace OnlineStore.XLRStore
private void 清空日志ToolStripMenuItem_Click(object sender, EventArgs e) private void 清空日志ToolStripMenuItem_Click(object sender, EventArgs e)
{ {
LogUtil.ClearLog(); LogUtil.ClearLog();
} }
private void 复制日志ToolStripMenuItem_Click(object sender, EventArgs e) private void 复制日志ToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Clipboard.SetDataObject(logBox.Text); Clipboard.SetDataObject(logBox.Text);
MessageBox.Show("已复制日志到粘贴板!"); MessageBox.Show("已复制日志到粘贴板!");
} }
private string gouStr = "✔"; private string gouStr = "✔";
private void 开机自动启动ToolStripMenuItem_Click(object sender, EventArgs e) private void 开机自动启动ToolStripMenuItem_Click(object sender, EventArgs e)
{ {
...@@ -689,7 +714,7 @@ namespace OnlineStore.XLRStore ...@@ -689,7 +714,7 @@ namespace OnlineStore.XLRStore
{ {
return; return;
} }
AgvClient.SetCancelState(result); AgvClient.SetCancelState(result);
if (result) if (result)
{ {
aGVCancelStateToolStripMenuItem.Text = gouStr + " AGV cancelState"; aGVCancelStateToolStripMenuItem.Text = gouStr + " AGV cancelState";
...@@ -700,10 +725,10 @@ namespace OnlineStore.XLRStore ...@@ -700,10 +725,10 @@ namespace OnlineStore.XLRStore
} }
LogUtil.info(Name + " 点击:" + aGVCancelStateToolStripMenuItem.Text); LogUtil.info(Name + " 点击:" + aGVCancelStateToolStripMenuItem.Text);
} }
private void toolStripMenuItem3_Click(object sender, EventArgs e) private void toolStripMenuItem3_Click(object sender, EventArgs e)
{ {
try try
...@@ -717,11 +742,6 @@ namespace OnlineStore.XLRStore ...@@ -717,11 +742,6 @@ namespace OnlineStore.XLRStore
} }
} }
private void timer2_Tick(object sender, EventArgs e)
{
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{ {
if (!LoadOk) if (!LoadOk)
...@@ -732,6 +752,8 @@ namespace OnlineStore.XLRStore ...@@ -732,6 +752,8 @@ namespace OnlineStore.XLRStore
{ {
inputEquip.FrmInputEquip_VisibleChanged(null, null); inputEquip.FrmInputEquip_VisibleChanged(null, null);
} }
if (tabControl1.SelectedIndex == 2)
WindowManager.Show();
} }
private void 启用安全光栅ToolStripMenuItem_Click(object sender, EventArgs e) private void 启用安全光栅ToolStripMenuItem_Click(object sender, EventArgs e)
...@@ -786,7 +808,37 @@ namespace OnlineStore.XLRStore ...@@ -786,7 +808,37 @@ namespace OnlineStore.XLRStore
private void 查看监控ToolStripMenuItem_Click(object sender, EventArgs e) private void 查看监控ToolStripMenuItem_Click(object sender, EventArgs e)
{ {
IPCameraHelper.StartIPCamService();
}
#region 窗口管理
void LoadWindow()
{
var ipcamera = new WindInfo() { Parent = panelVideo, Name = WindInfo.IPCamera };
WindowManager.windInfos.Add(ipcamera);
WindowManager.Start();
}
protected override void OnHandleDestroyed(EventArgs e)
{
//foreach (var wnd in WindowManager.windInfos)
//{
// if (wnd.WindowHandle != IntPtr.Zero)
// {
// WindowUtil.PostMessage(wnd.WindowHandle, WindowUtil.WM_CLOSE, 0, 0);
// // Delay for it to get the message
// System.Threading.Thread.Sleep(1000);
// // Clear internal handle
// wnd.WindowHandle = IntPtr.Zero;
// }
//}
// base.OnHandleDestroyed(e);
}
#endregion
private void FrmXLRStore_Shown(object sender, EventArgs e)
{
} }
} }
} }
...@@ -19,7 +19,7 @@ namespace OnlineStore.XLRStore.Properties { ...@@ -19,7 +19,7 @@ namespace OnlineStore.XLRStore.Properties {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。 // (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources { internal class Resources {
......
...@@ -12,7 +12,7 @@ namespace OnlineStore.XLRStore.Properties { ...@@ -12,7 +12,7 @@ namespace OnlineStore.XLRStore.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
......
using Common;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.XLRStore
{
internal class WindowManager
{
public static List<WindInfo> windInfos = new List<WindInfo>();
static string baseDir = @".\Modules\";
public static void Start()
{
foreach (var item in windInfos)
{
try
{
item.ProcessInfo = ProcessUtil.StartProcess(item.Name, baseDir + $"{item.Name}\\", 60000);
}
catch (Exception ex)
{
LogUtil.error($"程序{item.Name}启动失败", ex);
}
}
}
public static void Show()
{
foreach (var item in windInfos)
{
if (item.Parent.IsHandleCreated)
{
if (item.WindowHandle == IntPtr.Zero)
item.WindowHandle = WindowUtil.PutIntoForm(item.Parent, item.Name);
}
}
}
}
class WindInfo
{
public string Name { get; set; }
public IntPtr WindowHandle { get; set; }
public Panel Parent { get; set; }
public Process ProcessInfo { get; set; }
public const string IPCamera = "IPCamera";
}
}
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.XLRStore</RootNamespace> <RootNamespace>OnlineStore.XLRStore</RootNamespace>
<AssemblyName>XLRStore</AssemblyName> <AssemblyName>XLRStore</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl> <PublishUrl>publish\</PublishUrl>
...@@ -223,6 +223,7 @@ ...@@ -223,6 +223,7 @@
<Compile Include="useControl\EquipControl.Designer.cs"> <Compile Include="useControl\EquipControl.Designer.cs">
<DependentUpon>EquipControl.cs</DependentUpon> <DependentUpon>EquipControl.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="WindowManager.cs" />
<EmbeddedResource Include="boxForm\FrmAutoFindPos.resx"> <EmbeddedResource Include="boxForm\FrmAutoFindPos.resx">
<DependentUpon>FrmAutoFindPos.cs</DependentUpon> <DependentUpon>FrmAutoFindPos.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
......
...@@ -12,7 +12,6 @@ using System.Text; ...@@ -12,7 +12,6 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using eyemLib_Sharp; using eyemLib_Sharp;
using static CodeLibrary.EyemDecode;
namespace OnlineStore.XLRStore namespace OnlineStore.XLRStore
{ {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!