Beispiel #1
0
 private void timerTick(object sender, EventArgs e)
 {
     udpSender.SendMessage(this.cpLimits);
     udpSender.SendMessage(this.cpBus);
     udpSender.SendMessage(this.cpVelocity);
     udpSender.SendMessage(this.cpIVector);
     udpSender.SendMessage(this.cpTemp1);
 }
Beispiel #2
0
 private void OnUdpMessageReceived(UdpReceiver sender, UdpMessageReceivedEventArgs e)
 {
     if (e.Content == "ml.festival.defectively.scan")
     {
         UdpSender.SendMessage("ml.festival.defectively.scanResponse:42000", e.RemoteEndPoint.Address.ToString(), 52001);
     }
 }
        private async void startReplaying()
        {
            string line;

            string    timeStampIdentifier = "DateTime:";
            int       timeStampIndex;
            Stopwatch stopwatch = new Stopwatch();
            long      startTime = 0;
            long      timeStamp;
            int       timeDiff;
            string    rawDataIdentifier = "Data:";
            int       rawDataStrIndex;
            string    rawDataStr;

            stopwatch.Start();

            while (this.isReplaying && (line = ioStreamReader.ReadLine()) != null)
            {
                timeStampIndex = line.IndexOf(timeStampIdentifier) + timeStampIdentifier.Length;
                timeStamp      = Convert.ToInt64(line.Substring(timeStampIndex, 13));

                if (startTime == 0)
                {
                    startTime = timeStamp;
                }

                timeDiff = (int)(timeStamp - startTime - stopwatch.ElapsedMilliseconds);
                await Task.Delay(timeDiff);

                rawDataStrIndex = line.IndexOf(rawDataIdentifier) + rawDataIdentifier.Length;
                rawDataStr      = line.Substring(rawDataStrIndex, 60);
                udpSender.SendMessage(new CanPacket(rawDataStr));
            }

            this.ioStreamReader.Close();
            this.ioStream.Close();

            this.btnStartStop.Enabled = true;
            this.btnStop.Enabled      = false;
        }
Beispiel #4
0
 //NOTE: 本当はprivate protectedがしたいが、そのためだけにC# 7.2使うのもアレなのでinternalでごまかします
 internal void SendMessage(UdpMessage message)
 => _sender.SendMessage(message);