Example #1
0
        private async void BtnAddMapping_Click(object sender, RoutedEventArgs e)
        {
            int pubPort = TbPublicPort.ToInt();

            if (!InputConstraints.EnsureBetween(1, ushort.MaxValue, pubPort, "Public Port"))
            {
                return;
            }

            int privPort = TbPrivatePort.ToInt();

            if (!InputConstraints.EnsureBetween(1, ushort.MaxValue, privPort, "Private Port"))
            {
                return;
            }

            string description = string.IsNullOrWhiteSpace(TbDescription.Text)
                ? string.Empty : TbDescription.Text;

            int lifetimeHours = TbLifetime.ToInt();

            if (!InputConstraints.EnsureBetween(0, 596523, lifetimeHours, "Lifetime"))
            {
                return;
            }

            lifetimeHours *= 3600;

            List <Mapping> mappings = new List <Mapping>(2);

            if ((bool)CbTCP.IsChecked)
            {
                mappings.Add(new Mapping(Protocol.Tcp, TbPrivateIP.IPAddress,
                                         privPort, pubPort, lifetimeHours, description));
            }
            if ((bool)CbUDP.IsChecked)
            {
                mappings.Add(new Mapping(Protocol.Udp, TbPrivateIP.IPAddress,
                                         privPort, pubPort, lifetimeHours, description));
            }

            if (mappings.Count < 1) //This should never happen!
            {
                MessageBox.Show("No valid UPnP mapping configuration was entered.\nSelect at least one protocol."
                                , "Error", MessageBoxButton.OK, MessageBoxImage.Error); return;
            }

            SetBusy(true);
            if (await AddMappings(mappings))
            {
                m_didUpdate = true;
                Close();
            }
            SetBusy(false);
        }
Example #2
0
    /** \brief Controls the flow of the program
     *  \param args List of command-line arguments
     */
    public static void Main(string[] args)
    {
        string          filename = args[0];
        InputParameters inParams = new InputParameters();
        double          g        = 9.8;
        double          pi       = 3.14159265;
        double          epsilon  = 2.0e-2;

        InputFormat.get_input(inParams, filename);
        InputConstraints.input_constraints(inParams, pi);
        double t_flight = Calculations.func_t_flight(inParams, g);
        double p_land   = Calculations.func_p_land(inParams, g);
        double d_offset = Calculations.func_d_offset(inParams, p_land);
        string s        = Calculations.func_s(inParams, epsilon, d_offset);

        OutputFormat.write_output(s, d_offset);
    }
Example #3
0
    /** \brief Controls the flow of the program
     *  \param args List of command-line arguments
     */
    public static void Main(string[] args)
    {
        StreamWriter outfile;
        string       filename = args[0];

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'filename' assigned ");
        outfile.Write(filename);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        InputParameters inParams = new InputParameters();

        InputFormat.get_input(filename, inParams);
        DerivedValues.derived_values(inParams, inParams.F_vect_1, inParams.x_1, inParams.x_2);
        InputConstraints.input_constraints(inParams, pi);
        double F_vect_AC = Calculations.func_F_vect_AC(inParams);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'F_vect_AC' assigned ");
        outfile.Write(F_vect_AC);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        double F_vect_BC = Calculations.func_F_vect_BC(inParams);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'F_vect_BC' assigned ");
        outfile.Write(F_vect_BC);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        double F_vect_AD = Calculations.func_F_vect_AD(inParams, F_vect_AC);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'F_vect_AD' assigned ");
        outfile.Write(F_vect_AD);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        double F_vect_BD = Calculations.func_F_vect_BD(inParams, F_vect_BC);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'F_vect_BD' assigned ");
        outfile.Write(F_vect_BD);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        OutputFormat.write_output(inParams, F_vect_AC, F_vect_AD, F_vect_BC, F_vect_BD);
    }
Example #4
0
 private void OnPreviewTextInput(object sender, TextCompositionEventArgs e)
 => InputConstraints.NumericTextbox(sender, e);
Example #5
0
    /** \brief Controls the flow of the program
     *  \param args List of command-line arguments
     */
    public static void Main(string[] args)
    {
        StreamWriter outfile;
        string       filename = args[0];

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'filename' assigned to ");
        outfile.Write(filename);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        InputParameters inParams = new InputParameters();

        InputFormat.get_input(inParams, filename);
        DerivedValues.derived_values(inParams);
        InputConstraints.input_constraints(inParams);
        double J_tol = Calculations.func_J_tol(inParams);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'J_tol' assigned to ");
        outfile.Write(J_tol);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        double q = Calculations.func_q(inParams);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'q' assigned to ");
        outfile.Write(q);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        double q_hat = Calculations.func_q_hat(inParams, q);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'q_hat' assigned to ");
        outfile.Write(q_hat);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        double q_hat_tol = Calculations.func_q_hat_tol(inParams, J_tol);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'q_hat_tol' assigned to ");
        outfile.Write(q_hat_tol);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        double J = Calculations.func_J(inParams, q_hat);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'J' assigned to ");
        outfile.Write(J);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        double NFL = Calculations.func_NFL(inParams, q_hat_tol);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'NFL' assigned to ");
        outfile.Write(NFL);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        double B = Calculations.func_B(inParams, J);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'B' assigned to ");
        outfile.Write(B);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        double LR = Calculations.func_LR(inParams, NFL);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'LR' assigned to ");
        outfile.Write(LR);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        Boolean is_safeLR = Calculations.func_is_safeLR(LR, q);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'is_safeLR' assigned to ");
        outfile.Write(is_safeLR);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        double P_b = Calculations.func_P_b(B);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'P_b' assigned to ");
        outfile.Write(P_b);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        Boolean is_safePb = Calculations.func_is_safePb(inParams, P_b);

        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'is_safePb' assigned to ");
        outfile.Write(is_safePb);
        outfile.WriteLine(" in module Control");
        outfile.Close();
        OutputFormat.write_output(is_safePb, is_safeLR, P_b);
    }