コード例 #1
0
        private void CreatePointForSeries(Simulation simulation, ICircuitContext context, ExportDataEventArgs eventArgs, List <Export> exports, List <Series> series)
        {
            double x = 0;

            if (simulation is Transient)
            {
                x = eventArgs.Time;
            }

            if (simulation is AC)
            {
                x = eventArgs.Frequency;
            }

            if (simulation is DC dc)
            {
                if (eventArgs.GetSweepValues().Length > 1)
                {
                    // TODO: Add support for DC Sweeps > 1
                    context.Result.Validation.Add(
                        new ValidationEntry(
                            ValidationEntrySource.Reader,
                            ValidationEntryLevel.Warning,
                            ".PLOT doesn't support sweep count > 1"));
                    return;
                }

                x = eventArgs.GetSweepValues().FirstOrDefault();
            }

            for (var i = 0; i < exports.Count; i++)
            {
                try
                {
                    double val = exports[i].Extract();
                    if (!double.IsNaN(val))
                    {
                        series[i].Points.Add(new Point {
                            X = x, Y = val
                        });
                    }
                }
                catch (Exception)
                {
                    // ignore exception
                }
            }
        }
コード例 #2
0
        private static void CreateRowInPrint(ref int rowIndex, Simulation simulation, ICircuitContext context, ExportDataEventArgs eventArgs, List <Export> exports, Print print)
        {
            Row row = new Row(rowIndex++);

            double x = 0;

            if (simulation is Transient)
            {
                x = eventArgs.Time;
            }

            if (simulation is AC)
            {
                x = eventArgs.Frequency;
            }

            if (simulation is DC dc)
            {
                if (eventArgs.GetSweepValues().Length > 1)
                {
                    // TODO: Add support for DC Sweeps > 1
                    context.Result.Validation.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Warning, ".PRINT doesn't support sweep count > 1"));
                    return;
                }

                x = eventArgs.GetSweepValues().FirstOrDefault();
            }

            if (!(simulation is OP))
            {
                row.Columns.Add(x);
            }

            for (var i = 0; i < exports.Count; i++)
            {
                try
                {
                    double val = exports[i].Extract();
                    row.Columns.Add(val);
                }
                catch (Exception)
                {
                    row.Columns.Add(double.NaN);
                }
            }

            print.Rows.Add(row);
        }