예제 #1
0
        public SkinEffectActivity() : base(Resource.Layout.skin_effect_layout)
        {
            Loaded += delegate
            {
                //
                var tbFrequency    = FindViewById <EditText>(Resource.Id.tb_frequency);
                var tbResitivity   = FindViewById <EditText>(Resource.Id.tb_resistivity);
                var tbPermeability = FindViewById <EditText>(Resource.Id.tb_permeability);
                var lbOutput       = FindViewById <TextView>(Resource.Id.lb_output);

                FindViewById <Button>(Resource.Id.btn_evaluate).Click += delegate
                {
                    if (double.TryParse(tbPermeability.Text, out var pm) &&
                        double.TryParse(tbFrequency.Text, out var freq) &&
                        double.TryParse(tbResitivity.Text, out var resistivity))
                    {
                        double a         = Math.PI * pm * freq;
                        var    SkinDepth = resistivity / a;
                        var    b         = Math.Sqrt(SkinDepth);
                        lbOutput.Text = b.ToString();
                    }
                    else
                    {
                        ToastHelpers.ShowRequiredInputs(this);
                    }
                };
            };
        }
예제 #2
0
        public RadarRangeActivity() : base(Resource.Layout.radar_range_layout)
        {
            Loaded += delegate
            {
                var tbPulsePeakPower   = FindViewById <EditText>(Resource.Id.tb_pulse_peak_power);
                var tbMaxPowerGain     = FindViewById <EditText>(Resource.Id.tb_max_power_gain);
                var tbAntennaAperture  = FindViewById <EditText>(Resource.Id.tb_antenna_aperture);
                var tbCrossSectionArea = FindViewById <EditText>(Resource.Id.tb_cross_section_area);
                var tbPowerReceived    = FindViewById <EditText>(Resource.Id.tb_power_received);
                var lbResult           = FindViewById <TextView>(Resource.Id.lb_output);

                //
                FindViewById <Button>(Resource.Id.btn_evaluate).Click += delegate
                {
                    if (double.TryParse(tbPulsePeakPower.Text, out var pulsePeakPower) &&
                        double.TryParse(tbMaxPowerGain.Text, out var maxPowerGain) &&
                        double.TryParse(tbAntennaAperture.Text, out var aperture) &&
                        double.TryParse(tbCrossSectionArea.Text, out var crossSectionArea) &&
                        double.TryParse(tbPowerReceived.Text, out var powerReceived))
                    {
                        lbResult.Text = ((pulsePeakPower * maxPowerGain * aperture * crossSectionArea) / (Math.Pow(88.0 / 7.0, 2) * powerReceived)).ToString();
                    }
                    else
                    {
                        ToastHelpers.ShowRequiredInputs(this);
                    }
                };
            };
        }
        public SimultaneousEquationActivity()
            : base(Resource.Layout.simultaneous_equation_layout)
        {
            Loaded += delegate
            {
                //
                var tbA = FindViewById<EditText>(Resource.Id.tb_a);
                var tbB = FindViewById<EditText>(Resource.Id.tb_b);
                var tbC = FindViewById<EditText>(Resource.Id.tb_c);
                var tbD = FindViewById<EditText>(Resource.Id.tb_d);
                var tbE = FindViewById<EditText>(Resource.Id.tb_e);
                var tbF = FindViewById<EditText>(Resource.Id.tb_f);
                var lbX = FindViewById<TextView>(Resource.Id.lb_output_x);
                var lbY = FindViewById<TextView>(Resource.Id.lb_output_y);

                //
                FindViewById<Button>(Resource.Id.btn_evaluate).Click += delegate
                {
                    if (double.TryParse(tbA.Text, out var a) &&
                        double.TryParse(tbB.Text, out var b) &&
                        double.TryParse(tbC.Text, out var c) &&
                        double.TryParse(tbD.Text, out var d) &&
                        double.TryParse(tbE.Text, out var e) &&
                        double.TryParse(tbF.Text, out var f))
                    {
                        //
                        double y = ((a * f) - (d * c)) / ((a * e) - (b * d));
                        double x = (c - (b * y)) / a;

                        lbX.Text = x.ToString("N");
                        lbY.Text = y.ToString("N");
                    }
                    else
                    {
                        ToastHelpers.ShowRequiredInputs(this);
                    }
                };

            };
        }
        public CapacitiveReactanceActivity() : base(Resource.Layout.capacitive_reactance_layout)
        {
            Loaded += delegate
            {
                //
                var tbCapacitanceFreq = FindViewById <EditText>(Resource.Id.tb_capacitive_freq);
                var tbCapCapacitance  = FindViewById <EditText>(Resource.Id.tb_capacitive_capacitance);
                var lbCapacitanceOut  = FindViewById <TextView>(Resource.Id.lb_capacitance_out);

                //
                var tbInductiveFreq       = FindViewById <EditText>(Resource.Id.tb_inductive_freq);
                var tbInductiveInductance = FindViewById <EditText>(Resource.Id.tb_inductive_inductance);
                var lbInductanceOut       = FindViewById <TextView>(Resource.Id.lb_inductance_out);

                //
                FindViewById <Button>(Resource.Id.btn_evaluate_capacitance).Click += delegate
                {
                    if (double.TryParse(tbCapacitanceFreq.Text, out var freq) && double.TryParse(tbCapCapacitance.Text, out var cap))
                    {
                        lbCapacitanceOut.Text = (1.0 / (2.0 * Math.PI * freq * cap)).ToString();
                    }
                    else
                    {
                        ToastHelpers.ShowRequiredInputs(this);
                    }
                };

                FindViewById <Button>(Resource.Id.btn_evaluate_reactance).Click += delegate
                {
                    if (double.TryParse(tbInductiveFreq.Text, out var freq) && double.TryParse(tbInductiveInductance.Text, out var inductance))
                    {
                        lbInductanceOut.Text = (2.0 * Math.PI * freq * inductance).ToString();
                    }
                    else
                    {
                        ToastHelpers.ShowRequiredInputs(this);
                    }
                };
            };
        }
        public PowerDensityCalculatorActivity() : base(Resource.Layout.power_density_layout)
        {
            Loaded += delegate
            {
                var tbPower    = FindViewById <EditText>(Resource.Id.tb_power);
                var tbGain     = FindViewById <EditText>(Resource.Id.tb_gain);
                var tbDistance = FindViewById <EditText>(Resource.Id.tb_distance);

                var powerUnitSpinner = FindViewById <Spinner>(Resource.Id.spinner_out_power_unit);
                var gainUnitSpinner  = FindViewById <Spinner>(Resource.Id.spinner_gain_unit);
                var distanceSpinner  = FindViewById <Spinner>(Resource.Id.spinner_distancer_unit);

                //
                var lbOutput = FindViewById <TextView>(Resource.Id.lb_output);

                //
                powerUnitSpinner.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, new string[]
                {
                    "mW",
                    "dbM",
                    "dBW",
                    "W"
                });

                gainUnitSpinner.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, new string[]
                {
                    "Linear"
                });

                distanceSpinner.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, new string[]
                {
                    "Inches",
                    "Yards",
                    "Miles",
                    "Feets",
                    "Metres"
                });

                FindViewById <Button>(Resource.Id.btn_evaluate).Click += delegate
                {
                    if (double.TryParse(tbPower.Text, out var pOut) &&
                        double.TryParse(tbDistance.Text, out var D) &&
                        double.TryParse(tbGain.Text, out var gain))
                    {
                        switch (powerUnitSpinner.SelectedItemPosition)
                        {
                        case 0:
                            pOut = pOut / 100.0;
                            break;

                        case 1:
                            pOut = Math.Pow(10, pOut / 10.0) / 1000.0;
                            break;

                        case 2:
                            pOut = Math.Pow(10, pOut / 10.0);
                            break;
                        }

                        switch (distanceSpinner.SelectedItemPosition)
                        {
                        case 0:
                            D = 0.0254 * D;
                            break;

                        case 1:
                            D = 0.9144 * D;
                            break;

                        case 2:
                            D = 1609.344 * D;
                            break;

                        case 3:
                            D = D * 0.3048;
                            break;
                        }

                        //
                        double power = (pOut * gain) / (4 * Math.PI * (D * D));
                        lbOutput.Text = power.ToString();
                    }
                    else
                    {
                        ToastHelpers.ShowRequiredInputs(this);
                    }
                };
            };
        }
