Esempio n. 1
0
        private void btn_MeterCalc_Click(object sender, EventArgs e)
        {
            double.TryParse(txt_U.Text, out double Ub);
            double.TryParse(txt_I.Text, out double Ib);
            double.TryParse(txt_C.Text, out double C);
            double m = 1;

            switch (cmb_TestMode.Text)
            {
            case "1P2W": m = 1; break;

            case "3P3W": m = Math.Sqrt(3); break;

            case "3P4W": m = 3; break;
            }
            double factor  = 1;
            bool   IsMinus = false;

            if (!string.IsNullOrWhiteSpace(txt_PF.Text))
            {
                double.TryParse(txt_PF.Text, out factor);
                if (txt_PF.Text.IndexOf("-") >= 0)
                {
                    IsMinus = true;
                }
                if (cmb_FR.Text == "Reverse")
                {
                    IsMinus = true;
                }
            }
            double s     = Ub * Ib * m;
            double power = s * factor;
            double CFreq = Math.Abs(power * C / 3600 / 1000);
            double CTime = 0;

            if (CFreq != 0)
            {
                CTime = 1 / CFreq;
            }
            double seconds = CTime * C;

            double angle = Math.Acos(Math.Abs(factor)) / Math.PI * 180;

            if (IsMinus)
            {
                angle = angle + 180;
            }
            if ("Capacitive".Equals(cmb_LC.Text))
            {
                angle = angle * -1;
                if (angle < 0)
                {
                    angle = angle + 360;
                }
            }
            txt_P.Text            = power.ToString();
            txt_Q.Text            = Math.Sqrt(s * s - power * power).ToString();
            txt_S.Text            = s.ToString();
            txt_A.Text            = angle.ToString();
            txt_CHz.Text          = CFreq.ToString();
            txt_OnePulseTime.Text = CTime.ToString();
            txt_TimePerkWh.Text   = seconds.ToString();
            txt_MinPerkWh.Text    = (seconds / 60F).ToString();

            PowerHelper.CalculatePhaseDegree($"M{cmb_TestMode.Text}", cmb_PQ.Text, cmb_FR.Text, cmb_HABC.Text, factor, cmb_LC.Text, cmb_clockwise.Text == "anticlockwise", out PowerHelper.PhiParam phis);
            txt_PhiU1.Text = phis.PhiUa.ToString();
            txt_PhiU2.Text = phis.PhiUb.ToString();
            txt_PhiU3.Text = phis.PhiUc.ToString();
            txt_PhiI1.Text = phis.PhiIa.ToString();
            txt_PhiI2.Text = phis.PhiIb.ToString();
            txt_PhiI3.Text = phis.PhiIc.ToString();
            PMS.Platform.Utility.VectorHelper vector = new PMS.Platform.Utility.VectorHelper()
            {
                UL1Angle = (float)phis.PhiUa,
                UL2Angle = (float)phis.PhiUb,
                UL3Angle = (float)phis.PhiUc,
                IL1Angle = (float)phis.PhiIa,
                IL2Angle = (float)phis.PhiIb,
                IL3Angle = (float)phis.PhiIc,
            };
            switch (cmb_TestMode.Text)
            {
            case "1P2W":
                vector.UL2Value = 0;
                vector.UL3Value = 0;
                vector.IL2Value = 0;
                vector.IL3Value = 0;
                break;

            case "3P3W":
                vector.IL2Value = 0;
                break;

            case "3P4W":
                break;
            }
            if (vector.DrawVector())
            {
                pic_phase.Image = PicHelper.GetBitmap(vector.VectorFullPath);
            }
            else
            {
                pic_phase.Image = null;
            }
        }
Esempio n. 2
0
        private void Btn_CalcSequenceComponent_Click(object sender, EventArgs e)
        {
            double.TryParse(txt_scUa.Text, out double Ua);
            double.TryParse(txt_scPhiUa.Text, out double PhiUa);
            double.TryParse(txt_scUb.Text, out double Ub);
            double.TryParse(txt_scPhiUb.Text, out double PhiUb);
            double.TryParse(txt_scUc.Text, out double Uc);
            double.TryParse(txt_scPhiUc.Text, out double PhiUc);

            double.TryParse(txt_scIa.Text, out double Ia);
            double.TryParse(txt_scPhiIa.Text, out double PhiIa);
            double.TryParse(txt_scIb.Text, out double Ib);
            double.TryParse(txt_scPhiIb.Text, out double PhiIb);
            double.TryParse(txt_scIc.Text, out double Ic);
            double.TryParse(txt_scPhiIc.Text, out double PhiIc);

            PMS.Platform.Utility.VectorHelper vector = new PMS.Platform.Utility.VectorHelper()
            {
                UL1Angle = (float)PhiUa,
                UL2Angle = (float)PhiUb,
                UL3Angle = (float)PhiUc,
                IL1Angle = (float)PhiIa,
                IL2Angle = (float)PhiIb,
                IL3Angle = (float)PhiIc,
            };
            if (vector.DrawVector())
            {
                pic_phase.Image = PicHelper.GetBitmap(vector.VectorFullPath);
            }
            else
            {
                pic_phase.Image = null;
            }

            string format = "F3";

            PhaseSequence sequence = new PhaseSequence();

            {
                Polar vUa = new Polar(Ua, PhiUa);
                Polar vUb = new Polar(Ub, PhiUb);
                Polar vUc = new Polar(Uc, PhiUc);

                PSData vPositiveU = sequence.CalcPositive(vUa, vUb, vUc);

                txt_scPositiveU.Text    = vPositiveU.Amplitude.ToString(format);
                txt_scPositivePhiU.Text = vPositiveU.Phase.ToString(format);

                PSData vNegativeU = sequence.CalcNegative(vUa, vUb, vUc);

                txt_scNegativeU.Text    = vNegativeU.Amplitude.ToString(format);
                txt_scNegativePhiU.Text = vNegativeU.Phase.ToString(format);

                PSData vZeroU = sequence.CalcZero(vUa, vUb, vUc);

                txt_scZeroU.Text    = vZeroU.Amplitude.ToString(format);
                txt_scZeroPhiU.Text = vZeroU.Phase.ToString(format);
            }

            {
                Polar vIa = new Polar(Ia, PhiIa);
                Polar vIb = new Polar(Ib, PhiIb);
                Polar vIc = new Polar(Ic, PhiIc);

                PSData vPositiveI = sequence.CalcPositive(vIa, vIb, vIc);

                txt_scPositiveI.Text    = vPositiveI.Amplitude.ToString(format);
                txt_scPositivePhiI.Text = vPositiveI.Phase.ToString(format);

                PSData vNegativeI = sequence.CalcNegative(vIa, vIb, vIc);

                txt_scNegativeI.Text    = vNegativeI.Amplitude.ToString(format);
                txt_scNegativePhiI.Text = vNegativeI.Phase.ToString(format);

                PSData vZeroI = sequence.CalcZero(vIa, vIb, vIc);

                txt_scZeroI.Text    = vZeroI.Amplitude.ToString(format);
                txt_scZeroPhiI.Text = vZeroI.Phase.ToString(format);
            }
        }