剥离第一阶段需要做的函数,梳理关系,新增测试dll工程

This commit is contained in:
wio
2022-10-10 11:52:53 +08:00
parent 698e1223fa
commit 6d2b284f36
44 changed files with 1500 additions and 302 deletions
+134
View File
@@ -0,0 +1,134 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using HSI_SEVENOCEAN_EF1_CsTest;
using HSI_SEVENOCEAN_EF1_CsTest.HSI;
namespace HSI_SEVENOCEAN_EF1_CsTest
{
class Program
{
private static Interface.PEventCallback _eventCallback;
static void Main(string[] args)
{
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("Version:{0}.{1}", major, minjor);
var mainIntPtr = User32Api.GetCurrentWindowHandle();
rStatus = Interface.Startup(mainIntPtr, false);
Console.WriteLine("Interface.Startup:{0}", rStatus);
Interface.HsiCallback=new Interface.PEventCallback(Interface.EventCallback);
rStatus = Interface.SetEventCallback(Interface.HsiCallback);
Console.WriteLine("SetEventCallback:{0}", rStatus);
//if (Motion.IsActive(true))
{
rStatus = Motion.Startup(true);
Console.WriteLine("Motion.Startup:{0}", rStatus);
var bHomed = true;
rStatus = Motion.IsHomed(ref bHomed);
Console.WriteLine("Motion.IsHomed:{0}", rStatus);
var bexit = false;
double SpeedGear = 1.0;
var dPos = new double[3];
do
{
var info = Console.ReadKey();
double dTime = 0;
switch (info.Key)
{
case ConsoleKey.P:
dPos[0] += 10.0;
dPos[1] += 10.0;
rStatus = Motion.SetPositionXyz(Def.HSI_MOTION_AXIS_ALL, dPos[0], dPos[1], dPos[2], Def.HSI_MOTION_MOVE_TYPE.HSI_MOTION_MOVE_NOWAIT, 0.0);
break;
case ConsoleKey.Enter:
rStatus = Motion.GetPositionXyz(Def.HSI_MOTION_AXIS_ALL, ref dPos[0], ref dPos[1], ref dPos[2], ref dTime);
Console.WriteLine("Motion.GetPositionXyz:{0}", rStatus);
Console.WriteLine("Motion.XYZ:{0},{1},{2}", dPos[0], dPos[1], dPos[2]);
break;
case ConsoleKey.Escape:
bexit = true;
break;
case ConsoleKey.Spacebar:
rStatus = Motion.StopJog();
Console.WriteLine("Motion.StopJog:{0}", rStatus);
break;
case ConsoleKey.NumPad1:
case ConsoleKey.D1:
SpeedGear = 1.0;
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
break;
case ConsoleKey.NumPad2:
case ConsoleKey.D2:
SpeedGear = 2.0;
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
break;
case ConsoleKey.NumPad3:
case ConsoleKey.D3:
SpeedGear = 3.0;
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
break;
case ConsoleKey.NumPad4:
case ConsoleKey.D4:
SpeedGear = 4.0;
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
break;
case ConsoleKey.LeftArrow:
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_X, -SpeedGear);
Console.WriteLine("Motion.Jog(X,{1}):{0}", rStatus, SpeedGear);
break;
case ConsoleKey.RightArrow:
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_X, SpeedGear);
Console.WriteLine("Motion.Jog(X,{1}):{0}", rStatus, SpeedGear);
break;
case ConsoleKey.DownArrow:
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Y, -SpeedGear);
Console.WriteLine("Motion.Jog(Y,{1}):{0}", rStatus, SpeedGear);
break;
case ConsoleKey.UpArrow:
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Y, SpeedGear);
Console.WriteLine("Motion.Jog(Y,{1}):{0}", rStatus, SpeedGear);
break;
case ConsoleKey.PageUp:
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Z, SpeedGear);
Console.WriteLine("Motion.Jog(Z,{1}):{0}", rStatus, SpeedGear);
break;
case ConsoleKey.PageDown:
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Z, -SpeedGear);
Console.WriteLine("Motion.Jog(Z,{1}):{0}", rStatus, SpeedGear);
break;
default:
Console.WriteLine("Invalid");
break;
}
} while (!bexit);
rStatus = Motion.Shutdown();
Console.WriteLine("Motion.Startup:{0}", rStatus);
}
rStatus = Interface.Shutdown();
Console.WriteLine("Interface.Shutdown:{0}", rStatus);
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}