Пример #1
0
 public void SetVoltage(string InputName, Voltage Voltage)
 {
     try {
         allInputs.Find(i => i.name.Equals(InputName)).voltage = Voltage;
     } catch {
         throw new KeyNotFoundException();
     }
 }
Пример #2
0
 /// <summary>
 /// Creates new Voltages object with all of the phases specified
 /// </summary>
 /// <param name="thesePhases"></param>
 public Voltages(PhaseCode thesePhases) 
 {
     phasesPresent = thesePhases;
     phaseVoltages = new Dictionary<SinglePhaseType, Voltage>();
     var phaseArray = thesePhases.ToSinglePhaseTypeList();
     foreach (SinglePhaseType phase in phaseArray)
     {
         phaseVoltages[phase] = new Voltage(this, phase);
     }
 }
Пример #3
0
 /// <summary>
 /// Returns an array of all of the voltages that correspond to the flags present in the given PhaseCode
 /// </summary>
 /// <param name="phases"></param>
 /// <returns></returns>
 public Voltage[] this[PhaseCode phases]
 {
     get 
     {
         var phaseList = phases.ToSinglePhaseTypeList();
         var voltageArray = new Voltage[phaseList.Count];
         for (int i = 0; i < phaseList.Count; i++)
         {
             voltageArray[i] = phaseVoltages[phaseList[i]];
         }
         return voltageArray;
     }
     
 }
Пример #4
0
 public void ToInt32Test()
 {
     IConvertible target = new Voltage(10F);
     IFormatProvider provider = null;
     int expected = 10;
     int actual;
     actual = target.ToInt32(provider);
     Assert.AreEqual(expected, actual);
 }
Пример #5
0
 public void ToBooleanTest()
 {
     IConvertible target = new Voltage(10F);
     IFormatProvider provider = null;
     bool expected = true;
     bool actual;
     actual = target.ToBoolean(provider);
     Assert.AreEqual(expected, actual);
 }
Пример #6
0
 public void ParseStyleProviderTest()
 {
     double value = 10F;
     string s = value.ToString();
     NumberStyles style = new NumberStyles();
     IFormatProvider provider = null;
     Voltage expected = new Voltage(value);
     Voltage actual;
     actual = Voltage.Parse(s, style, provider);
     Assert.AreEqual(expected, actual);
 }
Пример #7
0
 public void op_GreaterThanTest()
 {
     Voltage value1 = new Voltage(10F);
     Voltage value2 = new Voltage(9F);
     bool expected = true;
     bool actual;
     actual = (value1 > value2);
     Assert.AreEqual(expected, actual);
 }
Пример #8
0
        public void VoltageConstructorTest()
        {
            List<Double> values = new List<Double>();

            //Initialization
            values.Add(0);

            foreach (Double value in values)
            {
                Voltage target = new Voltage(value);
                Assert.IsInstanceOfType(target, typeof(Voltage));
                Assert.IsNotNull(target);
            }
            values.Clear();

        }
Пример #9
0
 public void ToStatvoltsTest()
 {
     Voltage target = new Voltage(10F);
     double expected = 0.0333564095198152;
     double actual;
     actual = target.ToStatvolts();
     Assert.AreEqual(expected, actual);
 }
Пример #10
0
 public void TryParseTest()
 {
     double value = 10F;
     string s = value.ToString();
     Voltage result = new Voltage(value);
     Voltage resultExpected = new Voltage(value);
     bool expected = true;
     bool actual;
     actual = Voltage.TryParse(s, out result);
     Assert.AreEqual(resultExpected, result);
     Assert.AreEqual(expected, actual);
 }
Пример #11
0
 public MagneticFieldStrength(Voltage v, Time t, Area a)
 {
     _teslas = v.TotalVolts * t.TotalSeconds / a.TotalSquareMeters;
 }
Пример #12
0
 public void ToSingleTest()
 {
     IConvertible target = new Voltage(10F);
     IFormatProvider provider = null;
     float expected = 10F;
     float actual;
     actual = target.ToSingle(provider);
     Assert.AreEqual(expected, actual);
 }
Пример #13
0
 public void Reset()
 {
     this.OnAnyTextChanged = null;
     this._PerfEntry       = null;
     this.InternalReset();
 }
