Beispiel #1
0
        public override void Check()
        {
            int xr = InPortList[0].RowNo;
            int xc = InPortList[0].ColNo;
            int yr = InPortList[1].RowNo;
            int yc = InPortList[1].ColNo;

            xHandle = Observation.CreateObservation(xName, xr, xc);
            yHandle = Observation.CreateObservation(yName, yr, yc);
            if (xr == 0 && xc == 0 && yr == 0 && yc == 0)
            {
                FigureConfigDoubleScalar(xName, yName);
                SendData = SendDataDoubleScalar;
                SendFile = SendFileDoubleScalar;
            }
            else if (xr == 0 && yr == 0)
            {
                FigureConfigScalarMatrix(yc, yr, xName, yName);
                SendData = SendDataScalarMatrix;
                SendFile = SendFileScalarMatrix;
            }
            else if (yr == 0 && yc == 0)
            {
                FigureConfigMatrixScalar(xc, xr, xName, yName);
                SendData = SendDataMatrixScalar;
                SendFile = SendFileMatrixScalar;
            }
            else if (xr == 1 && yc == 1)
            {
                FigureConfigHVectorVVector(xc, yr, xName, yName);
                SendData = SendDataHVectorVVector;
                SendFile = SendFileHVectorVVector;
            }
            else if (xc == 1 && yr == 1)
            {
                FigureConfigVVectorHVector(xr, yc, xName, yName);
                SendData = SendDataVVectorHVector;
                SendFile = SendFileVVectorHVector;
            }
            else
            {
                throw logger.Error(new ModelException(this, "PhaseDiagram only accepts [scalar, (m*n)] or [(1*m), (n*1)] or vice versa."));
            }
        }
Beispiel #2
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);
 }
Beispiel #3
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);
        }