예제 #1
0
        private bool manualConnect(ref CommunicationManager comm)
        {
            if (comm == null)
            {
                return false;
            }
            try
            {
                bool flag2;
                if (clsGlobal.IsMarketingUser())
                {
                    comm.IsAutoDetectBaud = true;
                }
                if (comm.IsSourceDeviceOpen())
                {
                    goto Label_04E8;
                }
                if (!comm.RequireHostRun || (sysCmdExec.IsExistingWin(comm.HostSWFilePath) != 0))
                {
                    goto Label_02AC;
                }
                string argStr = string.Empty;
                switch (comm.InputDeviceMode)
                {
                    case CommonClass.InputDeviceModes.RS232:
                        argStr = @"-a\\.\\" + comm.HostPair1 + " -y\"" + comm.HostAppCfgFilePath + "\" -e\"" + comm.HostAppMEMSCfgPath + "\"";
                        break;

                    case CommonClass.InputDeviceModes.TCP_Client:
                        argStr = "-n" + comm.CMC.HostAppClient.TCPClientPortNum.ToString() + " -y\"" + comm.HostAppCfgFilePath + "\" -e\"" + comm.HostAppMEMSCfgPath + "\"";
                        break;

                    case CommonClass.InputDeviceModes.TCP_Server:
                        argStr = "-n" + comm.CMC.HostAppServer.TCPServerPortNum.ToString() + " -y\"" + comm.HostAppCfgFilePath + "\" -e\"" + comm.HostAppMEMSCfgPath + "\"";
                        break;
                }
                if (!comm.RequireEE)
                {
                    goto Label_02A4;
                }
                string eESelect = comm.EESelect;
                if (eESelect != null)
                {
                    if (!(eESelect == "CGEE"))
                    {
                        if (eESelect == "SGEE")
                        {
                            goto Label_01EB;
                        }
                        if (eESelect == "Mixed SGEE + CGEE")
                        {
                            goto Label_01F9;
                        }
                    }
                    else
                    {
                        argStr = argStr + " -mode \"ff4_cgee_only\"";
                    }
                }
                goto Label_0205;
            Label_01EB:
                argStr = argStr + " -mode \"ff4_sgee_only\"";
                goto Label_0205;
            Label_01F9:
                argStr = argStr + " -mode \"ff4_mixed_mode\"";
            Label_0205:;
                argStr = argStr + " -s\"" + comm.ServerName + "\" -d\"/diff/packedDifference.f2p" + comm.EEDayNum + "enc.ee\" -j\"" + comm.AuthenticationCode + "\" -k" + comm.ServerPort;
                if ((comm.EESelect == "CGEE") || (comm.EESelect == "Mixed SGEE + CGEE"))
                {
                    argStr = argStr + " -b" + comm.BankTime;
                }
            Label_02A4:
                RunHostAppFromMain(argStr, ref comm);
            Label_02AC:
                flag2 = false;
                if (comm.ProductFamily == CommonClass.ProductType.GSD4e)
                {
                    if (comm.InputDeviceMode == CommonClass.InputDeviceModes.RS232)
                    {
                        if ((comm.ResetPort != string.Empty) && (comm.ResetPort != "-1"))
                        {
                            string s = comm.ResetPort.Replace("COM", "");
                            int result = 0;
                            if (int.TryParse(s, out result))
                            {
                                comm.Init4eMPMWakeupPort(result);
                                comm.Toggle4eWakeupPort();
                            }
                        }
                        if (comm.IsAutoDetectBaud)
                        {
                            if (searchforProtocolAndBaud(ref comm) > 0)
                            {
                                flag2 = true;
                            }
                            else
                            {
                                flag2 = false;
                            }
                        }
                        else
                        {
                            comm.AutoDetectProtocolAndBaudDone = true;
                            flag2 = comm.OpenPort();
                        }
                    }
                    else if (comm.InputDeviceMode == CommonClass.InputDeviceModes.I2C)
                    {
                        if (searchforProtocol_I2C(ref comm) > 0)
                        {
                            flag2 = true;
                        }
                        else
                        {
                            flag2 = false;
                        }
                    }
                    else
                    {
                        flag2 = true;
                    }
                    if (!flag2)
                    {
                        comm.ConnectErrorString = "Autodetect baud failed!";
                        return false;
                    }
                    if (comm.MessageProtocol == "OSP")
                    {
                        comm.RxCurrentTransmissionType = CommunicationManager.TransmissionType.GPS;
                        comm.CMC.RxCurrentTransmissionType = CommonClass.TransmissionType.GPS;
                    }
                    else if (comm.MessageProtocol == "NMEA")
                    {
                        comm.RxCurrentTransmissionType = CommunicationManager.TransmissionType.Text;
                        comm.CMC.RxCurrentTransmissionType = CommonClass.TransmissionType.Text;
                    }
                    else
                    {
                        comm.RxCurrentTransmissionType = CommunicationManager.TransmissionType.Hex;
                        comm.CMC.RxCurrentTransmissionType = CommonClass.TransmissionType.Hex;
                    }
                }
                else
                {
                    comm.AutoDetectProtocolAndBaudDone = true;
                    if (!comm.OpenPort())
                    {
                        comm.ConnectErrorString = "Unable to open port!";
                        return false;
                    }
                }
                if (comm.RxType == CommunicationManager.ReceiverType.TTB)
                {
                    comm.WriteData("A0A2 0009 CCA6 0002 0100 0000 00 8175 B0B3");
                    comm.WriteData("A0A2 0009 CCA6 0004 0100 0000 00 8177 B0B3");
                    comm.WriteData("A0A2 0009 CCA6 0029 0100 0000 00 819C B0B3");
                }
                if (comm.RequireHostRun && (sysCmdExec.IsExistingWin(comm.HostSWFilePath) == 1))
                {
                    sysCmdExec.SetWinSize(comm.HostSWFilePath, 2);
                }
                if (comm.RequireHostRun)
                {
                    comm.RxCtrl.SetMEMSMode(0);
                }
                if (comm.MessageProtocol != "NMEA")
                {
                    comm.RxCtrl.PollClockStatus();
                    comm.RxCtrl.PollSWVersion();
                    comm.RxCtrl.PollNavigationParameters();
                }
                if (comm.RxName == string.Empty)
                {
                    comm.RxName = "SiRF_EVK";
                }
                goto Label_0515;
            Label_04E8:
                manualDisconnect(ref comm);
            }
            catch (Exception exception)
            {
                if (comm != null)
                {
                    comm.ConnectErrorString = "Error: " + exception.ToString();
                }
                return false;
            }
            Label_0515:
            return true;
        }