Ejemplo n.º 1
0
        public Lidar(Configuration config, string newIP, int port)
        {
            PORT        = port;
            this.config = config;
            IP          = IPAddress.Parse(newIP);
            IPAddress my = LocalIP.GetLocalIP(LOCAL_IP_TYPE.LIDAR);

            socket = new SocketSync(my, IP, PORT);
        }
Ejemplo n.º 2
0
 // Create Socket Connection with the server.
 // And send to the server configuration for correct display
 private void configServerConnection()
 {
     try {
         bool   isSucceeded           = false;
         int    vehicleWidth          = config.getVehicleWidth();
         int    height                = config.getSensorHeightSetup();
         int    setUpAngle            = config.getAngleSetup();
         float  resolution            = config.getResolution();
         int    startAngle            = config.getStartAngle();
         int    stopAngle             = config.getStopAngle();
         int    sideL                 = config.getSideLowAlert();
         int    sideH                 = config.getSideHighAlert();
         int    FrontL                = config.getFrontLowAlert();
         int    FrontH                = config.getFrontHighAlert();
         int    HoleL                 = config.getHoleLowAlert();
         int    HoleH                 = config.getHoleHighAlert();
         int    minimumHeightDetected = config.getMinimumHeightDetected();
         string srvConfig             = "Config " + vehicleWidth + " " + height + " " +
                                        setUpAngle + " " + resolution + " " + startAngle + " " +
                                        stopAngle + " " + sideL + " " + sideH + " " + FrontL + " " +
                                        FrontH + " " + HoleL + " " + HoleH + " " + minimumHeightDetected;
         IPAddress server = IPAddress.Parse(config.getServerIp());
         IPAddress my     = LocalIP.GetLocalIP(LOCAL_IP_TYPE.INTERNET);
         if (my == null || server == null)
         {
             throw new ProtocolViolationException();
         }
         sendSocket  = new SocketSync(my, server, serverPort, ServerTimeOut);
         isSucceeded = sendSocket.Connect();
         if (isSucceeded)
         {
             isSucceeded = sendSocket.Send(srvConfig, false);
         }
         ServerTimeOut(!isSucceeded);
     } catch (Exception e) {
         Console.WriteLine(e);
     }
 }
Ejemplo n.º 3
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();
            }
        }