Beispiel #1
0
        /// <summary>
        /// Constructor with parameters
        /// </summary>
        /// <param name="nodeIndices">Nodes present in this instance</param>
        /// <param name="activeComponentsIndices">Active components indices present in this instance</param>
        /// <param name="defaultValueFactory">Func used for generating initial values in <see cref="Potentials"/> and <see cref="Currents"/>,
        /// if null (which is the default value) <see cref="default(T)"/> will be used</param>
        /// <param name="sourceDescription">Description of source that produced this state. Can be null - it means that it's indetermined or
        /// many sources produced this state</param>
        public GenericState(IEnumerable <int> nodeIndices, IEnumerable <int> activeComponentsIndices, ISourceDescription sourceDescription,
                            Func <T> defaultValueFactory = null)
        {
            // Null checks
            if (nodeIndices == null)
            {
                throw new ArgumentNullException(nameof(nodeIndices));
            }

            if (activeComponentsIndices == null)
            {
                throw new ArgumentNullException(nameof(activeComponentsIndices));
            }

            // Make an entry for each node
            foreach (var node in nodeIndices)
            {
                Potentials.Add(node, defaultValueFactory == null ? default(T) : defaultValueFactory());
            }

            // Make an entry for each index
            foreach (var index in activeComponentsIndices)
            {
                Currents.Add(index, defaultValueFactory == null ? default(T) : defaultValueFactory());
            }

            // Assign source description
            SourceDescription = sourceDescription;
        }
Beispiel #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);
            }
        }
Beispiel #3
0
 private EntitiesController()
 {
     Current = new Currents();
     Get     = new Requests(this, uc);
 }
        // On tap, get an input line and perform a buffer and clip operation
        private async void mapView1_Tap(object sender, MapViewInputEventArgs e)
        {
            if (BusyVisibility == Visibility.Visible)
            {
                MessageBox.Show("Please wait until the current operation is complete.");
                return;
            }

            // Show busy UI
            BusyVisibility = Visibility.Visible;

            // Clear previous results
            TapPoints.Clear();
            Currents.Clear();



            // Create graphic and add to tap points
            var g = new Graphic()
            {
                Geometry = e.Location
            };

            TapPoints.Add(g);

            string error = null;

            // Initialize the Geoprocessing task with the drive time calculation service endpoint
            Geoprocessor task = new Geoprocessor(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
                                                         "Specialty/ESRI_Currents_World/GPServer/MessageInABottle"));

            // Initialize input parameters
            var parameter = new GPInputParameter()
            {
                OutSpatialReference = SpatialReferences.WebMercator
            };

            var projectedMapPoint = GeometryEngine.Project(e.Location, SpatialReferences.Wgs84);

            parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Point", projectedMapPoint));
            parameter.GPParameters.Add(new GPDouble("Days", Days));

            try
            {
                // Run the operation
                var result = await task.ExecuteAsync(parameter);

                // Check that layers were returned from the operation
                var outputLayers = result.OutParameters.OfType <GPFeatureRecordSetLayer>();
                if (outputLayers.Count() > 0)
                {
                    // Get the first layer returned - this will be the drive time areas
                    var outputLayer = outputLayers.First();
                    if (outputLayer.FeatureSet != null && outputLayer.FeatureSet.Features != null)
                    {
                        // Instead of adding ocean current features one-by-one, update the collection all at once to
                        // allow the map to render the new features in one rendering pass.
                        Currents = new ObservableCollection <Graphic>(outputLayer.FeatureSet.Features);
                    }
                    else
                    {
                        error = "No results returned";
                    }
                }
                else
                {
                    error = "No results returned";
                }
            }
            catch (Exception ex)
            {
                error = "Calculation failed: " + ex.Message;
            }

            // If operation did not succeed, notify user
            if (error != null)
            {
                MessageBox.Show(error);
            }

            // Hide busy UI
            BusyVisibility = Visibility.Collapsed;
        }
Beispiel #5
0
 public App()
 {
     Currents = new Currents();
 }
Beispiel #6
0
 /// <summary>
 /// Sets the sample rate of the voltage and current data sets.
 /// </summary>
 /// <param name="sampleRate"></param>
 public void SetSampleRates(int sampleRate)
 {
     Voltages.SetSampleRate(sampleRate);
     Currents.SetSampleRate(sampleRate);
 }
Beispiel #7
0
 /// <summary>
 /// Uses system frequency to calculate the sample rate for each set of
 /// <see cref="MeasurementData"/> in the voltage and current data sets.
 /// </summary>
 public void CalculateSampleRates()
 {
     Voltages.CalculateSampleRates(m_frequency);
     Currents.CalculateSampleRates(m_frequency);
 }