using ScottPlot; using System.Runtime.InteropServices; using static EF3.HSI.HSI; namespace EF3; public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btn_StartSCan_Click(object sender, EventArgs e) { //启动扫描 Motion.DCCScanStart(); } private void btn_GetEF3Version_Click(object sender, EventArgs e) { } private void btn_StopScan_Click(object sender, EventArgs e) { //扫描结束 Motion.DCCScanStop(); } private void btn_GetPoints_Click(object sender, EventArgs e) { //获取扫描结果 var dataCache = Marshal.AllocHGlobal(1000); var pointCount = 0; var data = new byte[1000]; Motion.GetPositionXyzCache(dataCache, ref pointCount); Console.WriteLine("pointCount = " + pointCount); Marshal.Copy(dataCache, data, 0, pointCount); //Point //打印扫描点 for (var i = 0; i < pointCount; i++) Console.WriteLine("Hex:{0} {1:X}", i, data[i]); } private void Form1_Load(object sender, EventArgs e) { //1 获取HSI Dll版本 uint major = Def.HSI_APIVersionMajor; uint minjor = Def.HSI_APIVersionMinor; var rStatus = Interface.GetInterfaceVersion(ref major, ref minjor); Console.WriteLine("Interface.GetInterfaceVersion: {0}", rStatus); Console.WriteLine("HSI.dll Version: {0}.{1}", major, minjor); //2 HSI 初始化 var mainIntPtr = User32Api.GetCurrentWindowHandle(); rStatus = Interface.Startup(mainIntPtr, false); Console.WriteLine("Interface.Startup: {0}", rStatus); //3 获取机器类型 var machineVersion = Def.HSI_EF3Version; rStatus = Interface.GetMachineInfo(ref machineVersion); Console.WriteLine("Interface.GetMachineInfo: {0}", rStatus); Console.WriteLine("HSI EF3 Version: {0}", machineVersion); //4 设置回调,方便根据回调结果进行提醒 Interface.HsiCallback = Interface.EventCallback; rStatus = Interface.SetEventCallback(Interface.HsiCallback); Console.WriteLine("SetEventCallback:{0}", rStatus); //事件回调成功 } private void btn_GoHome_Click(object sender, EventArgs e) { var rStatus = Motion.Startup(true); //运动初始化,回家判断 Console.WriteLine("Motion.Startup:{0}", rStatus); } private void btn_Plot_Click(object sender, EventArgs e) { //double[] dataX = { 1, 2, 3, 4, 5 }; //double[] dataY = { 1, 4, 9, 16, 25 }; //formsPlot1.Plot.AddScatter(dataX, dataY); //formsPlot1.Refresh(); var plt = new ScottPlot.Plot(600, 400); // plot some sample data plt.AddSignal(DataGen.Sin(51)); // add arrows using coordinates plt.AddArrow(25, 0, 27, .2); // you can define a minimum length so the line persists even when zooming out var arrow2 = plt.AddArrow(27, -.25, 23, -.5); arrow2.Color = System.Drawing.Color.Red; arrow2.MinimumLengthPixels = 100; // the shape of the arrowhead can be adjusted var skinny = plt.AddArrow(12, 1, 12, .5); skinny.Color = System.Drawing.Color.Green; skinny.ArrowheadLength = 5; skinny.ArrowheadWidth = 2; var fat = plt.AddArrow(20, .6, 20, 1); fat.Color = System.Drawing.Color.Blue; fat.ArrowheadLength = 2; fat.ArrowheadWidth = 5; // a marker can be drawn at the base of the arrow var arrow3 = plt.AddArrow(30, -.58, 35, -.4); arrow3.MarkerSize = 15; plt.SaveFig("plottable_arrow_quickstart.png"); formsPlot1.Plot.Add(plt.GetPlottables()[1]); formsPlot1.Refresh(); } }