Пример #14
0
        /// <inheritdoc />
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!this.initialized)
            {
                this.Initialize();
            }

            var message = this.errorText.ToString();

            if (!(targetType == typeof(Voltage) || targetType == typeof(Voltage?)))
            {
                message += $"{this.GetType().Name} does not support converting to {targetType.Name}";
            }

            if (message != string.Empty)
            {
                message = message.TrimEnd('\r', '\n');
                if (Is.DesignMode)
                {
                    throw new InvalidOperationException(message);
                }

                return(message);
            }

            if (value == null)
            {
                return(null);
            }

            if (value is double)
            {
                return(new Voltage((double)value, this.unit.Value));
            }

            var text = value as string;

            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            var unitInput = this.UnitInput ?? Wpf.UnitInput.ScalarOnly;

            switch (unitInput)
            {
            case Wpf.UnitInput.ScalarOnly:
            {
                double d;
                if (double.TryParse(text, NumberStyles.Float, culture, out d))
                {
                    return(new Voltage(d, this.unit.Value));
                }

                Voltage result;
                if (Voltage.TryParse(text, NumberStyles.Float, culture, out result))
                {
                    return($"#{text}#");        // returning modified text so that TypeConverter fails and we get an error
                }

                return(text);        // returning raw to trigger error
            }

            case Wpf.UnitInput.SymbolAllowed:
            {
                double d;
                int    pos = 0;
                WhiteSpaceReader.TryRead(text, ref pos);
                if (DoubleReader.TryRead(text, ref pos, NumberStyles.Float, culture, out d))
                {
                    WhiteSpaceReader.TryRead(text, ref pos);
                    if (pos == text.Length)
                    {
                        return(new Voltage(d, this.unit.Value));
                    }
                }

                goto case Wpf.UnitInput.SymbolRequired;
            }

            case Wpf.UnitInput.SymbolRequired:
            {
                Voltage result;
                if (Voltage.TryParse(text, NumberStyles.Float, culture, out result))
                {
                    return(result);
                }

                return(text);
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #15
0
        public override object ReadJson(JsonReader reader, Type objectType, object?existingValue, JsonSerializer serializer)
        {
            var stringValue = (string)reader.Value !;

            return(Voltage.Parse(stringValue, serializer.Culture));
        }
Пример #16
0
 // переозначення конструктора
 public CapacitorBank(string code, string type, double Q, Voltage ratedVoltage = Voltage.v220) :
     base(code, new Power(0, -Math.Abs(Q)), ratedVoltage)
 {
     this.type = type;
 }
Пример #17
0
 // переозначення конструктора та виклик конструктора з базового класу
 public RegularLoad(string code, string customer, double P, double Q, Voltage ratedVoltage = Voltage.v220) :
     base(code, new Power(P, Q), ratedVoltage)
 {
     this.customer = customer;
 }
Пример #18
0
 public void ToUInt64Test()
 {
     IConvertible target = new Voltage(10F);
     IFormatProvider provider = null;
     ulong expected = 10;
     ulong actual;
     actual = target.ToUInt64(provider);
     Assert.AreEqual(expected, actual);
 }
        private ObservableCollection <Card> FindPrVoltage(string pr, string sec)
        {
            ObservableCollection <Card> res = new ObservableCollection <Card>();

            string[] volt;
            Voltage  a = null;

            if (pr != null)
            {
                volt = pr.Split('-');
                a    = new Voltage(volt);
            }
            List <Voltage> b = new List <Voltage>();

            if (sec != null)
            {
                volt = sec.Split('/');
                b    = new List <Voltage>();
                foreach (var item in volt)
                {
                    Voltage c = new Voltage(item.Split('-'));
                    b.Add(c);
                }
            }
            bool contains = false;

            foreach (var item in Collection.Cards)
            {
                foreach (var i in a.Values)
                {
                    contains = item.Pr_Voltage.Values.Contains(i);
                    if (!contains)
                    {
                        break;
                    }
                }
                if (contains)
                {
                    res.Add(item);
                }
            }
            contains = false;
            ObservableCollection <Card> res1 = new ObservableCollection <Card>();

            foreach (var item in res)
            {
                foreach (var iter in item.Sec_Voltage)
                {
                    foreach (var intel in b)
                    {
                        foreach (var intellij in intel.Values)
                        {
                            contains = iter.Values.Contains(intellij);
                            if (!contains)
                            {
                                break;
                            }
                        }
                    }
                }
                if (contains)
                {
                    res1.Add(item);
                }
            }
            return(res1);
        }
Пример #20
0
 public void ToStringFormatTest()
 {
     double value = 10F;
     Voltage target = new Voltage(value);
     string format = string.Empty;
     string expected = value.ToString();
     string actual;
     actual = target.ToString(format);
     Assert.AreEqual(expected, actual);
 }
Пример #21
0
 public TeslaSilnik(int moc, double spalanie, string dzwiek, double horsePower, Voltage voltage) : base(moc, spalanie, dzwiek)
 {
     HorsePower = horsePower;
     Voltage    = voltage;
 }
Пример #22
0
 public void op_DivisionTest()
 {
     Voltage value1 = new Voltage(10F);
     Voltage value2 = new Voltage(10F);
     Voltage expected = new Voltage(1F);
     Voltage actual;
     actual = (value1 / value2);
     Assert.AreEqual(expected, actual);
 }
Пример #23
0
 /// <summary>
 /// Converts between various units of electrical voltage.
 /// </summary>
 /// <param name="oldVal">the value to be converted</param>
 /// <param name="oldUnit">the original unit of measure</param>
 /// <param name="newUnit">the new unit of measure</param>
 /// <returns></returns>
 public static double ConvertVoltage(double oldVal, Voltage oldUnit, Voltage newUnit)
 {
     // Look up conversion from old unit to new unit.
     return(oldVal / VoltageConversion[oldUnit] * VoltageConversion[newUnit]);
 }
Пример #24
0
 public void op_ImplicitTest1()
 {
     double value = 10F;
     Voltage expected = new Voltage(value);
     Voltage actual;
     actual = value;
     Assert.AreEqual(expected, actual);
 }
Пример #25
0
 public static void Upgrade(Voltage valtage)
 {
     Console.WriteLine("Допустимое значение напряжения :{0}", valtage());
 }
Пример #26
0
 public void op_ModulusTest()
 {
     Voltage value1 = new Voltage(10F);
     Voltage value2 = new Voltage(10F);
     Voltage expected = new Voltage(0F);
     Voltage actual;
     actual = (value1 % value2);
     Assert.AreEqual(expected, actual);
 }
Пример #27
0
 public override string ToString()
 {
     return($"emeter,collector={Environment.MachineName},host={EscapeString(Host)},alias={EscapeString(Alias)} voltage={Voltage.ToString(CultureInfo.InvariantCulture)},current={Current.ToString(CultureInfo.InvariantCulture)},power={Power.ToString(CultureInfo.InvariantCulture)},total={TotalPower.ToString(CultureInfo.InvariantCulture)} {Timestamp}");
 }
Пример #28
0
 public void ParseStyleTest()
 {
     double value = 10F;
     string s = value.ToString();
     NumberStyles style = new NumberStyles();
     Voltage expected = new Voltage(value);
     Voltage actual;
     actual = Voltage.Parse(s, style);
     Assert.AreEqual(expected, actual);
 }
Пример #29
0
 public static PowerValue ToPowerValue(this Voltage voltage, IPowerMode powerMode)
 => voltage == powerMode.On
         ? PowerValue.On
         : PowerValue.Off;
Пример #30
0
 public void ParseTest()
 {
     double value = 10F;
     string s = value.ToString();
     Voltage expected = new Voltage(value);
     Voltage actual;
     actual = Voltage.Parse(s);
     Assert.AreEqual(expected, actual);
 }
Пример #31
0
 public GUI_Settings()
 {
     this.prot = Protocol.MANCHESTER;
     this.volt = Voltage.V3_3;
     this.conn = Connector.P10;
 }
Пример #32
0
 public void ToDecimalTest()
 {
     IConvertible target = new Voltage(10F);
     IFormatProvider provider = null;
     Decimal expected = new Decimal(10F);
     Decimal actual;
     actual = target.ToDecimal(provider);
     Assert.AreEqual(expected, actual);
 }
Пример #33
0
 public override string GetHelpText() => $"Voltage = {Voltage.ToString("f3")} V{Environment.NewLine}Current = {Current.ToString("f3")} A{Environment.NewLine}Wattage = {ActivePower.ToString("f2")} Watts";
Пример #34
0
 public void ToSByteTest()
 {
     IConvertible target = new Voltage(10F);
     IFormatProvider provider = null;
     sbyte expected = 10;
     sbyte actual;
     actual = target.ToSByte(provider);
     Assert.AreEqual(expected, actual);
 }
Пример #35
0
 public override string ToString()
 {
     return($"Ch{Channel.ToString().PadLeft(5,' ')} {Voltage.ToString("0.0000").PadLeft(10, ' ')} V");
 }
Пример #36
0
 public void ToTypeTest()
 {
     IConvertible target = new Voltage(10F);
     Type conversionType = typeof(Double);
     IFormatProvider provider = null;
     object expected = new Voltage(10F);
     object actual;
     actual = target.ToType(conversionType, provider);
     Assert.AreEqual(expected, actual);
 }
Пример #37
0
 public override string ToString()
 {
     return("Current:" + Current.ToString() + " Voltage:" + Voltage.ToString() + " Power:" + Power.ToString() + Environment.NewLine);
 }
Пример #38
0
 public void ToAbvoltsTest()
 {
     Voltage target = new Voltage(10F);
     double expected = 1000000000.0;
     double actual;
     actual = target.ToAbvolts();
     Assert.AreEqual(expected, actual);
 }
Пример #39
0
        private void RedrawOthersInfoText()
        {
            BorderTextLabel airspeedlabel = new BorderTextLabel();

            airspeedlabel.Stroke     = Brushes.DimGray;
            airspeedlabel.Foreground = Brushes.White;
            airspeedlabel.FontSize   = 14;
            airspeedlabel.FontWeight = FontWeights.Bold;
            airspeedlabel.Text       = "空速  " + AirSpeed.ToString("0.0");
            Canvas.SetLeft(airspeedlabel, 4);
            Canvas.SetTop(airspeedlabel, 80);
            Canvas_ViewPortLeft.Children.Add(airspeedlabel);

            BorderTextLabel groundspeedlabel = new BorderTextLabel();

            groundspeedlabel.Stroke     = Brushes.DimGray;
            groundspeedlabel.Foreground = Brushes.White;
            groundspeedlabel.FontSize   = 14;
            groundspeedlabel.FontWeight = FontWeights.Bold;
            groundspeedlabel.Text       = "地速  " + GroundSpeed.ToString("0.0");
            Canvas.SetLeft(groundspeedlabel, 4);
            Canvas.SetTop(groundspeedlabel, 100);
            Canvas_ViewPortLeft.Children.Add(groundspeedlabel);

            BorderTextLabel batteryabel = new BorderTextLabel();

            batteryabel.Stroke     = Brushes.DimGray;
            batteryabel.Foreground = Brushes.White;
            batteryabel.FontSize   = 14;
            batteryabel.FontWeight = FontWeights.Bold;
            batteryabel.Text       = string.Format("电池  {0} v  {1} A  {2}%", Voltage.ToString("0.00"), Galvanic.ToString("0.0"), BatteryPercent * 100);
            Canvas.SetLeft(batteryabel, 10);
            Canvas.SetTop(batteryabel, 130);
            Canvas_ViewPortLeft.Children.Add(batteryabel);

            if (HasEKF)
            {
                BorderTextLabel ekflabel = new BorderTextLabel();
                ekflabel.Stroke     = Brushes.DimGray;
                ekflabel.Foreground = Brushes.White;
                ekflabel.FontSize   = 14;
                ekflabel.FontWeight = FontWeights.Bold;
                ekflabel.Text       = "EKF";
                Canvas.SetLeft(ekflabel, 200);
                Canvas.SetTop(ekflabel, 130);
                Canvas_ViewPortLeft.Children.Add(ekflabel);
            }
            if (HasVibe)
            {
                BorderTextLabel vibelabel = new BorderTextLabel();
                vibelabel.Stroke     = Brushes.DimGray;
                vibelabel.Foreground = Brushes.Red;
                vibelabel.FontSize   = 14;
                vibelabel.FontWeight = FontWeights.Bold;
                vibelabel.Text       = "Vibe";
                Canvas.SetLeft(vibelabel, 250);
                Canvas.SetTop(vibelabel, 130);
                Canvas_ViewPortLeft.Children.Add(vibelabel);
            }

            BorderTextLabel gpslabel = new BorderTextLabel();

            gpslabel.Stroke     = Brushes.DimGray;
            gpslabel.Foreground = Brushes.Red;
            gpslabel.FontSize   = 14;
            gpslabel.FontWeight = FontWeights.Bold;
            string s = HasGPS ? "有GPS" : "无GPS";

            gpslabel.Text = "GPS: " + s;
            Canvas.SetLeft(gpslabel, 300);
            Canvas.SetTop(gpslabel, 130);
            Canvas_ViewPortLeft.Children.Add(gpslabel);

            BorderTextLabel flytimelabel = new BorderTextLabel();

            flytimelabel.Stroke     = Brushes.DimGray;
            flytimelabel.Foreground = Brushes.White;
            flytimelabel.FontSize   = 14;
            flytimelabel.FontWeight = FontWeights.Bold;
            flytimelabel.Text       = new TimeSpan(FlyTime).ToString(@"hh\:mm\:ss");
            Canvas.SetLeft(flytimelabel, -80);
            Canvas.SetTop(flytimelabel, -110);
            Canvas_ViewPortRight.Children.Add(flytimelabel);
        }
Пример #40
0
 public void ToStringProviderTest()
 {
     double value = 10F;
     Voltage target = new Voltage(value);
     IFormatProvider provider = null;
     string expected = value.ToString();
     string actual;
     actual = target.ToString(provider);
     Assert.AreEqual(expected, actual);
 }
Пример #41
0
        public void TestMakeMethod()
        {
            Voltage voltage = Voltage.make(220);

            Assert.AreEqual("220v", voltage.ToString());
        }
Пример #42
0
 public void TryParseStyleProviderResultTest()
 {
     double value = 10F;
     string s = value.ToString();
     NumberStyles style = new NumberStyles();
     IFormatProvider provider = null;
     Voltage result = new Voltage(value);
     Voltage resultExpected = new Voltage(value);
     bool expected = true;
     bool actual;
     actual = Voltage.TryParse(s, style, provider, out result);
     Assert.AreEqual(resultExpected, result);
     Assert.AreEqual(expected, actual);
 }
Пример #43
0
 public static List <Tower> TowerList(Voltage voltage, TowerType towerType, string basename, double hcmin, double hcmax, double htmin, double step,
                                      double lh, double lv, double kv, double angle, double angleSpan, double maxSpan, double?downwardAngle,
                                      Dictionary <string, AttachmentPoint3D> hangPointList, Dictionary <string, (double Root, double Weigh)> RootWeightDic)
Пример #44
0
 public void op_AdditionTest()
 {
     Voltage value1 = new Voltage(10F);
     Voltage value2 = new Voltage(10F);
     Voltage expected = new Voltage(20F);
     Voltage actual;
     actual = (value1 + value2);
     Assert.AreEqual(expected, actual);
 }
 public static Voltage calculate(Current current, Resistance resistance)
 {
     return(Voltage.make(current.Value * resistance.Value));
 }
Пример #46
0
 public void op_ExponentTest()
 {
     Voltage value1 = new Voltage(2F);
     Voltage value2 = new Voltage(3F);
     double expected = 8F;
     double actual;
     actual = Voltage.op_Exponent(value1, value2);
     Assert.AreEqual(expected, actual);
 }
 public static Current calculate(Voltage voltage, Resistance resistance)
 {
     return(Current.make(voltage.Value / resistance.Value));
 }
Пример #48
0
 public void op_ImplicitTest()
 {
     Voltage value = new Voltage(10F);
     double expected = 10F;
     double actual;
     actual = value;
     Assert.AreEqual(expected, actual);
 }
 public static Resistance calculate(Voltage voltage, Current current)
 {
     return(Resistance.make(voltage.Value / current.Value));
 }
Пример #50
0
 public void op_InequalityTest()
 {
     Voltage value1 = new Voltage(10F);
     Voltage value2 = new Voltage(9F);
     bool expected = true;
     bool actual;
     actual = (value1 != value2);
     Assert.AreEqual(expected, actual);
 }
Пример #51
0
 public ICommand CreateSetVoltageAndFrequencyCommand(Voltage voltage, Frequency frequency)
 {
     return(new CommandSetVoltageAndFrequency(voltage, frequency));
 }
Пример #52
0
 public void op_LessThanOrEqualTest()
 {
     Voltage value1 = new Voltage(10F);
     Voltage value2 = new Voltage(10F);
     bool expected = true;
     bool actual;
     actual = (value1 <= value2);
     Assert.AreEqual(expected, actual);
 }
Пример #53
0
 /// <summary>
 /// Initializes a new instance of <see cref="Gu.Units.Wpf.VoltageExtension"/>.
 /// </summary>
 /// <param name="value"><see cref="Gu.Units.Voltage"/>.</param>
 public VoltageExtension(Voltage value)
 {
     this.Value = value;
 }
Пример #54
0
 public void op_MultiplyTest()
 {
     Voltage value1 = new Voltage(10F);
     Voltage value2 = new Voltage(10F);
     Voltage expected = new Voltage(100F);
     Voltage actual;
     actual = (value1 * value2);
     Assert.AreEqual(expected, actual);
 }
Пример #55
0
 public CommandSetVoltageAndFrequency(Voltage voltage, Frequency frequency)
 {
     this.voltage   = voltage;
     this.frequency = frequency;
 }