|
|
|
|
using Rs.Framework;
|
|
|
|
|
using Rs.MotionPlat.Entitys;
|
|
|
|
|
using Rs.MotionPlat.Flow;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Rs.MotionPlat.Commom
|
|
|
|
|
{
|
|
|
|
|
public static class Msgbox
|
|
|
|
|
{
|
|
|
|
|
static Dictionary<int, Form> boxList = new Dictionary<int, Form>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示模态弹框
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static EButtonType ShowTipDialog(EButtonType buttons,string content,string title="",bool warning=false)
|
|
|
|
|
{
|
|
|
|
|
if (warning)
|
|
|
|
|
{
|
|
|
|
|
BuzzerManager.Instance.On();
|
|
|
|
|
}
|
|
|
|
|
LogHelper.Debug($"ShowTipDialog({buttons},{content}, {title}, {warning})");
|
|
|
|
|
EButtonType ret = EButtonType.None;
|
|
|
|
|
FrmDialog fd = new FrmDialog();
|
|
|
|
|
ret = fd.ShowMessage(buttons, content, "",title);
|
|
|
|
|
if(warning)
|
|
|
|
|
{
|
|
|
|
|
BuzzerManager.Instance.Off();
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示模态弹框
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="alarmInfo"></param>
|
|
|
|
|
/// <param name="buttons"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static EButtonType ShowDialog(AlarmEntity alarmInfo, EButtonType buttons, bool warning = false)
|
|
|
|
|
{
|
|
|
|
|
DevLog.EventTracker("ERROR START", alarmInfo.AlarmID, alarmInfo.EventTrackerDesc, alarmInfo.EN);
|
|
|
|
|
//if (!GlobalVar.DisableBuzzer)
|
|
|
|
|
//{
|
|
|
|
|
// Ops.On("蜂鸣器");
|
|
|
|
|
//}
|
|
|
|
|
if(warning)
|
|
|
|
|
{
|
|
|
|
|
BuzzerManager.Instance.On();
|
|
|
|
|
LightManger.Instance.SetStatus(ELightStatus.Red);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string logInfo = $"{alarmInfo.CN}";
|
|
|
|
|
LogHelper.Debug($"ShowDialog({logInfo},{buttons}, {warning})");
|
|
|
|
|
// LogHelper.Debug(logInfo);
|
|
|
|
|
EButtonType ret = EButtonType.None;
|
|
|
|
|
if (!boxList.ContainsKey(alarmInfo.AlarmID))
|
|
|
|
|
{
|
|
|
|
|
FrmDialog fd = new FrmDialog();
|
|
|
|
|
boxList.Add(alarmInfo.AlarmID, fd);
|
|
|
|
|
ret = fd.ShowMessage(buttons, alarmInfo.CN,alarmInfo.EN);
|
|
|
|
|
boxList.Remove(alarmInfo.AlarmID);
|
|
|
|
|
//if (!GlobalVar.DisableBuzzer)
|
|
|
|
|
//{
|
|
|
|
|
// Ops.Off("蜂鸣器");
|
|
|
|
|
//}
|
|
|
|
|
//if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop)
|
|
|
|
|
//{
|
|
|
|
|
// LightManger.Instance.SetStatus(ELightStatus.Yellow);
|
|
|
|
|
//}
|
|
|
|
|
//else if (MachineManage.Instance.MachineStatus == EMachineStatus.Working)
|
|
|
|
|
//{
|
|
|
|
|
// LightManger.Instance.SetStatus(ELightStatus.Green);
|
|
|
|
|
//}
|
|
|
|
|
DevLog.EventTracker("ERROR END", alarmInfo.AlarmID, alarmInfo.EventTrackerDesc, alarmInfo.EN);
|
|
|
|
|
if (warning)
|
|
|
|
|
{
|
|
|
|
|
BuzzerManager.Instance.Off();
|
|
|
|
|
LightManger.Instance.SetStatus(ELightStatus.Green);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示非模态弹框
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="content"></param>
|
|
|
|
|
/// <param name="buttons"></param>
|
|
|
|
|
public static void Show(string content ,EButtonType buttons)
|
|
|
|
|
{
|
|
|
|
|
FrmDialog fd = new FrmDialog();
|
|
|
|
|
fd.ShowMessage(buttons, content, "", "", false);
|
|
|
|
|
Application.Run(fd); // 启动窗体的消息循环
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示非模态对话框
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="alarmInfo"></param>
|
|
|
|
|
/// <param name="buttons"></param>
|
|
|
|
|
public static void Show(AlarmEntity alarmInfo, EButtonType buttons)
|
|
|
|
|
{
|
|
|
|
|
if (!boxList.ContainsKey(alarmInfo.AlarmID))
|
|
|
|
|
{
|
|
|
|
|
FrmDialog fd = new FrmDialog();
|
|
|
|
|
boxList.Add(alarmInfo.AlarmID, fd);
|
|
|
|
|
fd.ShowMessage(buttons, alarmInfo.CN, alarmInfo.EN, "", false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭弹框
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="msgID"></param>
|
|
|
|
|
public static void CloseBox(int msgID)
|
|
|
|
|
{
|
|
|
|
|
if(boxList.ContainsKey(msgID))
|
|
|
|
|
{
|
|
|
|
|
boxList[msgID].Invoke(new Action(() => {
|
|
|
|
|
boxList[msgID].Close();
|
|
|
|
|
boxList.Remove(msgID);
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|