Пример #1
0
        bool Measure1(MeasureVoltage dmm)
        {
            double reading;
            int    i;

            dcVoltage1 = 0.0;
            for (i = 1; i <= 5; i++)
            {
                reading = Math.Abs(dmm.Measure());


                dcVoltage1 = (dcVoltage1 + reading);

                Application.Current.Dispatcher.Invoke(() => Voltages.Add(Convert.ToString(reading + " Volts")));
                if (reading == 0.00)
                {
                    Application.Current.Dispatcher.Invoke(() => MessageBox.Show("Connect Meter USB"));
                    TurnOffPower(power);
                    meterConnected = false;
                    return(false);
                }
                if (reading < 300 || reading > 340)
                {
                    dcVoltage1 = reading;

                    return(false);
                }
            }
            dcVoltage1 = dcVoltage1 / (i - 1);



            return(true);
        }
Пример #2
0
        /// <summary>
        /// 监控仪表电压和电流
        /// </summary>
        /// <param name="timeout">查询时间间隔,单位ms</param>
        public void MonitorInstrument(int timeout, DateTime time)
        {
            Voltages.Clear();
            Currents.Clear();

            if (!t6332A.Open())
            {
                return;
            }

            //if (!t6942A.Open())
            //    return;

            CsvHelper csvHelper = new CsvHelper($@"D:\HTOL\{time:yyyyMMddHHmmss}\InstrumentData.csv");

            csvHelper.WirteLine(new string[] { "Time(MMdd:HH:mm:ss)", "CH1_Voltage(V)", "CH2_Voltage(V)", "CH3_Voltage(V)", "CH1_Current(A)", "CH2_Current(A)", "CH3_Current(A)" });

            isMonitorInstrument = true;
            while (isMonitorInstrument)
            {
                var now = DateTime.Now;

                double[] voltages = t6332A.QueryVoltage();
                Voltages.Add(new GraphModel
                {
                    DateTime = now,
                    Value    = voltages[0]
                });

                double[] currents = t6332A.QueryCurrent();
                Currents.Add(new GraphModel
                {
                    DateTime = now,
                    Value    = currents[0]
                });

                csvHelper.WirteLine(new string[]
                                    { now.ToString("MMdd:HH:mm:ss"),
                                      voltages[0].ToString("0.000"),
                                      voltages[1].ToString("0.000"),
                                      voltages[2].ToString("0.000"),
                                      currents[0].ToString("0.000"),
                                      currents[1].ToString("0.000"),
                                      currents[2].ToString("0.000"), });

                SetAxisLimits(now);
                //lets only use the last 15 values
                if (Voltages.Count > 120)
                {
                    Voltages.RemoveAt(0);
                }
                if (Currents.Count > 120)
                {
                    Currents.RemoveAt(0);
                }
                Thread.Sleep(timeout);
            }
        }
        public void LinkNetworkComponents(int numberOfPhasors, int numberofShuntBreakers)
        {
            for (int i = 0; i < numberOfPhasors; i++)
            {
                VoltagePhasorGroup voltagePhasorGroup = new VoltagePhasorGroup();
                Voltages.Add(voltagePhasorGroup);
            }

            for (int i = 0; i < numberofShuntBreakers; i++)
            {
                Switch shuntBreaker = new Switch();
                ShuntBreakers.Add(shuntBreaker);
            }
        }
        public void LinkNetworkComponents(int numberOfPhasors, int numberofShuntBreakers)
        {
            for (int i = 0; i < numberOfPhasors; i++)
            {
                Phasor voltage = new Phasor();
                Voltages.Add(voltage);
            }

            for (int i = 0; i < numberofShuntBreakers; i++)
            {
                CapBank shuntBreaker = new CapBank();
                ShuntBreakers.Add(shuntBreaker);
            }
        }
        public void LinkNetworkComponents(int numberOfPhasors)
        {
            for (int i = 0; i < numberOfPhasors; i++)
            {
                Phasor voltage = new Phasor();
                Voltages.Add(voltage);
            }

            //for(int i = 0; i < numberofShuntBreakers; i++ )
            //{
            //    Switch shuntBreaker = new Switch();
            //    ShuntBreakers.Add(shuntBreaker);

            //}
        }
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var voltage = VoltageService.Get();
            var current = CurrentService.Get();
            var power   = 0;

            this.Measure           = new Measure(DateTime.Now, voltage, current, power);
            this.ThreePhaseMeasure = ThreePhaseInputService.Get();

            IsPowerOn       = OutputService.IsOn();
            SupplierVoltage = SupplierVoltageInputService.Get();
            SupplierCurrent = SupplierCurrentInputService.Get();

            Voltages.Add(this.Measure.Voltage);
        }
Пример #7
0
        private void Initialize(ISensor sensor)
        {
            switch (sensor.SensorType)
            {
            case SensorType.Temperature:
                Temperatures.Add(sensor);
                break;

            case SensorType.Voltage:
                if (sensor.Name.Contains("+3.3V"))
                {
                    Voltage3p3 = sensor;
                }
                else if (sensor.Name.Contains("VBat"))
                {
                    VBat = sensor;
                }
                else
                {
                    Voltages.Add(sensor);
                }
                break;

            case SensorType.Fan:
                if (sensor.Name.EndsWith("#1"))
                {
                    CpuFanSpeed = sensor;
                }
                else
                {
                    FanSpeeds.Add(sensor);
                }
                break;

            case SensorType.Control:
                FanControls.Add(sensor);
                break;

            default:
                Jsoner.ObjectSaver.AddObject(sensor);
                break;
            }
        }