# 对专机2部6轴平台支持,修改HexalMC

This commit is contained in:
zhengxuan.zhang
2025-03-29 16:20:59 +08:00
parent 9f3ee84467
commit 6ad8cfcd14
37 changed files with 8287 additions and 8278 deletions
Binary file not shown.
Binary file not shown.
+2 -2
View File
@@ -12,5 +12,5 @@
#define HSI_VERSION_REVNUM #define HSI_VERSION_REVNUM
#define HSI_VERSION_BUILD_DATE _T(__DATE__ ) #define HSI_VERSION_BUILD_DATE _T(__DATE__ )
#define HSI_VERSION_BUILD_TIME _T(__TIME__ ) #define HSI_VERSION_BUILD_TIME _T(__TIME__ )
#define HSI_FILE_DESCRIPTION "2025.03.05 / 16:50 " #define HSI_FILE_DESCRIPTION "2025.03.11 / 17:19 "
#define HSI_FILE_CSDESCRIPTION _T("2025.03.05 / 16:50 ") #define HSI_FILE_CSDESCRIPTION _T("2025.03.11 / 17:19 ")
+129 -49
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Data; using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
@@ -10,9 +9,7 @@ using System.Net.NetworkInformation;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Net.NetworkInformation;
namespace HexcalMC.Base namespace HexcalMC.Base
{ {
@@ -21,6 +18,7 @@ namespace HexcalMC.Base
public class RichTextUnit public class RichTextUnit
{ {
public static float MSize = 16; public static float MSize = 16;
public static void SetFont(RichTextBox mRichTextBox, Color mColor, bool bBold = false, float size = 16) public static void SetFont(RichTextBox mRichTextBox, Color mColor, bool bBold = false, float size = 16)
{ {
mRichTextBox.SelectionColor = mColor; mRichTextBox.SelectionColor = mColor;
@@ -70,6 +68,7 @@ namespace HexcalMC.Base
RichTextUnit.SetFont(mRichTextBox, Color.DarkRed, false, size); RichTextUnit.SetFont(mRichTextBox, Color.DarkRed, false, size);
} }
break; break;
case '>': case '>':
{ {
RichTextUnit.SetFont(mRichTextBox, Color.Blue, false, size); RichTextUnit.SetFont(mRichTextBox, Color.Blue, false, size);
@@ -77,12 +76,14 @@ namespace HexcalMC.Base
RichTextUnit.SetFont(mRichTextBox, Color.Black, false, size); RichTextUnit.SetFont(mRichTextBox, Color.Black, false, size);
} }
break; break;
case '/': case '/':
{ {
RichTextUnit.SetFont(mRichTextBox, Color.Blue, false, size); RichTextUnit.SetFont(mRichTextBox, Color.Blue, false, size);
mRichTextBox.SelectedText = strText[i].ToString(); mRichTextBox.SelectedText = strText[i].ToString();
} }
break; break;
case '=': case '=':
{ {
if (strText[i + 1] == '"') if (strText[i + 1] == '"')
@@ -93,6 +94,7 @@ namespace HexcalMC.Base
} }
} }
break; break;
case '"': case '"':
{ {
RichTextUnit.SetFont(mRichTextBox, Color.Blue, false, size); RichTextUnit.SetFont(mRichTextBox, Color.Blue, false, size);
@@ -103,12 +105,14 @@ namespace HexcalMC.Base
RichTextUnit.SetFont(mRichTextBox, Color.DarkRed, false, size); RichTextUnit.SetFont(mRichTextBox, Color.DarkRed, false, size);
} }
break; break;
case '!': case '!':
{ {
RichTextUnit.SetFont(mRichTextBox, Color.Green, false, size); RichTextUnit.SetFont(mRichTextBox, Color.Green, false, size);
mRichTextBox.SelectedText = strText[i].ToString(); mRichTextBox.SelectedText = strText[i].ToString();
} }
break; break;
case '\r': case '\r':
{ {
if (strText[i + 1] == '\n') if (strText[i + 1] == '\n')
@@ -118,13 +122,14 @@ namespace HexcalMC.Base
} }
} }
break; break;
default: default:
mRichTextBox.SelectedText = strText[i].ToString(); mRichTextBox.SelectedText = strText[i].ToString();
break; break;
} }
} }
} }
#endregion #endregion PARSE THROUGH TEXT DATA
mRichTextBox.SelectedText = Environment.NewLine; mRichTextBox.SelectedText = Environment.NewLine;
})); }));
@@ -143,6 +148,7 @@ namespace HexcalMC.Base
RichTextUnit.SetFont(mRichTextBox, Color.Red, false, size); RichTextUnit.SetFont(mRichTextBox, Color.Red, false, size);
mRichTextBox.SelectedText = strText[i].ToString(); mRichTextBox.SelectedText = strText[i].ToString();
break; break;
case '0': case '0':
case '1': case '1':
case '2': case '2':
@@ -156,16 +162,18 @@ namespace HexcalMC.Base
RichTextUnit.SetFont(mRichTextBox, Color.DeepSkyBlue, false, size); RichTextUnit.SetFont(mRichTextBox, Color.DeepSkyBlue, false, size);
mRichTextBox.SelectedText = strText[i].ToString(); mRichTextBox.SelectedText = strText[i].ToString();
break; break;
default: default:
RichTextUnit.SetFont(mRichTextBox, Color.White, false, size); RichTextUnit.SetFont(mRichTextBox, Color.White, false, size);
mRichTextBox.SelectedText = strText[i].ToString(); mRichTextBox.SelectedText = strText[i].ToString();
break; break;
} }
} }
#endregion #endregion PARSE THROUGH TEXT DATA
})); }));
} }
} }
public class MyBase public class MyBase
{ {
#region #region
@@ -198,7 +206,7 @@ namespace HexcalMC.Base
} }
} }
#endregion #endregion
public static void KillSoftware(string strSoftwareName) public static void KillSoftware(string strSoftwareName)
{ {
@@ -316,8 +324,8 @@ namespace HexcalMC.Base
if (mColor == new Color()) if (mColor == new Color())
{ {
if (str.ToUpper().Contains("ERROR") || str.ToUpper().Contains("错误") || if (str.ToUpper().Contains("ERROR") || str.ToUpper().Contains("错误") ||
str.ToUpper().Contains("出错") || str.ToUpper().Contains("EXCEPTION") || str.ToUpper().Contains("出错") || str.ToUpper().Contains("EXCEPTION") ||
str.ToUpper().Contains("异常") || str.ToUpper().Contains("失败")) str.ToUpper().Contains("异常") || str.ToUpper().Contains("失败"))
{ {
setColor = Color.Red; setColor = Color.Red;
} }
@@ -353,7 +361,7 @@ namespace HexcalMC.Base
} }
/// <summary> /// <summary>
/// 写debug文件,记录程序过程 /// 写debug文件,记录程序过程
/// </summary> /// </summary>
/// <param name="str">要写入日志的内容</param> /// <param name="str">要写入日志的内容</param>
public static void TraceWriteLine(string str) public static void TraceWriteLine(string str)
@@ -369,7 +377,6 @@ namespace HexcalMC.Base
} }
} }
public static string InputBox(string caption, string hint, string defaultTxt, string btn1 = "OK", public static string InputBox(string caption, string hint, string defaultTxt, string btn1 = "OK",
string btn2 = "Cancel", char strstyle = '*', bool bShowData = false) string btn2 = "Cancel", char strstyle = '*', bool bShowData = false)
{ {
@@ -513,17 +520,17 @@ namespace HexcalMC.Base
[DllImport("User32.dll")] [DllImport("User32.dll")]
private static extern bool SetCursorPos(int x, int y); private static extern bool SetCursorPos(int x, int y);
static public void SetCursorPosXy(int dx, int dy) public static void SetCursorPosXy(int dx, int dy)
{ {
SetCursorPos(dx, dy); SetCursorPos(dx, dy);
} }
static public void SetCursorPosXy(Point point) public static void SetCursorPosXy(Point point)
{ {
System.Windows.Forms.Cursor.Position = point; System.Windows.Forms.Cursor.Position = point;
} }
#endregion #endregion
/// <summary> /// <summary>
/// CopyFiles 函数 /// CopyFiles 函数
@@ -563,7 +570,9 @@ namespace HexcalMC.Base
public class HardwareInfoBase public class HardwareInfoBase
{ {
/// <summary> 获取指定驱动器的空间总大小(单位为B) ,只需输入代表驱动器的字母即可 </summary> /// <summary>
/// 获取指定驱动器的空间总大小(单位为B) ,只需输入代表驱动器的字母即可
/// </summary>
public static long GetHardDiskSpace(string strHardDiskName) public static long GetHardDiskSpace(string strHardDiskName)
{ {
long totalSize = new long(); long totalSize = new long();
@@ -581,7 +590,9 @@ namespace HexcalMC.Base
return totalSize; return totalSize;
} }
/// <summary> 获取指定驱动器的剩余空间总大小(单位为B) ,只需输入代表驱动器的字母即可 </summary> /// <summary>
/// 获取指定驱动器的剩余空间总大小(单位为B) ,只需输入代表驱动器的字母即可
/// </summary>
public static long GetHardDiskFreeSpace(string strHardDiskName) public static long GetHardDiskFreeSpace(string strHardDiskName)
{ {
long freeSpace = new long(); long freeSpace = new long();
@@ -599,19 +610,25 @@ namespace HexcalMC.Base
return freeSpace; return freeSpace;
} }
/// <summary> 获取指定驱动器的剩余空间总大小(单位为K) ,只需输入代表驱动器的字母即可 </summary> /// <summary>
/// 获取指定驱动器的剩余空间总大小(单位为K) ,只需输入代表驱动器的字母即可
/// </summary>
public static long GetHardDiskFreeSpace_K(string strHardDiskName) public static long GetHardDiskFreeSpace_K(string strHardDiskName)
{ {
return GetHardDiskFreeSpace(strHardDiskName) / 1024; return GetHardDiskFreeSpace(strHardDiskName) / 1024;
} }
/// <summary> 获取指定驱动器的剩余空间总大小(单位为M) ,只需输入代表驱动器的字母即可 </summary> /// <summary>
/// 获取指定驱动器的剩余空间总大小(单位为M) ,只需输入代表驱动器的字母即可
/// </summary>
public static long GetHardDiskFreeSpace_M(string strHardDiskName) public static long GetHardDiskFreeSpace_M(string strHardDiskName)
{ {
return GetHardDiskFreeSpace_K(strHardDiskName) / 1024; return GetHardDiskFreeSpace_K(strHardDiskName) / 1024;
} }
/// <summary> 获取指定驱动器的剩余空间总大小(单位为G) ,只需输入代表驱动器的字母即可 </summary> /// <summary>
/// 获取指定驱动器的剩余空间总大小(单位为G) ,只需输入代表驱动器的字母即可
/// </summary>
public static long GetHardDiskFreeSpace_G(string strHardDiskName) public static long GetHardDiskFreeSpace_G(string strHardDiskName)
{ {
return GetHardDiskFreeSpace_M(strHardDiskName) / 1024; return GetHardDiskFreeSpace_M(strHardDiskName) / 1024;
@@ -644,7 +661,6 @@ namespace HexcalMC.Base
return false; return false;
} }
[DllImport("kernel32")] [DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal,
int size, string filePath); int size, string filePath);
@@ -744,7 +760,7 @@ namespace HexcalMC.Base
WritePrivateProfileString(section, key, strWrite, path); WritePrivateProfileString(section, key, strWrite, path);
} }
#endregion #endregion INI参数
//=====================//=====================//=====================Read data //=====================//=====================//=====================Read data
@@ -759,7 +775,7 @@ namespace HexcalMC.Base
/// <returns>要读取的string类型内容</returns> /// <returns>要读取的string类型内容</returns>
public static string ReadString(string path, string section, string key) public static string ReadString(string path, string section, string key)
{ {
// 每次从ini中读取多少字节 // section=配置节,key=键名,temp=上面,path=路径 // 每次从ini中读取多少字节 // section=配置节,key=键名,temp=上面,path=路径
System.Text.StringBuilder temp = new System.Text.StringBuilder(255); System.Text.StringBuilder temp = new System.Text.StringBuilder(255);
GetPrivateProfileString(section, key, "", temp, 255, path); GetPrivateProfileString(section, key, "", temp, 255, path);
String str = temp.ToString(); String str = temp.ToString();
@@ -814,10 +830,9 @@ namespace HexcalMC.Base
return false; return false;
} }
#endregion #endregion INI参数
} }
//==================================================================================================SoundBase //==================================================================================================SoundBase
/// <summary> /// <summary>
/// 声音播放类 /// 声音播放类
@@ -914,12 +929,11 @@ namespace HexcalMC.Base
} }
} }
//================================================================================================== //==================================================================================================
/// <summary> /// <summary>
/// 数据格式化或校验检测 /// 数据格式化或校验检测
/// </summary> /// </summary>
class FormatCheckBase internal class FormatCheckBase
{ {
/// <summary> /// <summary>
/// 检测是否为十六进制字符串,长度不够在前面添加0 /// 检测是否为十六进制字符串,长度不够在前面添加0
@@ -1125,7 +1139,7 @@ namespace HexcalMC.Base
#region #region
static readonly byte[] AuchCrcHi = new byte[] private static readonly byte[] AuchCrcHi = new byte[]
{ {
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
@@ -1161,7 +1175,7 @@ namespace HexcalMC.Base
#region #region
static readonly byte[] AuchCrcLo = new byte[] private static readonly byte[] AuchCrcLo = new byte[]
{ {
0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06,
0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD,
@@ -1218,19 +1232,18 @@ namespace HexcalMC.Base
} }
} }
//==================================================================================================ConvertBase //==================================================================================================ConvertBase
/// <summary> /// <summary>
/// 数据转换类 /// 数据转换类
/// </summary> /// </summary>
class ConvertBase internal class ConvertBase
{ {
#region <--> #region <-->
/// <summary> /// <summary>
/// 图像转换为Byte数组 /// 图像转换为Byte数组
/// </summary> /// </summary>
static public byte[] ImageToByteArray(Image imageIn) public static byte[] ImageToByteArray(Image imageIn)
{ {
MemoryStream ms = new MemoryStream(); MemoryStream ms = new MemoryStream();
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Png); imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
@@ -1240,7 +1253,7 @@ namespace HexcalMC.Base
/// <summary> /// <summary>
/// Byte数组转换为图像 /// Byte数组转换为图像
/// </summary> /// </summary>
static public Image ByteArrayToImage(byte[] byteArrayIn) public static Image ByteArrayToImage(byte[] byteArrayIn)
{ {
MemoryStream ms = new MemoryStream(byteArrayIn); MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms); Image returnImage = Image.FromStream(ms);
@@ -1442,9 +1455,9 @@ namespace HexcalMC.Base
for (int i = 0; i < str.Length; i++) for (int i = 0; i < str.Length; i++)
{ {
if (! if (!
(((str[i] >= '0') && (str[i] <= '9')) || (((str[i] >= '0') && (str[i] <= '9')) ||
((str[i] >= 'a') && (str[i] <= 'f')) || ((str[i] >= 'a') && (str[i] <= 'f')) ||
((str[i] >= 'A') && (str[i] <= 'F'))) ((str[i] >= 'A') && (str[i] <= 'F')))
) )
{ {
return false; return false;
@@ -1772,21 +1785,27 @@ namespace HexcalMC.Base
case 10: case 10:
x = "A"; x = "A";
break; break;
case 11: case 11:
x = "B"; x = "B";
break; break;
case 12: case 12:
x = "C"; x = "C";
break; break;
case 13: case 13:
x = "D"; x = "D";
break; break;
case 14: case 14:
x = "E"; x = "E";
break; break;
case 15: case 15:
x = "F"; x = "F";
break; break;
default: default:
x = d.ToString(); x = d.ToString();
break; break;
@@ -1807,12 +1826,11 @@ namespace HexcalMC.Base
} }
} }
//==================================================================================================TcpBase //==================================================================================================TcpBase
/// <summary> /// <summary>
/// 网络通讯通用类函数库 /// 网络通讯通用类函数库
/// </summary> /// </summary>
class TcpBase internal class TcpBase
{ {
/// <summary> /// <summary>
/// 用CMD命令测试网络连接状态 /// 用CMD命令测试网络连接状态
@@ -1851,12 +1869,11 @@ namespace HexcalMC.Base
} }
} }
//==================================================================================================MyMath //==================================================================================================MyMath
/// <summary> /// <summary>
/// 数学函数库(算法) /// 数学函数库(算法)
/// </summary> /// </summary>
class MyMath internal class MyMath
{ {
public static double GetMax(double[] datas) public static double GetMax(double[] datas)
{ {
@@ -1981,36 +1998,52 @@ namespace HexcalMC.Base
{ {
case 0: case 0:
return (data & 0x0001) > 0; return (data & 0x0001) > 0;
case 1: case 1:
return (data & 0x0002) > 0; return (data & 0x0002) > 0;
case 2: case 2:
return (data & 0x0004) > 0; return (data & 0x0004) > 0;
case 3: case 3:
return (data & 0x0008) > 0; return (data & 0x0008) > 0;
case 4: case 4:
return (data & 0x0010) > 0; return (data & 0x0010) > 0;
case 5: case 5:
return (data & 0x0020) > 0; return (data & 0x0020) > 0;
case 6: case 6:
return (data & 0x0040) > 0; return (data & 0x0040) > 0;
case 7: case 7:
return (data & 0x0080) > 0; return (data & 0x0080) > 0;
case 8: case 8:
return (data & 0x0100) > 0; return (data & 0x0100) > 0;
case 9: case 9:
return (data & 0x0200) > 0; return (data & 0x0200) > 0;
case 10: case 10:
return (data & 0x0400) > 0; return (data & 0x0400) > 0;
case 11: case 11:
return (data & 0x0800) > 0; return (data & 0x0800) > 0;
case 12: case 12:
return (data & 0x1000) > 0; return (data & 0x1000) > 0;
case 13: case 13:
return (data & 0x2000) > 0; return (data & 0x2000) > 0;
case 14: case 14:
return (data & 0x4000) > 0; return (data & 0x4000) > 0;
case 15: case 15:
return (data & 0x8000) > 0; return (data & 0x8000) > 0;
default: default:
return false; return false;
} }
@@ -2022,37 +2055,52 @@ namespace HexcalMC.Base
{ {
case 0: case 0:
return (data & 0x0100) > 0; return (data & 0x0100) > 0;
case 1: case 1:
return (data & 0x0200) > 0; return (data & 0x0200) > 0;
case 2: case 2:
return (data & 0x0400) > 0; return (data & 0x0400) > 0;
case 3: case 3:
return (data & 0x0800) > 0; return (data & 0x0800) > 0;
case 4: case 4:
return (data & 0x1000) > 0; return (data & 0x1000) > 0;
case 5: case 5:
return (data & 0x2000) > 0; return (data & 0x2000) > 0;
case 6: case 6:
return (data & 0x4000) > 0; return (data & 0x4000) > 0;
case 7: case 7:
return (data & 0x8000) > 0; return (data & 0x8000) > 0;
case 8: case 8:
return (data & 0x0001) > 0; return (data & 0x0001) > 0;
case 9: case 9:
return (data & 0x0002) > 0; return (data & 0x0002) > 0;
case 10: case 10:
return (data & 0x0004) > 0; return (data & 0x0004) > 0;
case 11: case 11:
return (data & 0x0008) > 0; return (data & 0x0008) > 0;
case 12: case 12:
return (data & 0x0010) > 0; return (data & 0x0010) > 0;
case 13: case 13:
return (data & 0x0020) > 0; return (data & 0x0020) > 0;
case 14: case 14:
return (data & 0x0040) > 0; return (data & 0x0040) > 0;
case 15: case 15:
return (data & 0x0080) > 0; return (data & 0x0080) > 0;
default: default:
return false; return false;
} }
@@ -2077,7 +2125,6 @@ namespace HexcalMC.Base
return bResult; return bResult;
} }
/// <summary> /// <summary>
/// 获取单精度浮点数(float)数据 /// 获取单精度浮点数(float)数据
/// </summary> /// </summary>
@@ -2187,6 +2234,7 @@ namespace HexcalMC.Base
} }
break; break;
case 10: case 10:
foreach (byte b in arrLength) foreach (byte b in arrLength)
{ {
@@ -2194,6 +2242,7 @@ namespace HexcalMC.Base
} }
break; break;
case 16: case 16:
foreach (byte b in arrLength) foreach (byte b in arrLength)
{ {
@@ -2220,7 +2269,6 @@ namespace HexcalMC.Base
} }
} }
//====================================================================== //======================================================================
/// <summary> /// <summary>
/// 字节数组(byte 8位)转化为ushort(16位)数组 /// 字节数组(byte 8位)转化为ushort(16位)数组
@@ -2282,7 +2330,6 @@ namespace HexcalMC.Base
return ushorts; return ushorts;
} }
//====================================================================== //======================================================================
/// <summary> /// <summary>
/// 字节数组(byte 8位)转化为short(16位)数组 /// 字节数组(byte 8位)转化为short(16位)数组
@@ -2355,13 +2402,13 @@ namespace HexcalMC.Base
} }
} }
class CodeDfn internal class CodeDfn
{ {
public const string BlankSpace = " "; public const string BlankSpace = " ";
public const string StrEnter = "\r\n"; public const string StrEnter = "\r\n";
} }
class PlcMath internal class PlcMath
{ {
#region S7协议数据处理 #region S7协议数据处理
@@ -2412,7 +2459,7 @@ namespace HexcalMC.Base
if (byteData.Length < (dataAddr - startAddr)) if (byteData.Length < (dataAddr - startAddr))
{ {
MessageBox.Show("错误:获取S7字节数据, 要读取的偏移地址超出数组长度,偏移=" + (dataAddr - startAddr) + ", 数组长度=" + MessageBox.Show("错误:获取S7字节数据, 要读取的偏移地址超出数组长度,偏移=" + (dataAddr - startAddr) + ", 数组长度=" +
byteData.Length); byteData.Length);
return 0; return 0;
} }
else else
@@ -2547,6 +2594,7 @@ namespace HexcalMC.Base
} }
break; break;
case 10: case 10:
foreach (byte b in arrLength) foreach (byte b in arrLength)
{ {
@@ -2554,6 +2602,7 @@ namespace HexcalMC.Base
} }
break; break;
case 16: case 16:
foreach (byte b in arrLength) foreach (byte b in arrLength)
{ {
@@ -2561,6 +2610,7 @@ namespace HexcalMC.Base
} }
break; break;
default: default:
foreach (byte b in arrLength) foreach (byte b in arrLength)
{ {
@@ -2582,7 +2632,6 @@ namespace HexcalMC.Base
#endregion #endregion
#region ModbusTCP/FinsTCP协议数据处理 #region ModbusTCP/FinsTCP协议数据处理
/// <summary> /// <summary>
@@ -2708,36 +2757,52 @@ namespace HexcalMC.Base
{ {
case 0: case 0:
return (data & 0x0001) > 0; return (data & 0x0001) > 0;
case 1: case 1:
return (data & 0x0002) > 0; return (data & 0x0002) > 0;
case 2: case 2:
return (data & 0x0004) > 0; return (data & 0x0004) > 0;
case 3: case 3:
return (data & 0x0008) > 0; return (data & 0x0008) > 0;
case 4: case 4:
return (data & 0x0010) > 0; return (data & 0x0010) > 0;
case 5: case 5:
return (data & 0x0020) > 0; return (data & 0x0020) > 0;
case 6: case 6:
return (data & 0x0040) > 0; return (data & 0x0040) > 0;
case 7: case 7:
return (data & 0x0080) > 0; return (data & 0x0080) > 0;
case 8: case 8:
return (data & 0x0100) > 0; return (data & 0x0100) > 0;
case 9: case 9:
return (data & 0x0200) > 0; return (data & 0x0200) > 0;
case 10: case 10:
return (data & 0x0400) > 0; return (data & 0x0400) > 0;
case 11: case 11:
return (data & 0x0800) > 0; return (data & 0x0800) > 0;
case 12: case 12:
return (data & 0x1000) > 0; return (data & 0x1000) > 0;
case 13: case 13:
return (data & 0x2000) > 0; return (data & 0x2000) > 0;
case 14: case 14:
return (data & 0x4000) > 0; return (data & 0x4000) > 0;
case 15: case 15:
return (data & 0x8000) > 0; return (data & 0x8000) > 0;
default: default:
return false; return false;
} }
@@ -2749,37 +2814,52 @@ namespace HexcalMC.Base
{ {
case 0: case 0:
return (data & 0x0100) > 0; return (data & 0x0100) > 0;
case 1: case 1:
return (data & 0x0200) > 0; return (data & 0x0200) > 0;
case 2: case 2:
return (data & 0x0400) > 0; return (data & 0x0400) > 0;
case 3: case 3:
return (data & 0x0800) > 0; return (data & 0x0800) > 0;
case 4: case 4:
return (data & 0x1000) > 0; return (data & 0x1000) > 0;
case 5: case 5:
return (data & 0x2000) > 0; return (data & 0x2000) > 0;
case 6: case 6:
return (data & 0x4000) > 0; return (data & 0x4000) > 0;
case 7: case 7:
return (data & 0x8000) > 0; return (data & 0x8000) > 0;
case 8: case 8:
return (data & 0x0001) > 0; return (data & 0x0001) > 0;
case 9: case 9:
return (data & 0x0002) > 0; return (data & 0x0002) > 0;
case 10: case 10:
return (data & 0x0004) > 0; return (data & 0x0004) > 0;
case 11: case 11:
return (data & 0x0008) > 0; return (data & 0x0008) > 0;
case 12: case 12:
return (data & 0x0010) > 0; return (data & 0x0010) > 0;
case 13: case 13:
return (data & 0x0020) > 0; return (data & 0x0020) > 0;
case 14: case 14:
return (data & 0x0040) > 0; return (data & 0x0040) > 0;
case 15: case 15:
return (data & 0x0080) > 0; return (data & 0x0080) > 0;
default: default:
return false; return false;
} }
@@ -2913,6 +2993,7 @@ namespace HexcalMC.Base
} }
break; break;
case 10: case 10:
foreach (byte b in arrLength) foreach (byte b in arrLength)
{ {
@@ -2920,6 +3001,7 @@ namespace HexcalMC.Base
} }
break; break;
case 16: case 16:
foreach (byte b in arrLength) foreach (byte b in arrLength)
{ {
@@ -2927,6 +3009,7 @@ namespace HexcalMC.Base
} }
break; break;
default: default:
foreach (byte b in arrLength) foreach (byte b in arrLength)
{ {
@@ -2949,11 +3032,8 @@ namespace HexcalMC.Base
#endregion #endregion
} }
internal class Internet
class Internet
{ {
public static bool IsIpReachable(string ipAddress) public static bool IsIpReachable(string ipAddress)
{ {
try try
+8 -18
View File
@@ -1,11 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace HexcalMC.Base namespace HexcalMC.Base
@@ -20,7 +16,6 @@ namespace HexcalMC.Base
public static RichTextBox textBox_Msg; public static RichTextBox textBox_Msg;
//================================================================= //=================================================================
public static void StartDebugObj() public static void StartDebugObj()
{ {
@@ -122,26 +117,21 @@ namespace HexcalMC.Base
} }
} }
#endregion #endregion
} }
public class Errors public class Errors
{ {
/// <summary> /// <summary>
/// 0:无故障 PLC按位求 1对应101 /// 0:无故障 PLC按位求 1对应101 1:通讯故障 2:扫描枪读取故障
/// 1:通讯故障 /// 3: 控制柜急停被按下 4:外部急停被按下 5:PCL急停,辊道在CMM测量时上料
/// 2:扫描枪读取故障
/// 3: 控制柜急停被按下
/// 4:外部急停被按下
/// 5:PCL急停,辊道在CMM测量时上料
/// </summary> /// </summary>
public static int iErrors = 0; public static int iErrors = 0;
/// 101:通讯故障
/// 102:扫描枪读取故障 /// 101:通讯故障 102:扫描枪读取故障
/// 103: 控制柜急停被按下 /// 103: 控制柜急停被按下 104:外部急停被按下 105:PCL急停,辊道在CMM测量时上料
/// 104:外部急停被按下
/// 105:PCL急停,辊道在CMM测量时上料
public static bool bCommError = false; public static bool bCommError = false;
public static bool bReaderError = false; public static bool bReaderError = false;
public static bool bEStop_Controller = false; public static bool bEStop_Controller = false;
public static bool bEStop_Out = false; public static bool bEStop_Out = false;
@@ -158,7 +148,7 @@ namespace HexcalMC.Base
try try
{ {
if (Errors.ErrorWrite == null) if (Errors.ErrorWrite == null)
Errors.ErrorWrite = new StreamWriter(DebugDfn.StrDebugSavePath + "Error_(" + DateTime.Now.ToString("yyyy-MM-dd") + ").txt", true); Errors.ErrorWrite = new StreamWriter(DebugDfn.StrDebugSavePath + "Error_(" + DateTime.Now.ToString("yyyy-MM-dd") + ").txt", true);
Errors.ErrorWrite.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + strError); Errors.ErrorWrite.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + strError);
Errors.ErrorWrite.Flush(); Errors.ErrorWrite.Flush();
} }
File diff suppressed because it is too large Load Diff
+88 -91
View File
@@ -1,115 +1,112 @@
/*****************************************************************************
/*****************************************************************************
This class has been written by Łukasz Światkowski This class has been written by Łukasz Światkowski
Cleaned up spaghetti code and improved by Elmü (elmue@gmx.de) Cleaned up spaghetti code and improved by Elmü (elmue@gmx.de)
*****************************************************************************/ *****************************************************************************/
using Microsoft.CSharp;
using System; using System;
using System.CodeDom.Compiler; using System.CodeDom.Compiler;
using System.Reflection; using System.Reflection;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using Microsoft.CSharp;
using delRendererFunction = Plot3D.Editor3D.delRendererFunction; using delRendererFunction = Plot3D.Editor3D.delRendererFunction;
namespace Plot3D namespace Plot3D
{ {
public delegate double delCompiledFunction(params double[] x); public delegate double delCompiledFunction(params double[] x);
public static class FunctionCompiler public static class FunctionCompiler
{ {
const String EVAL_CLASS = private const String EVAL_CLASS =
"using {1};\n" "using {1};\n"
+ "public class Eval\n" + "public class Eval\n"
+ "{{\n" + "{{\n"
+ " public static double e {{ get {{ return System.Math.E; }} }}\n" + " public static double e {{ get {{ return System.Math.E; }} }}\n"
+ " public static double pi {{ get {{ return System.Math.PI; }} }}\n" + " public static double pi {{ get {{ return System.Math.PI; }} }}\n"
// ------------------------------------------------------- // -------------------------------------------------------
+ " public static double abs (double x) {{ return System.Math.Abs(x); }}\n" + " public static double abs (double x) {{ return System.Math.Abs(x); }}\n"
+ " public static double acos (double x) {{ return System.Math.Acos(x); }}\n" + " public static double acos (double x) {{ return System.Math.Acos(x); }}\n"
+ " public static double asin (double x) {{ return System.Math.Asin(x); }}\n" + " public static double asin (double x) {{ return System.Math.Asin(x); }}\n"
+ " public static double atan (double x) {{ return System.Math.Atan(x); }}\n" + " public static double atan (double x) {{ return System.Math.Atan(x); }}\n"
+ " public static double atan2(double x, double y) {{ return System.Math.Atan2(x, y); }}\n" + " public static double atan2(double x, double y) {{ return System.Math.Atan2(x, y); }}\n"
+ " public static double ceil (double x) {{ return System.Math.Ceiling(x); }}\n" + " public static double ceil (double x) {{ return System.Math.Ceiling(x); }}\n"
+ " public static double cos (double x) {{ return System.Math.Cos(x); }}\n" + " public static double cos (double x) {{ return System.Math.Cos(x); }}\n"
+ " public static double cosh (double x) {{ return System.Math.Cosh(x); }}\n" + " public static double cosh (double x) {{ return System.Math.Cosh(x); }}\n"
+ " public static double exp (double x) {{ return System.Math.Exp(x); }}\n" + " public static double exp (double x) {{ return System.Math.Exp(x); }}\n"
+ " public static double floor(double x) {{ return System.Math.Floor(x); }}\n" + " public static double floor(double x) {{ return System.Math.Floor(x); }}\n"
+ " public static double log (double x) {{ return System.Math.Log(x); }}\n" + " public static double log (double x) {{ return System.Math.Log(x); }}\n"
+ " public static double log2 (double x) {{ return System.Math.Log(x, 2.0); }}\n" + " public static double log2 (double x) {{ return System.Math.Log(x, 2.0); }}\n"
+ " public static double log10(double x) {{ return System.Math.Log10(x); }}\n" + " public static double log10(double x) {{ return System.Math.Log10(x); }}\n"
+ " public static double max (double x, double y) {{ return System.Math.Max(x, y); }}\n" + " public static double max (double x, double y) {{ return System.Math.Max(x, y); }}\n"
+ " public static double min (double x, double y) {{ return System.Math.Min(x, y); }}\n" + " public static double min (double x, double y) {{ return System.Math.Min(x, y); }}\n"
+ " public static double pow (double x, double y) {{ return System.Math.Pow(x, y); }}\n" + " public static double pow (double x, double y) {{ return System.Math.Pow(x, y); }}\n"
+ " public static double round(double x) {{ return System.Math.Round(x); }}\n" + " public static double round(double x) {{ return System.Math.Round(x); }}\n"
+ " public static double sign (double x) {{ return System.Math.Sign(x); }}\n" + " public static double sign (double x) {{ return System.Math.Sign(x); }}\n"
+ " public static double sin (double x) {{ return System.Math.Sin(x); }}\n" + " public static double sin (double x) {{ return System.Math.Sin(x); }}\n"
+ " public static double sinh (double x) {{ return System.Math.Sinh(x); }}\n" + " public static double sinh (double x) {{ return System.Math.Sinh(x); }}\n"
+ " public static double sqrt (double x) {{ return System.Math.Sqrt(x); }}\n" + " public static double sqrt (double x) {{ return System.Math.Sqrt(x); }}\n"
+ " public static double tan (double x) {{ return System.Math.Tan(x); }}\n" + " public static double tan (double x) {{ return System.Math.Tan(x); }}\n"
+ " public static double tanh (double x) {{ return System.Math.Tanh(x); }}\n" + " public static double tanh (double x) {{ return System.Math.Tanh(x); }}\n"
// ------------------------------------------------------- // -------------------------------------------------------
+ " public static double __eval(params double[] __X)\n" + " public static double __eval(params double[] __X)\n"
+ " {{\n" + " {{\n"
+ " double x = __X[0];\n" + " double x = __X[0];\n"
+ " double y = __X[1];\n" + " double y = __X[1];\n"
+ " return {0};\n" + " return {0};\n"
+ " }}\n" + " }}\n"
+ " public static {2} __get()\n" + " public static {2} __get()\n"
+ " {{\n" + " {{\n"
+ " return __eval;\n" + " return __eval;\n"
+ " }}\n" + " }}\n"
+ "}}"; + "}}";
public static delRendererFunction Compile(string functionBody) public static delRendererFunction Compile(string functionBody)
{ {
functionBody = functionBody.Trim().ToLower(); functionBody = functionBody.Trim().ToLower();
if (functionBody.Contains(";")) if (functionBody.Contains(";"))
throw new Exception("Function string cannot contain semicolon"); throw new Exception("Function string cannot contain semicolon");
string s_Class = string.Format(EVAL_CLASS, functionBody, typeof(delCompiledFunction).Namespace, typeof(delCompiledFunction).Name); string s_Class = string.Format(EVAL_CLASS, functionBody, typeof(delCompiledFunction).Namespace, typeof(delCompiledFunction).Name);
CSharpCodeProvider i_Provider = new CSharpCodeProvider(); CSharpCodeProvider i_Provider = new CSharpCodeProvider();
CompilerParameters i_Params = new CompilerParameters(); CompilerParameters i_Params = new CompilerParameters();
i_Params.CompilerOptions = "/t:library"; i_Params.CompilerOptions = "/t:library";
i_Params.GenerateInMemory = true; i_Params.GenerateInMemory = true;
i_Params.ReferencedAssemblies.Add("mscorlib.dll"); i_Params.ReferencedAssemblies.Add("mscorlib.dll");
i_Params.ReferencedAssemblies.Add("System.dll"); i_Params.ReferencedAssemblies.Add("System.dll");
i_Params.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location); i_Params.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);
CompilerResults i_Result = i_Provider.CompileAssemblyFromSource(i_Params, s_Class); CompilerResults i_Result = i_Provider.CompileAssemblyFromSource(i_Params, s_Class);
if (i_Result.Errors.HasErrors) if (i_Result.Errors.HasErrors)
{ {
StringBuilder s_Error = new StringBuilder(); StringBuilder s_Error = new StringBuilder();
if (i_Result.Errors.Count == 1) if (i_Result.Errors.Count == 1)
s_Error.Append("Compilation error:\n"); s_Error.Append("Compilation error:\n");
else else
s_Error.AppendFormat("{0} Compilation errors:\n", i_Result.Errors.Count); s_Error.AppendFormat("{0} Compilation errors:\n", i_Result.Errors.Count);
foreach (CompilerError i_Error in i_Result.Errors) foreach (CompilerError i_Error in i_Result.Errors)
{ {
s_Error.Append(i_Error.ErrorText); s_Error.Append(i_Error.ErrorText);
s_Error.Append("\n"); s_Error.Append("\n");
} }
s_Error.Append("\nSupported math functions are:\n" s_Error.Append("\nSupported math functions are:\n"
+ "e, pi, abs(), acos(), asin(), atan(), atan2(), ceil(), cos(), cosh(), " + "e, pi, abs(), acos(), asin(), atan(), atan2(), ceil(), cos(), cosh(), "
+ "exp(), floor(), log(), log2(), log10(), max(), min(), pow(), " + "exp(), floor(), log(), log2(), log10(), max(), min(), pow(), "
+ "round(), sign(), sin(), sinh(), sqrt(), tan(), tanh()\n"); + "round(), sign(), sin(), sinh(), sqrt(), tan(), tanh()\n");
throw new Exception(s_Error.ToString()); throw new Exception(s_Error.ToString());
} }
MethodInfo i_Method = i_Result.CompiledAssembly.GetType("Eval").GetMethod("__get"); MethodInfo i_Method = i_Result.CompiledAssembly.GetType("Eval").GetMethod("__get");
delCompiledFunction f_Compiled = (delCompiledFunction)i_Method.Invoke(null, null); delCompiledFunction f_Compiled = (delCompiledFunction)i_Method.Invoke(null, null);
delRendererFunction f_Render = delegate(double X, double Y) delRendererFunction f_Render = delegate (double X, double Y)
{ {
return f_Compiled(X, Y); return f_Compiled(X, Y);
}; };
return f_Render; return f_Render;
} }
} }
} }
+147 -150
View File
@@ -1,31 +1,24 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace HexcalMC namespace HexcalMC
{ {
public partial class Lamp : UserControl public partial class Lamp : UserControl
{ {
public Lamp() public Lamp()
{ {
InitializeComponent(); InitializeComponent();
base.SetStyle(ControlStyles.ResizeRedraw, true); base.SetStyle(ControlStyles.ResizeRedraw, true);
this.DoubleBuffered = true; this.DoubleBuffered = true;
} }
private void Lamp_Load(object sender, EventArgs e) private void Lamp_Load(object sender, EventArgs e)
{ {
}
} private static Color[] _colors = new Color[]
private static Color[] _colors = new Color[]
{ {
Color.Green, Color.Green,
Color.Orange, Color.Orange,
@@ -37,147 +30,151 @@ namespace HexcalMC
Color.Blue Color.Blue
}; };
private const int Ok = 0; private const int Ok = 0;
private const int Warn = 1; private const int Warn = 1;
private const int Error = 2; private const int Error = 2;
private const int Debug = 4; private const int Debug = 4;
private const int Undef = -1; private const int Undef = -1;
private int _state = -1; private int _state = -1;
private string _dtext = "";
private bool _shadow = false;
private string _dtext = ""; /// <summary>
private bool _shadow = false; /// 设置颜色
/// </summary>
public int State
{
get
{
return this._state;
}
set
{
this._state = value;
this.Refresh();
}
}
/// <summary> 设置颜色 </summary> /// <summary>
public int State /// 设置文字
{ /// </summary>
get public string LText
{ {
return this._state; get
} {
set return this._dtext;
{ }
this._state = value; set
this.Refresh(); {
} this._dtext = value;
} }
}
/// <summary> 设置文字 </summary> /// <summary>
public string LText /// 设置阴影
{ /// </summary>
get public bool Shadow
{ {
return this._dtext; get
} {
set return this._shadow;
{ }
this._dtext = value; set
} {
} this._shadow = value;
}
}
/// <summary> 设置阴影 </summary> protected override void OnPaint(PaintEventArgs gr)
public bool Shadow {
{ base.OnPaint(gr);
get int num = Math.Min(base.Width, base.Height);
{ bool flag = num >= 8;
return this._shadow; if (flag)
} {
set this.DrawLamp(gr.Graphics, num);
{ }
this._shadow = value; }
}
}
protected override void OnPaint(PaintEventArgs gr) private void DrawLamp(Graphics g, int rad)
{ {
base.OnPaint(gr); g.SmoothingMode = SmoothingMode.AntiAlias;
int num = Math.Min(base.Width, base.Height); RectangleF rect = new RectangleF(1f, 1f, (float)(rad - 5), (float)(rad - 5));
bool flag = num >= 8; float num = rect.Width / 12f;
if (flag) RectangleF rect2 = new RectangleF(rect.Location, rect.Size);
{ rect2.Inflate(1f, 1f);
this.DrawLamp(gr.Graphics, num); if (_shadow)
} {
} rect2.X += num;
rect2.Y += num;
g.FillEllipse(Brushes.Gray, rect2);
rect2.X -= num;
rect2.Y -= num;
}
g.FillEllipse(Brushes.Black, rect2);
private void DrawLamp(Graphics g, int rad) if (_state != -1)
{ {
g.SmoothingMode = SmoothingMode.AntiAlias; using (GraphicsPath graphicsPath = new GraphicsPath())
RectangleF rect = new RectangleF(1f, 1f, (float)(rad - 5), (float)(rad - 5)); {
float num = rect.Width / 12f; graphicsPath.AddEllipse(rect);
RectangleF rect2 = new RectangleF(rect.Location, rect.Size); int x = (int)(rect.X + rect.Width / 3f);
rect2.Inflate(1f, 1f); int y = (int)(rect.Y + rect.Height / 3f);
if (_shadow) Color color = Lamp._colors[_state];
{ using (PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath))
rect2.X += num; {
rect2.Y += num; pathGradientBrush.CenterColor = Color.Snow;
g.FillEllipse(Brushes.Gray, rect2); pathGradientBrush.CenterPoint = new Point(x, y);
rect2.X -= num; pathGradientBrush.SurroundColors = new Color[]
rect2.Y -= num;
}
g.FillEllipse(Brushes.Black, rect2);
if (_state != -1)
{
using (GraphicsPath graphicsPath = new GraphicsPath())
{
graphicsPath.AddEllipse(rect);
int x = (int)(rect.X + rect.Width / 3f);
int y = (int)(rect.Y + rect.Height / 3f);
Color color = Lamp._colors[_state];
using (PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath))
{
pathGradientBrush.CenterColor = Color.Snow;
pathGradientBrush.CenterPoint = new Point(x, y);
pathGradientBrush.SurroundColors = new Color[]
{ {
color color
}; };
g.FillPath(pathGradientBrush, graphicsPath); g.FillPath(pathGradientBrush, graphicsPath);
} }
} }
} }
else else
{ {
using (Brush brush = new SolidBrush(this.BackColor)) using (Brush brush = new SolidBrush(this.BackColor))
{ {
g.FillEllipse(brush, rect); g.FillEllipse(brush, rect);
} }
} }
if (_dtext.Length > 0) if (_dtext.Length > 0)
{ {
float emSize = rect.Height / 6f; float emSize = rect.Height / 6f;
Font font = new Font("Microsoft Sans Serif", emSize, FontStyle.Bold, GraphicsUnit.Point, 0); Font font = new Font("Microsoft Sans Serif", emSize, FontStyle.Bold, GraphicsUnit.Point, 0);
int num2 = (int)font.GetHeight(); int num2 = (int)font.GetHeight();
int y2 = (int)rect.Height / 2 - num2 / 2; int y2 = (int)rect.Height / 2 - num2 / 2;
int num3 = (int)g.MeasureString(_dtext, font).Width; int num3 = (int)g.MeasureString(_dtext, font).Width;
int num4 = (int)(rect.Width - (float)num3) / 2; int num4 = (int)(rect.Width - (float)num3) / 2;
bool flag3 = num4 < 0; bool flag3 = num4 < 0;
if (flag3) if (flag3)
{ {
num4 = 0; num4 = 0;
} }
g.DrawString(_dtext, font, Brushes.Black, new Point(num4, y2)); g.DrawString(_dtext, font, Brushes.Black, new Point(num4, y2));
} }
} }
}
} public class LampColor
{
public const int Ok = 0;
public const int Warn = 1;
public const int Error = 2;
public const int Debug = 4;
public const int Undef = -1;
public class LampColor public const int Green = 0;
{ public const int Orange = 1;
public const int Ok = 0; public const int Red = 2;
public const int Warn = 1; public const int White = 3;
public const int Error = 2; public const int Silver = 4;
public const int Debug = 4; public const int Transparent = 5;
public const int Undef = -1; public const int Yellow = 6;
public const int Blue = 7;
public const int Green = 0; }
public const int Orange = 1;
public const int Red = 2;
public const int White = 3;
public const int Silver = 4;
public const int Transparent = 5;
public const int Yellow = 6;
public const int Blue = 7;
}
} }
+85 -90
View File
@@ -1,105 +1,100 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Scatter namespace Scatter
{ {
static class Algerbra internal static class Algerbra
{ {
public class Matrix<T> public class Matrix<T>
{ {
int rows; private int rows;
int columns; private int columns;
private T[,] matrix; private T[,] matrix;
public Matrix(int n, int m) public Matrix(int n, int m)
{ {
matrix = new T[n, m]; matrix = new T[n, m];
rows = n; rows = n;
columns = m; columns = m;
} }
public void SetValByIdx(int m, int n, T x) public void SetValByIdx(int m, int n, T x)
{ {
matrix[n, m] = x; matrix[n, m] = x;
} }
public T GetValByIndex(int n, int m) public T GetValByIndex(int n, int m)
{ {
return matrix[n, m]; return matrix[n, m];
} }
public void SetMatrix(T[] arr) public void SetMatrix(T[] arr)
{ {
for (int r = 0; r < rows; r++) for (int r = 0; r < rows; r++)
for (int c = 0; c < columns; c++) for (int c = 0; c < columns; c++)
matrix[r, c] = arr[r * columns + c]; matrix[r, c] = arr[r * columns + c];
} }
public static Matrix<T> operator |(Matrix<T> m1, Matrix<T> m2) public static Matrix<T> operator |(Matrix<T> m1, Matrix<T> m2)
{ {
Matrix<T> m = new Matrix<T>(m1.rows, m1.columns + m2.columns); Matrix<T> m = new Matrix<T>(m1.rows, m1.columns + m2.columns);
for (int r = 0; r < m1.rows; r++) for (int r = 0; r < m1.rows; r++)
{ {
for (int c = 0; c < m1.columns; c++) for (int c = 0; c < m1.columns; c++)
m.matrix[r, c] = m1.matrix[r, c]; m.matrix[r, c] = m1.matrix[r, c];
for (int c = 0; c < m2.columns; c++) for (int c = 0; c < m2.columns; c++)
m.matrix[r, c + m1.columns] = m2.matrix[r, c]; m.matrix[r, c + m1.columns] = m2.matrix[r, c];
} }
return m; return m;
} }
public static Matrix<T> operator *(Matrix<T> m1, Matrix<T> m2) public static Matrix<T> operator *(Matrix<T> m1, Matrix<T> m2)
{ {
Matrix<T> m = new Matrix<T>(m1.rows, m2.columns); Matrix<T> m = new Matrix<T>(m1.rows, m2.columns);
for (int r = 0; r < m.rows; r++) for (int r = 0; r < m.rows; r++)
for (int c = 0; c < m.columns; c++) for (int c = 0; c < m.columns; c++)
{ {
T tmp = (dynamic)0; T tmp = (dynamic)0;
for (int i = 0; i < m2.rows; i++) for (int i = 0; i < m2.rows; i++)
tmp += (dynamic)m1.matrix[r, i] * (dynamic)m2.matrix[i, c]; tmp += (dynamic)m1.matrix[r, i] * (dynamic)m2.matrix[i, c];
m.matrix[r, c] = tmp; m.matrix[r, c] = tmp;
} }
return m; return m;
} }
public static Matrix<T> operator ~(Matrix<T> m) public static Matrix<T> operator ~(Matrix<T> m)
{ {
Matrix<T> tmp = new Matrix<T>(m.columns, m.rows); Matrix<T> tmp = new Matrix<T>(m.columns, m.rows);
for (int r = 0; r < m.rows; r++) for (int r = 0; r < m.rows; r++)
for (int c = 0; c < m.columns; c++) for (int c = 0; c < m.columns; c++)
tmp.matrix[c, r] = m.matrix[r, c]; tmp.matrix[c, r] = m.matrix[r, c];
return tmp; return tmp;
} }
public static Matrix<T> operator -(Matrix<T> m) public static Matrix<T> operator -(Matrix<T> m)
{ {
Matrix<T> tmp = new Matrix<T>(m.columns, m.rows); Matrix<T> tmp = new Matrix<T>(m.columns, m.rows);
for (int r = 0; r < m.rows; r++) for (int r = 0; r < m.rows; r++)
for (int c = 0; c < m.columns; c++) for (int c = 0; c < m.columns; c++)
tmp.matrix[r, c] = -(dynamic)m.matrix[r, c]; tmp.matrix[r, c] = -(dynamic)m.matrix[r, c];
return tmp; return tmp;
} }
public override string ToString() public override string ToString()
{ {
String output = ""; String output = "";
for (int r = 0; r < rows; r++) for (int r = 0; r < rows; r++)
{ {
output += "[\t"; output += "[\t";
for (int c = 0; c < columns; c++) for (int c = 0; c < columns; c++)
{ {
output += matrix[r, c].ToString(); output += matrix[r, c].ToString();
if (c < columns - 1) output += ",\t"; if (c < columns - 1) output += ",\t";
} }
output += "]\n"; output += "]\n";
} }
return output; return output;
} }
} }
}
}
} }
+50 -53
View File
@@ -1,68 +1,65 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing; using System.Drawing;
using System.Windows.Forms;
namespace Scatter namespace Scatter
{ {
public static class MouseWheelHandler public static class MouseWheelHandler
{ {
public static void Add(Control ctrl, Action<MouseEventArgs> onMouseWheel) public static void Add(Control ctrl, Action<MouseEventArgs> onMouseWheel)
{ {
if (ctrl == null || onMouseWheel == null) if (ctrl == null || onMouseWheel == null)
throw new ArgumentNullException(); throw new ArgumentNullException();
var filter = new MouseWheelMessageFilter(ctrl, onMouseWheel); var filter = new MouseWheelMessageFilter(ctrl, onMouseWheel);
Application.AddMessageFilter(filter); Application.AddMessageFilter(filter);
ctrl.Disposed += (s, e) => Application.RemoveMessageFilter(filter); ctrl.Disposed += (s, e) => Application.RemoveMessageFilter(filter);
} }
class MouseWheelMessageFilter private class MouseWheelMessageFilter
: IMessageFilter : IMessageFilter
{ {
private readonly Control _ctrl; private readonly Control _ctrl;
private readonly Action<MouseEventArgs> _onMouseWheel; private readonly Action<MouseEventArgs> _onMouseWheel;
public MouseWheelMessageFilter(Control ctrl, Action<MouseEventArgs> onMouseWheel) public MouseWheelMessageFilter(Control ctrl, Action<MouseEventArgs> onMouseWheel)
{ {
_ctrl = ctrl; _ctrl = ctrl;
_onMouseWheel = onMouseWheel; _onMouseWheel = onMouseWheel;
} }
public bool PreFilterMessage(ref Message m) public bool PreFilterMessage(ref Message m)
{ {
var parent = _ctrl.Parent; var parent = _ctrl.Parent;
if (parent != null && m.Msg == 0x20a) // WM_MOUSEWHEEL, find the control at screen position m.LParam if (parent != null && m.Msg == 0x20a) // WM_MOUSEWHEEL, find the control at screen position m.LParam
{ {
var pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16); var pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16);
var clientPos = _ctrl.PointToClient(pos); var clientPos = _ctrl.PointToClient(pos);
if (_ctrl.ClientRectangle.Contains(clientPos) if (_ctrl.ClientRectangle.Contains(clientPos)
&& ReferenceEquals(_ctrl, parent.GetChildAtPoint(parent.PointToClient(pos)))) && ReferenceEquals(_ctrl, parent.GetChildAtPoint(parent.PointToClient(pos))))
{ {
var wParam = m.WParam.ToInt32(); var wParam = m.WParam.ToInt32();
Func<int, MouseButtons, MouseButtons> getButton = Func<int, MouseButtons, MouseButtons> getButton =
(flag, button) => ((wParam & flag) == flag) ? button : MouseButtons.None; (flag, button) => ((wParam & flag) == flag) ? button : MouseButtons.None;
var buttons = getButton(wParam & 0x0001, MouseButtons.Left) var buttons = getButton(wParam & 0x0001, MouseButtons.Left)
| getButton(wParam & 0x0010, MouseButtons.Middle) | getButton(wParam & 0x0010, MouseButtons.Middle)
| getButton(wParam & 0x0002, MouseButtons.Right) | getButton(wParam & 0x0002, MouseButtons.Right)
| getButton(wParam & 0x0020, MouseButtons.XButton1) | getButton(wParam & 0x0020, MouseButtons.XButton1)
| getButton(wParam & 0x0040, MouseButtons.XButton2) | getButton(wParam & 0x0040, MouseButtons.XButton2)
; // Not matching for these /*MK_SHIFT=0x0004;MK_CONTROL=0x0008*/ ; // Not matching for these /*MK_SHIFT=0x0004;MK_CONTROL=0x0008*/
var delta = wParam >> 16; var delta = wParam >> 16;
var e = new MouseEventArgs(buttons, 0, clientPos.X, clientPos.Y, delta); var e = new MouseEventArgs(buttons, 0, clientPos.X, clientPos.Y, delta);
_onMouseWheel(e); _onMouseWheel(e);
return true; return true;
} }
} }
return false; return false;
} }
} }
} }
} }
+52 -55
View File
@@ -1,67 +1,64 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing; using System.Drawing;
using System.Diagnostics;
namespace Scatter namespace Scatter
{ {
static class Projection internal static class Projection
{ {
static public PointF Project(double[] x, double s_x, double s_y, double f, double[] d_w, double azimuth, double elevation) public static PointF Project(double[] x, double s_x, double s_y, double f, double[] d_w, double azimuth, double elevation)
{ {
Algerbra.Matrix<double> Mext = GetMext(azimuth, elevation, d_w); Algerbra.Matrix<double> Mext = GetMext(azimuth, elevation, d_w);
Algerbra.Matrix<double> Mint = GetMint(s_x, s_y, f); Algerbra.Matrix<double> Mint = GetMint(s_x, s_y, f);
Algerbra.Matrix<double> X_h = new Algerbra.Matrix<double>(4, 1); Algerbra.Matrix<double> X_h = new Algerbra.Matrix<double>(4, 1);
X_h.SetMatrix(new double[] { x[0], x[1], x[2], 1.0}); X_h.SetMatrix(new double[] { x[0], x[1], x[2], 1.0 });
//Debug.Print((Mint * Mext).ToString()); //Debug.Print((Mint * Mext).ToString());
Algerbra.Matrix<double> P = Mint * Mext * X_h; Algerbra.Matrix<double> P = Mint * Mext * X_h;
return new PointF((float)(P.GetValByIndex(0, 0) / P.GetValByIndex(2, 0)), (float)(P.GetValByIndex(1, 0) / P.GetValByIndex(2, 0))); return new PointF((float)(P.GetValByIndex(0, 0) / P.GetValByIndex(2, 0)), (float)(P.GetValByIndex(1, 0) / P.GetValByIndex(2, 0)));
} }
static public PointF[] ProjectVector(List<double[]> x, double s_x, double s_y, double f, double[] d_w, double azimuth, double elevation) public static PointF[] ProjectVector(List<double[]> x, double s_x, double s_y, double f, double[] d_w, double azimuth, double elevation)
{ {
Algerbra.Matrix<double> Mext = GetMext(azimuth, elevation, d_w); Algerbra.Matrix<double> Mext = GetMext(azimuth, elevation, d_w);
Algerbra.Matrix<double> Mint = GetMint(s_x, s_y, f); Algerbra.Matrix<double> Mint = GetMint(s_x, s_y, f);
Algerbra.Matrix<double> X_h = new Algerbra.Matrix<double>(4, 1); Algerbra.Matrix<double> X_h = new Algerbra.Matrix<double>(4, 1);
PointF[] Pvec = new PointF[x.Count]; PointF[] Pvec = new PointF[x.Count];
for (int i = 0; i < x.Count; i++) for (int i = 0; i < x.Count; i++)
{ {
X_h.SetMatrix(new double[] { x[i][0], x[i][1], x[i][2], 1.0 }); X_h.SetMatrix(new double[] { x[i][0], x[i][1], x[i][2], 1.0 });
Algerbra.Matrix<double> P = Mint * Mext * X_h; Algerbra.Matrix<double> P = Mint * Mext * X_h;
Pvec[i] = new PointF((float)(P.GetValByIndex(0, 0) / P.GetValByIndex(2, 0)), (float)(P.GetValByIndex(1, 0) / P.GetValByIndex(2, 0))); Pvec[i] = new PointF((float)(P.GetValByIndex(0, 0) / P.GetValByIndex(2, 0)), (float)(P.GetValByIndex(1, 0) / P.GetValByIndex(2, 0)));
} }
return Pvec; return Pvec;
} }
static Algerbra.Matrix<double> GetMint(double s_x, double s_y, double f) private static Algerbra.Matrix<double> GetMint(double s_x, double s_y, double f)
{ {
Algerbra.Matrix<double> Mint = new Algerbra.Matrix<double>(3, 3); Algerbra.Matrix<double> Mint = new Algerbra.Matrix<double>(3, 3);
double o_x = s_x / 2; double o_x = s_x / 2;
double o_y = s_y / 2; double o_y = s_y / 2;
double a = 1; double a = 1;
Mint.SetMatrix(new double[] { f, 0, o_x, 0, f * a, o_y, 0, 0, 1 }); Mint.SetMatrix(new double[] { f, 0, o_x, 0, f * a, o_y, 0, 0, 1 });
return Mint; return Mint;
} }
static Algerbra.Matrix<double> GetMext(double azimuth, double elevation, double[] d_w) private static Algerbra.Matrix<double> GetMext(double azimuth, double elevation, double[] d_w)
{ {
Algerbra.Matrix<double> R = RotationMatrix(azimuth, elevation); Algerbra.Matrix<double> R = RotationMatrix(azimuth, elevation);
Algerbra.Matrix<double> dw = new Algerbra.Matrix<double>(3, 1); Algerbra.Matrix<double> dw = new Algerbra.Matrix<double>(3, 1);
dw.SetMatrix(d_w); dw.SetMatrix(d_w);
Algerbra.Matrix<double> Mext = R | (-R * dw); Algerbra.Matrix<double> Mext = R | (-R * dw);
return Mext; return Mext;
} }
static Algerbra.Matrix<double> RotationMatrix(double azimuth, double elevation) private static Algerbra.Matrix<double> RotationMatrix(double azimuth, double elevation)
{ {
Algerbra.Matrix<double> R = new Algerbra.Matrix<double>(3, 3); Algerbra.Matrix<double> R = new Algerbra.Matrix<double>(3, 3);
R.SetMatrix(new double[] { Math.Cos(azimuth), 0, -Math.Sin(azimuth), R.SetMatrix(new double[] { Math.Cos(azimuth), 0, -Math.Sin(azimuth),
Math.Sin(azimuth)*Math.Sin(elevation), Math.Cos(elevation), Math.Cos(azimuth)*Math.Sin(elevation), Math.Sin(azimuth)*Math.Sin(elevation), Math.Cos(elevation), Math.Cos(azimuth)*Math.Sin(elevation),
Math.Cos(elevation)*Math.Sin(azimuth), -Math.Sin(elevation), Math.Cos(azimuth)*Math.Cos(elevation) }); Math.Cos(elevation)*Math.Sin(azimuth), -Math.Sin(elevation), Math.Cos(azimuth)*Math.Cos(elevation) });
return R; return R;
} }
} }
} }
+142 -150
View File
@@ -1,179 +1,171 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Diagnostics;
namespace Scatter namespace Scatter
{ {
public partial class ScatterPlot : UserControl public partial class ScatterPlot : UserControl
{ {
List<List<double[]>> Points = new List<List<double[]>>(); private List<List<double[]>> Points = new List<List<double[]>>();
List<PointF[]> ProjPoints = new List<PointF[]>(); private List<PointF[]> ProjPoints = new List<PointF[]>();
private double f = 1000; private double f = 1000;
private double d = 5; private double d = 5;
private double[] d_w = new double[3]; private double[] d_w = new double[3];
private double last_azimuth, azimuth = 0, last_elevation, elevation = 0; private double last_azimuth, azimuth = 0, last_elevation, elevation = 0;
private bool leftMousePressed = false; private bool leftMousePressed = false;
private PointF ptMouseClick; private PointF ptMouseClick;
public double Distance public double Distance
{ {
get { return d; } get { return d; }
set { d = (value >= 0.1) ? d = value : d; UpdateProjection(); } set { d = (value >= 0.1) ? d = value : d; UpdateProjection(); }
} }
public double F public double F
{ {
get { return f; } get { return f; }
set { f = value; UpdateProjection(); } set { f = value; UpdateProjection(); }
} }
public double[] CameraPos public double[] CameraPos
{ {
get { return d_w;} get { return d_w; }
set { d_w = value; UpdateProjection(); } set { d_w = value; UpdateProjection(); }
} }
public double Azimuth public double Azimuth
{ {
get { return azimuth; } get { return azimuth; }
set { azimuth = value; UpdateProjection(); } set { azimuth = value; UpdateProjection(); }
} }
public double Elevation public double Elevation
{ {
get { return elevation; } get { return elevation; }
set { elevation = value; UpdateProjection(); } set { elevation = value; UpdateProjection(); }
} }
public ScatterPlot() public ScatterPlot()
{ {
InitializeComponent(); InitializeComponent();
MouseWheelHandler.Add(this, MyOnMouseWheel); MouseWheelHandler.Add(this, MyOnMouseWheel);
} }
protected override CreateParams CreateParams protected override CreateParams CreateParams
{ {
get get
{ {
var cp = base.CreateParams; var cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp; return cp;
} }
} }
Color[] colorIdx = new Color[] { Color.Blue, Color.Red, Color.Green, Color.Orange, Color.Fuchsia, Color.Black }; private Color[] colorIdx = new Color[] { Color.Blue, Color.Red, Color.Green, Color.Orange, Color.Fuchsia, Color.Black };
protected override void OnPaint(PaintEventArgs e) protected override void OnPaint(PaintEventArgs e)
{ {
base.OnPaint(e); base.OnPaint(e);
Graphics g = this.CreateGraphics(); Graphics g = this.CreateGraphics();
g.FillRectangle(Brushes.White, new Rectangle(0, 0, this.Width, this.Height)); g.FillRectangle(Brushes.White, new Rectangle(0, 0, this.Width, this.Height));
if (ProjPoints != null) if (ProjPoints != null)
{ {
for (int i = 0; i < ProjPoints.Count; i++) for (int i = 0; i < ProjPoints.Count; i++)
{ {
foreach (PointF p in ProjPoints[i]) foreach (PointF p in ProjPoints[i])
{ {
g.FillEllipse(new SolidBrush(colorIdx[i % colorIdx.Length]), new RectangleF(p.X, p.Y, 4, 4)); g.FillEllipse(new SolidBrush(colorIdx[i % colorIdx.Length]), new RectangleF(p.X, p.Y, 4, 4));
} }
} }
} }
} }
public void AddPoint(double x, double y, double z, int series) public void AddPoint(double x, double y, double z, int series)
{ {
if (Points.Count - 1 < series) if (Points.Count - 1 < series)
{ {
Points.Add(new List<double[]>()); Points.Add(new List<double[]>());
} }
Points[series].Add(new double[] { x, y, z }); Points[series].Add(new double[] { x, y, z });
foreach (List<double[]> ser in Points) foreach (List<double[]> ser in Points)
{ {
if (ProjPoints.Count - 1 < series) if (ProjPoints.Count - 1 < series)
ProjPoints.Add(Projection.ProjectVector(ser, this.Width, this.Height, f, d_w, azimuth, elevation)); ProjPoints.Add(Projection.ProjectVector(ser, this.Width, this.Height, f, d_w, azimuth, elevation));
else else
ProjPoints[series] = Projection.ProjectVector(ser, this.Width, this.Height, f, d_w, azimuth, elevation); ProjPoints[series] = Projection.ProjectVector(ser, this.Width, this.Height, f, d_w, azimuth, elevation);
} }
this.Invalidate(); this.Invalidate();
} }
public void AddPoints(List<double[]> points) public void AddPoints(List<double[]> points)
{ {
List<double[]> _tmp = new List<double[]>(points); List<double[]> _tmp = new List<double[]>(points);
Points.Add(_tmp); Points.Add(_tmp);
ProjPoints.Add(Projection.ProjectVector(Points[Points.Count-1], this.Width, this.Height, f, d_w, azimuth, elevation)); ProjPoints.Add(Projection.ProjectVector(Points[Points.Count - 1], this.Width, this.Height, f, d_w, azimuth, elevation));
UpdateProjection(); UpdateProjection();
} }
public void Clear() public void Clear()
{ {
ProjPoints.Clear(); ProjPoints.Clear();
Points.Clear(); Points.Clear();
Azimuth = 0; Azimuth = 0;
Elevation = 0; Elevation = 0;
} }
private void ScatterPlot_MouseMove(object sender, MouseEventArgs e) private void ScatterPlot_MouseMove(object sender, MouseEventArgs e)
{ {
if (leftMousePressed) if (leftMousePressed)
{ {
azimuth = last_azimuth - (ptMouseClick.X - e.X) / 100; azimuth = last_azimuth - (ptMouseClick.X - e.X) / 100;
elevation = last_elevation + (ptMouseClick.Y - e.Y) / 100; elevation = last_elevation + (ptMouseClick.Y - e.Y) / 100;
UpdateProjection(); UpdateProjection();
} }
} }
private void ScatterPlot_SizeChanged(object sender, EventArgs e) private void ScatterPlot_SizeChanged(object sender, EventArgs e)
{ {
if (ProjPoints != null) if (ProjPoints != null)
UpdateProjection(); UpdateProjection();
} }
private void ScatterPlot_MouseDown(object sender, MouseEventArgs e) private void ScatterPlot_MouseDown(object sender, MouseEventArgs e)
{ {
if (e.Button == System.Windows.Forms.MouseButtons.Left) if (e.Button == System.Windows.Forms.MouseButtons.Left)
{ {
leftMousePressed = true; leftMousePressed = true;
ptMouseClick = new PointF(e.X, e.Y); ptMouseClick = new PointF(e.X, e.Y);
last_azimuth = azimuth; last_azimuth = azimuth;
last_elevation = elevation; last_elevation = elevation;
} }
} }
private void ScatterPlot_MouseUp(object sender, MouseEventArgs e) private void ScatterPlot_MouseUp(object sender, MouseEventArgs e)
{ {
if (e.Button == System.Windows.Forms.MouseButtons.Left) if (e.Button == System.Windows.Forms.MouseButtons.Left)
leftMousePressed = false; leftMousePressed = false;
} }
private void MyOnMouseWheel(MouseEventArgs e)
{
Distance += -e.Delta / 500D;
}
private void UpdateProjection()
{
if (ProjPoints == null)
return;
double x = d * Math.Cos(elevation) * Math.Cos(azimuth);
double y = d * Math.Cos(elevation) * Math.Sin(azimuth);
double z = d * Math.Sin(elevation);
d_w = new double[3] { -y, z, -x };
for (int i = 0; i < ProjPoints.Count; i++)
ProjPoints[i] = Projection.ProjectVector(Points[i], this.Width, this.Height, f, d_w, azimuth, elevation);
this.Invalidate();
}
}
private void MyOnMouseWheel(MouseEventArgs e)
{
Distance += -e.Delta / 500D;
}
private void UpdateProjection()
{
if (ProjPoints == null)
return;
double x = d * Math.Cos(elevation) * Math.Cos(azimuth);
double y = d * Math.Cos(elevation) * Math.Sin(azimuth);
double z = d * Math.Sin(elevation);
d_w = new double[3] { -y, z, -x };
for (int i = 0; i < ProjPoints.Count; i++)
ProjPoints[i] = Projection.ProjectVector(Points[i], this.Width, this.Height, f, d_w, azimuth, elevation);
this.Invalidate();
}
}
} }
+3 -5
View File
@@ -1,9 +1,9 @@
using System; using SharpGL;
using SharpGL.SceneGraph;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using SharpGL;
using SharpGL.SceneGraph;
using Telerik.WinControls.UI; using Telerik.WinControls.UI;
namespace HexcalMC.Base namespace HexcalMC.Base
@@ -22,7 +22,6 @@ namespace HexcalMC.Base
Dock = DockStyle.Fill Dock = DockStyle.Fill
}; };
Controls.Add(openGLControl); Controls.Add(openGLControl);
openGLControl.OpenGLInitialized += OpenGLControl_OpenGLInitialized; openGLControl.OpenGLInitialized += OpenGLControl_OpenGLInitialized;
@@ -31,7 +30,6 @@ namespace HexcalMC.Base
pointCloud = new List<Point3D>(); pointCloud = new List<Point3D>();
} }
public void SetPointCloud(List<Point3D> points) public void SetPointCloud(List<Point3D> points)
{ {
pointCloud = points; pointCloud = points;
+7 -7
View File
@@ -11,10 +11,10 @@ namespace HexcalMC.Form
{ {
InitializeComponent(); InitializeComponent();
// Initialize the AboutBox to display the product information from the assembly information. // Initialize the AboutBox to display the product information from the assembly
// Change assembly information settings for your application through either: // information. Change assembly information settings for your application through either:
// - Project->Properties->Application->Assembly Information // - Project->Properties->Application->Assembly Information
// - AssemblyInfo.cs // - AssemblyInfo.cs
Text = string.Format("关于 {0}", AssemblyTitle); Text = string.Format("关于 {0}", AssemblyTitle);
radLabelProductName.Text = AssemblyProduct; radLabelProductName.Text = AssemblyProduct;
radLabelVersion.Text = string.Format("Version {0}", AssemblyVersion); radLabelVersion.Text = string.Format("Version {0}", AssemblyVersion);
@@ -31,7 +31,6 @@ namespace HexcalMC.Form
Close(); Close();
} }
#region Assembly Attribute Accessors #region Assembly Attribute Accessors
public string AssemblyTitle public string AssemblyTitle
@@ -51,7 +50,8 @@ namespace HexcalMC.Form
return titleAttribute.Title; return titleAttribute.Title;
} }
// If there was no Title attribute, or if the Title attribute was the empty string, return the .exe name // If there was no Title attribute, or if the Title attribute was the empty string,
// return the .exe name
return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
} }
} }
@@ -118,6 +118,6 @@ namespace HexcalMC.Form
} }
} }
#endregion #endregion Assembly Attribute Accessors
} }
} }
+7 -7
View File
@@ -1,4 +1,5 @@
using System; using HexcalMC.Base;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
@@ -6,7 +7,6 @@ using System.Net.Sockets;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using HexcalMC.Base;
using Timer = System.Windows.Forms.Timer; using Timer = System.Windows.Forms.Timer;
namespace HexcalMC.Hexcal namespace HexcalMC.Hexcal
@@ -36,7 +36,7 @@ namespace HexcalMC.Hexcal
private Thread _mWatchThread; // 负责监听客户端连接请求的线程; private Thread _mWatchThread; // 负责监听客户端连接请求的线程;
/// <summary> /// <summary>
/// 使用模式,默认=1,接收任意数据显示;2=前两个字节为数据长度 /// 使用模式,默认=1,接收任意数据显示;2=前两个字节为数据长度
/// </summary> /// </summary>
public int UseMode = 1; public int UseMode = 1;
@@ -207,8 +207,8 @@ namespace HexcalMC.Hexcal
if (length > 0) if (length > 0)
{ {
string strData = Encoding.Default.GetString(arrMsgRec); // 将接受到的字节数据转化成字符串; string strData = Encoding.Default.GetString(arrMsgRec); // 将接受到的字节数据转化成字符串;
//strData = strData.Substring(0, length); //strData = strData.Substring(0, length);
//RaisedMessage(sokClient.RemoteEndPoint.ToString(), strData.Replace("\0", "<0>")); //RaisedMessage(sokClient.RemoteEndPoint.ToString(), strData.Replace("\0", "<0>"));
RaisedMessage(sokClient.RemoteEndPoint.ToString(), strData.Replace("\0", ".")); RaisedMessage(sokClient.RemoteEndPoint.ToString(), strData.Replace("\0", "."));
} }
@@ -226,6 +226,7 @@ namespace HexcalMC.Hexcal
} }
break; break;
case 3: case 3:
if (length > 0) if (length > 0)
{ {
@@ -315,7 +316,6 @@ namespace HexcalMC.Hexcal
} }
} }
public void SendMessageToAllClients(byte[] arrMsg) public void SendMessageToAllClients(byte[] arrMsg)
{ {
foreach (Socket soc in _dictSocket.Values) foreach (Socket soc in _dictSocket.Values)
@@ -388,7 +388,7 @@ namespace HexcalMC.Hexcal
for (int i = _dictSocket.Values.ToArray().Length - 1; i >= 0; i--) for (int i = _dictSocket.Values.ToArray().Length - 1; i >= 0; i--)
{ {
if (_dictSocket.Values.ToArray()[i] if (_dictSocket.Values.ToArray()[i]
.Poll(100, SelectMode.SelectRead)) //10毫秒,检查套接字状态, SelectMode 参数指定要监视的套接字的类别。 .Poll(100, SelectMode.SelectRead)) //10毫秒,检查套接字状态, SelectMode 参数指定要监视的套接字的类别。
{ {
// DictSocket.Remove(DictSocket.Keys.ToArray()[i]); // DictSocket.Remove(DictSocket.Keys.ToArray()[i]);
+14 -9
View File
@@ -86,16 +86,22 @@
<ApplicationIcon>Hexagon.ico</ApplicationIcon> <ApplicationIcon>Hexagon.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ManifestCertificateThumbprint>6EDD851028CAF15F53977FDAABCEB5A0859CFE89</ManifestCertificateThumbprint> <ManifestCertificateThumbprint>496B16FFAF2CF6830CF56CFF2C6223A82DC3B1DF</ManifestCertificateThumbprint>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ManifestKeyFile>HexcalMC_TemporaryKey.pfx</ManifestKeyFile> <ManifestKeyFile>HexcalMC_1_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<GenerateManifests>true</GenerateManifests> <GenerateManifests>true</GenerateManifests>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignManifests>true</SignManifests> <SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ACS.SPiiPlusNET, Version=3.2.0.32487, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="ACS.SPiiPlusNET, Version=3.2.0.32487, Culture=neutral, processorArchitecture=MSIL">
@@ -197,11 +203,11 @@
<DependentUpon>AboutBox.cs</DependentUpon> <DependentUpon>AboutBox.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Hexcal\TcpIpServer.cs" /> <Compile Include="Hexcal\TcpIpServer.cs" />
<Compile Include="MainFrom.cs"> <Compile Include="MainForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="MainFrom.Designer.cs"> <Compile Include="MainForm.Designer.cs">
<DependentUpon>MainFrom.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Motion\MonitorForm.cs"> <Compile Include="Motion\MonitorForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
@@ -236,8 +242,8 @@
<EmbeddedResource Include="Form\AboutBox.resx"> <EmbeddedResource Include="Form\AboutBox.resx">
<DependentUpon>AboutBox.cs</DependentUpon> <DependentUpon>AboutBox.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="MainFrom.resx"> <EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainFrom.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
<SubType>Designer</SubType> <SubType>Designer</SubType>
<LastGenOutput>MainFrom1.Designer.cs</LastGenOutput> <LastGenOutput>MainFrom1.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
@@ -267,7 +273,6 @@
</Compile> </Compile>
<None Include="app.config" /> <None Include="app.config" />
<None Include="ClassDiagram1.cd" /> <None Include="ClassDiagram1.cd" />
<None Include="HexcalMC_TemporaryKey.pfx" />
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
@@ -1,6 +1,6 @@
namespace HexcalMC namespace HexcalMC
{ {
partial class MainFrom partial class MainForm
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -29,14 +29,12 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainFrom)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.radLabelElement2 = new Telerik.WinControls.UI.RadLabelElement(); this.radLabelElement2 = new Telerik.WinControls.UI.RadLabelElement();
this.radTextBoxElement2 = new Telerik.WinControls.UI.RadTextBoxElement(); this.radTextBoxElement2 = new Telerik.WinControls.UI.RadTextBoxElement();
this.radButtonElement5 = new Telerik.WinControls.UI.RadButtonElement(); this.radButtonElement5 = new Telerik.WinControls.UI.RadButtonElement();
this.radTextBoxElement1 = new Telerik.WinControls.UI.RadTextBoxElement(); this.radTextBoxElement1 = new Telerik.WinControls.UI.RadTextBoxElement();
this.ribbonTab1 = new Telerik.WinControls.UI.RibbonTab(); this.ribbonTab1 = new Telerik.WinControls.UI.RibbonTab();
this.radRibbonBarGroup1 = new Telerik.WinControls.UI.RadRibbonBarGroup();
this.btn_motion = new Telerik.WinControls.UI.RadButtonElement();
this.radRibbonBarGroup4 = new Telerik.WinControls.UI.RadRibbonBarGroup(); this.radRibbonBarGroup4 = new Telerik.WinControls.UI.RadRibbonBarGroup();
this.radRibbonBarButtonGroup4 = new Telerik.WinControls.UI.RadRibbonBarButtonGroup(); this.radRibbonBarButtonGroup4 = new Telerik.WinControls.UI.RadRibbonBarButtonGroup();
this.radLabelElement5 = new Telerik.WinControls.UI.RadLabelElement(); this.radLabelElement5 = new Telerik.WinControls.UI.RadLabelElement();
@@ -62,6 +60,8 @@
this.rtb_stop = new Telerik.WinControls.UI.RadButtonElement(); this.rtb_stop = new Telerik.WinControls.UI.RadButtonElement();
this.radRibbonBarGroup9 = new Telerik.WinControls.UI.RadRibbonBarGroup(); this.radRibbonBarGroup9 = new Telerik.WinControls.UI.RadRibbonBarGroup();
this.rtb_etalon = new Telerik.WinControls.UI.RadButtonElement(); this.rtb_etalon = new Telerik.WinControls.UI.RadButtonElement();
this.radRibbonBarGroup1 = new Telerik.WinControls.UI.RadRibbonBarGroup();
this.btn_motion = new Telerik.WinControls.UI.RadButtonElement();
this.radRibbonBarGroup10 = new Telerik.WinControls.UI.RadRibbonBarGroup(); this.radRibbonBarGroup10 = new Telerik.WinControls.UI.RadRibbonBarGroup();
this.rtb_monitor = new Telerik.WinControls.UI.RadButtonElement(); this.rtb_monitor = new Telerik.WinControls.UI.RadButtonElement();
this.ribbonTab2 = new Telerik.WinControls.UI.RibbonTab(); this.ribbonTab2 = new Telerik.WinControls.UI.RibbonTab();
@@ -217,13 +217,13 @@
this.ribbonTab1.DisabledTextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; this.ribbonTab1.DisabledTextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
this.ribbonTab1.IsSelected = true; this.ribbonTab1.IsSelected = true;
this.ribbonTab1.Items.AddRange(new Telerik.WinControls.RadItem[] { this.ribbonTab1.Items.AddRange(new Telerik.WinControls.RadItem[] {
this.radRibbonBarGroup1,
this.radRibbonBarGroup4, this.radRibbonBarGroup4,
this.radRibbonBarGroup5, this.radRibbonBarGroup5,
this.radRibbonBarGroup6, this.radRibbonBarGroup6,
this.radRibbonBarGroup8, this.radRibbonBarGroup8,
this.radRibbonBarGroup7, this.radRibbonBarGroup7,
this.radRibbonBarGroup9, this.radRibbonBarGroup9,
this.radRibbonBarGroup1,
this.radRibbonBarGroup10}); this.radRibbonBarGroup10});
this.ribbonTab1.Name = "ribbonTab1"; this.ribbonTab1.Name = "ribbonTab1";
this.ribbonTab1.Text = "常用"; this.ribbonTab1.Text = "常用";
@@ -231,27 +231,6 @@
this.ribbonTab1.UseCompatibleTextRendering = false; this.ribbonTab1.UseCompatibleTextRendering = false;
this.ribbonTab1.UseMnemonic = false; this.ribbonTab1.UseMnemonic = false;
// //
// radRibbonBarGroup1
//
this.radRibbonBarGroup1.Alignment = System.Drawing.ContentAlignment.TopLeft;
this.radRibbonBarGroup1.AutoSize = false;
this.radRibbonBarGroup1.Bounds = new System.Drawing.Rectangle(0, 0, 77, 100);
this.radRibbonBarGroup1.Items.AddRange(new Telerik.WinControls.RadItem[] {
this.btn_motion});
this.radRibbonBarGroup1.Margin = new System.Windows.Forms.Padding(0);
this.radRibbonBarGroup1.MaxSize = new System.Drawing.Size(110, 100);
this.radRibbonBarGroup1.MinSize = new System.Drawing.Size(110, 100);
this.radRibbonBarGroup1.Name = "radRibbonBarGroup1";
this.radRibbonBarGroup1.Text = "运动控制";
this.radRibbonBarGroup1.UseCompatibleTextRendering = false;
//
// btn_motion
//
this.btn_motion.Image = global::HexcalMC.Properties.Resources.mothion_64;
this.btn_motion.Name = "btn_motion";
this.btn_motion.Text = "";
this.btn_motion.Click += new System.EventHandler(this.btn_motion_Click);
//
// radRibbonBarGroup4 // radRibbonBarGroup4
// //
this.radRibbonBarGroup4.Items.AddRange(new Telerik.WinControls.RadItem[] { this.radRibbonBarGroup4.Items.AddRange(new Telerik.WinControls.RadItem[] {
@@ -445,6 +424,7 @@
this.rtb_etalon}); this.rtb_etalon});
this.radRibbonBarGroup9.Name = "radRibbonBarGroup9"; this.radRibbonBarGroup9.Name = "radRibbonBarGroup9";
this.radRibbonBarGroup9.Text = "etalon校准"; this.radRibbonBarGroup9.Text = "etalon校准";
this.radRibbonBarGroup9.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
// //
// rtb_etalon // rtb_etalon
// //
@@ -453,18 +433,42 @@
this.rtb_etalon.Text = ""; this.rtb_etalon.Text = "";
this.rtb_etalon.Click += new System.EventHandler(this.rtb_etalon_Click); this.rtb_etalon.Click += new System.EventHandler(this.rtb_etalon_Click);
// //
// radRibbonBarGroup1
//
this.radRibbonBarGroup1.Alignment = System.Drawing.ContentAlignment.TopLeft;
this.radRibbonBarGroup1.AutoSize = false;
this.radRibbonBarGroup1.Bounds = new System.Drawing.Rectangle(0, 0, 77, 100);
this.radRibbonBarGroup1.Items.AddRange(new Telerik.WinControls.RadItem[] {
this.btn_motion});
this.radRibbonBarGroup1.Margin = new System.Windows.Forms.Padding(0);
this.radRibbonBarGroup1.MaxSize = new System.Drawing.Size(110, 100);
this.radRibbonBarGroup1.MinSize = new System.Drawing.Size(110, 100);
this.radRibbonBarGroup1.Name = "radRibbonBarGroup1";
this.radRibbonBarGroup1.Text = "运动控制";
this.radRibbonBarGroup1.UseCompatibleTextRendering = false;
this.radRibbonBarGroup1.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
//
// btn_motion
//
this.btn_motion.Image = global::HexcalMC.Properties.Resources.mothion_64;
this.btn_motion.Name = "btn_motion";
this.btn_motion.Text = "";
this.btn_motion.Click += new System.EventHandler(this.btn_motion_Click);
//
// radRibbonBarGroup10 // radRibbonBarGroup10
// //
this.radRibbonBarGroup10.Items.AddRange(new Telerik.WinControls.RadItem[] { this.radRibbonBarGroup10.Items.AddRange(new Telerik.WinControls.RadItem[] {
this.rtb_monitor}); this.rtb_monitor});
this.radRibbonBarGroup10.Name = "radRibbonBarGroup10"; this.radRibbonBarGroup10.Name = "radRibbonBarGroup10";
this.radRibbonBarGroup10.Text = "速度监控"; this.radRibbonBarGroup10.Text = "速度监控";
this.radRibbonBarGroup10.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
// //
// rtb_monitor // rtb_monitor
// //
this.rtb_monitor.AutoSize = false; this.rtb_monitor.AutoSize = false;
this.rtb_monitor.Bounds = new System.Drawing.Rectangle(0, 0, 66, 75); this.rtb_monitor.Bounds = new System.Drawing.Rectangle(0, 0, 66, 75);
this.rtb_monitor.Image = global::HexcalMC.Properties.Resources.speed; this.rtb_monitor.Image = global::HexcalMC.Properties.Resources.speed;
this.rtb_monitor.ImageAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.rtb_monitor.Name = "rtb_monitor"; this.rtb_monitor.Name = "rtb_monitor";
this.rtb_monitor.Text = ""; this.rtb_monitor.Text = "";
this.rtb_monitor.Click += new System.EventHandler(this.rtb_monitor_Click); this.rtb_monitor.Click += new System.EventHandler(this.rtb_monitor_Click);
@@ -537,6 +541,12 @@
this.radMenuItem2}); this.radMenuItem2});
this.radRibbonBar1.TabIndex = 0; this.radRibbonBar1.TabIndex = 0;
this.radRibbonBar1.Text = "运动补偿中间件"; this.radRibbonBar1.Text = "运动补偿中间件";
((Telerik.WinControls.UI.RadRibbonBarElement)(this.radRibbonBar1.GetChildAt(0))).Text = "运动补偿中间件";
((Telerik.WinControls.UI.RadQuickAccessToolBar)(this.radRibbonBar1.GetChildAt(0).GetChildAt(2))).Visibility = Telerik.WinControls.ElementVisibility.Hidden;
((Telerik.WinControls.UI.RadRibbonBarCaption)(this.radRibbonBar1.GetChildAt(0).GetChildAt(3))).Visibility = Telerik.WinControls.ElementVisibility.Visible;
((Telerik.WinControls.UI.RadPageViewContentAreaElement)(this.radRibbonBar1.GetChildAt(0).GetChildAt(4).GetChildAt(1))).Visibility = Telerik.WinControls.ElementVisibility.Visible;
((Telerik.WinControls.UI.RadApplicationMenuButtonElement)(this.radRibbonBar1.GetChildAt(0).GetChildAt(5))).Image = global::HexcalMC.Properties.Resources.Hexagon;
((Telerik.WinControls.UI.RadApplicationMenuButtonElement)(this.radRibbonBar1.GetChildAt(0).GetChildAt(5))).Visibility = Telerik.WinControls.ElementVisibility.Visible;
// //
// radRibbonBarBackstageView1 // radRibbonBarBackstageView1
// //
@@ -791,7 +801,7 @@
this.groupBox7.Size = new System.Drawing.Size(731, 154); this.groupBox7.Size = new System.Drawing.Size(731, 154);
this.groupBox7.TabIndex = 4; this.groupBox7.TabIndex = 4;
this.groupBox7.TabStop = false; this.groupBox7.TabStop = false;
this.groupBox7.Text = "Hexcal接口"; this.groupBox7.Text = "1. Hexcal接口";
// //
// groupBox1 // groupBox1
// //
@@ -801,7 +811,7 @@
this.groupBox1.Controls.Add(this.label3); this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Location = new System.Drawing.Point(14, 19); this.groupBox1.Location = new System.Drawing.Point(14, 19);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(701, 114); this.groupBox1.Size = new System.Drawing.Size(263, 114);
this.groupBox1.TabIndex = 0; this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "通讯状态"; this.groupBox1.Text = "通讯状态";
@@ -820,7 +830,7 @@
// //
// Btn_StopServer // Btn_StopServer
// //
this.Btn_StopServer.Location = new System.Drawing.Point(113, 79); this.Btn_StopServer.Location = new System.Drawing.Point(111, 63);
this.Btn_StopServer.Name = "Btn_StopServer"; this.Btn_StopServer.Name = "Btn_StopServer";
this.Btn_StopServer.Size = new System.Drawing.Size(81, 30); this.Btn_StopServer.Size = new System.Drawing.Size(81, 30);
this.Btn_StopServer.TabIndex = 26; this.Btn_StopServer.TabIndex = 26;
@@ -830,7 +840,7 @@
// //
// Btn_StartServer // Btn_StartServer
// //
this.Btn_StartServer.Location = new System.Drawing.Point(18, 79); this.Btn_StartServer.Location = new System.Drawing.Point(16, 63);
this.Btn_StartServer.Name = "Btn_StartServer"; this.Btn_StartServer.Name = "Btn_StartServer";
this.Btn_StartServer.Size = new System.Drawing.Size(81, 30); this.Btn_StartServer.Size = new System.Drawing.Size(81, 30);
this.Btn_StartServer.TabIndex = 25; this.Btn_StartServer.TabIndex = 25;
@@ -858,7 +868,7 @@
this.groupBox5.Size = new System.Drawing.Size(731, 154); this.groupBox5.Size = new System.Drawing.Size(731, 154);
this.groupBox5.TabIndex = 3; this.groupBox5.TabIndex = 3;
this.groupBox5.TabStop = false; this.groupBox5.TabStop = false;
this.groupBox5.Text = "运动平台"; this.groupBox5.Text = "2. 运动平台";
// //
// grpSafety // grpSafety
// //
@@ -1302,7 +1312,7 @@
this.txtIP.Name = "txtIP"; this.txtIP.Name = "txtIP";
this.txtIP.Size = new System.Drawing.Size(91, 21); this.txtIP.Size = new System.Drawing.Size(91, 21);
this.txtIP.TabIndex = 22; this.txtIP.TabIndex = 22;
this.txtIP.Text = "100.0.0.100"; this.txtIP.Text = "10.0.0.100";
// //
// btn_ACSStop // btn_ACSStop
// //
@@ -1372,7 +1382,7 @@
this.timer_RefreshUI.Interval = 1000; this.timer_RefreshUI.Interval = 1000;
this.timer_RefreshUI.Tick += new System.EventHandler(this.Timer_RefreshUI_Tick); this.timer_RefreshUI.Tick += new System.EventHandler(this.Timer_RefreshUI_Tick);
// //
// MainFrom // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@@ -1383,7 +1393,7 @@
this.Controls.Add(this.radRibbonBarBackstageView1); this.Controls.Add(this.radRibbonBarBackstageView1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = null; this.MainMenuStrip = null;
this.Name = "MainFrom"; this.Name = "MainForm";
// //
// //
// //
+1637
View File
File diff suppressed because it is too large Load Diff
@@ -632,13 +632,13 @@
</value> </value>
</data> </data>
<metadata name="tmrMonitor.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="tmrMonitor.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>328, 17</value> <value>164, 17</value>
</metadata> </metadata>
<metadata name="timer_RefreshUI.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="timer_RefreshUI.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value> <value>118</value>
</metadata> </metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
-1636
View File
File diff suppressed because it is too large Load Diff
+6 -4
View File
@@ -1,7 +1,7 @@
using System; using ACS.SPiiPlusNET;
using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using ACS.SPiiPlusNET;
using Telerik.WinControls.UI; using Telerik.WinControls.UI;
namespace HexcalMC namespace HexcalMC
@@ -55,11 +55,10 @@ namespace HexcalMC
//判断是否在演示中 //判断是否在演示中
if (Status == DemoStatus.InProgress) if (Status == DemoStatus.InProgress)
{ {
MessageBox.Show("演示正在进行中,请先停止演示","提示", MessageBoxButtons.OK, MessageBox.Show("演示正在进行中,请先停止演示", "提示", MessageBoxButtons.OK,
MessageBoxIcon.Information); MessageBoxIcon.Information);
} }
//运行演示 //运行演示
try try
{ {
@@ -121,14 +120,17 @@ namespace HexcalMC
lable_showstatus.ForeColor = Color.Black; lable_showstatus.ForeColor = Color.Black;
lable_showstatus.Text = "未演示"; lable_showstatus.Text = "未演示";
break; break;
case DemoStatus.InProgress: case DemoStatus.InProgress:
lable_showstatus.ForeColor = Color.Blue; lable_showstatus.ForeColor = Color.Blue;
lable_showstatus.Text = "演示中"; lable_showstatus.Text = "演示中";
break; break;
case DemoStatus.Completed: case DemoStatus.Completed:
lable_showstatus.ForeColor = Color.Green; lable_showstatus.ForeColor = Color.Green;
lable_showstatus.Text = "演示完成"; lable_showstatus.Text = "演示完成";
break; break;
case DemoStatus.Error: case DemoStatus.Error:
lable_showstatus.ForeColor = Color.Red; lable_showstatus.ForeColor = Color.Red;
lable_showstatus.Text = "演示出错"; lable_showstatus.Text = "演示出错";
File diff suppressed because it is too large Load Diff
+2 -18
View File
@@ -1,26 +1,13 @@
using ACS.SPiiPlusNET; using ACS.SPiiPlusNET;
using HexcalMC.Base; using HexcalMC.Base;
using ScottPlot.Renderable;
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Markup;
using Telerik.WinControls.UI;
using static ScottPlot.Generate;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
namespace HexcalMC namespace HexcalMC
{ {
public partial class MonitorForm : System.Windows.Forms.Form public partial class MonitorForm : System.Windows.Forms.Form
{ {
private readonly MainFrom mainFrom; private readonly MainForm mainFrom;
private readonly Api _acs; //ACS控制器 private readonly Api _acs; //ACS控制器
private double[] dataX; // X轴数据(时间戳) private double[] dataX; // X轴数据(时间戳)
@@ -28,7 +15,7 @@ namespace HexcalMC
private int dataLength = 200; // 显示的数据点数量‌:ml-citation{ref="4,5" data="citationList"} private int dataLength = 200; // 显示的数据点数量‌:ml-citation{ref="4,5" data="citationList"}
private Random rand = new Random(); private Random rand = new Random();
public MonitorForm(MainFrom _mainFrom) public MonitorForm(MainForm _mainFrom)
{ {
InitializeComponent(); InitializeComponent();
@@ -66,7 +53,6 @@ namespace HexcalMC
// 定时器事件:更新数据并刷新图表 // 定时器事件:更新数据并刷新图表
private void dataTimer_Tick(object sender, EventArgs e) private void dataTimer_Tick(object sender, EventArgs e)
{ {
// 生成新数据(模拟实时数据) // 生成新数据(模拟实时数据)
@@ -91,10 +77,8 @@ namespace HexcalMC
}); });
} }
private double GetSpeed(int axis) private double GetSpeed(int axis)
{ {
//判断对象是否为空 //判断对象是否为空
if (_acs == null) if (_acs == null)
{ {
+68 -91
View File
@@ -1,10 +1,10 @@
using System; using ACS.SPiiPlusNET;
using HexcalMC.Base;
using HexcalMC.Properties;
using System;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
using ACS.SPiiPlusNET;
using HexcalMC.Base;
using HexcalMC.Properties;
using Telerik.WinControls.UI; using Telerik.WinControls.UI;
// ACS .NET Library // ACS .NET Library
@@ -21,10 +21,9 @@ namespace HexcalMC
private readonly Api _acs; private readonly Api _acs;
private readonly int _motionTimeout = 50000; //延时时间 private readonly int _motionTimeout = 50000; //延时时间
private readonly MainFrom mainFrom; private readonly MainForm mainFrom;
private readonly Axis[] UseAxis = MainForm.UseAxis; //获取激活的轴
private readonly Axis[] UseAxis = MainFrom.UseAxis; //获取激活的轴
private MotionStates _currentMotionState = MotionStates.None; //运动状态 private MotionStates _currentMotionState = MotionStates.None; //运动状态
private Axis[] _mArrAxisList; private Axis[] _mArrAxisList;
private Array _mArrReadVector; private Array _mArrReadVector;
@@ -32,11 +31,10 @@ namespace HexcalMC
private bool _mBConnected; private bool _mBConnected;
private Button[] _mBtnOutput; private Button[] _mBtnOutput;
//定义Jog运动 速度 //定义Jog运动 速度
private double _mJogVel = 10.0f; private double _mJogVel = 10.0f;
private Label[] _mLblInput;
private Label[] _mLblInput;
private Label[] _mLblLeftLimit; //左限位 private Label[] _mLblLeftLimit; //左限位
private Label[] _mLblOutput; private Label[] _mLblOutput;
@@ -45,6 +43,7 @@ namespace HexcalMC
// For update values // For update values
private MotorStates _mNMotorState; //运动状态 private MotorStates _mNMotorState; //运动状态
private ProgramStates _mNProgramState; //程序状态 private ProgramStates _mNProgramState; //程序状态
private int _mNTotalAxis; private int _mNTotalAxis;
@@ -52,7 +51,7 @@ namespace HexcalMC
private int _mNValues, _mNOutputState; private int _mNValues, _mNOutputState;
private object _mObjReadVar; private object _mObjReadVar;
public Motion(MainFrom mainFrom) public Motion(MainForm mainFrom)
{ {
InitializeComponent(); InitializeComponent();
@@ -65,8 +64,7 @@ namespace HexcalMC
private void BtnSetZero_Click(object sender, EventArgs e) private void BtnSetZero_Click(object sender, EventArgs e)
{ {
// Change current poisition as you want // Change current poisition as you want SetFPosition(Axis number, new position)
// SetFPosition(Axis number, new position)
_acs.SetFPosition((Axis)cboAxisNo.SelectedIndex, 0); _acs.SetFPosition((Axis)cboAxisNo.SelectedIndex, 0);
} }
@@ -94,7 +92,7 @@ namespace HexcalMC
} }
} }
#endregion #endregion
#region IO #region IO
@@ -119,12 +117,10 @@ namespace HexcalMC
0 // 0 = OFF, 1 = ON 0 // 0 = OFF, 1 = ON
); );
// If your I/O device is EtherCAT type, you cannot use this function // If your I/O device is EtherCAT type, you cannot use this function You can use
// You can use WriteVariable function and Command function // WriteVariable function and Command function
// //
// Ex) If EtherCAT mapped variable is 'EC_DOUT' // Ex) If EtherCAT mapped variable is 'EC_DOUT' Want to ON bit '3' _ACS.Command("EC_DOUT.3=1");
// Want to ON bit '3'
// _ACS.Command("EC_DOUT.3=1");
} }
else else
{ {
@@ -137,7 +133,7 @@ namespace HexcalMC
} }
} }
#endregion #endregion IO
#region #region
@@ -206,32 +202,25 @@ namespace HexcalMC
#region #region
// Screen[] screens = Screen.AllScreens; // Screen[] screens = Screen.AllScreens; Screen secondaryScreen = screens.Length > 1 ?
// Screen secondaryScreen = screens.Length > 1 ? screens[1] : screens[0]; // 如果有多个屏幕,选择第二个屏幕作为副屏幕 // screens[1] : screens[0]; // 如果有多个屏幕,选择第二个屏幕作为副屏幕
// //
// // 创建一个新的窗体实例 // // 创建一个新的窗体实例 Form secondaryForm = new Form();
// Form secondaryForm = new Form();
// //
// // 设置窗体的位置和大小以适应副屏幕 // // 设置窗体的位置和大小以适应副屏幕 secondaryForm.StartPosition = FormStartPosition.Manual;
// secondaryForm.StartPosition = FormStartPosition.Manual; // secondaryForm.Location = secondaryScreen.Bounds.Location; secondaryForm.Size = secondaryScreen.Bounds.Size;
// secondaryForm.Location = secondaryScreen.Bounds.Location;
// secondaryForm.Size = secondaryScreen.Bounds.Size;
// //
// // 可选:设置副屏窗体的标题、样式等其他属性 // // 可选:设置副屏窗体的标题、样式等其他属性 secondaryForm.Text = "副屏窗体"; // ... 其他属性设置
// secondaryForm.Text = "副屏窗体";
// // ... 其他属性设置
// //
// // 显示副屏窗体 // // 显示副屏窗体 secondaryForm.Show();
// secondaryForm.Show();
#endregion
#endregion
#region #region
InitMotion(); InitMotion();
#endregion #endregion
} }
private void Motion_FormClosed(object sender, FormClosedEventArgs e) private void Motion_FormClosed(object sender, FormClosedEventArgs e)
@@ -239,7 +228,7 @@ namespace HexcalMC
tmrMonitor.Stop(); tmrMonitor.Stop();
} }
#endregion #endregion
#region #region
@@ -248,7 +237,6 @@ namespace HexcalMC
string strTemp; string strTemp;
int i; int i;
_mBConnected = _acs.IsConnected; _mBConnected = _acs.IsConnected;
// Get Total number of axes // Get Total number of axes
strTemp = _acs.Transaction("?SYSINFO(13)"); strTemp = _acs.Transaction("?SYSINFO(13)");
@@ -293,11 +281,9 @@ namespace HexcalMC
DebugDfn.AddLogText("运动平台已连接"); DebugDfn.AddLogText("运动平台已连接");
} }
InitMotion(); InitMotion();
_mBConnected = true; _mBConnected = true;
} }
catch (COMException comex) catch (COMException comex)
{ {
MessageBox.Show("Connection fail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Connection fail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
@@ -305,7 +291,6 @@ namespace HexcalMC
_mBConnected = false; _mBConnected = false;
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
@@ -323,7 +308,6 @@ namespace HexcalMC
btnClose.Enabled = false; btnClose.Enabled = false;
} }
private void TernminateUMD_Connection() private void TernminateUMD_Connection()
{ {
try try
@@ -343,12 +327,12 @@ namespace HexcalMC
} }
} }
#endregion #endregion
#region UI #region UI
/// <summary> /// <summary>
/// Update Motion Profile from Controller /// Update Motion Profile from Controller
/// </summary> /// </summary>
private void UpdateProfile() private void UpdateProfile()
{ {
@@ -390,16 +374,14 @@ namespace HexcalMC
if ((_mNMotorState & MotorStates.ACSC_MST_ENABLE) != 0) lblEnable.Image = Resources.On; if ((_mNMotorState & MotorStates.ACSC_MST_ENABLE) != 0) lblEnable.Image = Resources.On;
else lblEnable.Image = Resources.Off; // 使能 else lblEnable.Image = Resources.Off; // 使能
// Reference position // Reference position ACSPL+ Variable : RPOS (real)
// ACSPL+ Variable : RPOS (real)
_mLfRPos = _acs.GetRPosition((Axis)iAxisNo); // 参考位置 _mLfRPos = _acs.GetRPosition((Axis)iAxisNo); // 参考位置
// Feedback position (Encoder value) // Feedback position (Encoder value) ACSPL+ Variable : FPO (real)
// ACSPL+ Variable : FPO (real)
_mLfFPos = _acs.GetFPosition((Axis)iAxisNo); //反馈位置 _mLfFPos = _acs.GetFPosition((Axis)iAxisNo); //反馈位置
// PE (Position Error) // PE (Position Error) There is no function in library. We need to use
// There is no function in library. We need to use ReadVariable function // ReadVariable function
_mLfPe = (double)_acs.ReadVariable("PE", ProgramBuffer.ACSC_NONE, iAxisNo, iAxisNo); //位置误差 _mLfPe = (double)_acs.ReadVariable("PE", ProgramBuffer.ACSC_NONE, iAxisNo, iAxisNo); //位置误差
// Feedback Velocity // Feedback Velocity
@@ -410,8 +392,8 @@ namespace HexcalMC
txtPE.Text = string.Format("{0:0.0000}", _mLfPe); txtPE.Text = string.Format("{0:0.0000}", _mLfPe);
txtFVEL.Text = string.Format("{0:0.0000}", _mLfFvel); txtFVEL.Text = string.Format("{0:0.0000}", _mLfFvel);
// Program State 运动状态 // Program State 运动状态 State : Compiled, Running, Suspended, Autoroutine is
// State : Compiled, Running, Suspended, Autoroutine is running (ON syntax) // running (ON syntax)
// //
// ACSPL+ Variable : PST (integer) // ACSPL+ Variable : PST (integer)
_mNProgramState = _acs.GetProgramState((ProgramBuffer)iBufferNo); _mNProgramState = _acs.GetProgramState((ProgramBuffer)iBufferNo);
@@ -426,8 +408,7 @@ namespace HexcalMC
lblPRG_Status.Text = "Stop"; lblPRG_Status.Text = "Stop";
} }
// Read left/right hardware limits state // Read left/right hardware limits state ACSPL+ Variable : FAULT (integer)
// ACSPL+ Variable : FAULT (integer)
_mObjReadVar = _mObjReadVar =
_acs.ReadVariableAsVector("FAULT", ProgramBuffer.ACSC_NONE, 0, _mNTotalAxis - 1); _acs.ReadVariableAsVector("FAULT", ProgramBuffer.ACSC_NONE, 0, _mNTotalAxis - 1);
if (_mObjReadVar != null) if (_mObjReadVar != null)
@@ -442,8 +423,8 @@ namespace HexcalMC
} }
} }
// Read digital input/output (Port means all of bits) // Read digital input/output (Port means all of bits) If you want to read only 1
// If you want to read only 1 bit (not an integer), use "GetInput" function // bit (not an integer), use "GetInput" function
_mNValues = _acs.GetInputPort(0); // _ACS.ReadVariableAsVector("IN", -1, 0, 0, -1, -1); _mNValues = _acs.GetInputPort(0); // _ACS.ReadVariableAsVector("IN", -1, 0, 0, -1, -1);
UpdateIoState(_mNValues, true); UpdateIoState(_mNValues, true);
@@ -461,7 +442,6 @@ namespace HexcalMC
} }
} }
private void UpdateLimitState(int axisNo, int fault) //刷新限位状态 private void UpdateLimitState(int axisNo, int fault) //刷新限位状态
{ {
if (axisNo < MaxUiLimitCnt) if (axisNo < MaxUiLimitCnt)
@@ -475,7 +455,6 @@ namespace HexcalMC
} }
} }
private void UpdateIoState(int value, bool isInput) //刷新IO状态 private void UpdateIoState(int value, bool isInput) //刷新IO状态
{ {
int bitUpCnt = 0x01; int bitUpCnt = 0x01;
@@ -526,7 +505,7 @@ namespace HexcalMC
lbl_Z_target.Text = textBox_z.Text; lbl_Z_target.Text = textBox_z.Text;
} }
#endregion #endregion UI
#region 使 #region 使
@@ -539,8 +518,8 @@ namespace HexcalMC
// //
// Ex) Eanble three axes (0, 1, 6) // Ex) Eanble three axes (0, 1, 6)
// //
// int[] AxisList = new int[] { 0, 1, 6, -1 }; !!!! Important !! Must insert '-1' at the last // int[] AxisList = new int[] { 0, 1, 6, -1 }; !!!! Important !! Must insert '-1' at the
// _ACS.EnableM(AxisList); // last _ACS.EnableM(AxisList);
} }
private void BtnDisable_Click(object sender, EventArgs e) private void BtnDisable_Click(object sender, EventArgs e)
@@ -556,7 +535,7 @@ namespace HexcalMC
_acs.DisableAll(); _acs.DisableAll();
} }
#endregion #endregion 使
#region #region
@@ -605,7 +584,7 @@ namespace HexcalMC
} }
} }
#endregion #endregion
#region #region
@@ -637,7 +616,7 @@ namespace HexcalMC
} }
} }
#endregion #endregion
#region JOG #region JOG
@@ -671,7 +650,6 @@ namespace HexcalMC
} }
} }
private void BtnJogPos_MouseDown(object sender, MouseEventArgs e) private void BtnJogPos_MouseDown(object sender, MouseEventArgs e)
{ {
double lfVelocity = 0.0f; double lfVelocity = 0.0f;
@@ -702,7 +680,6 @@ namespace HexcalMC
{ {
_acs.Halt((Axis)cboAxisNo.SelectedIndex); _acs.Halt((Axis)cboAxisNo.SelectedIndex);
//自定义Jog //自定义Jog
if (sender is Button button) if (sender is Button button)
{ {
@@ -712,18 +689,23 @@ namespace HexcalMC
case "btn_X_left": case "btn_X_left":
_acs.Halt(Axis.ACSC_AXIS_1); _acs.Halt(Axis.ACSC_AXIS_1);
break; break;
case "btn_X_right": case "btn_X_right":
_acs.Halt(Axis.ACSC_AXIS_1); _acs.Halt(Axis.ACSC_AXIS_1);
break; break;
case "btn_Y_Forward": case "btn_Y_Forward":
_acs.Halt(Axis.ACSC_AXIS_0); _acs.Halt(Axis.ACSC_AXIS_0);
break; break;
case "btn_Y_Back": case "btn_Y_Back":
_acs.Halt(Axis.ACSC_AXIS_0); _acs.Halt(Axis.ACSC_AXIS_0);
break; break;
case "btn_Z_Up": case "btn_Z_Up":
_acs.Halt(Axis.ACSC_AXIS_8); _acs.Halt(Axis.ACSC_AXIS_8);
break; break;
case "btn_Z_Down": case "btn_Z_Down":
_acs.Halt(Axis.ACSC_AXIS_8); _acs.Halt(Axis.ACSC_AXIS_8);
break; break;
@@ -731,7 +713,7 @@ namespace HexcalMC
} }
} }
#endregion #endregion JOG
#region Buffer Program #region Buffer Program
@@ -774,7 +756,7 @@ namespace HexcalMC
_acs.StopBuffer((ProgramBuffer)cboBufferNo.SelectedIndex); _acs.StopBuffer((ProgramBuffer)cboBufferNo.SelectedIndex);
} }
#endregion #endregion Buffer Program
#region #region
@@ -788,7 +770,7 @@ namespace HexcalMC
{ {
// Allow numbers (0 ~ 9), . (DOT), Backspace // Allow numbers (0 ~ 9), . (DOT), Backspace
if ((e.KeyChar >= 0x30 && e.KeyChar <= 0x39) || e.KeyChar == 0x2E || e.KeyChar == 0x08 || if ((e.KeyChar >= 0x30 && e.KeyChar <= 0x39) || e.KeyChar == 0x2E || e.KeyChar == 0x08 ||
e.KeyChar == (char)Keys.Return || e.KeyChar == (char)Keys.Enter) e.KeyChar == (char)Keys.Return || e.KeyChar == (char)Keys.Enter)
{ {
if (e.KeyChar == 0x2E && textBox.Text.Contains(Convert.ToString(0x2E))) if (e.KeyChar == 0x2E && textBox.Text.Contains(Convert.ToString(0x2E)))
e.KeyChar = (char)0x00; e.KeyChar = (char)0x00;
@@ -799,21 +781,25 @@ namespace HexcalMC
lfTemp = Convert.ToDouble(textBox.Text.Trim()); lfTemp = Convert.ToDouble(textBox.Text.Trim());
switch (textBox.TabIndex) switch (textBox.TabIndex)
{ {
// Immediately change value (On the fly) : SetVelocityImm() // Immediately change value (On the fly) : SetVelocityImm() Affect
// Affect next motion : SetVelocity() // next motion : SetVelocity()
case 0: case 0:
_acs.SetVelocityImm((Axis)cboAxisNo.SelectedIndex, lfTemp); _acs.SetVelocityImm((Axis)cboAxisNo.SelectedIndex, lfTemp);
break; break;
case 1: case 1:
_acs.SetAccelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); _acs.SetAccelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp);
break; break;
case 2: case 2:
_acs.SetDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); _acs.SetDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp);
break; break;
case 3: case 3:
_acs.SetKillDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); _acs.SetKillDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp);
break; break;
case 4: case 4:
_acs.SetJerkImm((Axis)cboAxisNo.SelectedIndex, lfTemp); _acs.SetJerkImm((Axis)cboAxisNo.SelectedIndex, lfTemp);
break; break;
@@ -859,15 +845,19 @@ namespace HexcalMC
case 0: case 0:
_acs.SetVelocityImm((Axis)cboAxisNo.SelectedIndex, lfTemp); _acs.SetVelocityImm((Axis)cboAxisNo.SelectedIndex, lfTemp);
break; break;
case 1: case 1:
_acs.SetAccelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); _acs.SetAccelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp);
break; break;
case 2: case 2:
_acs.SetDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); _acs.SetDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp);
break; break;
case 3: case 3:
_acs.SetKillDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp); _acs.SetKillDecelerationImm((Axis)cboAxisNo.SelectedIndex, lfTemp);
break; break;
case 4: case 4:
_acs.SetJerkImm((Axis)cboAxisNo.SelectedIndex, lfTemp); _acs.SetJerkImm((Axis)cboAxisNo.SelectedIndex, lfTemp);
break; break;
@@ -881,7 +871,7 @@ namespace HexcalMC
} }
} }
#endregion #endregion
#region #region
@@ -896,8 +886,7 @@ namespace HexcalMC
{ {
int bit = 0x01; int bit = 0x01;
int axisNo = 0; int axisNo = 0;
// Param value is bit number // Param value is bit number Bit Number = Axis Number
// Bit Number = Axis Number
for (int i = 0; i < 64; i++) for (int i = 0; i < 64; i++)
{ {
if ((int)axis == bit) if ((int)axis == bit)
@@ -927,13 +916,11 @@ namespace HexcalMC
lstLog.Items.Add("PROGRAM_END event enabled"); lstLog.Items.Add("PROGRAM_END event enabled");
} }
private void ACS_PROGRAMEND(BufferMasks buffer) private void ACS_PROGRAMEND(BufferMasks buffer)
{ {
int bit = 0x01; int bit = 0x01;
int bufferNo = 0; int bufferNo = 0;
// Param value is bit number // Param value is bit number Bit Number = Axis Number
// Bit Number = Axis Number
for (int i = 0; i < 32; i++) for (int i = 0; i < 32; i++)
{ {
if ((int)buffer == bit) if ((int)buffer == bit)
@@ -953,7 +940,7 @@ namespace HexcalMC
}); });
} }
#endregion #endregion
#region #region
@@ -998,8 +985,7 @@ namespace HexcalMC
rtxtTerminal.ScrollToCaret(); rtxtTerminal.ScrollToCaret();
} }
#endregion #endregion
#region #region
@@ -1007,7 +993,7 @@ namespace HexcalMC
{ {
//判断是否为textBox_x空 //判断是否为textBox_x空
if (string.IsNullOrWhiteSpace(textBox_x.Text) || string.IsNullOrEmpty(textBox_y.Text) || if (string.IsNullOrWhiteSpace(textBox_x.Text) || string.IsNullOrEmpty(textBox_y.Text) ||
string.IsNullOrEmpty(textBox_z.Text)) string.IsNullOrEmpty(textBox_z.Text))
{ {
MessageBox.Show("输入文本框为空,请修改", "警告"); MessageBox.Show("输入文本框为空,请修改", "警告");
return; return;
@@ -1019,8 +1005,7 @@ namespace HexcalMC
double z = double.Parse(textBox_z.Text); double z = double.Parse(textBox_z.Text);
Point3D _point3D = new Point3D(x, y, z); Point3D _point3D = new Point3D(x, y, z);
if (MainForm.IsWithinLimit(_point3D)) //判断点是否在行程范围内
if (MainFrom.IsWithinLimit(_point3D)) //判断点是否在行程范围内
{ {
double[] pointsArray = double[] pointsArray =
{ {
@@ -1053,7 +1038,6 @@ namespace HexcalMC
} }
} }
private void btn_home_Click(object sender, EventArgs e) //回零 private void btn_home_Click(object sender, EventArgs e) //回零
{ {
double[] pointsArray = double[] pointsArray =
@@ -1125,7 +1109,6 @@ namespace HexcalMC
{ {
_mJogVel = Convert.ToDouble(txtJogVel.Text.Trim()); _mJogVel = Convert.ToDouble(txtJogVel.Text.Trim());
_acs.Jog( _acs.Jog(
MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志 MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志
Axis.ACSC_AXIS_1, // Axis number Axis.ACSC_AXIS_1, // Axis number
@@ -1172,7 +1155,6 @@ namespace HexcalMC
} }
} }
private void btn_Y_Back_MouseDown(object sender, MouseEventArgs e) private void btn_Y_Back_MouseDown(object sender, MouseEventArgs e)
{ {
try try
@@ -1181,7 +1163,6 @@ namespace HexcalMC
{ {
_mJogVel = Convert.ToDouble(txtJogVel.Text.Trim()); _mJogVel = Convert.ToDouble(txtJogVel.Text.Trim());
_acs.Jog( _acs.Jog(
MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志 MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志
Axis.ACSC_AXIS_0, // Axis number Axis.ACSC_AXIS_0, // Axis number
@@ -1237,7 +1218,6 @@ namespace HexcalMC
{ {
_mJogVel = Convert.ToDouble(txtJogVel.Text.Trim()); _mJogVel = Convert.ToDouble(txtJogVel.Text.Trim());
_acs.Jog( _acs.Jog(
MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志 MotionFlags.ACSC_AMF_VELOCITY, // Velocity flag 速度标志
Axis.ACSC_AXIS_8, // Axis number Axis.ACSC_AXIS_8, // Axis number
@@ -1257,9 +1237,6 @@ namespace HexcalMC
} }
} }
#endregion
#endregion
} }
} }
+3 -4
View File
@@ -1,9 +1,8 @@
using System; using HexcalMC.Base;
using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using HexcalMC.Base;
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// //
@@ -49,7 +48,7 @@ namespace HexcalMC
Trace.Listeners.Add(logger); Trace.Listeners.Add(logger);
MyBase.TraceWriteLine("--软件Main函数开始"); MyBase.TraceWriteLine("--软件Main函数开始");
Application.Run(new MainFrom()); Application.Run(new MainForm());
} }
} }
} }
-5
View File
@@ -1,8 +1,6 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
[assembly: AssemblyTitle("HexcalMC")] [assembly: AssemblyTitle("HexcalMC")]
[assembly: AssemblyDescription("本软件为海克斯康制造智能技术(青岛)有限公司(简称海克斯康)版权所有。本软件的任何部分,未经海克斯康公司事前书面许可,均不能复制、存储在检索系统中,或者以任何形式传播,或以任何方法(机械、电子及其他方法)影印、复制。")] [assembly: AssemblyDescription("本软件为海克斯康制造智能技术(青岛)有限公司(简称海克斯康)版权所有。本软件的任何部分,未经海克斯康公司事前书面许可,均不能复制、存储在检索系统中,或者以任何形式传播,或以任何方法(机械、电子及其他方法)影印、复制。")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
@@ -12,12 +10,9 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: Guid("6215eb36-92d3-4f96-9331-1e8cbda161f4")] [assembly: Guid("6215eb36-92d3-4f96-9331-1e8cbda161f4")]
[assembly: AssemblyVersion("0.0.3")] [assembly: AssemblyVersion("0.0.3")]
[assembly: AssemblyFileVersion("0.0.3")] [assembly: AssemblyFileVersion("0.0.3")]
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

+3 -3
View File
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></startup> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /></startup>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/> <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/> <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -21,7 +21,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>kw+hFfwnop75FYiMm+CkPl/Ui8EpkT8BuDrRnaok1W0=</dsig:DigestValue> <dsig:DigestValue>lMEM3iQRIwDj5xL2Aaf6lHIuYYSvnK+5moagVnmWLIY=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
Binary file not shown.
+3 -3
View File
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></startup> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /></startup>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/> <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/> <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
+4 -4
View File
@@ -55,14 +55,14 @@
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
<dependency> <dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="HexcalMC.exe" size="521216"> <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="HexcalMC.exe" size="521728">
<assemblyIdentity name="HexcalMC" version="0.0.3.0" language="neutral" processorArchitecture="amd64" /> <assemblyIdentity name="HexcalMC" version="0.0.3.0" language="neutral" processorArchitecture="amd64" />
<hash> <hash>
<dsig:Transforms> <dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>5H0iiPDRd1YOihJPwyJD4tzIp7TNDn1eXdVNt91nqVg=</dsig:DigestValue> <dsig:DigestValue>c//54i6mMSmqOysqRtrzN/1gINwehBCIXR60WbnWmfY=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
@@ -303,13 +303,13 @@
<dsig:DigestValue>32HYGtH3JppndtsILkwzp/GWhHh3Iq4VdbCQd7284ww=</dsig:DigestValue> <dsig:DigestValue>32HYGtH3JppndtsILkwzp/GWhHh3Iq4VdbCQd7284ww=</dsig:DigestValue>
</hash> </hash>
</file> </file>
<file name="HexcalMC.exe.config" size="519"> <file name="HexcalMC.exe.config" size="520">
<hash> <hash>
<dsig:Transforms> <dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>oxwFyeXS8BP9BAS4rAjMQJBMtU+40+onBndoHIYtMog=</dsig:DigestValue> <dsig:DigestValue>Nehw75tWncmh7MKTU45ORJgPSsOI3SkwzVWBcGk6J7w=</dsig:DigestValue>
</hash> </hash>
</file> </file>
<file name="SharpGL.ico" size="1150"> <file name="SharpGL.ico" size="1150">
Binary file not shown.
Binary file not shown.