Example #1
0
 /// <summary>
 /// 根据配置更新界面
 /// </summary>
 /// <param name="info"></param>
 public void UpdateInterface(DME.Updater.UpdateInfo info)
 {
     this.deletePreviousFileMode.SelectedIndex = (int)info.DeleteMethod;
     this.deleteRules.Text = info.DeleteFileLimits.IsEmpty() ? "" : string.Join(Environment.NewLine, info.DeleteFileLimits);
     this.requiredMinVersion.Text = info.RequiredMinVersion;
     this.txtPackagePassword.Text = info.PackagePassword ?? "";
 }
Example #2
0
 /// <summary>
 /// 保存设置到配置中
 /// </summary>
 /// <param name="info"></param>
 public void SaveSetting(DME.Updater.UpdateInfo info)
 {
     info.DeleteFileLimits = this.deleteRules.Lines;
     info.DeleteMethod = (DME.Updater.DeletePreviousProgramMethod)this.deletePreviousFileMode.SelectedIndex;
     info.RequiredMinVersion = this.requiredMinVersion.Text;
     info.PackagePassword = this.txtPackagePassword.Text;
 }
Example #3
0
        void Instance_DownloadProgressChanged(object sender, DME.Updater.Wrapper.RunworkEventArgs e)
        {
            pbProgress.Style = ProgressBarStyle.Blocks;
            pbProgress.Value = e.Progress.TaskPercentage;

            if (!string.IsNullOrEmpty(e.Progress.StateMessage)) lblProgressDesc.Text = e.Progress.StateMessage;
            else lblProgressDesc.Text = string.Format("{0}/{1}", ExtensionMethod.ToSizeDescription(e.Progress.TaskProgress), ExtensionMethod.ToSizeDescription(e.Progress.TaskCount));
        }
Example #4
0
 //[DeploymentItem("LibOpenBYOND.dll")]
 public void parseIncludeTest()
 {
     DME target = new DME(); // TODO: Initialize to an appropriate value
     string line = "#include \"balls.txt\""; // TODO: Initialize to an appropriate value
     string expected = Path.GetFullPath(Path.Combine("balls.txt"));
     target.parseInclude(line);
     CollectionAssert.Contains(target.Files, expected, "Balls.txt not in Files.");
 }
Example #5
0
        //[DeploymentItem("LibOpenBYOND.dll")]
        public void parseIncludeTest()
        {
            DME    target   = new DME();                // TODO: Initialize to an appropriate value
            string line     = "#include \"balls.txt\""; // TODO: Initialize to an appropriate value
            string expected = Path.GetFullPath(Path.Combine("balls.txt"));

            target.parseInclude(line);
            CollectionAssert.Contains(target.Files, expected, "Balls.txt not in Files.");
        }
Example #6
0
 private void initialize()
 {
     if (cDME == null)
     {
         cDME = new DME();
         cDME.iStation_ID_Characters    = new int[3];
         cDME.iStation_ID_Characters[0] = 10; // K
         cDME.iStation_ID_Characters[1] = 18; // S
         cDME.iStation_ID_Characters[2] = 15; // P
         cDME.buildStationID();
         sStation_ID = cDME.sStation_ID;
     }
     if (cNav_Master == null)
     {
         cNav_Master = new NAVmaster();
     }
 }
Example #7
0
        private static void LoadObjectTreeFrom(string file)
        {
            log.Info("Attempting object tree load...");

            DME dme = new DME();
            dme.LoadFile(file);

            ObjectTree otr = new ObjectTree();
            foreach (string filename in dme.Files)
            {
                if(filename.EndsWith(".dm"))
                    otr.ProcessFile(filename);
            }

            log.Info("TREE LOAD COMPLETE");

            Environment.Exit(0);
        }
Example #8
0
        //[DeploymentItem("TestFiles","TestFiles")]
        public void LoadFileTest()
        {
            //testContextInstance.WriteLine("CD: {0}", Environment.CurrentDirectory);

            DME target = new DME();
            string filename = Path.Combine("TestFiles","Test.dme");

            List<string> expected = new List<string>();
            expected.Add(Path.GetFullPath(Path.Combine("TestFiles", "code", "global.dm")));
            expected.Add(Path.GetFullPath(Path.Combine("TestFiles", "code", "world.dm")));
            expected.Add(Path.GetFullPath(Path.Combine("TestFiles", "interface", "interface.dm")));
            expected.Add(Path.GetFullPath(Path.Combine("TestFiles", "interface", "skin.dmf")));
            expected.Add(Path.GetFullPath(Path.Combine("TestFiles", "maps", "tgstation.dmm")));

            target.LoadFile(filename);

            Assert.AreEqual(target.Files.Count, 5, "Got incorrect # of files.");
            CollectionAssert.AllItemsAreInstancesOfType(target.Files, typeof(string), "Wrong types.");
            CollectionAssert.AreEqual(expected, target.Files, "Wrong entries");
        }
