示例#1
0
        private void Reconfig_Click(object sender, EventArgs e)
        {
            lidar.StopScan();
            var result = new Redefine().ShowDialog();

            if (result == DialogResult.OK)
            {
                lidar.PauseScan();
                config.LoadConfiguration();
                DistLabelSetup();
                // Reconfig lidar settings
                string lidarIP   = config.getLidarIp();
                string lidarPort = config.getLidarPort();
                if (lidarIP != Lidar.IP.ToString() || Lidar.PORT != Convert.ToInt32(lidarPort))
                {
                    lidar.SetIp(lidarIP);
                    lidar.SetPort(int.Parse(lidarPort));
                }
                LidarInitialization();

                // Reconfig Serial Port
                if (serialPort != null)
                {
                    serialPort.Close();
                    serialPort = null;
                }
                if (config.getControllerComName() != "כבוי")
                {
                    SerialPortConnection();
                }

                // Reconfig GPS Serial Port

                if (gps != null && config.getGPSComName() == "כבוי")
                {
                    activeAlert.Columns.RemoveAt(1);
                    log.Columns.RemoveAt(2);
                    gps.StopListening();
                    gps = null;
                }
                else if (config.getGPSComName() != "כבוי")
                {
                    if (activeAlert.Columns.Count == 6)
                    {
                        activeAlert.Columns.Insert(1, "קורדינטות");
                        activeAlert.Columns[1].Width     = 300;
                        activeAlert.Columns[1].TextAlign = HorizontalAlignment.Center;
                    }
                    if (log.Columns.Count == 7)
                    {
                        log.Columns.Insert(2, "קורדינטות");
                        log.Columns[2].Width     = 300;
                        log.Columns[2].TextAlign = HorizontalAlignment.Center;
                    }
                    gps = new GPS(config);
                    gps.StartListening(GpsStatus);
                }
                // Reconfig Server
                if (sendSocket != null)
                {
                    sendSocket.Disconnect();
                    sendSocket = null;
                    if (config.getInterntAdapter() != "כבוי")
                    {
                        new Thread(configServerConnection).Start();
                    }
                }
                lidar.ResumeScan();
            }
            else
            {
                lidar.ResumeScan();
            }
        }