Ejemplo n.º 1
0
        private void checkBoxGpsStartStop_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxGpsStartStop.Checked)
            {
                checkBoxGpsStartStop.Text = "Stop";

                GpsSimulationInfo info = new GpsSimulationInfo();
                info.Interval = int.Parse(textBoxGpsInterval.Text) * 1000; // seconds
                info.Type     = comboBoxGpsType.SelectedIndex;

                SmartMonitorSystem.Instance.StartGpsSimulation(info);
            }
            else
            {
                SmartMonitorSystem.Instance.StopGpsSimulation();
                checkBoxGpsStartStop.Text = "Start";
            }
        }
Ejemplo n.º 2
0
        public void StartGpsSimulation(GpsSimulationInfo info)
        {
            if (info == null)
            {
                return;
            }

            GpsInfo         = info;
            GpsInfo.Running = true;

            Task.Run(async() =>
            {
                int counter = 0;
                while (GpsInfo.Running)
                {
                    GpsMessage msg = new GpsMessage();
                    msg.Id         = msgcounter.ToString();
                    msg.DeviceId   = deviceId;
                    if (counter < GpsInfo.Country.Count)
                    {
                        msg.Latitude  = GpsInfo.Country[counter].Latitude;
                        msg.Longitude = GpsInfo.Country[counter].Longitude;
                        msgSendQueue.Enqueue(msg);
                        counter++;
                    }
                    else
                    {
                        counter = 0;
                    }

                    await Task.Delay(GpsInfo.Interval);

                    msgcounter++;
                }
            });
        }