Example #9
0
        //[DeploymentItem("TestFiles","TestFiles")]
        public void LoadFileTest()
        {
            //testContextInstance.WriteLine("CD: {0}", Environment.CurrentDirectory);

            DME    target   = new DME();
            string filename = Path.Combine("TestFiles", "Test.dme");

            List <string> expected = new List <string>();

            expected.Add(Path.GetFullPath(Path.Combine("TestFiles", "code", "global.dm")));
            expected.Add(Path.GetFullPath(Path.Combine("TestFiles", "code", "world.dm")));
            expected.Add(Path.GetFullPath(Path.Combine("TestFiles", "interface", "interface.dm")));
            expected.Add(Path.GetFullPath(Path.Combine("TestFiles", "interface", "skin.dmf")));
            expected.Add(Path.GetFullPath(Path.Combine("TestFiles", "maps", "tgstation.dmm")));

            target.LoadFile(filename);

            Assert.AreEqual(target.Files.Count, 5, "Got incorrect # of files.");
            CollectionAssert.AllItemsAreInstancesOfType(target.Files, typeof(string), "Wrong types.");
            CollectionAssert.AreEqual(expected, target.Files, "Wrong entries");
        }
Example #10
0
        private static void LoadObjectTreeFrom(string file)
        {
            log.Info("Attempting object tree load...");

            DME dme = new DME();

            dme.LoadFile(file);

            ObjectTree otr = new ObjectTree();

            foreach (string filename in dme.Files)
            {
                if (filename.EndsWith(".dm"))
                {
                    otr.ProcessFile(filename);
                }
            }

            log.Info("TREE LOAD COMPLETE");

            Environment.Exit(0);
        }
Example #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Dialer_StateChanged(object sender, DME.Dialer.StateChangedEventArgs e)
 {
     if (StateChanged != null)
     {
         this.StateChanged(this, e);
     }
 }
Example #12
0
        public override void OnUpdate()
        {
            initialize();

            string ResName = "ElectricCharge";

            double dPowerRequired = 10.0 * dW_to_EC; // 10 W is typical receive power for NAV radio

            double dElectric_Draw = dPowerRequired * TimeWarp.deltaTime;
            double elecAvail      = 0.0;

            if (bOn)
            {
                elecAvail = part.RequestResource(ResName, dElectric_Draw) / dElectric_Draw;
            }
            bPowered = (elecAvail > 0.90);

            if (cRecv.vPosition.updatePositionData(vessel.mainBody, vessel.latitude, vessel.longitude, vessel.altitude))
            {
                cNav_Master.updateReceiver(iReceiver_ID, cRecv);
            }

            //string sMsg = "Recv freq " + cRecv.getFrequency().ToString("000.00");
            //print(sMsg);
            cNav_Master.onReceiverUpdate();
            if (bPowered)
            {
                if (cRecv.isActiveILS())
                {
                    cTuned_GLS = cNav_Master.getStationGLS(iReceiver_ID) as GLS;
                    cTuned_LOC = cNav_Master.getStationLOC(iReceiver_ID) as LOC;
                    cTuned_VOR = null;
                }
                else
                {
                    cTuned_VOR = cNav_Master.getStationVOR(iReceiver_ID) as VOR;
                    cTuned_GLS = null;
                    cTuned_LOC = null;
                }
                cTuned_DME = cNav_Master.getStationDME(iReceiver_ID) as DME;
            }
            else
            {
                cTuned_VOR = null;
                cTuned_LOC = null;
                cTuned_DME = null;
                cTuned_GLS = null;
            }
            if (cTuned_VOR != null)
            {
                if (cTuned_VOR.getFlux(cRecv.vPosition) < 2.0e-9 || !cTuned_VOR.inLineOfSight(cRecv.vPosition))
                {
                    cTuned_VOR = null;
                }
            }
            if (cTuned_LOC != null)
            {
                if (cTuned_LOC.getFlux(cRecv.vPosition) < 2.0e-9 || !cTuned_LOC.inLineOfSight(cRecv.vPosition))
                {
                    cTuned_LOC = null;
                }
            }
            if (cTuned_DME != null)
            {
                if (cTuned_DME.getFlux(cRecv.vPosition) < 2.0e-9 || !cTuned_DME.inLineOfSight(cRecv.vPosition))
                {
                    cTuned_DME = null;
                }
            }
            if (cTuned_GLS != null)
            {
                if (cTuned_GLS.getFlux(cRecv.vPosition) > 2.0e-9 || !cTuned_GLS.inLineOfSight(cRecv.vPosition))
                {
                    cTuned_GLS = null;
                }
            }

            if (cTuned_VOR != null)
            {
                sTuned_Station = cTuned_VOR.sStation_ID;
            }
            else if (cTuned_LOC != null)
            {
                sTuned_Station = cTuned_LOC.sStation_ID;
            }
            else if (cTuned_DME != null)
            {
                sTuned_Station = cTuned_LOC.sStation_ID;
            }
            else if (cTuned_GLS != null)
            {
                sTuned_Station = cTuned_GLS.sStation_ID;
            }
            else
            {
                sTuned_Station = "---";
            }
        }
