Exemplo n.º 1
0
 public override void Check()
 {
     if (rowNo >= 0 || colNo >= 0)
     {
         if (rowNo != InPortList[0].RowNo)
         {
             throw logger.Error(new ModelException(this, $"Shape inconsistency. {InPortList[0].RowNo} rows got, {rowNo} expected."));
         }
         else if (colNo != InPortList[0].ColNo)
         {
             throw logger.Error(new ModelException(this, $"Shape inconsistency. {InPortList[0].ColNo} columns got, {colNo} expected."));
         }
     }
     else
     {
         rowNo = InPortList[0].RowNo;
         colNo = InPortList[0].ColNo;
     }
     handle = Observation.CreateObservation(varName, rowNo, colNo);
 }
Exemplo n.º 2
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);
        }