Author Topic: Messagelistbyvalue  (Read 1805 times)

m.hesler

  • Newbie
  • *
  • Posts: 13
    • View Profile
Messagelistbyvalue
« on: May 31, 2018, 04:52:15 AM »
Morning All

I don't know if this is already an open discussion, but I would like to use the messagelistbyvalue control and add in the "Speak Message" property that is in the messagedisplaybyvalue control.
I have looked in the code but cant find the reference to it.
Any help will be hugely appreciated.
Thanks

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Messagelistbyvalue
« Reply #1 on: May 31, 2018, 12:53:55 PM »
Do you mean  text to speech the content of the message?
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

m.hesler

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Messagelistbyvalue
« Reply #2 on: May 31, 2018, 01:35:40 PM »
Yes that's exactly what I want to do

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Messagelistbyvalue
« Reply #3 on: May 31, 2018, 03:02:07 PM »
I am not sure a property of "Speak Message" will do for you, but my thought is to use the value change event of the MessageDisplayByvalue, then do something along the line:
Code: [Select]
Dim synthesizer As SpeechSynthesizer = New SpeechSynthesizer()
            synthesizer.Volume = 100
        synthesizer.SelectVoice("Microsoft Anna")
        synthesizer.Rate = -2
        synthesizer.SpeakAsync("This is my message")
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

m.hesler

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Messagelistbyvalue
« Reply #4 on: May 31, 2018, 03:17:10 PM »
Thanks bachphi.

I'll give that a try. Didn't realise you could reference Microsoft voices.
Would this work with Cortana

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Messagelistbyvalue
« Reply #5 on: May 31, 2018, 05:56:30 PM »
I just did a quick test, it worked for me. Here is my code:
Code: [Select]
    Dim synthesizer As SpeechSynthesizer = New SpeechSynthesizer()
    Private Sub MessageDisplayByValue1_ValueChanged(sender As Object, e As Controls.ValueChangedEventArgs) Handles MessageDisplayByValue1.ValueChanged
        synthesizer.Volume = 100
        'synthesizer.SelectVoice("Microsoft Anna")
        'synthesizer.SelectVoice("Microsoft David Desktop")
        synthesizer.SelectVoice("Microsoft Zira Desktop")
        synthesizer.Rate = -2
        synthesizer.SpeakAsync(sender.Messages(e.NewValue).Message.ToString)
    End Sub
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

m.hesler

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Messagelistbyvalue
« Reply #6 on: June 01, 2018, 04:43:47 PM »
Thanks bachphi

I actually got it working. I did a bit of translation as I'm using C#.
Every time I referenced the voice type it threw back errors. So I just let it use my default voice in Windows.
Thanks for pointing me in the right direction though

Much Appreciated

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Messagelistbyvalue
« Reply #7 on: June 01, 2018, 06:48:04 PM »
You might consider posting your C# functional code just in case if somebody else might need it.

m.hesler

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Messagelistbyvalue
« Reply #8 on: June 02, 2018, 01:35:21 PM »
I Tried

using System.Speech.Synthesis;
using System.Speech;


   private void AlarmList_ValueChanged(object sender, MfgControl.AdvancedHMI.Controls.ValueChangedEventArgs e)
        {
            SpeechSynthesizer speechSynthesizer1 = new SpeechSynthesizer();
            speechSynthesizer1.Volume = 100;
            speechSynthesizer1.Rate = 2;
            speechSynthesizer1.SpeakAsync(AlarmList.Text);
        }





But she read EVERYTHING. Including the value, settings and time date stamp



so I opted for

  private void dataSubscriber21_DataChanged(object sender, MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs e)
        {
            string data = "";
            data = e.Values[0];
            string plcAddress = "";
            plcAddress = e.PlcAddress;

            //C3
            switch (plcAddress)
            {
                case "N170:30"://C3
                    switch (data)
                    {

                        case "1":
                            C3.ValueSelect2 = true;
                            C3.ValueSelect1 = false;
                            C3.ValueSelect3 = false;
                            break;
                        case "2":
                            C3.ValueSelect3 = true;
                            C3.ValueSelect1 = false;
                            C3.ValueSelect2 = false;
                            break;
                        case "5":
                            C3.ValueSelect1 = true;
                            C3.ValueSelect2 = false;
                            C3.ValueSelect3 = false;
                            AlarmList.Value = 1; SpeechSynthesizer speechSynthesizer1 = new SpeechSynthesizer();
                            speechSynthesizer1.Volume = 100;
                            speechSynthesizer1.Rate = 2;
                            speechSynthesizer1.SpeakAsync("Conveyor 3 Fault");
                            break;
                            default:
                            break;
                    }
                    break;




You may be able to help me further, as I have to type this code for every fault, and there's about 100

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Messagelistbyvalue
« Reply #9 on: June 02, 2018, 03:17:30 PM »
This is above my pay grade.

In your AdvancedHMIcs project, add a MessageDisplaybyValue, set your PLCAddress value and set up your texts in Messages.
Next click the Lightning icon, scroll down and double click ValueChanged event:

Code: [Select]
private SpeechSynthesizer synthesizer = new SpeechSynthesizer();
        private void messageDisplayByValue1_ValueChanged(object sender, MfgControl.AdvancedHMI.Controls.ValueChangedEventArgs e)
        {
            AdvancedHMIControls.MessageDisplayByValue msgDsp = (AdvancedHMIControls.MessageDisplayByValue)sender;
            int ee = (int)e.NewValue;
            synthesizer.Volume = 100;
            synthesizer.Rate = -2;
            synthesizer.SpeakAsync(msgDsp.Messages[ee].Message);
        }

Good luck!
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

m.hesler

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Messagelistbyvalue
« Reply #10 on: June 02, 2018, 04:36:45 PM »
The message display by value already has the "Speak Message" Property.
So there is no need for this extra code.
My dilemma is, I have a large range of messages spanning across multiple PLC addresses. I want to list them until the operator decides to clear the messages. I have this working already, but for that extra touch would like Cortana or any other built in voice to speak them.
The code I wrote works, however has its faults. If multiple faults occur at once, she speaks them all simultaneously. I would like her to read each text line..... one at a time.

m.hesler

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Messagelistbyvalue
« Reply #11 on: June 02, 2018, 04:48:37 PM »
Disregard my last post

bachphi you are an absolute star. If you were in front of me now I swear I would kiss you.
Your code worked, slightly tweaked, but it worked.
Thank you so much.

private SpeechSynthesizer synthesizer = new SpeechSynthesizer();
        private void AlarmList_ValueChanged(object sender, MfgControl.AdvancedHMI.Controls.ValueChangedEventArgs e)
        {
            AdvancedHMIControls.MessageListByValue msgDsp = (AdvancedHMIControls.MessageListByValue)sender;
            int ee = (int)e.NewValue;
            synthesizer.Volume = 100;
            synthesizer.Rate = -2;
            synthesizer.SpeakAsync(msgDsp.Messages[ee].Message);
        }

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Messagelistbyvalue
« Reply #12 on: June 02, 2018, 06:05:11 PM »
I did not even notice that "SpeakMessage", lol.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================