Example #13
0
        /// <summary>
        /// 引发 <see cref="DownloadProgressChanged"/> 事件
        /// </summary>
        /// <param name="e">类型为 <see cref="T:FSLib.Threading.RunworkEventArgs"/> 的参数</param>
        protected virtual void OnDownloadProgressChanged(DME.Updater.Wrapper.RunworkEventArgs e)
        {
            if (DownloadProgressChanged == null)
                return;

            DownloadProgressChanged(this, e);
        }
Example #14
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            double dElectric_Draw = 5.0 * dW_to_EC;
            double elecAvail      = part.RequestResource("ElectricCharge", dElectric_Draw) / dElectric_Draw;

            bPowered    = (elecAvail > 0.90);
            sStation_ID = "---";

            if (bPowered)
            {
                cNav_Select = null;
                foreach (Part p in vessel.Parts)
                {
                    //string sMsg1 = "VI: " + p.name;
                    //print(sMsg1);
                    foreach (PartModule m in p.Modules)
                    {
                        //string sMsg2 = "VIm: " + m.name;
                        //print(sMsg2);
                        VHF_NAV_Receiver cNav = m as VHF_NAV_Receiver;
                        if (cNav != null)
                        {
                            cNav_Select = cNav;
                        }
                    }
                }
                if (cNav_Select != null)
                {
                    //string sMsg = "DME indicator found receiver " + cNav_Select.moduleName;
                    //print(sMsg);
                    DME cDME = cNav_Select.getTunedDME();
                    if (cDME != null)
                    {
                        sStation_ID = cDME.sStation_ID;
                        if ((dLast_GS_Query_Time + 1.0) < Time.time)
                        {
                            dIndicated_Distance = cDME.getDistance(cNav_Select.getPosition());
                            if (bUnits_Mi)
                            {
                                dIndicated_Distance /= 1852.0; // convert to nm
                            }
                            else
                            {
                                dIndicated_Distance /= 1000.0; // convert to km
                            }
                            dIndicated_Groundspeed     = (dIndicated_Distance - dLast_Query_Distance) / (Time.time - dLast_GS_Query_Time) * 3600.0;
                            dIndicated_Time_To_Station = dIndicated_Distance / dIndicated_Groundspeed / 60.0;
                            dLast_Query_Distance       = dIndicated_Distance;
                            dLast_GS_Query_Time        = Time.time;
                        }
                    }
                    else
                    {
                        sStation_ID            = "---";
                        dIndicated_Distance    = -1;
                        dIndicated_Groundspeed = 0;
                        dLast_Query_Distance   = 0;
                        dLast_GS_Query_Time    = -1;
                    }
                }
                else
                {
                    sStation_ID            = "---";
                    dIndicated_Distance    = -1;
                    dIndicated_Groundspeed = 0;
                    dLast_Query_Distance   = 0;
                    dLast_GS_Query_Time    = -1;
                }
            }
        }
Example #15
0
 /// <summary>
 /// Raises the <see cref="RasDialer.StateChanged"/> event.
 /// </summary>
 /// <param name="e">An <see cref="DotRas.StateChangedEventArgs"/> containing event data.</param>
 private void OnStateChanged(DME.Dialer.StateChangedEventArgs e)
 {
     this.RaiseEvent<DME.Dialer.StateChangedEventArgs>(this.StateChanged, e);
 }
Example #16
0
 /// <summary>
 /// Raises the <see cref="RasDialer.DialCompleted"/> event.
 /// </summary>
 /// <param name="e">An <see cref="DotRas.DialCompletedEventArgs"/> containing event data.</param>
 private void OnDialCompleted(DME.Dialer.DialCompletedEventArgs e)
 {
     this.RaiseEvent<DME.Dialer.DialCompletedEventArgs>(this.DialCompleted, e);
 }
Example #17
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Dialer_DialCompleted(object sender, DME.Dialer.DialCompletedEventArgs e)
 {
     if (DialCompleted != null)
     {
         this.DialCompleted(this, e);
     }
 }