我使用C#WPF在从FPGA接收数据后使应用程序绘制图形,我使用了Dynamic-Data-Display,但是没有用。我的代码如下:
......
namespace FTDemoApp
{
public partial class MainWindow : Window
{
FTDI.FT_STATUS ftStatus = FTDI.FT_STATUS.FT_OK;
FTDI d3xxDevice;
UInt32 ulNumDevices;
const int dataNum = 1024; //The number of data
long[] x = new long[dataNum]; //x-value
long[] y = new long[dataNum]; //y-value
string[] x_Str = new string[dataNum];
string[] y_Str = new string[dataNum];
.....
private void ButtonStart_Click(object sender, RoutedEventArgs e)
{
UInt32 loopBytes = 4096;
byte[] writeBytes = new byte[4];
byte[] readBytes = new byte[loopBytes];
byte read_num = 0x82; //port number (read)
byte write_num = 0x02; //port number (write)
int td_numb = 1;
// Create data sources:
var xDataSource = x.AsXDataSource();
var yDataSource = y.AsYDataSource();
CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource);
// adding graph to plotter
plotter.AddLineGraph(compositeDataSource, Colors.Goldenrod, 10, "plot");
plotter.FitToView(); //Force evertyhing plotted to be visible
.....
//receive data
string new_code = byteToHexStr(readBytes);
//get data
for (int k = 0; k < 1024; k++)
{
x_Str[k] = new_code.Substring(k * 4, 4);
y_Str[k] = new_code.Substring(k * 4 + 4, 4);
x[k] = Convert.ToInt64(x_Str[k], 16);
y[k] = Convert.ToInt64(y_Str[k], 16);
}
........
我使用过控制台。 Writeline输出x和y数据,它们的数据正确,但是无法绘制图形。我的代码有什么问题? 此外,我希望X轴和Y轴介于0到800之间。我该怎么做? 谢谢!