Commit dc0d39bb LN

报警增加声音,投影闪烁。

1 个父辈 3714dd55
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
<Compile Include="deviceLibrary\IO\IOBase.cs" /> <Compile Include="deviceLibrary\IO\IOBase.cs" />
<Compile Include="deviceLibrary\IO\NanjingSDotIO.cs" /> <Compile Include="deviceLibrary\IO\NanjingSDotIO.cs" />
<Compile Include="deviceLibrary\IO\NiRenIO.cs" /> <Compile Include="deviceLibrary\IO\NiRenIO.cs" />
<Compile Include="manager\AlarmProcess.cs" />
<Compile Include="manager\LedManager.cs" /> <Compile Include="manager\LedManager.cs" />
<Compile Include="manager\LineWidthManager.cs" /> <Compile Include="manager\LineWidthManager.cs" />
<Compile Include="manager\ResourceControl.cs" /> <Compile Include="manager\ResourceControl.cs" />
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TSA_V.Common;
using TSA_V.DeviceLibrary;
namespace TSA_V
{
public class AlarmProcess
{
private static System.Timers.Timer proTimer = null;
private static bool InPlay = false;
private static string soundFileName = @"\sound\alarm.wav";
// 创建一个新的 SoundPlayer 实例
private static SoundPlayer player = new SoundPlayer();
public static void Init()
{
if (proTimer == null)
{
proTimer = new System.Timers.Timer();
proTimer.AutoReset = true;
proTimer.Enabled = false;
proTimer.Interval = 1000;
proTimer.Elapsed += ProTimer_Elapsed;
proTimer.Start();
}
}
public static bool IsAlarm(out string msg)
{
msg = "";
if (!String.IsNullOrEmpty(TSAVBean.WarnMsg))
{
msg = TSAVBean.WarnMsg;
return true;
}
else if(TSAVBean.NoAirAlarm)
{
msg = "未检测到气压信号";
return true;
}
return false;
}
private static void ProTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (AlarmProcess.IsAlarm(out string msg))
{
if (InPlay)
{
}
else
{
StartPlay();
}
}
else
{
if (InPlay)
{
StopPlay();
}
}
}
public static void StartPlay( )
{
// 音频文件路径
string audioFilePath = Application.StartupPath+ soundFileName;
LogUtil.info("开始播放:" + audioFilePath);
try
{
if(File.Exists(audioFilePath))
{
// 设置要播放的音频文件路径
player.SoundLocation = audioFilePath;
// 播放音频
player.PlayLooping();
}
else
{
LogUtil.error("未找到音频文件:" + audioFilePath);
}
InPlay = true;
}
catch (Exception ex)
{
LogUtil.error("发生错误:" + ex.Message);
}
}
public static void StopPlay()
{
InPlay = false;
LogUtil.info("停止播放音频");
// 停止播放音频
player.Stop();
}
}
}
...@@ -41,6 +41,7 @@ namespace TSA_V.DeviceLibrary ...@@ -41,6 +41,7 @@ namespace TSA_V.DeviceLibrary
} }
public static bool IsInPut = false; public static bool IsInPut = false;
public static bool IsInSuddenDown = false; public static bool IsInSuddenDown = false;
public static bool NoAirAlarm = false;//无气压报警
/// <summary> /// <summary>
/// 工作模式,0=脚踏模式,1=自动模式 /// 工作模式,0=脚踏模式,1=自动模式
...@@ -133,7 +134,7 @@ namespace TSA_V.DeviceLibrary ...@@ -133,7 +134,7 @@ namespace TSA_V.DeviceLibrary
//return ResourceControl.GetString(ResourceControl.InitXFail, "振镜初始化失败"); //return ResourceControl.GetString(ResourceControl.InitXFail, "振镜初始化失败");
} }
}); });
AlarmProcess.Init();
return ""; return "";
} }
...@@ -155,6 +156,7 @@ namespace TSA_V.DeviceLibrary ...@@ -155,6 +156,7 @@ namespace TSA_V.DeviceLibrary
{ {
LogUtil.error(Name + " StartRun 失败:Can协议连接失败:" + msg); LogUtil.error(Name + " StartRun 失败:Can协议连接失败:" + msg);
startRunMsg = ResourceControl.GetString(ResourceControl.CanConnectFail, "Can协议连接失败"); startRunMsg = ResourceControl.GetString(ResourceControl.CanConnectFail, "Can协议连接失败");
warnMsg = startRunMsg;
return startRunMsg; return startRunMsg;
} }
else else
...@@ -170,6 +172,7 @@ namespace TSA_V.DeviceLibrary ...@@ -170,6 +172,7 @@ namespace TSA_V.DeviceLibrary
{ {
LogUtil.info(Name + " StartRun 失败:IO模块连接失败"); LogUtil.info(Name + " StartRun 失败:IO模块连接失败");
startRunMsg = ResourceControl.GetString(ResourceControl.IOConnectError, "IO模块连接失败"); startRunMsg = ResourceControl.GetString(ResourceControl.IOConnectError, "IO模块连接失败");
warnMsg = startRunMsg;
return startRunMsg; return startRunMsg;
} }
StartReset(); StartReset();
...@@ -602,7 +605,7 @@ namespace TSA_V.DeviceLibrary ...@@ -602,7 +605,7 @@ namespace TSA_V.DeviceLibrary
} }
} }
} }
if (!IsInSuddenDown) if (!IsInSuddenDown)
{ {
if (Status.Equals(TSAVStatus.Reset)) if (Status.Equals(TSAVStatus.Reset))
...@@ -628,6 +631,8 @@ namespace TSA_V.DeviceLibrary ...@@ -628,6 +631,8 @@ namespace TSA_V.DeviceLibrary
} }
CheckPusicanAlarm(); CheckPusicanAlarm();
AirCheckPro();
} }
// IOManager.IOMove(IOManager.Warmer_Work, IO_VALUE.LOW); // IOManager.IOMove(IOManager.Warmer_Work, IO_VALUE.LOW);
} }
...@@ -637,6 +642,27 @@ namespace TSA_V.DeviceLibrary ...@@ -637,6 +642,27 @@ namespace TSA_V.DeviceLibrary
} }
IsProcess = false; IsProcess = false;
} }
private static void AirCheckPro()
{
if (IOManager.IOValue(IOManager.AirCheck_Single).Equals(IO_VALUE.LOW))
{
if (!NoAirAlarm)
{
NoAirAlarm = true;
LogUtil.error("未检测到气压信号");
}
}
else
{
if (NoAirAlarm)
{
NoAirAlarm = false;
LogUtil.error("自动解除:未检测到气压信号");
}
}
}
private static void WorkProcess() private static void WorkProcess()
{ {
if (Work.IsWaitMove) if (Work.IsWaitMove)
......
...@@ -58,6 +58,7 @@ namespace TSA_V ...@@ -58,6 +58,7 @@ namespace TSA_V
public static Image Menu_US_光学检测; public static Image Menu_US_光学检测;
public static Image Menu_US_补料; public static Image Menu_US_补料;
public static Image imgAlarm;
/// <summary> /// <summary>
/// 是否已经初始化过了 /// 是否已经初始化过了
/// </summary> /// </summary>
...@@ -128,6 +129,8 @@ namespace TSA_V ...@@ -128,6 +129,8 @@ namespace TSA_V
Main_US_历史记录 = GetImage(Application.StartupPath + "\\image\\US\\History.png"); Main_US_历史记录 = GetImage(Application.StartupPath + "\\image\\US\\History.png");
Menu_US_光学检测 = GetImage(Application.StartupPath+ "\\image\\US\\AOI.png"); Menu_US_光学检测 = GetImage(Application.StartupPath+ "\\image\\US\\AOI.png");
Menu_US_补料 = GetImage(Application.StartupPath+ "\\image\\US\\Replenish.png"); Menu_US_补料 = GetImage(Application.StartupPath+ "\\image\\US\\Replenish.png");
imgAlarm = Image.FromFile(Application.StartupPath + "\\image\\alarm.gif");
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -469,6 +469,15 @@ ...@@ -469,6 +469,15 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="image\backImage.png" /> <None Include="image\backImage.png" />
<Content Include="image\alarm2.gif">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="sound\alarm.wav">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="image\alarm.gif">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="image\CN\MOSCOT.jpg"> <Content Include="image\CN\MOSCOT.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
......
...@@ -28,19 +28,43 @@ ...@@ -28,19 +28,43 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.lblAlarm = new System.Windows.Forms.Label();
this.colorDialog1 = new System.Windows.Forms.ColorDialog(); this.colorDialog1 = new System.Windows.Forms.ColorDialog();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.panel1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// panel1 // panel1
// //
this.panel1.BackColor = System.Drawing.Color.Black; this.panel1.BackColor = System.Drawing.Color.Black;
this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel1.Controls.Add(this.lblAlarm);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(800, 633); this.panel1.Size = new System.Drawing.Size(800, 633);
this.panel1.TabIndex = 0; this.panel1.TabIndex = 0;
// //
// lblAlarm
//
this.lblAlarm.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblAlarm.Font = new System.Drawing.Font("微软雅黑", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblAlarm.ForeColor = System.Drawing.Color.Red;
this.lblAlarm.Location = new System.Drawing.Point(8, 4);
this.lblAlarm.Name = "lblAlarm";
this.lblAlarm.Size = new System.Drawing.Size(784, 93);
this.lblAlarm.TabIndex = 0;
this.lblAlarm.Text = "label1";
this.lblAlarm.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// timer1
//
this.timer1.Interval = 600;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// FrmProjectorScreen // FrmProjectorScreen
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
...@@ -55,6 +79,7 @@ ...@@ -55,6 +79,7 @@
this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.FrmScreenTest_Load); this.Load += new System.EventHandler(this.FrmScreenTest_Load);
this.Shown += new System.EventHandler(this.FrmScreenTest_Shown); this.Shown += new System.EventHandler(this.FrmScreenTest_Shown);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
...@@ -63,5 +88,7 @@ ...@@ -63,5 +88,7 @@
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.ColorDialog colorDialog1; private System.Windows.Forms.ColorDialog colorDialog1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label lblAlarm;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -33,7 +33,16 @@ namespace TSA_V ...@@ -33,7 +33,16 @@ namespace TSA_V
private void FrmScreenTest_Load(object sender, EventArgs e) private void FrmScreenTest_Load(object sender, EventArgs e)
{ {
this.Text = "显示测试_" + ScreenIndex; this.Text = "显示测试_" + ScreenIndex;
this.StartPosition = FormStartPosition.Manual; this.StartPosition = FormStartPosition.Manual;
timer1.Start();
if (panel1.BackgroundImage != null)
{
panel1.BackgroundImage = null;
}
if (lblAlarm.Visible)
{
lblAlarm.Visible = false;
}
} }
public bool CloseShowName=false; public bool CloseShowName=false;
public bool ShowForm() public bool ShowForm()
...@@ -340,6 +349,36 @@ namespace TSA_V ...@@ -340,6 +349,36 @@ namespace TSA_V
} }
g.Dispose(); g.Dispose();
} }
private void timer1_Tick(object sender, EventArgs e)
{
if (AlarmProcess.IsAlarm(out string msg))
{
if(panel1.BackgroundImage != null)
{
panel1.BackgroundImage = null;
}
else
{
panel1.BackgroundImage = ImageManager.imgAlarm;
panel1.BackgroundImageLayout = ImageLayout.Zoom;
lblAlarm.Text = msg;
lblAlarm.Visible = true;
}
}
else
{
if (panel1.BackgroundImage != null)
{
panel1.BackgroundImage = null;
}
if(lblAlarm.Visible)
{
lblAlarm.Visible = false;
}
}
}
} }
public class PointType_Define public class PointType_Define
......
...@@ -120,6 +120,9 @@ ...@@ -120,6 +120,9 @@
<metadata name="colorDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="colorDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>144, 17</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
......
此文件类型无法预览
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!