public void Validate() { // Load the sample file data file = new AFPFile(testFilePath, false); // Ensure it validates Assert.IsTrue(file.EncodeData().Any()); // Remove the first container information from all fields it contains Container c = file.Fields.First(f => f.LowestLevelContainer != null).LowestLevelContainer; foreach (DataStructure s in c.Structures) { s.Containers.Remove(c); } // it should no longer validate Assert.IsFalse(file.EncodeData().Any()); // Reload data file = new AFPFile(testFilePath, false); // Surround the file with BPF/EPF tags file.AddField(StructuredField.New <BPF>(), 0); file.AddField(StructuredField.New <EPF>(), file.Fields.Count); // Check it still validates (container info should have been updated) Assert.IsTrue(file.EncodeData().Any()); // Try adding a TLE field to the top of the file TLE newTLE = StructuredField.New <TLE>(); file.AddField(newTLE, 0); // Ensure it does not validate Assert.IsFalse(file.EncodeData().Any()); // Delete that field, and add it in a place where it is allowed to be (in this case, after a BPG) file.DeleteField(newTLE); int newIndex = 0; for (int i = 0; i < file.Fields.Count; i++) { if (file.Fields[i] is BPG) { newIndex = i + 1; break; } } file.AddField(newTLE, newIndex); Assert.IsTrue(file.EncodeData().Any()); }
private void btnImportTle_Click(object sender, EventArgs e) { if (openTleFileDialog.ShowDialog() == DialogResult.OK) { currentTle = new TLE(openTleFileDialog.FileName); this.lblTleEpoch.Text = currentTle.GetTleEpoch().ToString("dd MMM yyyy hh:mm:ss.fff"); this.lblSatNumber.Text = currentTle.GetSatNumber(); this.lblInclination.Text = currentTle.GetInclination(); this.lblEccentricity.Text = currentTle.GetEccentricity(); this.lblRevNumber.Text = currentTle.GetRevNumber(); this.lblMeanMotion.Text = currentTle.GetMeanMotion(); this.btnCreateScenarioTle.Enabled = true; } }
private void createScenarioSatcatDoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; app = new AgUiApplication(); app.LoadPersonality("STK"); root = (AgStkObjectRoot)app.Personality2; initState = new InitialState(); satData = new Data(Convert.ToDouble(tbMass.Text), Convert.ToDouble(tbDragArea.Text), Convert.ToDouble(tbCd.Text), Convert.ToDouble(tbSolarArea.Text), Convert.ToDouble(tbCr.Text)); string satelliteID = this.dgvSatList.SelectedRows[0].Cells[1].Value.ToString(); currentTle = STK.CreateScenarioFromSatcat(ref root, Convert.ToDouble(this.nudDuration.Value), ref initState, satelliteID); STK.ConfigurePropagator(root); root.Rewind(); }