public WarningViewModel(ConfigModel CM) { accessin = new Access(); for (int i = 0; i < CM.LTM.Count; i++) { TrackWarningViewModel twvm = new TrackWarningViewModel(); twvm.TrackNum = int.Parse(CM.LTM[i].TrackID); TWVM.Add(twvm); } Thread thread = new Thread(new ThreadStart(() => { //string Msg = String.Empty; Notification notification; while (true) { if (msgQueue != null && msgQueue.Count != 0) { notification = msgQueue.Dequeue(); } else { WarningText = "hide"; continue; } SpeechSynthesizer synth = new SpeechSynthesizer(); if (PLCControler.Instence.MWVM.CanSpeek) { PLCControler.Instence.SetChannel(PLCControler.Instence.MWVM.CM.SpeekAddress); } WarningDataTime = notification.DateTime; WarningText = notification.TrackNumber.ToString() + notification.NotifyInfo; IsWarning = notification.IsWarning; //synth.Speak(notification.TrackNumber.ToString() + notification.NotifyInfo); synth.Speak(notification.TrackNumber.ToString() + notification.NotifyInfo); PLCControler.Instence.ReSetChannel(PLCControler.Instence.MWVM.CM.SpeekAddress); } })); thread.IsBackground = true; thread.Start(); }
public WarningViewModel(ConfigModel CM) { accessin = new Access(); for (int i = 0; i < CM.LTM.Count; i++) { TrackWarningViewModel twvm = new TrackWarningViewModel(); twvm.TrackNum = int.Parse(CM.LTM[i].TrackID); TWVM.Add(twvm); } Thread thread = new Thread(new ThreadStart(() => { string Msg = String.Empty; while (true) { if (msgQueue != null && msgQueue.Count != 0) { Msg = msgQueue.Dequeue(); } else { continue; } SpeechSynthesizer synth = new SpeechSynthesizer(); if (PLCControler.Instence.MWVM.CanSpeek) { PLCControler.Instence.SetChannel(PLCControler.Instence.MWVM.CM.SpeekAddress); } synth.Speak(Msg); synth.Speak(Msg); PLCControler.Instence.ReSetChannel(PLCControler.Instence.MWVM.CM.SpeekAddress); Thread.Sleep(500); } })); thread.IsBackground = true; thread.Start(); }