예제 #6
0
        public NewtonRaphsonActivity() : base(Resource.Layout.newton_raphson_layout)
        {
            Loaded += delegate
            {
                //
                var tbA  = FindViewById <EditText>(Resource.Id.tb_a);
                var tbB  = FindViewById <EditText>(Resource.Id.tb_b);
                var tbC  = FindViewById <EditText>(Resource.Id.tb_c);
                var tbD  = FindViewById <EditText>(Resource.Id.tb_d);
                var lbX1 = FindViewById <TextView>(Resource.Id.lb_x1);
                var lbX2 = FindViewById <TextView>(Resource.Id.lb_x2);
                var lbX3 = FindViewById <TextView>(Resource.Id.lb_x3);

                FindViewById <Button>(Resource.Id.btn_evaluate).Click += delegate
                {
                    if (double.TryParse(tbA.Text, out var a) && double.TryParse(tbB.Text, out var b) &&
                        double.TryParse(tbC.Text, out var c) && double.TryParse(tbD.Text, out var d))
                    {
                        double x  = 1;
                        double y1 = 3 * a * x * x + 2 * b * x + c;

                        if (y1 == 0)
                        {
                            x  = x + 0.5;
                            y1 = 3 * a * x * x + 2 * b * x + c;
                        }

                        int i = 0;

                        double y2 = a * x * x * x + b * x * x + c * x + d;
                        double y  = x - y2 / y1;
                        while (x != y && i != 100)
                        {
                            i  = i + 1;
                            x  = y;
                            y1 = 3 * a * x * x + 2 * b * x + c;
                            y2 = a * x * x * x + b * x * x + c * x + d;
                            y  = x - y2 / y1;
                        }
                        double xo = x;

                        double x1 = -1;
                        x  = x1;
                        y1 = 3 * a * x * x + 2 * b * x + c;

                        if (y1 == 0)
                        {
                            x  = x + 0.5;
                            y1 = 3 * a * x * x + 2 * b * x + c;
                        }
                        int i1 = 0;

                        y2 = a * x * x * x + b * x * x + c * x + d;
                        y  = x - y2 / y1;
                        while (x != y && i1 != 100)
                        {
                            i = i1 + 1;
                            x = y;

                            y1 = 3 * a * x * x + 2 * b * x + c;
                            y2 = a * x * x * x + b * x * x + c * x + d;
                            y  = x - y2 / y1;
                        }

                        x1 = x;



                        double x2 = 15;
                        x  = x2;
                        y1 = 3 * a * x * x + 2 * b * x + c;

                        if (y1 == 0)
                        {
                            x  = x + 0.5;
                            y1 = 3 * a * x * x + 2 * b * x + c;
                        }
                        int i2 = 0;

                        y2 = a * x * x * x + b * x * x + c * x + d;
                        y  = x - y2 / y1;
                        while (x != y && i2 != 100)
                        {
                            i  = i + 1;
                            x  = y;
                            y1 = 3 * a * x * x + 2 * b * x + c;
                            y2 = a * x * x * x + b * x * x + c * x + d;
                            y  = x - y2 / y1;
                        }

                        x2 = x;

                        //
                        lbX1.Text = xo.ToString();

                        if (x1 != xo && x1 != x2)
                        {
                            lbX2.Text = x1.ToString();
                        }
                        else
                        {
                            lbX2.Text = "0";
                        }

                        if (x2 != xo && x2 != x1)
                        {
                            lbX3.Text = x2.ToString();
                        }
                        else
                        {
                            lbX3.Text = "0";
                        }
                    }
                    else
                    {
                        ToastHelpers.ShowRequiredInputs(this);
                    }
                };
            };
        }