Commit 5cf1f174 LN

1.自动模式增加脚踏/按钮暂停功能。

2.料塔初始化失败时,提示是否进入过板模式。
1 个父辈 a388df00
......@@ -104,6 +104,7 @@
<Compile Include="manager\TSAVBean_Partial.cs" />
<Compile Include="manager\TSAVStatus.cs" />
<Compile Include="manager\WorkInfo.cs" />
<Compile Include="manager\WorkModeUtil.cs" />
<Compile Include="mes\DeviceStatus.cs" />
<Compile Include="mes\MesUtil.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using TSA_V.Common;
namespace TSA_V.DeviceLibrary
{
/// <summary>
/// 工作模式选择
/// </summary>
public class WorkModeUtil
{
/// <summary>
/// 只能进入过板模式
/// </summary>
public static bool OnlyGuoBan = false;
public static bool WaitSelect = false;
private static bool IsSelected = false;
public static event ModeBoxShow boxShowEvent;
public delegate DialogResult ModeBoxShow(string msg,string okMsg);
public static event CheckModeEnd checkModeEndEvent;
public delegate void CheckModeEnd( );
public static void ModeCheckEnd()
{
WorkModeUtil.checkModeEndEvent?.Invoke();
}
internal static void SelectMode(string Name)
{
if (IsSelected)
{
return;
}
try
{
WaitSelect = true;
//如果超时,且调宽轴已上线,旋转轴上线失败,提示是否进入过板模式
IsSelected = true;
LogUtil.error(Name + " 询问是否进入过板模式");
//DialogResult result = MessageBox.Show("料塔加载失败,是否进入过板模式?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
string msg = ResourceControl.GetString("SelectModeMsg", "料塔加载失败,是否进入过板模式?");
string okMsg = ResourceControl.GetString("SelectModeMsgOK", "您已选择流水线过板模式");
DialogResult result = (DialogResult)(boxShowEvent?.Invoke(msg, okMsg));
LogUtil.error(Name + " 询问是否进入过板模式 ,结果:" + result.ToString());
if (result.Equals(DialogResult.OK))
{
OnlyGuoBan = true;
LogUtil.info(Name + " 选择过板模式,不需要复位料塔");
}
else
{
LogUtil.info(Name + " 继续复位料塔");
}
}
catch(Exception ex)
{
LogUtil.error("询问是否进入过板模式出错:"+ex.ToString());
}finally
{
ModeCheckEnd();
WaitSelect = false;
}
}
}
}
......@@ -32,8 +32,13 @@ namespace TSA_V
private void btnPosition_Click(object sender, EventArgs e)
{
string msg = "";
if (WorkModeUtil.OnlyGuoBan)
{
msg = ResourceControl.GetString("GuobanMode", "操作失败,当前为过板模式");
}
//复位完成才能打开
if (TSAVBean.IsInSuddenDown)
else if (TSAVBean.IsInSuddenDown)
{
msg = ResourceControl.GetString(ResourceControl.DeviceInSuddenStop, "设备急停中");
}
......@@ -48,8 +53,10 @@ namespace TSA_V
if (!String.IsNullOrEmpty(msg))
{
MessageBox.Show(msg);
MessageBoxMidle.Show(this, msg, ResourceCulture.GetString("提示"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
//MessageBox.Show(msg);
//return;
}
FrmPusicanTest frmCom = new FrmPusicanTest();
this.Visible = false;
......
此文件的差异太大,无法显示。
......@@ -2553,4 +2553,19 @@
<data name="CreateNew" xml:space="preserve">
<value>新建</value>
</data>
<data name="FrmWork_lblPause_Text" xml:space="preserve">
<value>已暂停</value>
</data>
<data name="SelectModeMsg" xml:space="preserve">
<value>料塔加载失败,是否进入过板模式</value>
</data>
<data name="SelectModeMsgOK" xml:space="preserve">
<value>您已选择流水线过板模式</value>
</data>
<data name="加载AOI失败" xml:space="preserve">
<value>加载AOI失败</value>
</data>
<data name="GuobanMode" xml:space="preserve">
<value>操作失败,当前为过板模式</value>
</data>
</root>
\ No newline at end of file
......@@ -189,6 +189,7 @@
<Compile Include="FrmBoardPutCom.Designer.cs">
<DependentUpon>FrmBoardPutCom.cs</DependentUpon>
</Compile>
<Compile Include="messageBox\MessageBoxMidle.cs" />
<Compile Include="projector\FrmProjectorScreen.cs">
<SubType>Form</SubType>
</Compile>
......
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TSA_V
{
/***
* Title:"三维可视化" 项目
* 主题:【视图层】将MessageBox显示控制
* Description:
* 功能:
* 1、将MessageBox.Show显示在窗体中间
* Date:2020
* Version:1.2版本
* Author:Coffee
* Modify Recoder:
*/
public class MessageBoxMidle
{
private static IWin32Window _owner;
private static HookProc _hookProc;
private static IntPtr _hHook;
public static DialogResult Show(string text)
{
Initialize();
return MessageBox.Show(text);
}
public static DialogResult Show(string text, string caption)
{
Initialize();
return MessageBox.Show(text, caption);
}
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons)
{
Initialize();
return MessageBox.Show(text, caption, buttons);
}
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
{
Initialize();
return MessageBox.Show(text, caption, buttons, icon);
}
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton)
{
Initialize();
return MessageBox.Show(text, caption, buttons, icon, defButton);
}
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton, MessageBoxOptions options)
{
Initialize();
return MessageBox.Show(text, caption, buttons, icon, defButton, options);
}
public static DialogResult Show(IWin32Window owner, string text)
{
_owner = owner;
Initialize();
return MessageBox.Show(owner, text);
}
public static DialogResult Show(IWin32Window owner, string text, string caption)
{
_owner = owner;
Initialize();
return MessageBox.Show(owner, text, caption);
}
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons)
{
_owner = owner;
Initialize();
return MessageBox.Show(owner, text, caption, buttons);
}
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
{
_owner = owner;
Initialize();
return MessageBox.Show(owner, text, caption, buttons, icon);
}
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton)
{
_owner = owner;
Initialize();
return MessageBox.Show(owner, text, caption, buttons, icon, defButton);
}
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton, MessageBoxOptions options)
{
_owner = owner;
Initialize();
return MessageBox.Show(owner, text, caption, buttons, icon,
defButton, options);
}
public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);
public delegate void TimerProc(IntPtr hWnd, uint uMsg, UIntPtr nIDEvent, uint dwTime);
public const int WH_CALLWNDPROCRET = 12;
public enum CbtHookAction : int
{
HCBT_MOVESIZE = 0,
HCBT_MINMAX = 1,
HCBT_QS = 2,
HCBT_CREATEWND = 3,
HCBT_DESTROYWND = 4,
HCBT_ACTIVATE = 5,
HCBT_CLICKSKIPPED = 6,
HCBT_KEYSKIPPED = 7,
HCBT_SYSCOMMAND = 8,
HCBT_SETFOCUS = 9
}
[DllImport("user32.dll")]
private static extern bool GetWindowRect(IntPtr hWnd, ref Rectangle lpRect);
[DllImport("user32.dll")]
private static extern int MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
[DllImport("User32.dll")]
public static extern UIntPtr SetTimer(IntPtr hWnd, UIntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc);
[DllImport("User32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
public static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);
[DllImport("user32.dll")]
public static extern int UnhookWindowsHookEx(IntPtr idHook);
[DllImport("user32.dll")]
public static extern IntPtr CallNextHookEx(IntPtr idHook, int nCode, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
public static extern int GetWindowTextLength(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int maxLength);
[DllImport("user32.dll")]
public static extern int EndDialog(IntPtr hDlg, IntPtr nResult);
[StructLayout(LayoutKind.Sequential)]
public struct CWPRETSTRUCT
{
public IntPtr lResult;
public IntPtr lParam;
public IntPtr wParam;
public uint message;
public IntPtr hwnd;
};
static MessageBoxMidle()
{
_hookProc = new HookProc(MessageBoxHookProc);
_hHook = IntPtr.Zero;
}
private static void Initialize()
{
if (_hHook != IntPtr.Zero)
{
throw new NotSupportedException("multiple calls are not supported");
}
if (_owner != null)
{
_hHook = SetWindowsHookEx(WH_CALLWNDPROCRET, _hookProc, IntPtr.Zero, AppDomain.GetCurrentThreadId());
}
}
private static IntPtr MessageBoxHookProc(int nCode, IntPtr wParam, IntPtr lParam)
{
if (nCode < 0)
{
return CallNextHookEx(_hHook, nCode, wParam, lParam);
}
CWPRETSTRUCT msg = (CWPRETSTRUCT)Marshal.PtrToStructure(lParam, typeof(CWPRETSTRUCT));
IntPtr hook = _hHook;
if (msg.message == (int)CbtHookAction.HCBT_ACTIVATE)
{
try
{
CenterWindow(msg.hwnd);
}
finally
{
UnhookWindowsHookEx(_hHook);
_hHook = IntPtr.Zero;
}
}
return CallNextHookEx(hook, nCode, wParam, lParam);
}
private static void CenterWindow(IntPtr hChildWnd)
{
Rectangle recChild = new Rectangle(0, 0, 0, 0);
bool success = GetWindowRect(hChildWnd, ref recChild);
int width = recChild.Width - recChild.X;
int height = recChild.Height - recChild.Y;
Rectangle recParent = new Rectangle(0, 0, 0, 0);
success = GetWindowRect(_owner.Handle, ref recParent);
Point ptCenter = new Point(0, 0);
ptCenter.X = recParent.X + ((recParent.Width - recParent.X) / 2);
ptCenter.Y = recParent.Y + ((recParent.Height - recParent.Y) / 2);
Point ptStart = new Point(0, 0);
ptStart.X = (ptCenter.X - (width / 2));
ptStart.Y = (ptCenter.Y - (height / 2));
ptStart.X = (ptStart.X < 0) ? 0 : ptStart.X;
ptStart.Y = (ptStart.Y < 0) ? 0 : ptStart.Y;
int result = MoveWindow(hChildWnd, ptStart.X, ptStart.Y, width, height, false);
}
}//Class_end
}
......@@ -36,7 +36,7 @@ namespace TSA_V
txtCode.Focus();
SetScreen();
if (!IOBase.NoLine)
timer1.Start();
timer1.Start();
IsInitOk = true;
}
private void LoadCom()
......@@ -61,6 +61,20 @@ namespace TSA_V
{
chbWorkSingleStart.Checked = true;
}
modePro();
}
private void modePro()
{
if (WorkModeUtil.OnlyGuoBan)
{
chbOffLine.Checked = false;
chbWorkSingleStart.Checked = false;
chbGuoban.Checked = true;
LogUtil.info("默认进入过板模式,其他模式不可选");
}
}
int preIndex = -1;
private void cmbBoardList_SelectedIndexChanged(object sender, EventArgs e)
......@@ -326,6 +340,13 @@ namespace TSA_V
}
else
{
//如果是过板模式,直接取消
if (WorkModeUtil.OnlyGuoBan)
{
chbGuoban.Checked = true;
return;
}
chbWorkSingleStart.Visible = true;
chbOffLine.Visible = true;
}
......
......@@ -36,12 +36,14 @@
this.btnCodeTest = new System.Windows.Forms.Button();
this.btnWorkInfo = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.lblPause = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.btnUpdateAutoTime = new System.Windows.Forms.Button();
this.txtAuToTime = new System.Windows.Forms.TextBox();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.lblGuoBan = new System.Windows.Forms.Label();
this.btnTest = new System.Windows.Forms.Button();
this.btnStart = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
......@@ -160,6 +162,8 @@
//
// groupBox3
//
this.groupBox3.Controls.Add(this.lblGuoBan);
this.groupBox3.Controls.Add(this.lblPause);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Controls.Add(this.label7);
this.groupBox3.Controls.Add(this.btnUpdateAutoTime);
......@@ -174,11 +178,22 @@
this.groupBox3.TabStop = false;
this.groupBox3.Text = "工作方式";
//
// lblPause
//
this.lblPause.AutoSize = true;
this.lblPause.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblPause.Location = new System.Drawing.Point(179, 61);
this.lblPause.Name = "lblPause";
this.lblPause.Size = new System.Drawing.Size(74, 21);
this.lblPause.TabIndex = 284;
this.lblPause.Text = "暂停工作";
this.lblPause.Visible = false;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label8.Location = new System.Drawing.Point(508, 24);
this.label8.Location = new System.Drawing.Point(584, 21);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(23, 20);
this.label8.TabIndex = 283;
......@@ -187,7 +202,7 @@
// label7
//
this.label7.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label7.Location = new System.Drawing.Point(226, 24);
this.label7.Location = new System.Drawing.Point(302, 21);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(222, 21);
this.label7.TabIndex = 282;
......@@ -198,7 +213,7 @@
//
this.btnUpdateAutoTime.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnUpdateAutoTime.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnUpdateAutoTime.Location = new System.Drawing.Point(421, 55);
this.btnUpdateAutoTime.Location = new System.Drawing.Point(497, 52);
this.btnUpdateAutoTime.Name = "btnUpdateAutoTime";
this.btnUpdateAutoTime.Size = new System.Drawing.Size(71, 32);
this.btnUpdateAutoTime.TabIndex = 281;
......@@ -210,7 +225,7 @@
// txtAuToTime
//
this.txtAuToTime.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtAuToTime.Location = new System.Drawing.Point(453, 20);
this.txtAuToTime.Location = new System.Drawing.Point(529, 17);
this.txtAuToTime.MaxLength = 5;
this.txtAuToTime.Name = "txtAuToTime";
this.txtAuToTime.Size = new System.Drawing.Size(47, 29);
......@@ -242,6 +257,19 @@
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// lblGuoBan
//
this.lblGuoBan.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblGuoBan.Font = new System.Drawing.Font("微软雅黑", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblGuoBan.Location = new System.Drawing.Point(11, 17);
this.lblGuoBan.Name = "lblGuoBan";
this.lblGuoBan.Size = new System.Drawing.Size(618, 71);
this.lblGuoBan.TabIndex = 285;
this.lblGuoBan.Text = "过板模式";
this.lblGuoBan.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// btnTest
//
this.btnTest.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
......@@ -934,5 +962,7 @@
private System.Windows.Forms.Button btnWorkInfo;
private System.Windows.Forms.Button btnCodeTest;
private System.Windows.Forms.Button btnIo;
private System.Windows.Forms.Label lblPause;
private System.Windows.Forms.Label lblGuoBan;
}
}
\ No newline at end of file
......@@ -37,7 +37,25 @@ namespace TSA_V
if (board != null)
{
this.Text = "Neo Station:" + board.boardName;
string modeStr = "";
lblGuoBan.Visible = false;
if (TSAVBean.OnlyGuoBan)
{
modeStr = "-" + ResourceCulture.GetString("FrmBoardSelect_chbGuoban_Text", "过板模式");
lblGuoBan.Text = ResourceCulture.GetString("FrmBoardSelect_chbGuoban_Text", "过板模式");
lblGuoBan.Visible = true;
}
else if (TSAVBean.OpenOfflineMode)
{
modeStr = "-" + ResourceCulture.GetString("FrmBoardSelect_chbOffLine_Text", "离线工作模式");
}
else if (TSAVBean.WorkSingleStart)
{
modeStr = "-" + ResourceCulture.GetString("FrmBoardSelect_chbWorkSingleStart_Text", "工作区检测开始工作");
}
this.Text = "Neo Station:" + board.boardName + modeStr;
workSmtList = board.GetSmtList();
preIndex = -1;
smtPoint = new SMTPointInfo();
......@@ -63,11 +81,13 @@ namespace TSA_V
radioButton2.Checked = true;
AutoVisiable(true);
}
}
else
{
LogUtil.info("配置程序之后才能工作!");
this.Close();
}
if (TSAVBean.IsNeedAOI && !string.IsNullOrEmpty(board.AOIProName))
......@@ -76,7 +96,7 @@ namespace TSA_V
if (CurrProject == null)
{
LogUtil.info("没有读取到AOI,结束,IsNeedAOI=true!");
MessageBox.Show(ResourceCulture.GetString("加载AOI失败."));
MessageBox.Show(ResourceCulture.GetString("加载AOI失败"));
//this.Close();
}
}
......@@ -270,6 +290,12 @@ namespace TSA_V
{
ShowAOI();
}
lblPause.Visible = TSAVBean.WorkPause;
}
else
{
lblPause.Visible = false;
}
}
catch (Exception ex)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!