private void OpenLoggingFile(CommunicationManager comm) { string inFilename = string.Empty; string path = clsGlobal.InstalledDirectory + @"\Log"; if (comm.IsSourceDeviceOpen()) { if (this.logFileName.Text.Length == 0) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } inFilename = path + @"\SiRFLive.log"; this.logFileName.Text = inFilename; } else { Regex regex = new Regex("^(([a-zA-Z]\\:)|(\\\\))(\\\\{1}|((\\\\{1})[^\\\\]([^/:*?<>\"|]*))+)$"); if (!regex.IsMatch(this.logFileName.Text)) { MessageBox.Show("Invalid File Path"); return; } inFilename = this.logFileName.Text; } if (!comm.Log.IsFileOpen()) { if (comm.Log.OpenFile(inFilename)) { this.frmCommOpenLogStatusLabel.Text = comm.Log.LoggingState.ToString() + " ..."; this.btn_logFileBroswer.Enabled = false; this.logFileName.Enabled = false; } } else { this.frmCommOpenLogStatusLabel.Text = comm.Log.LoggingState.ToString() + " ..."; } comm.Log.DurationLoggingStatusLabel = this.frmCommOpenDurationLoggingStatusLabel; comm.Log.LoggingStatusLabel = this.frmCommOpenLogStatusLabel; this.logFileName.Text = comm.Log.filename; comm.RxCtrl.PollSWVersion(); comm.RxCtrl.PollNavigationParameters(); } else { MessageBox.Show("Port not open", "Error logging", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }
private DialogResult createSwitchProtocolWindow(ref CommunicationManager comm) { if ((comm != null) && comm.IsSourceDeviceOpen()) { frmSwitchProtocol protocol = new frmSwitchProtocol(comm); return protocol.ShowDialog(); } return DialogResult.Cancel; }
private bool createRxSettingsWindow(ref CommunicationManager comm) { bool flag = false; if (comm != null) { if (!comm.IsSourceDeviceOpen()) { frmCommSettings settings = new frmCommSettings(ref comm); if (settings.ShowDialog() != DialogResult.Cancel) { flag = true; } } return flag; } MessageBox.Show("Port is connected! Disconnect port before configuring.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Hand); return flag; }
private bool updateSBASRangingMenu(CommunicationManager targetComm) { bool flag = false; try { if (targetComm.IsSourceDeviceOpen()) { targetComm.RxCtrl.PollNavigationParameters(); if (targetComm.NavigationParamrters.SBASRangingMode == 1) { setSBASRangingMenu(true); return true; } setSBASRangingMenu(false); return false; } flag = false; setSBASRangingMenu(false); } catch { flag = false; } return flag; }
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; }
private void localUpdateConnectBtnImage(CommunicationManager comm) { bool flag = false; if (comm != null) { if (toolStripPortComboBox.Text != comm.PortName) { if (toolStripPortComboBox.Text == "All") { bool flag2 = false; foreach (string str in PortManagerHash.Keys) { PortManager manager = (PortManager) PortManagerHash[str]; if (((manager != null) && (manager.comm != null)) && manager.comm.IsSourceDeviceOpen()) { flag2 = true; break; } } if (flag2) { toolStripPortOpenBtn.Image = Resources.connect; toolStripPortOpenBtn.Text = "Disconnect"; ChangeRestoreLayoutState(true); return; } toolStripPortOpenBtn.Image = Resources.disconnect; toolStripPortOpenBtn.Text = "Connect"; ChangeRestoreLayoutState(false); } return; } flag = comm.IsSourceDeviceOpen(); } if (flag) { flag = true; toolStripPortOpenBtn.Image = Resources.connect; toolStripPortOpenBtn.Text = "Disconnect"; receiverConnectToolStripMenuItem.Enabled = false; receiverDisconnectToolStripMenuItem.Enabled = true; } else { toolStripPortOpenBtn.Image = Resources.disconnect; toolStripPortOpenBtn.Text = "Connect"; receiverConnectToolStripMenuItem.Enabled = true; receiverDisconnectToolStripMenuItem.Enabled = false; } }