代码清理
This commit is contained in:
parent
fb1ae0bb08
commit
fabc7606e7
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace DHSoftware.Languages
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DHSoftware.Languages
|
|
||||||
{
|
{
|
||||||
public class Localizer_enus : AntdUI.ILocalization
|
public class Localizer_enus : AntdUI.ILocalization
|
||||||
{
|
{
|
||||||
@ -14,126 +8,183 @@ namespace DHSoftware.Languages
|
|||||||
{
|
{
|
||||||
case "search":
|
case "search":
|
||||||
return "Search";
|
return "Search";
|
||||||
|
|
||||||
case "welcome":
|
case "welcome":
|
||||||
return "Welcome to the AntdUI Demo";
|
return "Welcome to the AntdUI Demo";
|
||||||
|
|
||||||
case "home":
|
case "home":
|
||||||
return "Home";
|
return "Home";
|
||||||
|
|
||||||
case "closeall":
|
case "closeall":
|
||||||
return "Close all tabs";
|
return "Close all tabs";
|
||||||
|
|
||||||
#region systemset
|
#region systemset
|
||||||
|
|
||||||
case "systemset":
|
case "systemset":
|
||||||
return "System Settings";
|
return "System Settings";
|
||||||
|
|
||||||
case "baseset":
|
case "baseset":
|
||||||
return "Basic Settings";
|
return "Basic Settings";
|
||||||
|
|
||||||
case "messageconfig":
|
case "messageconfig":
|
||||||
return "Message configuration";
|
return "Message configuration";
|
||||||
|
|
||||||
case "animationon":
|
case "animationon":
|
||||||
return "Turn on animation";
|
return "Turn on animation";
|
||||||
|
|
||||||
case "shadowon":
|
case "shadowon":
|
||||||
return "Enable shadow";
|
return "Enable shadow";
|
||||||
|
|
||||||
case "scrollbarhide":
|
case "scrollbarhide":
|
||||||
return "Hide scrollbar";
|
return "Hide scrollbar";
|
||||||
|
|
||||||
case "showinwindow":
|
case "showinwindow":
|
||||||
return "Show in window";
|
return "Show in window";
|
||||||
|
|
||||||
case "windowOffsetXY":
|
case "windowOffsetXY":
|
||||||
return "WindowOffsetXY";
|
return "WindowOffsetXY";
|
||||||
|
|
||||||
case "tip":
|
case "tip":
|
||||||
return "Tip";
|
return "Tip";
|
||||||
|
|
||||||
case "switchsuccess":
|
case "switchsuccess":
|
||||||
return "Switch successful.";
|
return "Switch successful.";
|
||||||
#endregion
|
|
||||||
|
#endregion systemset
|
||||||
|
|
||||||
#region Button
|
#region Button
|
||||||
|
|
||||||
case "Button.Text":
|
case "Button.Text":
|
||||||
return "Button";
|
return "Button";
|
||||||
|
|
||||||
case "Button.Description":
|
case "Button.Description":
|
||||||
return "To trigger an operation.";
|
return "To trigger an operation.";
|
||||||
|
|
||||||
case "type":
|
case "type":
|
||||||
return "Type";
|
return "Type";
|
||||||
|
|
||||||
case "wave":
|
case "wave":
|
||||||
return "Wave";
|
return "Wave";
|
||||||
|
|
||||||
case "loading":
|
case "loading":
|
||||||
return "Loading";
|
return "Loading";
|
||||||
|
|
||||||
case "ghost":
|
case "ghost":
|
||||||
return "Ghost";
|
return "Ghost";
|
||||||
|
|
||||||
case "border":
|
case "border":
|
||||||
return "Border";
|
return "Border";
|
||||||
|
|
||||||
case "icon":
|
case "icon":
|
||||||
return "Icon";
|
return "Icon";
|
||||||
|
|
||||||
case "arrow":
|
case "arrow":
|
||||||
return "Arrow";
|
return "Arrow";
|
||||||
|
|
||||||
case "join":
|
case "join":
|
||||||
return "Join";
|
return "Join";
|
||||||
|
|
||||||
case "gradient":
|
case "gradient":
|
||||||
return "Gradient";
|
return "Gradient";
|
||||||
|
|
||||||
case "toggle":
|
case "toggle":
|
||||||
return "Toggle";
|
return "Toggle";
|
||||||
#endregion
|
|
||||||
|
#endregion Button
|
||||||
|
|
||||||
#region FloatButton
|
#region FloatButton
|
||||||
|
|
||||||
case "FloatButton.Text":
|
case "FloatButton.Text":
|
||||||
return "FloatButton";
|
return "FloatButton";
|
||||||
|
|
||||||
case "FloatButton.Description":
|
case "FloatButton.Description":
|
||||||
return "A button that floats at the top of the page.";
|
return "A button that floats at the top of the page.";
|
||||||
|
|
||||||
case "FloatButton.Tip":
|
case "FloatButton.Tip":
|
||||||
return "FloatButton does not have a toolbox control and is called code.";
|
return "FloatButton does not have a toolbox control and is called code.";
|
||||||
|
|
||||||
case "control_option":
|
case "control_option":
|
||||||
return "Control Options";
|
return "Control Options";
|
||||||
|
|
||||||
case "button_option":
|
case "button_option":
|
||||||
return "Button Options";
|
return "Button Options";
|
||||||
|
|
||||||
case "open":
|
case "open":
|
||||||
return "Open";
|
return "Open";
|
||||||
|
|
||||||
case "close":
|
case "close":
|
||||||
return "Close";
|
return "Close";
|
||||||
|
|
||||||
case "reset":
|
case "reset":
|
||||||
return "Reset";
|
return "Reset";
|
||||||
#endregion
|
|
||||||
|
#endregion FloatButton
|
||||||
|
|
||||||
#region Icon
|
#region Icon
|
||||||
|
|
||||||
case "Icon.Text":
|
case "Icon.Text":
|
||||||
return "Icon";
|
return "Icon";
|
||||||
|
|
||||||
case "Icon.Description":
|
case "Icon.Description":
|
||||||
return "Semantic vector graphics.";
|
return "Semantic vector graphics.";
|
||||||
|
|
||||||
case "Icon.Tip":
|
case "Icon.Tip":
|
||||||
return "Icon does not have a toolbox control and is used for Svg property assignments.";
|
return "Icon does not have a toolbox control and is used for Svg property assignments.";
|
||||||
|
|
||||||
case "outlined":
|
case "outlined":
|
||||||
return "Outlined";
|
return "Outlined";
|
||||||
|
|
||||||
case "filled":
|
case "filled":
|
||||||
return "Filled";
|
return "Filled";
|
||||||
|
|
||||||
case "directionalicon":
|
case "directionalicon":
|
||||||
return "Directional icons";
|
return "Directional icons";
|
||||||
|
|
||||||
case "suggestionicon":
|
case "suggestionicon":
|
||||||
return "Suggestion Icon";
|
return "Suggestion Icon";
|
||||||
|
|
||||||
case "editingicon":
|
case "editingicon":
|
||||||
return "Editing Icons";
|
return "Editing Icons";
|
||||||
|
|
||||||
case "dataicon":
|
case "dataicon":
|
||||||
return "Data icons";
|
return "Data icons";
|
||||||
|
|
||||||
case "brand":
|
case "brand":
|
||||||
return "Brand and logo";
|
return "Brand and logo";
|
||||||
|
|
||||||
case "universal":
|
case "universal":
|
||||||
return "Universal Icons for Websites";
|
return "Universal Icons for Websites";
|
||||||
|
|
||||||
case "copysuccess":
|
case "copysuccess":
|
||||||
return "Copy successful!";
|
return "Copy successful!";
|
||||||
|
|
||||||
case "copyfail":
|
case "copyfail":
|
||||||
return "Copy failed!";
|
return "Copy failed!";
|
||||||
#endregion
|
|
||||||
|
#endregion Icon
|
||||||
|
|
||||||
#region Divider
|
#region Divider
|
||||||
|
|
||||||
case "Divider.Text":
|
case "Divider.Text":
|
||||||
return "Divider";
|
return "Divider";
|
||||||
|
|
||||||
case "Divider.Description":
|
case "Divider.Description":
|
||||||
return "A divider line separates different content.";
|
return "A divider line separates different content.";
|
||||||
|
|
||||||
case "basicusage":
|
case "basicusage":
|
||||||
return "Basic Usage";
|
return "Basic Usage";
|
||||||
|
|
||||||
case "vertical":
|
case "vertical":
|
||||||
return "Vertical";
|
return "Vertical";
|
||||||
|
|
||||||
case "horizontal":
|
case "horizontal":
|
||||||
return "Horizontal";
|
return "Horizontal";
|
||||||
#endregion
|
|
||||||
|
#endregion Divider
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,26 +1,23 @@
|
|||||||
using AntdUI;
|
using AntdUI;
|
||||||
using DHSoftware.Models;
|
using DHSoftware.Models;
|
||||||
using DHSoftware.Services;
|
using DHSoftware.Services;
|
||||||
|
|
||||||
namespace DHSoftware
|
namespace DHSoftware
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public partial class LoginWindow : AntdUI.Window
|
public partial class LoginWindow : AntdUI.Window
|
||||||
{
|
{
|
||||||
|
|
||||||
public LoginWindow()
|
public LoginWindow()
|
||||||
{
|
{
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
button_ok.Click += Button_ok_Click;
|
button_ok.Click += Button_ok_Click;
|
||||||
button_cancel.Click += Button_cancel_Click;
|
button_cancel.Click += Button_cancel_Click;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 窗体对象实例
|
/// 窗体对象实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static LoginWindow _instance;
|
private static LoginWindow _instance;
|
||||||
|
|
||||||
internal static LoginWindow Instance
|
internal static LoginWindow Instance
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -30,6 +27,7 @@ namespace DHSoftware
|
|||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_cancel_Click(object? sender, EventArgs e)
|
private void Button_cancel_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.Dispose();
|
this.Dispose();
|
||||||
@ -37,8 +35,8 @@ namespace DHSoftware
|
|||||||
|
|
||||||
private void Button_ok_Click(object? sender, EventArgs e)
|
private void Button_ok_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(iptName.Text))
|
if (string.IsNullOrWhiteSpace(iptName.Text))
|
||||||
{
|
{
|
||||||
AntdUI.Message.warn(this, "用户名不能为空!", autoClose: 3);
|
AntdUI.Message.warn(this, "用户名不能为空!", autoClose: 3);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -47,9 +45,8 @@ namespace DHSoftware
|
|||||||
AntdUI.Message.warn(this, "密码不能为空!", autoClose: 3);
|
AntdUI.Message.warn(this, "密码不能为空!", autoClose: 3);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(AuthService.Login(iptName.Text, iptPwd.Text))
|
if (AuthService.Login(iptName.Text, iptPwd.Text))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (this.Owner is MainWindow parent)
|
if (this.Owner is MainWindow parent)
|
||||||
{
|
{
|
||||||
List<string> UserPermissions = AuthService.GetUserPermissions();
|
List<string> UserPermissions = AuthService.GetUserPermissions();
|
||||||
@ -87,10 +84,9 @@ namespace DHSoftware
|
|||||||
parent.Deleteschememe = false;
|
parent.Deleteschememe = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent.LoginName = iptName.Text;
|
||||||
parent.LoginName=iptName.Text;
|
|
||||||
}
|
}
|
||||||
this.Dispose();
|
this.Dispose();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -100,7 +96,6 @@ namespace DHSoftware
|
|||||||
|
|
||||||
private void LoginWindow_Load(object sender, EventArgs e)
|
private void LoginWindow_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -36,16 +36,12 @@ using ResultState = DH.Commons.Base.ResultState;
|
|||||||
|
|
||||||
namespace DHSoftware
|
namespace DHSoftware
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public partial class MainWindow : AntdUI.Window
|
public partial class MainWindow : AntdUI.Window
|
||||||
{
|
{
|
||||||
|
private Dictionary<string, List<string>> _cameraRelatedDetectionDict = null;
|
||||||
|
|
||||||
Dictionary<string, List<string>> _cameraRelatedDetectionDict = null;
|
|
||||||
|
|
||||||
private string _loginName;
|
private string _loginName;
|
||||||
|
|
||||||
public string LoginName
|
public string LoginName
|
||||||
{
|
{
|
||||||
get { return _loginName; }
|
get { return _loginName; }
|
||||||
@ -55,7 +51,9 @@ namespace DHSoftware
|
|||||||
UpdateLabel();
|
UpdateLabel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _ShowConfig;
|
private bool _ShowConfig;
|
||||||
|
|
||||||
public bool ShowConfig
|
public bool ShowConfig
|
||||||
{
|
{
|
||||||
get { return _ShowConfig; }
|
get { return _ShowConfig; }
|
||||||
@ -66,48 +64,51 @@ namespace DHSoftware
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _addscheme;
|
||||||
|
|
||||||
private bool _addscheme;
|
public bool Addscheme
|
||||||
public bool Addscheme
|
{
|
||||||
{
|
get { return _addscheme; }
|
||||||
get { return _addscheme; }
|
set
|
||||||
set
|
|
||||||
{
|
|
||||||
_addscheme = value;
|
|
||||||
UpdateScheme();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private bool _deletescheme;
|
|
||||||
public bool Deleteschememe
|
|
||||||
{
|
{
|
||||||
get { return _deletescheme; }
|
_addscheme = value;
|
||||||
set
|
|
||||||
{
|
|
||||||
_deletescheme = value;
|
|
||||||
UpdateScheme();
|
UpdateScheme();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private bool _loadscheme;
|
}
|
||||||
public bool Loadscheme
|
|
||||||
|
private bool _deletescheme;
|
||||||
|
|
||||||
|
public bool Deleteschememe
|
||||||
|
{
|
||||||
|
get { return _deletescheme; }
|
||||||
|
set
|
||||||
{
|
{
|
||||||
get { return _loadscheme; }
|
_deletescheme = value;
|
||||||
set
|
|
||||||
{
|
|
||||||
_loadscheme = value;
|
|
||||||
UpdateScheme();
|
UpdateScheme();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _loadscheme;
|
||||||
|
|
||||||
|
public bool Loadscheme
|
||||||
|
{
|
||||||
|
get { return _loadscheme; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_loadscheme = value;
|
||||||
|
UpdateScheme();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateScheme()
|
private void UpdateScheme()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (this.InvokeRequired)
|
if (this.InvokeRequired)
|
||||||
{
|
{
|
||||||
this.Invoke(new Action(UpdateScheme));
|
this.Invoke(new Action(UpdateScheme));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Loadscheme)
|
if (Loadscheme)
|
||||||
{
|
{
|
||||||
btnDeleteProject.Visible = true;
|
btnDeleteProject.Visible = true;
|
||||||
}
|
}
|
||||||
@ -142,6 +143,7 @@ namespace DHSoftware
|
|||||||
}
|
}
|
||||||
lbName.Text = _loginName;
|
lbName.Text = _loginName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateConfig()
|
private void UpdateConfig()
|
||||||
{
|
{
|
||||||
if (ShowConfig)
|
if (ShowConfig)
|
||||||
@ -163,29 +165,29 @@ namespace DHSoftware
|
|||||||
}
|
}
|
||||||
segmented1.Items.Remove(itemToHide);
|
segmented1.Items.Remove(itemToHide);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
//refreshTimer.Start();
|
//refreshTimer.Start();
|
||||||
//初始化数据
|
//初始化数据
|
||||||
InitData();
|
InitData();
|
||||||
//绑定事件
|
//绑定事件
|
||||||
BindEventHandler();
|
BindEventHandler();
|
||||||
UserConfigFrm userControlFrm = new UserConfigFrm();
|
UserConfigFrm userControlFrm = new UserConfigFrm();
|
||||||
|
|
||||||
userControlFrm.Window = this;
|
userControlFrm.Window = this;
|
||||||
userControlFrm.Dock = DockStyle.Fill;
|
userControlFrm.Dock = DockStyle.Fill;
|
||||||
tabPage2.Controls.Add(userControlFrm);
|
tabPage2.Controls.Add(userControlFrm);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 窗体对象实例
|
/// 窗体对象实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static MainWindow _instance;
|
private static MainWindow _instance;
|
||||||
|
|
||||||
internal static MainWindow Instance
|
internal static MainWindow Instance
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -195,12 +197,13 @@ namespace DHSoftware
|
|||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SegmentedItem itemToHide;
|
|
||||||
|
private SegmentedItem itemToHide;
|
||||||
|
|
||||||
private void InitData()
|
private void InitData()
|
||||||
{
|
{
|
||||||
itemToHide = segmented1.Items[4];
|
itemToHide = segmented1.Items[4];
|
||||||
segmented1.Items.Remove(itemToHide);
|
segmented1.Items.Remove(itemToHide);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadScheme()
|
public void LoadScheme()
|
||||||
@ -215,7 +218,7 @@ namespace DHSoftware
|
|||||||
//如果是空,新增默认数据
|
//如果是空,新增默认数据
|
||||||
if (list == null || list.Count <= 0)
|
if (list == null || list.Count <= 0)
|
||||||
{
|
{
|
||||||
list = new() { CurrentScheme };
|
list = new() { CurrentScheme };
|
||||||
//显示到方案列表
|
//显示到方案列表
|
||||||
sltProjects.Items.Clear();
|
sltProjects.Items.Clear();
|
||||||
|
|
||||||
@ -241,7 +244,7 @@ namespace DHSoftware
|
|||||||
//加载当前方案配置
|
//加载当前方案配置
|
||||||
ConfigHelper.LoadConfig();
|
ConfigHelper.LoadConfig();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AntdUI.Message.error(this, ex.Message, autoClose: 3);
|
AntdUI.Message.error(this, ex.Message, autoClose: 3);
|
||||||
}
|
}
|
||||||
@ -277,7 +280,6 @@ namespace DHSoftware
|
|||||||
// cam.CameraConnect();
|
// cam.CameraConnect();
|
||||||
cam.OnHImageOutput += OnCameraHImageOutput;
|
cam.OnHImageOutput += OnCameraHImageOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,7 +293,6 @@ namespace DHSoftware
|
|||||||
var plcBase = ConfigModel.PLCBaseList[i];
|
var plcBase = ConfigModel.PLCBaseList[i];
|
||||||
if (plcBase.PLCType == EnumPLCType.信捷XC网口)
|
if (plcBase.PLCType == EnumPLCType.信捷XC网口)
|
||||||
{
|
{
|
||||||
|
|
||||||
PLC.IP = plcBase.IP;
|
PLC.IP = plcBase.IP;
|
||||||
PLC.Enable = plcBase.Enable;
|
PLC.Enable = plcBase.Enable;
|
||||||
PLC.PLCName = plcBase.PLCName;
|
PLC.PLCName = plcBase.PLCName;
|
||||||
@ -300,7 +301,6 @@ namespace DHSoftware
|
|||||||
PLC.PLCConnect();
|
PLC.PLCConnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +311,6 @@ namespace DHSoftware
|
|||||||
|
|
||||||
if (ConfigModel.DetectionList.Count > 0)
|
if (ConfigModel.DetectionList.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
for (int i = 0; i < ConfigModel.DetectionList.Count; i++)
|
for (int i = 0; i < ConfigModel.DetectionList.Count; i++)
|
||||||
{
|
{
|
||||||
DetectionConfig detectionConfig = ConfigModel.DetectionList[i];
|
DetectionConfig detectionConfig = ConfigModel.DetectionList[i];
|
||||||
@ -329,7 +328,6 @@ namespace DHSoftware
|
|||||||
}
|
}
|
||||||
DetectionConfigs.ForEach(detection =>
|
DetectionConfigs.ForEach(detection =>
|
||||||
{
|
{
|
||||||
|
|
||||||
detection.CameraCollects.ForEach(cam =>
|
detection.CameraCollects.ForEach(cam =>
|
||||||
{
|
{
|
||||||
List<string> Dets = new List<string>
|
List<string> Dets = new List<string>
|
||||||
@ -344,14 +342,11 @@ namespace DHSoftware
|
|||||||
{
|
{
|
||||||
_cameraRelatedDetectionDict[cam.CameraSourceId].Add(detection.Id);
|
_cameraRelatedDetectionDict[cam.CameraSourceId].Add(detection.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
string inferenceDevice = "CPU";
|
string inferenceDevice = "CPU";
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
_visionEngine = new SimboVisionDriver();
|
_visionEngine = new SimboVisionDriver();
|
||||||
_visionEngine.DetectionConfigs = DetectionConfigs;
|
_visionEngine.DetectionConfigs = DetectionConfigs;
|
||||||
@ -360,16 +355,13 @@ namespace DHSoftware
|
|||||||
_visionEngine.Init();
|
_visionEngine.Init();
|
||||||
CtrlVisionRunBase ctrlVisionRun = new CtrlVisionRunBase(_visionEngine);
|
CtrlVisionRunBase ctrlVisionRun = new CtrlVisionRunBase(_visionEngine);
|
||||||
tabImgDisplay.Controls.Add(ctrlVisionRun);
|
tabImgDisplay.Controls.Add(ctrlVisionRun);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BindEventHandler()
|
private void BindEventHandler()
|
||||||
{
|
{
|
||||||
|
|
||||||
btnAddProject.Click += BtnAddProject_Click;
|
btnAddProject.Click += BtnAddProject_Click;
|
||||||
btnDeleteProject.Click += BtnDeleteProject_Click;
|
btnDeleteProject.Click += BtnDeleteProject_Click;
|
||||||
btnLoadProject.Click += BtnLoadProject_Click;
|
btnLoadProject.Click += BtnLoadProject_Click;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnDeleteProject_Click(object? sender, EventArgs e)
|
private void BtnDeleteProject_Click(object? sender, EventArgs e)
|
||||||
@ -400,19 +392,15 @@ namespace DHSoftware
|
|||||||
SchemeHelper.SetCurrentScheme(SystemModel.CurrentScheme);
|
SchemeHelper.SetCurrentScheme(SystemModel.CurrentScheme);
|
||||||
//加载当前方案配置
|
//加载当前方案配置
|
||||||
ConfigHelper.LoadConfig();
|
ConfigHelper.LoadConfig();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sltProjects.SelectedIndex = -1; // 清空选择
|
sltProjects.SelectedIndex = -1; // 清空选择
|
||||||
AntdUI.Modal.open(this, "空方案警告!", "当前方案全部删除,需重启程序!", TType.Warn);
|
AntdUI.Modal.open(this, "空方案警告!", "当前方案全部删除,需重启程序!", TType.Warn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AntdUI.Message.error(this, ex.Message, autoClose: 3);
|
AntdUI.Message.error(this, ex.Message, autoClose: 3);
|
||||||
}
|
}
|
||||||
@ -436,7 +424,8 @@ namespace DHSoftware
|
|||||||
ConfigHelper.LoadConfig();
|
ConfigHelper.LoadConfig();
|
||||||
AntdUI.Message.success(this, $"载入方案{SystemModel.CurrentScheme}成功!", autoClose: 3);
|
AntdUI.Message.success(this, $"载入方案{SystemModel.CurrentScheme}成功!", autoClose: 3);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex)
|
||||||
|
{
|
||||||
AntdUI.Message.error(this, ex.Message, autoClose: 3);
|
AntdUI.Message.error(this, ex.Message, autoClose: 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -481,23 +470,20 @@ namespace DHSoftware
|
|||||||
{
|
{
|
||||||
AntdUI.Message.error(this, ex.Message, autoClose: 3);
|
AntdUI.Message.error(this, ex.Message, autoClose: 3);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<HikVisionCamera> HKCameras { get; } = new List<HikVisionCamera>();
|
public List<HikVisionCamera> HKCameras { get; } = new List<HikVisionCamera>();
|
||||||
public List<Do3ThinkCamera> Cameras { get; } = new List<Do3ThinkCamera>();
|
public List<Do3ThinkCamera> Cameras { get; } = new List<Do3ThinkCamera>();
|
||||||
public Dictionary<string, SimboObjectDetection> Dectection { get; } = new Dictionary<string, SimboObjectDetection>();
|
public Dictionary<string, SimboObjectDetection> Dectection { get; } = new Dictionary<string, SimboObjectDetection>();
|
||||||
public XinJEPLCTcpNet PLC { get; } = XinJEPLCTcpNet.Instance;
|
public XinJEPLCTcpNet PLC { get; } = XinJEPLCTcpNet.Instance;
|
||||||
SLDMotion sLDMotion = new SLDMotion();
|
private SLDMotion sLDMotion = new SLDMotion();
|
||||||
|
|
||||||
private void MainWindow_Load(object sender, EventArgs e)
|
private void MainWindow_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _isClosing = false; // 状态标志
|
private bool _isClosing = false; // 状态标志
|
||||||
|
|
||||||
private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
|
private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
if (_isClosing) return;
|
if (_isClosing) return;
|
||||||
@ -509,34 +495,30 @@ namespace DHSoftware
|
|||||||
this.Hide();
|
this.Hide();
|
||||||
|
|
||||||
// 显示关闭界面
|
// 显示关闭界面
|
||||||
CloseWindow.Instance.Show();
|
CloseWindow.Instance.Show();
|
||||||
Thread.Sleep(200);
|
Thread.Sleep(200);
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
// 执行关闭操作
|
||||||
|
foreach (var camera in Cameras)
|
||||||
{
|
{
|
||||||
// 执行关闭操作
|
camera.CameraDisConnect();
|
||||||
foreach (var camera in Cameras)
|
}
|
||||||
{
|
foreach (var camera in HKCameras)
|
||||||
camera.CameraDisConnect();
|
{
|
||||||
}
|
camera.CameraDisConnect();
|
||||||
foreach (var camera in HKCameras)
|
}
|
||||||
{
|
PLC.PLCDisConnect();
|
||||||
camera.CameraDisConnect();
|
CloseWindow.Instance.Close();// 关闭提示窗口
|
||||||
}
|
//Application.Exit();
|
||||||
PLC.PLCDisConnect();
|
System.Environment.Exit(0);
|
||||||
CloseWindow.Instance.Close();// 关闭提示窗口
|
|
||||||
//Application.Exit();
|
|
||||||
System.Environment.Exit(0);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
CloseWindow.Instance.Close();
|
CloseWindow.Instance.Close();
|
||||||
|
|
||||||
System.Environment.Exit(0);
|
System.Environment.Exit(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void segmented1_SelectIndexChanged(object sender, EventArgs e)
|
private void segmented1_SelectIndexChanged(object sender, EventArgs e)
|
||||||
@ -550,40 +532,49 @@ namespace DHSoftware
|
|||||||
case 0: // "启动" (Start)
|
case 0: // "启动" (Start)
|
||||||
HandleStartButton();
|
HandleStartButton();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // "停止" (Stop)
|
case 1: // "停止" (Stop)
|
||||||
HandleStopButton();
|
HandleStopButton();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // "复位" (Reset)
|
case 2: // "复位" (Reset)
|
||||||
HandleResetButton();
|
HandleResetButton();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: // "设置" (Settings)
|
case 3: // "设置" (Settings)
|
||||||
HandleLoginButton();
|
HandleLoginButton();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: // "登录" (Login)
|
case 4: // "登录" (Login)
|
||||||
HandleSettingsButton();
|
HandleSettingsButton();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
segmented1.SelectIndex = -1;
|
segmented1.SelectIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CurrentMachine = false;
|
public bool CurrentMachine = false;
|
||||||
public volatile int ProductNum_Total = 0;
|
public volatile int ProductNum_Total = 0;
|
||||||
public volatile int ProductNum_OK = 0;
|
public volatile int ProductNum_OK = 0;
|
||||||
private readonly object _cameraSummaryLock = new object();
|
private readonly object _cameraSummaryLock = new object();
|
||||||
public SimboVisionDriver? _visionEngine = null;
|
public SimboVisionDriver? _visionEngine = null;
|
||||||
|
|
||||||
public PLCBase? _PLCConfig = null;
|
public PLCBase? _PLCConfig = null;
|
||||||
List<DetectionConfig> DetectionConfigs = new List<DetectionConfig>();
|
private List<DetectionConfig> DetectionConfigs = new List<DetectionConfig>();
|
||||||
List<SimboStationMLEngineSet> SimboStationMLEngineList = new List<SimboStationMLEngineSet>();
|
private List<SimboStationMLEngineSet> SimboStationMLEngineList = new List<SimboStationMLEngineSet>();
|
||||||
Dictionary<string, HDevEngineTool> HalconToolDict = new Dictionary<string, HDevEngineTool>();
|
private Dictionary<string, HDevEngineTool> HalconToolDict = new Dictionary<string, HDevEngineTool>();
|
||||||
public List<RecongnitionLabel> RecongnitionLabelList { get; set; } = new List<RecongnitionLabel>();
|
public List<RecongnitionLabel> RecongnitionLabelList { get; set; } = new List<RecongnitionLabel>();
|
||||||
public DateTime startTime;
|
public DateTime startTime;
|
||||||
|
|
||||||
private void HandleStartButton()
|
private void HandleStartButton()
|
||||||
{
|
{
|
||||||
StartProcess();
|
StartProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int currentRegister = 411; // 初始为 D411
|
private static int currentRegister = 411; // 初始为 D411
|
||||||
|
|
||||||
private void StartProcess()
|
private void StartProcess()
|
||||||
{
|
{
|
||||||
//计数清零
|
//计数清零
|
||||||
@ -591,7 +582,6 @@ namespace DHSoftware
|
|||||||
//吹气点位归置
|
//吹气点位归置
|
||||||
currentRegister = 411;
|
currentRegister = 411;
|
||||||
|
|
||||||
|
|
||||||
if (_PLCConfig?.Enable == true)
|
if (_PLCConfig?.Enable == true)
|
||||||
{
|
{
|
||||||
PLC.CountToZero();
|
PLC.CountToZero();
|
||||||
@ -606,12 +596,12 @@ namespace DHSoftware
|
|||||||
});
|
});
|
||||||
|
|
||||||
//PrepareBatchNO();
|
//PrepareBatchNO();
|
||||||
// isInPositionChecking = false;
|
// isInPositionChecking = false;
|
||||||
//isFullTrayChecking = false;
|
//isFullTrayChecking = false;
|
||||||
//队列清空
|
//队列清空
|
||||||
// var temp = new List<ITriggerSet>();
|
// var temp = new List<ITriggerSet>();
|
||||||
// temp.AddRange(XKRSPLCConfig.TriggerConfigCollection);
|
// temp.AddRange(XKRSPLCConfig.TriggerConfigCollection);
|
||||||
// temp.AddRange(XKRSPLCConfig.SnapshotTriggerConfigCollection);
|
// temp.AddRange(XKRSPLCConfig.SnapshotTriggerConfigCollection);
|
||||||
|
|
||||||
//temp.ForEach(t =>
|
//temp.ForEach(t =>
|
||||||
//{
|
//{
|
||||||
@ -632,22 +622,20 @@ namespace DHSoftware
|
|||||||
// return new ProcessResponse(false);
|
// return new ProcessResponse(false);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
// _diskInfoListInOrder = XKRSPLCConfig.DiskInfoList.OrderBy(u => u.DiskSequence).ToList();
|
||||||
|
// var axisNumList = _diskInfoListInOrder.Select(u => u.DiskAxisNum).ToList();
|
||||||
|
|
||||||
// _diskInfoListInOrder = XKRSPLCConfig.DiskInfoList.OrderBy(u => u.DiskSequence).ToList();
|
/// PrepareMLEngine();
|
||||||
// var axisNumList = _diskInfoListInOrder.Select(u => u.DiskAxisNum).ToList();
|
|
||||||
|
|
||||||
/// PrepareMLEngine();
|
// if (_PLCConfig?.Enable == true)
|
||||||
|
//挡料电机操作
|
||||||
|
// _PLC.FeedingMotor(_PLCConfig.CunToZeroSpeed, _PLCConfig.CunPos, _PLCConfig.CunSpeed, _PLCConfig.CunDirection);
|
||||||
// if (_PLCConfig?.Enable == true)
|
|
||||||
//挡料电机操作
|
|
||||||
// _PLC.FeedingMotor(_PLCConfig.CunToZeroSpeed, _PLCConfig.CunPos, _PLCConfig.CunSpeed, _PLCConfig.CunDirection);
|
|
||||||
|
|
||||||
//流程开启操作配置
|
//流程开启操作配置
|
||||||
// ProcessInitialAction();
|
// ProcessInitialAction();
|
||||||
// if (_PLC?Enabled == true)
|
// if (_PLC?Enabled == true)
|
||||||
//皮带
|
//皮带
|
||||||
// _PLC.Belt(true);
|
// _PLC.Belt(true);
|
||||||
|
|
||||||
//DeviceCollection.ForEach(d =>
|
//DeviceCollection.ForEach(d =>
|
||||||
//{
|
//{
|
||||||
@ -659,15 +647,18 @@ namespace DHSoftware
|
|||||||
// }
|
// }
|
||||||
//});
|
//});
|
||||||
_productLists.Clear();
|
_productLists.Clear();
|
||||||
#region 虚拟相机
|
|
||||||
|
#region 虚拟相机
|
||||||
|
|
||||||
//mOfflineImageTimer = new System.Timers.Timer();
|
//mOfflineImageTimer = new System.Timers.Timer();
|
||||||
|
|
||||||
//mOfflineImageTimer.Elapsed += OnEmitSerialPortAsync;
|
//mOfflineImageTimer.Elapsed += OnEmitSerialPortAsync;
|
||||||
//mOfflineImageTimer.Interval = 1000;
|
//mOfflineImageTimer.Interval = 1000;
|
||||||
//mOfflineImageTimer.Start();
|
//mOfflineImageTimer.Start();
|
||||||
#endregion
|
|
||||||
|
|
||||||
var settings = _visionEngine.DetectionConfigs.Where(u => u.IsEnabled && u.IsAddStation ).ToList();
|
#endregion 虚拟相机
|
||||||
|
|
||||||
|
var settings = _visionEngine.DetectionConfigs.Where(u => u.IsEnabled && u.IsAddStation).ToList();
|
||||||
if (settings != null)
|
if (settings != null)
|
||||||
{
|
{
|
||||||
settings = settings.Where(s => s.IsEnabled).ToList();
|
settings = settings.Where(s => s.IsEnabled).ToList();
|
||||||
@ -680,7 +671,6 @@ namespace DHSoftware
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _MGSCameraList = DeviceCollection
|
// _MGSCameraList = DeviceCollection
|
||||||
//.OfType<MGSCameraDriver>() // 直接筛选出 MGSCameraDriver 类型的元素
|
//.OfType<MGSCameraDriver>() // 直接筛选出 MGSCameraDriver 类型的元素
|
||||||
//.Where(camera => camera.IConfig != null && camera.IConfig.IsEnabled) // 进一步筛选 IConfig 不为 null 且 IsEnabled 为 true
|
//.Where(camera => camera.IConfig != null && camera.IConfig.IsEnabled) // 进一步筛选 IConfig 不为 null 且 IsEnabled 为 true
|
||||||
@ -694,7 +684,6 @@ namespace DHSoftware
|
|||||||
_productLists.Add(products);
|
_productLists.Add(products);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 转盘操作
|
// 转盘操作
|
||||||
// if (_PLC?.IIConfig?.IsEnabled == true)
|
// if (_PLC?.IIConfig?.IsEnabled == true)
|
||||||
|
|
||||||
@ -703,7 +692,6 @@ namespace DHSoftware
|
|||||||
if (itemSpeed != null)
|
if (itemSpeed != null)
|
||||||
{
|
{
|
||||||
PLC.TurntableOpen(Convert.ToInt32(itemSpeed.Value), true);
|
PLC.TurntableOpen(Convert.ToInt32(itemSpeed.Value), true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
@ -715,12 +703,11 @@ namespace DHSoftware
|
|||||||
// _PLC.Vibratory(true);
|
// _PLC.Vibratory(true);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
//InitialOEEStatistic();
|
//InitialOEEStatistic();
|
||||||
|
|
||||||
// MachineState = MachineState.Running;
|
// MachineState = MachineState.Running;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PrepareMLEngine()
|
private void PrepareMLEngine()
|
||||||
{
|
{
|
||||||
//if (_visionEngine == null)
|
//if (_visionEngine == null)
|
||||||
@ -733,9 +720,6 @@ namespace DHSoftware
|
|||||||
// throw new ProcessException($"未能获取检测设备");
|
// throw new ProcessException($"未能获取检测设备");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//相机模组
|
//相机模组
|
||||||
//_cameraRelatedDetectionDict = new();
|
//_cameraRelatedDetectionDict = new();
|
||||||
|
|
||||||
@ -756,7 +740,6 @@ namespace DHSoftware
|
|||||||
// _cameraRelatedDetectionDict[cam.CameraSourceId].Add(detection.Id);
|
// _cameraRelatedDetectionDict[cam.CameraSourceId].Add(detection.Id);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// });
|
// });
|
||||||
//});
|
//});
|
||||||
|
|
||||||
@ -766,8 +749,6 @@ namespace DHSoftware
|
|||||||
#if false
|
#if false
|
||||||
private void HandleStartButton2()
|
private void HandleStartButton2()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
CurrentMachine = true;
|
CurrentMachine = true;
|
||||||
|
|
||||||
//_visionEngine.Start();
|
//_visionEngine.Start();
|
||||||
@ -798,8 +779,6 @@ namespace DHSoftware
|
|||||||
RecongnitionLabelList.Add(recongnition2);
|
RecongnitionLabelList.Add(recongnition2);
|
||||||
RecongnitionLabelList.Add(recongnition3);
|
RecongnitionLabelList.Add(recongnition3);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var det1 = new DetectionConfig("相机1", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam1.onnx", false, "Cam1");
|
var det1 = new DetectionConfig("相机1", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam1.onnx", false, "Cam1");
|
||||||
var det2 = new DetectionConfig("相机2", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam2.onnx", false, "Cam2");
|
var det2 = new DetectionConfig("相机2", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam2.onnx", false, "Cam2");
|
||||||
var det3 = new DetectionConfig("相机3", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam3.onnx", false, "Cam3");
|
var det3 = new DetectionConfig("相机3", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam3.onnx", false, "Cam3");
|
||||||
@ -827,7 +806,6 @@ namespace DHSoftware
|
|||||||
|
|
||||||
float Conf = 0.5f;
|
float Conf = 0.5f;
|
||||||
|
|
||||||
|
|
||||||
det1.CameraCollects = CameraCollects;
|
det1.CameraCollects = CameraCollects;
|
||||||
det1.ModelconfThreshold = Conf;
|
det1.ModelconfThreshold = Conf;
|
||||||
det1.ModelWidth = 640;
|
det1.ModelWidth = 640;
|
||||||
@ -864,8 +842,6 @@ namespace DHSoftware
|
|||||||
det4.ShowLocation.X = 4;
|
det4.ShowLocation.X = 4;
|
||||||
det4.ShowLocation.Y = 1;
|
det4.ShowLocation.Y = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
det5.CameraCollects = CameraCollects5;
|
det5.CameraCollects = CameraCollects5;
|
||||||
det5.ModelconfThreshold = Conf;
|
det5.ModelconfThreshold = Conf;
|
||||||
det5.ModelWidth = 640;
|
det5.ModelWidth = 640;
|
||||||
@ -926,8 +902,6 @@ namespace DHSoftware
|
|||||||
camera.CameraConnect();
|
camera.CameraConnect();
|
||||||
camera.OnHImageOutput += OnCameraHImageOutput;
|
camera.OnHImageOutput += OnCameraHImageOutput;
|
||||||
HKCameras.Add(camera);
|
HKCameras.Add(camera);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
//Do3ThinkCamera do3ThinkCamera1 = new Do3ThinkCamera();
|
//Do3ThinkCamera do3ThinkCamera1 = new Do3ThinkCamera();
|
||||||
@ -939,7 +913,6 @@ namespace DHSoftware
|
|||||||
// Cameras.Add(do3ThinkCamera1);
|
// Cameras.Add(do3ThinkCamera1);
|
||||||
for (int i = 1; i <= 8; i++)
|
for (int i = 1; i <= 8; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
Do3ThinkCamera cam = new Do3ThinkCamera();
|
Do3ThinkCamera cam = new Do3ThinkCamera();
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
{
|
{
|
||||||
@ -956,13 +929,10 @@ namespace DHSoftware
|
|||||||
cam.OnHImageOutput += OnCameraHImageOutput;
|
cam.OnHImageOutput += OnCameraHImageOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
DetectionConfigs.ForEach(detection =>
|
DetectionConfigs.ForEach(detection =>
|
||||||
{
|
{
|
||||||
|
|
||||||
detection.CameraCollects.ForEach(cam =>
|
detection.CameraCollects.ForEach(cam =>
|
||||||
{
|
{
|
||||||
List<string> Dets = new List<string>
|
List<string> Dets = new List<string>
|
||||||
@ -977,15 +947,11 @@ namespace DHSoftware
|
|||||||
{
|
{
|
||||||
_cameraRelatedDetectionDict[cam.CameraSourceId].Add(detection.Id);
|
_cameraRelatedDetectionDict[cam.CameraSourceId].Add(detection.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
string inferenceDevice = "CPU";
|
string inferenceDevice = "CPU";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_visionEngine = new SimboVisionDriver();
|
_visionEngine = new SimboVisionDriver();
|
||||||
_visionEngine.DetectionConfigs = DetectionConfigs;
|
_visionEngine.DetectionConfigs = DetectionConfigs;
|
||||||
|
|
||||||
@ -1016,12 +982,9 @@ namespace DHSoftware
|
|||||||
sLDMotion.IODefinitionCollection = new List<IODefinition>();
|
sLDMotion.IODefinitionCollection = new List<IODefinition>();
|
||||||
Motion(sLDMotion.IODefinitionCollection);
|
Motion(sLDMotion.IODefinitionCollection);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sLDMotion.SnapshotSettings = new List<SnapshotSetting>();
|
sLDMotion.SnapshotSettings = new List<SnapshotSetting>();
|
||||||
int[] cameraPositions = { 24161, 33608, 39702, 45701 };
|
int[] cameraPositions = { 24161, 33608, 39702, 45701 };
|
||||||
|
|
||||||
|
|
||||||
sLDMotion.SnapshotSettings.Add(new SnapshotSetting
|
sLDMotion.SnapshotSettings.Add(new SnapshotSetting
|
||||||
{
|
{
|
||||||
IsEnabled = true,
|
IsEnabled = true,
|
||||||
@ -1040,8 +1003,6 @@ namespace DHSoftware
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sLDMotion.BlowSettings = new List<BlowSetting>();
|
sLDMotion.BlowSettings = new List<BlowSetting>();
|
||||||
int[] BlowPositions = { 61353, 68566 };
|
int[] BlowPositions = { 61353, 68566 };
|
||||||
sLDMotion.BlowSettings.Add(new BlowSetting
|
sLDMotion.BlowSettings.Add(new BlowSetting
|
||||||
@ -1065,8 +1026,6 @@ namespace DHSoftware
|
|||||||
//sna1.CameraPosition = 17000;
|
//sna1.CameraPosition = 17000;
|
||||||
//sna1.StationNumber = 0;
|
//sna1.StationNumber = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// sLDMotion.SnapshotSettings.Add(sna1);
|
// sLDMotion.SnapshotSettings.Add(sna1);
|
||||||
sLDMotion.AxisSettings.Add(axis1);
|
sLDMotion.AxisSettings.Add(axis1);
|
||||||
sLDMotion.Init();
|
sLDMotion.Init();
|
||||||
@ -1114,11 +1073,11 @@ namespace DHSoftware
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
private uint PieceCount = 0;
|
private uint PieceCount = 0;
|
||||||
private List<ConcurrentDictionary<uint, ProductData>> _productLists = new List<ConcurrentDictionary<uint, ProductData>>();
|
private List<ConcurrentDictionary<uint, ProductData>> _productLists = new List<ConcurrentDictionary<uint, ProductData>>();
|
||||||
private int ProductListMulti = 2;
|
private int ProductListMulti = 2;
|
||||||
private int ProductBaseCount = 0;
|
private int ProductBaseCount = 0;
|
||||||
|
|
||||||
private int PieceNumberToIndex(uint pn)
|
private int PieceNumberToIndex(uint pn)
|
||||||
{
|
{
|
||||||
// 物料编号,取余 集合数量
|
// 物料编号,取余 集合数量
|
||||||
@ -1126,7 +1085,9 @@ namespace DHSoftware
|
|||||||
int ret = (int)(pn % (ProductBaseCount * ProductListMulti));
|
int ret = (int)(pn % (ProductBaseCount * ProductListMulti));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
DateTime _ctTime = DateTime.Now;
|
|
||||||
|
private DateTime _ctTime = DateTime.Now;
|
||||||
|
|
||||||
public async void MainMotion_NewPieces(int axisIndex, uint pieceNumber)
|
public async void MainMotion_NewPieces(int axisIndex, uint pieceNumber)
|
||||||
{
|
{
|
||||||
//if (MachineState != MachineState.Running && MachineState != MachineState.Warning)
|
//if (MachineState != MachineState.Running && MachineState != MachineState.Warning)
|
||||||
@ -1134,10 +1095,8 @@ namespace DHSoftware
|
|||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
PieceCount++;
|
PieceCount++;
|
||||||
|
|
||||||
|
|
||||||
int index = PieceNumberToIndex(pieceNumber);
|
int index = PieceNumberToIndex(pieceNumber);
|
||||||
// productDatas.Add(pData);
|
// productDatas.Add(pData);
|
||||||
//转盘2 的物料是不是重新覆盖之前的pDta
|
//转盘2 的物料是不是重新覆盖之前的pDta
|
||||||
@ -1150,14 +1109,12 @@ namespace DHSoftware
|
|||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
//this.BeginInvoke(new MethodInvoker(delegate () { richTextBox1.AppendText(logStr); }));
|
//this.BeginInvoke(new MethodInvoker(delegate () { richTextBox1.AppendText(logStr); }));
|
||||||
|
|
||||||
});
|
});
|
||||||
DateTime dtNow = DateTime.Now;
|
DateTime dtNow = DateTime.Now;
|
||||||
UpdateCT(null, (float)(dtNow - _ctTime).TotalSeconds);
|
UpdateCT(null, (float)(dtNow - _ctTime).TotalSeconds);
|
||||||
_ctTime = dtNow;
|
_ctTime = dtNow;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateCT(object objData, float ctTime)
|
public async Task UpdateCT(object objData, float ctTime)
|
||||||
{
|
{
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
@ -1165,6 +1122,7 @@ namespace DHSoftware
|
|||||||
//OnUpdateCT?.Invoke(objData, ctTime);
|
//OnUpdateCT?.Invoke(objData, ctTime);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 相机回调
|
/// 相机回调
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -1173,7 +1131,6 @@ namespace DHSoftware
|
|||||||
/// <param name="imageSet"></param>
|
/// <param name="imageSet"></param>
|
||||||
private void OnCameraHImageOutput(DateTime dt, CameraBase camera, Mat imageSet)
|
private void OnCameraHImageOutput(DateTime dt, CameraBase camera, Mat imageSet)
|
||||||
{
|
{
|
||||||
|
|
||||||
//if (camera.CameraName.Equals("cam1", StringComparison.OrdinalIgnoreCase))
|
//if (camera.CameraName.Equals("cam1", StringComparison.OrdinalIgnoreCase))
|
||||||
//{
|
//{
|
||||||
// Console.WriteLine();
|
// Console.WriteLine();
|
||||||
@ -1230,7 +1187,6 @@ namespace DHSoftware
|
|||||||
localImageSet.Dispose();
|
localImageSet.Dispose();
|
||||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||||
{
|
{
|
||||||
|
|
||||||
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
||||||
|
|
||||||
richTextBox1.AppendText(productNumber + "提前推出" + camera.CameraName);
|
richTextBox1.AppendText(productNumber + "提前推出" + camera.CameraName);
|
||||||
@ -1252,11 +1208,9 @@ namespace DHSoftware
|
|||||||
|
|
||||||
if (!_cameraRelatedDetectionDict.ContainsKey(camera.CameraName))
|
if (!_cameraRelatedDetectionDict.ContainsKey(camera.CameraName))
|
||||||
{
|
{
|
||||||
|
|
||||||
localImageSet.Dispose();
|
localImageSet.Dispose();
|
||||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||||
{
|
{
|
||||||
|
|
||||||
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
||||||
|
|
||||||
richTextBox1.AppendText(productNumber + "提前推出" + camera.CameraName);
|
richTextBox1.AppendText(productNumber + "提前推出" + camera.CameraName);
|
||||||
@ -1276,33 +1230,23 @@ namespace DHSoftware
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double totalTime = 0.0;
|
double totalTime = 0.0;
|
||||||
List<ResultState> resultStates = new List<ResultState>();
|
List<ResultState> resultStates = new List<ResultState>();
|
||||||
List<string>? detectionDict = _cameraRelatedDetectionDict[camera.CameraName];
|
List<string>? detectionDict = _cameraRelatedDetectionDict[camera.CameraName];
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < detectionDict.Count; i++)
|
for (int i = 0; i < detectionDict.Count; i++)
|
||||||
{
|
{
|
||||||
string detectionId = detectionDict[i];
|
string detectionId = detectionDict[i];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 1. 预处理
|
// 1. 预处理
|
||||||
using (Mat inferenceImage = localImageSet.Clone()) // 仅在此处克隆,确保推理过程中 Mat 有独立副本
|
using (Mat inferenceImage = localImageSet.Clone()) // 仅在此处克隆,确保推理过程中 Mat 有独立副本
|
||||||
{
|
{
|
||||||
DetectStationResult temp1=_visionEngine.RunInference(inferenceImage, detectionId);
|
DetectStationResult temp1 = _visionEngine.RunInference(inferenceImage, detectionId);
|
||||||
|
|
||||||
resultStates.Add(temp1.ResultState);
|
resultStates.Add(temp1.ResultState);
|
||||||
|
|
||||||
product.ResultCollection.Add(temp1);
|
product.ResultCollection.Add(temp1);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
product.InferenceOne();
|
product.InferenceOne();
|
||||||
@ -1311,14 +1255,12 @@ namespace DHSoftware
|
|||||||
|
|
||||||
if (!product.InferenceFinished())
|
if (!product.InferenceFinished())
|
||||||
{
|
{
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ProductNum_Total++;
|
ProductNum_Total++;
|
||||||
CalculateOEE();
|
CalculateOEE();
|
||||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||||
{
|
{
|
||||||
|
|
||||||
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
||||||
|
|
||||||
richTextBox1.AppendText($"统计结果成功,{productNumber} 吹气!\n");
|
richTextBox1.AppendText($"统计结果成功,{productNumber} 吹气!\n");
|
||||||
@ -1327,22 +1269,18 @@ namespace DHSoftware
|
|||||||
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
||||||
richTextBox1.ScrollToCaret();
|
richTextBox1.ScrollToCaret();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
#region 6. 统计产品结果
|
#region 6. 统计产品结果
|
||||||
|
|
||||||
product.ProductResult = product.ResultCollection.Any(u => u.ResultState != ResultState.OK)
|
product.ProductResult = product.ResultCollection.Any(u => u.ResultState != ResultState.OK)
|
||||||
? ResultState.B_NG
|
? ResultState.B_NG
|
||||||
: ResultState.OK;
|
: ResultState.OK;
|
||||||
product.ProductLabelCategory = product.ProductResult.GetEnumDescription();
|
product.ProductLabelCategory = product.ProductResult.GetEnumDescription();
|
||||||
product.ProductLabel = product.ProductResult.GetEnumDescription();
|
product.ProductLabel = product.ProductResult.GetEnumDescription();
|
||||||
#endregion
|
|
||||||
#region 7.产品吹气
|
|
||||||
|
|
||||||
#endregion
|
#endregion 6. 统计产品结果
|
||||||
|
|
||||||
|
// 出列
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 出列
|
|
||||||
ProductData temp = null;
|
ProductData temp = null;
|
||||||
|
|
||||||
int tryTimes = 10;
|
int tryTimes = 10;
|
||||||
@ -1362,7 +1300,6 @@ namespace DHSoftware
|
|||||||
$"当前队列产品数量:{tmpDic.Count}";
|
$"当前队列产品数量:{tmpDic.Count}";
|
||||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||||
{
|
{
|
||||||
|
|
||||||
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
||||||
|
|
||||||
richTextBox1.AppendText(logStr);
|
richTextBox1.AppendText(logStr);
|
||||||
@ -1381,7 +1318,6 @@ namespace DHSoftware
|
|||||||
$"当前队列产品数量:{tmpDic.Count}";
|
$"当前队列产品数量:{tmpDic.Count}";
|
||||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||||
{
|
{
|
||||||
|
|
||||||
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
||||||
|
|
||||||
richTextBox1.AppendText(logStr);
|
richTextBox1.AppendText(logStr);
|
||||||
@ -1396,7 +1332,6 @@ namespace DHSoftware
|
|||||||
{
|
{
|
||||||
sw.WriteLine(logStr);
|
sw.WriteLine(logStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
finally
|
finally
|
||||||
@ -1407,10 +1342,8 @@ namespace DHSoftware
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateCT((float)(dtNow - _ctTime).TotalSeconds);
|
// UpdateCT((float)(dtNow - _ctTime).TotalSeconds);
|
||||||
//_ctTime = dtNow;
|
//_ctTime = dtNow;
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -1418,18 +1351,11 @@ namespace DHSoftware
|
|||||||
product?.Dispose();
|
product?.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetResult()
|
public void SetResult()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//// detectResult.IsPreTreatDone = detectResult.VisionImageSet.PreTreatedFlag
|
//// detectResult.IsPreTreatDone = detectResult.VisionImageSet.PreTreatedFlag
|
||||||
////2024-02-29 目标检测不能全是NG
|
////2024-02-29 目标检测不能全是NG
|
||||||
//if (IsPreTreatNG || IsObjectDetectNG)
|
//if (IsPreTreatNG || IsObjectDetectNG)
|
||||||
@ -1437,25 +1363,25 @@ namespace DHSoftware
|
|||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//if (IsPreTreatDone && IsMLDetectDone && IsAfterTreatDone)
|
//if (IsPreTreatDone && IsMLDetectDone && IsAfterTreatDone)
|
||||||
//{
|
//{
|
||||||
// ResultState = ResultState.OK;
|
// ResultState = ResultState.OK;
|
||||||
// ResultLabel = ResultState.OK.GetEnumDescription();
|
// ResultLabel = ResultState.OK.GetEnumDescription();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleStopButton()
|
private void HandleStopButton()
|
||||||
{
|
{
|
||||||
Cameras.Clear();
|
Cameras.Clear();
|
||||||
Dectection.Clear();
|
Dectection.Clear();
|
||||||
// Add the code for the "停止" button click here
|
// Add the code for the "停止" button click here
|
||||||
PLC.TurntableStop();
|
PLC.TurntableStop();
|
||||||
CurrentMachine = true;
|
CurrentMachine = true;
|
||||||
sLDMotion.Stop();
|
sLDMotion.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int UPH = 0;
|
public int UPH = 0;
|
||||||
|
|
||||||
public void CalculateOEE()
|
public void CalculateOEE()
|
||||||
{
|
{
|
||||||
TimeSpan timeSpan = DateTime.Now - startTime;
|
TimeSpan timeSpan = DateTime.Now - startTime;
|
||||||
@ -1466,10 +1392,8 @@ namespace DHSoftware
|
|||||||
{
|
{
|
||||||
label1.Text = UPH.ToString();
|
label1.Text = UPH.ToString();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleResetButton()
|
private void HandleResetButton()
|
||||||
{
|
{
|
||||||
// Add the code for the "复位" button click here
|
// Add the code for the "复位" button click here
|
||||||
@ -1481,19 +1405,17 @@ namespace DHSoftware
|
|||||||
// Add the code for the "设置" button click here
|
// Add the code for the "设置" button click here
|
||||||
|
|
||||||
SettingWindow.Instance.Show();
|
SettingWindow.Instance.Show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleLoginButton()
|
private void HandleLoginButton()
|
||||||
{
|
{
|
||||||
// Add the code for the "登录" button click here
|
// Add the code for the "登录" button click here
|
||||||
LoginWindow.Instance.Owner = this;
|
LoginWindow.Instance.Owner = this;
|
||||||
LoginWindow.Instance.Show();
|
LoginWindow.Instance.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void splitter1_SplitterMoved(object sender, SplitterEventArgs e)
|
private void splitter1_SplitterMoved(object sender, SplitterEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,12 @@
|
|||||||
using AntdUI;
|
using AntdUI;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DHSoftware.Models
|
namespace DHSoftware.Models
|
||||||
{
|
{
|
||||||
public class DataModel
|
public class DataModel
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public class DefectRow:NotifyProperty
|
|
||||||
|
public class DefectRow : NotifyProperty
|
||||||
{
|
{
|
||||||
private bool selected = false;
|
private bool selected = false;
|
||||||
public string LabelId { get; set; }
|
public string LabelId { get; set; }
|
||||||
@ -35,4 +31,4 @@ namespace DHSoftware.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
namespace AntdUIDemo.Models
|
||||||
|
|
||||||
namespace AntdUIDemo.Models
|
|
||||||
{
|
{
|
||||||
public class DataUtil
|
public class DataUtil
|
||||||
{
|
{
|
||||||
@ -220,9 +218,5 @@ namespace AntdUIDemo.Models
|
|||||||
{ "Chat", "MessageOutlined" },
|
{ "Chat", "MessageOutlined" },
|
||||||
{ "Other", "SettingOutlined" }
|
{ "Other", "SettingOutlined" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
@ -1,9 +1,4 @@
|
|||||||
using System;
|
using SqlSugar;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using SqlSugar;
|
|
||||||
|
|
||||||
namespace DHSoftware.Models
|
namespace DHSoftware.Models
|
||||||
{
|
{
|
||||||
@ -65,4 +60,4 @@ namespace DHSoftware.Models
|
|||||||
[SugarColumn(IsPrimaryKey = true)]
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
public string PermissionCode { get; set; }
|
public string PermissionCode { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,20 +1,9 @@
|
|||||||
using System;
|
namespace DHSoftware.Models
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
|
|
||||||
namespace DHSoftware.Models
|
|
||||||
{
|
{
|
||||||
public class Camera
|
public class Camera
|
||||||
{
|
{
|
||||||
public string DeviceName { get; set; }
|
public string DeviceName { get; set; }
|
||||||
public string Alias { get; set; }
|
public string Alias { get; set; }
|
||||||
public string ImagePath { get; set; }
|
public string ImagePath { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
@ -6,4 +6,4 @@
|
|||||||
public string Text { get; set; } = string.Empty;
|
public string Text { get; set; } = string.Empty;
|
||||||
public string Tag { get; set; } = null;
|
public string Tag { get; set; } = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +1,9 @@
|
|||||||
using System;
|
using DHSoftware.Models;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using DHSoftware.Models;
|
|
||||||
using DHSoftware.Utils;
|
using DHSoftware.Utils;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
||||||
namespace DHSoftware.Services
|
namespace DHSoftware.Services
|
||||||
{
|
{
|
||||||
|
|
||||||
public static class AuthService
|
public static class AuthService
|
||||||
{
|
{
|
||||||
public static User CurrentUser { get; private set; }
|
public static User CurrentUser { get; private set; }
|
||||||
@ -37,11 +31,11 @@ namespace DHSoftware.Services
|
|||||||
|
|
||||||
using (var db = DatabaseUtil.GetDatabase())
|
using (var db = DatabaseUtil.GetDatabase())
|
||||||
{
|
{
|
||||||
return db.Queryable<UserRole>()
|
return db.Queryable<UserRole>()
|
||||||
.InnerJoin<RolePermission>((ur, rp) => ur.RoleId == rp.RoleId)
|
.InnerJoin<RolePermission>((ur, rp) => ur.RoleId == rp.RoleId)
|
||||||
.Where((ur, rp) => ur.UserId == CurrentUser.Id)
|
.Where((ur, rp) => ur.UserId == CurrentUser.Id)
|
||||||
.Where((ur, rp) => rp.PermissionCode == permissionCode)
|
.Where((ur, rp) => rp.PermissionCode == permissionCode)
|
||||||
.Any();
|
.Any();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,4 +61,4 @@ namespace DHSoftware.Services
|
|||||||
.ExecuteCommand();
|
.ExecuteCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,18 +1,9 @@
|
|||||||
using System;
|
namespace DHSoftware.Utils
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AntdUI;
|
|
||||||
|
|
||||||
namespace DHSoftware.Utils
|
|
||||||
{
|
{
|
||||||
public static class AdaptiveHelper
|
public static class AdaptiveHelper
|
||||||
{
|
{
|
||||||
#region 控件大小随窗体大小等比例缩放
|
#region 控件大小随窗体大小等比例缩放
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void setTag(Control cons)
|
public static void setTag(Control cons)
|
||||||
{
|
{
|
||||||
foreach (Control con in cons.Controls)
|
foreach (Control con in cons.Controls)
|
||||||
@ -35,15 +26,13 @@ namespace DHSoftware.Utils
|
|||||||
con.Height = Convert.ToInt32(Convert.ToSingle(mytag[1]) * newy); //高度
|
con.Height = Convert.ToInt32(Convert.ToSingle(mytag[1]) * newy); //高度
|
||||||
con.Left = Convert.ToInt32(Convert.ToSingle(mytag[2]) * newx); //左边距
|
con.Left = Convert.ToInt32(Convert.ToSingle(mytag[2]) * newx); //左边距
|
||||||
con.Top = Convert.ToInt32(Convert.ToSingle(mytag[3]) * newy); //顶边距
|
con.Top = Convert.ToInt32(Convert.ToSingle(mytag[3]) * newy); //顶边距
|
||||||
var currentSize = Convert.ToSingle(mytag[4]) * newy; //字体大小
|
var currentSize = Convert.ToSingle(mytag[4]) * newy; //字体大小
|
||||||
if (currentSize > 0) con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit);
|
if (currentSize > 0) con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit);
|
||||||
con.Focus();
|
con.Focus();
|
||||||
if (con.Controls.Count > 0) setControls(newx, newy, con);
|
if (con.Controls.Count > 0) setControls(newx, newy, con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion 控件大小随窗体大小等比例缩放
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,4 @@
|
|||||||
using System;
|
using DHSoftware.Models;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using DHSoftware.Models;
|
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
||||||
namespace DHSoftware.Utils
|
namespace DHSoftware.Utils
|
||||||
@ -153,4 +148,4 @@ namespace DHSoftware.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,5 @@
|
|||||||
using System;
|
using System.Security.Cryptography;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DHSoftware.Utils
|
namespace DHSoftware.Utils
|
||||||
{
|
{
|
||||||
@ -20,4 +16,4 @@ namespace DHSoftware.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace DHSoftware.Utils
|
namespace DHSoftware.Utils
|
||||||
{
|
{
|
||||||
@ -45,4 +44,4 @@ namespace DHSoftware.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,25 +4,26 @@ using DH.Commons.Helper;
|
|||||||
using DH.Commons.Models;
|
using DH.Commons.Models;
|
||||||
using DHSoftware.Utils;
|
using DHSoftware.Utils;
|
||||||
using DH.Commons.Base;
|
using DH.Commons.Base;
|
||||||
|
|
||||||
namespace DHSoftware.Views
|
namespace DHSoftware.Views
|
||||||
{
|
{
|
||||||
public partial class SettingWindow : Window
|
public partial class SettingWindow : Window
|
||||||
{
|
{
|
||||||
private UserControl currControl;
|
private UserControl currControl;
|
||||||
|
|
||||||
|
|
||||||
public SettingWindow()
|
public SettingWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
BindEventHandler();
|
BindEventHandler();
|
||||||
InitData();
|
InitData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 窗体对象实例
|
/// 窗体对象实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static SettingWindow _instance;
|
private static SettingWindow _instance;
|
||||||
|
|
||||||
internal static SettingWindow Instance
|
internal static SettingWindow Instance
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -32,159 +33,153 @@ namespace DHSoftware.Views
|
|||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BindEventHandler()
|
private void BindEventHandler()
|
||||||
{
|
{
|
||||||
Resize += SettingWindow1_Resize;
|
Resize += SettingWindow1_Resize;
|
||||||
btnAdd.SelectedValueChanged += btnAdd_SelectedValueChanged;
|
btnAdd.SelectedValueChanged += btnAdd_SelectedValueChanged;
|
||||||
btnSave.Click += BtnSave_Click;
|
btnSave.Click += BtnSave_Click;
|
||||||
menu1.SelectChanged += Menu1_SelectChanged;
|
menu1.SelectChanged += Menu1_SelectChanged;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Menu1_SelectChanged(object sender, MenuSelectEventArgs e)
|
private void Menu1_SelectChanged(object sender, MenuSelectEventArgs e)
|
||||||
{
|
{
|
||||||
|
MenuItem clickedItem = e.Value;
|
||||||
MenuItem clickedItem = e.Value;
|
|
||||||
|
|
||||||
if (clickedItem != null)
|
if (clickedItem != null)
|
||||||
|
{
|
||||||
|
if (clickedItem.PARENTITEM == null)
|
||||||
{
|
{
|
||||||
if (clickedItem.PARENTITEM == null)
|
return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (clickedItem.PARENTITEM.Text)
|
|
||||||
{
|
|
||||||
case "相机设置":
|
|
||||||
foreach (var tab in tabs1.Pages)
|
|
||||||
{
|
|
||||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
|
||||||
{
|
|
||||||
isUpdatingTabs = true;
|
|
||||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
|
||||||
isUpdatingTabs = false;
|
|
||||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//先获取是否存在该名称的配置
|
|
||||||
//如果没有新建项
|
|
||||||
CameraBase? CameraBase = ConfigModel.CameraBaseList.Where(c => c.CameraName == clickedItem.Text).FirstOrDefault();
|
|
||||||
if (CameraBase == null)
|
|
||||||
{
|
|
||||||
CameraBase = new CameraBase();
|
|
||||||
}
|
|
||||||
UserControl control = null;
|
|
||||||
control = new CameraControl(this, CameraBase);
|
|
||||||
if (control != null)
|
|
||||||
{
|
|
||||||
//容器添加控件,需要调整dpi
|
|
||||||
control.Dock = DockStyle.Fill;
|
|
||||||
AutoDpi(control);
|
|
||||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
|
||||||
{
|
|
||||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
|
||||||
ReadOnly = false,
|
|
||||||
|
|
||||||
};
|
|
||||||
tabPage.Controls.Add(control);
|
|
||||||
tabs1.Pages.Add(tabPage);
|
|
||||||
isUpdatingTabs = true;
|
|
||||||
tabs1.SelectedTab = tabPage;
|
|
||||||
isUpdatingTabs = false;
|
|
||||||
currControl = control;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "工位设置":
|
|
||||||
// 检查是否已存在同名 TabPage
|
|
||||||
foreach (var tab in tabs1.Pages)
|
|
||||||
{
|
|
||||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
|
||||||
{
|
|
||||||
isUpdatingTabs = true;
|
|
||||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
|
||||||
isUpdatingTabs = false;
|
|
||||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DetectionConfig? detectionConfig = ConfigModel.DetectionList.Where(c => c.Name == clickedItem.Text).FirstOrDefault();
|
|
||||||
if (detectionConfig == null)
|
|
||||||
{
|
|
||||||
detectionConfig = new DetectionConfig();
|
|
||||||
}
|
|
||||||
UserControl control1 = null;
|
|
||||||
control1 = new DetectControl(this, detectionConfig);
|
|
||||||
if (control1 != null)
|
|
||||||
{
|
|
||||||
//容器添加控件,需要调整dpi
|
|
||||||
control1.Dock = DockStyle.Fill;
|
|
||||||
AutoDpi(control1);
|
|
||||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
|
||||||
{
|
|
||||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
|
||||||
ReadOnly = false,
|
|
||||||
|
|
||||||
};
|
|
||||||
tabPage.Controls.Add(control1);
|
|
||||||
tabs1.Pages.Add(tabPage);
|
|
||||||
isUpdatingTabs = true;
|
|
||||||
tabs1.SelectedTab = tabPage;
|
|
||||||
isUpdatingTabs = false;
|
|
||||||
currControl = control1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "运控设置":
|
|
||||||
foreach (var tab in tabs1.Pages)
|
|
||||||
{
|
|
||||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
|
||||||
{
|
|
||||||
isUpdatingTabs = true;
|
|
||||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
|
||||||
isUpdatingTabs = false;
|
|
||||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//先获取是否存在该名称的配置
|
|
||||||
//如果没有新建项
|
|
||||||
PLCBase? pLCBase = ConfigModel.PLCBaseList.Where(c => c.PLCName == clickedItem.Text).FirstOrDefault();
|
|
||||||
if (pLCBase == null)
|
|
||||||
{
|
|
||||||
pLCBase = new PLCBase();
|
|
||||||
}
|
|
||||||
UserControl control2 = null;
|
|
||||||
control = new MotionControl(this, pLCBase);
|
|
||||||
if (control != null)
|
|
||||||
{
|
|
||||||
//容器添加控件,需要调整dpi
|
|
||||||
control.Dock = DockStyle.Fill;
|
|
||||||
AutoDpi(control);
|
|
||||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
|
||||||
{
|
|
||||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
|
||||||
ReadOnly = false,
|
|
||||||
|
|
||||||
};
|
|
||||||
tabPage.Controls.Add(control);
|
|
||||||
tabs1.Pages.Add(tabPage);
|
|
||||||
isUpdatingTabs = true;
|
|
||||||
tabs1.SelectedTab = tabPage;
|
|
||||||
isUpdatingTabs = false;
|
|
||||||
currControl = control;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (clickedItem.PARENTITEM.Text)
|
||||||
|
{
|
||||||
|
case "相机设置":
|
||||||
|
foreach (var tab in tabs1.Pages)
|
||||||
|
{
|
||||||
|
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||||
|
{
|
||||||
|
isUpdatingTabs = true;
|
||||||
|
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||||
|
isUpdatingTabs = false;
|
||||||
|
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//先获取是否存在该名称的配置
|
||||||
|
//如果没有新建项
|
||||||
|
CameraBase? CameraBase = ConfigModel.CameraBaseList.Where(c => c.CameraName == clickedItem.Text).FirstOrDefault();
|
||||||
|
if (CameraBase == null)
|
||||||
|
{
|
||||||
|
CameraBase = new CameraBase();
|
||||||
|
}
|
||||||
|
UserControl control = null;
|
||||||
|
control = new CameraControl(this, CameraBase);
|
||||||
|
if (control != null)
|
||||||
|
{
|
||||||
|
//容器添加控件,需要调整dpi
|
||||||
|
control.Dock = DockStyle.Fill;
|
||||||
|
AutoDpi(control);
|
||||||
|
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||||
|
{
|
||||||
|
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||||
|
ReadOnly = false,
|
||||||
|
};
|
||||||
|
tabPage.Controls.Add(control);
|
||||||
|
tabs1.Pages.Add(tabPage);
|
||||||
|
isUpdatingTabs = true;
|
||||||
|
tabs1.SelectedTab = tabPage;
|
||||||
|
isUpdatingTabs = false;
|
||||||
|
currControl = control;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "工位设置":
|
||||||
|
// 检查是否已存在同名 TabPage
|
||||||
|
foreach (var tab in tabs1.Pages)
|
||||||
|
{
|
||||||
|
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||||
|
{
|
||||||
|
isUpdatingTabs = true;
|
||||||
|
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||||
|
isUpdatingTabs = false;
|
||||||
|
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DetectionConfig? detectionConfig = ConfigModel.DetectionList.Where(c => c.Name == clickedItem.Text).FirstOrDefault();
|
||||||
|
if (detectionConfig == null)
|
||||||
|
{
|
||||||
|
detectionConfig = new DetectionConfig();
|
||||||
|
}
|
||||||
|
UserControl control1 = null;
|
||||||
|
control1 = new DetectControl(this, detectionConfig);
|
||||||
|
if (control1 != null)
|
||||||
|
{
|
||||||
|
//容器添加控件,需要调整dpi
|
||||||
|
control1.Dock = DockStyle.Fill;
|
||||||
|
AutoDpi(control1);
|
||||||
|
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||||
|
{
|
||||||
|
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||||
|
ReadOnly = false,
|
||||||
|
};
|
||||||
|
tabPage.Controls.Add(control1);
|
||||||
|
tabs1.Pages.Add(tabPage);
|
||||||
|
isUpdatingTabs = true;
|
||||||
|
tabs1.SelectedTab = tabPage;
|
||||||
|
isUpdatingTabs = false;
|
||||||
|
currControl = control1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "运控设置":
|
||||||
|
foreach (var tab in tabs1.Pages)
|
||||||
|
{
|
||||||
|
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||||
|
{
|
||||||
|
isUpdatingTabs = true;
|
||||||
|
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||||
|
isUpdatingTabs = false;
|
||||||
|
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//先获取是否存在该名称的配置
|
||||||
|
//如果没有新建项
|
||||||
|
PLCBase? pLCBase = ConfigModel.PLCBaseList.Where(c => c.PLCName == clickedItem.Text).FirstOrDefault();
|
||||||
|
if (pLCBase == null)
|
||||||
|
{
|
||||||
|
pLCBase = new PLCBase();
|
||||||
|
}
|
||||||
|
UserControl control2 = null;
|
||||||
|
control = new MotionControl(this, pLCBase);
|
||||||
|
if (control != null)
|
||||||
|
{
|
||||||
|
//容器添加控件,需要调整dpi
|
||||||
|
control.Dock = DockStyle.Fill;
|
||||||
|
AutoDpi(control);
|
||||||
|
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||||
|
{
|
||||||
|
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||||
|
ReadOnly = false,
|
||||||
|
};
|
||||||
|
tabPage.Controls.Add(control);
|
||||||
|
tabs1.Pages.Add(tabPage);
|
||||||
|
isUpdatingTabs = true;
|
||||||
|
tabs1.SelectedTab = tabPage;
|
||||||
|
isUpdatingTabs = false;
|
||||||
|
currControl = control;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float x; //定义当前窗体的宽度
|
private float x; //定义当前窗体的宽度
|
||||||
private float y; //定义当前窗体的高度
|
private float y; //定义当前窗体的高度
|
||||||
|
|
||||||
private void InitData()
|
private void InitData()
|
||||||
{
|
{
|
||||||
btnAdd.Items.Clear();
|
btnAdd.Items.Clear();
|
||||||
@ -196,68 +191,60 @@ namespace DHSoftware.Views
|
|||||||
y = Height;
|
y = Height;
|
||||||
AdaptiveHelper.setTag(this);
|
AdaptiveHelper.setTag(this);
|
||||||
|
|
||||||
|
if (ConfigModel.CameraBaseList.Count > 0)
|
||||||
if (ConfigModel.CameraBaseList.Count > 0)
|
{
|
||||||
|
var workstationItem = FindMenuItem(menu1.Items, "相机设置");
|
||||||
|
|
||||||
|
if (workstationItem != null)
|
||||||
{
|
{
|
||||||
var workstationItem = FindMenuItem(menu1.Items, "相机设置");
|
foreach (var item in ConfigModel.CameraBaseList)
|
||||||
|
|
||||||
if (workstationItem != null)
|
|
||||||
{
|
{
|
||||||
foreach (var item in ConfigModel.CameraBaseList)
|
var newItem = new MenuItem();
|
||||||
{
|
newItem.Text = item.CameraName;
|
||||||
var newItem = new MenuItem();
|
newItem.IconSvg = "VideoCameraOutlined";
|
||||||
newItem.Text = item.CameraName;
|
workstationItem.Sub.Add(newItem);
|
||||||
newItem.IconSvg = "VideoCameraOutlined";
|
|
||||||
workstationItem.Sub.Add(newItem);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ConfigModel.DetectionList.Count > 0)
|
|
||||||
{
|
|
||||||
var workstationItem = FindMenuItem(menu1.Items, "工位设置");
|
|
||||||
|
|
||||||
if (workstationItem != null)
|
|
||||||
{
|
|
||||||
foreach (var item in ConfigModel.DetectionList)
|
|
||||||
{
|
|
||||||
var newItem = new MenuItem();
|
|
||||||
newItem.Text = item.Name;
|
|
||||||
newItem.IconSvg = "AppstoreOutlined";
|
|
||||||
workstationItem.Sub.Add(newItem);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ConfigModel.PLCBaseList.Count > 0)
|
|
||||||
{
|
|
||||||
var workstationItem = FindMenuItem(menu1.Items, "运控设置");
|
|
||||||
|
|
||||||
if (workstationItem != null)
|
|
||||||
{
|
|
||||||
foreach (var item in ConfigModel.PLCBaseList)
|
|
||||||
{
|
|
||||||
var newItem = new MenuItem();
|
|
||||||
newItem.Text = item.PLCName;
|
|
||||||
newItem.IconSvg = "ControlOutlined";
|
|
||||||
workstationItem.Sub.Add(newItem);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ConfigModel.DetectionList.Count > 0)
|
||||||
|
{
|
||||||
|
var workstationItem = FindMenuItem(menu1.Items, "工位设置");
|
||||||
|
|
||||||
|
if (workstationItem != null)
|
||||||
|
{
|
||||||
|
foreach (var item in ConfigModel.DetectionList)
|
||||||
|
{
|
||||||
|
var newItem = new MenuItem();
|
||||||
|
newItem.Text = item.Name;
|
||||||
|
newItem.IconSvg = "AppstoreOutlined";
|
||||||
|
workstationItem.Sub.Add(newItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConfigModel.PLCBaseList.Count > 0)
|
||||||
|
{
|
||||||
|
var workstationItem = FindMenuItem(menu1.Items, "运控设置");
|
||||||
|
|
||||||
|
if (workstationItem != null)
|
||||||
|
{
|
||||||
|
foreach (var item in ConfigModel.PLCBaseList)
|
||||||
|
{
|
||||||
|
var newItem = new MenuItem();
|
||||||
|
newItem.Text = item.PLCName;
|
||||||
|
newItem.IconSvg = "ControlOutlined";
|
||||||
|
workstationItem.Sub.Add(newItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void BtnSave_Click(object? sender, EventArgs e)
|
private void BtnSave_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
ConfigHelper.SaveConfig();
|
||||||
ConfigHelper.SaveConfig();
|
AntdUI.Message.success(this, "保存成功!", autoClose: 3);
|
||||||
AntdUI.Message.success(this, "保存成功!", autoClose: 3);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void SettingWindow1_Resize(object? sender, EventArgs e)
|
private void SettingWindow1_Resize(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var newx = Width / x;
|
var newx = Width / x;
|
||||||
@ -265,13 +252,6 @@ namespace DHSoftware.Views
|
|||||||
AdaptiveHelper.setControls(newx, newy, this);
|
AdaptiveHelper.setControls(newx, newy, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 递归查找菜单项
|
// 递归查找菜单项
|
||||||
private MenuItem FindMenuItem(MenuItemCollection items, string targetText)
|
private MenuItem FindMenuItem(MenuItemCollection items, string targetText)
|
||||||
{
|
{
|
||||||
@ -287,17 +267,12 @@ namespace DHSoftware.Views
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool isUpdatingTabs = false;
|
||||||
|
|
||||||
bool isUpdatingTabs = false;
|
|
||||||
|
|
||||||
|
|
||||||
private void menu1_MouseDown(object sender, MouseEventArgs e)
|
private void menu1_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (e.Button == MouseButtons.Right)
|
||||||
if (e.Button == MouseButtons.Right)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// 转换坐标到控件内部坐标系(考虑滚动条)
|
// 转换坐标到控件内部坐标系(考虑滚动条)
|
||||||
Point clickPoint = new Point(e.X, e.Y + menu1.ScrollBar.Value);
|
Point clickPoint = new Point(e.X, e.Y + menu1.ScrollBar.Value);
|
||||||
|
|
||||||
@ -315,7 +290,7 @@ namespace DHSoftware.Views
|
|||||||
{
|
{
|
||||||
case "相机设置":
|
case "相机设置":
|
||||||
var menulist = new AntdUI.IContextMenuStripItem[]
|
var menulist = new AntdUI.IContextMenuStripItem[]
|
||||||
{
|
{
|
||||||
new AntdUI.ContextMenuStripItem("重命名", "")
|
new AntdUI.ContextMenuStripItem("重命名", "")
|
||||||
{
|
{
|
||||||
IconSvg = "RetweetOutlined"
|
IconSvg = "RetweetOutlined"
|
||||||
@ -324,7 +299,6 @@ namespace DHSoftware.Views
|
|||||||
{
|
{
|
||||||
IconSvg = "DeleteOutlined"
|
IconSvg = "DeleteOutlined"
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
AntdUI.ContextMenuStrip.open(menu1, it =>
|
AntdUI.ContextMenuStrip.open(menu1, it =>
|
||||||
{
|
{
|
||||||
@ -346,6 +320,7 @@ namespace DHSoftware.Views
|
|||||||
}
|
}
|
||||||
ConfigModel.CameraBaseList.RemoveAll(c => c.CameraName == clickedItem.Text);
|
ConfigModel.CameraBaseList.RemoveAll(c => c.CameraName == clickedItem.Text);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "重命名":
|
case "重命名":
|
||||||
// 保存原始名称用于查找
|
// 保存原始名称用于查找
|
||||||
string originalName = clickedItem.Text;
|
string originalName = clickedItem.Text;
|
||||||
@ -374,7 +349,7 @@ namespace DHSoftware.Views
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clickedItem.Text= newName;
|
clickedItem.Text = newName;
|
||||||
var camera = ConfigModel.CameraBaseList.FirstOrDefault(c =>
|
var camera = ConfigModel.CameraBaseList.FirstOrDefault(c =>
|
||||||
c.CameraName.Equals(originalName, StringComparison.OrdinalIgnoreCase));
|
c.CameraName.Equals(originalName, StringComparison.OrdinalIgnoreCase));
|
||||||
camera.CameraName = newName;
|
camera.CameraName = newName;
|
||||||
@ -393,9 +368,9 @@ namespace DHSoftware.Views
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}, menulist);
|
}, menulist);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "工位设置":
|
case "工位设置":
|
||||||
var menulist1 = new AntdUI.IContextMenuStripItem[]
|
var menulist1 = new AntdUI.IContextMenuStripItem[]
|
||||||
{ new AntdUI.ContextMenuStripItem("重命名", "")
|
{ new AntdUI.ContextMenuStripItem("重命名", "")
|
||||||
@ -406,7 +381,6 @@ namespace DHSoftware.Views
|
|||||||
{
|
{
|
||||||
IconSvg = "DeleteOutlined"
|
IconSvg = "DeleteOutlined"
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
AntdUI.ContextMenuStrip.open(menu1, it =>
|
AntdUI.ContextMenuStrip.open(menu1, it =>
|
||||||
{
|
{
|
||||||
@ -427,6 +401,7 @@ namespace DHSoftware.Views
|
|||||||
}
|
}
|
||||||
ConfigModel.DetectionList.RemoveAll(c => c.Name == clickedItem.Text);
|
ConfigModel.DetectionList.RemoveAll(c => c.Name == clickedItem.Text);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "重命名":
|
case "重命名":
|
||||||
// 保存原始名称用于查找
|
// 保存原始名称用于查找
|
||||||
string originalName = clickedItem.Text;
|
string originalName = clickedItem.Text;
|
||||||
@ -479,7 +454,7 @@ namespace DHSoftware.Views
|
|||||||
|
|
||||||
case "运控设置":
|
case "运控设置":
|
||||||
var menulist2 = new AntdUI.IContextMenuStripItem[]
|
var menulist2 = new AntdUI.IContextMenuStripItem[]
|
||||||
{
|
{
|
||||||
new AntdUI.ContextMenuStripItem("重命名", "")
|
new AntdUI.ContextMenuStripItem("重命名", "")
|
||||||
{
|
{
|
||||||
IconSvg = "RetweetOutlined"
|
IconSvg = "RetweetOutlined"
|
||||||
@ -488,13 +463,12 @@ namespace DHSoftware.Views
|
|||||||
{
|
{
|
||||||
IconSvg = "DeleteOutlined"
|
IconSvg = "DeleteOutlined"
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
AntdUI.ContextMenuStrip.open(menu1, it =>
|
AntdUI.ContextMenuStrip.open(menu1, it =>
|
||||||
{
|
{
|
||||||
switch (it.Text)
|
switch (it.Text)
|
||||||
{
|
{
|
||||||
case "删除运控":
|
case "删除运控":
|
||||||
menu1.Remove(clickedItem);
|
menu1.Remove(clickedItem);
|
||||||
foreach (var tab in tabs1.Pages)
|
foreach (var tab in tabs1.Pages)
|
||||||
{
|
{
|
||||||
@ -512,7 +486,8 @@ namespace DHSoftware.Views
|
|||||||
ConfigModel.PLCBaseList.RemoveAll(c => c.PLCName == clickedItem.Text);
|
ConfigModel.PLCBaseList.RemoveAll(c => c.PLCName == clickedItem.Text);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "重命名":
|
|
||||||
|
case "重命名":
|
||||||
|
|
||||||
var form = new AddMotionControl(this, "重命名运动控制操作") { Size = new Size(300, 200) };
|
var form = new AddMotionControl(this, "重命名运动控制操作") { Size = new Size(300, 200) };
|
||||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||||
@ -553,23 +528,15 @@ namespace DHSoftware.Views
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}, menulist2);
|
}, menulist2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private MenuItem FindClickedItem(MenuItemCollection items, Point clickPoint)
|
private MenuItem FindClickedItem(MenuItemCollection items, Point clickPoint)
|
||||||
{
|
{
|
||||||
foreach (MenuItem item in items)
|
foreach (MenuItem item in items)
|
||||||
@ -590,20 +557,17 @@ namespace DHSoftware.Views
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void btnAdd_SelectedValueChanged(object sender, ObjectNEventArgs e)
|
private void btnAdd_SelectedValueChanged(object sender, ObjectNEventArgs e)
|
||||||
{
|
{
|
||||||
string selectedValue = e.Value.ToString();
|
string selectedValue = e.Value.ToString();
|
||||||
switch (selectedValue)
|
switch (selectedValue)
|
||||||
{
|
{
|
||||||
case "相机设置":
|
case "相机设置":
|
||||||
var workstationItem = FindMenuItem(menu1.Items, "相机设置");
|
var workstationItem = FindMenuItem(menu1.Items, "相机设置");
|
||||||
|
|
||||||
if (workstationItem != null)
|
if (workstationItem != null)
|
||||||
{
|
{
|
||||||
|
var form = new AddCameraControl(this, "新增相机操作") { Size = new Size(300, 200) };
|
||||||
var form = new AddCameraControl(this,"新增相机操作") { Size = new Size(300, 200) };
|
|
||||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||||
{
|
{
|
||||||
BtnHeight = 0,
|
BtnHeight = 0,
|
||||||
@ -627,14 +591,14 @@ namespace DHSoftware.Views
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "工位设置":
|
case "工位设置":
|
||||||
// 查找工位设置项
|
// 查找工位设置项
|
||||||
var workstationItem1= FindMenuItem(menu1.Items, "工位设置");
|
var workstationItem1 = FindMenuItem(menu1.Items, "工位设置");
|
||||||
|
|
||||||
if (workstationItem1 != null)
|
if (workstationItem1 != null)
|
||||||
{
|
{
|
||||||
|
var form = new AddCubicleControl(this, "新增工位操作") { Size = new Size(300, 200) };
|
||||||
var form = new AddCubicleControl(this,"新增工位操作") { Size = new Size(300, 200) };
|
|
||||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||||
{
|
{
|
||||||
BtnHeight = 0,
|
BtnHeight = 0,
|
||||||
@ -647,7 +611,7 @@ namespace DHSoftware.Views
|
|||||||
if (!workstationItem1.Sub.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
|
if (!workstationItem1.Sub.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
|
||||||
{
|
{
|
||||||
workstationItem1.Sub.Add(newItem);
|
workstationItem1.Sub.Add(newItem);
|
||||||
DetectionConfig detection = new DetectionConfig();
|
DetectionConfig detection = new DetectionConfig();
|
||||||
detection.Name = form.CubicleName;
|
detection.Name = form.CubicleName;
|
||||||
ConfigModel.DetectionList.Add(detection);
|
ConfigModel.DetectionList.Add(detection);
|
||||||
}
|
}
|
||||||
@ -658,13 +622,13 @@ namespace DHSoftware.Views
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "运控设置":
|
case "运控设置":
|
||||||
var workstationItem2 = FindMenuItem(menu1.Items, "运控设置");
|
var workstationItem2 = FindMenuItem(menu1.Items, "运控设置");
|
||||||
|
|
||||||
if (workstationItem2 != null)
|
if (workstationItem2 != null)
|
||||||
{
|
{
|
||||||
|
var form = new AddMotionControl(this, "新增运动控制操作") { Size = new Size(300, 200) };
|
||||||
var form = new AddMotionControl(this,"新增运动控制操作") { Size = new Size(300, 200) };
|
|
||||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||||
{
|
{
|
||||||
BtnHeight = 0,
|
BtnHeight = 0,
|
||||||
@ -691,5 +655,4 @@ namespace DHSoftware.Views
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user