示例#1
0
        public DetectVehicle(string ecuPath, EdInterfaceEnet.EnetConnection enetConnection = null)
        {
            EdInterfaceEnet edInterfaceEnet = new EdInterfaceEnet();

            _ediabas = new EdiabasNet
            {
                EdInterfaceClass = edInterfaceEnet,
                AbortJobFunc     = AbortEdiabasJob
            };
            _ediabas.SetConfigProperty("EcuPath", ecuPath);

            bool   icomAllocate = false;
            string hostAddress  = "auto:all";

            if (enetConnection != null)
            {
                icomAllocate = enetConnection.ConnectionType == EdInterfaceEnet.EnetConnection.InterfaceType.Icom;
                hostAddress  = enetConnection.ToString();
            }
            edInterfaceEnet.RemoteHost   = hostAddress;
            edInterfaceEnet.IcomAllocate = icomAllocate;
            EcuList = new List <PdszDatabase.EcuInfo>();

            ResetValues();
        }
示例#2
0
        private void buttonVehicleSearch_Click(object sender, EventArgs e)
        {
            bool preferIcom = checkBoxIcom.Checked;

            SearchVehiclesTask().ContinueWith(task =>
            {
                TaskActive = false;
                BeginInvoke((Action)(() =>
                {
                    List <EdInterfaceEnet.EnetConnection> detectedVehicles = task.Result;
                    EdInterfaceEnet.EnetConnection connectionDirect = null;
                    EdInterfaceEnet.EnetConnection connectionIcom = null;
                    EdInterfaceEnet.EnetConnection connectionSelected = null;
                    if (detectedVehicles != null)
                    {
                        foreach (EdInterfaceEnet.EnetConnection enetConnection in detectedVehicles)
                        {
                            if (enetConnection.IpAddress.ToString().StartsWith("192.168.11."))
                            {   // ICOM vehicle IP
                                continue;
                            }

                            if (connectionSelected == null)
                            {
                                connectionSelected = enetConnection;
                            }

                            switch (enetConnection.ConnectionType)
                            {
                            case EdInterfaceEnet.EnetConnection.InterfaceType.Icom:
                                if (connectionIcom == null)
                                {
                                    connectionIcom = enetConnection;
                                }
                                break;

                            default:
                                if (connectionDirect == null)
                                {
                                    connectionDirect = enetConnection;
                                }
                                break;
                            }
                        }
                    }

                    if (preferIcom)
                    {
                        if (connectionIcom != null)
                        {
                            connectionSelected = connectionIcom;
                        }
                    }
                    else
                    {
                        if (connectionDirect != null)
                        {
                            connectionSelected = connectionDirect;
                        }
                    }

                    bool ipValid = false;
                    try
                    {
                        if (connectionSelected != null)
                        {
                            ipAddressControlVehicleIp.Text = connectionSelected.IpAddress.ToString();
                            checkBoxIcom.Checked = connectionSelected.ConnectionType == EdInterfaceEnet.EnetConnection.InterfaceType.Icom;
                            ipValid = true;
                        }
                    }
                    catch (Exception)
                    {
                        ipValid = false;
                    }

                    if (!ipValid)
                    {
                        ipAddressControlVehicleIp.Text = DefaultIp;
                        checkBoxIcom.Checked = false;
                    }
                }));
            });

            TaskActive = true;
            UpdateDisplay();
        }