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

+4 -4
View File
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<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>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
</configuration>
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:Transforms>
<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>
</dependentAssembly>
</dependency>
Binary file not shown.
+4 -4
View File
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<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>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
</configuration>
+4 -4
View File
@@ -55,14 +55,14 @@
</dependentAssembly>
</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" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>5H0iiPDRd1YOihJPwyJD4tzIp7TNDn1eXdVNt91nqVg=</dsig:DigestValue>
<dsig:DigestValue>c//54i6mMSmqOysqRtrzN/1gINwehBCIXR60WbnWmfY=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
@@ -303,13 +303,13 @@
<dsig:DigestValue>32HYGtH3JppndtsILkwzp/GWhHh3Iq4VdbCQd7284ww=</dsig:DigestValue>
</hash>
</file>
<file name="HexcalMC.exe.config" size="519">
<file name="HexcalMC.exe.config" size="520">
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>oxwFyeXS8BP9BAS4rAjMQJBMtU+40+onBndoHIYtMog=</dsig:DigestValue>
<dsig:DigestValue>Nehw75tWncmh7MKTU45ORJgPSsOI3SkwzVWBcGk6J7w=</dsig:DigestValue>
</hash>
</file>
<file name="SharpGL.ico" size="1150">
Binary file not shown.
Binary file not shown.