/// <summary> /// 播放挂烟语音 /// </summary> public void PlayHangSound(object o) { //try //{ // SoundPlayer player = new SoundPlayer(); // player.SoundLocation = Application.StartupPath + "\\Sound\\挂烟.wav"; // player.Load(); // player.Play(); //} //catch //{ } LineBoxStatus lineboxstatus = (LineBoxStatus)o; int lineboxidint = Convert.ToInt32(lineboxstatus.lineboxcode); if (lineboxidint > 0) { int remainder = lineboxidint % 10; lineboxstatus.lineboxcode = (lineboxidint - remainder) / 10; SoundPlayer player; try { if (lineboxstatus.lineboxcode > 0) { player = new SoundPlayer(); player.SoundLocation = Application.StartupPath + "\\Sound\\" + lineboxstatus.lineboxcode + ".wav"; player.Load(); player.Play(); Thread.Sleep(700); player = new SoundPlayer(); player.SoundLocation = Application.StartupPath + "\\Sound\\10.wav"; player.Load(); player.Play(); Thread.Sleep(700); } if (remainder > 0) { player = new SoundPlayer(); player.SoundLocation = Application.StartupPath + "\\Sound\\" + remainder + ".wav"; player.Load(); player.Play(); Thread.Sleep(700); } if (lineboxstatus.status == 1) { player = new SoundPlayer(); player.SoundLocation = Application.StartupPath + "\\Sound\\挂烟.wav"; player.Load(); player.Play(); } } catch { } } }
/// <summary> /// 获取子线挂烟的状态 /// </summary> /// <returns></returns> public LineBoxStatus SubLineStatus() { LineBoxStatus lineboxstatus = null; HangCigLineBox hangCigLineBox = new HangCigLineBox();//挂烟的PLC地址 foreach (KeyValuePair <int, string> keyValuePair in hangCigLineBox) { PlcValue readValue = new PlcValue(); string a = keyValuePair.Value; readValue = plc.GetPlcValue(a); if (Convert.ToBoolean(readValue.Value)) { lineboxstatus = new LineBoxStatus(); lineboxstatus.lineboxcode = keyValuePair.Key; lineboxstatus.status = 1; return(lineboxstatus); } } return(null); }
/// <summary> /// 播放缺烟及卡烟语音 /// </summary> /// <param name="o"></param> private void PlayBlockSound(object o) { LineBoxStatus lineboxstatus = (LineBoxStatus)o; int lineboxidint = Convert.ToInt32(lineboxstatus.lineboxcode); if (lineboxidint > 0) { int remainder = lineboxidint % 10; lineboxstatus.lineboxcode = (lineboxidint - remainder) / 10; SoundPlayer player; try { if (lineboxstatus.lineboxcode > 0) { player = new SoundPlayer(); player.SoundLocation = Application.StartupPath + "\\Sound\\" + lineboxstatus.lineboxcode + ".wav"; player.Load(); player.Play(); Thread.Sleep(700); player = new SoundPlayer(); player.SoundLocation = Application.StartupPath + "\\Sound\\10.wav"; player.Load(); player.Play(); Thread.Sleep(700); } if (remainder > 0) { player = new SoundPlayer(); player.SoundLocation = Application.StartupPath + "\\Sound\\" + remainder + ".wav"; player.Load(); player.Play(); Thread.Sleep(700); } if (lineboxstatus.status == 8) { player = new SoundPlayer(); player.SoundLocation = Application.StartupPath + "\\Sound\\卡烟.wav"; player.Load(); player.Play(); } if (lineboxstatus.status == 4) { player = new SoundPlayer(); player.SoundLocation = Application.StartupPath + "\\Sound\\缺烟.wav"; player.Load(); player.Play(); } if (lineboxstatus.status == 16) { player = new SoundPlayer(); player.SoundLocation = Application.StartupPath + "\\Sound\\挂烟.wav"; player.Load(); player.Play(); } } catch { } } }
/// <summary> /// 获取烟仓打烟的异常状态 /// </summary> /// <returns></returns> public LineBoxStatus GetLineBoxException() { LineBoxStatus lineboxstatus = null; for (int i = 3; i <= 181; i = i + 2) { PlcValue readValue = new PlcValue(); string a = "S7:[S7 connection_1]DB4,B" + i.ToString(); readValue = plc.GetPlcValue(a); //只取异常值的低四位进行判断 int value = Convert.ToInt32((Convert.ToByte(readValue.Value) & 0xf)); if (value == 8) { lineboxstatus = new LineBoxStatus(); //plc中有挡板占用85仓的地址所以85-89仓地址需要向前挪动一个 if (i >= 173) { lineboxstatus.lineboxcode = ((i - 1) / 2) - 1; } else if (i != 171) { lineboxstatus.lineboxcode = (i - 1) / 2; } lineboxstatus.status = 8; lineboxstatus.putnum = GetTaskOutNum(lineboxstatus.lineboxcode); return(lineboxstatus); } if (value == 4) { lineboxstatus = new LineBoxStatus(); if (i >= 173) { lineboxstatus.lineboxcode = ((i - 1) / 2) - 1; } else if (i != 171) { lineboxstatus.lineboxcode = (i - 1) / 2; } lineboxstatus.status = 4; lineboxstatus.putnum = GetTaskOutNum(lineboxstatus.lineboxcode); return(lineboxstatus); } //只取异常值的低四位进行判断 value = Convert.ToInt32((Convert.ToByte(readValue.Value) & 0x10)); if (value == 16) { lineboxstatus = new LineBoxStatus(); if (i >= 173) { lineboxstatus.lineboxcode = ((i - 1) / 2) - 1; } else if (i != 171) { lineboxstatus.lineboxcode = (i - 1) / 2; } lineboxstatus.status = 16; lineboxstatus.putnum = GetTaskOutNum(lineboxstatus.lineboxcode); return(lineboxstatus); } } return(lineboxstatus); }