public GPSDateTime GetTime() { GPSDateTime time = new GPSDateTime(); time.SetTime(DateTime.Now + this.timeOffset); return(time); }
public void SetTime(GPSDateTime inTime) { this.timeOffset = (TimeSpan) (inTime.GetTime() - DateTime.Now); }
public GPSDateTime GetTime() { GPSDateTime time = new GPSDateTime(); time.SetTime(DateTime.Now + this.timeOffset); return time; }
public void SetGPSTime(string gpsWeek, string gpsTow) { try { GPSDateTime inTime = new GPSDateTime(); int inWeek = Convert.ToInt32(gpsWeek) + 0x400; double inTOW = Convert.ToDouble(gpsTow) / 100.0; inTime.SetUTCOffset(this._utcOffset); inTime.SetTime(inWeek, inTOW); this._gpsTimer.SetTime(inTime); if ((this._resetCtrl != null) && (this._resetCtrl.ResetGPSTimer != null)) { double gPSTOW = this._resetCtrl.ResetGPSTimer.GetTime().GetGPSTOW(); if ((gPSTOW < (inTOW - 10.0)) || (gPSTOW > (inTOW + 10.0))) { inTime.SetUTCOffset(this._utcOffset); inTime.SetTime(inWeek, inTOW); this._gpsTimer.SetTime(inTime); } } } catch (Exception exception) { this._commWindow.WriteApp("Set GPS Time error: " + exception.Message); } }
private void rinexToEphToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); if (dialog.ShowDialog() == DialogResult.OK) { string fileName = dialog.FileName; int length = fileName.LastIndexOf('.'); fileName.Substring(0, length); string path = fileName.Substring(0, length) + ".ai3eph"; StreamWriter writer = new StreamWriter(path); try { RinexFile file = new RinexFile(); file.Read(fileName); int year = file.Year; int month = file.Month; int day = file.Day; int hour = file.Hour; int minute = file.Minute; int second = file.Second; for (int i = 0; i < 0x18; i += 2) { DateTime inTime = new DateTime(year, month, day, i, 0, 0); GPSDateTime time2 = new GPSDateTime(); time2.SetUTCOffset(0); time2.SetTime(inTime); int gPSTOW = (int) time2.GetGPSTOW(); int num7 = gPSTOW + (time2.GetGPSWeek() * 0x93a80); string str3 = string.Format("// Hour {0:D2}-{1:D2}\r\n", i, i + 2) + "// Ephemeris Collection Time(UTC): "; string str4 = string.Format("{0:ddd MMM dd HH:mm:ss yyyy}", inTime); str3 = str3 + str4 + "\r\n*********** Ephemeris Data at GPS time: "; string str5 = num7.ToString(); str3 = str3 + str5 + "***********\r\n//\r\n//"; writer.WriteLine(str3); for (byte j = 1; j <= 0x20; j = (byte) (j + 1)) { RinexEph eph = file.SearchRinexArrayList(j, gPSTOW + file.UTCOffset); if (eph != null) { string str6 = string.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20}, {21}, {22}, {23},", new object[] { eph.svid, eph.ura_ind, (byte) eph.iode, (short) (eph.Crs * Math.Pow(2.0, 5.0)), (short) (eph.deltan * Math.Pow(2.0, 43.0)), (int) (eph.m0 * Math.Pow(2.0, 31.0)), (short) (eph.Cuc * Math.Pow(2.0, 29.0)), (uint) (eph.ecc * Math.Pow(2.0, 33.0)), (short) (eph.Cus * Math.Pow(2.0, 29.0)), (uint) (eph.sqrta * Math.Pow(2.0, 19.0)), (ushort) (eph.toe * Math.Pow(2.0, -4.0)), (short) (eph.Cic * Math.Pow(2.0, 29.0)), (int) (eph.omega0 * Math.Pow(2.0, 31.0)), (short) (eph.Cis * Math.Pow(2.0, 29.0)), (int) (eph.i0 * Math.Pow(2.0, 31.0)), (short) (eph.Crc * Math.Pow(2.0, 5.0)), (int) (eph.omega * Math.Pow(2.0, 31.0)), (int) (eph.omegaDot * Math.Pow(2.0, 43.0)), (short) (eph.idot * Math.Pow(2.0, 43.0)), (ushort) (eph.toc * Math.Pow(2.0, -4.0)), (sbyte) (eph.tgd * Math.Pow(2.0, 31.0)), (sbyte) (eph.af2 * Math.Pow(2.0, 55.0)), (short) (eph.af1 * Math.Pow(2.0, 43.0)), (int) (eph.af0 * Math.Pow(2.0, 31.0)) }); writer.WriteLine(str6); } } writer.WriteLine(""); } writer.Close(); MessageBox.Show("Conversion is complete and file saved as: " + path, "File Conversion Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception exception) { MessageBox.Show("Exception in Rinex to ai3eph file conversion: " + exception.ToString()); } } }
public void SetTime(GPSDateTime inTime) { this.timeOffset = (TimeSpan)(inTime.GetTime() - DateTime.Now); }
private int msg69ToMsg4AndMsg41Format(string inputString, ref string[] msg41Array) { string[] strArray = inputString.Split(new char[] { ',' }); int num = 0; try { Convert.ToInt32(strArray[2]); num = Convert.ToInt32(strArray[3]); Convert.ToInt32(strArray[4]); } catch { } if (num == 0) { return 1; } int num2 = 0; int num3 = 0; int inWeek = 0; double inTOW = 0.0; double num6 = 0.0; double num7 = 0.0; int num8 = 0; double num9 = 0.0; double num10 = 0.0; double num11 = 0.0; int inUTCOffset = 0; int num13 = 0; uint num14 = 0; try { num2 = Convert.ToInt32(strArray[5]); num3 = Convert.ToInt32(strArray[6]); Convert.ToInt32(strArray[7]); inWeek = Convert.ToInt32(strArray[8]); inTOW = Convert.ToDouble(strArray[9]) / 1000.0; num6 = (Convert.ToDouble(strArray[10]) * 180.0) / 4294967296; num7 = (Convert.ToDouble(strArray[11]) * 360.0) / 4294967296; num8 = Convert.ToInt32(strArray[12]); double num1 = (Convert.ToDouble(strArray[13]) * 180.0) / 256.0; num9 = (Convert.ToDouble(strArray[0x10]) * 0.1) - 500.0; num10 = Convert.ToDouble(strArray[0x12]) * 0.0625; num11 = (Convert.ToDouble(strArray[0x13]) * 360.0) / 65536.0; Convert.ToDouble(strArray[20]); Convert.ToDouble(strArray[0x15]); Convert.ToDouble(strArray[0x16]); Convert.ToDouble(strArray[0x17]); Convert.ToDouble(strArray[0x18]); Convert.ToInt32(strArray[0x19]); Convert.ToUInt16(strArray[0x1a]); Convert.ToDouble(strArray[0x1c]); if ((num8 & 8) == 8) { inUTCOffset = Convert.ToInt32(strArray[0x1d]); } else { inUTCOffset = 15; } num13 = Convert.ToInt32(strArray[30]); } catch { } if (num2 <= 0) { return 1; } msg41Array[0] = "41"; msg41Array[1] = "0"; switch ((num3 & 3)) { case 0: msg41Array[2] = "5"; break; case 1: msg41Array[2] = "6"; break; default: msg41Array[2] = "0"; break; } msg41Array[3] = strArray[8]; msg41Array[4] = strArray[9]; GPSDateTime time = new GPSDateTime(); time.SetTime(inWeek, inTOW); time.SetUTCOffset(inUTCOffset); DateTime time2 = time.GetTime(); msg41Array[5] = time2.Year.ToString(); msg41Array[6] = time2.Month.ToString(); msg41Array[7] = time2.Day.ToString(); msg41Array[8] = time2.Hour.ToString(); msg41Array[9] = time2.Minute.ToString(); msg41Array[10] = ((time2.Second * 0x3e8) + time2.Millisecond).ToString(); msg41Array[12] = string.Format("{0:F0}", num6 * 10000000.0); msg41Array[13] = string.Format("{0:F0}", num7 * 10000000.0); if ((num8 & 2) == 2) { msg41Array[14] = string.Format("{0:F0}", num9 * 100.0); } else { msg41Array[14] = "0"; } msg41Array[15] = "0"; msg41Array[0x10] = "0"; if ((num8 & 4) == 4) { msg41Array[0x11] = string.Format("{0:F0}", num10 * 100.0); msg41Array[0x12] = string.Format("{0:F0}", num11 * 100.0); } else { msg41Array[0x11] = "0"; msg41Array[0x12] = "0"; } for (int i = 0x13; i <= 0x20; i++) { msg41Array[i] = "0"; } msg41Array[0x21] = num13.ToString(); msg41Array[0x22] = "0"; msg41Array[0x23] = "0"; try { int[] numArray = new int[num13]; int[] numArray2 = new int[num13]; int[] numArray3 = new int[num13]; if ((num8 & 0x10) == 0x10) { int index = 0; int num19 = 0x1f; while (index < num13) { numArray[index] = Convert.ToInt32(strArray[num19++]); numArray2[index] = Convert.ToInt32(strArray[num19++]); numArray3[index] = Convert.ToInt32(strArray[num19++]); num14 |= ((uint) 1) << (numArray[index] - 1); index++; } } else { for (int j = 0; j < num13; j++) { numArray[j] = 0; numArray2[j] = 0; numArray3[j] = 0; num14 = 0; } } } catch { return 1; } msg41Array[11] = string.Format("{0}", num14); return 0; }
private void dataGridView1_Paint(object sender, PaintEventArgs e) { if ((this.TTFSDataElement != null) && this.TTFSDataElement.isValid) { if (this.dataGridView1.RowCount > 0x2710) { this.dataGridView1.Rows.RemoveAt(0); } GPSDateTime time = new GPSDateTime(); time.SetUTCOffset(15); time.SetTime(this.TTFSDataElement.Week, this.TTFSDataElement.TOW); DateTime time2 = time.GetTime(); string str = string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", new object[] { time2.Hour, time2.Minute, time2.Second, time2.Millisecond }); int num = this.dataGridView1.Rows.Add(); this.dataGridView1["TTFS", num].Value = this.TTFSDataElement.TTFS.ToString(); this.dataGridView1["UTCTime", num].Value = str; this.dataGridView1.Rows[num].HeaderCell.Value = (num + 1).ToString(); if (this.dataGridView1.Rows.Count >= 2) { this.dataGridView1.FirstDisplayedScrollingRowIndex = this.dataGridView1.Rows.Count - 2; } else { this.dataGridView1.FirstDisplayedScrollingRowIndex = 0; } this.TTFSDataElement.isValid = false; } }