diff --git a/OneClick.slnx b/OneClick.slnx
new file mode 100644
index 0000000..c148ece
--- /dev/null
+++ b/OneClick.slnx
@@ -0,0 +1,3 @@
+
+
+
diff --git a/OneClick/App.xaml b/OneClick/App.xaml
new file mode 100644
index 0000000..d0f0b1f
--- /dev/null
+++ b/OneClick/App.xaml
@@ -0,0 +1,8 @@
+
+
+
diff --git a/OneClick/App.xaml.cs b/OneClick/App.xaml.cs
new file mode 100644
index 0000000..ea262df
--- /dev/null
+++ b/OneClick/App.xaml.cs
@@ -0,0 +1,16 @@
+using Prism.Ioc;
+using System.ComponentModel;
+using System.Configuration;
+using System.Data;
+using System.Windows;
+
+namespace OneClick
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+
+}
diff --git a/OneClick/AssemblyInfo.cs b/OneClick/AssemblyInfo.cs
new file mode 100644
index 0000000..b0ec827
--- /dev/null
+++ b/OneClick/AssemblyInfo.cs
@@ -0,0 +1,10 @@
+using System.Windows;
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
diff --git a/OneClick/AxisService.cs b/OneClick/AxisService.cs
new file mode 100644
index 0000000..c0a662b
--- /dev/null
+++ b/OneClick/AxisService.cs
@@ -0,0 +1,344 @@
+using GTN;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection.Metadata;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace OneClick
+{
+ public class AxisService
+ {
+
+ public void InitMotionCard()
+ {
+ // 初始化运动控制卡
+ int sRtn = -1;
+ short eCATStatus = -1;
+ short core = 1; // 使用第一个EtherCAT主站
+ try
+ {
+ sRtn = GTN.mc.GTN_Open(5, 2);
+ //MessageBox.Show($"运动控制卡初始化成功,返回代码{sRtn}", "信息", MessageBoxButton.OK, MessageBoxImage.Information);
+ sRtn = GTN.mc.GTN_InitEcatComm(core);
+ int waitcount = 0;
+ do
+ {
+ sRtn = GTN.mc.GTN_IsEcatReady(core, out eCATStatus);
+ //waitcount++;
+ if (waitcount > 50000)
+ {
+ waitcount = 0;
+ MessageBox.Show("运动控制卡以太网通信初始化失败,请检查连接!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ } while (eCATStatus != 1 || sRtn != 0);
+ sRtn = GTN.mc.GTN_StartEcatComm(core);
+ }
+
+ catch (Exception ex)
+ {
+ MessageBox.Show($"运动控制卡初始化失败:{ex.Message},错误代码{sRtn}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ ///
+ /// 上使能
+ ///
+ /// 轴号
+ /// 核号
+ /// returns>状态码
+ public int AxisOn(short selectedindex, short core)
+ {
+ int sRtn = -1;
+ sRtn = mc.GTN_ClrSts(core, (short)(selectedindex), 1);
+ sRtn = GTN.mc.GTN_AxisOn(core, selectedindex);
+ return sRtn;
+ }
+
+ ///
+ /// 下使能
+ ///
+ /// 轴号
+ /// 核号
+ /// 状态码
+ public int AxisOff(short selectedindex, short core)
+ {
+ int sRtn = -1;
+ sRtn = GTN.mc.GTN_AxisOff(core, selectedindex);
+ return sRtn;
+ }
+
+ ///
+ /// 重置报警
+ ///
+ /// 轴号
+ /// 核号
+ ///
+ public int ResetAlarm(short selectedindex, short core)
+ {
+ int sRtn = -1;
+ sRtn = mc.GTN_ClrSts(core, (short)(selectedindex), 1);
+ return sRtn;
+ }
+
+ ///
+ /// 重置位置
+ ///
+ /// 轴号
+ /// 核号
+ ///
+ public int ResetPosition(short selectedindex, short core)
+ {
+ int sRtn = -1;
+ sRtn = mc.GTN_ZeroPos(core, selectedindex, 1);
+ return sRtn;
+ }
+
+
+ ///
+ /// 读取轴的状态
+ ///
+ /// 核号
+ /// 轴号
+ /// 轴状态
+ ///
+ public int ReadAxisStatus(short core, short axis, out string AxisSts)
+ {
+ int sRtn = -1;
+ Int32 psts;
+ UInt32 clock;
+ AxisSts = "";
+ // 读取轴状态
+ sRtn = mc.GTN_GetSts(core, axis, out psts, 1, out clock);
+
+ if ((psts & 0x2) != 0)
+ {
+ AxisSts += "报警\r\n";
+ }
+ if ((psts & 0x200) != 0)
+ {
+ AxisSts += "使能\r\n";
+ }
+ if ((psts & 0x40) != 0)
+ {
+ AxisSts += "负限位触发\r\n";
+ }
+ if ((psts & 0x20) != 0)
+ {
+ AxisSts += "正限位触发\r\n";
+ }
+ if ((psts & 0x400) != 0)
+ {
+ AxisSts += "正在移动\r\n";
+ }
+ if ((psts & 0x800) != 0)
+ {
+ AxisSts += "到位\r\n";
+ }
+ if ((psts & 0x10) != 0)
+ {
+ AxisSts += "跟随误差超限\r\n";
+ }
+ if ((psts & 0x80) != 0)
+ {
+ AxisSts += "平滑停止IO触发\r\n";
+ }
+ if ((psts & 0x100) != 0)
+ {
+ AxisSts += "急停触发\r\n";
+ }
+
+
+
+ return sRtn;
+
+ }
+
+ ///
+ /// Jog开始
+ ///
+ /// 核号
+ /// 轴号
+ ///
+ public int JogMove(short core, short axis,int rpm)
+ {
+ int sRtn = -1;
+ double speed;
+ Int32 mask;
+ // 设置轴为点动模式
+ sRtn = mc.GTN_PrfJog(core, axis);
+ if (sRtn != mc.CMD_SUCCESS) return sRtn;
+
+ // 将参数写死
+ mc.TJogPrm jog = new mc.TJogPrm
+ {
+ acc = 10, // 加速度
+ dec = 10, // 减速度
+ smooth = 0.0 // 平滑时间
+ };
+ speed = rpm*0.0667;
+ // 传入结构体引用
+ sRtn = mc.GTN_SetJogPrm(core, axis, ref jog);
+ if (sRtn != mc.CMD_SUCCESS) return sRtn;
+ // 设置点动速度
+ sRtn = mc.GTN_SetVel(1, axis, speed);
+ // 开始点动
+ mask= (int)AxisAndCoreToMask(core, axis);
+ sRtn =mc.GTN_Update(core,mask);
+ return sRtn;
+ }
+
+ ///
+ /// 停止运动
+ ///
+ /// 核号
+ /// 轴号
+ ///
+ public int AxisStop(short core, short axis)
+ {
+ int sRtn = -1;
+ Int32 mask;
+ Int32 option=0;
+ // 停止点动
+ mask = (int)AxisAndCoreToMask(core, axis);
+ sRtn = mc.GTN_Stop(core, mask,option);
+ return sRtn;
+ }
+
+
+ ///
+ /// 定时旋转
+ ///
+ /// 核号
+ /// 轴号
+ /// 速度
+ /// 时间
+ ///
+
+ public int TimelyRotate(short core,short axis,int rpm,int time)
+ {
+ int sRtn = -1;
+ sRtn = mc.GTN_PrfTrap(core, axis);
+
+
+ mc.TTrapPrm trap = new mc.TTrapPrm
+ {
+ acc = 10, // 加速度
+ dec = 10, // 减速度
+ velStart = 0.0, // 平滑时间
+ smoothTime = 10
+ };
+ sRtn = mc.GTN_SetTrapPrm(core, axis, ref trap);
+ sRtn=mc.GTN_SetPos(core, axis, (int)((double)rpm * 0.0667*time*1000));
+ sRtn=mc.GTN_SetVel(core,axis, (double)rpm*0.0667);
+ sRtn=mc.GTN_Update(core, (int)AxisAndCoreToMask(core, axis));
+
+
+ return sRtn;
+
+ }
+
+
+ ///
+ /// 关闭控制卡
+ ///
+ /// 核号
+ public void CloseMotionCard(short core)
+ {
+ // 关闭运动控制卡
+ int sRtn = -1;
+ try
+ {
+ sRtn = mc.GTN_TerminateEcatComm(core);
+ sRtn = GTN.mc.GTN_Close();
+ //MessageBox.Show($"运动控制卡关闭成功,返回代码{sRtn}", "信息", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"运动控制卡关闭失败:{ex.Message},错误代码{sRtn}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+
+
+ }
+
+ ///
+ /// 将给定的 core(核号) 与 axis(轴号) 转换为 32 位掩码 (mask)。
+ /// 规则:
+ /// - core=1 映射轴 1..32 到 mask 的位 0..31(轴1 -> bit0,轴32 -> bit31)
+ /// - core=2 映射轴 33..64 到 mask 的位 0..31(轴33 -> bit0,轴64 -> bit31)
+ /// 返回值为 UInt32 掩码;当输入不合法时抛出 。
+ ///
+ /// 核号(目前支持 1 或 2)
+ /// 轴号(1..64)
+ /// 对应的 32 位掩码
+ public static uint AxisAndCoreToMask(short core, short axis)
+ {
+ if (core < 1 || core > 2)
+ {
+ throw new ArgumentOutOfRangeException(nameof(core), "目前只支持 core=1 或 core=2。");
+ }
+
+ int baseAxis = (core - 1) * 32; // core=1 -> 0, core=2 -> 32
+ if (axis <= baseAxis || axis > baseAxis + 32)
+ {
+ throw new ArgumentOutOfRangeException(nameof(axis), $"轴号不在 core {core} 的有效范围 ({baseAxis + 1}..{baseAxis + 32})。");
+ }
+
+ int bitIndex = axis - baseAxis - 1; // 0..31
+ return 1u << bitIndex;
+ }
+
+ ///
+ /// 将 32 位掩码转换为该 core 下的轴列表。
+ /// 规则同 。
+ /// 返回的轴号为全局轴号(1..64)。
+ ///
+ /// 核号(1 或 2)
+ /// 32 位掩码,bit0 对应该 core 的最低号轴
+ /// 被选中轴的列表(按升序),掩码为0时返回空列表。
+ public static List MaskToAxisList(short core, uint mask)
+ {
+ var axes = new List();
+
+ if (core < 1 || core > 2)
+ {
+ throw new ArgumentOutOfRangeException(nameof(core), "目前只支持 core=1 或 core=2。");
+ }
+
+ int baseAxis = (core - 1) * 32; // core=1 -> 0, core=2 -> 32
+
+ for (int bit = 0; bit < 32; bit++)
+ {
+ if ((mask & (1u << bit)) != 0)
+ {
+ short axis = (short)(baseAxis + bit + 1);
+ axes.Add(axis);
+ }
+ }
+
+ return axes;
+ }
+
+ ///
+ /// 尝试将 axis 和 core 转换为 mask,转换成功返回 true 并输出 mask;失败返回 false 并输出 0。
+ /// 该方法便于在不抛出异常的情况下做验证。
+ ///
+ /// 核号
+ /// 轴号
+ /// 输出掩码
+ /// 是否成功
+ public static bool TryAxisAndCoreToMask(short core, short axis, out uint mask)
+ {
+ mask = 0;
+ if (core < 1 || core > 2) return false;
+ int baseAxis = (core - 1) * 32;
+ if (axis <= baseAxis || axis > baseAxis + 32) return false;
+ int bitIndex = axis - baseAxis - 1;
+ mask = 1u << bitIndex;
+ return true;
+ }
+ }
+}
diff --git a/OneClick/CameraService.cs b/OneClick/CameraService.cs
new file mode 100644
index 0000000..2faeeac
--- /dev/null
+++ b/OneClick/CameraService.cs
@@ -0,0 +1,171 @@
+using System;
+using System.Collections.Generic;
+using Basler.Pylon;
+
+namespace OneClick
+{
+ public interface ICameraService
+ {
+ IList EnumerateDevices();
+ void Open(string deviceId);
+ void Close();
+ bool StartGrabbing(bool continuous = true);
+ void StopGrabbing();
+ IGrabResult? GrabOnePic(int timeoutMs = 2000);
+ string? CurrentDeviceId { get; }
+ event EventHandler? GrabStarted;
+ event EventHandler? ImageGrabbed;
+ event EventHandler? GrabStopped;
+ event EventHandler? ConnectionLost;
+ }
+
+ public class BaslerCameraService : ICameraService
+ {
+ private Camera? _camera;
+ private readonly PixelDataConverter _converter = new PixelDataConverter();
+
+ public string? CurrentDeviceId { get; private set; }
+
+ public event EventHandler? GrabStarted;
+ public event EventHandler? ImageGrabbed;
+ public event EventHandler? GrabStopped;
+ public event EventHandler? ConnectionLost;
+
+ public IList EnumerateDevices()
+ {
+ var devices = CameraFinder.Enumerate();
+ var ids = new List();
+ foreach (var info in devices)
+ {
+ if (info.ContainsKey(CameraInfoKey.SerialNumber))
+ {
+ ids.Add(info[CameraInfoKey.SerialNumber]);
+ }
+ }
+ return ids;
+ }
+
+ public void Open(string deviceId)
+ {
+ if (string.IsNullOrWhiteSpace(deviceId))
+ throw new ArgumentException("豸IDΪա", nameof(deviceId));
+
+ Close();
+
+ _camera = new Camera(deviceId);
+
+ // ע¼
+ _camera.ConnectionLost += Camera_ConnectionLost;
+ _camera.StreamGrabber.GrabStarted += StreamGrabber_GrabStarted;
+ _camera.StreamGrabber.ImageGrabbed += StreamGrabber_ImageGrabbed;
+ _camera.StreamGrabber.GrabStopped += StreamGrabber_GrabStopped;
+
+ _camera.Open();
+ CurrentDeviceId = deviceId;
+ }
+
+ public void Close()
+ {
+ try
+ {
+ if (_camera != null)
+ {
+ if (_camera.StreamGrabber.IsGrabbing)
+ _camera.StreamGrabber.Stop();
+ }
+ }
+ catch
+ {
+ // ֹͣʧܲӰر
+ }
+
+ try
+ {
+ if (_camera != null)
+ {
+ // ע¼
+ _camera.ConnectionLost -= Camera_ConnectionLost;
+ _camera.StreamGrabber.GrabStarted -= StreamGrabber_GrabStarted;
+ _camera.StreamGrabber.ImageGrabbed -= StreamGrabber_ImageGrabbed;
+ _camera.StreamGrabber.GrabStopped -= StreamGrabber_GrabStopped;
+
+ _camera.Close();
+ _camera.Dispose();
+ _camera = null;
+ }
+ }
+ finally
+ {
+ CurrentDeviceId = null;
+ }
+ }
+
+ public bool StartGrabbing(bool continuous = true)
+ {
+ if (_camera == null)
+ throw new InvalidOperationException("δ");
+
+ try
+ {
+ if (continuous)
+ {
+ Configuration.AcquireContinuous(_camera, null);
+ _camera.StreamGrabber.Start(GrabStrategy.OneByOne, GrabLoop.ProvidedByStreamGrabber);
+ }
+ else
+ {
+ Configuration.AcquireSingleFrame(_camera, null);
+ _camera.StreamGrabber.Start(1, GrabStrategy.OneByOne, GrabLoop.ProvidedByStreamGrabber);
+ }
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
+ public void StopGrabbing()
+ {
+ if (_camera == null) return;
+
+ try
+ {
+ _camera.StreamGrabber.Stop();
+ }
+ catch
+ {
+ // ֹͣ쳣
+ }
+ }
+
+ public IGrabResult? GrabOnePic(int timeoutMs = 2000)
+ {
+ if (_camera == null)
+ return null;
+
+ return _camera.StreamGrabber.GrabOne(timeoutMs);
+ }
+
+ private void Camera_ConnectionLost(object? sender, EventArgs e)
+ {
+ ConnectionLost?.Invoke(this, EventArgs.Empty);
+ }
+
+ private void StreamGrabber_GrabStarted(object? sender, EventArgs e)
+ {
+ GrabStarted?.Invoke(this, EventArgs.Empty);
+ }
+
+ private void StreamGrabber_ImageGrabbed(object? sender, ImageGrabbedEventArgs e)
+ {
+ // ֱת UI ʾ
+ ImageGrabbed?.Invoke(this, e);
+ }
+
+ private void StreamGrabber_GrabStopped(object? sender, GrabStopEventArgs e)
+ {
+ GrabStopped?.Invoke(this, e);
+ }
+ }
+}
diff --git a/OneClick/ChangeSetting.xaml b/OneClick/ChangeSetting.xaml
new file mode 100644
index 0000000..260cab8
--- /dev/null
+++ b/OneClick/ChangeSetting.xaml
@@ -0,0 +1,420 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OneClick/ChangeSetting.xaml.cs b/OneClick/ChangeSetting.xaml.cs
new file mode 100644
index 0000000..48232c5
--- /dev/null
+++ b/OneClick/ChangeSetting.xaml.cs
@@ -0,0 +1,636 @@
+using Microsoft.Win32;
+using System;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace OneClick
+{
+ ///
+ /// ChangeSetting.xaml 的交互逻辑
+ ///
+ public partial class ChangeSetting : Window
+ {
+ private readonly RecipeManager _recipeManager;
+ private Recipe? _workingRecipe;
+
+ // 新的构造函数:注入外部 RecipeManager 实例
+ public ChangeSetting(RecipeManager recipeManager)
+ {
+ _recipeManager = recipeManager ?? throw new ArgumentNullException(nameof(recipeManager));
+
+ InitializeComponent();
+
+ // 事件绑定
+ AddRecipeButton.Click += AddRecipeButton_Click;
+ DeleteRecipeButton.Click += DeleteRecipeButton_Click;
+ BrowseFolderButton.Click += BrowseFolderButton_Click;
+ SaveButton.Click += SaveButton_Click;
+
+ RecipeComboBox.SelectionChanged += RecipeComboBox_SelectionChanged;
+ MotorSpeedSlider.ValueChanged += MotorSpeedSlider_ValueChanged;
+ LightIntensitySlider.ValueChanged += LightIntensitySlider_ValueChanged;
+ AxisComboBox.SelectionChanged += AxisComboBox_SelectionChanged;
+
+ LoadRecipeNamesToCombo();
+ InitializeAxisComboItems();
+ InitializeWorkingRecipe();
+ LoadWorkingRecipeToUI();
+ }
+
+ private void LoadRecipeNamesToCombo()
+ {
+ RecipeComboBox.ItemsSource = _recipeManager.GetNames().OrderBy(x => x).ToList();
+ if (_recipeManager.CurrentRecipe != null)
+ {
+ RecipeComboBox.SelectedItem = _recipeManager.CurrentRecipe.Name;
+ }
+ }
+
+ private void InitializeAxisComboItems()
+ {
+ // 依据实际项目轴数填充,这里示例填充 1-8
+ AxisComboBox.ItemsSource = Enumerable.Range(1, 8).ToList();
+ }
+
+ private void InitializeWorkingRecipe()
+ {
+ if (_recipeManager.CurrentRecipe != null)
+ {
+ _workingRecipe = CloneRecipe(_recipeManager.CurrentRecipe);
+ return;
+ }
+
+ // 若无当前配方,创建一个默认配方
+ _workingRecipe = new Recipe
+ {
+ Name = "Default",
+ CaptureIntervalMs = 1000,
+ SaveFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "OneClick"),
+ MotorSpeed = 1000,
+ SelectedAxis = 1,
+ LightIntensity = 50,
+ MotorRunTimeSec = 10
+ };
+
+ if (!_recipeManager.GetNames().Contains("Default"))
+ {
+ _recipeManager.Add(CloneRecipe(_workingRecipe));
+ _recipeManager.SetCurrent("Default");
+ LoadRecipeNamesToCombo();
+ RecipeComboBox.SelectedItem = "Default";
+ }
+ }
+
+ private void LoadWorkingRecipeToUI()
+ {
+ CaptureIntervalTextBox.Text = _workingRecipe?.CaptureIntervalMs?.ToString() ?? string.Empty;
+ SaveFolderTextBox.Text = _workingRecipe?.SaveFolder ?? string.Empty;
+ MotorSpeedTextBox.Text = _workingRecipe?.MotorSpeed?.ToString() ?? string.Empty;
+ MotorSpeedSlider.Value = _workingRecipe?.MotorSpeed.HasValue == true ? _workingRecipe!.MotorSpeed!.Value : 0;
+
+ // 光源亮度
+ LightIntensitySlider.Value = _workingRecipe?.LightIntensity.HasValue == true ? _workingRecipe!.LightIntensity!.Value : 0;
+
+ // 选择轴
+ if (_workingRecipe?.SelectedAxis.HasValue == true)
+ {
+ AxisComboBox.SelectedItem = _workingRecipe!.SelectedAxis!.Value;
+ }
+ else
+ {
+ AxisComboBox.SelectedItem = null;
+ }
+
+ // 转动时间(毫秒)
+ RotationTimeTextBox.Text = _workingRecipe?.MotorRunTimeSec?.ToString() ?? string.Empty;
+ }
+
+ private static Recipe CloneRecipe(Recipe r)
+ {
+ return new Recipe
+ {
+ Name = r.Name,
+ CaptureIntervalMs = r.CaptureIntervalMs,
+ SaveFolder = r.SaveFolder,
+ MotorSpeed = r.MotorSpeed,
+ // 包含新参数
+ SelectedAxis = r.SelectedAxis,
+ LightIntensity = r.LightIntensity,
+ MotorRunTimeSec = r.MotorRunTimeSec
+ };
+ }
+
+ private void RecipeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ var name = RecipeComboBox.SelectedItem as string;
+ if (string.IsNullOrWhiteSpace(name)) return;
+
+ var recipe = _recipeManager.Get(name);
+ if (recipe == null) return;
+
+ _workingRecipe = CloneRecipe(recipe);
+ LoadWorkingRecipeToUI();
+ }
+
+ private void AddRecipeButton_Click(object? sender, RoutedEventArgs e)
+ {
+ // 生成一个建议名称(保持与之前逻辑一致)
+ var baseName = "NewRecipe";
+ var idx = 1;
+ string suggested;
+ do
+ {
+ suggested = $"{baseName}{idx}";
+ idx++;
+ } while (_recipeManager.GetNames().Contains(suggested));
+
+ // 循环弹出输入框,直到用户取消或输入合法且不重复的名称
+ while (true)
+ {
+ var input = PromptForRecipeName(suggested);
+ if (input == null)
+ return; // 用户取消
+
+ input = input.Trim();
+ if (string.IsNullOrWhiteSpace(input))
+ {
+ MessageBox.Show(this, "配方名称不能为空,请重新输入。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+ suggested = input == string.Empty ? suggested : input;
+ continue;
+ }
+
+ if (ContainsInvalidFileNameChars(input))
+ {
+ MessageBox.Show(this, "配方名称包含非法字符(例如 \\ / : * ? \" < > | 等),请使用其他名称。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+ suggested = input;
+ continue;
+ }
+
+ if (_recipeManager.GetNames().Contains(input))
+ {
+ MessageBox.Show(this, "该配方名称已存在,请使用不同的名称。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+ suggested = input;
+ continue;
+ }
+
+ var newRecipe = new Recipe
+ {
+ Name = input,
+ CaptureIntervalMs = 1000,
+ SaveFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "OneClick"),
+ MotorSpeed = 1000,
+ SelectedAxis = 1,
+ LightIntensity = 50,
+ MotorRunTimeSec = 1000
+ };
+
+ if (_recipeManager.Add(newRecipe))
+ {
+ _recipeManager.SetCurrent(input);
+ _workingRecipe = CloneRecipe(newRecipe);
+ LoadRecipeNamesToCombo();
+ RecipeComboBox.SelectedItem = input;
+ LoadWorkingRecipeToUI();
+ }
+ return;
+ }
+ }
+
+ // 在内存中弹出一个简单的输入对话框,返回 null 表示取消
+ private string? PromptForRecipeName(string defaultName)
+ {
+ var dlg = new Window
+ {
+ Title = "输入配方名称",
+ Owner = this,
+ WindowStartupLocation = WindowStartupLocation.CenterOwner,
+ Width = 420,
+ Height = 150,
+ ResizeMode = ResizeMode.NoResize,
+ WindowStyle = WindowStyle.SingleBorderWindow,
+ ShowInTaskbar = false
+ };
+
+ var panel = new Grid
+ {
+ Margin = new Thickness(10)
+ };
+ panel.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
+ panel.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
+ panel.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
+
+ var label = new TextBlock
+ {
+ Text = "请输入配方名称:",
+ Margin = new Thickness(0, 0, 0, 6)
+ };
+ Grid.SetRow(label, 0);
+ panel.Children.Add(label);
+
+ var textBox = new TextBox
+ {
+ Text = defaultName ?? string.Empty,
+ MinWidth = 360
+ };
+ Grid.SetRow(textBox, 1);
+ panel.Children.Add(textBox);
+
+ var btnPanel = new StackPanel
+ {
+ Orientation = Orientation.Horizontal,
+ HorizontalAlignment = HorizontalAlignment.Right,
+ Margin = new Thickness(0, 8, 0, 0)
+ };
+
+ var okBtn = new Button
+ {
+ Content = "确定",
+ Width = 80,
+ IsDefault = true,
+ Margin = new Thickness(0, 0, 8, 0)
+ };
+ var cancelBtn = new Button
+ {
+ Content = "取消",
+ Width = 80,
+ IsCancel = true
+ };
+
+ btnPanel.Children.Add(okBtn);
+ btnPanel.Children.Add(cancelBtn);
+ Grid.SetRow(btnPanel, 2);
+ panel.Children.Add(btnPanel);
+
+ dlg.Content = panel;
+
+ okBtn.Click += (_, _) =>
+ {
+ dlg.DialogResult = true;
+ dlg.Close();
+ };
+
+ cancelBtn.Click += (_, _) =>
+ {
+ dlg.DialogResult = false;
+ dlg.Close();
+ };
+
+ // 聚焦并选择全部文本,便于用户直接输入
+ dlg.Loaded += (_, _) =>
+ {
+ textBox.Focus();
+ textBox.SelectAll();
+ };
+
+ var result = dlg.ShowDialog();
+ if (result == true)
+ return textBox.Text;
+ return null;
+ }
+
+ private static bool ContainsInvalidFileNameChars(string name)
+ {
+ var invalid = Path.GetInvalidFileNameChars();
+ return name.IndexOfAny(invalid) >= 0;
+ }
+
+ private void DeleteRecipeButton_Click(object? sender, RoutedEventArgs e)
+ {
+ var name = RecipeComboBox.SelectedItem as string;
+ if (string.IsNullOrWhiteSpace(name)) return;
+
+ if (_recipeManager.Remove(name))
+ {
+ LoadRecipeNamesToCombo();
+ // 切到任意一个剩余配方
+ var next = _recipeManager.GetNames().OrderBy(x => x).FirstOrDefault();
+ if (next != null)
+ {
+ _recipeManager.SetCurrent(next);
+ _workingRecipe = CloneRecipe(_recipeManager.Get(next)!);
+ RecipeComboBox.SelectedItem = next;
+ }
+ else
+ {
+ // 没有配方,创建默认
+ InitializeWorkingRecipe();
+ LoadRecipeNamesToCombo();
+ }
+ LoadWorkingRecipeToUI();
+ }
+ }
+
+ private void BrowseFolderButton_Click(object? sender, RoutedEventArgs e)
+ {
+ var dlg = new OpenFolderDialog
+ {
+ Title = "选择图片保存位置"
+ };
+
+ // 根据当前文本框内容设定初始目录
+ var current = SaveFolderTextBox.Text;
+ if (!string.IsNullOrWhiteSpace(current) && Directory.Exists(current))
+ {
+ dlg.InitialDirectory = current;
+ }
+
+ var result = dlg.ShowDialog(this);
+ if (result == true)
+ {
+ SaveFolderTextBox.Text = dlg.FolderName;
+ }
+ }
+
+ private void SaveButton_Click(object? sender, RoutedEventArgs e)
+ {
+ // 将 UI 的值写回工作配方
+ if (string.IsNullOrWhiteSpace(_workingRecipe?.Name))
+ {
+ MessageBox.Show("配方名称不能为空。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+
+ if (int.TryParse(CaptureIntervalTextBox.Text, out var interval))
+ _workingRecipe!.CaptureIntervalMs = interval;
+ else
+ _workingRecipe!.CaptureIntervalMs = null;
+
+ var folder = SaveFolderTextBox.Text;
+ _workingRecipe!.SaveFolder = string.IsNullOrWhiteSpace(folder) ? null : folder;
+
+ if (double.TryParse(MotorSpeedTextBox.Text, out var rpm))
+ _workingRecipe!.MotorSpeed = rpm;
+ else
+ _workingRecipe!.MotorSpeed = null;
+
+ // 新增:保存光源亮度和选择轴号
+ _workingRecipe!.LightIntensity = (int)Math.Round(LightIntensitySlider.Value);
+ var selectedAxisObj = AxisComboBox.SelectedItem;
+ if (selectedAxisObj is int axisNum)
+ {
+ _workingRecipe!.SelectedAxis = axisNum;
+ }
+ else
+ {
+ _workingRecipe!.SelectedAxis = null;
+ }
+
+ // 新增:保存转动时间(秒)
+ if (int.TryParse(RotationTimeTextBox.Text, out var rotMs))
+ _workingRecipe!.MotorRunTimeSec = rotMs;
+ else
+ _workingRecipe!.MotorRunTimeSec = null;
+
+ // 写入 RecipeManager 并设为当前
+ var exists = _recipeManager.Get(_workingRecipe!.Name!) != null;
+ if (exists)
+ _recipeManager.Update(CloneRecipe(_workingRecipe!));
+ else
+ _recipeManager.Add(CloneRecipe(_workingRecipe!));
+
+ _recipeManager.SetCurrent(_workingRecipe!.Name!);
+ _recipeManager.Save();
+
+ // 关闭并返回主界面
+ DialogResult = true;
+ Close();
+ }
+
+ private void MotorSpeedSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ MotorSpeedTextBox.Text = ((int)e.NewValue).ToString();
+ }
+
+ private void LightIntensitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ // 若需要在界面显示当前亮度值,可在此将值显示到 ToolTip 或状态文本
+ // 保留为轻量处理:无需文本框,值直接在保存时取用
+ }
+
+ private void AxisComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ // 轻量:选择变更时暂不立即写回,统一在保存时处理
+ }
+
+ private void TestLightButton_Click(object sender, RoutedEventArgs e)
+ {
+ var lightService = new LightSourceService();
+ lightService.TestSourceService();
+ }
+
+ private void SendLightCommandButton_Click(object sender, RoutedEventArgs e)
+ {
+ var cmd = LightCommandTextBox.Text?.Trim();
+ if (string.IsNullOrEmpty(cmd))
+ {
+ MessageBox.Show(this, "请输入要发送的光源指令。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+ LightCommandTextBox.Focus();
+ return;
+ }
+
+ var lightService = new LightSourceService();
+ try
+ {
+ var response = lightService.SendCommand(cmd);
+ if (!string.IsNullOrEmpty(response))
+ {
+ MessageBox.Show(this, "收到响应: " + response, "光源响应", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ else
+ {
+ MessageBox.Show(this, "未收到响应或响应为空。", "光源响应", MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(this, "发送命令时发生错误: " + ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ // 新增的占位事件处理器:开始旋转(后端由你实现)
+ private void StartRotationButton_Click(object sender, RoutedEventArgs e)
+ {
+ var axisService = new AxisService();
+ int axisNum = 1;
+ int speed = (int)MotorSpeedSlider.Value;
+ int time = 0;
+ var sel = AxisComboBox.SelectedItem;
+ if (sel is int i)
+ {
+ axisNum = i;
+ }
+ else if (sel is string s && int.TryParse(s, out var parsed))
+ {
+ axisNum = parsed;
+ }
+ // 解析 RotationTimeTextBox.Text 为 int
+ if (!int.TryParse(RotationTimeTextBox.Text, out time))
+ {
+ MessageBox.Show(this, "转动时间输入无效,已默认为 0。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+ time = 0;
+ }
+ axisService.TimelyRotate(1, (short)axisNum, speed, time);
+ //清除位置
+ //axisService.ResetPosition((short)axisNum, 1);
+ }
+
+ // 停止旋转
+ private void StopRotationButton_Click(object sender, RoutedEventArgs e)
+ {
+
+ var sel = AxisComboBox.SelectedItem;
+ var axisService = new AxisService();
+ if (sel is int i)
+ {
+ axisService.AxisStop(1, (short)i);
+ //axisService.ResetPosition((short)i, 1);
+ }
+ else if (sel is short s)
+ {
+ axisService.AxisStop(1, s);
+ //axisService.ResetPosition(s, 1);
+ }
+ else if (sel is string str && short.TryParse(str, out var p))
+ {
+ axisService.AxisStop(1, p);
+ //axisService.ResetPosition(p, 1);
+ }
+ else
+ {
+ // 处理未选择或不可解析的情况
+ }
+
+ }
+
+
+
+
+ private void EnableAxisButton_Click(object sender, RoutedEventArgs e)
+ {
+ var axisService = new AxisService();
+ int axisToEnable;
+ var sel = AxisComboBox.SelectedItem;
+ try
+ {
+ if (sel is int i)
+ {
+ axisToEnable = i;
+ }
+ else if (sel is string s && int.TryParse(s, out var parsed))
+ {
+ axisToEnable = parsed;
+ }
+
+ else
+ {
+ axisToEnable = 1;
+ MessageBox.Show(this, "未选择轴号,默认启用轴 1。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+
+ axisService.AxisOn((short)axisToEnable, 1);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(this, "启用轴时发生错误: " + ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void DisableAxisButton_Click(object sender, RoutedEventArgs e)
+ {
+ var axisService = new AxisService();
+ int axisToDisable;
+ var sel = AxisComboBox.SelectedItem;
+ try
+ {
+ if (sel is int i)
+ {
+ axisToDisable = i;
+ }
+ else if (sel is string s && int.TryParse(s, out var parsed))
+ {
+ axisToDisable = parsed;
+ }
+ else
+ {
+ axisToDisable = 1;
+ MessageBox.Show(this, "未选择轴号,默认禁用轴 1。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ axisService.AxisOff((short)axisToDisable, 1);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(this, "禁用轴时发生错误: " + ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+
+ }
+
+ private void ClearAlarmPositionButton_Click(object sender, RoutedEventArgs e)
+ {
+ var axisService = new AxisService();
+ int axisToClear;
+ var sel = AxisComboBox.SelectedItem;
+ try
+ {
+ if (sel is int i)
+ {
+ axisToClear = i;
+ }
+ else if (sel is string s && int.TryParse(s, out var parsed))
+ {
+ axisToClear = parsed;
+ }
+ else
+ {
+ axisToClear = 1;
+ MessageBox.Show(this, "未选择轴号,默认清除轴 1 的报警位置。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+
+ axisService.ResetAlarm((short)axisToClear, 1);
+ axisService.ResetPosition((short)axisToClear, 1);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(this, "清除报警位置时发生错误: " + ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void JogForwardButton_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+
+ var sel = AxisComboBox.SelectedItem;
+ var speed = (int)MotorSpeedSlider.Value;
+ var axisService = new AxisService();
+ axisService.JogMove(1, (short)sel,speed);
+
+ }
+
+ private void JogForwardButton_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ var sel = AxisComboBox.SelectedItem;
+ var axisService = new AxisService();
+ if (sel is int i)
+ {
+ axisService.AxisStop(1, (short)i);
+ }
+ else if (sel is short s)
+ {
+ axisService.AxisStop(1, s);
+ }
+ else if (sel is string str && short.TryParse(str, out var p))
+ {
+ axisService.AxisStop(1, p);
+ }
+ else
+ {
+ // 处理未选择或不可解析的情况
+ }
+ }
+
+ private void JogForwardButton_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+
+ }
+ }
+}
diff --git a/OneClick/LightSourceService.cs b/OneClick/LightSourceService.cs
new file mode 100644
index 0000000..fd71dde
--- /dev/null
+++ b/OneClick/LightSourceService.cs
@@ -0,0 +1,101 @@
+using System;
+using System.Net.Sockets;
+using System.Text;
+using System.Windows;
+
+namespace OneClick
+{
+ class LightSourceService
+ {
+ private static TcpClient? OpenSocket()
+ {
+ try
+ {
+ TcpClient tcpclient = new TcpClient();
+ tcpclient.Connect("192.168.0.7", 1234);
+ return tcpclient;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("光源连接失败: " + ex.Message, "连接错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ return null;
+ }
+ }
+
+ public int TestSourceService()
+ {
+ // 使用通用发送方法测试固定命令
+ var response = SendCommand("SA0000#");
+ if (!string.IsNullOrEmpty(response) && response.StartsWith("A", StringComparison.Ordinal))
+ {
+ //MessageBox.Show("光源通信成功!收到响应: " + response, "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+ return 0;
+ }
+ else if (response != null)
+ {
+ MessageBox.Show("光源响应异常,收到: " + response, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return 1;
+ }
+ return 1;
+ }
+
+ ///
+ /// 发送指定的原始指令到光源控制器,并尝试读取响应。
+ /// 调用者根据返回值判断是否通信成功;方法内部会在连接失败时弹窗提示错误。
+ ///
+ /// 要发送的命令(请包含必要的结束符,例如 #)
+ /// 发送/接收超时(毫秒)
+ /// 收到的响应字符串(可能为空),连接失败或异常时返回 null
+ public string? SendCommand(string command, int timeoutMs = 2000)
+ {
+ if (string.IsNullOrEmpty(command))
+ throw new ArgumentException("command 不能为空", nameof(command));
+
+ var tcpclient = OpenSocket();
+ if (tcpclient == null)
+ return null;
+
+ NetworkStream? networkstream = null;
+ try
+ {
+ tcpclient.ReceiveTimeout = timeoutMs;
+ tcpclient.SendTimeout = timeoutMs;
+
+ networkstream = tcpclient.GetStream();
+
+ byte[] sendbytes = Encoding.ASCII.GetBytes(command);
+ networkstream.Write(sendbytes, 0, sendbytes.Length);
+ networkstream.Flush();
+
+ // 读取响应(阻塞,受 ReceiveTimeout 控制)
+ byte[] buffer = new byte[1024];
+ int bytesRead = networkstream.Read(buffer, 0, buffer.Length); // 受 tcpclient.ReceiveTimeout 控制
+
+ if (bytesRead > 0)
+ {
+ string response = Encoding.ASCII.GetString(buffer, 0, bytesRead).Trim();
+ return response;
+ }
+ else
+ {
+ return string.Empty;
+ }
+ }
+ catch (SocketException se)
+ {
+ MessageBox.Show("光源通信超时或套接字错误: " + se.Message, "通信错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ return null;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("光源通信错误: " + ex.Message, "通信错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ return null;
+ }
+ finally
+ {
+ try { networkstream?.Close(); } catch { }
+ try { tcpclient.Close(); } catch { }
+ }
+ }
+ }
+}
diff --git a/OneClick/LoadingDialog.xaml b/OneClick/LoadingDialog.xaml
new file mode 100644
index 0000000..91e8710
--- /dev/null
+++ b/OneClick/LoadingDialog.xaml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/OneClick/LoadingDialog.xaml.cs b/OneClick/LoadingDialog.xaml.cs
new file mode 100644
index 0000000..44931a6
--- /dev/null
+++ b/OneClick/LoadingDialog.xaml.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace OneClick
+{
+ ///
+ /// LoadingDialog.xaml 的交互逻辑
+ ///
+ public partial class LoadingDialog : Window
+ {
+ public LoadingDialog()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/OneClick/MainWindow.xaml b/OneClick/MainWindow.xaml
new file mode 100644
index 0000000..08bb701
--- /dev/null
+++ b/OneClick/MainWindow.xaml
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OneClick/MainWindow.xaml.cs b/OneClick/MainWindow.xaml.cs
new file mode 100644
index 0000000..45b7c09
--- /dev/null
+++ b/OneClick/MainWindow.xaml.cs
@@ -0,0 +1,593 @@
+using Basler.Pylon;
+using HalconDotNet;
+using System;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Threading;
+using GTN; // 示例运动控制卡命名空间
+
+namespace OneClick
+{
+ public partial class MainWindow : Window
+ {
+ private readonly RecipeManager _recipeManager;
+ private readonly ICameraService _cameraService;
+ private HImage? image;
+
+ // 启动或刷新列表时抑制相机选择事件
+ private bool _suppressCameraSelectionChanged;
+ private readonly Stopwatch _displayStopwatch = new Stopwatch();
+ private readonly Dispatcher _uiDispatcher;
+
+ // 间隔保存相关
+ private DispatcherTimer? _captureTimer;
+ private int _captureIndex;
+ private string? _currentSaveFolder;
+
+ public MainWindow()
+ {
+ InitializeComponent();
+
+ var dataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OneClick");
+ var storePath = Path.Combine(dataDir, "recipes.json");
+
+ _recipeManager = new RecipeManager(storePath);
+ _cameraService = new BaslerCameraService();
+
+ Loaded += MainWindow_Loaded;
+ RescanButton.Click += RescanButton_Click;
+ CameraComboBox.SelectionChanged += CameraComboBox_SelectionChanged;
+ Closing += MainWindow_Closing;
+
+ _uiDispatcher = Dispatcher.CurrentDispatcher;
+
+ // 订阅相机服务事件
+ _cameraService.GrabStarted += CameraService_GrabStarted;
+ _cameraService.ImageGrabbed += CameraService_ImageGrabbed;
+ _cameraService.GrabStopped += CameraService_GrabStopped;
+ _cameraService.ConnectionLost += CameraService_ConnectionLost;
+ }
+
+
+
+
+ private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
+ {
+ // 载入配方列表到主界面下拉框
+ SettingsListBox.ItemsSource = _recipeManager.GetNames().OrderBy(x => x).ToList();
+ if (_recipeManager.CurrentRecipe != null)
+ {
+ SettingsListBox.SelectedItem = _recipeManager.CurrentRecipe.Name;
+ }
+
+ // 显示启动对话框
+ var loadingDialog = new LoadingDialog
+ {
+ Owner = this,
+ WindowStartupLocation = WindowStartupLocation.CenterOwner
+ };
+ loadingDialog.Show();
+
+ // 异步枚举相机并在 UI 线程更新列表(避免 UI 卡顿)
+ try
+ {
+ loadingDialog.LoadStatusMessage.Text = "正在初始化运动控制卡...";
+ await Task.Run(() =>
+ {
+ var axisService = new AxisService();
+ axisService.InitMotionCard();
+ Thread.Sleep(500); // 模拟初始化延迟
+ });
+
+ loadingDialog.LoadStatusMessage.Text = "正在启动光源...";
+ await Task.Run(() =>
+ {
+ var lightservice = new LightSourceService();
+ lightservice.TestSourceService();
+ Thread.Sleep(500); // 模拟初始化延迟
+ });
+
+
+ loadingDialog.LoadStatusMessage.Text = "正在启动相机...";
+ var devices = await Task.Run(() =>
+ {
+ try
+ {
+ return _cameraService.EnumerateDevices();
+ }
+ catch
+ {
+ return Enumerable.Empty();
+ }
+ });
+
+ _uiDispatcher.Invoke(() =>
+ {
+ _suppressCameraSelectionChanged = true;
+ try
+ {
+ var list = devices.ToList();
+ CameraComboBox.ItemsSource = list;
+ CameraComboBox.SelectedIndex = list.Count > 0 ? 0 : -1;
+ }
+ finally
+ {
+ _suppressCameraSelectionChanged = false;
+ }
+ });
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"枚举相机失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ finally
+ {
+ // 隐藏启动对话框
+ _uiDispatcher.BeginInvoke(new Action(() => loadingDialog.Close()));
+ }
+
+ try
+ {
+ var firstId = _cameraService.EnumerateDevices().FirstOrDefault();
+ if (!string.IsNullOrWhiteSpace(firstId))
+ {
+ _cameraService.Open(firstId);
+ _cameraService.Close();
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"相机初始化失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void RefreshCameraList()
+ {
+ // 枚举相机设备
+ var devices = _cameraService.EnumerateDevices();
+
+ // 在更新列表和默认选择期间抑制 SelectionChanged 事件
+ _suppressCameraSelectionChanged = true;
+ try
+ {
+ CameraComboBox.ItemsSource = devices;
+ CameraComboBox.SelectedIndex = devices.Count > 0 ? 0 : -1;
+ }
+ finally
+ {
+ _suppressCameraSelectionChanged = false;
+ }
+ }
+
+ private void RescanButton_Click(object sender, RoutedEventArgs e)
+ {
+ RefreshCameraList();
+ }
+
+ private void CameraComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
+ {
+ if (_suppressCameraSelectionChanged) return;
+
+ var id = CameraComboBox.SelectedItem as string;
+ if (string.IsNullOrWhiteSpace(id)) return;
+
+ try
+ {
+ _cameraService.StopGrabbing();
+ _cameraService.Close();
+ _cameraService.Open(id);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"打开相机失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void ChangeSettingButton_Click(object sender, RoutedEventArgs e)
+ {
+ // 通过构造函数注入同一个 RecipeManager 实例
+ var changeSettingWindow = new ChangeSetting(_recipeManager)
+ {
+ Owner = this,
+ WindowStartupLocation = WindowStartupLocation.CenterOwner
+ };
+
+ bool? dialogResult = changeSettingWindow.ShowDialog();
+ if (dialogResult == true)
+ {
+ // 直接从相同的 _recipeManager 刷新 UI(内存状态已被更新)
+ SettingsListBox.ItemsSource = _recipeManager.GetNames().OrderBy(x => x).ToList();
+ if (_recipeManager.CurrentRecipe != null)
+ {
+ SettingsListBox.SelectedItem = _recipeManager.CurrentRecipe.Name;
+ }
+ }
+ }
+
+ private void ResetSettingButton_Click(object sender, RoutedEventArgs e)
+ {
+ // 简单重置当前配方(示例)
+ var currentName = SettingsListBox.SelectedItem as string;
+ if (string.IsNullOrWhiteSpace(currentName))
+ {
+ MessageBox.Show("请先选择一个配方。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+ return;
+ }
+
+ var recipe = _recipeManager.Get(currentName);
+ if (recipe == null) return;
+
+ recipe.CaptureIntervalMs = 1000;
+ recipe.SaveFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "OneClick");
+ recipe.MotorSpeed = 1000;
+
+ _recipeManager.Update(recipe);
+ _recipeManager.Save();
+
+ MessageBox.Show("已重置当前配方为默认参数。", "完成", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+
+ private async void StartButton_Click(object sender, RoutedEventArgs e)
+ {
+ var currentName = SettingsListBox.SelectedItem as string;
+ if (string.IsNullOrWhiteSpace(currentName))
+ {
+ MessageBox.Show("请先选择一个配方。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+ return;
+ }
+
+ var recipe = _recipeManager.Get(currentName);
+ if (recipe == null)
+ {
+ MessageBox.Show("未找到所选配方。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (string.IsNullOrWhiteSpace(recipe.SaveFolder))
+ {
+ MessageBox.Show("保存位置未配置。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ Directory.CreateDirectory(recipe.SaveFolder);
+
+ var id = CameraComboBox.SelectedItem as string;
+ if (string.IsNullOrWhiteSpace(id))
+ {
+ MessageBox.Show("未选择相机。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ try
+ {
+ _cameraService.StopGrabbing();
+ _cameraService.Close();
+ _cameraService.Open(id);
+
+ // 启动持续抓取(参考示例)
+ if (!_cameraService.StartGrabbing(continuous: true))
+ {
+ MessageBox.Show("启动抓取失败。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ // 启动按配方的间隔保存
+ StartIntervalCapture(recipe);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"启动抓取失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ }
+
+ private void CameraService_GrabStarted(object? sender, EventArgs e)
+ {
+ _uiDispatcher.Invoke(() =>
+ {
+ _displayStopwatch.Reset();
+ });
+ }
+
+ private void CameraService_ImageGrabbed(object? sender, ImageGrabbedEventArgs e)
+ {
+ // 与示例一致:只显示最新帧,节流到约30FPS
+ if (!_displayStopwatch.IsRunning || _displayStopwatch.ElapsedMilliseconds > 33)
+ {
+ _displayStopwatch.Restart();
+
+ // 由于该事件可能在非 UI 线程,切回 UI 线程
+ _uiDispatcher.Invoke(() =>
+ {
+ try
+ {
+ using var grabResult = e.GrabResult;
+ if (grabResult == null || !grabResult.IsValid || !grabResult.GrabSucceeded) return;
+
+ var hImage = ConvertGrabResultToHalconImage(grabResult);
+ if (hImage == null) return;
+
+ image?.Dispose();
+ image = hImage;
+
+ // 显示到 HSmartWindowControl
+ HOperatorSet.DispImage(image, ImageWindow.HalconWindow);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"显示图像失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ });
+ }
+
+ // 释放克隆的抓取结果(仿照 WinForms 示例中 e.DisposeGrabResultIfClone)
+ e.DisposeGrabResultIfClone();
+ }
+
+ private void CameraService_GrabStopped(object? sender, GrabStopEventArgs e)
+ {
+ _uiDispatcher.Invoke(() =>
+ {
+ _displayStopwatch.Reset();
+ StopIntervalCapture();
+
+ if (e.Reason != GrabStopReason.UserRequest)
+ {
+ MessageBox.Show($"抓取错误:{e.ErrorMessage}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ });
+ }
+
+ private void CameraService_ConnectionLost(object? sender, EventArgs e)
+ {
+ _uiDispatcher.Invoke(() =>
+ {
+ _cameraService.StopGrabbing();
+ _cameraService.Close();
+ StopIntervalCapture();
+ RefreshCameraList();
+ MessageBox.Show("相机连接丢失。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ });
+ }
+
+ public HImage? ReadBuffer()
+ {
+ IGrabResult? grabResult = null;
+ try
+ {
+ grabResult = _cameraService.GrabOnePic();
+ if (grabResult == null || !grabResult.GrabSucceeded)
+ return null;
+
+ return ConvertGrabResultToHalconImage(grabResult);
+ }
+ finally
+ {
+ grabResult?.Dispose();
+ }
+ }
+
+ private HImage? ConvertGrabResultToHalconImage(IGrabResult grabResult)
+ {
+ var hImg = new HImage();
+
+ if (IsMonoData(grabResult))
+ {
+ // 对高位深单通道,统一转换到 Mono16 并以 16 位生成 Halcon 图像,避免 8 位截断
+ switch (grabResult.PixelTypeValue)
+ {
+ case PixelType.Mono10:
+ case PixelType.Mono10p:
+ case PixelType.Mono10packed:
+ case PixelType.Mono12:
+ case PixelType.Mono12p:
+ case PixelType.Mono12packed:
+ case PixelType.Mono16:
+ {
+ var converter = new PixelDataConverter { OutputPixelFormat = PixelType.Mono16 };
+ var bytes = new byte[grabResult.Width * grabResult.Height * 2]; // 16位
+ converter.Convert(bytes, grabResult);
+
+ var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
+ try
+ {
+ var ptr = handle.AddrOfPinnedObject();
+ // Halcon 中 16 位无符号类型为 "uint2"
+ hImg.GenImage1("uint2", grabResult.Width, grabResult.Height, ptr);
+ }
+ finally
+ {
+ handle.Free();
+ }
+ break;
+ }
+ default:
+ {
+ // 纯 8 位单通道,保持 8 位
+ var buffer = grabResult.PixelData as byte[];
+ if (buffer == null || buffer.Length < grabResult.Width * grabResult.Height)
+ return null;
+
+ var handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
+ try
+ {
+ var ptr = handle.AddrOfPinnedObject();
+ hImg.GenImage1("byte", grabResult.Width, grabResult.Height, ptr);
+ }
+ finally
+ {
+ handle.Free();
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ // 彩色:仍使用 RGB8packed(无损容器保存),若需原始 Bayer 可改为保存原始缓冲区而非去马赛克
+ var rgb = new byte[grabResult.Width * grabResult.Height * 3];
+ var converter = new PixelDataConverter { OutputPixelFormat = PixelType.RGB8packed };
+ converter.Convert(rgb, grabResult);
+
+ var handle = GCHandle.Alloc(rgb, GCHandleType.Pinned);
+ try
+ {
+ var ptr = handle.AddrOfPinnedObject();
+ hImg.GenImageInterleaved(ptr, "rgb", grabResult.Width, grabResult.Height, 0, "byte",
+ grabResult.Width, grabResult.Height, 0, 0, -1, 0);
+ }
+ finally
+ {
+ handle.Free();
+ }
+ }
+
+ return hImg;
+ }
+
+ // 窗口关闭处理:确保停止抓取并释放相机资源
+ private void MainWindow_Closing(object? sender, CancelEventArgs e)
+ {
+ try
+ {
+ // 停止抓取(若正在抓取)
+ _cameraService.StopGrabbing();
+ }
+ catch
+ {
+ // 忽略停止时的异常,仍尝试关闭资源
+ }
+
+ try
+ {
+ // 关闭并释放相机资源
+ _cameraService.Close();
+ }
+ catch
+ {
+ // 忽略关闭时的异常
+ }
+
+ StopIntervalCapture();
+
+ // 如果需要,终结 Pylon 库资源(只有在使用 Pylon.Initialize 时才需要)
+
+ }
+
+ private bool IsMonoData(IGrabResult iGrabResult)
+ {
+ switch (iGrabResult.PixelTypeValue)
+ {
+ case PixelType.Mono1packed:
+ case PixelType.Mono2packed:
+ case PixelType.Mono4packed:
+ case PixelType.Mono8:
+ case PixelType.Mono8signed:
+ case PixelType.Mono10:
+ case PixelType.Mono10p:
+ case PixelType.Mono10packed:
+ case PixelType.Mono12:
+ case PixelType.Mono12p:
+ case PixelType.Mono12packed:
+ case PixelType.Mono16:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ private void CameraTest_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ _cameraService.StopGrabbing();
+ StopIntervalCapture();
+ MessageBox.Show("已停止抓取。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"停止抓取失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ // ===== 新增:间隔保存实现 =====
+ private void StartIntervalCapture(Recipe recipe)
+ {
+ StopIntervalCapture();
+
+ _currentSaveFolder = recipe.SaveFolder;
+ if (string.IsNullOrWhiteSpace(_currentSaveFolder))
+ return;
+
+ Directory.CreateDirectory(_currentSaveFolder);
+
+ _captureIndex = 0;
+ _captureTimer = new DispatcherTimer(DispatcherPriority.Background, _uiDispatcher)
+ {
+ Interval = TimeSpan.FromMilliseconds(Math.Max(50, recipe.CaptureIntervalMs ?? 1000))
+ };
+ _captureTimer.Tick += CaptureTimer_Tick;
+ _captureTimer.Start();
+ }
+
+ private void StopIntervalCapture()
+ {
+ if (_captureTimer != null)
+ {
+ _captureTimer.Tick -= CaptureTimer_Tick;
+ _captureTimer.Stop();
+ _captureTimer = null;
+ }
+ }
+
+ private void CaptureTimer_Tick(object? sender, EventArgs e)
+ {
+ if (image == null || string.IsNullOrWhiteSpace(_currentSaveFolder))
+ return;
+
+ HImage? copy = null;
+ try
+ {
+ copy = image.Clone();
+ }
+ catch
+ {
+ copy?.Dispose();
+ return;
+ }
+
+ // 改为保存 tiff,无损且支持 16 位灰度
+ var fileName = $"{DateTime.Now:yyyyMMdd_HHmmss_fff}_{_captureIndex:D5}.tiff";
+ var fullPath = Path.Combine(_currentSaveFolder!, fileName);
+ _captureIndex++;
+
+ _ = Task.Run(() =>
+ {
+ try
+ {
+ if (copy != null)
+ {
+ // 第三个参数对 tiff 无效,仅用于 jpeg;此处传 0
+ HOperatorSet.WriteImage(copy, "tiff", 0, fullPath);
+ }
+ }
+ catch (Exception ex)
+ {
+ _uiDispatcher.BeginInvoke(() =>
+ {
+ MessageBox.Show($"保存图像失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ });
+ }
+ finally
+ {
+ copy?.Dispose();
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/OneClick/OneClick.csproj b/OneClick/OneClick.csproj
new file mode 100644
index 0000000..ca1df38
--- /dev/null
+++ b/OneClick/OneClick.csproj
@@ -0,0 +1,36 @@
+
+
+
+ WinExe
+ net8.0-windows
+ enable
+ enable
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ D:\Pylon\Development\Assemblies\Basler.Pylon\net8.0\x64\Basler.Pylon.dll
+
+
+ D:\MVTec\Halcon\HALCON-25.11-Progress\bin\dotnet35\halcondotnetxl.dll
+
+
+ D:\MVTec\Halcon\HALCON-25.11-Progress\bin\dotnet35\hdevenginedotnetxl.dll
+
+
+
+
diff --git a/OneClick/RecipeManager.cs b/OneClick/RecipeManager.cs
new file mode 100644
index 0000000..66729d3
--- /dev/null
+++ b/OneClick/RecipeManager.cs
@@ -0,0 +1,137 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text.Json;
+
+namespace OneClick
+{
+ public class RecipeManager
+ {
+ private readonly Dictionary _recipes = new();
+
+ // 当前配方(可选,但非常实用)
+ public Recipe? CurrentRecipe { get; private set; }
+
+ private readonly string _storePath;
+
+ public RecipeManager(string storePath)
+ {
+ _storePath = storePath;
+ Directory.CreateDirectory(Path.GetDirectoryName(_storePath)!);
+ Load();
+ }
+
+ ///
+ /// 新增配方
+ ///
+ public bool Add(Recipe recipe)
+ {
+ if (recipe == null || string.IsNullOrWhiteSpace(recipe.Name))
+ return false;
+
+ if (_recipes.ContainsKey(recipe.Name))
+ return false;
+
+ _recipes.Add(recipe.Name, recipe);
+ Save();
+ return true;
+ }
+
+ ///
+ /// 删除配方
+ ///
+ public bool Remove(string name)
+ {
+ if (!_recipes.Remove(name))
+ return false;
+
+ if (CurrentRecipe?.Name == name)
+ CurrentRecipe = null;
+
+ Save();
+ return true;
+ }
+
+ ///
+ /// 查询配方
+ ///
+ public Recipe? Get(string name)
+ {
+ _recipes.TryGetValue(name, out var recipe);
+ return recipe;
+ }
+
+ ///
+ /// 切换当前配方
+ ///
+ public bool SetCurrent(string name)
+ {
+ var recipe = Get(name);
+ if (recipe == null)
+ return false;
+
+ CurrentRecipe = recipe;
+ return true;
+ }
+
+ ///
+ /// 修改配方(按名字整体替换)
+ ///
+ public bool Update(Recipe recipe)
+ {
+ if (recipe == null || string.IsNullOrWhiteSpace(recipe.Name))
+ return false;
+
+ if (!_recipes.ContainsKey(recipe.Name))
+ return false;
+
+ _recipes[recipe.Name] = recipe;
+
+ if (CurrentRecipe?.Name == recipe.Name)
+ CurrentRecipe = recipe;
+
+ Save();
+ return true;
+ }
+
+ ///
+ /// 获取所有配方名(给 UI / 下拉框用)
+ ///
+ public IReadOnlyCollection GetNames()
+ {
+ return _recipes.Keys;
+ }
+
+ public void Save()
+ {
+ var list = new List(_recipes.Values);
+ var json = JsonSerializer.Serialize(list, new JsonSerializerOptions
+ {
+ WriteIndented = true
+ });
+ File.WriteAllText(_storePath, json);
+ }
+
+ public void Load()
+ {
+ if (!File.Exists(_storePath))
+ return;
+
+ try
+ {
+ var json = File.ReadAllText(_storePath);
+ var list = JsonSerializer.Deserialize>(json) ?? new List();
+ _recipes.Clear();
+ foreach (var r in list)
+ {
+ if (!string.IsNullOrWhiteSpace(r.Name))
+ _recipes[r.Name] = r;
+ }
+ }
+ catch
+ {
+ // 读失败保持空,不抛异常以避免影响启动
+ }
+ }
+ }
+}
diff --git a/OneClick/RecipePara.cs b/OneClick/RecipePara.cs
new file mode 100644
index 0000000..98a31b1
--- /dev/null
+++ b/OneClick/RecipePara.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace OneClick
+{
+ public class Recipe
+ {
+ // 配方名称
+ public string? Name { get; set; }
+ // 相机拍照间隔时间,单位毫秒
+ public int? CaptureIntervalMs { get; set; }
+ //保存文件夹路径
+ public string? SaveFolder { get; set; }
+ // 电机速度,单位RPM
+ public double? MotorSpeed { get; set; }
+ //电机转动时间,单位秒
+ public double? MotorRunTimeSec { get; set; }
+ // 光源强度,范围0-255
+ public int? LightIntensity { get; set; }
+ // 选择的轴号
+ public int? SelectedAxis { get; set; }
+ //
+
+
+ // 可根据需要扩展更多参数
+ }
+}
diff --git a/OneClick/gts.cs b/OneClick/gts.cs
new file mode 100644
index 0000000..70108d9
--- /dev/null
+++ b/OneClick/gts.cs
@@ -0,0 +1,2891 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace GTN
+{
+ public class mc
+ {
+ public const short CHANNEL_HOST=0;
+ public const short CHANNEL_UART=1;
+ public const short CHANNEL_SIM=2;
+ public const short CHANNEL_ETHER=3;
+ public const short CHANNEL_RS232=4;
+ public const short CHANNEL_PCIE=5;
+
+/*-----------------------------------------------------------*/
+/* */
+/*-----------------------------------------------------------*/
+
+ public const short CMD_SUCCESS=0;
+ public const short CMD_ERROR_READ_LEN= -2 ; /* ȡݳȴ */
+ public const short CMD_ERROR_READ_CHECKSUM=-3 ; /* ȡУʹ */
+ public const short CMD_ERROR_WRITE_BLOCK = -4 ; /* дݿ */
+ public const short CMD_ERROR_READ_BLOCK = -5 ; /* ȡݿ */
+ public const short CMD_ERROR_OPEN =-6 ; /* 豸 */
+ public const short CMD_ERROR_CLOSE =-6 ; /* ر豸 */
+ public const short CMD_ERROR_DSP_BUSY = -7; /* DSPæ */
+ public const short CMD_LOCK_ERROR = -8 ; /*߳Դæ*/
+ public const short CMD_ERROR_EXECUTE = 1;
+ public const short CMD_ERROR_VERSION_NOT_MATCH = 3;
+ public const short CMD_ERROR_PARAMETER= 7;
+ public const short CMD_ERROR_UNKNOWN =8 ; /* ֵָ֧ */
+
+
+ /*-----------------------------------------------------------*/
+ /* 궨 */
+ /*-----------------------------------------------------------*/
+ public const short MC_NONE = -1;
+ public const short MC_LIMIT_POSITIVE =0;
+ public const short MC_LIMIT_NEGATIVE = 1;
+ public const short MC_ALARM =(2);
+ public const short MC_HOME =(3);
+ public const short MC_GPI = (4);
+ public const short MC_ARRIVE = (5);
+// public const short MC_EGPI0 =(6);
+// public const short MC_EGPI1 = (7);
+// public const short MC_EGPI2 =(8);
+ public const short MC_MPG = (9);
+ public const short MC_ENABLE = (10);
+ public const short MC_CLEAR = (11);
+ public const short MC_GPO = (12);
+// public const short MC_EGPO0 = (13);
+// public const short MC_EGPO1 = (14);
+ public const short MC_HSO = (18);
+ public const short MC_DAC = (20);
+ public const short MC_STEP = (21);
+ public const short MC_PULSE = (22);
+ public const short MC_ENCODER = (23);
+ public const short MC_ADC = (24);
+ public const short MC_AU_ADC = (17);
+ public const short MC_AU_ENCODER = (26);
+ public const short MC_ABS_ENCODER = (29);
+ public const short MC_AXIS = (30);
+ public const short MC_PROFILE = (31);
+ public const short MC_CONTROL = (32);
+ public const short MC_TRIGGER = (40);
+ public const short MC_TERMINAL = (50);
+ public const short MC_EXT_MODULE = (60);
+ public const short MC_EXT_DI = (61);
+ public const short MC_EXT_DO = (62);
+ public const short MC_EXT_AI = (63);
+ public const short MC_EXT_AO = (64);
+ public const short MC_SCAN_CRD = (70);
+ public const short MC_POS_COMPARE = (80);
+ public const short MC_WATCH_VAR = (200);
+ public const short MC_WATCH_EVENT = (201);
+
+
+
+ public const short CORE_MODE_TIMER = (0);
+ public const short CORE_MODE_SYNCH = (1);
+ public const short CORE_MODE_EXTERNAL = (2);
+ public const short CORE_TASK_DEFAULT = (0);
+ public const short CORE_TASK_DLM = (1);
+ public const short SKIP_MODULE_SCAN = (0x001);
+ public const short SKIP_MODULE_POS_COMPARE = (0x002);
+ public const short SKIP_MODULE_CRD = (0x004);
+ public const short SKIP_MODULE_PLC = (0x010);
+ public const short SKIP_MODULE_DLM = (0x020);
+ public const short SKIP_MODULE_AXIS_CALCULATE =(0x100);
+ public const short SKIP_MODULE_WATCH =(0x800);
+
+ public enum ETimeElapse
+ {
+ TIME_ELAPSE_PROFILE = 1000,
+ TIME_ELAPSE_HOST_COMMAND_EXECUTE = 1220,
+ TIME_ELAPSE_ETHER_COMMAND_EXECUTE,
+ TIME_ELAPSE_PROFILE_CALCULATE = 6000,
+ TIME_ELAPSE_SCAN = 18000,
+ TIME_ELAPSE_AXIS_CHECK = 20000,
+ TIME_ELAPSE_AXIS_CALCULATE,
+ TIME_ELAPSE_ENCODER = 30000,
+ TIME_ELAPSE_DI = 31000,
+ TIME_ELAPSE_DO = 32000,
+ TIME_ELAPSE_AI = 33000,
+ TIME_ELAPSE_AO = 34000,
+ TIME_ELAPSE_TRIGGER = 38000,
+ TIME_ELAPSE_CONTROL = 40000,
+ TIME_ELAPSE_WATCH = 52000,
+ TIME_ELAPSE_TERMINAL = 53000,
+ TIME_ELAPSE_TERMINALDET = 54000,
+ }
+
+ //public struct TTerminalStatus
+ //{
+ // public ushort type;
+ // public short id;
+ // public Int32 status;
+ // public UInt32 synchCount;
+ // public UInt32 ringNetType;//
+ // public UInt32 coreStatus;//ģ˿״̬
+ // public UInt32 scoreDropCount;//ģSPORTʧ
+ // public UInt32 reserve1;
+ // public UInt32 reserve2;
+ // public UInt32 reserve3;
+ // public UInt32 reserve4;
+ // public UInt32 reserve5;
+ // public UInt32 reserve6;
+ // public UInt32 reserve7;
+ //}
+
+ public struct TPid
+ {
+ public double kp;
+ public double ki;
+ public double kd;
+ public double kvff;
+ public double kaff;
+ public Int32 IntegralLimit;
+ public Int32 derivativeLimit;
+ public short limit;
+ }
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetAuDac(short core, short dac,ref short pValue, short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAuDac(short core, short dac, out short pValue, short count, out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAuAdcValue(short core, short adc, out short pValue, short count, out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAuAdc(short core, short adc, out double pValue, short count, out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetGPIOConfig(short core, short station, Int32 effectiveLevel, Int32 direction);
+
+
+ /**
+ * @brief ˶,Ĭóʼ硣
+ * @param channel ˶ķʽ
+ * @param param
+ * @return
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_Open(short channel,short param);
+
+
+ /**
+ * @brief ر˶
+ * @return
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_Close();
+
+
+ /**
+ * @brief ȡ˶̼İ汾š
+ * @param core ˺š
+ * @param pVersion ȡ˶Ĺ̼汾ַ
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetVersion(short core,out string pVersion);
+
+
+ /**
+ * @brief ȡ̬İ汾š
+ * @param core ˺š
+ * @param type ͣtype=0,ȡgts.dllİ汾Ϣtype=4,ȡgt_rn.dllİ汾Ϣ;type=1,version.userλһ.
+ * @param pVersion ȡ̬汾
+ * @return 롣
+ */
+ public struct TVersion
+ {
+ public short year;
+ public short month;
+ public short day;
+ public short version;
+ public short user;
+ public short reserve1;
+ public short reserve2;
+ public short chip;
+ }
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetVersionEx(short core,short type,out TVersion pVersion);
+
+
+ /**
+ * @brief λ˶
+ * @param core ˺š
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_Reset(short core);
+
+
+ /**
+ * @brief ȡ˶ϵͳʱӡ
+ * @param core ˺š
+ * @param pClock ȡ˶ʱӣλ:ms
+ * @param pLoop ڲʹãĬֵΪNULLȡֵ
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetClock(short core, out UInt32 pClock, out UInt32 pLoop);
+
+
+ /**
+ * @brief ȡ˶ϵͳ߾ʱӡ
+ * @param core ˺š
+ * @param pClock ȡ˶ʱӣλ 250us
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetClockHighPrecision(short core,out UInt32 pClock);
+
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_ClearTime(short core,ETimeElapse item);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTime(short core, ETimeElapse item, out UInt32 pTime, out UInt32 pTimeMax, out UInt32 pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetCoreMode(short core,short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCoreMode(short core,out short pMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetCoreShare(short core,short type,short index,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCoreShare(short core,short type,out short pIndex,out short pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetCoreTask(short core,short task);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCoreTask(short core,out short pTask);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetResMax(short core,short type,out short pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetResCount(short core,short type,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetResCount(short core,short type,out short pCount);
+
+
+ /**
+ * @brief ȡ״̬
+ * @param core ˺š
+ * @param axis ʼţ
+ * @param pSts 32 λ״̬֡
+ * @param count ȡĬΪ11Զȡ8·
+ * @param pClock ȡʱӣ ĬֵΪNULLöȡʱӡ
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetSts(short core,short axis,out Int32 pSts,short count,out UInt32 pClock);
+
+
+ /**
+ * @brief ־Խޱ־λ־
+ * @param core ˺š
+ * @param axis ʼţ
+ * @param count ״̬ĬΪ 1
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_ClrSts(short core,short axis,short count);
+
+
+ /**
+ * @brief ʹܡ
+ * @param core ںˣ
+ * @param axis ŷʹܵıš
+ * @return 롣ֵΪ 1(1) ļбЧǷб(2) ǰڹ滮˶GTN_Stopֹͣ˶ٵøָ
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_AxisOn(short core,short axis);
+
+
+ /**
+ * @brief رʹܡ
+ * @param core ںˣ
+ * @param axis رŷʹܵıš
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_AxisOff(short core,short axis);
+
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_MultiAxisOn(short core,UInt32 mask);
+ [DllImport("gts.dll")]
+ public static extern short GTN_MultiAxisOff(short core, UInt32 mask);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetAxisOnDelayTime(short core,ushort delayTime);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAxisOnDelayTime(short core,out ushort pDelayTime);
+
+ /**
+ * @brief ֹͣһĹ滮˶ֹͣϵ˶ע⣺ҪֹͣϵֹͣӦϵеκһἴɡ
+ * @param core ںˣ
+ * @param mask λָʾҪֹͣ˶ŻϵšbitλΪ1ʱʾֹͣӦϵ
+ * @param option λָʾֹͣʽbitλΪ0ʱʾƽֹͣӦϵbitλΪ1ʱʾͣӦϵ
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_Stop(short core, Int32 mask, Int32 option);
+
+
+ /**
+ * @brief ָĹ滮λáֹ˶״̬Ĺ滮λá
+ * @param core ںˣ
+ * @param profile 滮ţ
+ * @param prfPos õĹ滮λõֵλpulse
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPrfPos(short core, short profile, Int32 prfPos);
+
+
+ /**
+ * @brief axis ϳɹ滮λú profile ͬaxis ϳɱλú encoder ͬ
+ * @param core ںˣ
+ * @param mask λʶҪλͬš 0ʾҪλͬ 1Ҫλͬ
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_SynchAxisPos(short core, Int32 mask);
+
+
+ /**
+ * @brief 滮λúʵλãƯ
+ * @param core ںˣ
+ * @param axis Ҫλʼţ
+ * @param count Ҫλ ĬֵΪ 1ȡֵΧͬ axis
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_ZeroPos(short core,short axis,short count);
+
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_SynchPrfPosWithEncPos(short core, short profile, short encoder);
+
+
+ /**
+ * @brief ȡλ״̬
+ * @param core ںˣ
+ * @param axis ţ
+ * @param pLimitPositive Ӳλʱλ״̬bit0λʱλ״̬bit1
+ * @param pLimitNegative Ӳλʱλ״̬bit0λʱλ״̬bit1
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetLimitStatus(short core,short axis,out short pLimitPositive,out short pLimitNegative);
+
+
+ /**
+ * @brief λģʽ
+ * @param core ںˣ
+ * @param axis ţ
+ * @param mode 0 SOFT_LIMIT_MODE_STOP //Խλλúʼֹͣ
+ 1 SOFT_LIMIT_MODE_LIMIT //λΧ֮
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetSoftLimitMode(short core,short axis,short mode);
+
+
+ /**
+ * @brief ȡλģʽ
+ * @param core ںˣ
+ * @param axis ţ
+ * @param mode 0 SOFT_LIMIT_MODE_STOP //Խλλúʼֹͣ
+ 1 SOFT_LIMIT_MODE_LIMIT //λΧ֮
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetSoftLimitMode(short core,short axis,out short pMode);
+
+
+ /**
+ * @brief λλ
+ * @param core ںˣ
+ * @param axis ţ
+ * @param positive λ滮λôڸֵʱλĬֵΪ 0x7fffffffʾλЧ
+ * @param negative Ӳλʱλ״̬bit0λʱλ״̬bit1
+ * @return 롣
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetSoftLimit(short core, short axis, Int32 positive, Int32 negative);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetSoftLimit(short core, short axis, out Int32 pPositive, out Int32 pNegative);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetAxisBand(short core, short axis, Int32 band, Int32 time);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetAxisMotionSmooth(short core, short axis, double time, double k);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAxisBand(short core, short axis, out Int32 pBand, out Int32 pTime);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPrfPos(short core,short profile,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPrfVel(short core,short profile,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPrfAcc(short core,short profile,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPrfMode(short core,short profile,out Int32 pValue, short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAxisPrfPos(short core,short axis,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAxisPrfPosCompensate(short core,short axis,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAxisPrfVel(short core,short axis,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAxisPrfAcc(short core,short axis,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAxisEncPos(short core,short axis,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAxisEncVel(short core,short axis,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAxisEncAcc(short core,short axis,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAxisError(short core,short axis,out double pValue, short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetControlFilter(short core,short control,short index);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetControlFilter(short core,short control,out short pIndex);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetControlSuperimposed(short core,short control,short superimposedType,short superimposedIndex);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetControlSuperimposed(short core,short control,out short pSuperimposedType,out short pSuperimposedIndex);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPid(short core,short control,short index,ref TPid pPid);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPid(short core,short control,short index,out TPid pPid);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetKvffFilter(short core,short control,short index,short kvffFilterExp,double accMax);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetKvffFilter(short core,short control,short index,out short pKvffFilterExp,out double pAccMax);
+ [DllImport("gts.dll")]
+ public static extern short GTN_Delay(short core,ushort ms);
+ [DllImport("gts.dll")]
+ public static extern short GTN_DelayHighPrecision(short core,ushort profile);
+
+ public const short STEP_DIR = 0;
+ public const short STEP_PULSE = 1;
+ public const short STEP_ORTHOGONAL = 2;
+
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_LoadConfig(short core,string pFile);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SaveConfig(short core,string pFile);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LoadTerminalConfig(short core,string pFile);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SaveTerminalConfig(short core,string pFile);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LoadExtModuleConfig(short core,string pFile);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SaveExtModuleConfig(short core,string pFile);
+ [DllImport("gts.dll")]
+ public static extern short GTN_AlarmOn(short core,short axis);
+ [DllImport("gts.dll")]
+ public static extern short GTN_AlarmOff(short core,short axis);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LmtsOn(short core,short axis,short limitType);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LmtsOff(short core,short axis,short limitType);
+ [DllImport("gts.dll")]
+ public static extern short GTN_StepDir(short core,short step);
+ [DllImport("gts.dll")]
+ public static extern short GTN_StepPulse(short core,short step);
+ [DllImport("gts.dll")]
+ public static extern short GTN_StepOrthogonal(short core,short step);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetMtrBias(short core,short dac,short bias);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetMtrBias(short core,short dac,out short pBias);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetMtrLmt(short core,short dac,short limit);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetMtrLmt(short core,short dac,out short pLimit);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetSense(short core,short dataType,short dataIndex,short value);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetSense(short core,short dataType,short dataIndex,out short pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EncOn(short core,short encoder);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EncOff(short core,short encoder);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPosErr(short core, short control, Int32 error);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPosErr(short core, short control, out Int32 pError);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetStopDec(short core,short profile,double decSmoothStop,double decAbruptStop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetStopDec(short core,short profile,out double pDecSmoothStop,out double pDecAbruptStop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_CtrlMode(short core,short axis,short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetStopIo(short core,short axis,short stopType,short inputType,short inputIndex);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetAdcFilterPrm(short core,short adc,double k);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAdcFilterPrm(short core,short adc,out double pk);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetAxisPrfVelFilter(short core,short axis,short filterNumExp);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAxisPrfVelFilter(short core,short axis,out short pFilterNumExp);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetAxisEncVelFilter(short core,short axis,short filterNumExp);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAxisEncVelFilter(short core,short axis,out short pFilterNumExp);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetProfileScale(short core, short i, Int32 alpha, Int32 beta);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetProfileScale(short core, short i, out Int32 pAlhpa, out Int32 pBeta);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEncoderScale(short core, short i, Int32 alpha, Int32 beta);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEncoderScale(short core, short i, out Int32 pAlhpa, out Int32 pBeta);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetAuEncoderScale(short core, short i, Int32 alpha, Int32 beta);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAuEncoderScale(short core, short i, out Int32 pAlhpa, out Int32 pBeta);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ReadAuEncPos(short core, short encoder, out double pPos, short count = 1);
+ public const short CAPTURE_HOME = (1);
+ public const short CAPTURE_INDEX = (2);
+ public const short CAPTURE_PROBE = (3);
+ public const short CAPTURE_HSIO0 = (6);
+ public const short CAPTURE_HSIO1 = (7);
+
+ public struct TTrigger
+ {
+ public short encoder;
+ public short probeType;
+ public short probeIndex;
+ public short sense;
+ public Int32 offset;
+ public UInt32 loop;
+ public short windowOnly;
+ public Int32 firstPosition;
+ public Int32 lastPosition;
+ }
+
+ public struct TTriggerAlign
+ {
+ public short encoder;
+ public short probeType;
+ public short probeIndex;
+ public short sense;
+ public Int32 offset;
+ public UInt32 loop;
+ public short windowOnly;
+ public short pad2;
+ public Int32 firstPosition;
+ public Int32 lastPosition;
+ }
+
+ public struct TTriggerStatus
+ {
+ public short execute;
+ public short done;
+ public Int32 position;
+ }
+
+ public struct TTriggerStatusEx
+ {
+ public short execute;
+ public short done;
+ public Int32 position;
+ public UInt32 clock;
+ public UInt32 loopCount;
+ }
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetTrigger(short core,short i,ref TTrigger pTrigger);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTrigger(short core,short i,out TTrigger pTrigger);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTriggerStatus(short core,short i,out TTriggerStatus pTriggerStatus,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTriggerStatusEx(short core,short i,out TTriggerStatusEx pTriggerStatusEx,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ClearTriggerStatus(short core,short i);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetCaptureMode(short core,short encoder,short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCaptureMode(short core,short encoder,out short pMode,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCaptureStatus(short core,short encoder,out short pStatus,out Int32 pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetCaptureSense(short core,short encoder,short mode,short sense);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ClearCaptureStatus(short core,short encoder);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetCaptureRepeat(short core,short encoder,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCaptureRepeatStatus(short core,short encoder,out short pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCaptureRepeatPos(short core, short encoder, out Int32 pValue, short startNum, short count);
+
+ public const short TRIGGER_DELTA_MODE_DEFAULT = (0);
+ public const short TRIGGER_DELTA_CHECKPOINT_MODE_AUTO = (0);
+ public const short TRIGGER_DELTA_CHECKPOINT_MODE_MANUAL = (1);
+ public struct TCheckpoint
+ {
+ public short mode;
+ public Int32 offset;
+ public short fifoIndex;
+ public UInt32 crossCount;
+ public short fifoDataCount;
+ public short dataReady;
+ public Int32 data;
+ public short dataIndex;
+ }
+ public struct TTriggerDeltaPrm
+ {
+ public short mode;
+ public short dir;
+ public short triggerIndex0;
+ public short triggerIndex1;
+ public short triggerIndex2;
+ }
+
+ public struct TTriggerDeltaInfo
+ {
+ public short enable;
+ public short checkpointCount;
+ public short fifoDataCount;
+ public short lostCount;
+ }
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_ClearTriggerDelta(short core,short index,short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_AddTriggerDeltaCheckpoint(short core, short index, short mode, Int32 offset, short fifo, ref short pIndex);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ReadTriggerDeltaCheckpointData(short core, short index, short checkpointIndex, out Int32 pBuf, short count, out short pReadCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_WriteTriggerDeltaCheckpointData(short core, short index, short checkpointIndex, ref Int32 pBuf, short count, ref short pWriteCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetTriggerDeltaPrm(short core,short index,ref TTriggerDeltaPrm pPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTriggerDeltaPrm(short core,short index,out TTriggerDeltaPrm pPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTriggerDeltaCheckpoint(short core,short index,short checkpointIndex,out TCheckpoint pCheckpoint);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTriggerDeltaInfo(short core,short index,out TTriggerDeltaInfo pTriggerDelta);
+ [DllImport("gts.dll")]
+ public static extern short GTN_TriggerDeltaOn(short core,short index);
+ [DllImport("gts.dll")]
+ public static extern short GTN_TriggerDeltaOff(short core,short index);
+
+
+ public struct TTrapPrm
+ {
+ public double acc;
+ public double dec;
+ public double velStart;
+ public short smoothTime;
+ }
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_Update(short core, Int32 mask);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPos(short core, short profile, Int32 pos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPos(short core, short profile, out Int32 pPos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetVel(short core,short profile,double vel);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetVel(short core,short profile,out double pVel);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_PrfTrap(short core,short profile);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetTrapPrm(short core,short profile,ref TTrapPrm pPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTrapPrm(short core,short profile,out TTrapPrm pPrm);
+
+
+ public struct TJogPrm
+ {
+ public double acc;
+ public double dec;
+ public double smooth;
+ }
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_PrfJog(short core,short profile);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetJogPrm(short core,short profile,ref TJogPrm pPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetJogPrm(short core,short profile,out TJogPrm pPrm);
+
+ public const short PT_MODE_STATIC = 0;
+ public const short PT_MODE_DYNAMIC = 1;
+
+ public const short PT_SEGMENT_NORMAL = 0;
+ public const short PT_SEGMENT_EVEN = 1;
+ public const short PT_SEGMENT_STOP = 2;
+
+ public struct TPtInfo
+ {
+ public double prfPos;
+ public Int32 loop;
+ public short mode;
+ public short fifoUse;
+ public short fifoPlace;
+ public short segmentNumber;
+ public UInt32 segmentReceive1;
+ public UInt32 segmentReceive2;
+ public UInt32 segmentExecute1;
+ public UInt32 segmentExecute2;
+ public UInt32 bufferReceive1;
+ public UInt32 bufferReceive2;
+ public UInt32 bufferExecute1;
+ public UInt32 bufferExecute2;
+ }
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_PrfPt(short core,short profile,short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPtLoop(short core, short profile, Int32 loop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPtLoop(short core, short profile, out Int32 pLoop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PtSpace(short core,short profile,out short pSpace,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PtSpaceEx(short core,short profile,out short pSpace,out short pListSpace,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PtData(short core,short profile,double pos,Int32 time,short type,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PtClear(short core,short profile,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PtStart(short core, Int32 mask, Int32 option);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPtMemory(short core,short profile,short memory);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPtMemory(short core,short profile,out short pMemory);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPtPrecisionMode(short core,short profile,short precisionMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPtPrecisionMode(short core,short profile,out short pPrecisionMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPtInfo(short core,short profile,out TPtInfo pPtInfo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPtLink(short core,short profile,short fifo,short list);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPtLink(short core,short profile,short fifo,out short pList);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PtDoBit(short core,short profile,short doType,short index,short value,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PtAo(short core,short profile,short aoType,short index,double value,short fifo);
+
+
+
+ public struct TPvtTableMovePrm
+ {
+ public short tableId;
+ public Int32 distance;
+ public double vm;
+ public double am;
+ public double jm;
+ public double time;
+ }
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_PrfPvt(short core,short profile);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPvtLoop(short core, short profile, Int32 loop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPvtLoop(short core, short profile, out Int32 pLoopCount, out Int32 pLoop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtStatus(short core,short profile,out short pTableId,out double pTime,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtStart(short core, Int32 mask);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtTableSelect(short core,short profile,short tableId);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_PvtTable(short core, short tableId, Int32 count, ref double pTime, ref double pPos, ref double pVel);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtTableEx(short core, short tableId, Int32 count, ref double pTime, ref double pPos, ref double pVelBegin, ref double pVelEnd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtTableComplete(short core, short tableId, Int32 count, ref double pTime, ref double pPos, ref double pA, ref double pB, ref double pC, double velBegin, double velEnd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtTablePercent(short core, short tableId, Int32 count, ref double pTime, ref double pPos, ref double pPercent, double velBegin);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtPercentCalculate(short core, Int32 n, ref double pTime, ref double pPos, ref double pPercent, double velBegin, ref double pVel);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtTableContinuous(short core, short tableId, Int32 count, ref double pPos, ref double pVel, ref double pPercent, ref double pVelMax, ref double pAcc, ref double pDec, double timeBegin);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtContinuousCalculate(short core, Int32 n, ref double pPos, ref double pVel, ref double pPercent, ref double pVelMax, ref double pAcc, ref double pDec, ref double pTime);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtTableMove(short core, short tableId, Int32 distance, double vm, double am, double jm, ref double pTime);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtTableMovePercent(short core, short tableId, Int32 distance, double vm,
+ double acc,double pa1,double pa2,
+ double dec,double pd1,double pd2,
+ ref double pVel,ref double pAcc,ref double pDec,ref double pTime);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtTableMovePercentEx(short core, short tableId, Int32 distance, double vm,
+ double acc,double pa1,double pa2,double ma,
+ double dec,double pd1,double pd2,double md,
+ ref double pVel,ref double pAcc,ref double pDec,ref double pTime);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PvtTableMoveTogether(short core,short tableCount,ref TPvtTableMovePrm pPvtTableMovePrm);
+ public const short GEAR_MASTER_ENCODER = 1;
+ public const short GEAR_MASTER_PROFILE = 2;
+ public const short GEAR_MASTER_AXIS = 3;
+ public const short GEAR_MASTER_AU_ENCODER = 4;
+
+ public const short GEAR_MASTER_ENCODER_OTHER = 101;
+ public const short GEAR_MASTER_AXIS_OTHER = 103;
+
+ public const short GEAR_EVENT_START = 1;
+ public const short GEAR_EVENT_PASS = 2;
+ public const short GEAR_EVENT_AREA = 5;
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_PrfGear(short core,short profile,short dir);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetGearMaster(short core,short profile,short masterIndex,short masterType,short masterItem);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetGearMaster(short core,short profile,out short pMasterIndex,out short pMasterType,out short pMasterItem);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetGearRatio(short core, short profile, Int32 masterEven, Int32 slaveEven, Int32 masterSlope);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetGearRatio(short core, short profile, out Int32 pMasterEven, out Int32 pSlaveEven, out Int32 pMasterSlope);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GearStart(short core, Int32 mask);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetGearEvent(short core, short profile, short gearevent, Int32 startPara0, Int32 startPara1);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetGearEvent(short core, short profile, out short pEvent, out Int32 pStartPara0, out Int32 pStartPara1);
+ public const short FOLLOW_SWITCH_SEGMENT = (1);
+ public const short FOLLOW_SWITCH_TABLE = (2);
+
+ public const short FOLLOW_MASTER_ENCODER = (1);
+ public const short FOLLOW_MASTER_PROFILE = (2);
+ public const short FOLLOW_MASTER_AXIS = (3);
+ public const short FOLLOW_MASTER_AU_ENCODER = (4);
+
+ public const short FOLLOW_MASTER_ENCODER_OTHER = (101);
+ public const short FOLLOW_MASTER_AXIS_OTHER = (103);
+
+ public const short FOLLOW_EVENT_START = (1);
+ public const short FOLLOW_EVENT_PASS = (2);
+
+ public const short FOLLOW_SEGMENT_NORMAL = (0);
+ public const short FOLLOW_SEGMENT_EVEN = (1);
+ public const short FOLLOW_SEGMENT_STOP = (2);
+ public const short FOLLOW_SEGMENT_CONTINUE = (3);
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_PrfFollow(short core,short profile,short dir);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetFollowMaster(short core,short profile,short masterIndex,short masterType,short masterItem);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowMaster(short core,short profile,out short pMasterIndex,out short pMasterType,out short pMasterItem);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetFollowLoop(short core, short profile, Int32 loop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowLoop(short core, short profile, out Int32 pLoop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetFollowEvent(short core, short profile, short followevent, short masterDir, Int32 pos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowEvent(short core, short profile, out short pEvent, out short pMasterDir, out Int32 pPos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowSpace(short core,short profile,out short pSpace,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowData(short core, short profile, Int32 masterSegment, double slaveSegment, short type, short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowClear(short core,short profile,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowStart(short core, Int32 mask, Int32 option);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowSwitch(short core,Int32 mask);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetFollowMemory(short core,short profile,short memory);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowMemory(short core,short profile,out short pMemory);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowStatus(short core,short profile,out short pFifoNum,out short pSwitchStatus);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetFollowPhasing(short core,short profile,short profilePhasing);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowPhasing(short core,short profile,out short pProfilePhasing);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_PrfFollowEx(short core,short profile,short dir);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetFollowMasterEx(short core,short profile,short masterIndex,short masterType,short masterItem);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowMasterEx(short core,short profile,out short pMasterIndex,out short pMasterType,out short pMasterItem);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetFollowLoopEx(short core, short profile, Int32 loop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowLoopEx(short core, short profile, out Int32 pLoop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetFollowEventEx(short core, short profile, short followevent, short masterDir, Int32 pos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowEventEx(short core, short profile, out short pEvent, out short pMasterDir, out Int32 pPos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowSpaceEx(short core,short profile,out short pSpace,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowDataPercentEx(short core,short profile,double masterSegment,double slaveSegment,short type,short percent,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowClearEx(short core,short profile,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowStartEx(short core, Int32 mask, Int32 option);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowSwitchEx(short core, Int32 mask);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetFollowMemoryEx(short core,short profile,short memory);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowMemoryEx(short core,short profile,out short pMemory);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowStatusEx(short core,short profile,out short pFifoNum,out short pSwitchStatus);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetFollowPhasingEx(short core,short profile,short profilePhasing);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowPhasingEx(short core,short profile,out short pProfilePhasing);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowSwitchNowEx(short core,short profile,short method,short buffer,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowDataPercent2Ex(short core,short profile,double masterSegment,double slaveSegment,double velBeginRatio,double velEndRatio,short percent,out short pPercent1,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFollowDataPercent2Ex(short core,double masterPos,double v1,double v2,double p,double p1,out double pSlavePos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowDoBitEx(short core,short profile,short doType,short index,short value,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowDelayEx(short core,short profile,UInt32 delayTime,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_FollowDiBitEx(short core,short profile,short diType,short index,short value,UInt32 time,short fifo);
+
+
+ public struct TMoveAbsolutePrm
+ {
+ public Int32 pos;
+ public double vel;
+ public double acc;
+ public double dec;
+ public short percent;
+ }
+
+ public struct TMoveAbsolutePrmEx
+ {
+ public Int32 pos; /*Ŀλ*/
+ public double vel; /*ٶ*/
+ public double acc; /*ٶȣλpulse/ms2*/
+ public double dec; /*ٶȣλpulse/ms2*/
+ public short percent; /*S߰ٷֱ*/
+ public double velStart; /*ٶȣλpulse/ms*/
+ public double velEnd; /*յٶȣλpulse/ms*/
+ public double accStartPercent; /*ٶʼٶȰٷֱ*/
+ public double decEndPercent; /*ٶյٶȰٷֱ*/
+ }
+
+ public struct TMoveVelocityPrm
+ {
+ public double vel; /*Ŀٶ*/
+ public double acc; /*ٶȣλpulse/ms2*/
+ public double dec; /*ٶȣλpulse/ms2*/
+ public double jerkBegin; /*ʼjerkλpulse/ms3*/
+ public double jerkEnd; /*Ŀٶʱjerkλpulse/ms3*/
+ public short direction; /*˶*/
+ }
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_MoveAbsolute(short core,short profile,ref TMoveAbsolutePrm pPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetMoveAbsolute(short core,short profile,out TMoveAbsolutePrm pPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_MoveAbsoluteEx(short core,short profile,ref TMoveAbsolutePrmEx pPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetMoveAbsoluteEx(short core,short profile,out TMoveAbsolutePrmEx pPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_MoveVelocity(short core,short profile,ref TMoveVelocityPrm pPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetMoveVelocity(short core,short profile,out TMoveVelocityPrm pPrm);
+
+
+ public struct TTransformOrthogonal
+ {
+ public short source;
+ public short enable;
+ public short x;
+ public short y;
+ public double theta; // degree
+ }
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetTransformOrthogonal(short core,short index,ref TTransformOrthogonal pOrthogonal);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTransformOrthogonal(short core,short index,out TTransformOrthogonal pOrthogonal);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTransformOrthogonalPosition(short core,short index,out double pPositionX,out double pPositionY);
+
+
+ public const short HOME_STAGE_IDLE = (0);
+ public const short HOME_STAGE_START = (1);
+
+ public const short HOME_STAGE_SEARCH_LIMIT = (10);
+ public const short HOME_STAGE_SEARCH_LIMIT_STOP = (11);
+
+ public const short HOME_STAGE_SEARCH_LIMIT_ESCAPE= (13);
+
+ public const short HOME_STAGE_SEARCH_LIMIT_RETURN= (15);
+ public const short HOME_STAGE_SEARCH_LIMIT_RETURN_STOP= (16);
+
+ public const short HOME_STAGE_SEARCH_HOME= (20);
+
+ public const short HOME_STAGE_SEARCH_HOME_RETURN= (25);
+
+ public const short HOME_STAGE_SEARCH_INDEX= (30);
+
+ public const short HOME_STAGE_SEARCH_GPI= (40);
+
+ public const short HOME_STAGE_SEARCH_GPI_RETURN = (45);
+
+ public const short HOME_STAGE_GO_HOME= (80);
+
+ public const short HOME_STAGE_END= (100);
+
+ public const short HOME_ERROR_NONE= (0);
+ public const short HOME_ERROR_NOT_TRAP_MODE= (1);
+ public const short HOME_ERROR_DISABLE = (2);
+ public const short HOME_ERROR_ALARM= (3);
+ public const short HOME_ERROR_STOP= (4);
+ public const short HOME_ERROR_STAGE= (5);
+ public const short HOME_ERROR_HOME_MODE = (6);
+ public const short HOME_ERROR_SET_CAPTURE_HOME= (7);
+ public const short HOME_ERROR_NO_HOME = (8);
+ public const short HOME_ERROR_SET_CAPTURE_INDEX = (9);
+ public const short HOME_ERROR_NO_INDEX = (10);
+
+ public const short HOME_MODE_LIMIT = (10);
+ public const short HOME_MODE_LIMIT_HOME = (11);
+ public const short HOME_MODE_LIMIT_INDEX= (12);
+ public const short HOME_MODE_LIMIT_HOME_INDEX= (13);
+
+ public const short HOME_MODE_HOME= (20);
+
+ public const short HOME_MODE_HOME_INDEX = (22);
+
+ public const short HOME_MODE_INDEX= (30);
+
+ public struct THomePrm
+ {
+ public short mode; // ģʽ
+ public short moveDir; // ʱ˶
+ public short indexDir; // Index
+ public short edge; // ò
+ public short triggerIndex; // ô
+ public short pad10; // 1
+ public short pad11; // 1
+ public short pad12; // 1
+ public double velHigh; // Homeٶ
+ public double velLow; // Indexٶ
+ public double acc;
+ public double dec;
+ public short smoothTime;
+ public short pad20; // 2
+ public short pad21; // 2
+ public short pad22; // 2
+ public Int32 homeOffset; // ԭƫ
+ public Int32 searchHomeDistance; // Home룬Ϊ0ʾ
+ public Int32 searchIndexDistance; // Index룬Ϊ0ʾ
+ public Int32 escapeStep; // 벽
+ public Int32 pad31; // 3
+ public Int32 pad32; // 3
+ public Int32 pad33; // 3
+ }
+
+ public struct THomeStatus
+ {
+ public short run;
+ public short stage;
+ public short error;
+ public short pad1;
+ public Int32 capturePos;
+ public Int32 targetPos;
+ }
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_GoHome(short core,short axis,ref THomePrm pHomePrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetHomePrm(short core,short axis,out THomePrm pHomePrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetHomeStatus(short core,short axis,out THomeStatus pHomeStatus);
+
+
+ public const short PLC_THREAD_MAX= (32);
+ public const short PLC_PAGE_MAX = (32);
+ public const short PLC_LOCAL_VAR_MAX= (1024);
+ public const short PLC_ACCESS_VAR_COUNT_MAX = (8);
+
+ public const short PLC_TIMER_TT = (0);
+ public const short PLC_TIMER_TF = (1);
+ public const short PLC_TIMER_TTF= (2);
+
+ public const short PLC_COUNTER_EQ= (0);
+ public const short PLC_COUNTER_LE= (1);
+ public const short PLC_COUNTER_GE= (2);
+
+ public const short PLC_COUNTER_EDGE_UP= (0);
+ public const short PLC_COUNTER_EDGE_DOWN= (1);
+ public const short PLC_COUNTER_EDGE_UP_DOWN= (2);
+
+ public const short PLC_FLANK_UP = (0);
+ public const short PLC_FLANK_DOWN= (1);
+ public const short PLC_FLANK_UP_DOWN= (2);
+
+ public enum EPlcBind
+ {
+ PLC_BIND_NONE,
+ PLC_BIND_DI,
+ PLC_BIND_DO,
+ PLC_BIND_TIMER,
+ PLC_BIND_COUNTER,
+ PLC_BIND_FLANK,
+ PLC_BIND_SRFF,
+ }
+
+ //public struct TVarInfo
+ //{
+ // public short id;
+ // public short dataType;
+ // public string name;
+ //}
+ public struct TVarInfo
+ {
+ public short id;
+ public short dataType;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
+ public string name;
+ //public string name;
+ }
+
+ public struct TBindDi
+ {
+ public short diType;
+ public short index;
+ public short reverse;
+ }
+
+ public struct TBindDo
+ {
+ public short doType;
+ public short index;
+ public short reverse;
+ }
+
+ public struct TBindTimer
+ {
+ public short timerType;
+ public Int32 delay;
+ public short inputVarId;
+ }
+
+ public struct TBindCounter
+ {
+ public short counterType;
+ public short edge;
+ public Int32 init;
+ public Int32 target;
+ public Int32 begin;
+ public Int32 end;
+ public short dir;
+ public Int32 unit;
+ public short inputVarId;
+ public short resetVarId;
+ }
+
+ public struct TBindFlank
+ {
+ public short flankType;
+ public short inputVarId;
+ }
+
+ public struct TBindSrff
+ {
+ public short setVarId;
+ public short resetVarId;
+ }
+
+ public struct TCompileInfo
+ {
+ public string pFileName;
+ public short pLineNo;
+ public string pMessage;
+ }
+
+ public struct TThreadSts
+ {
+ public short run;
+ public short error;
+ public double result;
+ public short line;
+ }
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_Compile(string pFileName,out TCompileInfo pWrongInfo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_Download(short core,string pFileName);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFunId(string pFunName,out short pFunId);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetVarId(string pFunName,string pVarName,out TVarInfo pVarInfo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_Bind(short core,short thread,short funId,short page);
+ [DllImport("gts.dll")]
+ public static extern short GTN_RunThread(short core,short thread);
+ [DllImport("gts.dll")]
+ public static extern short GTN_RunThreadPeriod(short core,short thread,short ms,short priority);
+ [DllImport("gts.dll")]
+ public static extern short GTN_StepThread(short core,short thread);
+ [DllImport("gts.dll")]
+ public static extern short GTN_StopThread(short core,short thread);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PauseThread(short core,short thread);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetThreadSts(short core,short thread,out TThreadSts pThreadSts);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetThreadTime(short core,short thread,out short pPeriod,out double pExecuteTime,out double pExecuteTimeMax);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetVarValue(short core,short page,ref TVarInfo pVarInfo,ref double pValue,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetVarValue(short core,short page,ref TVarInfo pVarInfo,out double pValue,short count);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_UnbindVar(short core,short thread);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BindDi(short core,short thread,ref TVarInfo pVarInfo,ref TBindDi pBindDi);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BindDo(short core,short thread,ref TVarInfo pVarInfo,ref TBindDo pBindDo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BindTimer(short core,short thread,ref TVarInfo pVarInfo,ref TBindTimer pBindTimer);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BindCounter(short core,short thread,ref TVarInfo pVarInfo,ref TBindCounter pBindCounter);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BindFlank(short core,short thread,ref TVarInfo pVarInfo,ref TBindFlank pBindFlank);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BindSrff(short core,short thread,ref TVarInfo pVarInfo,ref TBindSrff pBindSrff);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_GetBindDi(short core,out TVarInfo pVarInfo,out TBindDi pBindDi);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindDo(short core,out TVarInfo pVarInfo,out TBindDo pBindDo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindTimer(short core,out TVarInfo pVarInfo,out TBindTimer pBindTimer,out Int32 pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindCounter(short core,out TVarInfo pVarInfo,out TBindCounter pBindCounter,out Int32 pUnitCount,out Int32 pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindFlank(short core,out TVarInfo pVarInfo,out TBindFlank pBindFlank);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindSrff(short core,out TVarInfo pVarInfo,out TBindSrff pBindSrff);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_GetBindDiCount(short core,short thread,out short pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindDoCount(short core,short thread,out short pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindTimerCount(short core,short thread,out short pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindCounterCount(short core,short thread,out short pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindFlankCount(short core,short thread,out short pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindSrffCount(short core,short thread,out short pCount);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_GetBindDiInfo(short core,short thread,short index,out short pVar,out TBindDi pBindDi);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindDoInfo(short core,short thread,short index,out short pVar,out TBindDo pBindDo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindTimerInfo(short core,short thread,short index,out short pVar,out TBindTimer pBindTimer);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindCounterInfo(short core,short thread,short index,out short pVar,out TBindCounter pBindCounter);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindFlankInfo(short core,short thread,short index,out short pVar,out TBindFlank pBindFlank);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBindSrffInfo(short core,short thread,short index,out short pVar,out TBindSrff pBindSrff);
+
+
+
+ public const short INTERPOLATION_AXIS_MAX = (8);
+
+ public const short CRD_OPERATION_DATA_EXT_MAX = (2);
+
+
+ public const short CRD_BUFFER_MODE_DYNAMIC_DEFAULT = (0);
+ public const short CRD_BUFFER_MODE_DYNAMIC_KEEP = (1);
+ public const short CRD_BUFFER_MODE_STATIC_INPUT = (11);
+ public const short CRD_BUFFER_MODE_STATIC_READY = (12);
+ public const short CRD_BUFFER_MODE_STATIC_START = (13);
+
+ public const short INTERPOLATION_CIRCLE_PLAT_XY = (0);
+ public const short INTERPOLATION_CIRCLE_PLAT_YZ = (1);
+ public const short INTERPOLATION_CIRCLE_PLAT_ZX = (2);
+
+ public const short INTERPOLATION_HELIX_CIRCLE_XY_LINE_Z = (0);
+ public const short INTERPOLATION_HELIX_CIRCLE_YZ_LINE_X = (1);
+ public const short INTERPOLATION_HELIX_CIRCLE_ZX_LINE_Y = (2);
+ public const short INTERPOLATION_CIRCLE_DIR_CW = (0);
+ public const short INTERPOLATION_CIRCLE_DIR_CCW = (1);
+
+ public struct TCrdPrm
+ {
+ public short dimension; // ϵά
+ public short profile1; // profile
+ public short profile2; // profile
+ public short profile3; // profile
+ public short profile4; // profile
+ public short profile5; // profile
+ public short profile6; // profile
+ public short profile7; // profile
+ public short profile8; // profile
+ public double synVelMax; // ϳٶ
+ public double synAccMax; // ϳɼٶ
+ public short evenTime; // Сʱ
+ public short setOriginFlag; // ԭֵ־,0:Ĭϵǰ滮λΪԭλ;1:ûָԭλ
+ public Int32 originPos1; // ûָԭλ
+ public Int32 originPos2; // ûָԭλ
+ public Int32 originPos3; // ûָԭλ
+ public Int32 originPos4; // ûָԭλ
+ public Int32 originPos5; // ûָԭλ
+ public Int32 originPos6; // ûָԭλ
+ public Int32 originPos7; // ûָԭλ
+ public Int32 originPos8; // ûָԭλ
+ }
+
+ public struct TCrdBufOperation
+ {
+ public short flag; // ־ò岹ǷIOʱ
+ public ushort delay; // ʱʱ
+ public short doType; // IO,0:IO
+ public ushort doMask; // IO
+ public ushort doValue; // IOֵ
+ public ushort dataExt1; // չ
+ public ushort dataExt2; // չ
+ }
+
+ public struct TCrdData
+ {
+ public short motionType; // ˶,0:ֱ߲岹,1:Բ岹
+ public short circlePlat; // Բ岹ƽ
+ public Int32 pos1; // ǰθյλ
+ public Int32 pos2; // ǰθյλ
+ public Int32 pos3; // ǰθյλ
+ public Int32 pos4; // ǰθյλ
+ public Int32 pos5; // ǰθյλ
+ public Int32 pos6; // ǰθյλ
+ public Int32 pos7; // ǰθյλ
+ public Int32 pos8; // ǰθյλ
+ public double radius; // Բ岹İ뾶
+ public short circleDir; // Բת,0:˳ʱ;1:ʱ
+ public double center1; // Բ岹Բ
+ public double center2; // Բ岹Բ
+ public double vel; // ǰκϳĿٶ
+ public double acc; // ǰκϳɼٶ
+ public short velEndZero; // ־ǰεյٶǷǿΪ0,0:ǿΪ0;1:ǿΪ0
+ public TCrdBufOperation operation; // ʱIOṹ
+
+ public double cos1; // ǰθӦֵ
+ public double cos2; // ǰθӦֵ
+ public double cos3; // ǰθӦֵ
+ public double cos4; // ǰθӦֵ
+ public double cos5; // ǰθӦֵ
+ public double cos6; // ǰθӦֵ
+ public double cos7; // ǰθӦֵ
+ public double cos8; // ǰθӦֵ
+ public double velEnd; // ǰκϳյٶ
+ public double velEndAdjust; // յٶʱõı(ǰհģ)
+ public double r; // ǰκϳλ
+ }
+
+ public struct TCrdTime
+ {
+ public double time;
+ public Int32 segmentUsed;
+ public Int32 segmentHead;
+ public Int32 segmentTail;
+ }
+
+ public struct TBufFollowMaster
+ {
+ public Int16 crdAxis;
+ public Int16 masterIndex;
+ public Int16 masterType;
+ }
+
+ public struct TBufFollowEventCross
+ {
+ public Int32 masterPos;
+ public Int32 pad;
+ }
+
+ public struct TBufFollowEventTrigger
+ {
+ public Int16 triggerIndex;
+ public Int32 triggerOffset;
+ public Int32 pad;
+ }
+
+ public struct TCrdFollowPrm
+ {
+ public double velRatioMax;
+ public double accRatioMax;
+ public Int32 masterLead;
+ public Int32 masterEven;
+ public Int32 slaveEven;
+ public Int16 dir;
+ public Int16 smoothPercent;
+ public Int16 synchAlign;
+ }
+
+ public struct TCrdFollowStatus
+ {
+ public Int16 stage;
+ public double slavePos;
+ public double slaveVel;
+ public Int32 masterFrameWidth;
+ public Int32 masterFrameIndex;
+ public UInt32 loopCount;
+ }
+ public struct TAxisCircularSafetyZone
+ {
+ public short axisIndex1;
+ public short axisIndex2;
+ public short reservel1;
+ public short reservel2;
+ public double radius;
+ public double center1;
+ public double center2;
+ }
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetAxisCircularSafetyZone(short core, short safetyZoneIndex,short enable, ref TAxisCircularSafetyZone TAxisCircularSafetyZone);
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_SetCrdPrm(short core,short crd,ref TCrdPrm pCrdPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCrdPrm(short core,short crd,out TCrdPrm pCrdPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_CrdSpace(short core,short crd,out Int32 pSpace,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_CrdData(short core, short crd, IntPtr pCrdData, short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_CrdHsOn(short core, short crd, short fifo, short link, ushort threshold, short lookaheadInMc);
+ [DllImport("gts.dll")]
+ public static extern short GTN_CrdHsOff(short core, short crd, short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCrdHsPrm(short core, short crd, short fifo, out short pEnable, out short pLink, out ushort pThreshold, out short pLookAheadInMc);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetFlashPassword(short core, out ushort pPassword);
+ [DllImport("gts.dll")]
+ public static extern short GT_GetFlashPassword(out ushort pPassword);
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXY(short core,short crd,Int32 x,Int32 y,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYOverride2(short core,short crd,Int32 x,Int32 y,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYWN(short core,short crd,Int32 x,Int32 y,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYOverride2WN(short core,short crd,Int32 x,Int32 y,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_LnXYG0(short core,short crd,Int32 x,Int32 y,double synVel,double synAcc,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYG0Override2(short core,short crd,Int32 x,Int32 y,double synVel,double synAcc,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYG0WN(short core,short crd,Int32 x,Int32 y,double synVel,double synAcc,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYG0Override2WN(short core,short crd,Int32 x,Int32 y,double synVel,double synAcc,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_LnXYZ(short core,short crd,Int32 x,Int32 y,Int32 z,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZOverride2(short core,short crd,Int32 x,Int32 y,Int32 z,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZWN(short core,short crd,Int32 x,Int32 y,Int32 z,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZOverride2WN(short core,short crd,Int32 x,Int32 y,Int32 z,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_LnXYZG0(short core,short crd,Int32 x,Int32 y,Int32 z,double synVel,double synAcc,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZG0Override2(short core,short crd,Int32 x,Int32 y,Int32 z,double synVel,double synAcc,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZG0WN(short core,short crd,Int32 x,Int32 y,Int32 z,double synVel,double synAcc,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZG0Override2WN(short core,short crd,Int32 x,Int32 y,Int32 z,double synVel,double synAcc,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_LnXYZA(short core,short crd,Int32 x,Int32 y,Int32 z,Int32 a,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZAOverride2(short core,short crd,Int32 x,Int32 y,Int32 z,Int32 a,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZAWN(short core,short crd,Int32 x,Int32 y,Int32 z,Int32 a,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZAOverride2WN(short core,short crd,Int32 x,Int32 y,Int32 z,Int32 a,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_LnXYZAG0(short core,short crd,Int32 x,Int32 y,Int32 z,Int32 a,double synVel,double synAcc,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZAG0Override2(short core,short crd,Int32 x,Int32 y,Int32 z,Int32 a,double synVel,double synAcc,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZAG0WN(short core,short crd,Int32 x,Int32 y,Int32 z,Int32 a,double synVel,double synAcc,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZAG0Override2WN(short core,short crd,Int32 x,Int32 y,Int32 z,Int32 a,double synVel,double synAcc,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_LnXYZACUVW(short core,short crd,ref Int32 pPos,short posMask,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZACUVWOverride2(short core,short crd,ref Int32 pPos,short posMask,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZACUVWWN(short core,short crd,ref Int32 pPos,short posMask,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LnXYZACUVWOverride2WN(short core,short crd,ref Int32 pPos,short posMask,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_ArcXYR(short core,short crd,Int32 x,Int32 y,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcXYROverride2(short core,short crd,Int32 x,Int32 y,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcXYRWN(short core,short crd,Int32 x,Int32 y,double radius,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcXYROverride2WN(short core,short crd,Int32 x,Int32 y,double radius,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_ArcXYC(short core,short crd,Int32 x,Int32 y,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcXYCOverride2(short core,short crd,Int32 x,Int32 y,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcXYCWN(short core,short crd,Int32 x,Int32 y,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcXYCOverride2WN(short core,short crd,Int32 x,Int32 y,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_ArcYZR(short core,short crd,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcYZROverride2(short core,short crd,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcYZRWN(short core,short crd,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcYZROverride2WN(short core,short crd,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_ArcYZC(short core,short crd,Int32 y,Int32 z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcYZCOverride2(short core,short crd,Int32 y,Int32 z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcYZCWN(short core,short crd,Int32 y,Int32 z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcYZCOverride2WN(short core,short crd,Int32 y,Int32 z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcXYZ(short core, short crd, int x, int y, int z, double interX, double interY, double interZ, double synVel, double synAcc, double velEnd, short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_ArcZXR(short core,short crd,Int32 z,Int32 x,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcZXROverride2(short core,short crd,Int32 z,Int32 x,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcZXRWN(short core,short crd,Int32 z,Int32 x,double radius,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcZXROverride2WN(short core,short crd,Int32 z,Int32 x,double radius,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_ArcZXC(short core,short crd,Int32 z,Int32 x,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcZXCOverride2(short core,short crd,Int32 z,Int32 x,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcZXCWN(short core,short crd,Int32 z,Int32 x,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ArcZXCOverride2WN(short core,short crd,Int32 z,Int32 x,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_HelixXYRZ(short core,short crd,Int32 x,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixXYRZOverride2(short core,short crd,Int32 x,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixXYRZWN(short core,short crd,Int32 x,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixXYRZOverride2WN(short core,short crd,Int32 x,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_HelixXYCZ(short core,short crd,Int32 x,Int32 y,Int32 z,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixXYCZOverride2(short core,short crd,Int32 x,Int32 y,Int32 z,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixXYCZWN(short core,short crd,Int32 x,Int32 y,Int32 z,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixXYCZOverride2WN(short core,short crd,Int32 x,Int32 y,Int32 z,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_HelixYZRX(short core,short crd,Int32 x,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixYZRXOverride2(short core,short crd,Int32 x,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixYZRXWN(short core,short crd,Int32 x,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixYZRXOverride2WN(short core,short crd,Int32 x,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_HelixYZCX(short core,short crd,Int32 x,Int32 y,Int32 z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixYZCXOverride2(short core,short crd,Int32 x,Int32 y,Int32 z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixYZCXWN(short core,short crd,Int32 x,Int32 y,Int32 z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixYZCXOverride2WN(short core,short crd,Int32 x,Int32 y,Int32 z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_HelixZXRY(short core,short crd,Int32 x,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixZXRYOverride2(short core,short crd,Int32 x,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixZXRYWN(short core,short crd,Int32 x,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixZXRYOverride2WN(short core,short crd,Int32 x,Int32 y,Int32 z,double radius,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_HelixZXCY(short core,short crd,Int32 x,Int32 y,Int32 z,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixZXCYOverride2(short core,short crd,Int32 x,Int32 y,Int32 z,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixZXCYWN(short core,short crd,Int32 x,Int32 y,Int32 z,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_HelixZXCYOverride2WN(short core,short crd,Int32 x,Int32 y,Int32 z,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_BufIO(short core,short crd,short doType,ushort doMask,ushort doValue,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufDelay(short core,short crd,ushort delayTime,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufDA(short core,short crd,short chn,short daValue,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufLmtsOn(short core,short crd,short axis,short limitType,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufLmtsOff(short core,short crd,short axis,short limitType,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufSetStopIo(short core,short crd,short axis,short stopType,short inputType,short inputIndex,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufMove(short core,short crd,short moveAxis,Int32 pos,double vel,double acc,short modal,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufGear(short core,short crd,short gearAxis,Int32 pos,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufGearPercent(short core,short crd,short gearAxis,Int32 pos,short accPercent,short decPercent,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufStopMotion(short core,short crd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufSetVarValue(short core,short crd,short pageId,ref TVarInfo pVarInfo,double value,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufJumpNextSeg(short core,short crd,short axis,short limitType,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufSynchPrfPos(short core,short crd,short encoder,short profile,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufVirtualToActual(short core,short crd,short fifo);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_CrdStart(short core,short mask,short option);
+ [DllImport("gts.dll")]
+ public static extern short GTN_CrdStartStep(short core,short mask,short option);
+ [DllImport("gts.dll")]
+ public static extern short GTN_CrdStepMode(short core,short mask,short option);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetOverride(short core,short crd,double synVelRatio);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetOverride2(short core,short crd,double synVelRatio);
+ [DllImport("gts.dll")]
+ public static extern short GTN_InitLookAhead(short core,short crd,short fifo,double T,double accMax,short n,ref TCrdData pLookAheadBuf);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetLookAheadSpace(short core,short crd,out Int32 pSpace,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetLookAheadSegCount(short core,short crd,out Int32 pSegCount,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_CrdClear(short core,short crd,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_CrdStatus(short core,short crd,out short pRun,out Int32 pSegment,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetUserSegNum(short core,short crd,Int32 segNum,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetUserSegNum(short core,short crd,out Int32 pSegment,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetUserSegNumWN(short core,short crd,out Int32 pSegment,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetRemainderSegNum(short core,short crd,out Int32 pSegment,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetCrdStopDec(short core,short crd,double decSmoothStop,double decAbruptStop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCrdStopDec(short core,short crd,out double pDecSmoothStop,out double pDecAbruptStop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetCrdLmtStopMode(short core,short crd,short lmtStopMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCrdLmtStopMode(short core,short crd,out short pLmtStopMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetUserTargetVel(short core,short crd,out double pTargetVel);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetSegTargetPos(short core,short crd,out Int32 pTargetPos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCrdPos(short core,short crd,out double pPos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCrdVel(short core,short crd,out double pSynVel);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufLaserOn(short core,short crd,short fifo,short channel);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufLaserOff(short core,short crd,short fifo,short channel);
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufLaserPrfCmd(short core,short crd,double laserPower,short fifo,short channel);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_SetG0Mode(short core,short crd,short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetG0Mode(short core,short crd,out short pMode);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_SetCrdMapBase(short core,short crd,short Mapbase);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCrdMapBase(short core,short crd,out short pBase);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetCrdBufferMode(short core,short crd, short bufferMode,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCrdBufferMode(short core,short crd,out short pBufferMode,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCrdSegmentTime(short core,short crd,Int32 segmentIndex,out double pSegmentTime,out Int32 pSegmentNumber,short fifo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCrdTime(short core,short crd,out TCrdTime pTime,short fifo);
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetBacklash(short core,short axis,Int32 value,double changeValue,Int32 dir);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetBacklash(short core,short axis,out Int32 pValue,out double pChangeValue,out Int32 pDir);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetLeadScrewComp(short core,short axis,short n,Int32 startPos,Int32 lenPos,ref Int32 pPositive,ref Int32 pNegative);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EnableLeadScrewComp(short core,short axis,short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetLeadScrewCrossComp(short core,short axis,short n,Int32 startPos,Int32 lenPos,ref Int32 pPositive,out Int32 pNegative,short link);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EnableLeadScrewCrossComp(short core,short axis,short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCompensate(short core,short axis,out double pPitchError,out double pCrossError,out double pBacklashError,ref double pEncPos,ref double pPrfPos);
+ public struct TLeadScrewPrm
+ {
+ public short n;
+ public Int32 startPos;
+ public Int32 lenPos;
+ public Int32 pCompPos;
+ public Int32 pCompNeg;
+ }
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_SetLeadScrewTable(short core,short axis,ref TLeadScrewPrm pPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EnableLeadScrewTable(short core,short axis,Int32 error);
+ [DllImport("gts.dll")]
+ public static extern short GTN_DisableLeadScrewTable(short core,short axis);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetLeadScrewTablePrfPosCount(short core,Int32 encPos,out TLeadScrewPrm pPrm,out short pCountPositive,out short pCountNegative);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetLeadScrewTablePrfPosPositive(short core,Int32 encPos,out TLeadScrewPrm pPrm,short index,out Int32 pPrfPosPositive);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetLeadScrewTablePrfPosNegative(short core,Int32 encPos,out TLeadScrewPrm pPrm,short index,out Int32 pPrfPosNegative);
+ [DllImport("gts.dll")]
+ public static extern short GTN_InitMcAxisGap(short core);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetMcAxisGap(short core,short axis, short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetMcAxisGap(short core, short axis,ref short pActualAxisNo, short count);
+
+
+ public struct TCompensate2DTable
+ {
+ public short count1; // СֵΪ2
+ public short count2; // СֵΪ2
+ public Int32 posBegin1; // λ
+ public Int32 posBegin2; // λ
+ public Int32 step1; //
+ public Int32 step2; //
+ }
+
+ public struct TCompensate2D
+ {
+ public short enable; // 2Dʹܱ־
+ public short tableIndex; // ʹõ2D
+ public short axisType1; //
+ public short axisType2; //
+ public short axisIndex1; //
+ public short axisIndex2; //
+ }
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetCompensate2DTable(short core,short tableIndex,ref TCompensate2DTable pTable,ref Int32 pData,short extend);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCompensate2DTable(short core,short tableIndex,out TCompensate2DTable pTable,out short pExtend);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetCompensate2D(short core,short axis,ref TCompensate2D pComp2d);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCompensate2D(short core,short axis,out TCompensate2D pComp2d);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetCompensate2DValue(short core,short axis,out double pValue);
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetDo(short core,short doType,Int32 value);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetDoEx(short core, short doType, ref Int32 pValue, short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetDoBit(short core,short doType,short doIndex,short value);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetDo(short core,short doType,out Int32 pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetDoBitReverse(short core,short doType,short doIndex,short value,short reverseTime);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetDoBit(short core, short doType, short doIndex, out short pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetDiBit(short core, short diType, short diIndex,out short pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetDi(short core,short diType,out Int32 pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetDiReverseCount(short core,short diType,short diIndex,out UInt32 pReverseCount,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetDiReverseCount(short core,short diType,short diIndex,ref UInt32 pReverseCount,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetDiRaw(short core,short diType,out Int32 pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetDiEx(short core,short diType,out Int32 pValue,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetDac(short core,short dac,ref short pValue,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetDac(short core,short dac,out short pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAdc(short core,short adc,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAdcValue(short core,short adc,out short pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEncPos(short core,short encoder,Int32 encPos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEncPos(short core,short encoder,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEncPosPre(short core,short encoder,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEncVel(short core,short encoder,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_SetPlsPos(short core,short encoder,Int32 encPos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPlsPos(short core,short pulse,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPlsVel(short core,short pulse,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_SetAuEncPos(short core,short encoder,Int32 encPos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAuEncPos(short core,short encoder,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAuEncVel(short core,short encoder,out double pValue,short count,out UInt32 pClock);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAbsEncPos(short core,short encoder,out Int32 pValue,short mode,short param);
+
+
+
+ public const short POS_COMPARE_MODE_FIFO = (0);
+ public const short POS_COMPARE_MODE_LINEAR = (1);
+
+ public const short POS_COMPARE_OUTPUT_PULSE= (0);
+ public const short POS_COMPARE_OUTPUT_LEVEL= (1);
+
+ public const short POS_COMPARE_SOURCE_ENCODER = (0);
+ public const short POS_COMPARE_SOURCE_PULSE = (1);
+
+
+ public struct TPosCompareMode
+ {
+ public short mode; // FIFOģʽLinearģʽ
+ public short dimension; // 1D,2D
+ public short sourceMode; //
+ public short sourceX; // XȽԴ
+ public short sourceY; // YȽԴ
+ public short outputMode; // ģʽ塢ƽ
+ public short outputCounter; // Դ
+ public ushort outputPulseWidth; // ȣƽģʽЧ
+ public ushort errorBand; // άλñȽ
+ }
+
+ public struct TPosCompareLinear
+ {
+ public UInt32 count;
+ public ushort hso;
+ public ushort gpo;
+
+ public Int32 startPos;
+ public Int32 interval;
+ }
+
+ public struct TPosCompareLinear2D
+ {
+ public UInt32 count;
+ public ushort hso;
+ public ushort gpo;
+
+ public Int32 startPosX;
+ public Int32 startPosY;
+ public Int32 intervalX;
+ public Int32 intervalY;
+ }
+
+
+ public struct TPosCompareData
+ {
+ public Int32 pos;
+ public ushort hso;
+ public ushort gpo;
+ public UInt32 segmentNumber;
+ }
+
+ public struct TPosCompareData2D
+ {
+ public Int32 posX;
+ public Int32 posY;
+ public ushort hso;
+ public ushort gpo;
+ public UInt32 segmentNumber;
+ }
+ public struct TPosComparePsoPrm
+ {
+ public UInt32 count;
+ public Int16 hso;
+ public UInt16 gpo;
+ public Int32 startPosX;
+ public Int32 startPosY;
+ public Int32 syncPos;
+ public Int32 time;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
+ public short[] reserve;
+ }
+ public struct TPosCompareStatus
+ {
+ public ushort mode; // 0:FIFOģʽ1Linearģʽ
+ public ushort run;
+ public ushort space;
+ public UInt32 pulseCount;
+ public ushort hso;
+ public ushort gpo;
+ public UInt32 segmentNumber;
+ }
+
+ public struct TPosCompareInfo
+ {
+ public ushort config;
+ public ushort fifoEmpty;
+ public ushort head;
+ public ushort tail;
+ public UInt32 commandReceive;
+ public UInt32 commandSend;
+ public Int32 posX;
+ public Int32 posY;
+ }
+
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPosComparePsoPrm(short core, short index, ref TPosComparePsoPrm pPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PosCompareStart(short core,short index);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PosCompareStop(short core,short index);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PosCompareClear(short core,short index);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PosCompareStatus(short core,short index,out TPosCompareStatus pStatus);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PosCompareData(short core,short index,ref TPosCompareData pData);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PosCompareData2D(short core,short index,ref TPosCompareData2D pData);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPosCompareMode(short core,short index,ref TPosCompareMode pMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPosCompareMode(short core,short index,out TPosCompareMode pMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPosCompareLinear(short core,short index,ref TPosCompareLinear pLinear);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPosCompareLinear(short core,short index,out TPosCompareLinear pLinear);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPosCompareLinear2D(short core,short index,ref TPosCompareLinear2D pLinear);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPosCompareLinear2D(short core,short index,out TPosCompareLinear2D pLinear);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PosCompareInfo(short core,short index,out TPosCompareInfo pInfo);
+
+
+
+ public const short FIFO_MODE_STATIC = (0);
+ public const short FIFO_MODE_DYNAMIC = (1);
+
+ public const short SCAN_STATUS_WAIT = (0);
+ public const short SCAN_STATUS_RUN= (1);
+ public const short SCAN_STATUS_DONE = (2);
+
+ public struct TScanInit
+ {
+ public Int32 lookAheadNum; //ǰհ
+ public double time; //ʱ䳣
+ public double radiusRatio; //Ƶڲ
+ }
+
+ public struct TScanInfo
+ {
+ public UInt32 segmentNumber;
+ public ushort commandNumber;
+ public ushort prfVel;
+ public ushort fifoEmpty;
+ public ushort head;
+ public ushort tail;
+ public UInt32 commandReceive;
+ public UInt32 commandSend;
+ public UInt32 reserve1;
+ public UInt32 reserve2;
+ public UInt32 reserve3;
+ public UInt32 reserve4;
+ public UInt32 reserve5;
+ public UInt32 reserve6;
+ }
+
+ public struct TLaserInfo
+ {
+ public ushort hso;
+ public ushort powerMode;
+ public ushort power;
+ public ushort powerMax;
+ public ushort powerMin;
+ public ushort frequency;
+ public ushort pulseWidth;
+ }
+ public struct TLaserPowerPrm
+ {
+ public short n;
+ public double startVel;
+ public double power;
+ }
+
+ public struct TLaserPowerTable
+ {
+ public short n;
+ public double startVel;
+ public double velStep;
+ public double power;
+ }
+
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanInit(short core,ref TScanInit pScanInit,double jumpAcc,double markAcc,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanCrdDataEnd(short core,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetScanMode(short core,short mode,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetScanMode(short core,out short pMode,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ClearScanStatus(short core,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanGetCrdPos(short core,out short pPos,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanJump(short core,short x,short y,double vel,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanJumpPoint(short core,short x,short y,double vel,Int32 motionDelayTime,Int32 laserDelayTime,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanTimeJump(short core,short x,short y,ushort time,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanTimeJumpPoint(short core, short x, short y, ushort time, Int32 motionDelayTime, Int32 laserDelayTime, short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanMark(short core,short x,short y,double vel,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanTimeMark(short core, short x, short y, ushort time, short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetScanDaType(short core,short type,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanBufLaserPrfCmd(short core,double laserPower,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanBufIO(short core, ushort doType, ushort doMask, ushort doValue, short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanBufDelay(short core,Int32 time,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanBufDA(short core, ushort chn, short value, short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanBufLaserDelay(short core,short laserOnDelay,short laserOffDelay,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanBufLaserOutFrq(short core,double outFrq,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanBufSetPulseWidth(short core, ushort width, short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanBufLaserOn(short core,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanBufLaserOff(short core,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanBufStop(short core,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanLaserIntervalOnList(short core,Int32 time,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetScanDelayTime(short core, ushort maxJumpDelay, ushort markDelay, ushort multiMarkDelayConst, short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetScanDelayMode(short core, short multiMarkDelayMode, ushort multiMarkLaserOffDelay, ushort minJumpDelay, ushort jumpDelayLengthLimit, short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanStop(short core,short stopType,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanCrdSpace(short core,out short pSpace,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanCrdStart(short core,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanCrdClear(short core,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanCrdStatus(short core,out short pRun,out short pCmdId,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetHSIOOpt(short core, ushort value, ushort crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetHSIOOpt(short core, out short pValue, ushort crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetLaserMode(short core, ushort laserMode, ushort crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LaserPowerMode(short core, short laserPowerMode, double maxValue, double minValue, ushort crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LaserPrfCmd(short core, double power, ushort crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LaserOutFrq(short core, double outFrq, ushort crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPulseWidth(short core, ushort width, ushort crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetLevelDelay(short core, ushort highLevelDelay, ushort lowLevelDelay, ushort crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ScanInfo(short core,ref TScanInfo pScanInfo,short crd);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LaserInfo(short core,ref TLaserInfo pLaserInfo,short crd);
+
+
+ public const short DLM_FUNCTION_EVENT = (0);
+ public const short DLM_FUNCTION_TIMER= (1);
+ public const short DLM_FUNCTION_BACKGROUND= (2);
+ public const short DLM_FUNCTION_COMMAND = (3);
+
+ public const short DLM_FUNCTION_PROCEDURE= (7);
+
+ public const short DLM_FUNCTION_PROFILE_EVENT= (8);
+ public const short DLM_FUNCTION_PROFILE = (9);
+ public const short DLM_FUNCTION_PROFILE_SUPERIMPOSED= (10);
+ public const short DLM_FUNCTION_PROFILE_FILTER = (11);
+
+ public const short DLM_FUNCTION_SERVO_EVENT= (16);
+ public const short DLM_FUNCTION_SERVO = (17);
+ public const short DLM_FUNCTION_SERVO_SUPERIMPOSED= (18);
+ public const short DLM_FUNCTION_SERVO_FILTER = (19);
+
+ public const short DLM_LOAD_MODE_NONE = (0);
+ public const short DLM_LOAD_MODE_COMMAND= (1);
+ public const short DLM_LOAD_MODE_BOOT= (2);
+ public const short DLM_LOAD_MODE_RUN = (3);
+
+ public struct TDlmStatus
+ {
+ public Int32 version;
+ public Int32 date;
+ public short enable;
+ public Int32 function;
+ }
+
+ public struct TDlmFunction
+ {
+ public short function;
+ public short enable;
+ public Int32 value;
+ }
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_LoadDlm(short core,Int32 vender,Int32 module,string fileName,out short pId);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ProgramDlm(short core,short id,short loadMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetDlmLoadMode(short core,short id,out short pLoadMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_RunDlm(short core,short id);
+ [DllImport("gts.dll")]
+ public static extern short GTN_StopDlm(short core,short id);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetDlmStatus(short core,short id,out TDlmStatus pStatus);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetDlmFunction(short core,short id,ref TDlmFunction pFunction);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetDlmFunction(short core,short id,out TDlmFunction pFunction);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_DlmCommandInit(short core,short code,Int32 index);
+ [DllImport("gts.dll")]
+ public static extern short GTN_DlmCommandAdd16(short core,short value);
+ [DllImport("gts.dll")]
+ public static extern short GTN_DlmCommandAdd32(short core,Int32 value);
+ [DllImport("gts.dll")]
+ public static extern short GTN_DlmCommandAddFloat(short core,float value);
+ [DllImport("gts.dll")]
+ public static extern short GTN_DlmCommandAddDouble(short core,double value);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SendDlmCommand(short core,short id,out short pReturnValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_DlmCommandGet16(short core,out short pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_DlmCommandGet32(short core,out Int32 pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_DlmCommandGetFloat(short core,ref float pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_DlmCommandGetDouble(short core,out double pValue);
+
+
+ public const short WATCH_GROUP_TIMER = (0);
+ public const short WATCH_GROUP_BACKGROUND= (1);
+
+ public const short WATCH_LOAD_MODE_NONE = (0);
+ public const short WATCH_LOAD_MODE_BOOT= (2);
+ public const short WATCH_LOAD_MODE_RUN = (3);
+
+ public const short WATCH_MODE_STATIC= (0);
+ public const short WATCH_MODE_LOOP= (1);
+ public const short WATCH_MODE_DYNAMIC= (2);
+
+ public const short WATCH_EVENT_RUN= (1);
+ public const short WATCH_EVENT_START= (10);
+ public const short WATCH_EVENT_STOP= (20);
+ public const short WATCH_EVENT_OFF= (30);
+
+ public const short WATCH_CONDITION_EQ= (1);
+ public const short WATCH_CONDITION_NE= (2);
+ public const short WATCH_CONDITION_GE= (3);
+ public const short WATCH_CONDITION_LE= (4);
+
+ public const short WATCH_CONDITION_CHANGE_TO= (11);
+ public const short WATCH_CONDITION_CHANGE= (12);
+ public const short WATCH_CONDITION_UP= (13);
+ public const short WATCH_CONDITION_DOWN = (14);
+
+ public const short WATCH_CONDITION_REMAIN_AT= (21);
+ public const short WATCH_CONDITION_REMAIN= (22);
+ public const short WATCH_CONDITION_CROSS_POSITIVE= (23);
+ public const short WATCH_CONDITION_CROSS_NEGATIVE= (24);
+
+ public const short WATCH_CONDITION_NEAREST= (31);
+ public const short WATCH_CONDITION_DELTA= (32);
+
+ public struct TWatchVar
+ {
+ public ushort type;
+ public ushort index;
+ public ushort id;
+ }
+
+ public struct TWatchEvent
+ {
+ public ushort type;
+ public ushort loop;
+ public ushort watchCount;
+ public TWatchVar var;
+ public ushort condition;
+ public double value;
+ }
+
+ public struct TWatchVarInfo
+ {
+ public UInt32 pAddress;
+ public ushort length;
+ public short fraction;
+ public ushort format;
+ public ushort hex;
+ public ushort sign;
+ public ushort bit;
+ }
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_SetWatchGroup(short core,short group);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetWatchGroup(short core,out short pGroup);
+ [DllImport("gts.dll")]
+ public static extern short GTN_LoadWatchConfig(short core,string pFile);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SaveWatchConfig(short core,short group,string pFile);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PrintWatch(short core, string pFileName,Int32 start,UInt32 printCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ReadWatch(short core,short varIndex,ref double pBuffer,UInt32 bufferSize,ref UInt32 pReadCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ProgramWatch(short core,short loadMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetWatchLoadMode(short core,short group,out short pLoadMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetMcVar(short core,out TWatchVar pVar,out double pValue);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_ClearWatch(short core,short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_AddWatchVar(short core,ref TWatchVar pVar);
+ [DllImport("gts.dll")]
+ public static extern short GTN_AddWatchEvent(short core,ref TWatchEvent pEvent);
+ [DllImport("gts.dll")]
+ public static extern short GTN_WatchOn(short core,short interval,short mode,UInt32 count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_WatchOff(short core);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_GetWatchEvent(short core,short index,out TWatchEvent pEvent);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetWatchVar(short core,short index,out TWatchVar pVar,out TWatchVarInfo pVarInfo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetWatchModeEx(short core,short group,short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetWatchIntervalEx(short core,short group,short interval);
+
+
+ public const short TASK_SET_DO_BIT= (0x1101);
+ public const short TASK_SET_DAC = (0x1120);
+
+ public const short TASK_STOP= (0x1303);
+
+ public const short TASK_UPDATE_POS= (0x2002);
+ public const short TASK_UPDATE_VEL= (0x2004);
+
+ public const short TASK_PT_START= (0x2306);
+ public const short TASK_PVT_START= (0x2346);
+ public const short TASK_MOVE_ABSOLUTE= (0x2500);
+
+ public const short TASK_GEAR_START= (0x3005);
+
+ public const short TASK_FOLLOW_START= (0x310A);
+ public const short TASK_FOLLOW_SWITCH= (0x310B);
+
+ public const short TASK_CRD_START= (0x4004);
+ public const short TASK_SCAN_START= (0x4102);
+
+ public const short TASK_SET_DO_BIT_MODE_NONE = (0);
+ public const short TASK_SET_DO_BIT_MODE_TIME= (10);
+ public const short TASK_SET_DO_BIT_MODE_DISTANCE= (20);
+
+
+ public struct TTaskSetDoBit
+ {
+ public short doType;
+ public short doIndex;
+ public short doValue;
+ public short mode;
+ public Int32 parameter1;
+ public Int32 parameter2;
+ public Int32 parameter3;
+ public Int32 parameter4;
+ public Int32 parameter5;
+ public Int32 parameter6;
+ public Int32 parameter7;
+ public Int32 parameter8;
+ }
+
+ public struct TTaskSetDac
+ {
+ public short dac;
+ public short value;
+ }
+
+ public struct TTaskStop
+ {
+ public Int32 mask;
+ public Int32 option;
+ }
+
+ public struct TTaskFifoOperation
+ {
+ public short type;
+ public short index;
+ public short operation;
+ public short data1;
+ public short data2;
+ public short data3;
+ public short data4;
+ public short data5;
+ public short data6;
+ public short data7;
+ public short data8;
+ public short data9;
+ public short data10;
+ public short data11;
+ public short data12;
+ public short data13;
+ public short data14;
+ public short data15;
+ public short data16;
+ public short data17;
+ public short data18;
+ public short data19;
+ public short data20;
+ }
+
+ public struct TTaskUpdatePos
+ {
+ public short profile;
+ public Int32 pos;
+ }
+ public struct TTaskUpdateDistance
+ {
+ public short profile;
+ public short triggerIndex;
+ public Int32 distance;
+ }
+ public struct TTaskUpdateVel
+ {
+ public short profile;
+ public double vel;
+ }
+
+ public struct TTaskPtStart
+ {
+ public Int32 mask;
+ public Int32 option;
+ }
+
+ public struct TTaskPvtStart
+ {
+ public Int32 mask;
+ }
+
+ public struct TTaskGearStart
+ {
+ public Int32 mask;
+ }
+
+ public struct TTaskFollowStart
+ {
+ public Int32 mask;
+ public Int32 option;
+ }
+
+ public struct TTaskFollowSwitch
+ {
+ public Int32 mask;
+ }
+
+ public struct TTaskMoveAbsolute
+ {
+ public short profile;
+ public Int32 pos;
+ public double vel;
+ public double acc;
+ public double dec;
+ public short percent;
+ }
+
+ public struct TTaskCrdStart
+ {
+ public short mask;
+ public short option;
+ }
+
+ public struct TTaskScanStart
+ {
+ public short core;
+ public short index;
+ public short count;
+ }
+
+ public struct TEvent
+ {
+ public UInt32 loop;
+ public TWatchVar var;
+ public ushort condition;
+ public double value;
+ }
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_ClearEvent(short core);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ClearTask(short core);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ClearEventTaskLink(short core);
+ [DllImport("gts.dll")]
+ public static extern short GTN_AddTask(short core,short taskType, IntPtr pTaskData, ref short pTaskIndex);
+ [DllImport("gts.dll")]
+ public static extern short GTN_AddEvent(short core,ref TEvent pEvent,ref short pEventIndex);
+ [DllImport("gts.dll")]
+ public static extern short GTN_AddEventTaskLink(short core,short eventIndex,short taskIndex,ref short pLinkIndex);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEventCount(short core,out short pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEvent(short core,short eventIndex,out TEvent pEvent);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEventLoop(short core,short eventIndex,out UInt32 pEventLoop);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTaskCount(short core,out short pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEventTaskLinkCount(short core,out short pCount);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEventTaskLink(short core,short linkIndex,out short pEventIndex,out short pTaskIndex);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EventOn(short core,short eventIndex,short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EventOff(short core,short eventIndex,short count);
+
+
+ public const short TERMINAL_LOAD_MODE_NONE = (0);
+ public const short TERMINAL_LOAD_MODE_BOOT = (2);
+
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_TerminalInit(short core,short detect);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTerminalVersion(short core,short index,out TVersion pTerminalVersion);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetTerminalPermit(short core,short index,short dataType,ushort permit);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetTerminalPermitEx(short core, short station, short dataType, ref short pPermit, short index, short count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_PosComparePulse(short core, short index, short outputMode, short level, UInt16 outputPulseWidth);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPosComparePulseCount(short core, short index, Int32 count);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTerminalPermit(short core,short index,short dataType, out short pPermit);
+ [DllImport("gts.dll")]
+ public static extern short GTN_ProgramTerminalConfig(short core,short loadMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTerminalConfigLoadMode(short core,out short pLoadMode);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_ReadPhysicalMap();
+ [DllImport("gts.dll")]
+ public static extern short ConvertPhysical(short core,short dataType,short terminal,short index);
+ [DllImport("gts.dll")]
+
+ public static extern short GTN_SetRetainValue(short core,UInt32 address,short count,ref short pData);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetRetainValue(short core,UInt32 address,short count,out short pData);
+
+
+ //EtherCAT
+ public const short ECAT_STATE_OP = (2);
+ public const short ECAT_AXIS_MAX = (12);
+ public const short ECAT_MODE_HOMING = (6);
+ public const short ECAT_MODE_CSP = (8);
+ public const short ECAT_MODE_CSV = (9);
+ public const short ECAT_MODE_CST = (10);
+ public const short ECAT_MODE_PV = (3);
+ public const short ECAT_MODE_PT = (4);
+
+ public const short ECAT_PROBE_TRIGGER_TYPE_FIRST_EVENT = (0);
+ public const short ECAT_PROBE_TRIGGER_TYPE_CONTINUES = (1);
+ public const short ECAT_PROBE_TRIGGER_LEVEL_POS = (1);
+ public const short ECAT_PROBE_TRIGGER_LEVEL_NEG = (-1);
+ public const short ECAT_PROBE_TRIGGER_LEVEL_DUL = (0);
+
+ public const short ECAT_ACT_ENC_POS = (0);
+ public const short ECAT_ACT_ENC_VEL = (1);
+ public const short ECAT_ACT_CURRENT = (2);
+ public const short ECAT_ACT_TORQUE = (3);
+ public const short ECAT_ACT_CT = (4);
+
+
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatHomingPrm(short core,short axis,short method,double speed1,double speed2,double acc,Int32 offset,ushort probeFunction);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatHomingPrmEx(short core, short axis, short method, double speed1, double speed2, double acc, Int32 offset, ushort probeFunction);
+ [DllImport("gts.dll")]
+ public static extern short GTN_StartEcatHoming(short core,short axis);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetHomingMode(short core,short axis,short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatHomingPrmEx(short core, short axis, IntPtr psMethod, IntPtr pdSpeed1, IntPtr pdSpeed2, IntPtr pdAcc, IntPtr plOffset, IntPtr pusProbeFunction);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatHomingStatus(short core,short axis,out ushort homingStatus);
+ [DllImport("gts.dll")]
+ public static extern short GTN_StopEcatHoming(short core,short axis);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetTouchProbeFunction(short core,short axis,short ProbePrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetTouchProbeFunctionEx(short core,short axis,short Probe1Enable,short Probe1TriggerType,short Probe1TriggerLevel,short Probe2Enable,short Probe2TriggerType,short Probe2TriggerLevel);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetTouchProbeStatus(short core,short axis,out ushort probeStatus,out Int32 probe1PosValue,out Int32 probe1NegValue,out Int32 probe2PosValue,out Int32 probe2NegValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatGpioConfig(short core,short effectiveLevel,short direction);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatAxisOnThreshold(short core,short axis,ushort threshold);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisOnThreshold(short core,short axis,out ushort threshold);
+ [DllImport("gts.dll")]
+ public static extern short GTN_InitEcatComm(short core);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatPdoDataMode(short core, short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_InitEcatCommEx(short core, string eniFilePath);
+ [DllImport("gts.dll")]
+ public static extern short GTN_StartEcatComm(short core);
+ [DllImport("gts.dll")]
+ public static extern short GTN_IsEcatReady(short core,out short pStatus);
+ [DllImport("gts.dll")]
+ public static extern short GTN_TerminateEcatComm(short core);
+ [DllImport("gts.dll")]
+ public static extern short GTN_TerminateEcatCommEx(short core);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatErrorCode(short core,short axis,out ushort pErrorCode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetDcError(short core,out short pError);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatAxisMode(short core,short axis,short mode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisMode(short core,short axis,out ushort drvMode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatAxisPV(short core,short axis,Int32 velocity);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatAxisPT(short core,short axis,short torque);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatEncPos(short core,short axis,out Int32 pEncPos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAuxEncPos(short core,short axis,out Int32 pAuxEncPos);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatEncVel(short core,short axis,out Int32 pVelocity);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisAtlCurrent(short core,short axis,out short pCur);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisAtlTorque(short core,short axis,out short pTorque);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisAV(short core,short axis,out Int32 pVel);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisACT(short core,short axis,out short pCur,out short pTorque);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatMCType(short core,out short pType);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetPosScale(short core,short axis,ushort posScale);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetPosScale(short core,short axis,out ushort posScale);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisAI(short core,short axis,short channel,out short pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisDI(short core,short axis,out UInt32 pDi);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatAxisDO(short core,short axis,UInt32 DoValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisDO(short core,short axis,out UInt32 pDo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatAxisDOBit(short core,short axis,short bitOffset,byte DoBitValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisDOBit(short core,short axis,short bitOffset,out byte pDoBitValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatSlaves(short core,out short pSlaveMotionCnt, out short pSlaveIOCnt);
+ public struct TSlaveInfo
+ {
+ public Int32 slave_cnt;
+ public Int32 slave_type;
+ public Int32 motion_cnt;
+ public Int32 io_nmap;
+ public Int32 io_length;
+ public UInt32 Vid;
+ public UInt32 Pid;
+ public Int32 io_type;
+ }
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatSlaveInfo(short core,short slave,out TSlaveInfo pSlaveinfo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisPE(short core,short axis,out Int32 pPosErr);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatRawData(short core,ushort offset,ushort nByteSize,ref byte pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatSlaveObjectData(short core, short slaveIndex, ushort objectIndex, ushort objectSubIndex, ref byte pValue, uint data_size, out ushort pOpModee);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatRawData(short core,ushort offset,ushort nByteSize,out byte pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatSlaveObjectData(short core, short slaveIndex, ushort objectIndex, ushort objectSubIndex, out byte pValue, uint data_size, out ushort pOpModee);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatAxisTorqueOffset(short core,short axis,short torqueOffset);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisTorqueOffset(short core,short axis,out short pTorqueOffset);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatPdoLength(short core,out short pPdoLen);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetAuxEncoderCapture(short core,short encoder,short CapPrm);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetAuxEncoderCaptureEx(short core,short encoder,short CapUpEnable,short CapUpIO,short CapDnEnable,short CapDnIO);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetAuxEncoderCaptureStatus(short core,short encoder,out ushort CapSts,out Int32 PosValue,out Int32 NegValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EcatSDODownload(short core,ushort slave,ushort index,byte subindex,ref byte data,UInt32 data_size,out UInt32 abort_code);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EcatSDOUpload(short core,ushort slave,ushort index,byte subindex,out byte target,UInt32 target_size,out UInt32 result_size,out UInt32 abort_code);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EcatIOReadInput(short core,ushort slave,ushort offset,ushort nSize,out byte pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EcatIOReadOutput(short core, ushort slaveno, ushort offset, ushort nSize, out byte pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EcatIOWriteOutput(short core,ushort slave,ushort offset,ushort nSize,ref byte pValue);
+ [DllImport ("gts.dll")]
+ public static extern short GTN_EcatIOBitWriteOutput (short core, ushort slaveno, ushort offset, short Index, byte value );
+ [DllImport("gts.dll")]
+ public static extern short GTN_EcatIOBitReadInput(short core, ushort slaveno, ushort offset, ushort Index, out byte pValue);
+ [DllImport("gts.dll")]
+ public static extern short GTN_EcatIOBitReadOutput(short core, ushort slaveno, ushort offset, ushort Index, out byte pValue);
+
+ [DllImport ("gts.dll")]
+ public static extern short GTN_EcatIOSynch (short core);
+ [DllImport ("gts.dll")]
+ public static extern short GTN_GetEcatAxisPdoData (short core,short axis, ushort objectWord, out byte pValue );
+ [DllImport("gts.dll")]
+ public static extern short GTN_RelateEcatSlaveToMcGpoBit(short core,short gpoIndex,short slave,short slaveType,short bitOffset,short pdoOffset);
+ [DllImport("gts.dll")]
+ public static extern short GTN_RelateEcatSlaveToMcGpiBit(short core, short gpi, short ecatIndex, short ecatType, short bitoffset, short pdoOffset);
+ [DllImport("gts.dll")]
+ public static extern short GTN_RelateEcatSlaveToMcAuEncoderEx(short core, short auenc, short ecatIndex, short ecatType, short pdoOffset,short pdoByteLength);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetMcEcatAxisNum(short core,ref short pNum);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatAxisLmtHomeIndex(short core,short axis,short index_LimitN, short index_LimitP, short index_Home);
+
+ public struct TEcatErrInfo
+ {
+ public short dcError;
+ public short workingCountErrorCnt;
+ public short ecatCommStatus;
+ public short workingCount;
+ public short offlineFlag;
+ public short dump;
+ public short dump1;
+ public short dump2;
+ }
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatDcErrorEx(short core, ref TEcatErrInfo pEcatErrorInfo);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatErrorCode(short core, short axis, out short pErrorCode);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatSlavePdo(short core, short slaveIndex, ushort Object, ushort objectSubIndex, ref byte pValue, uint data_size);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatSlavePdo(short core, short slaveIndex, ushort Object, ushort objectSubIndex, out byte pValue, uint data_size);
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatRawDataPro(short core, ushort offset, ushort nByteSize, ref byte pValue, short chn);
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatRawDataPro(short core, ushort offset, ushort nByteSize, short mode, out byte pValue, short chn);
+ [DllImport("gts.dll")]
+ public static extern short GTN_RelateEcatSlaveToMcMpgEncoder(short core, short mpg, short ecatAxisIndex);
+ [DllImport("gts.dll")]
+ public static extern short GTN_RelateEcatSlaveToMcAuEncoder(short core, short auenc, short ecatAxisIndex);
+ [DllImport("gts.dll")]
+ public static extern short GTN_RelateEcatSlaveToMcMpgDi(short core, short mpg, short ecatAxisIndex, short bitoffset);
+ [DllImport("gts.dll")]
+ public static extern short GTN_RelateEcatSlaveToMcMpgDiEx(short core, short mpg, short ecatIndex, short ecatType, short bitoffset, short pdoOffset);
+
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_RelateEcatSlaveToMcMpgEncoderEx(short core, short mpg, short ecatIndex, short ecatType, short pdoOffset, short pdoByteLength);
+
+
+ /**
+ * @brief ʼֹܡ
+ * @param core ˺š
+ * @param mode ѡԴ MC_MPG 9,ʹMPG; MC_AU_ENCODER 26 ,ʹø; MC_ENCODER 23,ʹ
+ * @return
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_HandwheelInit(short core, short mode);
+
+
+ /**
+ * @brief
+ * @param core ˺š
+ * @param slave ţ1ʼ
+ * @param master ţ1ʼ
+ * @param masterEven ᴫϵλƣȡֵ[-32768,32767]
+ * @param slaveEven ᴫϵλơϵıֵdzֱȣ
+ * @param intervalTime λƲʱȡֵ[1,32767]λ滮ڡ
+ * @param acc дļٶȣֵ
+ * @param dec дļٶȣֵ
+ * @param vel дٶȣֵ
+ * @param stopWaitTime жֹͣʱ䣬ȡֵ[1,32767]λ滮ڡٸʱἱͣᾭʱֹֹͣ
+ * @return 1˶ 7ȡֵΧ
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_StartHandwheel(short core, short slave, short master, short masterEven, short slaveEven, short intervalTime, double acc, double dec, double vel, short stopWaitTime);
+
+
+ /**
+ * @brief ֹֹͣܡ
+ * @param core ˺š
+ * @param slave ţ1ʼ
+ * @return
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_EndHandwheel(short core, short slave);
+
+ public struct TMpgInfo
+ {
+ public double pos;
+ public double vel;
+ public double reserve1;
+ public double reserve2;
+ public Int32 di;
+ public Int32 reserve1_1;
+ public Int32 reserve1_2;
+ public Int32 reserve1_3;
+ };
+ [DllImport("gts.dll")]
+ public static extern short GTN_ReadMpgInfo(short core, short mpg, ref TMpgInfo pMpgInfo);
+
+
+ /**
+ * @brief EtherCATCSV/PVģʽ£Ŀٶ0x60ffֵλμʹֲᡣ
+ * @param core ˺š
+ * @param axis ţ1ʼ
+ * @param targetMaxVel Ŀٶ0x60ffֵλμʹֲᡣ
+ * @return
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_SetEcatAxisMaxTargetVel(short core, short axis, UInt32 targetMaxVel);
+
+
+ /**
+ * @brief ȡõEtherCATCSV/PVģʽĿٶ0x60ffֵλμʹֲᡣ
+ * @param core ˺š
+ * @param axis ţ1ʼ
+ * @param targetMaxVel ȡĿĿٶ0x60ffֵλμʹֲᡣ
+ * @return
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_GetEcatAxisMaxTargetVel(short core, short axis, out UInt32 targetMaxVel);
+
+
+
+ [DllImport("gts.dll")]
+ public static extern short GTN_EC_GetPdoEntryReg(short core,ushort slaveIndex, ushort index, byte subIndex,out uint pOffset,out uint pBitPosition);
+
+
+ /**
+ * @brief ʽʼEtherCAT
+ * @param core ˺
+ * @param pPrm ʼ
+ * @return
+ */
+ public struct TEcatInitPrm
+ {
+ public ushort skip_count; //վԤĬ0
+ public ushort netOpenSts;//ʼز 1ʾָʱEtherCATûгʼָ˳ʼվOP״̬ 2ʾָʱEtherCATѾʼOP״ָ̬δԴվв
+ public ushort slave_position;//վԤĬ0
+ public string eniFilePath;//ļ·ʹÿļĿ¼ʱļGecat.xmlڿļĿ¼òΪNULL
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
+ public ushort[] reserve2;//ԤĬ0
+ }
+ [DllImport("gts.dll")]
+ public static extern short GTN_InitEcatComm_MultiTask(short core, ref TEcatInitPrm pPrm);
+
+
+ /**
+ * @brief ָ(ô16·)
+ * @param core ˺
+ * @param crd ϵ
+ * @param doType ͡MC_ENABLE(ú궨Ϊ 10)ʹ; MC_CLEAR(ú궨Ϊ 11); MC_GPO(ú궨Ϊ 12)ͨ
+ * @param index 1ʼ
+ * @param doValue ֵĬ£1ʾߵƽ0ʾ͵ƽ
+ * @param fifo 岹ţĬֵΪ0
+ * @return
+ */
+ [DllImport("gts.dll")]
+ public static extern short GTN_BufDoBit(short core, short crd, ushort doType, ushort index, short doValue, short fifo);
+
+
+ }
+}