小转盘基本都能出列
This commit is contained in:
parent
0314f4d403
commit
e7736217db
@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<Platforms>AnyCPU;X64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -54,4 +55,492 @@ namespace DH.Commons.Enums
|
||||
心跳=25
|
||||
|
||||
}
|
||||
|
||||
|
||||
public enum StreamFormat
|
||||
{
|
||||
[Description("8位图像")]
|
||||
S_RAW8 = 0,
|
||||
[Description("10位图像")]
|
||||
S_RAW10 = 1,
|
||||
[Description("12位图像")]
|
||||
S_RAW12 = 2,
|
||||
[Description("14位图像")]
|
||||
S_RAW14 = 3,
|
||||
[Description("16位图像")]
|
||||
S_RAW16 = 4,
|
||||
[Description("BGR三通道24比特图像")]
|
||||
S_BGR24 = 10,
|
||||
[Description("BGRA四通道32比特图像")]
|
||||
S_BGR32 = 11,
|
||||
[Description("BGRA四通道48比特图像")]
|
||||
S_BGR48 = 12,
|
||||
[Description("BGRA四通道64比特图像")]
|
||||
S_BGR64 = 13,
|
||||
[Description("RGB三通道24比特图像")]
|
||||
S_RGB24 = 14,
|
||||
[Description("RGBA四通道32比特图像")]
|
||||
S_RGB32 = 15,
|
||||
[Description("RGBA四通道48比特图像")]
|
||||
S_RGB48 = 16,
|
||||
[Description("RGBA四通道64比特图像")]
|
||||
S_RGB64 = 17,
|
||||
[Description("YUV411")]
|
||||
S_YCBCR_411 = 20,
|
||||
[Description("YUV422")]
|
||||
S_YCBCR_422 = 21,
|
||||
[Description("YUV444")]
|
||||
S_YCBCR_444 = 22,
|
||||
[Description("8位灰度图像")]
|
||||
S_MONO8 = 30,
|
||||
[Description("10位灰度图像")]
|
||||
S_MONO10 = 31,
|
||||
[Description("12位灰度图像")]
|
||||
S_MONO12 = 32,
|
||||
[Description("14位灰度图像")]
|
||||
S_MONO14 = 33,
|
||||
[Description("16位灰度图像")]
|
||||
S_MONO16 = 34,
|
||||
S_B8_G8_R8 = 40,
|
||||
S_B16_G16_R16 = 44
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 主板型号
|
||||
/// </summary>
|
||||
public enum BoardModelEnum
|
||||
{
|
||||
EC3216 = 0,
|
||||
EC3224,
|
||||
EC3416,
|
||||
}
|
||||
/// <summary>
|
||||
/// 扩展板类型
|
||||
/// </summary>
|
||||
public enum ExtensionBoardEnum
|
||||
{
|
||||
[Description("未外接扩展板")]
|
||||
None,
|
||||
[Description("一个IO扩展板")]
|
||||
ExtIO_1,
|
||||
[Description("一个EC3216扩展板")]
|
||||
ExtEC3216_1,
|
||||
[Description("一个EC3224扩展板")]
|
||||
ExtEC3224_1,
|
||||
[Description("一个EC3416扩展板")]
|
||||
ExtEC3416_1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 转盘类型
|
||||
/// </summary>
|
||||
public enum MachineDiskType
|
||||
{
|
||||
|
||||
[Description("单转盘")]
|
||||
SingleDisk = 1,
|
||||
|
||||
[Description("双转盘")]
|
||||
DoubleDisk = 2,
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 运动板卡 IO 类型(IN OUT)
|
||||
/// </summary>
|
||||
public enum IOType
|
||||
{
|
||||
[Description("INPUT")]
|
||||
INPUT = 0,
|
||||
[Description("OUTPUT")]
|
||||
OUTPUT = 1
|
||||
}
|
||||
|
||||
public enum IOValue
|
||||
{
|
||||
[Description("关闭")]
|
||||
FALSE = 0,
|
||||
[Description("开启")]
|
||||
TRUE = 1,
|
||||
[Description("反转")]
|
||||
REVERSE = 2,
|
||||
}
|
||||
public enum RotationDirectionEnum
|
||||
{
|
||||
|
||||
[Description("顺时针(正方向)")]
|
||||
Clockwise = 0,
|
||||
|
||||
[Description("逆时针(负方向)")]
|
||||
AntiClockwise = 1,
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IO预定义类型 主要针对输出
|
||||
/// </summary>
|
||||
public enum IOPrestatement
|
||||
{
|
||||
[Description("自定义")]
|
||||
Customized = 0,
|
||||
|
||||
[Description("指示灯-黄")]
|
||||
Light_Yellow = 1,
|
||||
[Description("指示灯-绿")]
|
||||
Light_Green = 2,
|
||||
[Description("指示灯-红")]
|
||||
Light_Red = 3,
|
||||
[Description("蜂鸣器")]
|
||||
Beep = 4,
|
||||
[Description("照明灯")]
|
||||
Light = 5,
|
||||
|
||||
[Description("急停")]
|
||||
EmergencyStop = 99,
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 相机信号IO输出模式
|
||||
/// </summary>
|
||||
public enum ActionMode
|
||||
{
|
||||
[Description("IO断路输出")]
|
||||
OpenCircuit = 1,
|
||||
|
||||
[Description("IO开漏输出低电平")]
|
||||
LowLevel = 2,
|
||||
|
||||
[Description("取反IO")]
|
||||
Reverse = 3,
|
||||
|
||||
[Description("输出500us低脉冲")]
|
||||
OutputPulse500us = 5,
|
||||
|
||||
[Description("输出1ms低脉冲")]
|
||||
OutputPulse1ms = 6,
|
||||
|
||||
[Description("输出2ms低脉冲")]
|
||||
OutputPulse2ms = 9,
|
||||
|
||||
[Description("输出3ms低脉冲")]
|
||||
OutputPulse3ms = 10,
|
||||
|
||||
[Description("输出4ms低脉冲")]
|
||||
OutputPulse4ms = 11,
|
||||
|
||||
[Description("输出5ms低脉冲")]
|
||||
OutputPulse5ms = 12,
|
||||
|
||||
[Description("输出6ms低脉冲")]
|
||||
OutputPulse6ms = 13,
|
||||
|
||||
[Description("输出7ms低脉冲")]
|
||||
OutputPulse7ms = 14,
|
||||
|
||||
[Description("输出8ms低脉冲")]
|
||||
OutputPulse8ms = 15,
|
||||
|
||||
[Description("输出9ms低脉冲")]
|
||||
OutputPulse9ms = 16,
|
||||
|
||||
[Description("输出10ms低脉冲")]
|
||||
OutputPulse10ms = 17,
|
||||
|
||||
[Description("输出20ms低脉冲")]
|
||||
OutputPulse20ms = 18,
|
||||
|
||||
[Description("输出30ms低脉冲")]
|
||||
OutputPulse30ms = 19,
|
||||
|
||||
[Description("输出40ms低脉冲")]
|
||||
OutputPulse40ms = 20,
|
||||
|
||||
[Description("输出50ms低脉冲")]
|
||||
OutputPulse50ms = 21,
|
||||
|
||||
[Description("输出60ms低脉冲")]
|
||||
OutputPulse60ms = 22,
|
||||
|
||||
[Description("输出70ms低脉冲")]
|
||||
OutputPulse70ms = 23,
|
||||
|
||||
[Description("输出80ms低脉冲")]
|
||||
OutputPulse80ms = 24,
|
||||
|
||||
[Description("输出90ms低脉冲")]
|
||||
OutputPulse90ms = 25,
|
||||
|
||||
[Description("输出100ms低脉冲")]
|
||||
OutputPulse100ms = 26,
|
||||
|
||||
[Description("输出200ms低脉冲")]
|
||||
OutputPulse200ms = 27,
|
||||
|
||||
[Description("输出300ms低脉冲")]
|
||||
OutputPulse300ms = 28,
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 吹气信号IO输出模式
|
||||
/// </summary>
|
||||
public enum BlowType
|
||||
{
|
||||
|
||||
[Description("OK吹气口")]
|
||||
OK,
|
||||
|
||||
[Description("NG吹气口")]
|
||||
NG,
|
||||
|
||||
[Description("吹气口1")]
|
||||
Blow1,
|
||||
|
||||
[Description("吹气口2")]
|
||||
Blow2,
|
||||
|
||||
[Description("吹气口3")]
|
||||
Blow3,
|
||||
|
||||
[Description("吹气口4")]
|
||||
Blow4,
|
||||
|
||||
[Description("吹气口5")]
|
||||
Blow5,
|
||||
|
||||
[Description("吹气口6")]
|
||||
Blow6,
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 来料检测位号,目前支持两路
|
||||
/// </summary>
|
||||
public enum BitInputNumberEnum
|
||||
{
|
||||
[Description("第0路")]
|
||||
BitInput0 = 0,
|
||||
|
||||
[Description("第1路")]
|
||||
BitInput1,
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 电平
|
||||
/// </summary>
|
||||
public enum LogicLevelEnum
|
||||
{
|
||||
[Description("低电平")]
|
||||
LowLevel = 0,
|
||||
[Description("高电平")]
|
||||
HighLevel,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 捕捉位置模式
|
||||
/// </summary>
|
||||
public enum PositionSourceEnum
|
||||
{
|
||||
[Description("指令位置")]
|
||||
CommandPosition = 0,
|
||||
[Description("编码器位置")]
|
||||
EncoderPosition = 1,
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 来料检测捕获位置
|
||||
/// </summary>
|
||||
public enum SortingInputPositionModeEnum
|
||||
{
|
||||
[Description("前部")]
|
||||
Front = 0,
|
||||
[Description("中间")]
|
||||
Middle,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回原点模式1
|
||||
/// </summary>
|
||||
public enum GoHomeMode
|
||||
{
|
||||
// Negative: 负极限、负方向
|
||||
// Positive: 正极限、正方向
|
||||
// NeL:负限开关
|
||||
// N:无
|
||||
|
||||
|
||||
//[ColorSelect("Gray")]
|
||||
//[FontColorSelect("Black")]
|
||||
[Description("1 负极限:负限开关_中间:无_正极限:无_Index位置:负限位正边_偏移:正方向")]
|
||||
Negative_Ne_Center_N_Positive_N_Index_NePo_Offset_Po = 1,
|
||||
|
||||
[Description("2 负极限:无_中间:无_正极限:正限开关_Index位置:正限位负边_偏移:负方向")]
|
||||
Negative_N_Center_N_Positive_Po_Index_PoNe_Offset_Ne = 2,
|
||||
|
||||
[Description("3 负极限:无_中间:无_正极限:原点开关_Index位置:原点负边外侧_偏移:负方向")]
|
||||
Negative_N_Center_N_Positive_H_Index_HNeO_Offset_Ne = 3,
|
||||
|
||||
[Description("4 负极限:无_中间:无_正极限:原点开关_Index位置:原点负边内侧_偏移:正方向")]
|
||||
Negative_N_Center_N_Positive_H_Index_HNeI_Offset_Po = 4,
|
||||
|
||||
|
||||
|
||||
|
||||
[Description("5 负极限:原点开关_中间:无_正极限:无_Index位置:原点正边外侧_偏移:正方向")]
|
||||
Negative_H_Center_N_Positive_N_Index_HPoO_Offset_Po = 5,
|
||||
|
||||
[Description("6 负极限:原点开关_中间:无_正极限:无_Index位置:原点正边内侧_偏移:负方向")]
|
||||
Negative_H_Center_N_Positive_N_Index_HPoI_Offset_Ne = 6,
|
||||
|
||||
|
||||
|
||||
|
||||
[Description("7 负极限:无_中间:原点开关_正极限:正限开关_Index位置:原点负边外侧_偏移:负方向")]
|
||||
Negative_N_Center_H_Positive_Po_Index_HNeO_Offset_Ne = 7,
|
||||
[Description("8 负极限:无_中间:原点开关_正极限:正限开关_Index位置:原点负边内侧_偏移:正方向")]
|
||||
Negative_N_Center_H_Positive_Po_Index_HNeI_Offset_Po = 8,
|
||||
[Description("9 负极限:无_中间:原点开关_正极限:正限开关_Index位置:原点正边内侧_偏移:负方向")]
|
||||
Negative_N_Center_H_Positive_Po_Index_HPoI_Offset_Ne = 9,
|
||||
[Description("10 负极限:无_中间:原点开关_正极限:正限开关_Index位置:原点正边外侧_偏移:正方向")]
|
||||
Negative_N_Center_H_Positive_Po_Index_HPoO_Offset_Po = 10,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[Description("11 负极限:负限开关_中间:原点开关_正极限:无_Index位置:原点正边外侧_偏移:正方向")]
|
||||
Negative_Ne_Center_H_Positive_N_Index_HPoO_Offset_Po = 11,
|
||||
[Description("12 负极限:负限开关_中间:原点开关_正极限:无_Index位置:原点正边内侧_偏移:负方向")]
|
||||
Negative_Ne_Center_H_Positive_N_Index_HPoI_Offset_Ne = 12,
|
||||
[Description("13 负极限:负限开关_中间:原点开关_正极限:无_Index位置:原点负边内侧_偏移:正方向")]
|
||||
Negative_Ne_Center_H_Positive_N_Index_HNeI_Offset_Po = 13,
|
||||
[Description("14 负极限:负限开关_中间:原点开关_正极限:无_Index位置:原点负边外侧_偏移:负方向")]
|
||||
Negative_Ne_Center_H_Positive_N_Index_HNeO_Offset_Ne = 14,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[Description("17 负极限:负限开关_中间:无_正极限:无_停止位置:负限位正边_偏移:正方向")]
|
||||
Negative_Ne_Center_N_Positive_N_Stop_NePo_Offset_Po = 17,
|
||||
|
||||
|
||||
|
||||
[Description("18 负极限:无_中间:无_正极限:正限开关_停止位置:正极限负边_偏移:负方向")]
|
||||
Negative_N_Center_N_Positive_Po_Stop_PoNe_Offset_Ne = 18,
|
||||
|
||||
|
||||
[Description("19 负极限:无_中间:无_正极限:原点开关_停止位置:原点负边外侧_偏移:负方向")]
|
||||
Negative_N_Center_N_Positive_H_Stop_HNeO_Offset_Ne = 19,
|
||||
[Description("20 负极限:无_中间:无_正极限:原点开关_停止位置:原点负边内侧_偏移:正方向")]
|
||||
Negative_N_Center_N_Positive_H_Stop_HNeI_Offset_Po = 20,
|
||||
|
||||
|
||||
|
||||
[Description("21 负极限:原点开关_中间:无_正极限:无_停止位置:原点正边外侧_偏移:正方向")]
|
||||
Negative_H_Center_N_Positive_N_Stop_HPoO_Offset_Po = 21,
|
||||
[Description("22 负极限:原点开关_中间:无_正极限:无_停止位置:原点正边内侧_偏移:负方向")]
|
||||
Negative_H_Center_N_Positive_N_Stop_HPoI_Offset_Ne = 22,
|
||||
|
||||
|
||||
|
||||
|
||||
[Description("23 负极限:无_中间:原点开关_正极限:正限开关_停止位置:原点负边外侧_偏移:负方向")]
|
||||
Negative_N_Center_H_Positive_Po_Stop_HNeO_Offset_Ne = 23,
|
||||
[Description("24 负极限:无_中间:原点开关_正极限:正限开关_停止位置:原点负边内侧_偏移:正方向")]
|
||||
Negative_N_Center_H_Positive_Po_Stop_HNeI_Offset_Po = 24,
|
||||
[Description("25 负极限:无_中间:原点开关_正极限:正限开关_停止位置:原点正边内侧_偏移:负方向")]
|
||||
Negative_N_Center_H_Positive_Po_Stop_HPoI_Offset_Ne = 25,
|
||||
[Description("26 负极限:无_中间:原点开关_正极限:正限开关_停止位置:原点正边外侧_偏移:正方向")]
|
||||
Negative_N_Center_H_Positive_Po_Stop_HPoO_Offset_Po = 26,
|
||||
|
||||
|
||||
|
||||
|
||||
[Description("27 负极限:负限开关_中间:原点开关_正极限:无_停止位置:原点正边外侧_偏移:正方向")]
|
||||
Negative_Ne_Center_H_Positive_N_Stop_HPoO_Offset_Ne = 27,
|
||||
[Description("28 负极限:负限开关_中间:原点开关_正极限:无_停止位置:原点正边内侧_偏移:负方向")]
|
||||
Negative_Ne_Center_H_Positive_N_Stop_HPoI_Offset_Po = 28,
|
||||
[Description("29 负极限:负限开关_中间:原点开关_正极限:无_停止位置:原点负边内侧_偏移:正方向")]
|
||||
Negative_Ne_Center_H_Positive_N_Stop_HNeI_Offset_Ne = 29,
|
||||
[Description("30 负极限:负限开关_中间:原点开关_正极限:无_停止位置:原点负边外侧_偏移:负方向")]
|
||||
Negative_Ne_Center_H_Positive_N_Stop_HNeO_Offset_Po = 30,
|
||||
|
||||
|
||||
|
||||
|
||||
[Description("33 负极限:无_中间:无_正极限:无_Index位置:负方向Index_偏移:负方向")]
|
||||
Negative_N_Center_N_Positive_N_Index_NeIndex_Offset_Ne = 33,
|
||||
[Description("34 负极限:无_中间:无_正极限:无_Index位置:正方向Index_偏移:正方向")]
|
||||
Negative_N_Center_N_Positive_N_Index_PoIndex_Offset_Po = 34,
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 马达/运动板卡运行模式
|
||||
/// </summary>
|
||||
public enum MotionMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 普通点位运动
|
||||
/// </summary>
|
||||
[Description("普通点位运动")]
|
||||
P2P = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 找正限位运动
|
||||
/// </summary>
|
||||
[Description("找正限位运动")]
|
||||
FindPositive = 4,
|
||||
|
||||
/// <summary>
|
||||
/// 离开正限位
|
||||
/// </summary>
|
||||
[Description("离开正限位")]
|
||||
LeavePositive = 5,
|
||||
|
||||
/// <summary>
|
||||
/// 找负限位运动
|
||||
/// </summary>
|
||||
[Description("找负限位运动")]
|
||||
FindNegative = 6,
|
||||
|
||||
/// <summary>
|
||||
/// 离开负限位
|
||||
/// </summary>
|
||||
[Description("离开负限位")]
|
||||
LeaveNegative = 7,
|
||||
|
||||
/// <summary>
|
||||
/// 找原点运动
|
||||
/// </summary>
|
||||
[Description("回原点运动")]
|
||||
GoHome = 8,
|
||||
|
||||
/// <summary>
|
||||
/// Jog模式
|
||||
/// </summary>
|
||||
[Description("Jog模式")]
|
||||
Jog = 9,
|
||||
|
||||
///// <summary>
|
||||
///// 读数头找原点方式
|
||||
///// </summary>
|
||||
//[Description("找原点inde")]
|
||||
//FindOriIndex = 10,
|
||||
|
||||
///// <summary>
|
||||
///// 插补模式
|
||||
///// </summary>
|
||||
//[Description("插补模式")]
|
||||
//Coordinate = 11
|
||||
}
|
||||
|
||||
}
|
||||
|
277
DH.Commons/Enums/SolidMotionCardEnum.cs
Normal file
277
DH.Commons/Enums/SolidMotionCardEnum.cs
Normal file
@ -0,0 +1,277 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace XKRS.Common.Model.SolidMotionCard
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 回零状态
|
||||
/// </summary>
|
||||
public enum SearchHomeState
|
||||
{
|
||||
/// <summary>
|
||||
/// 回零成功
|
||||
/// </summary>
|
||||
[Description("回零成功")]
|
||||
HomeSucess = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 回零错误
|
||||
/// </summary>
|
||||
[Description("回零错误")]
|
||||
HomeError = 31,
|
||||
|
||||
/// <summary>
|
||||
/// 正在回零点
|
||||
/// </summary>
|
||||
[Description("正在回零点")]
|
||||
Homing = 32,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 0.3 坐标模式
|
||||
/// </summary>
|
||||
public enum PositionMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 绝对位置模式
|
||||
/// </summary>
|
||||
[Description("绝对位置模式")]
|
||||
Position_Absolute = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 相对位置模式
|
||||
/// </summary>
|
||||
[Description("相对位置模式")]
|
||||
Position_Opposite = 1,
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 0.4 单轴点动曲线类型
|
||||
/// </summary>
|
||||
public enum Profile
|
||||
{
|
||||
/// <summary>
|
||||
/// T型曲线
|
||||
/// </summary>
|
||||
[Description("T型曲线")]
|
||||
Profile_T = 0,
|
||||
|
||||
/// <summary>
|
||||
/// S型曲线
|
||||
/// </summary>
|
||||
[Description("S型曲线")]
|
||||
Profile_S = 1,
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 3.1 伺服使能设置
|
||||
/// </summary>
|
||||
public enum ServoLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// 触点闭合
|
||||
/// </summary>
|
||||
[Description("触点闭合")]
|
||||
Servo_Close = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 触点打开
|
||||
/// </summary>
|
||||
[Description("触点打开")]
|
||||
Servo_Open = 1,
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 3.2 报警复位电平设置
|
||||
/// </summary>
|
||||
public enum AlarmLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// 触点闭合
|
||||
/// </summary>
|
||||
[Description("触点闭合")]
|
||||
Alarm_Close = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 触点打开
|
||||
/// </summary>
|
||||
[Description("触点打开")]
|
||||
Alarm_Open = 1,
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 3.6
|
||||
/// </summary>
|
||||
public enum HomeState
|
||||
{
|
||||
/// <summary>
|
||||
/// 触点闭合,硬件灯亮
|
||||
/// </summary>
|
||||
[Description("触点闭合,硬件灯亮")]
|
||||
Home_Close = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 触点打开,硬件灯灭
|
||||
/// </summary>
|
||||
[Description("触点打开,硬件灯灭")]
|
||||
Home_Open = 1,
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 4.1 脉冲模式
|
||||
/// </summary>
|
||||
public enum PulseMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 脉冲方向(默认)
|
||||
/// </summary>
|
||||
[Description("模式0")]
|
||||
Pulse_Dir_H = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 脉冲方向
|
||||
/// </summary>
|
||||
[Description("模式1")]
|
||||
Pulse_Dir_L = 1,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 双脉冲
|
||||
/// </summary>
|
||||
[Description("模式2")]
|
||||
Pulse_CW_CCW = 2,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 双脉冲
|
||||
/// </summary>
|
||||
[Description("模式3")]
|
||||
Pulse_CCW_CW = 3,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// AB相位
|
||||
/// </summary>
|
||||
[Description("模式4")]
|
||||
Pulse_AB = 4,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// AB相位
|
||||
/// </summary>
|
||||
[Description("模式5")]
|
||||
Pulse_BA = 5,
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************************************************
|
||||
5 轴硬件触发停止运动函数
|
||||
*****************************************************************************************************************/
|
||||
//5.1 EMG_Mode
|
||||
public enum EMG_Mode
|
||||
{
|
||||
[Description("不使用紧急停止功能")]
|
||||
EMG_Trigger_Close = 0, //不使用紧急停止功能
|
||||
|
||||
[Description("低电平触发紧急停止")]
|
||||
EMG_Trigger_Low_IMD = 1, //低电平触发紧急停止
|
||||
|
||||
[Description("低电平触发减速停止")]
|
||||
EMG_Trigger_Low_DEC = 2,//低电平触发减速停止
|
||||
|
||||
[Description("高电平触发紧急停止")]
|
||||
EMG_Trigger_High_IMD = 3, //高电平触发紧急停止
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 6.1.1 正负限位触发电平
|
||||
/// </summary>
|
||||
public enum LimitLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// 低电平触发
|
||||
/// </summary>
|
||||
[Description("低电平触发")]
|
||||
Low_Logic = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 高电平触发
|
||||
/// </summary>
|
||||
[Description("高电平触发")]
|
||||
High_Logic = 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 6.1.2 回零限位触发电平
|
||||
/// </summary>
|
||||
public enum HomeLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// 低电平触发
|
||||
/// </summary>
|
||||
[Description("低电平触发")]
|
||||
Low_Logic = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 高电平触发
|
||||
/// </summary>
|
||||
[Description("高电平触发")]
|
||||
High_Logic = 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 6.1.3 Index触发电平
|
||||
/// </summary>
|
||||
public enum IndexLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// 低电平触发
|
||||
/// </summary>
|
||||
[Description("低电平触发")]
|
||||
Low_Logic = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 高电平触发
|
||||
/// </summary>
|
||||
[Description("高电平触发")]
|
||||
High_Logic = 1,
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Imaging;
|
||||
using DH.Commons.Enums;
|
||||
using DVPCameraType;
|
||||
using OpenCvSharp;
|
||||
|
||||
@ -21,8 +21,12 @@ namespace DH.Devices.Camera
|
||||
public string SerialNumber { get; set; } = string.Empty;
|
||||
public string CameraName { get; set; } = string.Empty;
|
||||
|
||||
public dvpStreamFormat dvpStreamFormat = dvpStreamFormat.S_RGB24;
|
||||
public string CameraIP { get; set; } = string.Empty;
|
||||
|
||||
public string ComputerIP { get; set; } = string.Empty;
|
||||
|
||||
// public StreamFormat dvpStreamFormat = dvpStreamFormat.;
|
||||
public dvpStreamFormat dvpStreamFormat = dvpStreamFormat.S_RGB24;
|
||||
[Category("采图模式")]
|
||||
[Description("是否传感器直接硬触发。true:传感器硬触发,不通过软件触发;false:通过软件触发IO 的硬触发模式")]
|
||||
[DisplayName("是否传感器直接硬触发")]
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>..\</BaseOutputPath>
|
||||
@ -11,15 +12,28 @@
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="CameraBase.cs" />
|
||||
<Compile Include="Do3ThinkCamera.cs" />
|
||||
<Compile Include="HikVisionCamera.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" />
|
||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.10.0.20241108" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="DVPCameraCS64">
|
||||
<HintPath>..\x64\Debug\DVPCameraCS64.dll</HintPath>
|
||||
<HintPath>..\X64\Debug\DVPCameraCS64.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MvCameraControl.Net">
|
||||
<HintPath>..\x64\Debug\MvCameraControl.Net.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace DH.Devices.Camera
|
||||
throw new Exception($"Create device failed:{nRet:x8}");
|
||||
}
|
||||
|
||||
nRet = DVPCamera.dvpSetTargetFormat(m_handle, dvpStreamFormat);
|
||||
nRet = DVPCamera.dvpSetTargetFormat(m_handle, (dvpStreamFormat)dvpStreamFormat);
|
||||
if (dvpStatus.DVP_STATUS_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Set image format failed:{nRet:x8}");
|
||||
@ -308,6 +308,8 @@ namespace DH.Devices.Camera
|
||||
|
||||
public int ImageCallbackFunc(uint handle, dvpStreamEvent _event, IntPtr pContext, ref dvpFrame refFrame, IntPtr pBuffer)
|
||||
{
|
||||
Mat cvImage = new Mat();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@ -316,8 +318,7 @@ namespace DH.Devices.Camera
|
||||
|
||||
int nWidth = refFrame.iWidth;
|
||||
int nHeight = refFrame.iHeight;
|
||||
Mat cvImage = new Mat();
|
||||
|
||||
|
||||
// 根据图像格式创建Mat
|
||||
switch (refFrame.format)
|
||||
{
|
||||
@ -337,7 +338,8 @@ namespace DH.Devices.Camera
|
||||
default:
|
||||
throw new NotSupportedException($"Unsupported format: {refFrame.format}");
|
||||
}
|
||||
OnHImageOutput?.Invoke(DateTime.Now, this, cvImage);
|
||||
Mat smat = cvImage.Clone();
|
||||
OnHImageOutput?.Invoke(DateTime.Now, this, smat);
|
||||
|
||||
|
||||
|
||||
@ -348,6 +350,10 @@ namespace DH.Devices.Camera
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
cvImage?.Dispose();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
492
DH.Devices.Camera/HikVisionCamera.cs
Normal file
492
DH.Devices.Camera/HikVisionCamera.cs
Normal file
@ -0,0 +1,492 @@
|
||||
using System.Diagnostics;
|
||||
using OpenCvSharp;
|
||||
using MvCamCtrl.NET;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Xml.Linq;
|
||||
using DH.Commons.Enums;
|
||||
using static MvCamCtrl.NET.MyCamera;
|
||||
|
||||
|
||||
|
||||
namespace DH.Devices.Camera
|
||||
{
|
||||
public class HikVisionCamera : CameraBase
|
||||
{
|
||||
readonly MyCamera cameraObj = new MyCamera();
|
||||
MyCamera.MV_CC_DEVICE_INFO stDevInfo = new MyCamera.MV_CC_DEVICE_INFO();
|
||||
int nRet = MyCamera.MV_OK;
|
||||
MyCamera.cbExceptiondelegate pCallBackFunc;
|
||||
public MyCamera.cbOutputExdelegate ImageCallback;
|
||||
MyCamera.MV_FRAME_OUT _frame = new MyCamera.MV_FRAME_OUT();
|
||||
readonly ManualResetEvent _snapHandle = new ManualResetEvent(false);
|
||||
bool _snapFlag = false;
|
||||
|
||||
public HikVisionCamera()
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override bool CameraConnect()
|
||||
{
|
||||
try
|
||||
{
|
||||
pCallBackFunc = new MyCamera.cbExceptiondelegate(cbExceptiondelegate);
|
||||
|
||||
#region 根据IP连接相机
|
||||
stDevInfo.nTLayerType = MyCamera.MV_GIGE_DEVICE;
|
||||
MyCamera.MV_GIGE_DEVICE_INFO stGigEDev = new MyCamera.MV_GIGE_DEVICE_INFO();
|
||||
|
||||
|
||||
var parts = CameraIP.Split('.');
|
||||
int nIp1 = Convert.ToInt32(parts[0]);
|
||||
int nIp2 = Convert.ToInt32(parts[1]);
|
||||
int nIp3 = Convert.ToInt32(parts[2]);
|
||||
int nIp4 = Convert.ToInt32(parts[3]);
|
||||
stGigEDev.nCurrentIp = (uint)((nIp1 << 24) | (nIp2 << 16) | (nIp3 << 8) | nIp4);
|
||||
|
||||
parts = ComputerIP.Split('.');
|
||||
nIp1 = Convert.ToInt32(parts[0]);
|
||||
nIp2 = Convert.ToInt32(parts[1]);
|
||||
nIp3 = Convert.ToInt32(parts[2]);
|
||||
nIp4 = Convert.ToInt32(parts[3]);
|
||||
stGigEDev.nNetExport = (uint)((nIp1 << 24) | (nIp2 << 16) | (nIp3 << 8) | nIp4);
|
||||
|
||||
IntPtr stGigeInfoPtr = Marshal.AllocHGlobal(216);
|
||||
Marshal.StructureToPtr(stGigEDev, stGigeInfoPtr, false);
|
||||
stDevInfo.SpecialInfo.stGigEInfo = new Byte[540];
|
||||
Marshal.Copy(stGigeInfoPtr, stDevInfo.SpecialInfo.stGigEInfo, 0, 540);
|
||||
//释放内存空间
|
||||
Marshal.FreeHGlobal(stGigeInfoPtr);
|
||||
#endregion
|
||||
// ch:创建设备 | en: Create device
|
||||
nRet = cameraObj.MV_CC_CreateDevice_NET(ref stDevInfo);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Create device failed:{nRet:x8}");
|
||||
}
|
||||
|
||||
// ch:打开设备 | en:Open device
|
||||
nRet = cameraObj.MV_CC_OpenDevice_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Open device failed:{nRet:x8}");
|
||||
}
|
||||
|
||||
|
||||
// ch:探测网络最佳包大小(只对GigE相机有效) | en:Detection network optimal package size(It only works for the GigE camera)
|
||||
if (stDevInfo.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||
{
|
||||
int nPacketSize = cameraObj.MV_CC_GetOptimalPacketSize_NET();
|
||||
if (nPacketSize > 0)
|
||||
{
|
||||
nRet = cameraObj.MV_CC_SetIntValue_NET("GevSCPSPacketSize", (uint)nPacketSize);
|
||||
if (nRet != MyCamera.MV_OK)
|
||||
{
|
||||
Console.WriteLine("Warning: Set Packet Size failed {0:x8}", nRet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Warning: Get Packet Size failed {0:x8}", nPacketSize);
|
||||
}
|
||||
}
|
||||
|
||||
// ch:注册异常回调函数 | en:Register Exception Callback
|
||||
nRet = cameraObj.MV_CC_RegisterExceptionCallBack_NET(pCallBackFunc, IntPtr.Zero);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Register expection callback failed:{nRet}");
|
||||
}
|
||||
GC.KeepAlive(pCallBackFunc);
|
||||
|
||||
// ch:设置采集连续模式 | en:Set Continues Aquisition Mode
|
||||
cameraObj.MV_CC_SetEnumValue_NET("AcquisitionMode", 2);// ch:工作在连续模式 | en:Acquisition On Continuous Mode
|
||||
//if (IIConfig.IsContinueMode)
|
||||
//{
|
||||
// cameraObj.MV_CC_SetEnumValue_NET("TriggerMode", 0); // ch:连续模式 | en:Continuous
|
||||
|
||||
// // ch:注册回调函数 | en:Register image callback
|
||||
// ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||
// nRet = cameraObj.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// throw new Exception("Register image callback failed!");
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// ch:设置触发模式为off || en:set trigger mode as off
|
||||
nRet = cameraObj.MV_CC_SetEnumValue_NET("TriggerMode", 1);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Set TriggerMode failed!");
|
||||
}
|
||||
|
||||
//if (IIConfig.IsHardwareTrigger)
|
||||
//{
|
||||
// ch:触发源选择:0 - Line0; | en:Trigger source select:0 - Line0;
|
||||
// 1 - Line1;
|
||||
// 2 - Line2;
|
||||
// 3 - Line3;
|
||||
// 4 - Counter;
|
||||
// 7 - Software;
|
||||
nRet = cameraObj.MV_CC_SetEnumValue_NET("TriggerSource", 0);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Set Line0 Trigger failed!");
|
||||
}
|
||||
|
||||
// ch:注册回调函数 | en:Register image callback
|
||||
ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||
nRet = cameraObj.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Register image callback failed!");
|
||||
}
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// nRet = cameraObj.MV_CC_SetEnumValue_NET("TriggerSource", 7);
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// throw new Exception("Set Software Trigger failed!");
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
// ch:开启抓图 || en: start grab image
|
||||
nRet = cameraObj.MV_CC_StartGrabbing_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Start grabbing failed:{nRet:x8}");
|
||||
}
|
||||
|
||||
//if (IConfig.DefaultExposure != 0)
|
||||
//{
|
||||
// cameraObj.MV_CC_SetEnumValue_NET("ExposureAuto", 0);
|
||||
// nRet = cameraObj.MV_CC_SetFloatValue_NET("ExposureTime", IConfig.DefaultExposure);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"Exposure set failed:{nRet}");
|
||||
// }
|
||||
//}
|
||||
//if (IIConfig.Gain >= 0)
|
||||
//{
|
||||
// nRet = cameraObj.MV_CC_SetFloatValue_NET("Gain", IIConfig.Gain);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"Gain set failed:{nRet}");
|
||||
// }
|
||||
//}
|
||||
// 设置 触发延迟
|
||||
//if (IIConfig.TriggerDelay > 0)
|
||||
//{
|
||||
// nRet = cameraObj.MV_CC_SetFloatValue_NET("TriggerDelay", IIConfig.TriggerDelay);
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// throw new Exception("Set TriggerDelay failed!");
|
||||
// }
|
||||
//}
|
||||
//if (IIConfig.LineDebouncerTime > 0)
|
||||
//{
|
||||
// nRet = cameraObj.MV_CC_SetIntValue_NET("LineDebouncerTime", (uint)IIConfig.LineDebouncerTime);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"LineDebouncerTime set failed:{nRet}");
|
||||
// }
|
||||
//}
|
||||
//IIConfig.PropertyChanged -= IIConfig_PropertyChanged;
|
||||
//IIConfig.PropertyChanged += IIConfig_PropertyChanged;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void IIConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
//if (e.PropertyName == "IsHardwareTrigger" && !IIConfig.IsContinueMode)
|
||||
//{
|
||||
// // ch:停止抓图 | en:Stop grab image
|
||||
// nRet = cameraObj.MV_CC_StopGrabbing_NET();
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// throw new Exception($"Stop grabbing failed{nRet:x8}");
|
||||
// }
|
||||
|
||||
// if (IIConfig.IsHardwareTrigger)
|
||||
// {
|
||||
// // ch:触发源选择:0 - Line0; | en:Trigger source select:0 - Line0;
|
||||
// // 1 - Line1;
|
||||
// // 2 - Line2;
|
||||
// // 3 - Line3;
|
||||
// // 4 - Counter;
|
||||
// // 7 - Software;
|
||||
// nRet = cameraObj.MV_CC_SetEnumValue_NET("TriggerSource", 0);
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// throw new Exception("Set Line0 Trigger failed!");
|
||||
// }
|
||||
|
||||
// // ch:注册回调函数 | en:Register image callback
|
||||
// ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||
// nRet = cameraObj.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// throw new Exception("Register image callback failed!");
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// nRet = cameraObj.MV_CC_SetEnumValue_NET("TriggerSource", 7);
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// throw new Exception("Set Software Trigger failed!");
|
||||
// }
|
||||
// }
|
||||
|
||||
// // ch:开启抓图 || en: start grab image
|
||||
// nRet = cameraObj.MV_CC_StartGrabbing_NET();
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// throw new Exception($"Start grabbing failed:{nRet:x8}");
|
||||
// }
|
||||
|
||||
// if (IConfig.DefaultExposure != 0)
|
||||
// {
|
||||
// cameraObj.MV_CC_SetEnumValue_NET("ExposureAuto", 0);
|
||||
// nRet = cameraObj.MV_CC_SetFloatValue_NET("ExposureTime", IConfig.DefaultExposure);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"Exposure set failed:{nRet}");
|
||||
// }
|
||||
// }
|
||||
// if (IIConfig.Gain >= 0)
|
||||
// {
|
||||
// nRet = cameraObj.MV_CC_SetFloatValue_NET("Gain", IIConfig.Gain);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"Gain set failed:{nRet}");
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 设置 触发延迟
|
||||
// if (IIConfig.TriggerDelay > 0)
|
||||
// {
|
||||
// nRet = cameraObj.MV_CC_SetFloatValue_NET("TriggerDelay", IIConfig.TriggerDelay);
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// throw new Exception("Set TriggerDelay failed!");
|
||||
// }
|
||||
// }
|
||||
// if (IIConfig.LineDebouncerTime > 0)
|
||||
// {
|
||||
// nRet = cameraObj.MV_CC_SetIntValue_NET("LineDebouncerTime", (uint)IIConfig.LineDebouncerTime);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"LineDebouncerTime set failed:{nRet}");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
public override bool CameraDisConnect()
|
||||
{
|
||||
//IIConfig.PropertyChanged -= IIConfig_PropertyChanged;
|
||||
|
||||
//base.Stop();
|
||||
|
||||
// ch:停止抓图 | en:Stop grab image
|
||||
|
||||
try
|
||||
{
|
||||
nRet = cameraObj.MV_CC_StopGrabbing_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Stop grabbing failed{nRet:x8}");
|
||||
}
|
||||
|
||||
// ch:关闭设备 | en:Close device
|
||||
nRet = cameraObj.MV_CC_CloseDevice_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Close device failed{nRet:x8}");
|
||||
}
|
||||
|
||||
// ch:销毁设备 | en:Destroy device
|
||||
nRet = cameraObj.MV_CC_DestroyDevice_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Destroy device failed:{nRet:x8}");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ImageCallbackFunc(IntPtr pData, ref MyCamera.MV_FRAME_OUT_INFO_EX pFrameInfo, IntPtr pUser)
|
||||
{
|
||||
Mat cvImage = new Mat();
|
||||
try
|
||||
{
|
||||
|
||||
Interlocked.Increment(ref SnapshotCount);
|
||||
int nWidth = pFrameInfo.nWidth;
|
||||
int nHeight = pFrameInfo.nHeight;
|
||||
switch (pFrameInfo.enPixelType)
|
||||
{
|
||||
case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerGR8:
|
||||
case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerRG8:
|
||||
case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerGB8:
|
||||
case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerBG8:
|
||||
cvImage = Mat.FromPixelData(nHeight, nWidth, MatType.CV_8UC1, pData);
|
||||
break;
|
||||
case MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed:
|
||||
cvImage = Mat.FromPixelData(nHeight, nWidth, MatType.CV_8UC3, pData);
|
||||
Cv2.CvtColor(cvImage, cvImage, ColorConversionCodes.RGB2BGR);
|
||||
break;
|
||||
case MyCamera.MvGvspPixelType.PixelType_Gvsp_BGR8_Packed:
|
||||
cvImage = Mat.FromPixelData(nHeight, nWidth, MatType.CV_8UC3, pData);
|
||||
break;
|
||||
case MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono8:
|
||||
cvImage = Mat.FromPixelData(nHeight, nWidth, MatType.CV_8UC1, pData);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotSupportedException($"Unsupported pixel type: {pFrameInfo.enPixelType}");
|
||||
}
|
||||
|
||||
OnHImageOutput?.Invoke(DateTime.Now, this, cvImage);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
cvImage?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public MvGvspPixelType GetMvGvspPixelType(StreamFormat streamFormat)
|
||||
{
|
||||
switch (streamFormat)
|
||||
{
|
||||
// 原始数据格式映射
|
||||
case StreamFormat.S_RAW8:
|
||||
return MvGvspPixelType.PixelType_Gvsp_Mono8;
|
||||
case StreamFormat.S_RAW10:
|
||||
return MvGvspPixelType.PixelType_Gvsp_Mono10_Packed;
|
||||
case StreamFormat.S_RAW12:
|
||||
return MvGvspPixelType.PixelType_Gvsp_Mono12_Packed;
|
||||
case StreamFormat.S_RAW14:
|
||||
return MvGvspPixelType.PixelType_Gvsp_Mono14;
|
||||
case StreamFormat.S_RAW16:
|
||||
return MvGvspPixelType.PixelType_Gvsp_Mono16;
|
||||
|
||||
// RGB/BGR格式映射
|
||||
case StreamFormat.S_BGR24:
|
||||
return MvGvspPixelType.PixelType_Gvsp_BGR8_Packed;
|
||||
case StreamFormat.S_BGR32:
|
||||
return MvGvspPixelType.PixelType_Gvsp_BGRA8_Packed;
|
||||
case StreamFormat.S_RGB24:
|
||||
return MvGvspPixelType.PixelType_Gvsp_RGB8_Packed;
|
||||
case StreamFormat.S_RGB32:
|
||||
return MvGvspPixelType.PixelType_Gvsp_RGBA8_Packed;
|
||||
case StreamFormat.S_BGR48:
|
||||
return MvGvspPixelType.PixelType_Gvsp_BGR10_Packed;
|
||||
case StreamFormat.S_RGB48:
|
||||
return MvGvspPixelType.PixelType_Gvsp_RGB16_Packed;
|
||||
|
||||
// YUV格式映射
|
||||
case StreamFormat.S_YCBCR_411:
|
||||
return MvGvspPixelType.PixelType_Gvsp_YCBCR411_8_CBYYCRYY;
|
||||
case StreamFormat.S_YCBCR_422:
|
||||
return MvGvspPixelType.PixelType_Gvsp_YUV422_YUYV_Packed;
|
||||
case StreamFormat.S_YCBCR_444:
|
||||
return MvGvspPixelType.PixelType_Gvsp_YUV444_Packed;
|
||||
|
||||
// 灰度图像映射
|
||||
case StreamFormat.S_MONO8:
|
||||
return MvGvspPixelType.PixelType_Gvsp_Mono8;
|
||||
case StreamFormat.S_MONO10:
|
||||
return MvGvspPixelType.PixelType_Gvsp_Mono10;
|
||||
case StreamFormat.S_MONO12:
|
||||
return MvGvspPixelType.PixelType_Gvsp_Mono12;
|
||||
case StreamFormat.S_MONO14:
|
||||
return MvGvspPixelType.PixelType_Gvsp_Mono14;
|
||||
case StreamFormat.S_MONO16:
|
||||
return MvGvspPixelType.PixelType_Gvsp_Mono16;
|
||||
|
||||
// 特殊格式映射
|
||||
case StreamFormat.S_B8_G8_R8:
|
||||
return MvGvspPixelType.PixelType_Gvsp_RGB8_Planar;
|
||||
case StreamFormat.S_B16_G16_R16:
|
||||
return MvGvspPixelType.PixelType_Gvsp_RGB16_Planar;
|
||||
|
||||
default:
|
||||
throw new ArgumentException($"Unsupported stream format: {streamFormat}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ch:回调函数 | en:Callback function
|
||||
private void cbExceptiondelegate(uint nMsgType, IntPtr pUser)
|
||||
{
|
||||
//if (nMsgType == MyCamera.MV_EXCEPTION_DEV_DISCONNECT)
|
||||
//{
|
||||
// if (CurrentState != EnumHelper.DeviceState.DSClose)
|
||||
// {
|
||||
// int reTryTimes = 3;
|
||||
// do
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Task.Delay(1000).Wait();
|
||||
// Stop();
|
||||
|
||||
// Start();
|
||||
// reTryTimes = -1;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// reTryTimes--;
|
||||
|
||||
// if (reTryTimes > 0)
|
||||
// {
|
||||
// LogAsync(DateTime.Now, LogLevel.Information, $"{this.Name}重新连接异常,{ex.GetExceptionMessage()}");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw ex;
|
||||
// }
|
||||
// }
|
||||
// } while (reTryTimes > 0);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
29
DH.Devices.Motion/DH.Devices.Motion.csproj
Normal file
29
DH.Devices.Motion/DH.Devices.Motion.csproj
Normal file
@ -0,0 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>..\</BaseOutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>output</AppendTargetFrameworkToOutputPath>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="MCDLL_NET.cs" />
|
||||
<Compile Include="MCDLL_NET_Code.cs" />
|
||||
<Compile Include="MCDLL_NET_SORTING.cs" />
|
||||
<Compile Include="MotionBase.cs" />
|
||||
<Compile Include="SLDMotion.cs" />
|
||||
<Compile Include="SolidMotionCardEnum.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
621
DH.Devices.Motion/MCDLL_NET.cs
Normal file
621
DH.Devices.Motion/MCDLL_NET.cs
Normal file
@ -0,0 +1,621 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
/********************************************************************************************************************************************************************
|
||||
1 每个相机可以单独设置触发参数,适应给更多不同相机
|
||||
2 物件状态实时可以存储10组数据,防止计算机不实时
|
||||
3 根据物件编号下达动作,方便用户使用
|
||||
4 吹气口各种工作,防止OK与NG占用同一个通道
|
||||
********************************************************************************************************************************************************************/
|
||||
namespace MCDLL_NET
|
||||
{
|
||||
|
||||
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
//public static class SolidMotionCardRetCode
|
||||
//{
|
||||
// public const int RetOK = 0;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 轴停止模式
|
||||
/// </summary>
|
||||
public static class AxisStopMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 紧急停止
|
||||
/// </summary>
|
||||
public const int AxisStopIMD = 0;
|
||||
/// <summary>
|
||||
/// 减速停止
|
||||
/// </summary>
|
||||
public const int AxisStopDEC = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class CMCDLL_NET
|
||||
{
|
||||
/********************************************************************************************************************************************************************
|
||||
1 控制卡打开函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//1.0 网络并联模式设置函数(打开卡前设置) 宏定义1.0
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Switch_State_Net")]
|
||||
public static extern short MCF_Set_Switch_State_Net(ushort Mode = 0);
|
||||
// 网卡设置函数(打开卡前设置)
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Card_Number_Net")]
|
||||
public static extern short MCF_Set_Card_Number_Net(ushort Card_Number = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Card_Number_Net")]
|
||||
public static extern short MCF_Get_Card_Number_Net(ref ushort Card_Number);
|
||||
//1.1 初始化函数 [1,100] [0,99] 宏定义1.1
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Open_Net")]
|
||||
public static extern short MCF_Open_Net(ushort Connection_Number, ref ushort Station_Number, ref ushort Station_Type);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Open_Net")]
|
||||
public static extern short MCF_Get_Open_Net(ref ushort Connection_Number, ref ushort Station_Number, ref ushort Station_Type);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Close_Net")]
|
||||
public static extern short MCF_Close_Net();
|
||||
//1.2 链接超时紧急停止函数 [0,60000]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Link_TimeOut_Net")]
|
||||
public static extern short MCF_Set_Link_TimeOut_Net(uint Time_1MS, uint TimeOut_Output, ushort StationNumber = 0);
|
||||
// 链接超时紧急停止触发使能函数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Trigger_Output_Bit_Net")]
|
||||
public static extern short MCF_Set_Trigger_Output_Bit_Net(ushort Bit_Output_Number, ushort Bit_Output_Enable, ushort StationNumber = 0);
|
||||
//1.3 链接监测函数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Link_State_Net")]
|
||||
public static extern short MCF_Get_Link_State_Net(ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
2 通用输入输出函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//2.1 通用IO全部输出函数 [OUT31,OUT0] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Output_Net")]
|
||||
public static extern short MCF_Set_Output_Net(uint All_Output_Logic, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Output_Net")]
|
||||
public static extern short MCF_Get_Output_Net(ref uint All_Output_Logic, ushort StationNumber = 0);
|
||||
//2.2 通用IO按位输出函数 宏定义2.3.1 宏定义2.3.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Output_Bit_Net")]
|
||||
public static extern short MCF_Set_Output_Bit_Net(ushort Bit_Output_Number, ushort Bit_Output_Logic, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Output_Bit_Net")]
|
||||
public static extern short MCF_Get_Output_Bit_Net(ushort Bit_Output_Number, ref ushort Bit_Output_Logic, ushort StationNumber = 0);
|
||||
//2.3 通用IO输出复用1:按位输出保持时间函数 宏定义2.3.1 宏定义2.3.2 [0,65535] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Output_Time_Bit_Net")]
|
||||
public static extern short MCF_Set_Output_Time_Bit_Net(ushort Bit_Output_Number, ushort Bit_Output_Logic, ushort Output_Time_1MS, ushort StationNumber = 0);
|
||||
// 通用IO输出复用2:按位置输出保持时间函数 宏定义2.3.1 [0,1000] [-2^31,(2^31-1)] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Compare_Output_Bit_Net")]
|
||||
public static extern short MCF_Set_Compare_Output_Bit_Net(ushort Compare_Output_Number, ushort Compare_Output_1MS, ushort Compare_dDist, ushort StationNumber = 0);
|
||||
//2.4 通用IO全部输入函数 [Input31,Input0] [Input48,Input32] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Input_Net")]
|
||||
public static extern short MCF_Get_Input_Net(ref uint All_Input_Logic1, ref uint All_Input_Logic2, ushort StationNumber = 0);
|
||||
//2.5 通用IO按位输入函数 宏定义2.4.1 宏定义2.4.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Input_Bit_Net")]
|
||||
public static extern short MCF_Get_Input_Bit_Net(ushort Bit_Input_Number, ref ushort Bit_Input_Logic, ushort StationNumber = 0);
|
||||
//2.6 通用IO按位输入下升沿高速捕获清除函数 [Bit_Input_0,Bit_Input_3] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Clear_Input_Fall_Bit_Net")]
|
||||
public static extern short MCF_Clear_Input_Fall_Bit_Net(ushort Bit_Input_Number, ushort StationNumber = 0);
|
||||
//2.7 通用IO按位输入下升沿高速捕获读取函数 [Bit_Input_0,Bit_Input_3] 宏定义2.7 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Input_Fall_Bit_Net")]
|
||||
public static extern short MCF_Get_Input_Fall_Bit_Net(ushort Bit_Input_Number, ref ushort Bit_Input_Fall, ushort StationNumber = 0);
|
||||
//2.9 通用IO按位输入下升沿高速计数读取函数 [Bit_Input_0,Bit_Input_3] [0,(2^32-1)] 10个最新编码器锁存数据 &Array[10] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Input_Fall_Count_Bit_Net")]
|
||||
public static extern short MCF_Get_Input_Fall_Count_Bit_Net(ushort Bit_Input_Number, ref uint Input_Count_Fall, ref uint Lock_Data_Buffer, ushort StationNumber = 0);
|
||||
//2.10 通用IO按位输入数据锁存保持(最近10个下升沿数据)打开函数(必须在MCF_Open_Net前面提前调用)
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Open_Input_Lock_Bit_Net")]
|
||||
public static extern short MCF_Open_Input_Lock_Bit_Net(ushort Lock_Mode = 0, ushort StationNumber = 0);
|
||||
//2.11 通用IO按位输入滤波函数 [Bit_Input_0,Bit_Input_3] [1,100]MS [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Input_Filter_Time_Bit_Net")]
|
||||
public static extern short MCF_Set_Input_Filter_Time_Bit_Net(ushort Bit_Input_Number, uint Filter_Time_1MS, ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
3 轴专用输入输出函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//3.1 伺服使能设置函数 宏定义0.0 宏定义3.1 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Servo_Enable_Net")]
|
||||
public static extern short MCF_Set_Servo_Enable_Net(ushort Axis, ushort Servo_Logic, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Servo_Enable_Net")]
|
||||
public static extern short MCF_Get_Servo_Enable_Net(ushort Axis, ref ushort Servo_Logic, ushort StationNumber = 0);
|
||||
//3.2 伺服报警复位设置函数 宏定义0.0 宏定义3.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Servo_Alarm_Reset_Net")]
|
||||
public static extern short MCF_Set_Servo_Alarm_Reset_Net(ushort Axis, ushort Alarm_Logic, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Servo_Alarm_Reset_Net")]
|
||||
public static extern short MCF_Get_Servo_Alarm_Reset_Net(ushort Axis, ref ushort Alarm_Logic, ushort StationNumber = 0);
|
||||
//3.3 伺服报警输入获取函数 宏定义0.0 宏定义3.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Servo_Alarm_Net")]
|
||||
public static extern short MCF_Get_Servo_Alarm_Net(ushort Axis, ref ushort Servo_Alarm_State, ushort StationNumber = 0);
|
||||
//3.4 伺服定位完成输入获取函数 宏定义0.0 宏定义3.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Servo_INP_Net")]
|
||||
public static extern short MCF_Get_Servo_INP_Net(ushort Axis, ref ushort Servo_INP_State, ushort StationNumber = 0);
|
||||
//3.5 编码器Z相输入获取函数 宏定义0.0 宏定义3.5 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Z_Net")]
|
||||
public static extern short MCF_Get_Z_Net(ushort Axis, ref ushort Z_State, ushort StationNumber = 0);
|
||||
//3.6 原点输入获取函数 宏定义0.0 宏定义3.6 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Home_Net")]
|
||||
public static extern short MCF_Get_Home_Net(ushort Axis, ref ushort Home_State, ushort StationNumber = 0);
|
||||
//3.7 正限位输入获取函数 宏定义0.0 宏定义3.7 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Positive_Limit_Net")]
|
||||
public static extern short MCF_Get_Positive_Limit_Net(ushort Axis, ref ushort Positive_Limit_State, ushort StationNumber = 0);
|
||||
//3.8 负限位输入获取函数 宏定义0.0 宏定义3.8 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Negative_Limit_Net")]
|
||||
public static extern short MCF_Get_Negative_Limit_Net(ushort Axis, ref ushort Negative_Limit_State, ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
4 轴设置函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//4.1 脉冲通道输出设置函数 宏定义0.0 宏定义4.1 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Pulse_Mode_Net")]
|
||||
public static extern short MCF_Set_Pulse_Mode_Net(ushort Axis, uint Pulse_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Pulse_Mode_Net")]
|
||||
public static extern short MCF_Get_Pulse_Mode_Net(ushort Axis, ref uint Pulse_Mode, ushort StationNumber = 0);
|
||||
//4.2 位置设置函数 宏定义0.0 [-2^31,(2^31-1)] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Position_Net")]
|
||||
public static extern short MCF_Set_Position_Net(ushort Axis, int Position, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Position_Net")]
|
||||
public static extern short MCF_Get_Position_Net(ushort Axis, ref int Position, ushort StationNumber = 0);
|
||||
//4.3 编码器设置函数 宏定义0.0 [-2^31,(2^31-1)] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Encoder_Net")]
|
||||
public static extern short MCF_Set_Encoder_Net(ushort Axis, int Encoder, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Encoder_Net")]
|
||||
public static extern short MCF_Get_Encoder_Net(ushort Axis, ref int Encoder, ushort StationNumber = 0);
|
||||
// 通过Z相清除AB编码器值
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Z_Clear_Encoder_Net")]
|
||||
public static extern short MCF_Z_Clear_Encoder_Net(ushort Axis, ushort Enable, ushort StationNumber = 0);
|
||||
// 通过Z相后固定距离输出IO 宏定义0.0 [0,255] [0,65535] [0,255]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Z_Output_Bit_Net")]
|
||||
public static extern short MCF_Z_Output_Bit_Net(ushort Axis, ushort Number, uint dDist, ushort Time_1MS, ushort StationNumber = 0);
|
||||
//4.4 速度获取 宏定义0.0 [-2^15,(2^15-1)] [-2^15,(2^15-1)] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Vel_Net")]
|
||||
public static extern short MCF_Get_Vel_Net(ushort Axis, ref double Command_Vel, ref double Encode_Vel, ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
5 轴硬件触发停止运动函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//5.1 5.1 通用IO输入复用:做为紧急停止函数 宏定义2.4.1 宏定义5.1 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_EMG_Bit_Net")]
|
||||
public static extern short MCF_Set_EMG_Bit_Net(ushort EMG_Input_Number, ushort EMG_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_EMG_Output_Net")]
|
||||
public static extern short MCF_Set_EMG_Output_Net(ushort EMG_Input_Number, ushort EMG_Mode, uint EMG_Output, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_EMG_Output_Enable_Net")]
|
||||
public static extern short MCF_Set_EMG_Output_Enable_Net(ushort Bit_Output_Number, ushort Bit_Output_Enable, ushort StationNumber = 0);
|
||||
// 通用IO输入复用:做为触发停止 [0,3] 宏定义0.0 [Bit_Input_0,Bit_Input_15] 宏定义5.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Input_Trigger_Net")]
|
||||
public static extern short MCF_Set_Input_Trigger_Net(ushort Channel, ushort Axis, ushort Bit_Input_Number, uint Trigger_Mode, ushort StationNumber = 0);
|
||||
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Input_Trigger_Net")]
|
||||
public static extern short MCF_Get_Input_Trigger_Net(ushort Channel, ref ushort Axis, ref ushort Bit_Input_Number, ref uint Trigger_Mode, ushort StationNumber = 0);
|
||||
|
||||
//5.2 软件限位触发运动停止函数 宏定义0.0 [-2^31,2^31]P > [-2^31,2^31]P [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Soft_Limit_Net")]
|
||||
public static extern short MCF_Set_Soft_Limit_Net(ushort Axis, int Positive_Position, int Negative_Position, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Soft_Limit_Net")]
|
||||
public static extern short MCF_Get_Soft_Limit_Net(ushort Axis, ref int Positive_Position, ref int Negative_Position, ushort StationNumber = 0);
|
||||
//5.3 软件限位触发运动停止开关函数 宏定义0.0 宏定义5.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Soft_Limit_Enable_Net")]
|
||||
public static extern short MCF_Set_Soft_Limit_Enable_Net(ushort Axis, uint Soft_Limit_Enable, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Soft_Limit_Enable_Net")]
|
||||
public static extern short MCF_Get_Soft_Limit_Enable_Net(ushort Axis, ref uint Soft_Limit_Enable, ushort StationNumber = 0);
|
||||
//5.4 伺服报警触发运动停止函数 宏定义0.0 宏定义5.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Alarm_Trigger_Net")]
|
||||
public static extern short MCF_Set_Alarm_Trigger_Net(ushort Axis, uint Trigger_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Alarm_Trigger_Net")]
|
||||
public static extern short MCF_Get_Alarm_Trigger_Net(ushort Axis, ref uint Trigger_Mode, ushort StationNumber = 0);
|
||||
//5.5 Index触发运动停止函数 宏定义0.0 宏定义5.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Index_Trigger_Net")]
|
||||
public static extern short MCF_Set_Index_Trigger_Net(ushort Axis, uint Trigger_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Index_Trigger_Net")]
|
||||
public static extern short MCF_Get_Index_Trigger_Net(ushort Axis, ref uint Trigger_Mode, ushort StationNumber = 0);
|
||||
//5.6 原点触发运动停止函数 宏定义0.0 宏定义5.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Home_Trigger_Net")]
|
||||
public static extern short MCF_Set_Home_Trigger_Net(ushort Axis, uint Trigger_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Home_Trigger_Net")]
|
||||
public static extern short MCF_Get_Home_Trigger_Net(ushort Axis, ref uint Trigger_Mode, ushort StationNumber = 0);
|
||||
//5.7 正限位触发运动停止函数 宏定义0.0 宏定义5.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_ELP_Trigger_Net")]
|
||||
public static extern short MCF_Set_ELP_Trigger_Net(ushort Axis, uint Trigger_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_ELP_Trigger_Net")]
|
||||
public static extern short MCF_Get_ELP_Trigger_Net(ushort Axis, ref uint Trigger_Mode, ushort StationNumber = 0);
|
||||
//5.8 负限位触发运动停止函数 宏定义0.0 宏定义5.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_ELN_Trigger_Net")]
|
||||
public static extern short MCF_Set_ELN_Trigger_Net(ushort Axis, uint Trigger_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_ELN_Trigger_Net")]
|
||||
public static extern short MCF_Get_ELN_Trigger_Net(ushort Axis, ref uint Trigger_Mode, ushort StationNumber = 0);
|
||||
//5.9 原点触发位置记录函数 宏定义0.0 [-2^31,(2^31-1)] [0,99] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Home_Rise_Position_Net")]
|
||||
public static extern short MCF_Get_Home_Rise_Position_Net(ushort Axis, ref int Position, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Home_Fall_Position_Net")]
|
||||
public static extern short MCF_Get_Home_Fall_Position_Net(ushort Axis, ref int Position, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Home_Rise_Encoder_Net")]
|
||||
public static extern short MCF_Get_Home_Rise_Encoder_Net(ushort Axis, ref int Encoder, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Home_Fall_Encoder_Net")]
|
||||
public static extern short MCF_Get_Home_Fall_Encoder_Net(ushort Axis, ref int Encoder, ushort StationNumber = 0);
|
||||
//5.10 轴状态清除函数 宏定义0.0 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Clear_Axis_State_Net")]
|
||||
public static extern short MCF_Clear_Axis_State_Net(ushort Axis, ushort StationNumber = 0);
|
||||
//5.11 轴状态触发停止运动查询函数 宏定义0.0 MC_Retrun.h[0,28] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Axis_State_Net")]
|
||||
public static extern short MCF_Get_Axis_State_Net(ushort Axis, ref short Reason, ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
6 轴回原点函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//6.1 设置回零参数 宏定义0.0 [1,65535] [1,65535]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Search_Home_dMaxA_Time_Net")]
|
||||
public static extern short MCF_Search_Home_dMaxA_Time_Net(ushort Axis, ushort H_dMaxA_Time = 10, ushort L_dMaxA_Time = 10, ushort StationNumber = 0);
|
||||
// 宏定义0.0 [1,35] 宏定义6.1.1 宏定义6.1.2 宏定义6.1.3 (0,10M]P/S (0,10M]P/S [-2^31,(2^31-1)] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Search_Home_Set_Net")]
|
||||
public static extern short MCF_Search_Home_Set_Net(ushort Axis, ushort Search_Home_Mode, ushort Limit_Logic, ushort Home_Logic, ushort Index_Logic, double H_dMaxV, double L_dMaxV, int Offset_Position, ushort Trigger_Source, ushort StationNumber = 0);
|
||||
//6.2 设置回零启动 宏定义0.0 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Search_Home_Start_Net")]
|
||||
public static extern short MCF_Search_Home_Start_Net(ushort Axis, ushort StationNumber = 0);
|
||||
//6.3 设置回零停止 宏定义0.0 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Search_Home_Stop_Net")]
|
||||
public static extern short MCF_Search_Home_Stop_Net(ushort Axis, ushort StationNumber = 0);
|
||||
//6.4 获取回零状态 宏定义0.0 MC_Retrun.h{0,31,32} [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Search_Home_Get_State_Net")]
|
||||
public static extern short MCF_Search_Home_Get_State_Net(ushort Axis, ref ushort Home_State, ushort StationNumber = 0);
|
||||
//6.5 设置回零缓停时间 宏定义0.0 [0,1000] 单位:ms [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Search_Home_Stop_Time_Net")]
|
||||
public static extern short MCF_Search_Home_Stop_Time_Net(ushort Axis, ushort Stop_Time, ushort StationNumber = 0);
|
||||
//6.6 设置回零完成后保持位置值 宏定义0.0 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Search_Home_Keep_Position_Net")]
|
||||
public static extern short MCF_Search_Home_Keep_Position_Net(ushort Axis, ushort StationNumber = 0);
|
||||
//6.7 设置回零完成后保持编码器值 宏定义0.0 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Search_Home_Keep_Encoder_Net")]
|
||||
public static extern short MCF_Search_Home_Keep_Encoder_Net(ushort Axis, ushort StationNumber = 0);
|
||||
//6.8 设置回零在零点位置离开速度 宏定义0.0 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Search_Home_Leave_Vel_Net")]
|
||||
public static extern short MCF_Search_Home_Leave_Vel_Net(ushort Axis, double M_dMaxV, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
7 点位运动控制函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//7.1 速度控制函数 宏定义0.0 (0,10M]P/S (0,1T]P^2/S [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_JOG_Net")]
|
||||
public static extern short MCF_JOG_Net(ushort Axis, double dMaxV, double dMaxA, ushort StationNumber = 0);
|
||||
//7.2 单轴运动位置改变函数 宏定义0.0 [-2^31,(2^31-1)] 宏定义0.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Uniaxial_dDist_Change_Net")]
|
||||
public static extern short MCF_Uniaxial_dDist_Change_Net(ushort Axis, int dDist, ushort Position_Mode, ushort StationNumber = 0);
|
||||
//7.3 单轴运动速度改变函数 宏定义0.0 (0,10M]P/S [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Uniaxial_dMaxV_Change_Net")]
|
||||
public static extern short MCF_Uniaxial_dMaxV_Change_Net(ushort Axis, double dMaxV, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Uniaxial_dMaxA_Change_Net")]
|
||||
public static extern short MCF_Uniaxial_dMaxA_Change_Net(ushort Axis, double dMaxA, ushort StationNumber = 0);
|
||||
//7.4 单轴曲线函数 宏定义0.0 [0,dMaxV] (0,10M]P/S (0,1T]P^2/S (0,100T]P^3/S [0,dMaxV] 宏定义0.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Axis_Profile_Net")]
|
||||
public static extern short MCF_Set_Axis_Profile_Net(ushort Axis, double dV_ini, double dMaxV, double dMaxA, double dJerk, double dV_end, ushort Profile, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Axis_Profile_Net")]
|
||||
public static extern short MCF_Get_Axis_Profile_Net(ushort Axis, ref double dV_ini, ref double dMaxV, ref double dMaxA, ref double dJerk, ref double dV_end, ref ushort Profile, ushort StationNumber = 0);
|
||||
//7.5 单轴运动函数 宏定义0.0 [-2^31,(2^31-1)] 宏定义0.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Uniaxial_Net")]
|
||||
public static extern short MCF_Uniaxial_Net(ushort Axis, int dDist, ushort Position_Mode, ushort StationNumber = 0);
|
||||
//7.6 单轴停止曲线函数 宏定义0.0 (0,1T]P^2/S (0,100T]P^3/S 宏定义0.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Axis_Stop_Profile_Net")]
|
||||
public static extern short MCF_Set_Axis_Stop_Profile_Net(ushort Axis, double dMaxA, double dJerk, ushort Profile, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Axis_Stop_Profile_Net")]
|
||||
public static extern short MCF_Get_Axis_Stop_Profile_Net(ushort Axis, ref double dMaxA, ref double dJerk, ref ushort Profile, ushort StationNumber = 0);
|
||||
//7.7 轴停止函数 宏定义0.0 宏定义7.7 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Axis_Stop_Net")]
|
||||
public static extern short MCF_Axis_Stop_Net(ushort Axis, ushort Axis_Stop_Mode, ushort StationNumber = 0);
|
||||
//7.8 单轴运动改变周期函数 宏定义0.0 [1,1000]MS [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Uniaxial_Cycle_Change_Net")]
|
||||
public static extern short MCF_Uniaxial_Cycle_Change_Net(ushort Axis, ushort Cycle, ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
8 插补运动控制函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//8.1 坐标系曲线函数 宏定义0.1 [0,dMaxV] (0,10M]P/S (0,1T]P^2/S (0,100T]P^3/S [0,dMaxV] 宏定义0.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Coordinate_Profile_Net")]
|
||||
public static extern short MCF_Set_Coordinate_Profile_Net(ushort Coordinate, double dV_ini, double dMaxV, double dMaxA, double dJerk, double dV_end, ushort Profile, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Coordinate_Profile_Net")]
|
||||
public static extern short MCF_Get_Coordinate_Profile_Net(ushort Coordinate, ref double dV_ini, ref double dMaxV, ref double dMaxA, ref double dJerk, ref double dV_end, ref ushort Profile, ushort StationNumber = 0);
|
||||
//8.2 圆半径插补运动函数 宏定义0.1 宏定义0.0 [-2^31,(2^31-1)] [-2^31,(2^31-1)] 宏定义0.5 宏定义0.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Arc2_Radius_Net")]
|
||||
public static extern short MCF_Arc2_Radius_Net(ushort Coordinate, ref ushort Axis_List, ref int dDist_List, int Arc_Radius, ushort Direction, ushort Position_Mode, ushort StationNumber = 0);
|
||||
//8.3 圆圆心插补运动函数 宏定义0.1 宏定义0.0 [-2^31,(2^31-1)] [-2^31,(2^31-1)] 宏定义0.5 宏定义0.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Arc2_Centre_Net")]
|
||||
public static extern short MCF_Arc2_Centre_Net(ushort Coordinate, ref ushort Axis_List, ref int dDist_List, ref int Center_List, ushort Direction, ushort Position_Mode, ushort StationNumber = 0);
|
||||
//8.4 直线插补运动函数 宏定义0.1 宏定义0.0 [-2^31,(2^31-1)] 宏定义0.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Line2_Net")]
|
||||
public static extern short MCF_Line2_Net(ushort Coordinate, ref ushort Axis_List, ref int dDist_List, ushort Position_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Line3_Net")]
|
||||
public static extern short MCF_Line3_Net(ushort Coordinate, ref ushort Axis_List, ref int dDist_List, ushort Position_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Line4_Net")]
|
||||
public static extern short MCF_Line4_Net(ushort Coordinate, ref ushort Axis_List, ref int dDist_List, ushort Position_Mode, ushort StationNumber = 0);
|
||||
//8.5 坐标系停止曲线函数 宏定义0.1 (0,1T]P^2/S (0,100T]P^3/S 宏定义0.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Coordinate_Stop_Profile_Net")]
|
||||
public static extern short MCF_Set_Coordinate_Stop_Profile_Net(ushort Coordinate, double dMaxA, double dJerk, ushort Profile, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Coordinate_Stop_Profile_Net")]
|
||||
public static extern short MCF_Get_Coordinate_Stop_Profile_Net(ushort Coordinate, ref double dMaxA, ref double dJerk, ref ushort Profile, ushort StationNumber = 0);
|
||||
//8.6 螺旋线圆半径插补运动函数 宏定义0.1 宏定义0.0 [-2^31,(2^31-1)] [-2^31,(2^31-1)] 宏定义0.5 宏定义0.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Screw3_Radius_Net")]
|
||||
public static extern short MCF_Screw3_Radius_Net(ushort Coordinate, ref ushort Axis_List, ref int dDist_List, int Arc_Radius, ushort Direction, ushort Position_Mode, ushort StationNumber = 0);
|
||||
//8.7 螺旋线圆圆心插补运动函数 宏定义0.1 宏定义0.0 [-2^31,(2^31-1)] [-2^31,(2^31-1)] 宏定义0.5 宏定义0.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Screw3_Centre_Net")]
|
||||
public static extern short MCF_Screw3_Centre_Net(ushort Coordinate, ref ushort Axis_List, ref int dDist_List, ref int Center_List, ushort Direction, ushort Position_Mode, ushort StationNumber = 0);
|
||||
//8.8 坐标系停止函数 宏定义0.1 宏定义5.6 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Coordinate_Stop_Net")]
|
||||
public static extern short MCF_Coordinate_Stop_Net(ushort Coordinate, ushort Coordinate_Stop_Mode, ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
9 缓冲区函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//9.1 缓冲区停止曲线函数 宏定义0.2 (0,1T]P^2/S (0,100T]P^3/S 宏定义0.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Set_Stop_Profile_Net")]
|
||||
public static extern short MCF_Buffer_Set_Stop_Profile_Net(ushort Buffer_Number, double dMaxA, double dJerk, ushort Profile, ushort StationNumber = 0);
|
||||
//9.2 缓冲区停止函数 宏定义0.2 宏定义9.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Stop_Net")]
|
||||
public static extern short MCF_Buffer_Stop_Net(ushort Buffer_Number, ushort Buffer_Stop_Mode, ushort StationNumber = 0);
|
||||
//9.3 缓冲区在线改变速度倍率 宏定义0.2 (0,10] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Change_Velocity_Ratio_Net")]
|
||||
public static extern short MCF_Buffer_Change_Velocity_Ratio_Net(ushort Buffer_Number, double Velocity_Ratio, ushort StationNumber = 0);
|
||||
//9.4 缓冲区建立开始函数 宏定义0.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Start_Net")]
|
||||
public static extern short MCF_Buffer_Start_Net(ushort Buffer_Number, ushort StationNumber = 0);
|
||||
//9.5 缓冲区速度倍率 宏定义0.2 宏定义9.5 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Set_Velocity_Ratio_Enable_Net")]
|
||||
public static extern short MCF_Buffer_Set_Velocity_Ratio_Enable_Net(ushort Buffer_Number, ushort Velocity_Ratio_Enable = 0, ushort StationNumber = 0);
|
||||
//9.6 缓冲区前瞻处理降速比 宏定义0.2 (0,1] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Set_Reduce_Ratio_Net")]
|
||||
public static extern short MCF_Buffer_Set_Reduce_Ratio_Net(ushort Buffer_Number, double Reduce_Ratio = 1.0, ushort StationNumber = 0);
|
||||
//9.7 缓冲区曲线函数 宏定义0.2 [0,dMaxV] (0,10M]P/S (0,1T]P^2/S (0,100T]P^3/S [0,dMaxV] 宏定义0.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Set_Profile_Net")]
|
||||
public static extern short MCF_Buffer_Set_Profile_Net(ushort Buffer_Number, double dV_ini, double dMaxV, double dMaxA, double dJerk, double dV_end, ushort Profile, ushort StationNumber = 0);
|
||||
//9.8 缓冲区单轴运动 宏定义0.2 宏定义0.0 [-2^31,(2^31-1)] 宏定义0.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Uniaxial_Net")]
|
||||
public static extern short MCF_Buffer_Uniaxial_Net(ushort Buffer_Number, ushort Axis, int dDist, ushort Position_Mode, ushort StationNumber = 0);
|
||||
//缓冲区单轴运动距离同步跟随函数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Sync_Follow_Net")]
|
||||
public static extern short MCF_Buffer_Sync_Follow_Net(ushort Buffer_Number, ushort Axis, int dDist, ushort StationNumber = 0);
|
||||
//9.9 缓冲区直线插补运动 宏定义0.2 宏定义0.0 [-2^31,(2^31-1)] 宏定义0.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Line2_Net")]
|
||||
public static extern short MCF_Buffer_Line2_Net(ushort Buffer_Number, ref ushort Axis_List, ref int dDist_List, ushort Position_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Line3_Net")]
|
||||
public static extern short MCF_Buffer_Line3_Net(ushort Buffer_Number, ref ushort Axis_List, ref int dDist_List, ushort Position_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Line4_Net")]
|
||||
public static extern short MCF_Buffer_Line4_Net(ushort Buffer_Number, ref ushort Axis_List, ref int dDist_List, ushort Position_Mode, ushort StationNumber = 0);
|
||||
//9.10 缓冲区平面圆半径插补运动函数 宏定义0.2 宏定义0.0 [-2^31,(2^31-1)] [-2^31,(2^31-1)] 宏定义0.5 宏定义0.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Arc_Radius_Net")]
|
||||
public static extern short MCF_Buffer_Arc_Radius_Net(ushort Buffer_Number, ref ushort Axis_List, ref int dDist_List, int Arc_Radius, ushort Direction, ushort Position_Mode, ushort StationNumber = 0);
|
||||
//9.11 缓冲区平面圆圆心插补运动函数 宏定义0.2 宏定义0.0 [-2^31,(2^31-1)] [-2^31,(2^31-1)] 宏定义0.5 宏定义0.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Arc_Centre_Net")]
|
||||
public static extern short MCF_Buffer_Arc_Centre_Net(ushort Buffer_Number, ref ushort Axis_List, ref int dDist_List, ref int Center_List, ushort Direction, ushort Position_Mode, ushort StationNumber = 0);
|
||||
//9.12 缓冲区延时函数 宏定义0.2 [0,2^31-1] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Delay_Net")]
|
||||
public static extern short MCF_Buffer_Delay_Net(ushort Buffer_Number, uint number, ushort StationNumber = 0);
|
||||
//9.13 缓冲区IO输出函数 宏定义0.2 宏定义2.3.1 宏定义2.3.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Set_Output_Bit_Net")]
|
||||
public static extern short MCF_Buffer_Set_Output_Bit_Net(ushort Buffer_Number, ushort Bit_Number, ushort output, ushort StationNumber = 0);
|
||||
//9.14 缓冲区IO等待函数 宏定义0.2 宏定义2.4.1 宏定义2.4.2 (0,2^15-1] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Wait_Input_Bit_Net")]
|
||||
public static extern short MCF_Buffer_Wait_Input_Bit_Net(ushort Buffer_Number, ushort Bit_Number, ushort Logic, ushort Time_Out, ushort StationNumber = 0);
|
||||
//9.15 缓冲区建立结束 宏定义0.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_End_Net")]
|
||||
public static extern short MCF_Buffer_End_Net(ushort Buffer_Number, ushort StationNumber = 0);
|
||||
//9.16 缓冲区执行函数 宏定义0.2 宏定义9.16 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Execute_Net")]
|
||||
public static extern short MCF_Buffer_Execute_Net(ushort Buffer_Number, ushort Execute_Mode, ushort StationNumber = 0);
|
||||
//9.17 缓冲区断点启动函数 宏定义0.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Execute_BreakPoint_Net")]
|
||||
public static extern short MCF_Buffer_Execute_BreakPoint_Net(ushort Buffer_Number, ushort StationNumber = 0);
|
||||
//9.18 缓冲区状态查询函数 宏定义0.2 MC_Retrun.h{0,29,30} [0,2^15-1]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Get_State_Net")]
|
||||
public static extern short MCF_Buffer_Get_State_Net(ushort Buffer_Number, ref ushort Execute_State, ref ushort Execute_Number, ushort StationNumber = 0);
|
||||
//9.19 缓冲区剩余可插入指令空间百分比查询 宏定义0.2 [0,100]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Get_Remainder_Space_Net")]
|
||||
public static extern short MCF_Buffer_Get_Remainder_Space_Net(ushort Buffer_Number, ref ushort Remainder_Space_Ratio, ushort StationNumber = 0);
|
||||
//9.20 缓冲区开始插入(建议查询到剩余有一半以上空间) 宏定义0.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Insert_Start_Net")]
|
||||
public static extern short MCF_Buffer_Insert_Start_Net(ushort Buffer_Number, ushort StationNumber = 0);
|
||||
//9.22 缓冲区结束插入 宏定义0.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Insert_End_Net")]
|
||||
public static extern short MCF_Buffer_Insert_End_Net(ushort Buffer_Number, ushort StationNumber = 0);
|
||||
//9.23 计算加入指令所占用的空间百分比 宏定义0.2 [0,100] [0,99]
|
||||
// 在MCF_Buffer_Start_Net或者MCF_Buffer_Insert_Start_Net后开始从0计算
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Buffer_Count_Occupy_Space_Net")]
|
||||
public static extern short MCF_Buffer_Count_Occupy_Space_Net(ushort Buffer_Number, ref ushort Occupy_Space_Ratio, ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
10 示波器10K采样频率数据捕捉函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//10.1 数据捕捉打开/关闭函数(必须在MCF_Open_Net前面提前调用,而且只支持一个运动控制卡)
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Capture_Open_Net")]
|
||||
public static extern short MCF_Capture_Open_Net(ushort Capture_Mode = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Capture_Close_Net")]
|
||||
public static extern short MCF_Capture_Close_Net();
|
||||
//10.2 数据捕捉检查数据更新函数 宏定义10.2
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Capture_State_Net")]
|
||||
public static extern short MCF_Capture_State_Net(ref ushort Capture_State);
|
||||
//10.3 读取采样连续的1000个位置命令数据 宏定义0.0 &Array[Capture_Frequency*Capture_Time_1MS]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Capture_Read_Command_Net")]
|
||||
public static extern short MCF_Capture_Read_Command_Net(ushort Axis, ref int Command);
|
||||
//10.4 读取采样连续的1000个编码器数据 宏定义0.0 &Array[Capture_Frequency*Capture_Time_1MS]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Capture_Read_Encoder_Net")]
|
||||
public static extern short MCF_Capture_Read_Encoder_Net(ushort Axis, ref int Encoder);
|
||||
//10.5 读取采样连续的1000个模拟量数据 宏定义0.0 &Array[Capture_Frequency*Capture_Time_1MS]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Capture_Read_AD_Net")]
|
||||
public static extern short MCF_Capture_Read_AD_Net(ushort Axis, ref int AD);
|
||||
//10.6 ADC采样滤波 宏定义0.0 [0,1]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Capture_Filter_AD_Net")]
|
||||
public static extern short MCF_Capture_Filter_AD_Net(ushort Axis, double Filter_Coefficient = 1);
|
||||
//10.7 数据捕捉频率设置 宏定义10.7
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Capture_Frequency_Net")]
|
||||
public static extern short MCF_Capture_Frequency_Net(ushort Capture_Frequency = 1, ushort StationNumber = 0);
|
||||
//10.8 数据捕捉缓存时间设置 [2,1000] 2的倍数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Capture_Time_Net")]
|
||||
public static extern short MCF_Capture_Time_Net(ushort Capture_Time_1MS = 100, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
11 电子齿轮控制函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//11.1 电子齿轮设置函数 宏定义0.0 宏定义0.0 (0,(2^31-1)] (0,(2^31-1)] 宏定义11.1.1 宏定义11.1.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Gear_Net")]
|
||||
public static extern short MCF_Set_Gear_Net(ushort Axis, ushort Follow_Axis, uint Denominator, uint Molecule, ushort Follow_Source, ushort Dir, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Gear_Net")]
|
||||
public static extern short MCF_Get_Gear_Net(ushort Axis, ref ushort Follow_Axis, ref uint Denominator, ref uint Molecule, ref ushort Follow_Source, ref ushort Dir, ushort StationNumber = 0);
|
||||
//11.2 电子齿轮开关函数 宏定义0.0 宏定义11.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Gear_Enable_Net")]
|
||||
public static extern short MCF_Set_Gear_Enable_Net(ushort Axis, ushort Gear_Enable, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Gear_Enable_Net")]
|
||||
public static extern short MCF_Get_Gear_Enable_Net(ushort Axis, ref ushort Gear_Enable, ushort StationNumber = 0);
|
||||
//11.3 电子齿轮运动距离后自动关闭 宏定义0.0 [-2^31,(2^31-1)] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Gear_Auto_Disable_Net")]
|
||||
public static extern short MCF_Set_Gear_Auto_Disable_Net(ushort Axis, int dDist, ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
12 位置比较输出函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//12.1 设置一维位置比较器 宏定义0.0
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Compare_Config_Net")]
|
||||
public static extern short MCF_Set_Compare_Config_Net(ushort Axis, ushort Enable, ushort Compare_Source, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Compare_Config_Net")]
|
||||
public static extern short MCF_Get_Compare_Config_Net(ushort Axis, ref ushort Enable, ref ushort Compare_Source, ushort StationNumber = 0);
|
||||
//12.2 清除一维位置所有/当前比较点/关闭任意点 宏定义0.0
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Clear_Compare_Points_Net")]
|
||||
public static extern short MCF_Clear_Compare_Points_Net(ushort Axis, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Clear_Compare_Current_Points_Net")]
|
||||
public static extern short MCF_Clear_Compare_Current_Points_Net(ushort Axis, ushort StationNumber = 0);
|
||||
// 按照 MCF_Add_Compare_Point_Net 数据累加计算 宏定义0.0 [1,(2^31-1)}
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Disable_Compare_Any_Points_Net")]
|
||||
public static extern short MCF_Disable_Compare_Any_Points_Net(ushort Axis, uint Point_Number, ushort StationNumber = 0);
|
||||
//12.3 添加一维位置比较点 宏定义0.0
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Add_Compare_Point_Net")]
|
||||
public static extern short MCF_Add_Compare_Point_Net(ushort Axis, int Position, ushort Dir, ushort Action, ushort Actpara, ushort StationNumber = 0);
|
||||
//12.4 读取当前一维比较点位置 宏定义0.0
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Compare_Current_Point_Net")]
|
||||
public static extern short MCF_Get_Compare_Current_Point_Net(ushort Axis, ref int Position, ushort StationNumber = 0);
|
||||
//12.5 查询已经比较过的一维比较点个数(注意数据溢出) 宏定义0.0 [0,256]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Compare_Points_Runned_Net")]
|
||||
public static extern short MCF_Get_Compare_Points_Runned_Net(ushort Axis, ref ushort Point_Number, ushort StationNumber = 0);
|
||||
//12.6 查询可以加入的一维比较点个数 宏定义0.0 [0,256]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Compare_Points_Remained_Net")]
|
||||
public static extern short MCF_Get_Compare_Points_Remained_Net(ushort Axis, ref ushort Point_Number, ushort StationNumber = 0);
|
||||
//12.7 查询所有未完成一维比较点个数和位置 宏定义0.0
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Compare_Points_Incomplete_Net")]
|
||||
public static extern short MCF_Get_Compare_Points_Incomplete_Net(ushort Axis, ref ushort Incomplete_Number, ref int Incomplete_Position, ushort StationNumber = 0);
|
||||
|
||||
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
13 PWM输出函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//13.1 设置PWM输出参数 宏定义13.1.1 宏定义13.1.2 宏定义13.1.3 宏定义13.1.4
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Pwm_Config_Net")]
|
||||
public static extern short MCF_Set_Pwm_Config_Net(ushort Channel, ushort Enable, ushort Output_Port_Config, ushort Output_Start_Logic, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Pwm_Config_Net")]
|
||||
public static extern short MCF_Get_Pwm_Config_Net(ushort Channel, ref ushort Enable, ref ushort Output_Port_Config, ref ushort Output_Start_Logic, ushort StationNumber = 0);
|
||||
//13.2 输出PWM信号 宏定义13.1.1 [0,1000000] [0,100] (0,(2^31-1)]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Pwm_Output_Net")]
|
||||
public static extern short MCF_Set_Pwm_Output_Net(ushort Channel, uint Frequency, uint DutyCycle, uint Pwm_Number, ushort StationNumber = 0);
|
||||
//13.3 PWM完成信号 宏定义13.1.1 宏定义13.3.1
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Pwm_State_Net")]
|
||||
public static extern short MCF_Get_Pwm_State_Net(ushort Channel, ref ushort Finish, ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
14 手轮函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//14.1 开启手轮功能 宏定义11.1.2
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Hand_Wheel_Open_Net")]
|
||||
public static extern short MCF_Hand_Wheel_Open_Net(ushort Dir, ushort StationNumber = 0);
|
||||
//14.2 关闭手轮功能
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Hand_Wheel_Close_Net")]
|
||||
public static extern short MCF_Hand_Wheel_Close_Net(ushort StationNumber = 0);
|
||||
//14.3 设置硬件手轮编码器通道 宏定义0.0
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Hand_Wheel_Config_Encoder_Net")]
|
||||
public static extern short MCF_Hand_Wheel_Config_Encoder_Net(ushort Axis, ushort StationNumber = 0);
|
||||
//14.4 设置硬件手轮速率配置输入点 宏定义2.4.1
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Hand_Wheel_Config_X1_Net")]
|
||||
public static extern short MCF_Hand_Wheel_Config_X1_Net(ushort Bit_Input_Number, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Hand_Wheel_Config_X10_Net")]
|
||||
public static extern short MCF_Hand_Wheel_Config_X10_Net(ushort Bit_Input_Number, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Hand_Wheel_Config_X100_Net")]
|
||||
public static extern short MCF_Hand_Wheel_Config_X100_Net(ushort Bit_Input_Number, ushort StationNumber = 0);
|
||||
// 设置硬件手轮速率大小 [1,100]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Hand_Wheel_Speed_X1_Net")]
|
||||
public static extern short MCF_Hand_Wheel_Speed_X1_Net(ushort Speed_X = 1, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Hand_Wheel_Speed_X10_Net")]
|
||||
public static extern short MCF_Hand_Wheel_Speed_X10_Net(ushort Speed_X = 10, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Hand_Wheel_Speed_X100_Net")]
|
||||
public static extern short MCF_Hand_Wheel_Speed_X100_Net(ushort Speed_X = 100, ushort StationNumber = 0);
|
||||
//14.4 设置硬件手轮轴号配置输入点 宏定义0.0 宏定义2.4.1
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Hand_Wheel_Config_Axis_Net")]
|
||||
public static extern short MCF_Hand_Wheel_Config_Axis_Net(ushort Axis, ushort Bit_Input_Number, ushort StationNumber = 0);
|
||||
//14.5 设置手轮运动平滑滤波时间 宏定义0.0 [1,1000]MS
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Hand_Wheel_Config_Filter_Time_Net")]
|
||||
public static extern short MCF_Hand_Wheel_Config_Filter_Time_Net(ushort Axis, uint Filter_Time_1MS, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
15 模拟量输入输出函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//15.1 读取单次ADC采样 宏定义0.0 [-2^15,(2^15-1)]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Single_Read_AD_Net")]
|
||||
public static extern short MCF_Single_Read_AD_Net(ushort Channel, ref short AD, ushort StationNumber = 0);
|
||||
//15.2 读取单次DAC输出 宏定义0.0 [-2^15,(2^15-1)]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Single_Write_DA_Net")]
|
||||
public static extern short MCF_Single_Write_DA_Net(ushort Channel, short DA, ushort StationNumber = 0);
|
||||
//15.3 设置AD双向比较器停止对应轴
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_AD_Compare_Net")]
|
||||
public static extern short MCF_Set_AD_Compare_Net(ushort Channel, short AD_Compare, ushort Stop_Axis, ushort StationNumber = 0);
|
||||
//15.4 设置AD触发数值 [0,7]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_AD_Capture_Net")]
|
||||
public static extern short MCF_Set_AD_Capture_Net(ushort Channel, short AD_Capture, ushort StationNumber = 0);
|
||||
// 0:保持不变 1:清除复位
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Clear_AD_Capture_Net")]
|
||||
public static extern short MCF_Clear_AD_Capture_Net(ushort C_1, ushort C_2, ushort C_3, ushort C_4,
|
||||
ushort C_5, ushort C_6, ushort C_7, ushort C_8, ushort StationNumber = 0);
|
||||
// 读取到达设置AD值捕获到的对应通道的AD值和轴X位置
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Capture_AD_1_Net")]
|
||||
public static extern short MCF_Get_Capture_AD_1_Net(ref short AD_5, ref int Position_1, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Capture_AD_2_Net")]
|
||||
public static extern short MCF_Get_Capture_AD_2_Net(ref short AD_6, ref int Position_1, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Capture_AD_3_Net")]
|
||||
public static extern short MCF_Get_Capture_AD_3_Net(ref short AD_7, ref int Position_1, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Capture_AD_4_Net")]
|
||||
public static extern short MCF_Get_Capture_AD_4_Net(ref short AD_8, ref int Position_1, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Capture_AD_5_Net")]
|
||||
public static extern short MCF_Get_Capture_AD_5_Net(ref short AD_1, ref int Position_1, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Capture_AD_6_Net")]
|
||||
public static extern short MCF_Get_Capture_AD_6_Net(ref short AD_2, ref int Position_1, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Capture_AD_7_Net")]
|
||||
public static extern short MCF_Get_Capture_AD_7_Net(ref short AD_3, ref int Position_1, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Capture_AD_8_Net")]
|
||||
public static extern short MCF_Get_Capture_AD_8_Net(ref short AD_4, ref int Position_1, ushort StationNumber = 0);
|
||||
//15.5 设置触发位置数值 [0,7]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Position_Capture_AD_Net")]
|
||||
public static extern short MCF_Set_Position_Capture_AD_Net(ushort Channel, int Position_1, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Position_Capture_AD_Net")]
|
||||
public static extern short MCF_Get_Position_Capture_AD_Net(ushort Channel, ref short AD, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Clear_Position_Capture_AD_Net")]
|
||||
public static extern short MCF_Clear_Position_Capture_AD_Net(ushort C_1, ushort C_2, ushort C_3, ushort C_4, ushort C_5, ushort C_6, ushort C_7, ushort C_8, ushort StationNumber = 0);
|
||||
//15.6 获取AD最大值 [0,7]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Limit_AD_Net")]
|
||||
public static extern short MCF_Get_Limit_AD_Net(ushort Channel, ref short MAX_AD, ref short MIN_AD, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Clear_Limit_AD_Net")]
|
||||
public static extern short MCF_Clear_Limit_AD_Net(ushort C_1, ushort C_2, ushort C_3, ushort C_4, ushort C_5, ushort C_6, ushort C_7, ushort C_8, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
16 系统函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//16.1 模块版本号 [0x00000000,0xFFFFFFFF] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Version_Net")]
|
||||
public static extern short MCF_Get_Version_Net(ref uint Version, ushort StationNumber = 0);
|
||||
//16.2 序列号 [0x00000000,0xFFFFFFFF] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Serial_Number_Net")]
|
||||
public static extern short MCF_Get_Serial_Number_Net(ref long Serial_Number, ushort StationNumber = 0);
|
||||
//16.3 模块运行时间 [0x00000000,0xFFFFFFFF] [0,99] 单位:秒
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Run_Time_Net")]
|
||||
public static extern short MCF_Get_Run_Time_Net(ref uint Run_Time, ushort StationNumber = 0);
|
||||
//16.4 Flash 读写功能目前暂时大小2Kbytes,也即定义一个 unsigned int Array[256] 存放数据
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Flash_Write_Net")]
|
||||
public static extern short MCF_Flash_Write_Net(uint Pass_Word_Setup, ref uint Flash_Write_Data, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Flash_Read_Net")]
|
||||
public static extern short MCF_Flash_Read_Net(uint Pass_Word_Check, ref uint Flash_Read_Data, ushort StationNumber = 0);
|
||||
//16.5 开启网络回路,一发一收,正常控制使用(默认)
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_LookBack_Enable_Net")]
|
||||
public static extern short MCF_LookBack_Enable_Net();
|
||||
//16.6 关闭网络回路,只发不收,测试老化模式下使用,或者检测各个级联模块是否工作
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_LookBack_Disable_Net")]
|
||||
public static extern short MCF_LookBack_Disable_Net();
|
||||
//16.7 通讯时间监测 &Array[12]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Connect_Time_Count_Net")]
|
||||
public static extern short MCF_Get_Connect_Time_Count_Net(ref uint Connect_Count);
|
||||
//16.8 系统定时回调函数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_CallBack_Net")]
|
||||
public static extern short MCF_Set_CallBack_Net(int CallBack, uint Time_1MS);
|
||||
}
|
||||
|
||||
}
|
26
DH.Devices.Motion/MCDLL_NET_Code.cs
Normal file
26
DH.Devices.Motion/MCDLL_NET_Code.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace XKRS.Device.SolidMotionCard
|
||||
{
|
||||
|
||||
public enum FuncRet
|
||||
{
|
||||
/// <summary>
|
||||
/// 正常命令执行成功
|
||||
/// </summary>
|
||||
Function_Success = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 打开站点不成功
|
||||
/// </summary>
|
||||
|
||||
ERR_Open_Station_Fail = -18,
|
||||
|
||||
}
|
||||
|
||||
}
|
338
DH.Devices.Motion/MCDLL_NET_SORTING.cs
Normal file
338
DH.Devices.Motion/MCDLL_NET_SORTING.cs
Normal file
@ -0,0 +1,338 @@
|
||||
using System.Runtime.InteropServices;
|
||||
/********************************************************************************************************************************************************************
|
||||
1 每个相机可以单独设置触发参数,适应给更多不同相机
|
||||
2 物件状态实时可以存储10组数据,防止计算机不实时
|
||||
3 根据物件编号下达动作,方便用户使用
|
||||
4 吹气口各种工作,防止OK与NG占用同一个通道
|
||||
********************************************************************************************************************************************************************/
|
||||
namespace MCDLL_NET
|
||||
{
|
||||
public class CMCDLL_NET_Sorting
|
||||
{
|
||||
/********************************************************************************************************************************************************************
|
||||
1 系统设置函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//1.0 筛选功能初始化函数 必须在 MCF_Open_Net() 前调用
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Init_Net")]
|
||||
public static extern short MCF_Sorting_Init_Net(ushort StationNumber = 0);
|
||||
//1.1 控制卡打开关闭函数 [1,100] [0,99] 宏定义1.1
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Open_Net")]
|
||||
public static extern short MCF_Open_Net(ushort Connection_Number, ref ushort Station_Number, ref ushort Station_Type);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Open_Net")]
|
||||
public static extern short MCF_Get_Open_Net(ref ushort Connection_Number, ref ushort Station_Number, ref ushort Station_Type);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Close_Net")]
|
||||
public static extern short MCF_Close_Net();
|
||||
//1.2 链接超时紧急停止函数 [0,60000]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Link_TimeOut_Net")]
|
||||
public static extern short MCF_Set_Link_TimeOut_Net(uint Time_1MS, uint TimeOut_Output, ushort StationNumber = 0);
|
||||
// 链接超时紧急停止触发使能函数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Trigger_Output_Bit_Net")]
|
||||
public static extern short MCF_Set_Trigger_Output_Bit_Net(ushort Bit_Output_Number, ushort Bit_Output_Enable, ushort StationNumber = 0);
|
||||
|
||||
//1.3 链接监测函数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Link_State_Net")]
|
||||
public static extern short MCF_Get_Link_State_Net(ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
2 通用输入输出函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//2.1 通用IO全部输出函数 [OUT31,OUT0] [0,99] [10000,10099]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Output_Net")]
|
||||
public static extern short MCF_Set_Output_Net(uint All_Output_Logic, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Output_Net")]
|
||||
public static extern short MCF_Get_Output_Net(ref uint All_Output_Logic, ushort StationNumber = 0);
|
||||
//2.2 通用IO按位输出函数 宏定义2.3.1 宏定义2.3.2 [0,99] [10000,10099]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Output_Bit_Net")]
|
||||
public static extern short MCF_Set_Output_Bit_Net(ushort Bit_Output_Number, ushort Bit_Output_Logic, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Output_Bit_Net")]
|
||||
public static extern short MCF_Get_Output_Bit_Net(ushort Bit_Output_Number, ref ushort Bit_Output_Logic, ushort StationNumber = 0);
|
||||
//2.4 通用IO全部输入函数 [Input31,Input0] [Input48,Input32] [0,99] [10000,10099]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Input_Net")]
|
||||
public static extern short MCF_Get_Input_Net(ref uint All_Input_Logic1, ref uint All_Input_Logic2, ushort StationNumber = 0);
|
||||
//2.5 通用IO按位输入函数 宏定义2.4.1 宏定义2.4.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Input_Bit_Net")]
|
||||
public static extern short MCF_Get_Input_Bit_Net(ushort Bit_Input_Number, ref ushort Bit_Input_Logic, ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
3 轴专用输入输出函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//3.1 伺服使能设置函数 宏定义0.0 宏定义3.1 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Servo_Enable_Net")]
|
||||
public static extern short MCF_Set_Servo_Enable_Net(ushort Axis, ushort Servo_Logic, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Servo_Enable_Net")]
|
||||
public static extern short MCF_Get_Servo_Enable_Net(ushort Axis, ref ushort Servo_Logic, ushort StationNumber = 0);
|
||||
//3.2 伺服报警复位设置函数 宏定义0.0 宏定义3.2 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Servo_Alarm_Reset_Net")]
|
||||
public static extern short MCF_Set_Servo_Alarm_Reset_Net(ushort Axis, ushort Alarm_Logic, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Servo_Alarm_Reset_Net")]
|
||||
public static extern short MCF_Get_Servo_Alarm_Reset_Net(ushort Axis, ref ushort Alarm_Logic, ushort StationNumber = 0);
|
||||
//3.3 伺服报警输入获取函数 宏定义0.0 宏定义3.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Servo_Alarm_Net")]
|
||||
public static extern short MCF_Get_Servo_Alarm_Net(ushort Axis, ref ushort Servo_Alarm_State, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
4 轴设置函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//4.1 脉冲通道输出设置函数 宏定义0.0 宏定义4.1 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Pulse_Mode_Net")]
|
||||
public static extern short MCF_Set_Pulse_Mode_Net(ushort Axis, uint Pulse_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Pulse_Mode_Net")]
|
||||
public static extern short MCF_Get_Pulse_Mode_Net(ushort Axis, ref uint Pulse_Mode, ushort StationNumber = 0);
|
||||
//4.2 位置设置函数 宏定义0.0 [-2^31,(2^31-1)] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Position_Net")]
|
||||
public static extern short MCF_Set_Position_Net(ushort Axis, int Position, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Position_Net")]
|
||||
public static extern short MCF_Get_Position_Net(ushort Axis, ref int Position, ushort StationNumber = 0);
|
||||
//4.3 编码器设置函数 宏定义0.0 [-2^31,(2^31-1)] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Encoder_Net")]
|
||||
public static extern short MCF_Set_Encoder_Net(ushort Axis, int Encoder, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Encoder_Net")]
|
||||
public static extern short MCF_Get_Encoder_Net(ushort Axis, ref int Encoder, ushort StationNumber = 0);
|
||||
//4.4 速度获取 宏定义0.0 [-2^15,(2^15-1)] [-2^15,(2^15-1)] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Vel_Net")]
|
||||
public static extern short MCF_Get_Vel_Net(ushort Axis, ref double Command_Vel, ref double Encode_Vel, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
5 轴硬件触发停止运动函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//5.1 通用IO输入复用:做为紧急停止函数 宏定义2.4.1 宏定义5.1 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_EMG_Bit_Net")]
|
||||
public static extern short MCF_Set_EMG_Bit_Net(ushort EMG_Input_Number, ushort EMG_Mode, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_EMG_Output_Net")]
|
||||
public static extern short MCF_Set_EMG_Output_Net(ushort EMG_Input_Number, ushort EMG_Mode, uint EMG_Output, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_EMG_Output_Enable_Net")]
|
||||
public static extern short MCF_Set_EMG_Output_Enable_Net(ushort Bit_Output_Number, ushort Bit_Output_Enable, ushort StationNumber = 0);
|
||||
//5.11 轴状态触发停止运动查询函数 宏定义0.0 MC_Retrun.h[0,28] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Axis_State_Net")]
|
||||
public static extern short MCF_Get_Axis_State_Net(ushort Axis, ref short Reason, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
7 点位运动控制函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//7.1 速度控制函数 宏定义0.0 (0,10M]P/S (0,1T]P^2/S [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_JOG_Net")]
|
||||
public static extern short MCF_JOG_Net(ushort Axis, double dMaxV, double dMaxA, ushort StationNumber = 0);
|
||||
//7.4 单轴曲线函数 宏定义0.0 [0,dMaxV] (0,10M]P/S (0,1T]P^2/S (0,100T]P^3/S [0,dMaxV] 宏定义0.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Axis_Profile_Net")]
|
||||
public static extern short MCF_Set_Axis_Profile_Net(ushort Axis, double dV_ini, double dMaxV, double dMaxA, double dJerk, double dV_end, ushort Profile, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Axis_Profile_Net")]
|
||||
public static extern short MCF_Get_Axis_Profile_Net(ushort Axis, ref double dV_ini, ref double dMaxV, ref double dMaxA, ref double dJerk, ref double dV_end, ref ushort Profile, ushort StationNumber = 0);
|
||||
//7.5 单轴运动函数 宏定义0.0 [-2^31,(2^31-1)] 宏定义0.3 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Uniaxial_Net")]
|
||||
public static extern short MCF_Uniaxial_Net(ushort Axis, int dDist, ushort Position_Mode, ushort StationNumber = 0);
|
||||
//7.6 单轴停止曲线函数 宏定义0.0 (0,1T]P^2/S (0,100T]P^3/S 宏定义0.4 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Axis_Stop_Profile_Net")]
|
||||
public static extern short MCF_Set_Axis_Stop_Profile_Net(ushort Axis, double dMaxA, double dJerk, ushort Profile, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Axis_Stop_Profile_Net")]
|
||||
public static extern short MCF_Get_Axis_Stop_Profile_Net(ushort Axis, ref double dMaxA, ref double dJerk, ref ushort Profile, ushort StationNumber = 0);
|
||||
//7.7 轴停止函数 宏定义0.0 宏定义7.7 [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Axis_Stop_Net")]
|
||||
public static extern short MCF_Axis_Stop_Net(ushort Axis, ushort Axis_Stop_Mode, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
16 光源控制器函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//16.1 设置光源模式(1MS阻塞函数) 宏定义16.1.1 0:关闭 1:24V常亮 2:24V频闪 3:48V爆闪
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Light_Mode_Net")]
|
||||
public static extern short MCF_Set_Light_Mode_Net(ushort Channel, ushort Light_Mode, ushort StationNumber = 0);
|
||||
//16.2 设置电流保护(1MS阻塞函数) 宏定义16.1.1 [0,15000] 单位:MA Over_Current/1000*0.1*11/3.3 * 4095
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Light_Current_Net")]
|
||||
public static extern short MCF_Set_Light_Current_Net(ushort Channel, ushort Max_Current, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Light_Current_1_4_Net")]
|
||||
public static extern short MCF_Get_Light_Current_1_4_Net(ref ushort Current_1, ref ushort Current_2, ref ushort Current_3, ref ushort Current_4, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Light_Current_5_8_Net")]
|
||||
public static extern short MCF_Get_Light_Current_5_8_Net(ref ushort Current_5, ref ushort Current_6, ref ushort Current_7, ref ushort Current_8, ushort StationNumber = 0);
|
||||
//16.3 设置光源输出(1MS阻塞函数) 宏定义16.1.1 常亮:[0,255] 频闪[0,1000]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Light_Output_Net")]
|
||||
public static extern short MCF_Set_Light_Output_Net(ushort Channel, ushort Light_Size, ushort StationNumber = 0);
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
17 系统函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//17.1 模块版本号 [0x00000000,0xFFFFFFFF] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Version_Net")]
|
||||
public static extern short MCF_Get_Version_Net(ref uint Version, ushort StationNumber = 0);
|
||||
//17.2 序列号 [0x00000000,0xFFFFFFFF] [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Serial_Number_Net")]
|
||||
public static extern short MCF_Get_Serial_Number_Net(ref long Serial_Number, ushort StationNumber = 0);
|
||||
//17.3 模块运行时间 [0x00000000,0xFFFFFFFF] [0,99] 单位:秒
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Get_Run_Time_Net")]
|
||||
public static extern short MCF_Get_Run_Time_Net(ref uint Run_Time, ushort StationNumber = 0);
|
||||
//17.4 Flash 读写功能目前暂时大小2Kbytes,也即定义一个 unsigned int Array[256] 存放数据
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Flash_Write_Net")]
|
||||
public static extern short MCF_Flash_Write_Net(uint Pass_Word_Setup, ref uint Flash_Write_Data, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Flash_Read_Net")]
|
||||
public static extern short MCF_Flash_Read_Net(uint Pass_Word_Check, ref uint Flash_Read_Data, ushort StationNumber = 0);
|
||||
//17.8 系统定时回调函数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_CallBack_Net")]
|
||||
public static extern short MCF_Set_CallBack_Net(int CallBack, uint Time_1MS);
|
||||
|
||||
|
||||
|
||||
/********************************************************************************************************************************************************************
|
||||
101 关闭自动筛选功能并清除来料,相机,吹气计数 注意:调用该函数后才可以设置102,103,104项目参数
|
||||
********************************************************************************************************************************************************************/
|
||||
//101.1 设置参数前必须调用先关闭筛选功能
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Close_Net")]
|
||||
public static extern short MCF_Sorting_Close_Net(ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
102 设置来料检测功能,用户根据需要设置 注意:自动筛选时禁止设置
|
||||
********************************************************************************************************************************************************************/
|
||||
//102.1 物件最大最小尺寸
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Piece_Size_Net")]
|
||||
public static extern short MCF_Sorting_Set_Piece_Size_Net(uint Max_Size, uint Min_Size, ushort StationNumber = 0);
|
||||
//102.2 物件安全距离,安全时间
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Piece_Place_Net")]
|
||||
public static extern short MCF_Sorting_Set_Piece_Place_Net(uint Min_Distance, uint Min_Time_Intervel, ushort StationNumber = 0);
|
||||
//102.3 来料检测设置
|
||||
// 来料检测使能(默认Bit_Output_0,Bit_Output_1开,0:关 1:开) [Bit_Input_0,Bit_Input_3]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Input_Enable_Net")]
|
||||
public static extern short MCF_Sorting_Set_Input_Enable_Net(ushort Bit_Input_Number, ushort Bit_Input_Enable, ushort StationNumber = 0);
|
||||
// 来料检测电平(默认全部低电平, 0:低电平 1:高电平) [Bit_Input_0,Bit_Input_3]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Input_Logic_Net")]
|
||||
public static extern short MCF_Sorting_Set_Input_Logic_Net(ushort Bit_Input_Number, ushort Bit_Input_Logic, ushort StationNumber = 0);
|
||||
// 来料检测编码器(默认全部跟随Axis_1编码器) [Bit_Input_0,Bit_Input_3]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Input_Source_Net")]
|
||||
public static extern short MCF_Sorting_Set_Input_Source_Net(ushort Bit_Input_Number, ushort Axis, ushort Source, ushort StationNumber = 0);
|
||||
// 来料检测捕获位置(默认全部捕获前部, 0:前部 1:中间) [Bit_Input_0,Bit_Input_3]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Input_Position_Net")]
|
||||
public static extern short MCF_Sorting_Set_Input_Position_Net(ushort Bit_Input_Number, ushort Mode, ushort StationNumber = 0);
|
||||
|
||||
//102.4 DI00 检测不连续物件强制保持连续
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Piece_Keep_Net")]
|
||||
public static extern short MCF_Sorting_Set_Piece_Keep_Net(uint Keep_Length, ushort StationNumber = 0);
|
||||
//102.5 DI00 物件检测无料超时停止轴运动(默认时间0,表示不启动) [0,60000] &Array[DO00,DO15],0:低 1:高 2:关闭
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Input_0_TimeOut_Net")]
|
||||
public static extern short MCF_Sorting_Set_Input_0_TimeOut_Net(uint Time_1MS, ref uint TimeOut_Output, ushort StationNumber = 0);
|
||||
//102.6 通用IO按位输入滤波函数 [Bit_Input_0,Bit_Input_1] [1,100]MS [0,99]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Set_Input_Filter_Time_Bit_Net")]
|
||||
public static extern short MCF_Set_Input_Filter_Time_Bit_Net(ushort Bit_Input_Number, uint Filter_Time_1MS, ushort StationNumber = 0);
|
||||
//102.7 多个来料检测绑定相机触发,OK吹气,NG吹气 [Bit_Input_1]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Input_Bind_Net")]
|
||||
public static extern short MCF_Sorting_Set_Input_Bind_Net(ushort Bit_Input_Number, ushort Camera_Start_Number, ushort Bond_Start_Number, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
103 设置OK,NG安全保护参数,用户根据需要设置 注意:自动筛选时禁止设置
|
||||
********************************************************************************************************************************************************************/
|
||||
//103.1 物件吹气OK超时停止轴运动(默认时间0,表示不启动) [0,60000] &Array[DO00,DO15],0:低 1:高 2:关闭
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Trig_Blow_OK_TimeOut_Net")]
|
||||
public static extern short MCF_Sorting_Set_Trig_Blow_OK_TimeOut_Net(uint Time_1MS, ref uint TimeOut_Output, ushort StationNumber = 0);
|
||||
//103.2 物件吹气连续NG停止轴运动(默认时间0,表示不启动) [0,60000] &Array[DO00,DO15],0:低 1:高 2:关闭
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Trig_Blow_NG_NumberOut_Net")]
|
||||
public static extern short MCF_Sorting_Set_Trig_Blow_NG_NumberOut_Net(uint NG_Number, ref uint NumberOut_Output, ushort StationNumber = 0);
|
||||
//103.3 HMC3432S/HMC3412S 可以设置物件重新检测确定功能,以此判定是否误吹
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Blow_Check_Again_Net")]
|
||||
public static extern short MCF_Sorting_Set_Blow_Check_Again_Net(ushort Bit_Input_Number, ushort Bit_Input_Logic, int Input_Position, uint Piece_Size,
|
||||
ushort Blow_OK_Check,
|
||||
ushort Blow_NG_Check,
|
||||
ushort Blow_1_Check,
|
||||
ushort Blow_2_Check,
|
||||
ushort Blow_3_Check,
|
||||
ushort Blow_4_Check,
|
||||
ushort Blow_5_Check,
|
||||
ushort Blow_6_Check,
|
||||
ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Blow_Check_Lose_Number_Net")]
|
||||
public static extern short MCF_Sorting_Get_Blow_Check_Lose_Number_Net(ref uint Lose_Number, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
104 设置相机吹气参数,用户必须设置 注意:自动筛选时禁止设置
|
||||
********************************************************************************************************************************************************************/
|
||||
//104.1 HMC3432S 可以配置相机和吹气个数 [1,30] [1,30]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Camera_Blow_Config_Net")]
|
||||
public static extern short MCF_Sorting_Camera_Blow_Config_Net(ushort Camera_Number, ushort Blow_Number, ushort StationNumber = 0);
|
||||
//104.2 设置相机参数 与检测装置的相对位置 编码器反馈的运行方向
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Camera_Net")]
|
||||
public static extern short MCF_Sorting_Set_Camera_Net(ushort Camera_Number, int Camera_Position, ushort Motion_Dir, ushort Action_Mode, ushort Action_IO, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Camera_Light_Frequency_Net")]
|
||||
public static extern short MCF_Sorting_Set_Camera_Light_Frequency_Net(ushort Camera_Number, ushort Light_Number, ushort Frequency_Enable, ushort StationNumber = 0);
|
||||
//104.3 设置运动控制卡触发相机拍照后,延时多少毫秒计数增加1,一般设置为 大于 控制卡从触发相机拍照到软件出图像结果需要的时间,
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Trig_Camera_Delay_Count_Net")]
|
||||
public static extern short MCF_Sorting_Set_Trig_Camera_Delay_Count_Net(ushort Camera_Number, double Camera_Delay_Count_MS, ushort StationNumber = 0);
|
||||
//104.4 设置OK吹气参数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Blow_OK_Net")]
|
||||
public static extern short MCF_Sorting_Set_Blow_OK_Net(int Blow_OK_Position, ushort Motion_Dir, ushort Action_Mode, ushort Action_IO, ushort StationNumber = 0);
|
||||
//104.5 设置NG吹气参数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Blow_NG_Net")]
|
||||
public static extern short MCF_Sorting_Set_Blow_NG_Net(int Blow_NG_Position, ushort Motion_Dir, ushort Action_Mode, ushort Action_IO, ushort StationNumber = 0);
|
||||
//104.6 设置吹气1到30参数 [1,30]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Blow_Net")]
|
||||
public static extern short MCF_Sorting_Set_Blow_Net(ushort Blow_Number, int Blow_Position, ushort Motion_Dir, ushort Action_Mode, ushort Action_IO, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
105 自动筛选功能启动函数 注意:调用该函数后禁止设置102,103,104项目参数
|
||||
********************************************************************************************************************************************************************/
|
||||
//105.1 筛选启动函数,在设置好参数后启动
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Start_Net")]
|
||||
public static extern short MCF_Sorting_Start_Net(ushort Mode = 0, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
106 物料图像结果处理
|
||||
********************************************************************************************************************************************************************/
|
||||
//106.0 设置相机处理结果最短时间和最大超时时间,允许连续超时最大个数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Camera_Handle_Time_Net")]
|
||||
public static extern short MCF_Sorting_Set_Camera_Handle_Time_Net(ushort Camera_Number, double Handle_Time_1MS, double Handle_TimeOut_1MS, uint Handle_TimeOut_Number, ushort StationNumber = 0);
|
||||
//106.1 吹气模式0:用户综合所有相机结果后发送吹气指令
|
||||
// 用户在图像处理回调函数中调用该函数通知图像处理结果
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Camera_Result_Data_Net")]
|
||||
public static extern short MCF_Sorting_Set_Camera_Result_Data_Net(ushort Camera_Number, uint Result_Data, ushort StationNumber = 0);
|
||||
// 用户开辟线程检查物料最新的图像结果
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Camera_Result_Updata_Net")]
|
||||
public static extern short MCF_Sorting_Get_Camera_Result_Updata_Net(ushort Camera_Number, ref uint Piece_Number, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Camera_Result_Buffer_Net")]
|
||||
public static extern short MCF_Sorting_Get_Camera_Result_Buffer_Net(ushort Camera_Number, uint Piece_Number, ref uint Result_Buffer, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Camera_Handle_Time_Net")]
|
||||
public static extern short MCF_Sorting_Get_Camera_Handle_Time_Net(ushort Camera_Number, uint Piece_Number, ref uint Handle_Time, ushort StationNumber = 0);
|
||||
// 用户根据图像结果吹气
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Trig_Blow_OK_Net")]
|
||||
public static extern short MCF_Sorting_Set_Trig_Blow_OK_Net(uint Piece_Number, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Trig_Blow_NG_Net")]
|
||||
public static extern short MCF_Sorting_Set_Trig_Blow_NG_Net(uint Piece_Number, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Trig_Blow_Net")]
|
||||
public static extern short MCF_Sorting_Set_Trig_Blow_Net(ushort Blow_Number, uint Piece_Number, ushort StationNumber = 0);
|
||||
//106.2 吹气模式1:用户直接发送每个相机结果,控制卡自动综合结果后吹气
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Camera_Result_OK_Net")]
|
||||
public static extern short MCF_Sorting_Set_Camera_Result_OK_Net(ushort Camera_Number, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Camera_Result_NG_Net")]
|
||||
public static extern short MCF_Sorting_Set_Camera_Result_NG_Net(ushort Camera_Number, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Blow_Result_OK_Net")]
|
||||
public static extern short MCF_Sorting_Get_Blow_Result_OK_Net(ref uint Result_OK_Number, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Blow_Result_NG_Net")]
|
||||
public static extern short MCF_Sorting_Get_Blow_Result_NG_Net(ref uint Result_NG_Number, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Blow_Result_Miss_Net")]
|
||||
public static extern short MCF_Sorting_Get_Blow_Result_Miss_Net(ref uint Result_Miss_Number, ushort StationNumber = 0);
|
||||
|
||||
//106.3 吹气模式2:用户不需要发送相机结果,控制卡通过IO综合结果后吹气,全程通过硬件实现,可以直接替代PLC (0,500]
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Camera_Result_Input_OK_Net")]
|
||||
public static extern short MCF_Sorting_Set_Camera_Result_Input_OK_Net(ushort Camera_Number, ushort Input_Number, ushort Logic, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Set_Camera_Result_Input_NG_Net")]
|
||||
public static extern short MCF_Sorting_Set_Camera_Result_Input_NG_Net(ushort Camera_Number, ushort Input_Number, ushort Logic, ushort StationNumber = 0);
|
||||
/********************************************************************************************************************************************************************
|
||||
107 物件,相机,吹气状态监测函数
|
||||
********************************************************************************************************************************************************************/
|
||||
//107.0 筛选监测函数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_State_Net")]
|
||||
public static extern short MCF_Sorting_Get_State_Net(ref ushort State, ushort StationNumber = 0);
|
||||
|
||||
//107.1 获取DI00物件不合格计数个数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Piece_Pass_Net")]
|
||||
public static extern short MCF_Sorting_Get_Piece_Pass_Net(ushort Piece_Input_Number, ref uint Piece_Pass, ushort StationNumber = 0);
|
||||
//107.2 获取DI00物件计数个数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Piece_State_Net")]
|
||||
public static extern short MCF_Sorting_Get_Piece_State_Net(ushort Piece_Input_Number, //物件计数的输入端口号
|
||||
ref uint Piece_Find, //物件匹配统计数量
|
||||
ref uint Piece_Size, //物件大小,10组
|
||||
ref uint Piece_Distance_To_next, //物件间距,10组
|
||||
ref uint Piece_Cross_Camera, //物件经过所有相机个数
|
||||
ushort StationNumber = 0);
|
||||
//107.3 获取判断控制卡触发相机拍照计数,图像结果输出结果一定要先于延时后的控制卡相机拍照计数,而且要一一对应,否则做为图像异常或者漏拍处理
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Trig_Camera_Count_Net")]
|
||||
public static extern short MCF_Sorting_Get_Trig_Camera_Count_Net(ushort Camera_Number, ref uint Trig_Camera_Count, ushort StationNumber = 0);
|
||||
//107.4 获取OK,NG触发计数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Trig_Blow_NG_Count_Net")]
|
||||
public static extern short MCF_Sorting_Get_Trig_Blow_NG_Count_Net(ref uint Trig_Blow_NG_Count, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Trig_Blow_OK_Count_Net")]
|
||||
public static extern short MCF_Sorting_Get_Trig_Blow_OK_Count_Net(ref uint Trig_Blow_OK_Count, ushort StationNumber = 0);
|
||||
//107.5 获取OK,NG漏触发计数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Lose_Blow_NG_Count_Net")]
|
||||
public static extern short MCF_Sorting_Get_Lose_Blow_NG_Count_Net(ref uint Lose_Blow_NG_Count, ushort StationNumber = 0);
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Lose_Blow_OK_Count_Net")]
|
||||
public static extern short MCF_Sorting_Get_Lose_Blow_OK_Count_Net(ref uint Lose_Blow_OK_Count, ushort StationNumber = 0);
|
||||
//107.6 获取气阀吹气计数
|
||||
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Sorting_Get_Trig_Blow_Count_Net")]
|
||||
public static extern short MCF_Sorting_Get_Trig_Blow_Count_Net(ushort Blow_Number, ref uint Trig_Blow_Count, ushort StationNumber = 0);
|
||||
|
||||
}
|
||||
}
|
1239
DH.Devices.Motion/MotionBase.cs
Normal file
1239
DH.Devices.Motion/MotionBase.cs
Normal file
File diff suppressed because it is too large
Load Diff
2688
DH.Devices.Motion/SLDMotion.cs
Normal file
2688
DH.Devices.Motion/SLDMotion.cs
Normal file
File diff suppressed because it is too large
Load Diff
277
DH.Devices.Motion/SolidMotionCardEnum.cs
Normal file
277
DH.Devices.Motion/SolidMotionCardEnum.cs
Normal file
@ -0,0 +1,277 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DH.Devices.Motion
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 回零状态
|
||||
/// </summary>
|
||||
public enum SearchHomeState
|
||||
{
|
||||
/// <summary>
|
||||
/// 回零成功
|
||||
/// </summary>
|
||||
[Description("回零成功")]
|
||||
HomeSucess = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 回零错误
|
||||
/// </summary>
|
||||
[Description("回零错误")]
|
||||
HomeError = 31,
|
||||
|
||||
/// <summary>
|
||||
/// 正在回零点
|
||||
/// </summary>
|
||||
[Description("正在回零点")]
|
||||
Homing = 32,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 0.3 坐标模式
|
||||
/// </summary>
|
||||
public enum PositionMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 绝对位置模式
|
||||
/// </summary>
|
||||
[Description("绝对位置模式")]
|
||||
Position_Absolute = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 相对位置模式
|
||||
/// </summary>
|
||||
[Description("相对位置模式")]
|
||||
Position_Opposite = 1,
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 0.4 单轴点动曲线类型
|
||||
/// </summary>
|
||||
public enum Profile
|
||||
{
|
||||
/// <summary>
|
||||
/// T型曲线
|
||||
/// </summary>
|
||||
[Description("T型曲线")]
|
||||
Profile_T = 0,
|
||||
|
||||
/// <summary>
|
||||
/// S型曲线
|
||||
/// </summary>
|
||||
[Description("S型曲线")]
|
||||
Profile_S = 1,
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 3.1 伺服使能设置
|
||||
/// </summary>
|
||||
public enum ServoLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// 触点闭合
|
||||
/// </summary>
|
||||
[Description("触点闭合")]
|
||||
Servo_Close = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 触点打开
|
||||
/// </summary>
|
||||
[Description("触点打开")]
|
||||
Servo_Open = 1,
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 3.2 报警复位电平设置
|
||||
/// </summary>
|
||||
public enum AlarmLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// 触点闭合
|
||||
/// </summary>
|
||||
[Description("触点闭合")]
|
||||
Alarm_Close = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 触点打开
|
||||
/// </summary>
|
||||
[Description("触点打开")]
|
||||
Alarm_Open = 1,
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 3.6
|
||||
/// </summary>
|
||||
public enum HomeState
|
||||
{
|
||||
/// <summary>
|
||||
/// 触点闭合,硬件灯亮
|
||||
/// </summary>
|
||||
[Description("触点闭合,硬件灯亮")]
|
||||
Home_Close = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 触点打开,硬件灯灭
|
||||
/// </summary>
|
||||
[Description("触点打开,硬件灯灭")]
|
||||
Home_Open = 1,
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 4.1 脉冲模式
|
||||
/// </summary>
|
||||
public enum PulseMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 脉冲方向(默认)
|
||||
/// </summary>
|
||||
[Description("模式0")]
|
||||
Pulse_Dir_H = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 脉冲方向
|
||||
/// </summary>
|
||||
[Description("模式1")]
|
||||
Pulse_Dir_L = 1,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 双脉冲
|
||||
/// </summary>
|
||||
[Description("模式2")]
|
||||
Pulse_CW_CCW = 2,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 双脉冲
|
||||
/// </summary>
|
||||
[Description("模式3")]
|
||||
Pulse_CCW_CW = 3,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// AB相位
|
||||
/// </summary>
|
||||
[Description("模式4")]
|
||||
Pulse_AB = 4,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// AB相位
|
||||
/// </summary>
|
||||
[Description("模式5")]
|
||||
Pulse_BA = 5,
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************************************************
|
||||
5 轴硬件触发停止运动函数
|
||||
*****************************************************************************************************************/
|
||||
//5.1 EMG_Mode
|
||||
public enum EMG_Mode
|
||||
{
|
||||
[Description("不使用紧急停止功能")]
|
||||
EMG_Trigger_Close = 0, //不使用紧急停止功能
|
||||
|
||||
[Description("低电平触发紧急停止")]
|
||||
EMG_Trigger_Low_IMD = 1, //低电平触发紧急停止
|
||||
|
||||
[Description("低电平触发减速停止")]
|
||||
EMG_Trigger_Low_DEC = 2,//低电平触发减速停止
|
||||
|
||||
[Description("高电平触发紧急停止")]
|
||||
EMG_Trigger_High_IMD = 3, //高电平触发紧急停止
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 6.1.1 正负限位触发电平
|
||||
/// </summary>
|
||||
public enum LimitLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// 低电平触发
|
||||
/// </summary>
|
||||
[Description("低电平触发")]
|
||||
Low_Logic = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 高电平触发
|
||||
/// </summary>
|
||||
[Description("高电平触发")]
|
||||
High_Logic = 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 6.1.2 回零限位触发电平
|
||||
/// </summary>
|
||||
public enum HomeLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// 低电平触发
|
||||
/// </summary>
|
||||
[Description("低电平触发")]
|
||||
Low_Logic = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 高电平触发
|
||||
/// </summary>
|
||||
[Description("高电平触发")]
|
||||
High_Logic = 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 6.1.3 Index触发电平
|
||||
/// </summary>
|
||||
public enum IndexLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// 低电平触发
|
||||
/// </summary>
|
||||
[Description("低电平触发")]
|
||||
Low_Logic = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 高电平触发
|
||||
/// </summary>
|
||||
[Description("高电平触发")]
|
||||
High_Logic = 1,
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -49,7 +49,7 @@ namespace DH.Devices.PLC
|
||||
{
|
||||
connected = true;
|
||||
MonitorPieces();
|
||||
TurntableOpen(2000,true);
|
||||
TurntableOpen(12000,true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -23,6 +23,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DH.Devices.Camera", "DH.Dev
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DH.Devices.PLC", "DH.Devices.PLC\DH.Devices.PLC.csproj", "{458B2CF6-6F1B-4B8B-BB85-C6FD7F453A5D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Motion", "Motion", "{5C8472C6-EB6A-4D89-B519-7073BBF6A5D2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DH.Devices.Motion", "DH.Devices.Motion\DH.Devices.Motion.csproj", "{144E3775-0BD7-4528-9FB0-A0F4ADC74313}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -71,6 +75,14 @@ Global
|
||||
{458B2CF6-6F1B-4B8B-BB85-C6FD7F453A5D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{458B2CF6-6F1B-4B8B-BB85-C6FD7F453A5D}.Release|x64.ActiveCfg = Release|x64
|
||||
{458B2CF6-6F1B-4B8B-BB85-C6FD7F453A5D}.Release|x64.Build.0 = Release|x64
|
||||
{144E3775-0BD7-4528-9FB0-A0F4ADC74313}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{144E3775-0BD7-4528-9FB0-A0F4ADC74313}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{144E3775-0BD7-4528-9FB0-A0F4ADC74313}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{144E3775-0BD7-4528-9FB0-A0F4ADC74313}.Debug|x64.Build.0 = Debug|x64
|
||||
{144E3775-0BD7-4528-9FB0-A0F4ADC74313}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{144E3775-0BD7-4528-9FB0-A0F4ADC74313}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{144E3775-0BD7-4528-9FB0-A0F4ADC74313}.Release|x64.ActiveCfg = Release|x64
|
||||
{144E3775-0BD7-4528-9FB0-A0F4ADC74313}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -83,6 +95,8 @@ Global
|
||||
{97B55FCF-54A3-449E-8437-735E65C35291} = {F77AF94C-280D-44C5-B7C0-FC86AA9EC504}
|
||||
{1378A932-1C25-40EF-BA31-A3463B23F4E5} = {1591B03B-0015-42FC-B784-0D9F740E2A23}
|
||||
{458B2CF6-6F1B-4B8B-BB85-C6FD7F453A5D} = {2560C5A5-0CA2-48AD-B606-6C55BEFD8109}
|
||||
{5C8472C6-EB6A-4D89-B519-7073BBF6A5D2} = {8EC33C16-65CE-4C12-9C8D-DB2425F9F7C0}
|
||||
{144E3775-0BD7-4528-9FB0-A0F4ADC74313} = {5C8472C6-EB6A-4D89-B519-7073BBF6A5D2}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6FC1A8DF-636E-434C-981E-10F20FAD723B}
|
||||
|
@ -17,6 +17,8 @@ using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static AntdUI.Math3D;
|
||||
@ -209,7 +211,7 @@ namespace DHSoftware
|
||||
|
||||
|
||||
|
||||
|
||||
public List<HikVisionCamera> HKCameras { get; } = new List<HikVisionCamera>();
|
||||
public List<Do3ThinkCamera> Cameras { get; } = new List<Do3ThinkCamera>();
|
||||
public Dictionary<string, SimboObjectDetection> Dectection { get; } = new Dictionary<string, SimboObjectDetection>();
|
||||
public XinJEPLCTcpNet PLC { get; } = new XinJEPLCTcpNet();
|
||||
@ -224,7 +226,10 @@ namespace DHSoftware
|
||||
{
|
||||
camera.CameraDisConnect();
|
||||
}
|
||||
|
||||
foreach (var camera in HKCameras)
|
||||
{
|
||||
camera.CameraDisConnect();
|
||||
}
|
||||
PLC.PLCDisConnect();
|
||||
}
|
||||
|
||||
@ -339,6 +344,7 @@ namespace DHSoftware
|
||||
detectionList.Add(det3);
|
||||
detectionList.Add(det4);
|
||||
Cameras.Clear();
|
||||
HKCameras.Clear();
|
||||
Dectection.Clear();
|
||||
_cameraRelatedDetectionDict = new();
|
||||
|
||||
@ -365,7 +371,34 @@ namespace DHSoftware
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
string inferenceDevice = "CPU";
|
||||
//for (int i = 1; i <= 8; i++)
|
||||
//{
|
||||
// HikVisionCamera camera = new HikVisionCamera();
|
||||
// camera.CameraName = $"Cam{i}";
|
||||
// camera.CameraIP = $"192.168.{i}.1";
|
||||
// camera.ComputerIP = $"192.168.{i}.1";
|
||||
// camera.CameraConnect();
|
||||
// camera.OnHImageOutput += OnCameraHImageOutput;
|
||||
// HKCameras.Add(camera);
|
||||
// var simbo_1 = new SimboObjectDetection
|
||||
// {
|
||||
|
||||
// };
|
||||
// MLInit mLInit_1;
|
||||
|
||||
|
||||
// mLInit_1 = new MLInit($"D:\\PROJECTS\\MaodingTest1\\Vision\\cam{i}.onnx", "images", inferenceDevice, 640, 640);
|
||||
|
||||
|
||||
// simbo_1.Load(mLInit_1);
|
||||
// Dectection.Add(camera.CameraName, simbo_1);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Add the code for the "启动" button click here
|
||||
Do3ThinkCamera do3ThinkCamera1 = new Do3ThinkCamera();
|
||||
|
||||
@ -383,7 +416,7 @@ namespace DHSoftware
|
||||
do3ThinkCamera2.OnHImageOutput += OnCameraHImageOutput;
|
||||
var simbo1 = new SimboObjectDetection();
|
||||
MLInit mLInit;
|
||||
string inferenceDevice = "CPU";
|
||||
|
||||
|
||||
mLInit = new MLInit($"D:\\PROJECTS\\MaodingTest1\\Vision\\cam1.onnx", "images", inferenceDevice, 640, 640);
|
||||
|
||||
@ -395,9 +428,9 @@ namespace DHSoftware
|
||||
|
||||
var simbo2 = new SimboObjectDetection();
|
||||
MLInit mLInit2;
|
||||
string inferenceDevice2 = "CPU";
|
||||
|
||||
|
||||
mLInit2 = new MLInit($"D:\\PROJECTS\\MaodingTest1\\Vision\\cam2.onnx", "images", inferenceDevice2, 640, 640);
|
||||
mLInit2 = new MLInit($"D:\\PROJECTS\\MaodingTest1\\Vision\\cam2.onnx", "images", inferenceDevice, 640, 640);
|
||||
|
||||
|
||||
simbo2.Load(mLInit2);
|
||||
@ -479,6 +512,7 @@ namespace DHSoftware
|
||||
{
|
||||
using (Mat localImageSet = imageSet.Clone()) // 复制 Mat 避免并发问题
|
||||
{
|
||||
// imageSet?.Dispose();
|
||||
// 拍照计数与物件编号一致,查找对应的产品
|
||||
ProductData product = null;
|
||||
//内外壁模组多个相机的处理方法
|
||||
@ -558,190 +592,148 @@ namespace DHSoftware
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#region 1.预处理
|
||||
#endregion
|
||||
#region 2.深度学习推理
|
||||
var req = new MLRequest();
|
||||
|
||||
req.mImage = localImageSet.Clone();
|
||||
//req.ResizeWidth = detectConfig.ModelWidth;
|
||||
//req.ResizeHeight = detectConfig.ModelHeight;
|
||||
//req.confThreshold = detectConfig.ModelconfThreshold;
|
||||
//req.iouThreshold = 0.3f;
|
||||
//req.out_node_name = detectConfig.ModeloutNodeName;
|
||||
//req.in_lable_path = detectConfig.in_lable_path;
|
||||
req.ResizeWidth = 640;
|
||||
req.ResizeHeight = 640;
|
||||
req.confThreshold = 0.5f;
|
||||
req.iouThreshold = 0.3f;
|
||||
req.out_node_name = "output0";
|
||||
req.in_lable_path = "D:\\PROJECTS\\MaodingTest1\\Vision\\cam1.txt";
|
||||
//req.LabelNames = dc.GetLabelNames();
|
||||
|
||||
//HOperatorSet.WriteImage(req.HImage, "png", 0, @"D:\\666.png");
|
||||
Stopwatch
|
||||
sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
|
||||
var result = Dectection[detectionId].RunInference(req);
|
||||
sw.Stop();
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.1,产品{productNumber},耗时{sw.ElapsedMilliseconds}ms");
|
||||
#endregion
|
||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||
// 1. 预处理
|
||||
using (Mat inferenceImage = localImageSet.Clone()) // 仅在此处克隆,确保推理过程中 Mat 有独立副本
|
||||
{
|
||||
if (pictureBox1.Image != null)
|
||||
#region 1.预处理
|
||||
#endregion
|
||||
#region 2.深度学习推理
|
||||
var req = new MLRequest();
|
||||
|
||||
req.mImage = inferenceImage;
|
||||
|
||||
req.ResizeWidth = 640;
|
||||
req.ResizeHeight = 640;
|
||||
req.confThreshold = 0.5f;
|
||||
req.iouThreshold = 0.3f;
|
||||
req.out_node_name = "output0";
|
||||
req.in_lable_path = "D:\\PROJECTS\\MaodingTest1\\Vision\\cam1.txt";
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
var result = Dectection[detectionId].RunInference(req);
|
||||
sw.Stop();
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.1,产品{productNumber},耗时{sw.ElapsedMilliseconds}ms");
|
||||
#endregion
|
||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
pictureBox1.Image.Dispose(); // 释放旧图像
|
||||
}
|
||||
pictureBox1.Image = result.ResultMap;
|
||||
richTextBox1.AppendText($"推理成功 {productNumber}, {result.IsSuccess} 耗时 {sw.ElapsedMilliseconds}ms\n");
|
||||
}));
|
||||
req.mImage.Dispose();
|
||||
pictureBox1.Image?.Dispose(); // 释放旧图像
|
||||
pictureBox1.Image = result.ResultMap;
|
||||
richTextBox1.AppendText($"推理成功 {productNumber}, {result.IsSuccess} 耗时 {sw.ElapsedMilliseconds}ms\n");
|
||||
}));
|
||||
req.mImage.Dispose();
|
||||
#if true
|
||||
|
||||
#region 3.后处理
|
||||
DetectStationResult detectResult = new DetectStationResult();
|
||||
if (result == null || (result != null && !result.IsSuccess))
|
||||
{
|
||||
detectResult.IsMLDetectDone = false;
|
||||
}
|
||||
if (result != null && result.IsSuccess)
|
||||
{
|
||||
detectResult.DetectDetails = result.ResultDetails;
|
||||
if (detectResult.DetectDetails != null)
|
||||
{
|
||||
}
|
||||
else
|
||||
#region 3.后处理
|
||||
DetectStationResult detectResult = new DetectStationResult();
|
||||
if (result == null || (result != null && !result.IsSuccess))
|
||||
{
|
||||
detectResult.IsMLDetectDone = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region 3.后处理
|
||||
#endregion
|
||||
//根据那些得分大于阈值的推理结果,判断产品是否成功
|
||||
#region 4.最终过滤(逻辑过滤)
|
||||
detectResult.DetectDetails?.ForEach(d =>
|
||||
{
|
||||
|
||||
|
||||
//当前检测项的 过滤条件
|
||||
//var conditionList = detectConfig.DetectionFilterList
|
||||
// .Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
||||
// .GroupBy(u => u.ResultState)
|
||||
// .OrderBy(u => u.Key)
|
||||
// .ToList();
|
||||
//当前检测项的 过滤条件
|
||||
var conditionList = detectConfig.DetectionFilterList
|
||||
.Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
||||
.GroupBy(u => u.ResultState)
|
||||
.OrderBy(u => u.Key)
|
||||
.ToList();
|
||||
|
||||
if (conditionList.Count == 0)
|
||||
if (result != null && result.IsSuccess)
|
||||
{
|
||||
|
||||
if (d.LabelName.ToLower() == "ok")
|
||||
detectResult.DetectDetails = result.ResultDetails;
|
||||
if (detectResult.DetectDetails != null)
|
||||
{
|
||||
d.FinalResult = d.InferenceResult = ResultState.OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
d.FinalResult = d.InferenceResult = ResultState.DetectNG;
|
||||
detectResult.IsMLDetectDone = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
#endregion
|
||||
#region 3.后处理
|
||||
#endregion
|
||||
//根据那些得分大于阈值的推理结果,判断产品是否成功
|
||||
#region 4.最终过滤(逻辑过滤)
|
||||
detectResult.DetectDetails?.ForEach(d =>
|
||||
{
|
||||
if (detectConfig.IsMixModel)
|
||||
|
||||
|
||||
//当前检测项的 过滤条件
|
||||
//var conditionList = detectConfig.DetectionFilterList
|
||||
// .Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
||||
// .GroupBy(u => u.ResultState)
|
||||
// .OrderBy(u => u.Key)
|
||||
// .ToList();
|
||||
//当前检测项的 过滤条件
|
||||
var conditionList = detectConfig.DetectionFilterList
|
||||
.Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
||||
.GroupBy(u => u.ResultState)
|
||||
.OrderBy(u => u.Key)
|
||||
.ToList();
|
||||
|
||||
if (conditionList.Count == 0)
|
||||
{
|
||||
d.FinalResult = d.InferenceResult = ResultState.A_NG;
|
||||
|
||||
d.FinalResult = d.LabelName.ToLower() == "ok"
|
||||
? ResultState.OK
|
||||
: ResultState.DetectNG;
|
||||
}
|
||||
else
|
||||
{
|
||||
//将所有已将筛选出来的缺陷进行过滤
|
||||
d.FinalResult = d.InferenceResult = ResultState.OK;
|
||||
d.FinalResult = detectConfig.IsMixModel
|
||||
? ResultState.A_NG
|
||||
: ResultState.OK;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
foreach (IGrouping<ResultState, DetectionFilter> group in conditionList)
|
||||
{
|
||||
bool b = group.ToList().Any(f =>
|
||||
foreach (IGrouping<ResultState, DetectionFilter> group in conditionList)
|
||||
{
|
||||
return f.FilterOperation(d);
|
||||
});
|
||||
//bool b = group.ToList().Any(f =>
|
||||
//{
|
||||
// return f.FilterOperation(d);
|
||||
//});
|
||||
|
||||
|
||||
if (b)
|
||||
{
|
||||
d.FinalResult = group.Key;
|
||||
break;
|
||||
//if (b)
|
||||
//{
|
||||
// d.FinalResult = group.Key;
|
||||
// break;
|
||||
//}
|
||||
|
||||
if (group.Any(f => f.FilterOperation(d)))
|
||||
{
|
||||
d.FinalResult = group.Key;
|
||||
break;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// d.FinalResult = d.InferenceResult = ResultState.OK;
|
||||
//}
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// d.FinalResult = d.InferenceResult = ResultState.OK;
|
||||
//}
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
#region 5.统计缺陷过滤结果或预处理直接NG
|
||||
if (detectResult.DetectDetails?.Count > 0)
|
||||
{
|
||||
detectResult.ResultState = detectResult.DetectDetails.GroupBy(u => u.FinalResult).OrderBy(u => u.Key).First().First().FinalResult;
|
||||
});
|
||||
#endregion
|
||||
#region 5.统计缺陷过滤结果或预处理直接NG
|
||||
//if (detectResult.DetectDetails?.Count > 0)
|
||||
//{
|
||||
// detectResult.ResultState = detectResult.DetectDetails.GroupBy(u => u.FinalResult).OrderBy(u => u.Key).First().First().FinalResult;
|
||||
// detectResult.ResultLabel = detectResult.ResultLabel;
|
||||
// detectResult.ResultLabelCategoryId = detectResult.ResultLabel;//TODO:设置优先级
|
||||
|
||||
|
||||
//}
|
||||
detectResult.ResultState = detectResult.DetectDetails?
|
||||
.GroupBy(u => u.FinalResult)
|
||||
.OrderBy(u => u.Key)
|
||||
.FirstOrDefault()?.Key ?? ResultState.OK;
|
||||
detectResult.ResultLabel = detectResult.ResultLabel;
|
||||
detectResult.ResultLabelCategoryId = detectResult.ResultLabel;//TODO:设置优先级
|
||||
//////根据优先级设置ResultLabel
|
||||
//if (detectionLabels.Count > 0)
|
||||
//{
|
||||
// foreach (var l in detectionLabels)
|
||||
// {
|
||||
// var isExist = DetectDetails.Any(o => NormalizeAndClean(o.LabelName) == NormalizeAndClean(l.LabelName) && o.FinalResult == ResultState.DetectNG);
|
||||
// if (isExist)
|
||||
// {
|
||||
|
||||
// ResultLabelCategoryId = l.LabelCategoryId;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
resultStates.Add(detectResult.ResultState);
|
||||
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
resultStates.Add(detectResult.ResultState);
|
||||
|
||||
product.ResultCollection.Add(detectResult);
|
||||
product.ResultCollection.Add(detectResult);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//DetectStationResult temp;
|
||||
////LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.4,产品{productNumber}");
|
||||
//// 检测结果
|
||||
//if (temp != null)
|
||||
//{
|
||||
// // LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.5,产品{productNumber}");
|
||||
// //var totalElapsed = (temp.EndTime - temp.VisionImageSet.ImageTime).TotalMilliseconds;
|
||||
// //totalTime += totalElapsed;
|
||||
// resultStates.Add(temp.ResultState);
|
||||
|
||||
// product.ResultCollection.Add(temp);
|
||||
// // LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.6,产品{productNumber}");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// //LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 检测失败,物料编号:{productNumber},检测项:{d}");
|
||||
//}
|
||||
|
||||
// imageSet.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -749,15 +741,9 @@ namespace DHSoftware
|
||||
}
|
||||
}
|
||||
|
||||
//detectionDict.ForEach(d =>
|
||||
//{
|
||||
|
||||
|
||||
//});
|
||||
|
||||
// LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度2,产品{productNumber}");
|
||||
|
||||
|
||||
imageSet.Dispose();
|
||||
|
||||
product.InferenceOne(() =>
|
||||
{
|
||||
;
|
||||
@ -767,7 +753,7 @@ namespace DHSoftware
|
||||
});
|
||||
|
||||
// LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理完成,产品{productNumber}");
|
||||
|
||||
|
||||
if (!product.InferenceFinished())
|
||||
{
|
||||
|
||||
@ -786,24 +772,12 @@ namespace DHSoftware
|
||||
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
||||
richTextBox1.ScrollToCaret();
|
||||
}));
|
||||
#region 6.统计产品结果
|
||||
if (product.ResultCollection.Any(u => u.ResultState != ResultState.OK))
|
||||
{
|
||||
//检测结果TBD
|
||||
// CurTrigger = TriggerSettings.FirstOrDefault(u => u.TriggerType == TriggerType.B_NG);
|
||||
product.ProductResult = ResultState.B_NG;
|
||||
product.ProductLabelCategory = ResultState.B_NG.GetEnumDescription();
|
||||
product.ProductLabel = ResultState.B_NG.GetEnumDescription();
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// CurTrigger = TriggerSettings.FirstOrDefault(u => u.TriggerType == TriggerType.OK);
|
||||
product.ProductResult = ResultState.OK;
|
||||
product.ProductLabelCategory = ResultState.OK.GetEnumDescription();
|
||||
product.ProductLabel = ResultState.OK.GetEnumDescription();
|
||||
}
|
||||
#region 6. 统计产品结果
|
||||
product.ProductResult = product.ResultCollection.Any(u => u.ResultState != ResultState.OK)
|
||||
? ResultState.B_NG
|
||||
: ResultState.OK;
|
||||
product.ProductLabelCategory = product.ProductResult.GetEnumDescription();
|
||||
product.ProductLabel = product.ProductResult.GetEnumDescription();
|
||||
#endregion
|
||||
#region 7.产品吹气
|
||||
|
||||
@ -811,110 +785,45 @@ namespace DHSoftware
|
||||
|
||||
|
||||
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"推理完成,产品{product.PieceNumber}获取结果");
|
||||
|
||||
// 统计产品结果
|
||||
//Task resultTask = product.SetProductResult(_totalDetectionNum, X017Config.IsTBDPriority, labelCategoryLists);
|
||||
|
||||
//await resultTask.ContinueWith(t =>
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// UpdateTriggerCount(DateTime.Now, "获取结果");
|
||||
// UpdateResult(DateTime.Now, camera, product.ProductResult.GetEnumDescription());
|
||||
// UpdateResultNew(DateTime.Now, camera, "合计");
|
||||
// LogAsync(DateTime.Now, LogLevel.Information, $"产品{product.PieceNumber}获取结果:{product.ProductResult} {(product.IsA2B ? "产品IsA2B" : "")}");
|
||||
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// LogAsync(DateTime.Now, LogLevel.Information, $"产品{product.PieceNumber}获取结果异常:{product.ProductResult} {(product.IsA2B ? "产品IsA2B" : "")}," +
|
||||
// $"异常信息:{ex.GetExceptionMessage}");
|
||||
|
||||
// }
|
||||
|
||||
// // 吹气
|
||||
// DateTime dtNow = DateTime.Now;
|
||||
// product.BlowOutTime = dtNow;
|
||||
|
||||
|
||||
// var setting = X017Config.ProductBlowSettings.FirstOrDefault(s => product.ProductResult.Equals(s.ProductResult));
|
||||
|
||||
// if (setting != null)
|
||||
// {
|
||||
// uint NGNumC = 0;
|
||||
// uint OKNumC = 0;
|
||||
|
||||
// CMCDLL_NET.MCF_Sorting_Get_Lose_Blow_NG_Count_Net(ref NGNumC, 0);
|
||||
// CMCDLL_NET.MCF_Sorting_Get_Lose_Blow_OK_Count_Net(ref OKNumC, 0);
|
||||
// _mainMotion.Blow(product.PieceNumber, setting.BindBlow);
|
||||
// LogAsync(DateTime.Now, LogLevel.Action, $"产品{product.PieceNumber}吹气{NGNumC}+ {OKNumC}");
|
||||
// //if (product.ProductResult == ResultState.OK)
|
||||
// //{
|
||||
// // //OKProcessNum++;
|
||||
// // OKNum++;
|
||||
// //}
|
||||
// }
|
||||
|
||||
// //判断超时出队
|
||||
// foreach (var kvp in tmpDic)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// ProductData dataN = kvp.Value;
|
||||
// TimeSpan timeDifference = DateTime.Now - dataN.CreateTime;
|
||||
// if (timeDifference.TotalMinutes >= 1)
|
||||
// {
|
||||
|
||||
// //出队
|
||||
// bool isremoved = tmpDic.TryRemove(kvp.Key, out _);
|
||||
// if (isremoved)
|
||||
// {
|
||||
// LogAsync(DateTime.Now, LogLevel.Error, $"====产品{kvp.Key}超时出列成功" +
|
||||
// $"产品结果:{dataN.ProductResult.GetEnumDescription()} {dataN.ProductResult}," +
|
||||
// $"当前队列产品数量:{tmpDic.Count}====");
|
||||
|
||||
// try
|
||||
// {
|
||||
// //重新生成实例 销毁之前的实例
|
||||
// var saveData = dataN.GetProductData();
|
||||
// var productDefects = dataN.GetDetectDetailData();
|
||||
// SaveProductDataAsync(saveData, productDefects);
|
||||
// dataN = null;
|
||||
// }
|
||||
// catch (Exception) { }
|
||||
|
||||
// dataN?.Dispose();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// LogAsync(DateTime.Now, LogLevel.Error, $"=====产品{kvp.Key}超时出列失败" +
|
||||
// $"当前队列产品数量:{tmpDic.Count}=====");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// LogAsync(DateTime.Now, LogLevel.Error, $"=====产品{kvp.Key}超时出列失败" +
|
||||
// $"当前队列产品数量:{tmpDic.Count}====={ex.GetExceptionMessage}");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// 出列
|
||||
ProductData temp = null;
|
||||
|
||||
int tryTimes = 5;
|
||||
int tryTimes = 10;
|
||||
while (temp == null && tryTimes > 0)
|
||||
{
|
||||
var isSuccess = tmpDic.Remove(productNumber, out temp);
|
||||
|
||||
if (isSuccess)
|
||||
if (tmpDic.TryRemove(productNumber, out temp))
|
||||
{
|
||||
string logStr = $"{DateTime.Now}产品{productNumber}出列成功:{isSuccess}," +
|
||||
$"产品结果:{temp.ProductResult.GetEnumDescription()}," +
|
||||
break;
|
||||
}
|
||||
|
||||
tryTimes--;
|
||||
Thread.Sleep(5);
|
||||
}
|
||||
if (temp == null)
|
||||
{
|
||||
string logStr = $"{DateTime.Now}产品{productNumber}出列失败:true,"+
|
||||
$"当前队列产品数量:{tmpDic.Count}";
|
||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
|
||||
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
||||
|
||||
richTextBox1.AppendText(logStr);
|
||||
|
||||
// 设置回原来的滚动位置
|
||||
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
||||
richTextBox1.ScrollToCaret();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
string logStr = $"{DateTime.Now}产品{productNumber}出列成功:true," +
|
||||
$"产品结果:{temp.ProductResult.GetEnumDescription()}," +
|
||||
$"当前队列产品数量:{tmpDic.Count}";
|
||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
|
||||
@ -926,22 +835,12 @@ namespace DHSoftware
|
||||
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
||||
richTextBox1.ScrollToCaret();
|
||||
}));
|
||||
}
|
||||
tryTimes--;
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
if (temp == null)
|
||||
{
|
||||
//LogAsync(DateTime.Now, LogLevel.Assist, $"产品{productNumber}出列失败," +
|
||||
// $"当前队列产品数量:{tmpDic.Count}");
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
//重新生成实例 销毁之前的实例
|
||||
var saveData = temp.GetProductData();
|
||||
|
||||
using(StreamWriter sw=new StreamWriter("D://123log.txt",true,Encoding.UTF8))
|
||||
{
|
||||
sw.WriteLine(logStr);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
Loading…
x
Reference in New Issue
Block a user