Ejemplo n.º 1
0
 private void SendFileDoubleScalar()
 {
     FigureProtocol.DataFile dataFile = new FigureProtocol.DataFile()
     {
         FigureId    = publisher.Id,
         CurveHandle = 0,
         FileName    = Observation.DataFile,
         XColumn     = xHandle.space[0].Name,
         YColumn     = yHandle.space[0].Name
     };
     publisher.Send(FigureProtocol.DataFileLabel, dataFile);
 }
Ejemplo n.º 2
0
 private void SendFileMatrixScalar()
 {
     for (int i = 0; i < xHandle.space.Count; i++)
     {
         FigureProtocol.DataFile dataFile = new FigureProtocol.DataFile()
         {
             FigureId    = publisher.Id,
             CurveHandle = i,
             FileName    = Observation.DataFile,
             XColumn     = xHandle.space[i].Name,
             YColumn     = yHandle.space[0].Name
         };
         publisher.Send(FigureProtocol.DataFileLabel, dataFile);
     }
 }
Ejemplo n.º 3
0
 public override void Release()
 {
     for (int i = 0; i < handle.space.Count; i++)
     {
         Observation             observation = handle.space[i];
         FigureProtocol.DataFile dataFile    = new FigureProtocol.DataFile()
         {
             FigureId    = publisher.Id,
             CurveHandle = i,
             FileName    = Observation.DataFile,
             XColumn     = "Time",
             YColumn     = observation.Name
         };
         publisher.Send(FigureProtocol.DataFileLabel, dataFile);
     }
     ;
 }
Ejemplo n.º 4
0
 private void SendFileVVectorHVector()
 {
     for (int i = 0; i < xHandle.space.Count; i++)
     {
         for (int j = 0; j < yHandle.space.Count; j++)
         {
             FigureProtocol.DataFile dataFile = new FigureProtocol.DataFile()
             {
                 FigureId    = publisher.Id,
                 CurveHandle = i * yHandle.space.Count + j,
                 FileName    = Observation.DataFile,
                 XColumn     = xHandle.space[i].Name,
                 YColumn     = yHandle.space[j].Name
             };
             publisher.Send(FigureProtocol.DataFileLabel, dataFile);
         }
     }
 }
Ejemplo n.º 5
0
        protected override bool Receive(FigureProtocol.DataFile dataFile)
        {
            if (!Figures.ContainsKey(dataFile.FigureId))
            {
                return(false);
            }
            Figure figure = Figures[dataFile.FigureId];

            if (!figure.Curves.ContainsKey(dataFile.CurveHandle))
            {
                return(false);
            }
            Curve curve = figure.Curves[dataFile.CurveHandle];

            Flush(curve, dataFile.FigureId, dataFile.CurveHandle);
            curve.Showed = true;
            if (SaveFigure && figure.Showed)
            {
                string fileName = Path.GetFullPath(dataFile.FileName);
                string figName  = figure.Name;
                foreach (char invalidChar in Path.GetInvalidFileNameChars())
                {
                    figName = figName.Replace(invalidChar, '_');
                }
                Execute($@"
plt.savefig(r'{Path.GetDirectoryName(fileName)}\{figName}.png')
");
            }
            foreach (Figure fig in Figures.Values)
            {
                if (!figure.Showed)
                {
                    return(true);
                }
            }
            Execute(@"
plt.ioff()
plt.show()
");
            Unsubscribe();
            return(true);
        }
Ejemplo n.º 6
0
 protected virtual bool Receive(FigureProtocol.DataFile dataFile)
 {
     return(false);
 }
Ejemplo n.º 7
0
        protected override bool Receive(FigureProtocol.DataFile dataFile)
        {
            if (!Figures.ContainsKey(dataFile.FigureId))
            {
                return(false);
            }
            Figure figure = Figures[dataFile.FigureId];

            if (!figure.Curves.ContainsKey(dataFile.CurveHandle))
            {
                return(false);
            }
            Curve  curve    = figure.Curves[dataFile.CurveHandle];
            string fileName = Path.GetFullPath(dataFile.FileName);

            if (!Files.ContainsKey(fileName))
            {
                Execute($@"
df{Files.Count} = pd.read_csv(r'{fileName}', skipinitialspace=True)
");
                Files[fileName] = Files.Count;
            }
            Execute($@"
x = df{Files[fileName]}['{dataFile.XColumn}'].values
y = df{Files[fileName]}['{dataFile.YColumn}'].values
");
            switch (figure.AxesShape)
            {
            case AxesShapeType.Scalar:
                Execute($@"
ax{dataFile.FigureId}.plot(x, y)
");
                break;

            case AxesShapeType.Vector:
                int index = curve.RowNO > curve.ColNO ? curve.RowNO : curve.ColNO;
                Execute($@"
ax{dataFile.FigureId}[{index}].plot(x, y)
");
                break;

            case AxesShapeType.Matrix:
                Execute($@"
ax{dataFile.FigureId}[{curve.RowNO}, {curve.ColNO}].plot(x, y)
ax.grid()
");
                break;
            }
            curve.Showed = true;
            if (SaveFigure && figure.Showed)
            {
                string figName = figure.Name;
                foreach (char invalidChar in Path.GetInvalidFileNameChars())
                {
                    figName = figName.Replace(invalidChar, '_');
                }
                Execute($@"
plt.savefig(r'{Path.GetDirectoryName(fileName)}\{figName}.png')
");
            }
            foreach (var fig in Figures.Values)
            {
                if (!fig.Showed)
                {
                    return(true);
                }
            }
            Execute($@"
plt.show()
");
            Unsubscribe();
            return(true);
        }