init: 导入项目到 meswork Gitea
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModelBasic
|
||||
{
|
||||
public partial class SS
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModelBasic
|
||||
{
|
||||
public partial class SS
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModelBasic
|
||||
{
|
||||
public partial class SS
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
17
DataMirrorTools_Simulator/ModelBasic/BasicClass/A_BAK_1.cs
Normal file
17
DataMirrorTools_Simulator/ModelBasic/BasicClass/A_BAK_1.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModelBasic
|
||||
{
|
||||
public partial class SS
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
public class AutoClosingMessageBox
|
||||
{
|
||||
private System.Threading.Timer _timeoutTimer;
|
||||
private string _caption;
|
||||
private const int WM_CLOSE = 16;
|
||||
private AutoClosingMessageBox(string text, string caption, int timeout)
|
||||
{
|
||||
this._caption = caption;
|
||||
this._timeoutTimer = new System.Threading.Timer(new System.Threading.TimerCallback(this.OnTimerElapsed), null, timeout, -1);
|
||||
MessageBox.Show(text, caption);
|
||||
}
|
||||
public static void Show(string text, string caption, int timeout)
|
||||
{
|
||||
new AutoClosingMessageBox(text, caption, timeout);
|
||||
}
|
||||
private void OnTimerElapsed(object state)
|
||||
{
|
||||
IntPtr intPtr = AutoClosingMessageBox.FindWindow(null, this._caption);
|
||||
if (intPtr != IntPtr.Zero)
|
||||
{
|
||||
AutoClosingMessageBox.SendMessage(intPtr, 16u, IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
this._timeoutTimer.Dispose();
|
||||
}
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
|
||||
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
|
||||
}
|
||||
391
DataMirrorTools_Simulator/ModelBasic/BasicClass/CONVERT.cs
Normal file
391
DataMirrorTools_Simulator/ModelBasic/BasicClass/CONVERT.cs
Normal file
@@ -0,0 +1,391 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CVT
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="M"></param>
|
||||
/// <returns></returns>
|
||||
public static double MToMM(object M)
|
||||
{
|
||||
return Math.Round(Convert.ToDouble(M.ToString()) * 1000, 2);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="MM"></param>
|
||||
/// <returns></returns>
|
||||
public static double MMToM(object MM)
|
||||
{
|
||||
return Math.Round(Convert.ToDouble(MM.ToString()) / 1000, 5);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="angle"></param>
|
||||
/// <returns></returns>
|
||||
public static double AngleToRad(object angle)
|
||||
{
|
||||
return Math.Round(Convert.ToDouble(angle.ToString()) * Math.PI / 180, 5);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="rad"></param>
|
||||
/// <returns></returns>
|
||||
public static double RadToAngle(object rad)
|
||||
{
|
||||
return Math.Round(Convert.ToDouble(rad.ToString()) * 180 / Math.PI, 5);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="M"></param>
|
||||
/// <returns></returns>
|
||||
public static double MToMM(string M)
|
||||
{
|
||||
return Math.Round(Convert.ToDouble(M) * 1000, 2);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="MM"></param>
|
||||
/// <returns></returns>
|
||||
public static double MMToM(string MM)
|
||||
{
|
||||
return Math.Round(Convert.ToDouble(MM) / 1000, 5);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="angle"></param>
|
||||
/// <returns></returns>
|
||||
public static double AngleToRad(string angle)
|
||||
{
|
||||
return Math.Round(Convert.ToDouble(angle) * Math.PI / 180, 5);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="rad"></param>
|
||||
/// <returns></returns>
|
||||
public static double RadToAngle(string rad)
|
||||
{
|
||||
return Math.Round(Convert.ToDouble(rad) * 180 / Math.PI, 5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="M"></param>
|
||||
/// <returns></returns>
|
||||
public static double MToMM(double M)
|
||||
{
|
||||
return Math.Round(M * 1000, 2);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="MM"></param>
|
||||
/// <returns></returns>
|
||||
public static double MMToM(double MM)
|
||||
{
|
||||
return Math.Round(MM / 1000, 5);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="angle"></param>
|
||||
/// <returns></returns>
|
||||
public static double AngleToRad(double angle)
|
||||
{
|
||||
return Math.Round(angle * Math.PI / 180, 5);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="rad"></param>
|
||||
/// <returns></returns>
|
||||
public static double RadToAngle(double rad)
|
||||
{
|
||||
return Math.Round(rad * 180 / Math.PI, 5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 坐标系的转换
|
||||
/// ThreeJsToMatlab
|
||||
/// 原则:Y、Z互换,且Y取负方向
|
||||
/// 2020.10.19
|
||||
/// </summary>
|
||||
/// <param name="threePosition"></param>
|
||||
/// <returns></returns>
|
||||
public static double[] ThreeJsToMatlab__Y_Z(double[] threePosition)
|
||||
{
|
||||
double[] matlabPosition = new double[6];
|
||||
matlabPosition[0] = threePosition[0];
|
||||
matlabPosition[1] = threePosition[2] * (-1);
|
||||
matlabPosition[2] = threePosition[1];
|
||||
matlabPosition[3] = threePosition[3];
|
||||
matlabPosition[4] = threePosition[4];
|
||||
matlabPosition[5] = threePosition[5];
|
||||
return matlabPosition;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 坐标系的转换
|
||||
/// ThreeJsToMatlab
|
||||
/// </summary>
|
||||
/// <param name="threePosition"></param>
|
||||
/// <returns></returns>
|
||||
public static double[] ThreeJsToKdl(double[] threePosition)
|
||||
{
|
||||
double[] matlabPosition = new double[6];
|
||||
|
||||
//// 2020.10.19 原则:当时好用的变换
|
||||
//matlabPosition[0] = threePosition[2] * (-1);
|
||||
//matlabPosition[1] = threePosition[0] * (-1);
|
||||
//matlabPosition[2] = threePosition[1];
|
||||
//matlabPosition[3] = threePosition[5] * (-1);
|
||||
//matlabPosition[4] = threePosition[3] * (-1);
|
||||
//matlabPosition[5] = threePosition[4];
|
||||
|
||||
//// 2020.11.24 原则:不做变换
|
||||
//matlabPosition[0] = threePosition[0];
|
||||
//matlabPosition[1] = threePosition[1];
|
||||
//matlabPosition[2] = threePosition[2];
|
||||
//matlabPosition[3] = threePosition[3];
|
||||
//matlabPosition[4] = threePosition[4];
|
||||
//matlabPosition[5] = threePosition[5];
|
||||
|
||||
//// 2020.11.25 原则:
|
||||
//matlabPosition[0] = threePosition[2] ;
|
||||
//matlabPosition[1] = threePosition[0] * (-1);
|
||||
//matlabPosition[2] = threePosition[1];
|
||||
//matlabPosition[3] = threePosition[5] ;
|
||||
//matlabPosition[4] = threePosition[3] * (-1);
|
||||
//matlabPosition[5] = threePosition[4];
|
||||
|
||||
// 2020.11.25 原则:现在好用的
|
||||
matlabPosition[0] = threePosition[2];
|
||||
matlabPosition[1] = threePosition[0];
|
||||
matlabPosition[2] = threePosition[1];
|
||||
matlabPosition[3] = threePosition[5];
|
||||
matlabPosition[4] = threePosition[3];
|
||||
matlabPosition[5] = threePosition[4];
|
||||
|
||||
return matlabPosition;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 字符串 转换 双浮点
|
||||
/// </summary>
|
||||
/// <param name="arrayStr"></param>
|
||||
/// <returns></returns>
|
||||
public static double[] StringArrayToDoubleArray(string[] arrayStr)
|
||||
{
|
||||
double[] arrayDouble = new double[arrayStr.Length];
|
||||
for (int i = 0; i < arrayStr.Length; i++)
|
||||
arrayDouble[i] = Convert.ToDouble(arrayStr[i]);
|
||||
return arrayDouble;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// obj 转换 双浮点
|
||||
/// </summary>
|
||||
/// <param name="arrayStr"></param>
|
||||
/// <returns></returns>
|
||||
public static double[] ObjectArrayToDoubleArray(object[] arrayObj)
|
||||
{
|
||||
double[] arrayDouble = new double[arrayObj.Length];
|
||||
for (int i = 0; i < arrayObj.Length; i++)
|
||||
arrayDouble[i] = Convert.ToDouble(arrayObj[i].ToString());
|
||||
return arrayDouble;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 毫米转米
|
||||
/// 角度转弧度
|
||||
/// 10个值
|
||||
/// 2021.2.26
|
||||
/// </summary>
|
||||
/// <param name="p_Ten"></param>
|
||||
public static double[] MMToM_AngleToRad_Ten(double[] p_Ten)
|
||||
{
|
||||
return new double[] {
|
||||
CVT.MMToM(p_Ten[0]),
|
||||
CVT.MMToM(p_Ten[1]),
|
||||
CVT.MMToM(p_Ten[2]),
|
||||
p_Ten[3],
|
||||
p_Ten[4],
|
||||
p_Ten[5],
|
||||
p_Ten[6],
|
||||
CVT.AngleToRad(p_Ten[7]),
|
||||
CVT.AngleToRad(p_Ten[8]),
|
||||
CVT.AngleToRad(p_Ten[9]) };
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 毫米转米
|
||||
/// 角度转弧度
|
||||
/// 7个值
|
||||
/// 2021.2.26
|
||||
/// </summary>
|
||||
/// <param name="p_Seven"></param>
|
||||
public static double[] MMToM_AngleToRad_Seven(double[] p_Seven)
|
||||
{
|
||||
return new double[] {
|
||||
CVT.MMToM(p_Seven[0]),
|
||||
CVT.MMToM(p_Seven[1]),
|
||||
CVT.MMToM(p_Seven[2]),
|
||||
p_Seven[3],
|
||||
p_Seven[4],
|
||||
p_Seven[5],
|
||||
p_Seven[6] };
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 毫米转米
|
||||
/// 角度转弧度
|
||||
/// 6个值
|
||||
/// 2021.2.26
|
||||
/// </summary>
|
||||
/// <param name="p_Six"></param>
|
||||
public static double[] MMToM_AngleToRad_Six(double[] p_Six)
|
||||
{
|
||||
return new double[]{
|
||||
CVT.MMToM(p_Six[0]),
|
||||
CVT.MMToM(p_Six[1]),
|
||||
CVT.MMToM(p_Six[2]),
|
||||
CVT.AngleToRad(p_Six[3]),
|
||||
CVT.AngleToRad(p_Six[4]),
|
||||
CVT.AngleToRad(p_Six[5])};
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 米转毫米
|
||||
/// 弧度转角度
|
||||
/// 10个值
|
||||
/// 2021.2.26
|
||||
/// </summary>
|
||||
/// <param name="p_Ten"></param>
|
||||
public static double[] MToMM_RadToAngle_Ten(double[] p_Ten)
|
||||
{
|
||||
return new double[] {
|
||||
CVT.MToMM(p_Ten[0]),
|
||||
CVT.MToMM(p_Ten[1]),
|
||||
CVT.MToMM(p_Ten[2]),
|
||||
p_Ten[3],
|
||||
p_Ten[4],
|
||||
p_Ten[5],
|
||||
p_Ten[6],
|
||||
CVT.RadToAngle(p_Ten[7]),
|
||||
CVT.RadToAngle(p_Ten[8]),
|
||||
CVT.RadToAngle(p_Ten[9])
|
||||
};
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 米转毫米
|
||||
/// 弧度转角度
|
||||
/// 7个值
|
||||
/// 2021.2.26
|
||||
/// </summary>
|
||||
/// <param name="p_Seven"></param>
|
||||
public static double[] MToMM_RadToAngle_Seven(double[] p_Seven)
|
||||
{
|
||||
return new double[] {
|
||||
CVT.MToMM(p_Seven[0]),
|
||||
CVT.MToMM(p_Seven[1]),
|
||||
CVT.MToMM(p_Seven[2]),
|
||||
p_Seven[3],
|
||||
p_Seven[4],
|
||||
p_Seven[5],
|
||||
p_Seven[6] };
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 米转毫米
|
||||
/// 弧度转角度
|
||||
/// 6个值
|
||||
/// 2021.2.26
|
||||
/// </summary>
|
||||
/// <param name="p_Six"></param>
|
||||
public static double[] MToMM_RadToAngle_Six(double[] p_Six)
|
||||
{
|
||||
return new double[]{
|
||||
CVT.MToMM(p_Six[0]),
|
||||
CVT.MToMM(p_Six[1]),
|
||||
CVT.MToMM(p_Six[2]),
|
||||
CVT.RadToAngle(p_Six[3]),
|
||||
CVT.RadToAngle(p_Six[4]),
|
||||
CVT.RadToAngle(p_Six[5])
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="radList"></param>
|
||||
/// <returns></returns>
|
||||
public static List<double> RadToAngle(List<double> radList)
|
||||
{
|
||||
var angleList = new List<double>();
|
||||
|
||||
foreach (double rad in radList)
|
||||
{
|
||||
angleList.Add(Math.Round(rad * 180 / Math.PI, 5));
|
||||
}
|
||||
|
||||
return angleList;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="angleList"></param>
|
||||
/// <returns></returns>
|
||||
public static List<double> AngleToRad(List<double> angleList)
|
||||
{
|
||||
var radList = new List<double>();
|
||||
|
||||
foreach (double angle in angleList)
|
||||
{
|
||||
radList.Add(Math.Round(angle * Math.PI / 180, 5));
|
||||
}
|
||||
|
||||
return radList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CVT_Import
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="extension"></param>
|
||||
/// <returns></returns>
|
||||
public static string ConvertingFileFormats(string localFilePath, string extension, out string sourceData_Raw)
|
||||
{
|
||||
var sourceData_Joint = "-1";
|
||||
sourceData_Raw = "-1";
|
||||
|
||||
var sourceData = File.ReadLines(localFilePath);
|
||||
sourceData_Raw = File.ReadAllText(localFilePath);
|
||||
List<String> playData_Group = null;
|
||||
|
||||
switch (extension.ToLower())
|
||||
{
|
||||
case "dat":
|
||||
playData_Group = GeneratePdpsPlayData_NoHead(sourceData);
|
||||
break;
|
||||
default:
|
||||
playData_Group = GenerateConnServerPlayData_NoHead(sourceData);
|
||||
break;
|
||||
}
|
||||
sourceData_Joint = string.Join("", playData_Group);
|
||||
sourceData_Joint = "[" + sourceData_Joint + "]";
|
||||
sourceData_Joint = sourceData_Joint.Replace(",]", "]");
|
||||
|
||||
return sourceData_Joint;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据Pdps文本文件,得到播放序列
|
||||
/// 生成的数据不包含头
|
||||
/// </summary>
|
||||
/// <param name="sourceData"></param>
|
||||
/// <returns></returns>
|
||||
private static List<String> GeneratePdpsPlayData_NoHead(IEnumerable<String> sourceData)
|
||||
{
|
||||
List<String> sendList = new List<String>();
|
||||
|
||||
List<List<double>> rowData = new List<List<double>>();
|
||||
foreach (string str in sourceData)
|
||||
{
|
||||
List<double> data = new List<double>();
|
||||
foreach (string str2 in str.Split('\t'))
|
||||
{
|
||||
data.Add(Convert.ToDouble(str2.Split(',')[1].Trim()));
|
||||
}
|
||||
rowData.Add(data);
|
||||
}
|
||||
|
||||
int count = rowData[0].Count;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
sendList.Add(GetRobotJoint(new double[] { rowData[0][i], rowData[1][i], rowData[2][i], rowData[3][i], rowData[4][i], rowData[5][i] }));
|
||||
|
||||
return sendList;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据通讯服务文本文件,得到播放序列
|
||||
/// 生成的数据不包含头
|
||||
/// 2020.12.12
|
||||
/// </summary>
|
||||
/// <param name="sourceData"></param>
|
||||
/// <returns></returns>
|
||||
private static List<String> GenerateConnServerPlayData_NoHead(IEnumerable<String> sourceData)
|
||||
{
|
||||
var sendList = new List<String>();
|
||||
foreach (string str in sourceData)
|
||||
{
|
||||
double[] j = new double[6];
|
||||
string j_ValueStr = str.Split('|')[3];
|
||||
int count = j_ValueStr.Count(i => "&".Contains(i));
|
||||
if (count == 5 | count == 6)
|
||||
{
|
||||
string[] j_Value = j_ValueStr.Split('&');
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
string value = j_Value[i].Trim();
|
||||
if (value.Length > 0)
|
||||
{
|
||||
j[i] = Convert.ToDouble(j_Value[i].Trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
sendList.Add(GetRobotJoint(j));
|
||||
}
|
||||
|
||||
return sendList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合成机器人的 Joint 数据
|
||||
/// </summary>
|
||||
/// <param name="j"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetRobotJoint(double[] j)
|
||||
{
|
||||
return "{\"j1\":" + CVT.AngleToRad(j[0]) + ",\"j2\":" + CVT.AngleToRad(j[1]) + ",\"j3\":" + CVT.AngleToRad(j[2]) + ",\"j4\":" + CVT.AngleToRad(j[3]) + ",\"j5\":" + CVT.AngleToRad(j[4]) + ",\"j6\":" + CVT.AngleToRad(j[5]) + "},";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CVT_JSON
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 把JointData 转化成 JointList
|
||||
/// 2021.3.29
|
||||
/// </summary>
|
||||
/// <param name="craftPlayData_Joint"></param>
|
||||
/// <returns></returns>
|
||||
public static List<double[]> JointDataToJointList(string craftPlayData_Joint)
|
||||
{
|
||||
List<double[]> jSqlList = new List<double[]>();
|
||||
foreach (JToken jJointFramesRows in (JArray)JsonConvert.DeserializeObject(craftPlayData_Joint))
|
||||
jSqlList.Add(new double[] {
|
||||
Convert.ToDouble(jJointFramesRows["j1"]),
|
||||
Convert.ToDouble(jJointFramesRows["j2"]),
|
||||
Convert.ToDouble(jJointFramesRows["j3"]),
|
||||
Convert.ToDouble(jJointFramesRows["j4"]),
|
||||
Convert.ToDouble(jJointFramesRows["j5"]),
|
||||
Convert.ToDouble(jJointFramesRows["j6"])});
|
||||
return jSqlList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
110
DataMirrorTools_Simulator/ModelBasic/BasicClass/CONVERT_TABLE.cs
Normal file
110
DataMirrorTools_Simulator/ModelBasic/BasicClass/CONVERT_TABLE.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CVT_TABLE
|
||||
{
|
||||
/// <summary>
|
||||
/// 将Datatable数据转化需要的格式
|
||||
/// 2021.3.25
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <param name="baseQ_List"></param>
|
||||
/// <param name="toolQ_List"></param>
|
||||
/// <param name="ptQ_List"></param>
|
||||
/// <param name="useTime_List"></param>
|
||||
public static void DatatableTo_BaseToolTcp_List(DataTable dt,
|
||||
out List<String> processCode_List,
|
||||
out List<double[]> baseQ_List, out List<double[]> toolQ_List, out List<double[]> ptQ_List, out List<double[]> ptP_List,
|
||||
out List<Int32> useTime_List, out string modelCode_Base, out string modelName_Base, out int reverse)
|
||||
{
|
||||
processCode_List = new List<String>();
|
||||
baseQ_List = new List<double[]>();
|
||||
toolQ_List = new List<double[]>();
|
||||
ptQ_List = new List<double[]>();
|
||||
ptP_List = new List<double[]>();
|
||||
useTime_List = new List<Int32>();
|
||||
modelCode_Base = dt.Rows[0]["ModelCode"].ToString ();
|
||||
modelName_Base = dt.Rows[0]["ModelName"].ToString();
|
||||
reverse = Convert.ToInt32(dt.Rows[0]["Reverse"]);
|
||||
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
var processCode = dt.Rows[i]["ProcessCode"].ToString();
|
||||
|
||||
var baseQ = new double[7];
|
||||
baseQ[0] = Convert.ToDouble(dt.Rows[i]["X_Base"]);
|
||||
baseQ[1] = Convert.ToDouble(dt.Rows[i]["Y_Base"]);
|
||||
baseQ[2] = Convert.ToDouble(dt.Rows[i]["Z_Base"]);
|
||||
baseQ[3] = Convert.ToDouble(dt.Rows[i]["QX_Base"]);
|
||||
baseQ[4] = Convert.ToDouble(dt.Rows[i]["QY_Base"]);
|
||||
baseQ[5] = Convert.ToDouble(dt.Rows[i]["QZ_Base"]);
|
||||
baseQ[6] = Convert.ToDouble(dt.Rows[i]["QW_Base"]);
|
||||
|
||||
var toolQ = new double[7];
|
||||
toolQ[0] = Convert.ToDouble(dt.Rows[i]["X_Tool"]);
|
||||
toolQ[1] = Convert.ToDouble(dt.Rows[i]["Y_Tool"]);
|
||||
toolQ[2] = Convert.ToDouble(dt.Rows[i]["Z_Tool"]);
|
||||
toolQ[3] = Convert.ToDouble(dt.Rows[i]["QX_Tool"]);
|
||||
toolQ[4] = Convert.ToDouble(dt.Rows[i]["QY_Tool"]);
|
||||
toolQ[5] = Convert.ToDouble(dt.Rows[i]["QZ_Tool"]);
|
||||
toolQ[6] = Convert.ToDouble(dt.Rows[i]["QW_Tool"]);
|
||||
|
||||
var ptQ = new double[7];
|
||||
ptQ[0] = Convert.ToDouble(dt.Rows[i]["X"]);
|
||||
ptQ[1] = Convert.ToDouble(dt.Rows[i]["Y"]);
|
||||
ptQ[2] = Convert.ToDouble(dt.Rows[i]["Z"]);
|
||||
ptQ[3] = Convert.ToDouble(dt.Rows[i]["QX"]);
|
||||
ptQ[4] = Convert.ToDouble(dt.Rows[i]["QY"]);
|
||||
ptQ[5] = Convert.ToDouble(dt.Rows[i]["QZ"]);
|
||||
ptQ[6] = Convert.ToDouble(dt.Rows[i]["QW"]);
|
||||
|
||||
var ptP = new double[6];
|
||||
ptP[0] = Convert.ToDouble(dt.Rows[i]["X"]);
|
||||
ptP[1] = Convert.ToDouble(dt.Rows[i]["Y"]);
|
||||
ptP[2] = Convert.ToDouble(dt.Rows[i]["Z"]);
|
||||
ptP[3] = Convert.ToDouble(dt.Rows[i]["RX"]);
|
||||
ptP[4] = Convert.ToDouble(dt.Rows[i]["RY"]);
|
||||
ptP[5] = Convert.ToDouble(dt.Rows[i]["RZ"]);
|
||||
|
||||
var useTime = Convert.ToInt32(dt.Rows[i]["UseTime"]);
|
||||
|
||||
processCode_List.Add(processCode);
|
||||
baseQ_List.Add(baseQ);
|
||||
toolQ_List.Add(toolQ);
|
||||
ptQ_List.Add(ptQ);
|
||||
ptP_List.Add(ptP);
|
||||
useTime_List.Add(useTime);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ToDataTable
|
||||
/// </summary>
|
||||
/// <param name="rows"></param>
|
||||
/// <returns></returns>
|
||||
public static DataTable ToDataTable(DataRow[] rows)
|
||||
{
|
||||
if (rows == null || rows.Length == 0) return null;
|
||||
DataTable tmp = rows[0].Table.Clone(); // 复制DataRow的表结构
|
||||
foreach (DataRow row in rows)
|
||||
{
|
||||
tmp.ImportRow(row); // 将DataRow添加到DataTable中
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
namespace ModelBasic
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CopyFilesHandler
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="strSouPath"></param>
|
||||
/// <param name="strDesPath"></param>
|
||||
public static void CopyFiles(string strSouPath, string strDesPath)
|
||||
{
|
||||
Directory.CreateDirectory(strDesPath);
|
||||
|
||||
if (!Directory.Exists(strSouPath)) return;
|
||||
|
||||
string[] directories = Directory.GetDirectories(strSouPath);
|
||||
|
||||
if (directories.Length > 0)
|
||||
{
|
||||
foreach (string d in directories)
|
||||
{
|
||||
CopyFiles(d, strDesPath + d.Substring(d.LastIndexOf("\\")));
|
||||
}
|
||||
}
|
||||
|
||||
string[] files = Directory.GetFiles(strSouPath);
|
||||
|
||||
if (files.Length > 0)
|
||||
{
|
||||
foreach (string s in files)
|
||||
{
|
||||
string targetPath = strDesPath + s.Substring(s.LastIndexOf("\\"));
|
||||
if (File.Exists(targetPath))
|
||||
{
|
||||
File.Delete(targetPath);
|
||||
}
|
||||
File.Copy(s, targetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static List<String> fileNameLiat = new List<String>();
|
||||
|
||||
|
||||
public static int GetFileCount(string strSouPath)
|
||||
{
|
||||
|
||||
if (!Directory.Exists(strSouPath)) return 0;
|
||||
|
||||
string[] directories = Directory.GetDirectories(strSouPath);
|
||||
|
||||
if (directories.Length > 0)
|
||||
{
|
||||
foreach (string d in directories)
|
||||
{
|
||||
GetFileCount(d);
|
||||
}
|
||||
}
|
||||
|
||||
string[] files = Directory.GetFiles(strSouPath);
|
||||
|
||||
if (files.Length > 0)
|
||||
{
|
||||
foreach (string s in files)
|
||||
{
|
||||
fileNameLiat.Add(s);
|
||||
}
|
||||
}
|
||||
return fileNameLiat.Count();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModelBasic
|
||||
{
|
||||
public class CreateTable
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 创建 固定格式 数据表
|
||||
/// 显示机器人的数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DataTable CreateDataTableForShowDeviceImportData()
|
||||
{
|
||||
var dt = new DataTable();
|
||||
dt.Columns.Add("Index");
|
||||
dt.Columns.Add("模型名称");
|
||||
dt.Columns.Add("J1");
|
||||
dt.Columns.Add("J2");
|
||||
dt.Columns.Add("J3");
|
||||
dt.Columns.Add("J4");
|
||||
dt.Columns.Add("J5");
|
||||
dt.Columns.Add("J6");
|
||||
return dt;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
106
DataMirrorTools_Simulator/ModelBasic/BasicClass/DelayAction.cs
Normal file
106
DataMirrorTools_Simulator/ModelBasic/BasicClass/DelayAction.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Timers;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace HZ.Common
|
||||
{
|
||||
public class DelayAction
|
||||
{
|
||||
Timer _timerDbc;
|
||||
Timer _timerTrt;
|
||||
|
||||
/// <summary>
|
||||
/// 延迟timesMs后执行。 在此期间如果再次调用,则重新计时
|
||||
/// </summary>
|
||||
/// <param name="invoker">同步对象,一般为Control控件。 如不需同步可传null</param>
|
||||
public void Debounce(int timeMs, ISynchronizeInvoke invoker, Action action)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (_timerDbc == null)
|
||||
{
|
||||
_timerDbc = new Timer(timeMs);
|
||||
_timerDbc.AutoReset = false;
|
||||
_timerDbc.Elapsed += (o, e) =>
|
||||
{
|
||||
_timerDbc.Stop();
|
||||
_timerDbc.Close();
|
||||
_timerDbc = null;
|
||||
InvokeAction(action, invoker);
|
||||
};
|
||||
}
|
||||
_timerDbc.Stop();
|
||||
_timerDbc.Start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 即刻执行,执行之后,在timeMs内再次调用无效
|
||||
/// </summary>
|
||||
/// <param name="timeMs">不应期,这段时间内调用无效</param>
|
||||
/// <param name="invoker">同步对象,一般为控件。 如不需同步可传null</param>
|
||||
public void Throttle(int timeMs, ISynchronizeInvoke invoker, Action action)
|
||||
{
|
||||
System.Threading.Monitor.Enter(this);
|
||||
bool needExit = true;
|
||||
try
|
||||
{
|
||||
if (_timerTrt == null)
|
||||
{
|
||||
_timerTrt = new Timer(timeMs);
|
||||
_timerTrt.AutoReset = false;
|
||||
_timerTrt.Elapsed += (o, e) =>
|
||||
{
|
||||
_timerTrt.Stop();
|
||||
_timerTrt.Close();
|
||||
_timerTrt = null;
|
||||
};
|
||||
_timerTrt.Start();
|
||||
System.Threading.Monitor.Exit(this);
|
||||
needExit = false;
|
||||
InvokeAction(action, invoker);//这个过程不能锁
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (needExit)
|
||||
System.Threading.Monitor.Exit(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 延迟timesMs后执行。
|
||||
/// </summary>
|
||||
public void Delay(int timeMs, ISynchronizeInvoke invoker, Action action)
|
||||
{
|
||||
Debounce(timeMs, invoker, action);
|
||||
}
|
||||
|
||||
|
||||
private static void InvokeAction(Action action, ISynchronizeInvoke invoker)
|
||||
{
|
||||
if (invoker == null)
|
||||
{
|
||||
action();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (invoker.InvokeRequired)
|
||||
{
|
||||
invoker.Invoke(action, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
action();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
157
DataMirrorTools_Simulator/ModelBasic/BasicClass/ExtendMethod.cs
Normal file
157
DataMirrorTools_Simulator/ModelBasic/BasicClass/ExtendMethod.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ModelBasic
|
||||
{
|
||||
public static class ExtendMethod
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
public static List<T> ToDataList<T>(this DataTable dt)
|
||||
{
|
||||
var list = new List<T>();
|
||||
var plist = new List<PropertyInfo>(typeof(T).GetProperties());
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
T s = Activator.CreateInstance<T>();
|
||||
for (int i = 0; i < dt.Columns.Count; i++)
|
||||
{
|
||||
PropertyInfo info = plist.Find(p => p.Name == dt.Columns[i].ColumnName);
|
||||
if (info != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Convert.IsDBNull(item[i]))
|
||||
{
|
||||
object v = null;
|
||||
if (info.PropertyType.ToString().Contains("System.Nullable"))
|
||||
{
|
||||
v = Convert.ChangeType(item[i], Nullable.GetUnderlyingType(info.PropertyType));
|
||||
}
|
||||
else
|
||||
{
|
||||
v = Convert.ChangeType(item[i], info.PropertyType);
|
||||
}
|
||||
info.SetValue(s, v, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogNet.LogisTrac.WriteLog(typeof(ExtendMethod), ex);
|
||||
|
||||
throw new Exception("字段[" + info.Name + "]转换出错," + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.Add(s);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DataTable转成Dto
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
public static T ToDataDto<T>(this DataTable dt)
|
||||
{
|
||||
T s = Activator.CreateInstance<T>();
|
||||
if (dt == null || dt.Rows.Count == 0)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
var plist = new List<PropertyInfo>(typeof(T).GetProperties());
|
||||
for (int i = 0; i < dt.Columns.Count; i++)
|
||||
{
|
||||
PropertyInfo info = plist.Find(p => p.Name == dt.Columns[i].ColumnName);
|
||||
if (info != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Convert.IsDBNull(dt.Rows[0][i]))
|
||||
{
|
||||
object v = null;
|
||||
if (info.PropertyType.ToString().Contains("System.Nullable"))
|
||||
{
|
||||
v = Convert.ChangeType(dt.Rows[0][i], Nullable.GetUnderlyingType(info.PropertyType));
|
||||
}
|
||||
else
|
||||
{
|
||||
v = Convert.ChangeType(dt.Rows[0][i], info.PropertyType);
|
||||
}
|
||||
info.SetValue(s, v, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogNet.LogisTrac.WriteLog(typeof(ExtendMethod), ex);
|
||||
|
||||
throw new Exception("字段[" + info.Name + "]转换出错," + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将实体集合转换为DataTable
|
||||
/// </summary>
|
||||
/// <typeparam name="T">实体类型</typeparam>
|
||||
/// <param name="entities">实体集合</param>
|
||||
public static DataTable ToDataTable<T>(List<T> entities)
|
||||
{
|
||||
var result = CreateTable<T>();
|
||||
FillData(result, entities);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建表
|
||||
/// </summary>
|
||||
private static DataTable CreateTable<T>()
|
||||
{
|
||||
var result = new DataTable();
|
||||
var type = typeof(T);
|
||||
foreach (var property in type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance))
|
||||
{
|
||||
var propertyType = property.PropertyType;
|
||||
if ((propertyType.IsGenericType) && (propertyType.GetGenericTypeDefinition() == typeof(Nullable<>)))
|
||||
propertyType = propertyType.GetGenericArguments()[0];
|
||||
result.Columns.Add(property.Name, propertyType);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充数据
|
||||
/// </summary>
|
||||
private static void FillData<T>(DataTable dt, IEnumerable<T> entities)
|
||||
{
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
dt.Rows.Add(CreateRow(dt, entity));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建行
|
||||
/// </summary>
|
||||
private static DataRow CreateRow<T>(DataTable dt, T entity)
|
||||
{
|
||||
DataRow row = dt.NewRow();
|
||||
var type = typeof(T);
|
||||
foreach (var property in type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance))
|
||||
{
|
||||
row[property.Name] = property.GetValue(entity) ?? DBNull.Value;
|
||||
}
|
||||
return row;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
DataMirrorTools_Simulator/ModelBasic/BasicClass/Judge.cs
Normal file
32
DataMirrorTools_Simulator/ModelBasic/BasicClass/Judge.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModelBasic
|
||||
{
|
||||
public class Judge
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串是否是int/double
|
||||
/// </summary>
|
||||
public static bool IsIntOrDouble(string strNumber)
|
||||
{
|
||||
var objNotNumberPattern = new Regex("[^0-9.-]");
|
||||
var objTwoDotPattern = new Regex("[0-9]*[.][0-9]*[.][0-9]*");
|
||||
var objTwoMinusPattern = new Regex("[0-9]*[-][0-9]*[-][0-9]*");
|
||||
const string strValidRealPattern = "^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$";
|
||||
const string strValidIntegerPattern = "^([-]|[0-9])[0-9]*$";
|
||||
var objNumberPattern = new Regex("(" + strValidRealPattern + ")|(" + strValidIntegerPattern + ")");
|
||||
return !objNotNumberPattern.IsMatch(strNumber) &&
|
||||
!objTwoDotPattern.IsMatch(strNumber) &&
|
||||
!objTwoMinusPattern.IsMatch(strNumber) &&
|
||||
objNumberPattern.IsMatch(strNumber);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
104
DataMirrorTools_Simulator/ModelBasic/BasicClass/ParsingData.cs
Normal file
104
DataMirrorTools_Simulator/ModelBasic/BasicClass/ParsingData.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using DTTest;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
namespace ModelBasic
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ParsingData
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 在Json中得到Base、Tool、Tcp位置
|
||||
/// 2021.1.15
|
||||
/// </summary>
|
||||
/// <param name="jsonStr">Json</param>
|
||||
/// <param name="threejsBase">xyz rpy</param>
|
||||
/// <param name="threejsTool">xyz qxqyqzqw</param>
|
||||
/// <param name="threejsTcp">xyz qxqyqzqw</param>
|
||||
/// <param name="threejsInitJoint">返回初始机器人姿态坐标值,传出的threejsInitJoint 是rad 和m</param>
|
||||
public static void GetRobotParameter_MM(Data_RobotCurr robotCurr, out double[] threejsBaseQ, out double[] threejsToolQ, out double[] threejsTcpQ,out double[] threejsInitJoint)
|
||||
{
|
||||
threejsBaseQ = new double[] {
|
||||
CVT.MToMM(robotCurr.Base.tx),
|
||||
CVT.MToMM(robotCurr.Base.ty),
|
||||
CVT.MToMM(robotCurr.Base.tz),
|
||||
robotCurr.Base.qx,
|
||||
robotCurr.Base.qy,
|
||||
robotCurr.Base.qz,
|
||||
robotCurr.Base.qw};
|
||||
threejsToolQ = new double[] {
|
||||
CVT.MToMM(robotCurr.Tool.tx),
|
||||
CVT.MToMM(robotCurr.Tool.ty),
|
||||
CVT.MToMM(robotCurr.Tool.tz),
|
||||
robotCurr.Tool.qx,
|
||||
robotCurr.Tool.qy,
|
||||
robotCurr.Tool.qz,
|
||||
robotCurr.Tool.qw};
|
||||
threejsTcpQ = new double[] {
|
||||
CVT.MToMM(robotCurr.Tcp.tx),
|
||||
CVT.MToMM(robotCurr.Tcp.ty),
|
||||
CVT.MToMM(robotCurr.Tcp.tz),
|
||||
robotCurr.Tcp.qx,
|
||||
robotCurr.Tcp.qy,
|
||||
robotCurr.Tcp.qz,
|
||||
robotCurr.Tcp.qw};
|
||||
|
||||
#region 处理初始joint
|
||||
|
||||
var currentJoint = robotCurr.CurrentJoint;
|
||||
var jointNum = currentJoint.Count;
|
||||
|
||||
threejsInitJoint = new double[jointNum];
|
||||
|
||||
for (int i = 0; i < jointNum; i++)
|
||||
{
|
||||
var item = currentJoint[i];
|
||||
double value = Convert.ToDouble(item.JValue);
|
||||
// 转动副 从弧度转换为角度
|
||||
if (item.JType == "0")
|
||||
{
|
||||
value = value * 180 / Math.PI;
|
||||
}
|
||||
else // 滑动副 从m转换为mm
|
||||
{
|
||||
//value = value * 1000;
|
||||
}
|
||||
threejsInitJoint[i] = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dataSplit"></param>
|
||||
/// <param name="items"></param>
|
||||
/// <returns></returns>
|
||||
public static JObject GetPositionDataInfo(string jStr)
|
||||
{
|
||||
var itemsArray = (JArray)JsonConvert.DeserializeObject(jStr);
|
||||
var jObjectParam = itemsArray[0].ToString();
|
||||
return (JObject)JsonConvert.DeserializeObject(jObjectParam);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
namespace ModelBasic
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class SortBindingHelper<T> : BindingList<T>
|
||||
{
|
||||
private bool isSortedCore = true;
|
||||
private ListSortDirection sortDirectionCore = ListSortDirection.Ascending;
|
||||
private PropertyDescriptor sortPropertyCore = null;
|
||||
private string defaultSortItem;
|
||||
|
||||
public SortBindingHelper() : base() { }
|
||||
|
||||
public SortBindingHelper(IList<T> list) : base(list) { }
|
||||
|
||||
protected override bool SupportsSortingCore
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
protected override bool SupportsSearchingCore
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
protected override bool IsSortedCore
|
||||
{
|
||||
get { return isSortedCore; }
|
||||
}
|
||||
|
||||
protected override ListSortDirection SortDirectionCore
|
||||
{
|
||||
get { return sortDirectionCore; }
|
||||
}
|
||||
|
||||
protected override PropertyDescriptor SortPropertyCore
|
||||
{
|
||||
get { return sortPropertyCore; }
|
||||
}
|
||||
|
||||
protected override int FindCore(PropertyDescriptor prop, object key)
|
||||
{
|
||||
for (int i = 0; i < this.Count; i++)
|
||||
{
|
||||
if (Equals(prop.GetValue(this[i]), key)) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected override void ApplySortCore(PropertyDescriptor prop, ListSortDirection direction)
|
||||
{
|
||||
isSortedCore = true;
|
||||
sortPropertyCore = prop;
|
||||
sortDirectionCore = direction;
|
||||
Sort();
|
||||
}
|
||||
|
||||
protected override void RemoveSortCore()
|
||||
{
|
||||
if (isSortedCore)
|
||||
{
|
||||
isSortedCore = false;
|
||||
sortPropertyCore = null;
|
||||
sortDirectionCore = ListSortDirection.Ascending;
|
||||
Sort();
|
||||
}
|
||||
}
|
||||
|
||||
public string DefaultSortItem
|
||||
{
|
||||
get { return defaultSortItem; }
|
||||
set
|
||||
{
|
||||
if (defaultSortItem != value)
|
||||
{
|
||||
defaultSortItem = value;
|
||||
Sort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Sort()
|
||||
{
|
||||
List<T> list = (this.Items as List<T>);
|
||||
list.Sort(CompareCore);
|
||||
ResetBindings();
|
||||
}
|
||||
|
||||
private int CompareCore(T o1, T o2)
|
||||
{
|
||||
int ret = 0;
|
||||
if (SortPropertyCore != null)
|
||||
{
|
||||
ret = CompareValue(SortPropertyCore.GetValue(o1), SortPropertyCore.GetValue(o2), SortPropertyCore.PropertyType);
|
||||
}
|
||||
if (ret == 0 && DefaultSortItem != null)
|
||||
{
|
||||
PropertyInfo property = typeof(T).GetProperty(DefaultSortItem, BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.IgnoreCase, null, null, new Type[0], null);
|
||||
if (property != null)
|
||||
{
|
||||
ret = CompareValue(property.GetValue(o1, null), property.GetValue(o2, null), property.PropertyType);
|
||||
}
|
||||
}
|
||||
if (SortDirectionCore == ListSortDirection.Descending) ret = -ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static int CompareValue(object o1, object o2, Type type)
|
||||
{
|
||||
if (o1 == null) return o2 == null ? 0 : -1;
|
||||
else if (o2 == null) return 1;
|
||||
else if (type.IsPrimitive || type.IsEnum) return Convert.ToDouble(o1).CompareTo(Convert.ToDouble(o2));
|
||||
else if (type == typeof(DateTime)) return Convert.ToDateTime(o1).CompareTo(o2);
|
||||
else return String.Compare(o1.ToString().Trim(), o2.ToString().Trim());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class SortableBindingList<T> : BindingList<T>
|
||||
{
|
||||
private System.Collections.ArrayList sortedList;
|
||||
private bool isSortedValue;
|
||||
|
||||
public SortableBindingList()
|
||||
{
|
||||
}
|
||||
|
||||
public SortableBindingList(IList<T> list)
|
||||
{
|
||||
foreach (object o in list)
|
||||
{
|
||||
this.Add((T)o);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool SupportsSortingCore
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
|
||||
protected override bool IsSortedCore
|
||||
{
|
||||
get { return isSortedValue; }
|
||||
}
|
||||
|
||||
ListSortDirection sortDirectionValue;
|
||||
PropertyDescriptor sortPropertyValue;
|
||||
|
||||
protected override void ApplySortCore(PropertyDescriptor prop,
|
||||
ListSortDirection direction)
|
||||
{
|
||||
sortedList = new ArrayList();
|
||||
|
||||
Type interfaceType = prop.PropertyType.GetInterface("IComparable");
|
||||
|
||||
if (interfaceType == null && prop.PropertyType.IsValueType)
|
||||
{
|
||||
Type underlyingType = Nullable.GetUnderlyingType(prop.PropertyType);
|
||||
|
||||
if (underlyingType != null)
|
||||
{
|
||||
interfaceType = underlyingType.GetInterface("IComparable");
|
||||
}
|
||||
}
|
||||
|
||||
if (interfaceType != null)
|
||||
{
|
||||
sortPropertyValue = prop;
|
||||
sortDirectionValue = direction;
|
||||
|
||||
IEnumerable<T> query = base.Items;
|
||||
if (direction == ListSortDirection.Ascending)
|
||||
{
|
||||
query = query.OrderBy(i => prop.GetValue(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
query = query.OrderByDescending(i => prop.GetValue(i));
|
||||
}
|
||||
int newIndex = 0;
|
||||
foreach (object item in query)
|
||||
{
|
||||
this.Items[newIndex] = (T)item;
|
||||
newIndex++;
|
||||
}
|
||||
isSortedValue = true;
|
||||
this.OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException("Cannot sort by " + prop.Name +
|
||||
". This" + prop.PropertyType.ToString() +
|
||||
" does not implement IComparable");
|
||||
}
|
||||
}
|
||||
|
||||
protected override PropertyDescriptor SortPropertyCore
|
||||
{
|
||||
get { return sortPropertyValue; }
|
||||
}
|
||||
|
||||
protected override ListSortDirection SortDirectionCore
|
||||
{
|
||||
get { return sortDirectionValue; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModelBasic
|
||||
{
|
||||
public class TransitionalClass
|
||||
{
|
||||
|
||||
public TransitionalClass()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为了数字孪生初始化加载数据(单个链接)
|
||||
/// </summary>
|
||||
/// <param name="ipPortOpName_1"></param>
|
||||
/// <param name="prefix0"></param>
|
||||
/// <param name="objectHeader0"></param>
|
||||
/// <param name="sendInterval0"></param>
|
||||
/// <param name="connectionString"></param>
|
||||
/// <param name="projectName"></param>
|
||||
public void Load_PlcVarName_Trig_3DModel_Movement_Interface(
|
||||
string ipPortOpName_1, string prefix0, string objectHeader0, int sendInterval0,
|
||||
string connectionString, string projectName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为了数字孪生初始化加载数据(两个链接)
|
||||
/// </summary>
|
||||
/// <param name="ipPortOpName_1"></param>
|
||||
/// <param name="ipPortOpName_2"></param>
|
||||
/// <param name="prefix0"></param>
|
||||
/// <param name="objectHeader0"></param>
|
||||
/// <param name="sendInterval0"></param>
|
||||
/// <param name="connectionString"></param>
|
||||
/// <param name="projectName"></param>
|
||||
public void Load_PlcVarName_Trig_3DModel_Movement_Interface(
|
||||
string ipPortOpName_1, string ipPortOpName_2, string prefix0, string objectHeader0, int sendInterval0,
|
||||
string connectionString, string projectName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PLC 信号 触发3D模型运动
|
||||
/// </summary>
|
||||
/// <param name="tagNamePlc"></param>
|
||||
/// <param name="inputValue"></param>
|
||||
public void PlcVarName_Trig_3DModel_Movement(string tagNamePlc, bool inputValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 模型可见控制
|
||||
/// </summary>
|
||||
/// <param name="modelName"></param>
|
||||
/// <param name="visible"></param>
|
||||
public void ModelVisible(string modelName, bool visible)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user