Пример #1
0
 private void CheckSendMessage()
 {
     if (cb_Choice.Text == "Text")
     {
         Log.MessageSent("---TEXT---");
         Message = new SomeIPMessage(Convert.ToUInt32(SomeIPMessage.SOMEIP_MessageID.TEXT), 0xABAB5555,
                                     Convert.ToByte(SomeIPMessage.SOMEIP_MessageType.REQUEST), Convert.ToByte(SomeIPMessage.SOMEIP_ReturnCode.E_OK));
         byte[] temp = Encoding.ASCII.GetBytes(textBox1.Text);
         Message.Payload = temp;
         PlayBtn.Enabled = false;
     }
     else if (cb_Choice.Text == "Picture")
     {
         Log.MessageSent("---PICTURE---");
         Message = new SomeIPMessage(Convert.ToUInt32(SomeIPMessage.SOMEIP_MessageID.PICTURE), 0xABAB5555,
                                     Convert.ToByte(SomeIPMessage.SOMEIP_MessageType.REQUEST), Convert.ToByte(SomeIPMessage.SOMEIP_ReturnCode.E_OK));
         prepareImageMessage(pictureBox1.Image);
         PlayBtn.Enabled = false;
     }
     else if (cb_Choice.Text == "Sound")
     {
         pictureBox1.Image = null;
         Log.MessageSent("---SOUND---");
         Message = new SomeIPMessage(Convert.ToUInt32(SomeIPMessage.SOMEIP_MessageID.SOUND), 0xABAB5555,
                                     Convert.ToByte(SomeIPMessage.SOMEIP_MessageType.REQUEST), Convert.ToByte(SomeIPMessage.SOMEIP_ReturnCode.E_OK));
         prepareSoundMessage();
     }
     else
     {
         MessageBox.Show("You have not selected what to send!!");
     }
 }
Пример #2
0
        public void checkReceiveMessage(byte[] udpPayload)
        {
            SomeIPMessage temp = new SomeIPMessage(udpPayload);

            if (temp.MessageID == Convert.ToUInt32(SomeIPMessage.SOMEIP_MessageID.PICTURE))
            {
                imgMessage = temp;
                pictureBox1.Refresh(); //da ne moram praviti metodu ShowMessage
            }

            else
            {
                //text je ili vec nesto drugo
            }
        }
Пример #3
0
        public void checkReceiveMessage(byte[] udpPayload)
        {
            SomeIPMessage temp = new SomeIPMessage(udpPayload);

            Log.MessageSent("RECEIVING...");
            Log.MessageSent("MessageID:  " + temp.MessageID.ToString());
            Log.MessageSent("RequestID:  " + temp.RequestID.ToString());
            Log.MessageSent("Lenght:  " + temp.GetLength.ToString());

            if (temp.MessageID == Convert.ToUInt32(SomeIPMessage.SOMEIP_MessageID.PICTURE))
            {
                ImageConverter converter = new ImageConverter();
                pictureBox1.Image = (Image)converter.ConvertFrom(temp.Payload);
                Log.MessageSent("---PICTURE---");
                PlayBtn.Enabled = false;
                textBox1.Text   = null;

                pictureBox1.Refresh();
            }
            else if (temp.MessageID == Convert.ToUInt32(SomeIPMessage.SOMEIP_MessageID.TEXT))
            {
                Log.MessageSent("---TEXT---");
                textBox1.Text     = System.Text.Encoding.Default.GetString(temp.Payload);
                PlayBtn.Enabled   = false;
                pictureBox1.Image = null;
            }

            else if (temp.MessageID == Convert.ToUInt32(SomeIPMessage.SOMEIP_MessageID.SOUND))
            {
                Log.MessageSent("---SOUND---");
                File.WriteAllBytes(@"C:\Temp\WriteSound\Temp.wav", temp.Payload);
                textBox1.Text     = @"C:\Temp\WriteSound\Temp.wav";
                PlayBtn.Enabled   = true;
                pictureBox1.Image = null;
            }
            else
            {
                SomeIPServiceDiscoveryMessage SDtemp = new SomeIPServiceDiscoveryMessage(udpPayload);
                uint a = SDtemp.GetLength - 3; //pomaknuti računanje payloada ili oduzeti sve sa options da znamo koliko ima. moze i tako pa pomaknuti
                //kod uzimanja entrya
            }
            WriteLog();
        }