예제 #1
0
 private void FigureConfigMatrixScalar(int xc, int xr, string xName, string yName)
 {
     FigureProtocol.FigureConfig figureConfig = new FigureProtocol.FigureConfig()
     {
         FigureId     = publisher.Id,
         Title        = varName,
         RowsCount    = xc,
         ColumnsCount = xr
     };
     publisher.Send(FigureProtocol.FigureConfigLabel, figureConfig);
     for (int i = 0; i < xr; i++)
     {
         for (int j = 0; j < xc; j++)
         {
             string observationName = $"{xName}({i}-{j})";
             FigureProtocol.PlotConfig plotConfig = new FigureProtocol.PlotConfig()
             {
                 FigureId = publisher.Id,
                 RowNO    = i,
                 ColumnNO = j,
                 XLabel   = observationName,
                 YLabel   = yName
             };
             publisher.Send(FigureProtocol.PlotConfigLabel, plotConfig);
             FigureProtocol.Curve curve = new FigureProtocol.Curve()
             {
                 FigureId    = publisher.Id,
                 CurveHandle = i * xc + j,
                 RowNO       = i,
                 ColumnNO    = j
             };
             publisher.Send(FigureProtocol.CurveLabel, curve);
         }
     }
 }
예제 #2
0
 private void FigureConfigDoubleScalar(string xName, string yName)
 {
     FigureProtocol.FigureConfig figureConfig = new FigureProtocol.FigureConfig()
     {
         FigureId     = publisher.Id,
         Title        = varName,
         RowsCount    = 1,
         ColumnsCount = 1
     };
     publisher.Send(FigureProtocol.FigureConfigLabel, figureConfig);
     FigureProtocol.PlotConfig plotConfig = new FigureProtocol.PlotConfig()
     {
         FigureId = publisher.Id,
         RowNO    = 0,
         ColumnNO = 0,
         XLabel   = xName,
         YLabel   = yName
     };
     publisher.Send(FigureProtocol.PlotConfigLabel, plotConfig);
     FigureProtocol.Curve curve = new FigureProtocol.Curve()
     {
         FigureId    = publisher.Id,
         CurveHandle = 0,
         RowNO       = 0,
         ColumnNO    = 0
     };
     publisher.Send(FigureProtocol.CurveLabel, curve);
 }
예제 #3
0
 private void FigureConfigVVectorHVector(int xr, int yc, string xName, string yName)
 {
     FigureProtocol.FigureConfig figureConfig = new FigureProtocol.FigureConfig()
     {
         FigureId     = publisher.Id,
         Title        = varName,
         RowsCount    = yc,
         ColumnsCount = xr
     };
     publisher.Send(FigureProtocol.FigureConfigLabel, figureConfig);
     for (int i = 0; i < yc; i++)
     {
         string observationName = $"{yName}({i})";
     }
     for (int i = 0; i < xr; i++)
     {
         string observationName = $"{xName}({i})";
         for (int j = 0; j < yc; j++)
         {
             FigureProtocol.PlotConfig plotConfig = new FigureProtocol.PlotConfig()
             {
                 FigureId = publisher.Id,
                 RowNO    = i,
                 ColumnNO = j,
                 XLabel   = observationName,
                 YLabel   = yHandle.space[j].Name
             };
             publisher.Send(FigureProtocol.PlotConfigLabel, plotConfig);
             FigureProtocol.Curve curve = new FigureProtocol.Curve()
             {
                 FigureId    = publisher.Id,
                 CurveHandle = i * yc + j,
                 RowNO       = i,
                 ColumnNO    = j
             };
             publisher.Send(FigureProtocol.CurveLabel, curve);
         }
     }
 }
예제 #4
0
파일: Plotter.cs 프로젝트: JRY-Zheng/ligral
        protected override bool Receive(FigureProtocol.FigureConfig figureConfig)
        {
            Execute($@"
fig{figureConfig.FigureId}, ax{figureConfig.FigureId} = plt.subplots({figureConfig.RowsCount}, {figureConfig.ColumnsCount}, num='{figureConfig.Title}')
fig{figureConfig.FigureId}.suptitle('{figureConfig.Title}')
");
            Figure figure = new Figure();

            if (figureConfig.RowsCount == 1 && figureConfig.ColumnsCount == 1)
            {
                figure.AxesShape = AxesShapeType.Scalar;
            }
            else if (figureConfig.RowsCount == 1 || figureConfig.ColumnsCount == 1)
            {
                figure.AxesShape = AxesShapeType.Vector;
            }
            else
            {
                figure.AxesShape = AxesShapeType.Matrix;
            }
            figure.Name = figureConfig.Title;
            Figures[figureConfig.FigureId] = figure;
            return(true);
        }
예제 #5
0
 protected virtual bool Receive(FigureProtocol.FigureConfig figureConfig)
 {
     return(false);
 }
예제 #6
0
        public override void Check()
        {
            int rowNo = InPortList[0].RowNo;
            int colNo = InPortList[0].ColNo;

            FigureProtocol.FigureConfig figureConfig = new FigureProtocol.FigureConfig()
            {
                FigureId     = publisher.Id,
                Title        = varName,
                RowsCount    = rowNo == 0 ? 1 : rowNo,
                ColumnsCount = colNo == 0 ? 1 : colNo
            };
            publisher.Send(FigureProtocol.FigureConfigLabel, figureConfig);
            handle = Observation.CreateObservation(varName, rowNo, colNo);
            if (rowNo > 0 && colNo > 0)
            {
                for (int i = 0; i < rowNo; i++)
                {
                    for (int j = 0; j < colNo; j++)
                    {
                        string observationName = $"{varName}({i}-{j})";
                        FigureProtocol.PlotConfig plotConfig = new FigureProtocol.PlotConfig()
                        {
                            FigureId = publisher.Id,
                            RowNO    = i,
                            ColumnNO = j,
                            XLabel   = "time/s",
                            YLabel   = observationName
                        };
                        publisher.Send(FigureProtocol.PlotConfigLabel, plotConfig);
                        FigureProtocol.Curve curve = new FigureProtocol.Curve()
                        {
                            FigureId    = publisher.Id,
                            CurveHandle = i * colNo + j,
                            RowNO       = i,
                            ColumnNO    = j
                        };
                        publisher.Send(FigureProtocol.CurveLabel, curve);
                    }
                }
            }
            else
            {
                FigureProtocol.PlotConfig plotConfig = new FigureProtocol.PlotConfig()
                {
                    FigureId = publisher.Id,
                    RowNO    = 0,
                    ColumnNO = 0,
                    XLabel   = "time/s",
                    YLabel   = varName
                };
                publisher.Send(FigureProtocol.PlotConfigLabel, plotConfig);
                FigureProtocol.Curve curve = new FigureProtocol.Curve()
                {
                    FigureId    = publisher.Id,
                    CurveHandle = 0,
                    RowNO       = 0,
                    ColumnNO    = 0
                };
                publisher.Send(FigureProtocol.CurveLabel, curve);
            }
            FigureProtocol.ShowCommand showCommand = new FigureProtocol.ShowCommand()
            {
                FigureId = publisher.Id
            };
            publisher.Send(FigureProtocol.ShowCommandLabel, showCommand);
        }