init: CATL电池线SCADA首次入库
This commit is contained in:
119
DT_SCADA/Core/B_AGV.cs
Normal file
119
DT_SCADA/Core/B_AGV.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using DatabaseClient;
|
||||
using Opc.Ua;
|
||||
using OpcBasic;
|
||||
using Robot.Common;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Threading;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class AgvRead
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string from_to_loc = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string from_to_loc_old = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string tagID = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string opName = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string connectStr = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool onLine = false;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string update_time = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string from_loc = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string to_loc = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Start(string connectStr,int interval, int intervalUpdate ,string tagID,string opName)
|
||||
{
|
||||
this.connectStr = connectStr;
|
||||
this.tagID = tagID;
|
||||
this.opName = opName;
|
||||
|
||||
new Thread(new ThreadStart(delegate () {
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
from_to_loc = ReadAgv();
|
||||
if (from_to_loc_old != from_to_loc)
|
||||
{
|
||||
from_to_loc_old = from_to_loc;
|
||||
|
||||
MesWorkForm.S_C_B_TagIDTrigger(opName,this.tagID, from_to_loc);
|
||||
}
|
||||
}
|
||||
catch (Exception err) { }
|
||||
Thread.Sleep(interval);
|
||||
}
|
||||
})).Start();
|
||||
|
||||
}
|
||||
public string ReadAgv()
|
||||
{
|
||||
var value = "";
|
||||
try
|
||||
{
|
||||
var sql =
|
||||
$" SELECT aid,from_loc,to_loc,start_run,update_time FROM agv_from_to" +
|
||||
$" ORDER BY aid LIMIT 1";
|
||||
MysqlClient.ExecQueryDataTable(sql, this.connectStr, out DataTable dt, out string err);
|
||||
onLine = err.Length < 1;
|
||||
if (onLine == false)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
var aid = dt.Rows[0]["aid"].ToString();
|
||||
var from_loc = dt.Rows[0]["from_loc"].ToString();
|
||||
var to_loc = dt.Rows[0]["to_loc"].ToString();
|
||||
var start_run = dt.Rows[0]["start_run"].ToString();
|
||||
update_time = dt.Rows[0]["update_time"].ToString();
|
||||
|
||||
this.from_loc = from_loc;
|
||||
this.to_loc = to_loc;
|
||||
|
||||
value = $"{from_loc}__{to_loc}";
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
613
DT_SCADA/Core/B_Cnc_Edm.cs
Normal file
613
DT_SCADA/Core/B_Cnc_Edm.cs
Normal file
@@ -0,0 +1,613 @@
|
||||
using BsRmlib.EDM;
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public class B_Cnc_Edm
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private CClient edm = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool OnLine = false;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ip = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int port = -1;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int interval = -1;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool isRun = true;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Id = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Name = "";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 机床状态
|
||||
/// -1-离线,0-待机,1-运行,2-报警
|
||||
/// </summary>
|
||||
public int edmCtrlStatus = 0;
|
||||
/// <summary>
|
||||
/// 机床报警号及信息
|
||||
/// </summary>
|
||||
public ushort edmGetError = 0;
|
||||
public ushort edmGetError_Old = 0;
|
||||
public string edmGetErrMsg = "";
|
||||
/// <summary>
|
||||
/// 机床提示号及信息
|
||||
/// </summary>
|
||||
public ushort edmGetComment = 0;
|
||||
public ushort edmGetComment_Old = 0;
|
||||
public string edmGetComMsg = "";
|
||||
/// <summary>
|
||||
/// 机床电流电压
|
||||
/// </summary>
|
||||
public int edmGetCurrent = 0;
|
||||
public int edmGetVoltage = 0;
|
||||
|
||||
public string programName = "";
|
||||
|
||||
|
||||
|
||||
public string edmGetRunTime = "";
|
||||
|
||||
public string progContent = "";
|
||||
|
||||
public uint toolNum_Set = 0;
|
||||
|
||||
public ushort doorAtStatus = 3;
|
||||
public ushort doorAtStatus_Old = 3;
|
||||
|
||||
public DateTime start = DateTime.Now;
|
||||
|
||||
public ushort workbench_HasPart = 0;
|
||||
public ushort workbench_HasPart_Old = 0;
|
||||
public ushort spindleClamp_HasPart = 0;
|
||||
public ushort spindleClamp_HasPart_Old = 0;
|
||||
public ushort toolLib_HasPart = 0;
|
||||
public ushort toolLib_HasPart_Old = 0;
|
||||
public int IsSpark = 0;
|
||||
public int IsSpark_Old = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
public double[] absolute_j = new double[12];
|
||||
public double[] relative_j = new double[12];
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double[] machine_j = new double[12];
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double[] jDemo = new double[12];
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public List<JointConfig> Joints = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string sendStr_Old = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string payloadInfoStr_Old = "";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public B_Cnc_Edm()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ipPort"></param>
|
||||
/// <param name="interval"></param>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <param name="modelManagement"></param>
|
||||
/// <param name="modelCode"></param>
|
||||
public void Start(string ip, int port,int interval, int intervalUpdate, string DeviceCode, string OpName, List<JointConfig> Joints
|
||||
,string tagID_DoorOpen = "", string tagID_DoorClose = ""
|
||||
, string tagID_Workbench = "", string tagID_SpindleClamp = "", string tagID_ToolLib = "", string modelCode_Spark = "")
|
||||
{
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
this.interval = interval;
|
||||
this.Id = DeviceCode;
|
||||
this.Name = OpName;
|
||||
this.Joints = Joints;
|
||||
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (isRun)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (edm == null)
|
||||
{
|
||||
edmCtrlStatus = -1;
|
||||
ReConnRobot();
|
||||
}
|
||||
if (OnLine = edm.IsConnected())
|
||||
{
|
||||
machine_j = ReadResult_To_Array();
|
||||
|
||||
//到位状态:O:打开或关闭过程中,1:打开到位,2:关闭到位
|
||||
doorAtStatus = edm.EdmStatFrontDoor();
|
||||
if (doorAtStatus_Old != doorAtStatus)
|
||||
{
|
||||
switch (doorAtStatus_Old)
|
||||
{
|
||||
case 0://0->其他:不处理
|
||||
break;
|
||||
case 1://1->0:关闭
|
||||
MesWorkForm.S_C_B_TagIDTrigger(Name, tagID_DoorClose, "1");
|
||||
break;
|
||||
case 2://2->0:打开
|
||||
MesWorkForm.S_C_B_TagIDTrigger(Name, tagID_DoorOpen, "1");
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
doorAtStatus_Old = doorAtStatus;
|
||||
|
||||
//机床状态;0-停止,1-运行,2-报警,3-暂停
|
||||
var edmCtrlStatus_NC = edm.EdmCtrlStatus();
|
||||
|
||||
switch (edmCtrlStatus_NC)
|
||||
{
|
||||
case EnumEdmStatus.Stop:
|
||||
edmCtrlStatus = 0;
|
||||
break;
|
||||
case EnumEdmStatus.Run:
|
||||
edmCtrlStatus = 1;
|
||||
break;
|
||||
case EnumEdmStatus.Halt:
|
||||
edmCtrlStatus = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
//机床报警号及信息
|
||||
edmGetError = edm.EdmGetError();
|
||||
edmGetErrMsg = edm.EdmGetErrMsg(edmGetError);
|
||||
if (edmGetError_Old != edmGetError)
|
||||
{
|
||||
// B_DB_Opera.Event_AlarmAndTip_Start(Name, edmGetError, edmGetErrMsg, edmGetError.ToString(),1);
|
||||
}
|
||||
edmGetError_Old = edmGetError;
|
||||
|
||||
//机床提示号及信息
|
||||
edmGetComment = edm.EdmGetComment();
|
||||
edmGetComMsg = edm.EdmGetComMsg(edmGetComment);
|
||||
if (edmGetComment_Old != edmGetComment)
|
||||
{
|
||||
// B_DB_Opera.Event_AlarmAndTip_Start(Name, edmGetComment, edmGetComMsg, edmGetComment.ToString(),2);
|
||||
}
|
||||
edmGetComment_Old = edmGetComment;
|
||||
|
||||
//机床电流电压
|
||||
edmGetCurrent = edm.EdmGetCurrent();
|
||||
edmGetVoltage = edm.EdmGetVoltage();
|
||||
|
||||
if (edmGetCurrent > 5)
|
||||
{
|
||||
IsSpark = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsSpark = 0;
|
||||
}
|
||||
|
||||
if (IsSpark_Old != IsSpark)
|
||||
{
|
||||
// MesWorkForm.S_C_B_SparkTrigger(Name, modelCode_Spark, IsSpark.ToString());
|
||||
}
|
||||
IsSpark_Old = IsSpark;
|
||||
|
||||
|
||||
|
||||
|
||||
//获取当前机床主程序
|
||||
programName = edm.PrgGetSelMain();
|
||||
|
||||
//运行时间
|
||||
edmGetRunTime = edm.EdmGetRunTime().ToString();
|
||||
|
||||
//程序内容
|
||||
progContent = edm.EdmGetDispNc().nc;
|
||||
|
||||
//刀具号
|
||||
toolNum_Set = edm.EdmGetToolNo();
|
||||
|
||||
|
||||
workbench_HasPart = edm.EdmStatWorkbenExistPiece();
|
||||
if (workbench_HasPart_Old != workbench_HasPart)
|
||||
{
|
||||
MesWorkForm.S_C_B_TagIDTrigger(Name, tagID_Workbench, workbench_HasPart.ToString());
|
||||
}
|
||||
workbench_HasPart_Old = workbench_HasPart;
|
||||
|
||||
spindleClamp_HasPart = edm.EdmStatSpindleExistTool();
|
||||
if (spindleClamp_HasPart_Old != spindleClamp_HasPart)
|
||||
{
|
||||
MesWorkForm.S_C_B_TagIDTrigger(Name, tagID_SpindleClamp, spindleClamp_HasPart.ToString());
|
||||
}
|
||||
spindleClamp_HasPart_Old = spindleClamp_HasPart;
|
||||
|
||||
toolLib_HasPart = edm.EdmStatMagaginExistTool();
|
||||
if (toolLib_HasPart_Old != toolLib_HasPart)
|
||||
{
|
||||
MesWorkForm.S_C_B_TagIDTrigger(Name, tagID_ToolLib, toolLib_HasPart.ToString());
|
||||
}
|
||||
toolLib_HasPart_Old = toolLib_HasPart;
|
||||
}
|
||||
else
|
||||
{
|
||||
edmCtrlStatus = -1;
|
||||
Thread.Sleep(10_000);
|
||||
ReConnRobot();
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < Joints.Count ; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = DeviceCode;
|
||||
Joints[i].Value = machine_j[i].ToString();
|
||||
}
|
||||
|
||||
var sendStr = MesWorkForm.Move_Joint(Joints);
|
||||
if (sendStr_Old != sendStr)
|
||||
{
|
||||
sendStr_Old = sendStr;
|
||||
MesWorkForm.SendMsg(sendStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception err) { }
|
||||
Thread.Sleep(interval);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
new Thread(new ThreadStart(delegate () {
|
||||
while (isRun)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < Joints.Count; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = DeviceCode;
|
||||
Joints[i].Value = machine_j[i].ToString();
|
||||
}
|
||||
|
||||
var payload = MesWorkForm.Move_Joint(Joints);
|
||||
MesWorkForm.SendMsg(payload);
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{ }
|
||||
Thread.Sleep(intervalUpdate);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (isRun)
|
||||
{
|
||||
UpdateDataToSql();
|
||||
UpdateStationStatusToSql();
|
||||
|
||||
|
||||
var deviceInfo = new DeviceInfo();
|
||||
deviceInfo.order = "";
|
||||
deviceInfo.Name = Name;
|
||||
deviceInfo.Id = Id;
|
||||
|
||||
deviceInfo.Status = edmCtrlStatus.ToString();
|
||||
deviceInfo.Program = programName;
|
||||
deviceInfo.ProgramStatus = "";
|
||||
deviceInfo.Feed = "";
|
||||
deviceInfo.Speed = "";
|
||||
deviceInfo.Rapid = "";
|
||||
deviceInfo.Current = edmGetCurrent.ToString();
|
||||
deviceInfo.Voltage = edmGetVoltage.ToString();
|
||||
deviceInfo.Axis = new List<AxisInfo>();
|
||||
deviceInfo.Tool = null;
|
||||
deviceInfo.OtherParameter = new List<ParameterInfo>();
|
||||
deviceInfo.Alarm = new List<AlarmInfo>();
|
||||
if (edmGetErrMsg.Length > 0)
|
||||
{
|
||||
deviceInfo.Alarm.Add(new AlarmInfo()
|
||||
{
|
||||
AlarmCode = edmGetError.ToString(),
|
||||
Alarm = edmGetErrMsg,
|
||||
AlarmTime = DateTime.Now.ToString("G")
|
||||
});
|
||||
}
|
||||
deviceInfo.Tip = new List<TipInfo>();
|
||||
if (edmGetComMsg.Length > 0)
|
||||
{
|
||||
deviceInfo.Tip.Add(new TipInfo()
|
||||
{
|
||||
TipCode = edmGetComment.ToString(),
|
||||
Tip = edmGetComMsg,
|
||||
TipTime = DateTime.Now.ToString("G")
|
||||
});
|
||||
}
|
||||
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "X", AxisValue = machine_j[0].ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "Y", AxisValue = machine_j[1].ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "Z", AxisValue = machine_j[2].ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "U", AxisValue = machine_j[3].ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "V", AxisValue = machine_j[4].ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "W", AxisValue = machine_j[5].ToString() });
|
||||
|
||||
var payloadInfoStr = MesWorkForm.Make_DeviceInfo(new List<DeviceInfo>() { deviceInfo });
|
||||
|
||||
DateTime current = DateTime.Now;
|
||||
if ((current - start).TotalMilliseconds > 1000)
|
||||
{
|
||||
// if (payloadInfoStr_Old != payloadInfoStr)
|
||||
{
|
||||
payloadInfoStr_Old = payloadInfoStr;
|
||||
MesWorkForm.SendMsg(payloadInfoStr);
|
||||
}
|
||||
start = current;
|
||||
}
|
||||
|
||||
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (isRun)
|
||||
{
|
||||
InsertStationStatusToSql();
|
||||
Thread.Sleep(60 * 1000);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void TimelyUpdate()
|
||||
{
|
||||
var sendStr = MesWorkForm.Move_Joint(Joints);
|
||||
MesWorkForm.SendMsg(sendStr);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
~B_Cnc_Edm()
|
||||
{
|
||||
DisConn();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
public void DisConn()
|
||||
{
|
||||
isRun = false;
|
||||
Thread.Sleep(199);
|
||||
edm?.Disconnect();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private void ReConnRobot()
|
||||
{
|
||||
if (edm != null)
|
||||
{
|
||||
edm?.Disconnect();
|
||||
}
|
||||
edm = new CClient();
|
||||
var success = edm.Connect(ip, (uint)port);
|
||||
if (success)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <returns></returns>
|
||||
private double[] ReadResult_To_Array()
|
||||
{
|
||||
if (MesWorkForm.IsDemoMesServer == 1)
|
||||
{
|
||||
return jDemo;
|
||||
}
|
||||
|
||||
double[] joint = new double[12];
|
||||
|
||||
var X = edm.EdmGetMachine(EnumAxisNo.X) / GetAxisDec(EnumAxisNo.X);
|
||||
var Y = edm.EdmGetMachine(EnumAxisNo.Y) / GetAxisDec(EnumAxisNo.Y);
|
||||
var Z = edm.EdmGetMachine(EnumAxisNo.Z) / GetAxisDec(EnumAxisNo.Z);
|
||||
var U = edm.EdmGetMachine(EnumAxisNo.U) / GetAxisDec(EnumAxisNo.U);
|
||||
var V = 0;
|
||||
var W = 0;
|
||||
|
||||
joint[0] = X;
|
||||
joint[1] = Y;
|
||||
joint[2] = Z;
|
||||
joint[3] = U;
|
||||
joint[4] = V;
|
||||
joint[5] = W;
|
||||
|
||||
|
||||
return joint;
|
||||
}
|
||||
|
||||
private double GetAxisDec(EnumAxisNo axis)
|
||||
{
|
||||
CPosInfo info = edm.EdmGetPosInfo(axis);
|
||||
if (info.dec == 3)
|
||||
return 1000.0;
|
||||
else if (info.dec == 4)
|
||||
return 10000.0;
|
||||
return 1000.0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动测试读取
|
||||
/// </summary>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <param name="j7"></param>
|
||||
/// <returns></returns>
|
||||
public string ReadTest(string robotName)
|
||||
{
|
||||
return "【" + robotName + "】" + MesWorkForm.Move_Joint(Joints);
|
||||
}
|
||||
|
||||
public void UpdateDataToSql()
|
||||
{
|
||||
//StoredProcedure("Event_CNC_Update");
|
||||
}
|
||||
|
||||
//private void StoredProcedure(string pName)
|
||||
//{
|
||||
// var sqlParameter = new SqlParameter[] {
|
||||
// new SqlParameter("@DeviceCode", Id),
|
||||
// new SqlParameter("@Online", OnLine.ToString()),
|
||||
// new SqlParameter("@StationName", Name),
|
||||
// new SqlParameter("@SlaveAddr", $"{ip}:{port}"),
|
||||
// new SqlParameter("@Path", 1),
|
||||
|
||||
// new SqlParameter("@程序号",0 ),
|
||||
// new SqlParameter("@程序名称", programName),
|
||||
// new SqlParameter("@主轴转速组", JsonConvert.SerializeObject(new double[6])),
|
||||
// new SqlParameter("@坐标_绝对组", JsonConvert.SerializeObject(new double[6])),
|
||||
// new SqlParameter("@坐标_相对组", JsonConvert.SerializeObject(new double[6])),
|
||||
// new SqlParameter("@坐标_机械组", JsonConvert.SerializeObject(machine_j)),
|
||||
// new SqlParameter("@伺服负载组", JsonConvert.SerializeObject(new double[6])),
|
||||
// new SqlParameter("@进给速度",0 ),
|
||||
// new SqlParameter("@进给倍率",0),
|
||||
// new SqlParameter("@主轴倍率", 0),
|
||||
// new SqlParameter("@已加工数量",0 ),
|
||||
// new SqlParameter("@总加工数量", 0),
|
||||
// new SqlParameter("@工作模式",JsonConvert.SerializeObject(new double[6] )),
|
||||
// new SqlParameter("@TM模式", 0),
|
||||
// new SqlParameter("@自动模式", 0),
|
||||
// new SqlParameter("@运行状态",0),
|
||||
// new SqlParameter("@轴_停留状态",0),
|
||||
// new SqlParameter("@matb", 0),
|
||||
// new SqlParameter("@急停", 0),
|
||||
// new SqlParameter("@报警",0 ),
|
||||
// new SqlParameter("@编辑状态", 0),
|
||||
// new SqlParameter("@开机时间", 0),
|
||||
// new SqlParameter("@运行时间", edmGetRunTime),
|
||||
// new SqlParameter("@切削时间",0 ),
|
||||
// new SqlParameter("@循环时间", 0),
|
||||
// new SqlParameter("@机床时间", 0),
|
||||
// new SqlParameter("@加工次数", 0),
|
||||
// new SqlParameter("@额定次数", 0),
|
||||
// new SqlParameter("@程序内容", progContent),
|
||||
// new SqlParameter("@刀具号", (int)toolNum_Set),
|
||||
// //北京电火花项目
|
||||
// new SqlParameter("@机床状态",(int)edmCtrlStatus),
|
||||
// new SqlParameter("@报警代码",(int)edmGetError),
|
||||
// new SqlParameter("@报警内容",edmGetErrMsg),
|
||||
// new SqlParameter("@提示代码",(int)edmGetError),
|
||||
// new SqlParameter("@提示内容",edmGetErrMsg),
|
||||
// new SqlParameter("@电流",(int)edmGetCurrent),
|
||||
// new SqlParameter("@电压",(int)edmGetVoltage),
|
||||
|
||||
|
||||
// };
|
||||
// MesWorkForm.taskSql.Enqueue(new NJ_ZC.ParamT
|
||||
// {
|
||||
// procedureName = pName,
|
||||
// sqlParameter = sqlParameter
|
||||
// });
|
||||
//}
|
||||
|
||||
|
||||
private void UpdateStationStatusToSql()
|
||||
{
|
||||
//Event_StationStatus("Event_StationStatus_Update");
|
||||
}
|
||||
private void InsertStationStatusToSql()
|
||||
{
|
||||
//Event_StationStatus("Event_StationStatus_Insert");
|
||||
}
|
||||
|
||||
//public void Event_StationStatus(string pName)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// var ChangeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
|
||||
// MesWorkForm.taskSql.Enqueue(new NJ_ZC.ParamT
|
||||
// {
|
||||
// procedureName = pName,
|
||||
// sqlParameter = new SqlParameter[] {
|
||||
// new SqlParameter("@OpName", Name),
|
||||
// new SqlParameter("@Status", (int)edmCtrlStatus),
|
||||
// new SqlParameter("@ChangeTime",ChangeTime)
|
||||
// }
|
||||
// });
|
||||
|
||||
// }
|
||||
// catch (Exception err)
|
||||
// {
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
148
DT_SCADA/Core/B_DeviceState.cs
Normal file
148
DT_SCADA/Core/B_DeviceState.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using Opc.Ua;
|
||||
using OpcBasic;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Threading;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
namespace MesWork
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class B_DeviceState
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int interval = 0;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int intervalUpdate = 0;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int intervalInsert = 0;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string opName = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public ConcurrentDictionary<string, object> cd_OpNameGroupData = new ConcurrentDictionary<string, object>();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="interval"></param>
|
||||
/// <param name="intervalUpdate"></param>
|
||||
/// <param name="modelCode"></param>
|
||||
/// <param name="opName"></param>
|
||||
public B_DeviceState(int interval, int intervalUpdate, int intervalInsert, string opName)
|
||||
{
|
||||
this.interval = interval;
|
||||
this.intervalUpdate = intervalUpdate;
|
||||
this.intervalInsert = intervalInsert;
|
||||
this.opName = opName;
|
||||
}
|
||||
public void Start()
|
||||
{
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
cd_OpNameGroupData = MesWorkForm.ReadPLC_GroupData(opName);
|
||||
}
|
||||
catch (Exception err) { }
|
||||
Thread.Sleep(interval);
|
||||
}
|
||||
})) { IsBackground = true }.Start();
|
||||
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
UpdateDataToSql();
|
||||
Thread.Sleep(intervalUpdate);
|
||||
}
|
||||
})){ IsBackground = true }.Start();
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
InsertDataToSql();
|
||||
Thread.Sleep(intervalInsert);
|
||||
}
|
||||
})){ IsBackground = true }.Start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void UpdateDataToSql()
|
||||
{
|
||||
StoredProcedure("Event_Device_Update_CurrInfo");
|
||||
}
|
||||
private void InsertDataToSql()
|
||||
{
|
||||
StoredProcedure("Event_Device_Insert_CurrInfo");
|
||||
}
|
||||
|
||||
public void StoredProcedure(string pName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ChangeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
|
||||
foreach (KeyValuePair<string, object> item in cd_OpNameGroupData)
|
||||
{
|
||||
var TF = (TagFormat)item.Value;
|
||||
|
||||
var TagTypeCodeID = TF.TagTypeCodeID;
|
||||
var TagOrderBy = TF.TagOrderBy;
|
||||
var ItemName = TF.ItemName;
|
||||
var TagValue = TF.TagValue.ToString();
|
||||
var TagID = TF.TagID;
|
||||
|
||||
if (TagTypeCodeID < 1000 | TagTypeCodeID >= 40000)
|
||||
{
|
||||
|
||||
//MesWorkForm.taskSql.Enqueue(new NJ_ZC.ParamT
|
||||
//{
|
||||
// procedureName = pName,
|
||||
// sqlParameter = new SqlParameter[] {
|
||||
// new SqlParameter("@OpName", opName),
|
||||
// new SqlParameter("@TagTypeCodeID", TagTypeCodeID),
|
||||
// new SqlParameter("@TagOrderBy", TagOrderBy),
|
||||
// new SqlParameter("@ItemName", ItemName),
|
||||
// new SqlParameter("@TagValue", TagValue),
|
||||
// new SqlParameter("@ChangeTime",ChangeTime),
|
||||
// new SqlParameter("@TagID", TagID)
|
||||
// }
|
||||
//});
|
||||
//var sendStr2 = MesWorkForm.MachineQtyDataInfo("C_B_QtyInfo", opName, TagID, TagValue);
|
||||
//MesWorkForm.SendMsg(sendStr2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
188
DT_SCADA/Core/B_Read_N_Axis.cs
Normal file
188
DT_SCADA/Core/B_Read_N_Axis.cs
Normal file
@@ -0,0 +1,188 @@
|
||||
using Opc.Ua;
|
||||
using OpcBasic;
|
||||
using Robot.Common;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public partial class Temp { }
|
||||
public partial class B_Read_N_Axis
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string sendStr_Temp = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string opName = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int axisNum = 1;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int interval = 100;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int intervalUpdate = 10000;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string Id = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string Name = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Start(int interval, int intervalUpdate ,string opName, List<JointConfig> Joints, string Id, string Name)
|
||||
{
|
||||
this.axisNum = Joints.Count;
|
||||
this.interval = interval;
|
||||
this.intervalUpdate = intervalUpdate;
|
||||
this.opName = opName;
|
||||
|
||||
|
||||
new Thread(new ThreadStart(delegate () { while (true) { try {
|
||||
|
||||
var j = Read_N_Axis(out bool success);
|
||||
if (success == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//if (j.Select(it => it == 0).Count() == j.Length)
|
||||
//{
|
||||
// continue;
|
||||
//}
|
||||
for (int i = 0; i < j.Length; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = opName;
|
||||
Joints[i].Value = j[i].ToString();
|
||||
}
|
||||
var sendStr = MesWorkForm.Move_Joint(Joints);
|
||||
if (sendStr_Temp != sendStr)
|
||||
{
|
||||
MesWorkForm.SendMsg(sendStr);
|
||||
MesWorkForm.S_C_B_Info_Fast(Joints);
|
||||
MesWorkForm.WriteLog(sendStr);
|
||||
}
|
||||
sendStr_Temp = sendStr;
|
||||
} catch (Exception err) { } Thread.Sleep(interval);
|
||||
} })).Start();
|
||||
|
||||
new Thread(new ThreadStart(delegate () { while (true) { try {
|
||||
|
||||
var j = Read_N_Axis(out bool success);
|
||||
if (success == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//if (j.Select(it => it == 0).Count() == j.Length)
|
||||
//{
|
||||
// continue;
|
||||
//}
|
||||
for (int i = 0; i < j.Length; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = opName;
|
||||
Joints[i].Value = j[i].ToString();
|
||||
}
|
||||
var sendStr = MesWorkForm.Move_Joint(Joints);
|
||||
MesWorkForm.SendMsg(sendStr);
|
||||
MesWorkForm.S_C_B_Info_Fast(Joints);
|
||||
MesWorkForm.WriteLog(sendStr);
|
||||
} catch (Exception err) { } Thread.Sleep(intervalUpdate);
|
||||
}})).Start();
|
||||
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var deviceInfo = new DeviceInfo();
|
||||
deviceInfo.order = "";
|
||||
deviceInfo.Name = Name;
|
||||
deviceInfo.Id = Id;
|
||||
|
||||
deviceInfo.Axis = new List<AxisInfo>();
|
||||
deviceInfo.OtherParameter = new List<ParameterInfo>();
|
||||
|
||||
var j = Read_N_Axis(out bool success);
|
||||
|
||||
if (success == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//if (j.Select(it => it == 0).Count() == j.Length)
|
||||
//{
|
||||
// continue;
|
||||
//}
|
||||
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "J1", AxisValue = Math.Round(j[0], 2).ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "J2", AxisValue = Math.Round(j[1], 2).ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "J3", AxisValue = Math.Round(j[2], 2).ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "J4", AxisValue = Math.Round(j[3], 2).ToString() });
|
||||
|
||||
var payloadInfoStr = MesWorkForm.Make_DeviceInfo(new List<DeviceInfo>() { deviceInfo });
|
||||
|
||||
MesWorkForm.SendMsg(payloadInfoStr);
|
||||
|
||||
Thread.Sleep(300);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public double[] Read_N_Axis(out bool success)
|
||||
{
|
||||
success = true;
|
||||
double[] p = new double[this.axisNum];
|
||||
|
||||
var jointArray = MesWorkForm.ReadPLC_GroupData(this.opName);
|
||||
if (axisNum != jointArray.Count)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
var listFalse = new List<bool>();
|
||||
foreach (KeyValuePair<string, object> item in jointArray)
|
||||
{
|
||||
var TF = (TagFormat)item.Value;
|
||||
var index = Convert.ToInt32(TF.ShaftID);
|
||||
var value = Convert.ToDouble(TF.TagValue);
|
||||
switch (value)
|
||||
{
|
||||
case -1:
|
||||
case -2:
|
||||
case -5:
|
||||
case 100:
|
||||
listFalse.Add(false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
p[index] = value;
|
||||
}
|
||||
if (listFalse.Count() > 0)
|
||||
{
|
||||
success = false;
|
||||
return p;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
160
DT_SCADA/Core/B_Read_N_AxisCard.cs
Normal file
160
DT_SCADA/Core/B_Read_N_AxisCard.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using NPOI.XSSF.Streaming.Values;
|
||||
using Opc.Ua;
|
||||
using OpcBasic;
|
||||
using Robot.Common;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public class B_Read_N_AxisCard
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string sendStr_Temp = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string opName = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int axisNum = 1;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int interval = 100;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int intervalUpdate = 10000;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Start(int interval, int intervalUpdate ,string opName, List<JointConfig> Joints)
|
||||
{
|
||||
this.axisNum = Joints.Count;
|
||||
this.interval = interval;
|
||||
this.intervalUpdate = intervalUpdate;
|
||||
this.opName = opName;
|
||||
|
||||
|
||||
new Thread(new ThreadStart(delegate () { while (true) { try {
|
||||
|
||||
var j = Read_N_Axis();
|
||||
for (int i = 0; i < j.Length; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = opName;
|
||||
Joints[i].Value = j[i].ToString();
|
||||
}
|
||||
var sendStr = MesWorkForm.Move_Joint(Joints);
|
||||
if (sendStr_Temp != sendStr)
|
||||
{
|
||||
MesWorkForm.SendMsg(sendStr);
|
||||
MesWorkForm.S_C_B_Info_Fast(Joints);
|
||||
}
|
||||
sendStr_Temp = sendStr;
|
||||
} catch (Exception err) { } Thread.Sleep(interval);
|
||||
} })).Start();
|
||||
|
||||
new Thread(new ThreadStart(delegate () { while (true) { try {
|
||||
|
||||
var j = Read_N_Axis();
|
||||
for (int i = 0; i < j.Length; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = opName;
|
||||
Joints[i].Value = j[i].ToString();
|
||||
}
|
||||
var sendStr = MesWorkForm.Move_Joint(Joints);
|
||||
MesWorkForm.SendMsg(sendStr);
|
||||
MesWorkForm.S_C_B_Info_Fast(Joints);
|
||||
} catch (Exception err) { } Thread.Sleep(intervalUpdate);
|
||||
}})).Start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//public double[] Read_N_Axis()
|
||||
//{
|
||||
// double[] p = new double[this.axisNum];
|
||||
|
||||
// var x1 = Convert.ToDouble(MesWorkForm.ReadPLC(101, this.opName).ToString());
|
||||
// var x2 = Convert.ToDouble(MesWorkForm.ReadPLC(102, this.opName).ToString());
|
||||
// var y1 = Convert.ToDouble(MesWorkForm.ReadPLC(201, this.opName).ToString());
|
||||
// var y2 = Convert.ToDouble(MesWorkForm.ReadPLC(202, this.opName).ToString());
|
||||
// var z1 = Convert.ToDouble(MesWorkForm.ReadPLC(301, this.opName).ToString());
|
||||
// var z2 = Convert.ToDouble(MesWorkForm.ReadPLC(302, this.opName).ToString());
|
||||
|
||||
// p[0] = x1 + x2 * 0.001;
|
||||
// p[1] = y1 + y2 * 0.001;
|
||||
// p[2] = z1 + z2 * 0.001;
|
||||
|
||||
// return p;
|
||||
//}
|
||||
|
||||
public double[] Read_N_Axis()
|
||||
{
|
||||
double[] p = new double[this.axisNum];
|
||||
|
||||
//var x1 = Convert.ToDouble(MesWorkForm.ReadPLC(101, this.opName).ToString());
|
||||
//var x2 = Convert.ToDouble(MesWorkForm.ReadPLC(102, this.opName).ToString());
|
||||
//var y1 = Convert.ToDouble(MesWorkForm.ReadPLC(201, this.opName).ToString());
|
||||
//var y2 = Convert.ToDouble(MesWorkForm.ReadPLC(202, this.opName).ToString());
|
||||
//var z1 = Convert.ToDouble(MesWorkForm.ReadPLC(301, this.opName).ToString());
|
||||
//var z2 = Convert.ToDouble(MesWorkForm.ReadPLC(302, this.opName).ToString());
|
||||
|
||||
double x1 = 0;
|
||||
double x2 = 0;
|
||||
double y1 = 0;
|
||||
double y2 = 0;
|
||||
double z1 = 0;
|
||||
double z2 = 0;
|
||||
|
||||
var jointArray = MesWorkForm.ReadPLC_GroupData(this.opName);
|
||||
foreach (KeyValuePair<string, object> item in jointArray)
|
||||
{
|
||||
var TF = (TagFormat)item.Value;
|
||||
var tagTypeCodeID = Convert.ToInt32(TF.TagTypeCodeID);
|
||||
var value = Convert.ToDouble(TF.TagValue);
|
||||
|
||||
switch (tagTypeCodeID)
|
||||
{
|
||||
case 101:
|
||||
x1 = value;
|
||||
break;
|
||||
case 102:
|
||||
x2 = value;
|
||||
break;
|
||||
case 201:
|
||||
y1 = value;
|
||||
break;
|
||||
case 202:
|
||||
y2 = value;
|
||||
break;
|
||||
case 301:
|
||||
z1 = value;
|
||||
break;
|
||||
case 302:
|
||||
z2 = value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
p[0] = x1 + x2 * 0.001;
|
||||
p[1] = y1 + y2 * 0.001;
|
||||
p[2] = z1 + z2 * 0.001;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
305
DT_SCADA/Core/B_Robot_Abb.cs
Normal file
305
DT_SCADA/Core/B_Robot_Abb.cs
Normal file
@@ -0,0 +1,305 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using ABB.Robotics.Controllers;
|
||||
using ABB.Robotics.Controllers.Discovery;
|
||||
using ABB.Robotics.Controllers.IOSystemDomain;
|
||||
using Robot.Common;
|
||||
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public class B_Robot_Abb
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private Controller abb = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool OnLine = false;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ip = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string cname = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int interval = -1;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool isRun = true;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Id = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Name = "";
|
||||
|
||||
|
||||
|
||||
public string robotWorkbench_1 = "";
|
||||
public string robotWorkbench_Old_1 = "";
|
||||
public string robotWorkbench_2 = "";
|
||||
public string robotWorkbench_Old_2 = "";
|
||||
|
||||
public string TagID_Axis_7 = "";
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double[] j = new double[12];
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double[] jDemo = new double[12];
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public List<JointConfig> Joints = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string sendStr_Old = "";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public B_Robot_Abb()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ipPort"></param>
|
||||
/// <param name="interval"></param>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <param name="modelManagement"></param>
|
||||
/// <param name="modelCode"></param>
|
||||
public void Start(string ip, string cname,int interval, int intervalUpdate, string DeviceCode, string OpName, List<JointConfig> Joints
|
||||
, string TagID_DoorOpen = "", string TagID_DoorClose = "", string TagID_Axis_7 = "")
|
||||
{
|
||||
this.ip = ip;
|
||||
this.cname = cname;
|
||||
this.interval = interval;
|
||||
this.Id = DeviceCode;
|
||||
this.Name = OpName;
|
||||
this.Joints = Joints;
|
||||
this.TagID_Axis_7 = TagID_Axis_7;
|
||||
|
||||
var robotWorkbench_1_Addr = TagID_DoorOpen.Split(',')[0];
|
||||
var robotWorkbench_1_TagID = TagID_DoorOpen.Split(',')[1];
|
||||
var robotWorkbench_2_Addr = TagID_DoorClose.Split(',')[0];
|
||||
var robotWorkbench_2_TagID = TagID_DoorClose.Split(',')[1];
|
||||
|
||||
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (isRun)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (abb == null)
|
||||
{
|
||||
ReConnRobot();
|
||||
}
|
||||
OnLine = abb.Connected;
|
||||
if (OnLine)
|
||||
{
|
||||
j = ReadResult_To_Array();
|
||||
|
||||
robotWorkbench_1 = ReadIO(robotWorkbench_1_Addr);
|
||||
if (robotWorkbench_Old_1 != robotWorkbench_1)
|
||||
{
|
||||
MesWorkForm.S_C_B_TagIDTrigger(Name, robotWorkbench_1_TagID, robotWorkbench_1);
|
||||
}
|
||||
robotWorkbench_Old_1 = robotWorkbench_1;
|
||||
|
||||
robotWorkbench_2 = ReadIO(robotWorkbench_2_Addr);
|
||||
if (robotWorkbench_Old_2 != robotWorkbench_2)
|
||||
{
|
||||
MesWorkForm.S_C_B_TagIDTrigger(Name, robotWorkbench_2_TagID, robotWorkbench_2);
|
||||
}
|
||||
robotWorkbench_Old_2 = robotWorkbench_2;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(10 * 1000);
|
||||
ReConnRobot();
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < Joints.Count ; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = DeviceCode;
|
||||
Joints[i].Value = j[i].ToString();
|
||||
}
|
||||
|
||||
var sendStr = MesWorkForm.Move_Joint(Joints);
|
||||
if (sendStr_Old != sendStr)
|
||||
{
|
||||
sendStr_Old = sendStr;
|
||||
MesWorkForm.SendMsg(sendStr);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err) { }
|
||||
Thread.Sleep(interval);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
new Thread(new ThreadStart(delegate () {
|
||||
while (isRun)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < Joints.Count; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = DeviceCode;
|
||||
Joints[i].Value = j[i].ToString();
|
||||
}
|
||||
|
||||
var sendStr = MesWorkForm.Move_Joint(Joints);
|
||||
MesWorkForm.SendMsg(sendStr);
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{ }
|
||||
Thread.Sleep(intervalUpdate);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
}
|
||||
|
||||
|
||||
private string ReadIO(string addr)
|
||||
{
|
||||
var valueStr = "";
|
||||
// using (var m = Mastership.Request(abb.Rapid))
|
||||
{
|
||||
var _d = (DigitalSignal)abb.IOSystem.GetSignal(addr);
|
||||
if (_d != null)
|
||||
{
|
||||
valueStr = _d.Value.ToString();
|
||||
}
|
||||
}
|
||||
switch (valueStr.ToLower())
|
||||
{
|
||||
case "0":
|
||||
case "false":
|
||||
valueStr = "0";
|
||||
break;
|
||||
case "1":
|
||||
case "true":
|
||||
valueStr = "1";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return valueStr;
|
||||
}
|
||||
|
||||
~B_Robot_Abb()
|
||||
{
|
||||
DisConn();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
public void DisConn()
|
||||
{
|
||||
isRun = false;
|
||||
Thread.Sleep(199);
|
||||
abb?.Logoff();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private void ReConnRobot()
|
||||
{
|
||||
if (MesWorkForm.IsDemoMesServer == 1)
|
||||
{
|
||||
//abb = ControllerFactory.CreateFrom();
|
||||
//abb.Logon(UserInfo.DefaultUser);
|
||||
abb = new Controller();
|
||||
return;
|
||||
}
|
||||
|
||||
if (abb != null)
|
||||
{
|
||||
abb?.Logoff();
|
||||
abb = null;
|
||||
}
|
||||
|
||||
var scanner = new NetworkScanner();
|
||||
var controllers = scanner.GetControllers();
|
||||
foreach (var controllerInfo in controllers)
|
||||
{
|
||||
if (controllerInfo.IPAddress.ToString() == ip & controllerInfo.SystemName == cname)
|
||||
{
|
||||
abb = ControllerFactory.CreateFrom(controllerInfo);
|
||||
abb.Logon(UserInfo.DefaultUser);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <returns></returns>
|
||||
private double[] ReadResult_To_Array()
|
||||
{
|
||||
|
||||
if (MesWorkForm.IsDemoMesServer == 1)
|
||||
{
|
||||
return jDemo;
|
||||
}
|
||||
float j7 = 0f;
|
||||
try
|
||||
{
|
||||
j7 = Convert.ToSingle(MesWorkForm.ReadPLC(TagID_Axis_7).ToString());
|
||||
|
||||
}
|
||||
catch (Exception err )
|
||||
{
|
||||
}
|
||||
|
||||
var joint = new double[12];
|
||||
var currJoint = abb.MotionSystem.ActiveMechanicalUnit.GetPosition();
|
||||
joint[0] = currJoint.RobAx.Rax_1;
|
||||
joint[1] = currJoint.RobAx.Rax_2;
|
||||
joint[2] = currJoint.RobAx.Rax_3;
|
||||
joint[3] = currJoint.RobAx.Rax_4;
|
||||
joint[4] = currJoint.RobAx.Rax_5;
|
||||
joint[5] = currJoint.RobAx.Rax_6;
|
||||
joint[6] = j7;
|
||||
|
||||
return joint;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
418
DT_SCADA/Core/B_Robot_Espon.cs
Normal file
418
DT_SCADA/Core/B_Robot_Espon.cs
Normal file
@@ -0,0 +1,418 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using HslCommunication.Robot.FANUC;
|
||||
using HslCommunication.Robot.KUKA;
|
||||
using System.Net.Sockets;
|
||||
using Org.BouncyCastle.Bcpg;
|
||||
using System.Text;
|
||||
using Adapters;
|
||||
using static Focas1;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public class B_Robot_Espon
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private Socket espon = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool OnLine = false;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ip = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int port = -1;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int interval = -1;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool isRun = true;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string sendV_Temp = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double[] j = new double[12];
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double[] jDemo = new double[12];
|
||||
/// <summary>
|
||||
/// 记录老值
|
||||
/// </summary>
|
||||
string axis_act_Old = "-1";
|
||||
/// <summary>
|
||||
/// 焊接中
|
||||
/// </summary>
|
||||
public string clamp_Old = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string clamp = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Id = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Name = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public List<JointConfig> Joints = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string md5Pos = "";
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public B_Robot_Espon()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ipPort"></param>
|
||||
/// <param name="interval"></param>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <param name="modelManagement"></param>
|
||||
/// <param name="modelCode"></param>
|
||||
public void Start(string ip, int port,int interval, int intervalUpdate, string DeviceCode, string OpName, List<JointConfig> Joints,string TagID_Clamp)
|
||||
{
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
this.interval = interval;
|
||||
this.Id = DeviceCode;
|
||||
this.Name = OpName;
|
||||
this.Joints = Joints;
|
||||
var dataRec = new byte[1024 * 1024];
|
||||
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (isRun)
|
||||
{
|
||||
try
|
||||
{
|
||||
int readlen = 0;
|
||||
if (espon == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
espon.ReceiveTimeout = 5000;
|
||||
readlen = espon.Receive(dataRec, 0, dataRec.Length, SocketFlags.None);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (readlen <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var str = Encoding.Default.GetString(dataRec, 0, readlen);
|
||||
|
||||
j = ReadResult_To_Array(str, out string clamp);
|
||||
|
||||
if (clamp_Old != clamp)
|
||||
{
|
||||
MesWorkForm.S_C_B_TagIDTrigger(OpName, TagID_Clamp, clamp);
|
||||
}
|
||||
clamp_Old = clamp;
|
||||
|
||||
for (int i = 0; i < Joints.Count; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = $"ROBOT_ESPON_{ip.Split('.')[3]}";
|
||||
Joints[i].Value = j[i].ToString();
|
||||
}
|
||||
|
||||
var payload = MesWorkForm.Move_Joint(Joints);
|
||||
var md5Str = JsonConvert.SerializeObject(payload);
|
||||
if (md5Pos != md5Str)
|
||||
{
|
||||
md5Pos = md5Str;
|
||||
MesWorkForm.SendMsg(payload);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception err) { }
|
||||
Thread.Sleep(15);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (isRun)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (MesWorkForm.IsDemoMesServer == 1)
|
||||
{
|
||||
j = jDemo;
|
||||
OnLine = true;
|
||||
continue;
|
||||
}
|
||||
if (espon == null)
|
||||
{
|
||||
ReConnRobot();
|
||||
}
|
||||
var data = Encoding.Default.GetBytes("1");
|
||||
espon.Send(data, 0, data.Length, SocketFlags.None);
|
||||
OnLine = true;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
OnLine = false;
|
||||
Thread.Sleep(2000);
|
||||
ReConnRobot();
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err) { }
|
||||
Thread.Sleep(interval);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
|
||||
new Thread(new ThreadStart(delegate () {
|
||||
while (isRun)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < Joints.Count; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = $"ROBOT_ESPON_{ip.Split('.')[3]}";
|
||||
Joints[i].Value = j[i].ToString();
|
||||
}
|
||||
|
||||
var payload = MesWorkForm.Move_Joint(Joints);
|
||||
MesWorkForm.SendMsg(payload);//FANUC机床的轴位置
|
||||
|
||||
UpdateDataToSql();
|
||||
}
|
||||
catch (Exception err)
|
||||
{ }
|
||||
Thread.Sleep(intervalUpdate);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (isRun)
|
||||
{
|
||||
var deviceInfo = new DeviceInfo();
|
||||
deviceInfo.order = "";
|
||||
deviceInfo.Name = Name;
|
||||
deviceInfo.Id = Id;
|
||||
|
||||
deviceInfo.Axis = new List<AxisInfo>();
|
||||
deviceInfo.OtherParameter = new List<ParameterInfo>();
|
||||
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "J1", AxisValue = Math.Round(j[0], 2).ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "J2", AxisValue = Math.Round(j[1], 2).ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "J3", AxisValue = Math.Round(j[2], 2).ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "J4", AxisValue = Math.Round(j[3], 2).ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "J5", AxisValue = Math.Round(j[4], 2).ToString() });
|
||||
deviceInfo.Axis.Add(new AxisInfo() { AxisName = "J6", AxisValue = Math.Round(j[5], 2).ToString() });
|
||||
|
||||
var payloadInfoStr = MesWorkForm.Make_DeviceInfo(new List<DeviceInfo>() { deviceInfo });
|
||||
|
||||
MesWorkForm.SendMsg(payloadInfoStr);
|
||||
|
||||
Thread.Sleep(300);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void TimelyUpdate()
|
||||
{
|
||||
var sendStr = MesWorkForm.Move_Joint(Joints);
|
||||
MesWorkForm.SendMsg(sendStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
~B_Robot_Espon()
|
||||
{
|
||||
DisConn();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
public void DisConn()
|
||||
{
|
||||
isRun = false;
|
||||
Thread.Sleep(199);
|
||||
espon?.Close();
|
||||
espon = null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <returns></returns>
|
||||
private void ReConnRobot()
|
||||
{
|
||||
if (MesWorkForm.IsDemoMesServer == 1)
|
||||
{
|
||||
espon = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (espon != null)
|
||||
{
|
||||
espon?.Close();
|
||||
espon = null;
|
||||
}
|
||||
espon = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
espon.Connect(ip, port);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <returns></returns>
|
||||
private double[] ReadResult_To_Array(string readResult,out string clamp)
|
||||
{
|
||||
clamp = "-1";
|
||||
|
||||
var joint = new double[12];
|
||||
var jStr = readResult.Split(',');
|
||||
|
||||
joint[0] = Math.Round(Convert.ToDouble(jStr[0]), 2);
|
||||
joint[1] = Math.Round(Convert.ToDouble(jStr[1]), 2);
|
||||
joint[2] = Math.Round(Convert.ToDouble(jStr[2]), 2);
|
||||
joint[3] = Math.Round(Convert.ToDouble(jStr[3]), 2);
|
||||
joint[4] = Math.Round(Convert.ToDouble(jStr[4]), 2);
|
||||
joint[5] = Math.Round(Convert.ToDouble(jStr[5]), 2);
|
||||
|
||||
clamp = jStr[6];
|
||||
|
||||
return joint;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 读取数据
|
||||
/// </summary>
|
||||
/// <param name="addr"></param>
|
||||
/// <returns></returns>
|
||||
public string Read_Welding(string addr)
|
||||
{
|
||||
string str = "-1";
|
||||
//if (kuka != null)
|
||||
//{
|
||||
// var r = kuka.ReadString(addr);
|
||||
// if (r.IsSuccess)
|
||||
// {
|
||||
// str = r.Content;
|
||||
// }
|
||||
//}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动测试读取
|
||||
/// </summary>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <param name="j7"></param>
|
||||
/// <returns></returns>
|
||||
public string ReadTest(string robotName)
|
||||
{
|
||||
return "【" + robotName + "】" + MesWorkForm.Move_Joint(Joints);
|
||||
}
|
||||
|
||||
public void UpdateDataToSql()
|
||||
{
|
||||
StoredProcedure("Event_Robot_Update");
|
||||
}
|
||||
private void StoredProcedure(string pName)
|
||||
{
|
||||
//var sqlParameter = new SqlParameter[] {
|
||||
// new SqlParameter("@DeviceCode", DeviceCode),
|
||||
// new SqlParameter("@Online", OnLine),
|
||||
// new SqlParameter("@StationName", OpName),
|
||||
// new SqlParameter("@SlaveAddr", $"{ip}:{port}"),
|
||||
|
||||
// new SqlParameter("@Joint1", j[0]),
|
||||
// new SqlParameter("@Joint2", j[1]),
|
||||
// new SqlParameter("@Joint3", j[2]),
|
||||
|
||||
// new SqlParameter("@Joint4", j[3]),
|
||||
// new SqlParameter("@Joint5", j[4]),
|
||||
// new SqlParameter("@Joint6", j[5]),
|
||||
|
||||
// new SqlParameter("@Joint7", j[6]),
|
||||
// new SqlParameter("@Joint8", j[7]),
|
||||
// new SqlParameter("@Joint9", j[8]),
|
||||
|
||||
// new SqlParameter("@Joint10",j[9]),
|
||||
// new SqlParameter("@Joint11",j[10]),
|
||||
// new SqlParameter("@Joint12",j[11]),
|
||||
// new SqlParameter("@Clamp", welding)
|
||||
// };
|
||||
//MesWorkForm.taskSql.Enqueue(new NJ_ZC.ParamT
|
||||
//{
|
||||
// procedureName = pName,
|
||||
// sqlParameter = sqlParameter
|
||||
//});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
409
DT_SCADA/Core/B_Robot_Fanuc.cs
Normal file
409
DT_SCADA/Core/B_Robot_Fanuc.cs
Normal file
@@ -0,0 +1,409 @@
|
||||
using HslCommunication.Robot.FANUC;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Threading;
|
||||
using static Focas1;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public partial class Temp { }
|
||||
public partial class B_Robot_Fanuc
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private FanucInterfaceNet fanuc = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool OnLine = false;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private string ip = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private int port = -1;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private int interval = -1;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private bool isRun = true;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private string cmd = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private string cmd_Welding = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string sendV_Temp = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double[] j = new double[12];
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double[] jDemo = new double[12];
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string DeviceCode = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string OpName = "";
|
||||
/// <summary>
|
||||
/// 焊接中
|
||||
/// </summary>
|
||||
int welding = 0;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Id = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string Name = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
List<JointConfig> Joints = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string md5Pos = "";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public B_Robot_Fanuc()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <param name="interval"></param>
|
||||
/// <param name="intervalUpdate"></param>
|
||||
/// <param name="cmd"></param>
|
||||
/// <param name="cmd_Welding"></param>
|
||||
/// <param name="Id"></param>
|
||||
/// <param name="Name"></param>
|
||||
/// <param name="Joints"></param>
|
||||
public void Start(string ip, int port, int interval, int intervalUpdate, string cmd, string cmd_Welding, string Id, string Name, List<JointConfig> Joints)
|
||||
{
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
this.interval = interval;
|
||||
this.cmd = cmd;
|
||||
this.cmd_Welding = cmd_Welding;
|
||||
this.Id = Id;
|
||||
this.Name = Name;
|
||||
this.Joints = Joints;
|
||||
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (isRun)
|
||||
{
|
||||
try
|
||||
{
|
||||
//var weldingStr = Read_Welding(cmd_Welding);
|
||||
//switch (weldingStr.ToLower())
|
||||
//{
|
||||
// case "1":
|
||||
// case "true":
|
||||
// welding = 1;
|
||||
// break;
|
||||
// default:
|
||||
// welding = 0;
|
||||
// break;
|
||||
//}
|
||||
|
||||
if (fanuc == null)
|
||||
{
|
||||
ReConnRobot();
|
||||
}
|
||||
var r = fanuc.ReadString(cmd);
|
||||
OnLine = r.IsSuccess;
|
||||
if (OnLine)
|
||||
{
|
||||
j = ReadResult_To_Array(r.Content);
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(10 * 1000);
|
||||
ReConnRobot();
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Joints.Count; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = $"ROBOT_FANUC_{ip.Split('.')[3]}";
|
||||
Joints[i].Value = j[i].ToString();
|
||||
}
|
||||
//Joints[0].Value = j[0].ToString();
|
||||
//Joints[1].Value = j[1].ToString();
|
||||
//Joints[2].Value = j[2].ToString();
|
||||
//Joints[3].Value = j[3].ToString();
|
||||
//Joints[4].Value = j[4].ToString();
|
||||
//Joints[5].Value = j[5].ToString();
|
||||
//Joints[6].Value = j[6].ToString();
|
||||
|
||||
var payload = MesWorkForm.Move_Joint(Joints);
|
||||
var md5Str = JsonConvert.SerializeObject(payload);
|
||||
if (md5Pos != md5Str)
|
||||
{
|
||||
md5Pos = md5Str;
|
||||
MesWorkForm.SendMsg(payload);//FANUC机床的轴位置
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err) { }
|
||||
Thread.Sleep(interval);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
new Thread(new ThreadStart(delegate () {
|
||||
while (isRun)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
for (int i = 0; i < Joints.Count; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = $"ROBOT_FANUC_{ip.Split('.')[3]}";
|
||||
Joints[i].Value = j[i].ToString();
|
||||
}
|
||||
//Joints[0].Value = j[0].ToString();
|
||||
//Joints[1].Value = j[1].ToString();
|
||||
//Joints[2].Value = j[2].ToString();
|
||||
//Joints[3].Value = j[3].ToString();
|
||||
//Joints[4].Value = j[4].ToString();
|
||||
//Joints[5].Value = j[5].ToString();
|
||||
//Joints[6].Value = j[6].ToString();
|
||||
|
||||
var payload = MesWorkForm.Move_Joint(Joints);
|
||||
MesWorkForm.SendMsg(payload);//FANUC机床的轴位置
|
||||
|
||||
UpdateDataToSql();
|
||||
}
|
||||
catch (Exception err) { }
|
||||
Thread.Sleep(intervalUpdate);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
}
|
||||
|
||||
public void TimelyUpdate()
|
||||
{
|
||||
var sendStr = MesWorkForm.Move_Joint(Joints);
|
||||
MesWorkForm.SendMsg(sendStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
~B_Robot_Fanuc()
|
||||
{
|
||||
FanucClose();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
public void FanucClose()
|
||||
{
|
||||
isRun = false;
|
||||
Thread.Sleep(199);
|
||||
fanuc?.ConnectClose();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <returns></returns>
|
||||
private void ReConnRobot()
|
||||
{
|
||||
if (MesWorkForm.IsDemoMesServer == 1)
|
||||
{
|
||||
fanuc = new FanucInterfaceNet();
|
||||
return;
|
||||
}
|
||||
|
||||
if (fanuc != null)
|
||||
{
|
||||
fanuc?.ConnectClose();
|
||||
}
|
||||
fanuc = new FanucInterfaceNet();
|
||||
fanuc.IpAddress = ip;
|
||||
fanuc.Port = port;
|
||||
var connect = fanuc.ConnectServer();
|
||||
if (connect.IsSuccess)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
public void DisConn()
|
||||
{
|
||||
if (fanuc != null)
|
||||
{
|
||||
fanuc?.ConnectClose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <returns></returns>
|
||||
private double[] ReadResult_To_Array(string readResult)
|
||||
{
|
||||
if (MesWorkForm.IsDemoMesServer == 1)
|
||||
{
|
||||
return jDemo;
|
||||
}
|
||||
|
||||
double[] joint = new double[12];
|
||||
|
||||
var recdata = readResult;
|
||||
var jsc = ((JObject)JsonConvert.DeserializeObject(recdata))["Joint"];
|
||||
joint[0] = Convert.ToDouble(jsc[0]);
|
||||
joint[1] = Convert.ToDouble(jsc[1]);
|
||||
joint[2] = Convert.ToDouble(jsc[2]);
|
||||
joint[3] = Convert.ToDouble(jsc[3]);
|
||||
joint[4] = Convert.ToDouble(jsc[4]);
|
||||
joint[5] = Convert.ToDouble(jsc[5]);
|
||||
joint[6] = Convert.ToDouble(jsc[6]);
|
||||
joint[7] = Convert.ToDouble(jsc[7]);
|
||||
joint[8] = Convert.ToDouble(jsc[8]);
|
||||
|
||||
joint[9] = Convert.ToDouble(0);
|
||||
joint[10] = Convert.ToDouble(0);
|
||||
joint[11] = Convert.ToDouble(0);
|
||||
|
||||
joint = new double[]
|
||||
{
|
||||
//Math.Round(Convert.ToDouble(joint[0])*Math.PI/180,4),
|
||||
//Math.Round(Convert.ToDouble(joint[1])*Math.PI/180,4),
|
||||
//Math.Round(( Convert.ToDouble(joint[2])+ Convert.ToDouble(joint[1]))*Math.PI/180 ,4),
|
||||
//Math.Round(Convert.ToDouble(joint[3])*Math.PI/180,4),
|
||||
//Math.Round(Convert.ToDouble(joint[4])*Math.PI/180,4),
|
||||
//Math.Round(Convert.ToDouble(joint[5])*Math.PI/180,4),
|
||||
//Convert.ToDouble(joint[6])/1000,
|
||||
//Convert.ToDouble(joint[7])/1000,
|
||||
//Convert.ToDouble(joint[8])/1000
|
||||
|
||||
Math.Round(Convert.ToDouble(joint[0]),2),
|
||||
Math.Round(Convert.ToDouble(joint[1]),2),
|
||||
Math.Round((Convert.ToDouble(joint[2])+ Convert.ToDouble(joint[1])) ,2),
|
||||
Math.Round(Convert.ToDouble(joint[3]),2),
|
||||
Math.Round(Convert.ToDouble(joint[4]),2),
|
||||
Math.Round(Convert.ToDouble(joint[5]),2),
|
||||
Convert.ToDouble(joint[6])/1000,
|
||||
Convert.ToDouble(joint[7])/1000,
|
||||
Convert.ToDouble(joint[8])/1000,
|
||||
Convert.ToDouble(joint[9]),
|
||||
Convert.ToDouble(joint[10]),
|
||||
Convert.ToDouble(joint[11])
|
||||
};
|
||||
|
||||
|
||||
return joint;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 读取数据
|
||||
/// </summary>
|
||||
/// <param name="addr"></param>
|
||||
/// <returns></returns>
|
||||
public string Read_Welding(string addr)
|
||||
{
|
||||
string str = "-1";
|
||||
//if (kuka != null)
|
||||
//{
|
||||
// var r = kuka.ReadString(addr);
|
||||
// if (r.IsSuccess)
|
||||
// {
|
||||
// str = r.Content;
|
||||
// }
|
||||
//}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动测试读取
|
||||
/// </summary>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <param name="j7"></param>
|
||||
/// <returns></returns>
|
||||
public string ReadTest(string robotName)
|
||||
{
|
||||
return "【" + robotName + "】" + MesWorkForm.Move_Joint(Joints);
|
||||
}
|
||||
|
||||
public void UpdateDataToSql()
|
||||
{
|
||||
StoredProcedure("Event_Robot_Update");
|
||||
}
|
||||
private void StoredProcedure(string pName)
|
||||
{
|
||||
//var sqlParameter = new SqlParameter[] {
|
||||
// new SqlParameter("@DeviceCode", DeviceCode),
|
||||
// new SqlParameter("@Online", OnLine),
|
||||
// new SqlParameter("@StationName", OpName),
|
||||
// new SqlParameter("@SlaveAddr", $"{ip}:{port}"),
|
||||
|
||||
// new SqlParameter("@Joint1", j[0]),
|
||||
// new SqlParameter("@Joint2", j[1]),
|
||||
// new SqlParameter("@Joint3", j[2]),
|
||||
|
||||
// new SqlParameter("@Joint4", j[3]),
|
||||
// new SqlParameter("@Joint5", j[4]),
|
||||
// new SqlParameter("@Joint6", j[5]),
|
||||
|
||||
// new SqlParameter("@Joint7", j[6]),
|
||||
// new SqlParameter("@Joint8", j[7]),
|
||||
// new SqlParameter("@Joint9", j[8]),
|
||||
|
||||
// new SqlParameter("@Joint10",j[9]),
|
||||
// new SqlParameter("@Joint11",j[10]),
|
||||
// new SqlParameter("@Joint12",j[11]),
|
||||
// new SqlParameter("@Clamp", welding)
|
||||
// };
|
||||
//MesWorkForm.taskSql.Enqueue(new NJ_ZC.ParamT
|
||||
//{
|
||||
// procedureName = pName,
|
||||
// sqlParameter = sqlParameter
|
||||
//});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
386
DT_SCADA/Core/B_Robot_Kuka.cs
Normal file
386
DT_SCADA/Core/B_Robot_Kuka.cs
Normal file
@@ -0,0 +1,386 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using HslCommunication.Robot.FANUC;
|
||||
using HslCommunication.Robot.KUKA;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public partial class Temp { }
|
||||
public partial class B_Robot_Kuka
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private KukaAvarProxyNet kuka = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool OnLine = false;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private string ip = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private int port = -1;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private int interval = -1;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private bool isRun = true;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private string cmd = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private string cmd_Welding = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string sendV_Temp = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double[] j = new double[12];
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double[] jDemo = new double[12];
|
||||
/// <summary>
|
||||
/// 记录老值
|
||||
/// </summary>
|
||||
string axis_act_Old = "-1";
|
||||
/// <summary>
|
||||
/// 焊接中
|
||||
/// </summary>
|
||||
int welding = 0;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Id = "-1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string Name = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public List<JointConfig> Joints = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string md5Pos = "";
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public B_Robot_Kuka()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ipPort"></param>
|
||||
/// <param name="interval"></param>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <param name="modelManagement"></param>
|
||||
/// <param name="modelCode"></param>
|
||||
public void Start(string ip, int port,int interval, int intervalUpdate, string cmd, string cmd_Welding, string DeviceCode, string OpName, List<JointConfig> Joints)
|
||||
{
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
this.interval = interval;
|
||||
this.cmd = cmd;
|
||||
this.cmd_Welding = cmd_Welding;
|
||||
this.Id = DeviceCode;
|
||||
this.Name = OpName;
|
||||
this.Joints = Joints;
|
||||
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (isRun)
|
||||
{
|
||||
try
|
||||
{
|
||||
//var weldingStr = Read_Welding(cmd_Welding);
|
||||
//switch (weldingStr.ToLower())
|
||||
//{
|
||||
// case "1":
|
||||
// case "true":
|
||||
// welding = 1;
|
||||
// break;
|
||||
// default:
|
||||
// welding = 0;
|
||||
// break;
|
||||
//}
|
||||
|
||||
if (kuka == null)
|
||||
{
|
||||
ReConnRobot();
|
||||
}
|
||||
var r = kuka.ReadString(cmd);
|
||||
OnLine = r.IsSuccess;
|
||||
if (OnLine)
|
||||
{
|
||||
j = ReadResult_To_Array(r.Content);
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(10 * 1000);
|
||||
ReConnRobot();
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < Joints.Count ; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = $"ROBOT_KUKA_{ip.Split('.')[3]}";
|
||||
Joints[i].Value = j[i].ToString();
|
||||
}
|
||||
//Joints[0].Value = j[0].ToString();
|
||||
//Joints[1].Value = j[1].ToString();
|
||||
//Joints[2].Value = j[2].ToString();
|
||||
//Joints[3].Value = j[3].ToString();
|
||||
//Joints[4].Value = j[4].ToString();
|
||||
//Joints[5].Value = j[5].ToString();
|
||||
//Joints[6].Value = j[6].ToString();
|
||||
|
||||
var payload = MesWorkForm.Move_Joint(Joints);
|
||||
var md5Str = JsonConvert.SerializeObject(payload);
|
||||
if (md5Pos != md5Str)
|
||||
{
|
||||
md5Pos = md5Str;
|
||||
MesWorkForm.SendMsg(payload);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err) { }
|
||||
Thread.Sleep(interval);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
new Thread(new ThreadStart(delegate () {
|
||||
while (isRun)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < Joints.Count; i++)
|
||||
{
|
||||
Joints[i].DeviceCode = $"ROBOT_KUKA_{ip.Split('.')[3]}";
|
||||
Joints[i].Value = j[i].ToString();
|
||||
}
|
||||
//Joints[0].Value = j[0].ToString();
|
||||
//Joints[1].Value = j[1].ToString();
|
||||
//Joints[2].Value = j[2].ToString();
|
||||
//Joints[3].Value = j[3].ToString();
|
||||
//Joints[4].Value = j[4].ToString();
|
||||
//Joints[5].Value = j[5].ToString();
|
||||
//Joints[6].Value = j[6].ToString();
|
||||
|
||||
var payload = MesWorkForm.Move_Joint(Joints);
|
||||
MesWorkForm.SendMsg(payload);//FANUC机床的轴位置
|
||||
|
||||
UpdateDataToSql();
|
||||
}
|
||||
catch (Exception err)
|
||||
{ }
|
||||
Thread.Sleep(intervalUpdate);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
|
||||
}
|
||||
|
||||
public void TimelyUpdate()
|
||||
{
|
||||
var sendStr = MesWorkForm.Move_Joint(Joints);
|
||||
MesWorkForm.SendMsg(sendStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
~B_Robot_Kuka()
|
||||
{
|
||||
DisConn();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
public void DisConn()
|
||||
{
|
||||
isRun = false;
|
||||
Thread.Sleep(199);
|
||||
kuka?.ConnectClose();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <returns></returns>
|
||||
private void ReConnRobot()
|
||||
{
|
||||
if (MesWorkForm.IsDemoMesServer == 1)
|
||||
{
|
||||
kuka = new KukaAvarProxyNet();
|
||||
return;
|
||||
}
|
||||
|
||||
if (kuka != null)
|
||||
{
|
||||
kuka?.ConnectClose();
|
||||
}
|
||||
kuka = new KukaAvarProxyNet();
|
||||
kuka.IpAddress = ip;
|
||||
kuka.Port = port;
|
||||
var connect = kuka.ConnectServer();
|
||||
if (connect.IsSuccess)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <returns></returns>
|
||||
private double[] ReadResult_To_Array(string readResult)
|
||||
{
|
||||
//string readResult = "{E6AXIS: A1 -12.03, A2 -97.15, A3 116.47, A4 -30.16, A5 -23.85, A6 27.48, E1 0.0, E2 0.0, E3 0.0, E4 0.0, E5 0.0, E6 0.0}";
|
||||
|
||||
if (MesWorkForm.IsDemoMesServer == 1)
|
||||
{
|
||||
return jDemo;
|
||||
}
|
||||
|
||||
var axis_act = readResult;
|
||||
|
||||
double[] joint = new double[12];
|
||||
|
||||
if (axis_act == "-1")
|
||||
{
|
||||
axis_act = axis_act_Old;
|
||||
}
|
||||
else
|
||||
{
|
||||
//axis_act = Regex.Split(axis_act, ", E4", RegexOptions.IgnoreCase)[0];
|
||||
axis_act = Regex.Split(axis_act, "}", RegexOptions.IgnoreCase)[0];
|
||||
axis_act = axis_act.Replace("{E6AXIS: A1 ", "").Replace(", A2 ", "&").Replace(", A3 ", "&").Replace(", A4 ", "&").Replace(", A5 ", "&").Replace(", A6 ", "&")
|
||||
.Replace(", E1 ", "&").Replace(", E2 ", "&").Replace(", E3 ", "&").Replace(", E4 ", "&").Replace(", E5 ", "&").Replace(", E6 ", "&");
|
||||
axis_act_Old = axis_act;
|
||||
}
|
||||
|
||||
string[] jStr = axis_act.Split('&');
|
||||
|
||||
for (int i = 0; i < jStr.Length; i++)
|
||||
{
|
||||
joint[i] = Math.Round(Convert.ToDouble(jStr[i]), 2);
|
||||
//joint[i] = Convert.ToDouble(jStr[i]);
|
||||
//if (i == 6 | i == 7 | i == 8 | i == 9 | i == 10 | i == 11)
|
||||
// joint[i] = Math.Round(joint[i] / 1000.0, 2);
|
||||
//else
|
||||
// joint[i] = Math.Round(joint[i] * Math.PI / 180, 2);
|
||||
}
|
||||
|
||||
return joint;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 读取数据
|
||||
/// </summary>
|
||||
/// <param name="addr"></param>
|
||||
/// <returns></returns>
|
||||
public string Read_Welding(string addr)
|
||||
{
|
||||
string str = "-1";
|
||||
//if (kuka != null)
|
||||
//{
|
||||
// var r = kuka.ReadString(addr);
|
||||
// if (r.IsSuccess)
|
||||
// {
|
||||
// str = r.Content;
|
||||
// }
|
||||
//}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动测试读取
|
||||
/// </summary>
|
||||
/// <param name="j1_6"></param>
|
||||
/// <param name="j7"></param>
|
||||
/// <returns></returns>
|
||||
public string ReadTest(string robotName)
|
||||
{
|
||||
return "【" + robotName + "】" + MesWorkForm.Move_Joint(Joints);
|
||||
}
|
||||
|
||||
public void UpdateDataToSql()
|
||||
{
|
||||
StoredProcedure("Event_Robot_Update");
|
||||
}
|
||||
private void StoredProcedure(string pName)
|
||||
{
|
||||
//var sqlParameter = new SqlParameter[] {
|
||||
// new SqlParameter("@DeviceCode", DeviceCode),
|
||||
// new SqlParameter("@Online", OnLine),
|
||||
// new SqlParameter("@StationName", OpName),
|
||||
// new SqlParameter("@SlaveAddr", $"{ip}:{port}"),
|
||||
|
||||
// new SqlParameter("@Joint1", j[0]),
|
||||
// new SqlParameter("@Joint2", j[1]),
|
||||
// new SqlParameter("@Joint3", j[2]),
|
||||
|
||||
// new SqlParameter("@Joint4", j[3]),
|
||||
// new SqlParameter("@Joint5", j[4]),
|
||||
// new SqlParameter("@Joint6", j[5]),
|
||||
|
||||
// new SqlParameter("@Joint7", j[6]),
|
||||
// new SqlParameter("@Joint8", j[7]),
|
||||
// new SqlParameter("@Joint9", j[8]),
|
||||
|
||||
// new SqlParameter("@Joint10",j[9]),
|
||||
// new SqlParameter("@Joint11",j[10]),
|
||||
// new SqlParameter("@Joint12",j[11]),
|
||||
// new SqlParameter("@Clamp", welding)
|
||||
// };
|
||||
//MesWorkForm.taskSql.Enqueue(new NJ_ZC.ParamT
|
||||
//{
|
||||
// procedureName = pName,
|
||||
// sqlParameter = sqlParameter
|
||||
//});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
780
DT_SCADA/Core/ElectricEnergyMeter.cs
Normal file
780
DT_SCADA/Core/ElectricEnergyMeter.cs
Normal file
@@ -0,0 +1,780 @@
|
||||
//using ConLink.ModBus;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using static ConLink.BasicFramework.SoftBasic;
|
||||
//using System.Threading;
|
||||
//using System.Threading.Tasks;
|
||||
//using System.Data.SqlClient;
|
||||
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
//namespace MesWork
|
||||
|
||||
|
||||
|
||||
///*
|
||||
// public float Ua = 0f;
|
||||
// public float Ub = 0f;
|
||||
// public float Uc = 0f;
|
||||
// public float Uab = 0f;
|
||||
// public float Ubc = 0f;
|
||||
// public float Uca = 0f;
|
||||
// public float Ia = 0f;
|
||||
// public float Ib = 0f;
|
||||
// public float Ic = 0f;
|
||||
// public float Pa = 0f;
|
||||
// public float Pb = 0f;
|
||||
// public float Pc = 0f;
|
||||
// public float P = 0f;
|
||||
// public float Qa = 0f;
|
||||
// public float Qb = 0f;
|
||||
// public float Qc = 0f;
|
||||
// public float Q = 0f;
|
||||
// public float Sa = 0f;
|
||||
// public float Sb = 0f;
|
||||
// public float Sc = 0f;
|
||||
// public float S = 0f;
|
||||
// public float PFa = 0f;
|
||||
// public float PFb = 0f;
|
||||
// public float PFc = 0f;
|
||||
// public float PF = 0f;
|
||||
// public float FR = 0f;
|
||||
// public float Ep1 = 0f;
|
||||
// public float Ep2 = 0f;
|
||||
// public float Eq1 = 0f;
|
||||
// public float Eq2 = 0f;
|
||||
// */
|
||||
|
||||
|
||||
|
||||
///*
|
||||
// @Ua REAL = 0,
|
||||
// @Ub REAL = 0,
|
||||
// @Uc REAL = 0,
|
||||
// @Uab REAL = 0,
|
||||
// @Ubc REAL = 0,
|
||||
// @Uca REAL = 0,
|
||||
// @Ia REAL = 0,
|
||||
// @Ib REAL = 0,
|
||||
// @Ic REAL = 0,
|
||||
// @Pa REAL = 0,
|
||||
// @Pb REAL = 0,
|
||||
// @Pc REAL = 0,
|
||||
// @P REAL = 0,
|
||||
// @Qa REAL = 0,
|
||||
// @Qb REAL = 0,
|
||||
// @Qc REAL = 0,
|
||||
// @Q REAL = 0,
|
||||
// @Sa REAL = 0,
|
||||
// @Sb REAL = 0,
|
||||
// @Sc REAL = 0,
|
||||
// @S REAL = 0,
|
||||
// @PFa REAL = 0,
|
||||
// @PFb REAL = 0,
|
||||
// @PFc REAL = 0,
|
||||
// @PF REAL = 0,
|
||||
// @FR REAL = 0,
|
||||
// @Ep1 REAL = 0,
|
||||
// @Ep2 REAL = 0,
|
||||
// @Eq1 REAL = 0,
|
||||
// @Eq2 REAL = 0
|
||||
// */
|
||||
//{
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public class ElectricEnergyMeter
|
||||
// {
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private string ip = "";
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private int port = 0;
|
||||
// /// <summary>
|
||||
// /// /
|
||||
// /// </summary>
|
||||
// private byte station = 0;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private string opName = "";
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private int intervalRead = 1 * 1000;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private int intervalUpdate = 5 * 1000;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private int intervalInsert = 10 * 1000;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private ModbusTcpNet mbt = null;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private Thread tt = null;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private Thread ttt = null;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private Thread tttt = null;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private string message = "00 00 00 00 00 06 01 03 00 00 00 3C";
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private int offset = 18;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private int index = 0;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Ua = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Ub = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Uc = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Uab = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Ubc = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Uca = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Ia = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Ib = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Ic = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Pa = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Pb = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Pc = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float P = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Qa = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Qb = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Qc = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Q = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Sa = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Sb = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Sc = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float S = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float PFa = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float PFb = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float PFc = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float PF = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float FR = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Ep1 = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Ep2 = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Eq1 = 0f;
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public float Eq2 = 0f;
|
||||
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
|
||||
// public void Start(string ip,int port,byte station,string opName,int intervalRead
|
||||
// , int intervalUpdate ,int intervalInsert)
|
||||
// {
|
||||
// this.ip = ip;
|
||||
// this.port = port;
|
||||
// this.station = station;
|
||||
// this.opName = opName;
|
||||
// this.intervalRead = intervalRead;
|
||||
// this.intervalUpdate = intervalUpdate;
|
||||
// this.intervalInsert = intervalInsert;
|
||||
|
||||
// mbt = new ModbusTcpNet(ip, port, station);
|
||||
// mbt.AddressStartWithZero = true ;
|
||||
|
||||
// mbt.SetLoginAccount("","");
|
||||
|
||||
// mbt.DataFormat = ConLink.Core.DataFormat.ABCD;
|
||||
// mbt.IsStringReverse = false;
|
||||
|
||||
// var s = mbt.ConnectServer();
|
||||
// var dfg = s.IsSuccess;
|
||||
|
||||
// tt = new Thread(new ThreadStart(Read));
|
||||
// tt.IsBackground = true;
|
||||
// tt.Start();
|
||||
|
||||
// ttt = new Thread(new ThreadStart(Update));
|
||||
// ttt.IsBackground = true;
|
||||
// ttt.Start();
|
||||
|
||||
// tttt = new Thread(new ThreadStart(Insert));
|
||||
// tttt.IsBackground = true;
|
||||
// tttt.Start();
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private void Read()
|
||||
// {
|
||||
// while (true)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var read = mbt.ReadFromCoreServer(HexStringToBytes(this.message));
|
||||
// if (read.IsSuccess)
|
||||
// {
|
||||
// var rc = read.Content;
|
||||
// var str = ByteToHexString(rc);
|
||||
// //str = "00000000001B010318199A435C199A435C199A435C199A435C199A435C199A435C";
|
||||
// index = 0;
|
||||
// Ua = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4,4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 1;
|
||||
// Ub = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 2;
|
||||
// Uc = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 3;
|
||||
// Uab = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 4;
|
||||
// Ubc = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 5;
|
||||
// Uca = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
|
||||
|
||||
|
||||
// index = 6;
|
||||
// Ia = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 7;
|
||||
// Ib = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 8;
|
||||
// Ic = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
|
||||
|
||||
|
||||
// index = 9;
|
||||
// Pa = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 10;
|
||||
// Pb = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 11;
|
||||
// Pc = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 12;
|
||||
// P = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
|
||||
// index = 13;
|
||||
// Qa = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 14;
|
||||
// Qb = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 15;
|
||||
// Qc = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 16;
|
||||
// Q = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
|
||||
|
||||
// index = 17;
|
||||
// Sa = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 18;
|
||||
// Sb = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 19;
|
||||
// Sc = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 20;
|
||||
// S = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
|
||||
|
||||
|
||||
// index = 21;
|
||||
// PFa = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 22;
|
||||
// PFb = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 23;
|
||||
// PFc = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 24;
|
||||
// PF = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
|
||||
|
||||
|
||||
|
||||
// index = 25;
|
||||
// FR = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
|
||||
// index = 26;
|
||||
// Ep1 = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
// index = 27;
|
||||
// Ep2 = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
|
||||
|
||||
// index = 28;
|
||||
// Eq1 = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
|
||||
// index = 29;
|
||||
// Eq2 = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToUInt32(
|
||||
// str.Substring(offset + index * 8 + 4, 4) + str.Substring(offset + index * 8 + 0, 4)
|
||||
// , 16)), 0);
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Thread.Sleep(this.intervalRead * 3);
|
||||
// }
|
||||
// }
|
||||
// catch (Exception err)
|
||||
// {
|
||||
|
||||
// }
|
||||
// Thread.Sleep(this.intervalRead);
|
||||
// }
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private void Update()
|
||||
// {
|
||||
// while (true)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// ExecUpdate();
|
||||
// }
|
||||
// catch (Exception err)
|
||||
// {
|
||||
|
||||
// }
|
||||
// Thread.Sleep(this.intervalUpdate);
|
||||
|
||||
// }
|
||||
// }
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private void Insert()
|
||||
// {
|
||||
// while (true)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// ExecInsert();
|
||||
// }
|
||||
// catch (Exception err)
|
||||
// {
|
||||
|
||||
// }
|
||||
// Thread.Sleep(this.intervalInsert);
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private void ExecUpdate()
|
||||
// {
|
||||
// /*
|
||||
// public float Ua = 0f;
|
||||
// public float Ub = 0f;
|
||||
// public float Uc = 0f;
|
||||
// public float Uab = 0f;
|
||||
// public float Ubc = 0f;
|
||||
// public float Uca = 0f;
|
||||
// public float Ia = 0f;
|
||||
// public float Ib = 0f;
|
||||
// public float Ic = 0f;
|
||||
// public float Pa = 0f;
|
||||
// public float Pb = 0f;
|
||||
// public float Pc = 0f;
|
||||
// public float P = 0f;
|
||||
// public float Qa = 0f;
|
||||
// public float Qb = 0f;
|
||||
// public float Qc = 0f;
|
||||
// public float Q = 0f;
|
||||
// public float Sa = 0f;
|
||||
// public float Sb = 0f;
|
||||
// public float Sc = 0f;
|
||||
// public float S = 0f;
|
||||
// public float PFa = 0f;
|
||||
// public float PFb = 0f;
|
||||
// public float PFc = 0f;
|
||||
// public float PF = 0f;
|
||||
// public float FR = 0f;
|
||||
// public float Ep1 = 0f;
|
||||
// public float Ep2 = 0f;
|
||||
// public float Eq1 = 0f;
|
||||
// public float Eq2 = 0f;
|
||||
// */
|
||||
|
||||
|
||||
// UpdateCurr();
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// private void ExecInsert()
|
||||
// {
|
||||
// /*
|
||||
// public float Ua = 0f;
|
||||
// public float Ub = 0f;
|
||||
// public float Uc = 0f;
|
||||
// public float Uab = 0f;
|
||||
// public float Ubc = 0f;
|
||||
// public float Uca = 0f;
|
||||
// public float Ia = 0f;
|
||||
// public float Ib = 0f;
|
||||
// public float Ic = 0f;
|
||||
// public float Pa = 0f;
|
||||
// public float Pb = 0f;
|
||||
// public float Pc = 0f;
|
||||
// public float P = 0f;
|
||||
// public float Qa = 0f;
|
||||
// public float Qb = 0f;
|
||||
// public float Qc = 0f;
|
||||
// public float Q = 0f;
|
||||
// public float Sa = 0f;
|
||||
// public float Sb = 0f;
|
||||
// public float Sc = 0f;
|
||||
// public float S = 0f;
|
||||
// public float PFa = 0f;
|
||||
// public float PFb = 0f;
|
||||
// public float PFc = 0f;
|
||||
// public float PF = 0f;
|
||||
// public float FR = 0f;
|
||||
// public float Ep1 = 0f;
|
||||
// public float Ep2 = 0f;
|
||||
// public float Eq1 = 0f;
|
||||
// public float Eq2 = 0f;
|
||||
// */
|
||||
|
||||
|
||||
// InsertHis();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// private bool UpdateCurr()
|
||||
// {
|
||||
// /*
|
||||
// public float Ua = 0f;
|
||||
// public float Ub = 0f;
|
||||
// public float Uc = 0f;
|
||||
// public float Uab = 0f;
|
||||
// public float Ubc = 0f;
|
||||
// public float Uca = 0f;
|
||||
// public float Ia = 0f;
|
||||
// public float Ib = 0f;
|
||||
// public float Ic = 0f;
|
||||
// public float Pa = 0f;
|
||||
// public float Pb = 0f;
|
||||
// public float Pc = 0f;
|
||||
// public float P = 0f;
|
||||
// public float Qa = 0f;
|
||||
// public float Qb = 0f;
|
||||
// public float Qc = 0f;
|
||||
// public float Q = 0f;
|
||||
// public float Sa = 0f;
|
||||
// public float Sb = 0f;
|
||||
// public float Sc = 0f;
|
||||
// public float S = 0f;
|
||||
// public float PFa = 0f;
|
||||
// public float PFb = 0f;
|
||||
// public float PFc = 0f;
|
||||
// public float PF = 0f;
|
||||
// public float FR = 0f;
|
||||
// public float Ep1 = 0f;
|
||||
// public float Ep2 = 0f;
|
||||
// public float Eq1 = 0f;
|
||||
// public float Eq2 = 0f;
|
||||
// */
|
||||
|
||||
// var sqlParameter = new SqlParameter[] {
|
||||
// new SqlParameter("@StationName", opName),
|
||||
// new SqlParameter("@SlaveAddr", ip),
|
||||
|
||||
// new SqlParameter("@Ua", Ua),
|
||||
// new SqlParameter("@Ub", Ub),
|
||||
// new SqlParameter("@Uc", Uc),
|
||||
|
||||
// new SqlParameter("@Uab", Ua),
|
||||
// new SqlParameter("@Ubc", Ub),
|
||||
// new SqlParameter("@Uca", Uc),
|
||||
|
||||
// new SqlParameter("@Ia", Ia),
|
||||
// new SqlParameter("@Ib", Ib),
|
||||
// new SqlParameter("@Ic", Ic),
|
||||
|
||||
// new SqlParameter("@Pa", Pa),
|
||||
// new SqlParameter("@Pb", Pb),
|
||||
// new SqlParameter("@Pc", Pc),
|
||||
// new SqlParameter("@P", Pa),
|
||||
|
||||
// new SqlParameter("@Qa", Qa),
|
||||
// new SqlParameter("@Qb", Qb),
|
||||
// new SqlParameter("@Qc", Qc),
|
||||
// new SqlParameter("@Q", Q),
|
||||
|
||||
// new SqlParameter("@Sa", Sa),
|
||||
// new SqlParameter("@Sb", Sb),
|
||||
// new SqlParameter("@Sc", Sc),
|
||||
// new SqlParameter("@S", S),
|
||||
|
||||
// new SqlParameter("@PFa", PFa),
|
||||
// new SqlParameter("@PFb", PFb),
|
||||
// new SqlParameter("@PFc", PFc),
|
||||
// new SqlParameter("@PF", PF),
|
||||
|
||||
// new SqlParameter("@FR", FR),
|
||||
|
||||
// new SqlParameter("@Ep1", Ep1),
|
||||
// new SqlParameter("@Ep2", Ep2),
|
||||
|
||||
// new SqlParameter("@Eq1", Eq1),
|
||||
// new SqlParameter("@Eq2", Eq2)
|
||||
|
||||
// };
|
||||
// return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("Event_Meter_Update",MesWorkForm.ConnectionString, ref sqlParameter, out string errorMessage);
|
||||
|
||||
// }
|
||||
// private bool InsertHis()
|
||||
// {
|
||||
// /*
|
||||
// public float Ua = 0f;
|
||||
// public float Ub = 0f;
|
||||
// public float Uc = 0f;
|
||||
// public float Uab = 0f;
|
||||
// public float Ubc = 0f;
|
||||
// public float Uca = 0f;
|
||||
// public float Ia = 0f;
|
||||
// public float Ib = 0f;
|
||||
// public float Ic = 0f;
|
||||
// public float Pa = 0f;
|
||||
// public float Pb = 0f;
|
||||
// public float Pc = 0f;
|
||||
// public float P = 0f;
|
||||
// public float Qa = 0f;
|
||||
// public float Qb = 0f;
|
||||
// public float Qc = 0f;
|
||||
// public float Q = 0f;
|
||||
// public float Sa = 0f;
|
||||
// public float Sb = 0f;
|
||||
// public float Sc = 0f;
|
||||
// public float S = 0f;
|
||||
// public float PFa = 0f;
|
||||
// public float PFb = 0f;
|
||||
// public float PFc = 0f;
|
||||
// public float PF = 0f;
|
||||
// public float FR = 0f;
|
||||
// public float Ep1 = 0f;
|
||||
// public float Ep2 = 0f;
|
||||
// public float Eq1 = 0f;
|
||||
// public float Eq2 = 0f;
|
||||
// */
|
||||
|
||||
// var sqlParameter = new SqlParameter[] {
|
||||
// new SqlParameter("@StationName", opName),
|
||||
// new SqlParameter("@SlaveAddr", ip),
|
||||
|
||||
// new SqlParameter("@Ua", Ua),
|
||||
// new SqlParameter("@Ub", Ub),
|
||||
// new SqlParameter("@Uc", Uc),
|
||||
|
||||
// new SqlParameter("@Uab", Ua),
|
||||
// new SqlParameter("@Ubc", Ub),
|
||||
// new SqlParameter("@Uca", Uc),
|
||||
|
||||
// new SqlParameter("@Ia", Ia),
|
||||
// new SqlParameter("@Ib", Ib),
|
||||
// new SqlParameter("@Ic", Ic),
|
||||
|
||||
// new SqlParameter("@Pa", Pa),
|
||||
// new SqlParameter("@Pb", Pb),
|
||||
// new SqlParameter("@Pc", Pc),
|
||||
// new SqlParameter("@P", Pa),
|
||||
|
||||
// new SqlParameter("@Qa", Qa),
|
||||
// new SqlParameter("@Qb", Qb),
|
||||
// new SqlParameter("@Qc", Qc),
|
||||
// new SqlParameter("@Q", Q),
|
||||
|
||||
// new SqlParameter("@Sa", Sa),
|
||||
// new SqlParameter("@Sb", Sb),
|
||||
// new SqlParameter("@Sc", Sc),
|
||||
// new SqlParameter("@S", S),
|
||||
|
||||
// new SqlParameter("@PFa", PFa),
|
||||
// new SqlParameter("@PFb", PFb),
|
||||
// new SqlParameter("@PFc", PFc),
|
||||
// new SqlParameter("@PF", PF),
|
||||
|
||||
// new SqlParameter("@FR", FR),
|
||||
|
||||
// new SqlParameter("@Ep1", Ep1),
|
||||
// new SqlParameter("@Ep2", Ep2),
|
||||
|
||||
// new SqlParameter("@Eq1", Eq1),
|
||||
// new SqlParameter("@Eq2", Eq2)
|
||||
|
||||
// };
|
||||
// return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("Event_Meter_Insert", MesWorkForm.ConnectionString, ref sqlParameter, out string errorMessage);
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// }
|
||||
//}
|
||||
28
DT_SCADA/Core/ExecSqlServer.cs
Normal file
28
DT_SCADA/Core/ExecSqlServer.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using MesWork;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NJ_ZC
|
||||
{
|
||||
|
||||
public class ParamT
|
||||
{
|
||||
public string procedureName
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = "";
|
||||
|
||||
public SqlParameter[] sqlParameter
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
154
DT_SCADA/Core/Load.cs
Normal file
154
DT_SCADA/Core/Load.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using NJ_ZC;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using OpcBasic;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public partial class Temp { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public partial class MesWorkForm
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dt_Robot"></param>
|
||||
private void LoadDevice(ScadaConfig appConfig)
|
||||
{
|
||||
foreach (var mu in appConfig.MachineTool)
|
||||
{
|
||||
var Enable = mu.Enable;
|
||||
var Type = mu.Type;
|
||||
var ConnectStr = mu.ConnectStr;
|
||||
var Id = mu.Id;
|
||||
var Name = mu.Name;
|
||||
var DataTimeInterval = Convert.ToInt32(mu.DataTimeInterval);
|
||||
var AxesTimeInterval = Convert.ToInt32(mu.AxesTimeInterval);
|
||||
var Joints = mu.Joints;
|
||||
|
||||
var TagID_Clamp = mu.TagID_Clamp;
|
||||
|
||||
|
||||
var IP = "";
|
||||
var Port = 0;
|
||||
|
||||
if (Enable == "1")
|
||||
{
|
||||
switch (Type.ToUpper())
|
||||
{
|
||||
case "ROBOTFANUC":
|
||||
{
|
||||
if (!ConnectStr.Contains(":"))
|
||||
{
|
||||
MessageBox.Show("Json文件中,ConnectStr 值格式错误!");
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
IP = ConnectStr.Split(':')[0];
|
||||
Port = Convert.ToInt32(ConnectStr.Split(':')[1]);
|
||||
var fanuc = new B_Robot_Fanuc();
|
||||
fanuc.Start(IP, Port, AxesTimeInterval, DataTimeInterval, "CurrentPose", "", Id, Name, Joints);
|
||||
dc_Robot.Add($"{Type}|{Id}", fanuc);
|
||||
}
|
||||
break;
|
||||
case "ROBOTKUKA":
|
||||
{
|
||||
if (!ConnectStr.Contains(":"))
|
||||
{
|
||||
MessageBox.Show("Json文件中,ConnectStr 值格式错误!");
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
IP = ConnectStr.Split(':')[0];
|
||||
Port = Convert.ToInt32(ConnectStr.Split(':')[1]);
|
||||
var kuka = new B_Robot_Kuka();
|
||||
kuka.Start(IP, Port, AxesTimeInterval, DataTimeInterval, "$axis_act", "$OUT[8]", Id, Name, Joints);
|
||||
dc_Robot.Add($"{Type}|{Id}", kuka);
|
||||
}
|
||||
break;
|
||||
case "ROBOTABB":
|
||||
{
|
||||
if (!ConnectStr.Contains(":"))
|
||||
{
|
||||
MessageBox.Show("Json文件中,ConnectStr 值格式错误!");
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
IP = ConnectStr.Split(':')[0];
|
||||
var cname = ConnectStr.Split(':')[1];
|
||||
var abb = new B_Robot_Abb();
|
||||
abb.Start(IP, cname, AxesTimeInterval, DataTimeInterval, Id, Name, Joints);
|
||||
dc_Robot.Add($"{Type}|{Id}", abb);
|
||||
}
|
||||
break;
|
||||
case "ROBOTEPSON":
|
||||
{
|
||||
if (!ConnectStr.Contains(":"))
|
||||
{
|
||||
MessageBox.Show("Json文件中,ConnectStr 值格式错误!");
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
IP = ConnectStr.Split(':')[0];
|
||||
Port = Convert.ToInt32(ConnectStr.Split(':')[1]);
|
||||
var espon = new B_Robot_Espon();
|
||||
espon.Start(IP, Port, AxesTimeInterval, DataTimeInterval, Id, Name, Joints, TagID_Clamp);
|
||||
dc_Robot.Add($"{Type}|{Id}", espon);
|
||||
}
|
||||
break;
|
||||
case "AXIS":
|
||||
{
|
||||
var b_Read_N_Axis = new B_Read_N_Axis();
|
||||
b_Read_N_Axis.Start(AxesTimeInterval, DataTimeInterval, ConnectStr, Joints, Id, Name);
|
||||
dc_Name_Axis.Add($"{Type}|{Id}|{ConnectStr}", b_Read_N_Axis);
|
||||
}
|
||||
break;
|
||||
case "AXIS_CARD":
|
||||
{
|
||||
var b_Read_N_AxisCard = new B_Read_N_AxisCard();
|
||||
b_Read_N_AxisCard.Start(AxesTimeInterval, DataTimeInterval, ConnectStr, Joints);
|
||||
dc_Name_Axis_Card.Add($"{Type}|{Id}|{ConnectStr}", b_Read_N_AxisCard);
|
||||
}
|
||||
break;
|
||||
case "AGV":
|
||||
{
|
||||
agvRead = new AgvRead();
|
||||
agvRead.Start(ConnectStr,AxesTimeInterval, DataTimeInterval, Id, Name);
|
||||
}
|
||||
break;
|
||||
case "CNCEDM":
|
||||
{
|
||||
IP = ConnectStr.Split(':')[0];
|
||||
Port = Convert.ToInt32(ConnectStr.Split(':')[1]);
|
||||
|
||||
var edm = new B_Cnc_Edm();
|
||||
edm.Start(IP, Port, AxesTimeInterval, DataTimeInterval, Id, Name, Joints);
|
||||
|
||||
dc_Robot.Add($"{Type}|{Id}", edm);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
53
DT_SCADA/Core/MW.DisConn.cs
Normal file
53
DT_SCADA/Core/MW.DisConn.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using NJ_ZC;
|
||||
using OpcBasic;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using SystemFramework;
|
||||
using static System.Configuration.ConfigurationManager;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public partial class Temp { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public partial class MesWorkForm
|
||||
{
|
||||
|
||||
public void DisConnect()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var robot in new Dictionary<string,object>(dc_Robot))
|
||||
{
|
||||
var key = robot.Key;
|
||||
var robotObj = robot.Value;
|
||||
var type = key.Split('|')[0];
|
||||
var robotCode = key.Split('|')[1];
|
||||
switch (type)
|
||||
{
|
||||
case "FANUC":
|
||||
((B_Robot_Fanuc)robotObj).DisConn();
|
||||
break;
|
||||
case "KUKA":
|
||||
((B_Robot_Kuka)robotObj).DisConn();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err){}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
95
DT_SCADA/Core/MysqlClient.cs
Normal file
95
DT_SCADA/Core/MysqlClient.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseClient
|
||||
{
|
||||
public class MysqlClient
|
||||
{
|
||||
|
||||
public static bool ExecQuerySQL(string sql, string ConnectStr, out string err)
|
||||
{
|
||||
// lock (losk1) {
|
||||
bool success = false;
|
||||
err = "";
|
||||
using (MySqlConnection conn = new MySqlConnection(ConnectStr))
|
||||
{
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
MySqlCommand command = new MySqlCommand(sql, conn);
|
||||
command.ExecuteNonQuery();
|
||||
success = true;
|
||||
}
|
||||
catch (Exception er)
|
||||
{
|
||||
err = er.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn != null)
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return success;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static bool ExecQueryDataTable(string sql, string ConnectStr,out DataTable dt, out string err)
|
||||
{
|
||||
bool success = false;
|
||||
err = "";
|
||||
dt = null;
|
||||
using (MySqlConnection conn = new MySqlConnection(ConnectStr))
|
||||
{
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
MySqlCommand command = new MySqlCommand(sql, conn);
|
||||
MySqlDataAdapter da = new MySqlDataAdapter(command);
|
||||
DataSet ds = new DataSet();
|
||||
da.Fill(ds);
|
||||
|
||||
if (ds.Tables.Count > 0)
|
||||
{
|
||||
dt = ds.Tables[0];
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
catch (Exception er)
|
||||
{
|
||||
err = er.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn != null)
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
113
DT_SCADA/Core/Remote.Receive.cs
Normal file
113
DT_SCADA/Core/Remote.Receive.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public partial class QingYa_OP0010 { }
|
||||
public partial class MesWorkForm
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="_Msg"></param>
|
||||
public void LoadClientInfo(object _Msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
string recStr = (string)_Msg;
|
||||
string m_Source = recStr.Split('|')[0];
|
||||
string cmd = recStr.Split('|')[1];
|
||||
//string OpName = recStr.Split('|')[2];
|
||||
//string tagValue = recStr.Split('|')[3];
|
||||
|
||||
switch (m_Source)
|
||||
{
|
||||
case "DT":
|
||||
switch (cmd)
|
||||
{
|
||||
case "B_C_DT_WebLoaded":
|
||||
new TaskFactory().StartNew(delegate () {
|
||||
try
|
||||
{
|
||||
var tagList = DriverCache["Cache_Tag"];
|
||||
foreach (var item in tagList)
|
||||
{
|
||||
var tf = (OpcBasic.TagFormat)item.Value;
|
||||
var tagID = tf.TagID;
|
||||
var tagValue = tf.TagValue.ToString();
|
||||
var tagTypeID = Convert.ToInt32(tf.TagTypeID);
|
||||
var tagTypeCodeID = (int)tf.TagTypeCodeID;
|
||||
var opName = tf.OpName.ToString();
|
||||
if (tagTypeID == 11)
|
||||
{
|
||||
switch (tagValue.ToUpper())
|
||||
{
|
||||
case "1":
|
||||
case "TRUE":
|
||||
tagValue = "1";
|
||||
break;
|
||||
default:
|
||||
tagValue = "0";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
S_C_B_TagIDTrigger(opName,tagID, tagValue);
|
||||
}
|
||||
}
|
||||
catch (Exception ew1) { }
|
||||
//try
|
||||
//{
|
||||
// var from_to_loc = agvRead.ReadAgv();
|
||||
// MesWorkForm.S_C_B_TagIDTrigger(agvRead.connectStr, agvRead.tagID, from_to_loc);
|
||||
//}
|
||||
//catch (Exception ew2) { }
|
||||
});
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "MES":
|
||||
switch (cmd)
|
||||
{
|
||||
case "B_C_DT_WebLoaded":
|
||||
//string OpName = recStr.Split('|')[2];
|
||||
//if (OpName == "AllOpName")
|
||||
//{
|
||||
|
||||
// foreach (var fanucBaseNC in fanucBaseNCArray)
|
||||
// {
|
||||
// fanucBaseNC.SendDataReLoad();
|
||||
// }
|
||||
|
||||
// return;
|
||||
//}
|
||||
//if (fanucBaseNCArray.FirstOrDefault(o => o.OpName == OpName) != null) {
|
||||
// fanucBaseNCArray.FirstOrDefault(o => o.OpName == OpName).SendDataReLoad();
|
||||
//}
|
||||
|
||||
// FanucBaseNC.SendStateDataFirst();
|
||||
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err) { }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
275
DT_SCADA/Core/Remote.Send.cs
Normal file
275
DT_SCADA/Core/Remote.Send.cs
Normal file
@@ -0,0 +1,275 @@
|
||||
using HslCommunication;
|
||||
using HslCommunication.Core.Net;
|
||||
using HslCommunication.Enthernet;
|
||||
using MQTTnet;
|
||||
using MQTTnet.Client.Connecting;
|
||||
using MQTTnet.Client.Disconnecting;
|
||||
using MQTTnet.Client.Options;
|
||||
using MQTTnet.Client.Receiving;
|
||||
using MQTTnet.Extensions.ManagedClient;
|
||||
using MQTTnet.Formatter;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
namespace MesWork
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public partial class Temp { }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public partial class MesWorkForm
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static NetComplexClient complexClient = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
static private IManagedMqttClient mqttClient = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
string topic = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
static bool OnLine_Mqtt = false;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="uri"></param>
|
||||
/// <returns></returns>
|
||||
public async Task StartAsync(string uri)
|
||||
{
|
||||
var array = uri.Split(new char[] { ':', ',' });
|
||||
string mqttUser = array[2];
|
||||
string mqttPassword = "";
|
||||
var options = new MqttClientOptions
|
||||
{
|
||||
ClientId = $"{mqttUser}_{Guid.NewGuid().ToString()}",
|
||||
ProtocolVersion = MqttProtocolVersion.V311,
|
||||
ChannelOptions = new MqttClientTcpOptions { Server = array[0], Port = Convert.ToInt32(array[1]) },
|
||||
CleanSession = true,
|
||||
KeepAlivePeriod = TimeSpan.FromSeconds(15),
|
||||
Credentials = new MqttClientCredentials
|
||||
{
|
||||
Username = mqttUser,
|
||||
Password = Encoding.UTF8.GetBytes(mqttPassword)
|
||||
}
|
||||
};
|
||||
mqttClient = new MqttFactory().CreateManagedMqttClient();
|
||||
mqttClient.ConnectedHandler = new MqttClientConnectedHandlerDelegate(OnSubscriberConnected);
|
||||
mqttClient.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate(OnSubscriberDisconnected);
|
||||
mqttClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(OnSubscriberMessageReceived);
|
||||
await mqttClient.StartAsync(new ManagedMqttClientOptions { ClientOptions = options });
|
||||
this.topic = array[2];
|
||||
await mqttClient.SubscribeAsync(new MqttTopicFilter { Topic = topic });
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="MesServer_IpPortName"></param>
|
||||
private void ClientConnection(string MesServer_IpPortName)
|
||||
{
|
||||
string serverIP = MesServer_IpPortName.Split(':')[0];
|
||||
string portString = MesServer_IpPortName.Split(':')[1].Split(',')[0];
|
||||
string opNameSocket = MesServer_IpPortName.Split(',')[1];
|
||||
|
||||
if (!IPAddress.TryParse(serverIP, out IPAddress address))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(portString, out int port))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 连接 connect
|
||||
complexClient = new NetComplexClient();
|
||||
complexClient.ClientAlias = opNameSocket;
|
||||
complexClient.EndPointServer = new IPEndPoint(address, port);
|
||||
//complexClient.Token = new Guid(textBox3.Text);
|
||||
complexClient.AcceptString += ComplexClient_AcceptString;
|
||||
complexClient.MessageAlerts += ComplexClient_MessageAlerts;
|
||||
complexClient.ClientStart();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HslCommunication.BasicFramework.SoftBasic.ShowExceptionMessage(ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="publish_topic"></param>
|
||||
/// <param name="publish_msg"></param>
|
||||
/// <returns></returns>
|
||||
private static async Task Publish(string publish_topic, string publish_msg)
|
||||
{
|
||||
if (mqttClient != null)
|
||||
{
|
||||
await mqttClient.PublishAsync(new MqttApplicationMessageBuilder().WithTopic(publish_topic).WithPayload(publish_msg).WithAtMostOnceQoS().Build());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task DisConnectService()
|
||||
{
|
||||
if (mqttClient != null)
|
||||
{
|
||||
await mqttClient.UnsubscribeAsync(new string[] { topic });
|
||||
await mqttClient.StopAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
private void ComplexClient_MessageAlerts(string text)
|
||||
{
|
||||
//if (InvokeRequired)
|
||||
//{
|
||||
// Invoke(new Action<string>(ComplexClient_MessageAlerts), text);
|
||||
// return;
|
||||
//}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 连接完成
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
private void OnSubscriberConnected(MqttClientConnectedEventArgs x)
|
||||
{
|
||||
OnLine_Mqtt = true;
|
||||
// textBox1_robotData.Text += "连接完成" + "\r\n";
|
||||
var rec = x.AuthenticateResult.ResultCode.ToString();
|
||||
// label_State.Text = rec;
|
||||
// textBox1_robotData.Text += rec + "\r\n";
|
||||
}
|
||||
/// <summary>
|
||||
/// 断开连接
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
private void OnSubscriberDisconnected(MqttClientDisconnectedEventArgs x)
|
||||
{
|
||||
OnLine_Mqtt = false;
|
||||
try
|
||||
{
|
||||
// textBox1_robotData.Text += "断开连接" + "\r\n";
|
||||
|
||||
var rec = x.ClientWasConnected.ToString();
|
||||
// textBox1_robotData.Text += rec + "\r\n";
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
// textBox1_robotData.Text += $"Message:{err.Message}\r\n\r\nStackTrace:{err.StackTrace}" + "\r\n";
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 接收信息
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
private void OnSubscriberMessageReceived(MqttApplicationMessageReceivedEventArgs x)
|
||||
{
|
||||
var recStr = x.ApplicationMessage.ConvertPayloadToString();
|
||||
ThreadPool.QueueUserWorkItem(LoadClientInfo, recStr);
|
||||
}
|
||||
/// <summary>
|
||||
/// 接收消息
|
||||
/// </summary>
|
||||
/// <param name="arg1"></param>
|
||||
/// <param name="arg2"></param>
|
||||
/// <param name="arg3"></param>
|
||||
private void ComplexClient_AcceptString(AppSession arg1, NetHandle arg2, string arg3)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(LoadClientInfo, (string)arg3);
|
||||
}
|
||||
|
||||
public static void SendMsg(string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (ConnectType)
|
||||
{
|
||||
case 1:
|
||||
complexClient.Send(1, str);
|
||||
break;
|
||||
case 2:
|
||||
//var s = $"{MqttTargetTopic}\\?";
|
||||
//var sendString = Regex.Split(str, s, RegexOptions.IgnoreCase);
|
||||
//TOBS??SCADAMain?DT|C_B_JointMoveTo|
|
||||
var topic = $"{str.Split('?')[2]}";
|
||||
var content = $"{str.Split('?')[3]}";
|
||||
Publish(topic, content);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
public static void SendMsg(string opName, string topic, string content)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (ConnectType)
|
||||
{
|
||||
case 1:
|
||||
complexClient.Send(1, content);
|
||||
break;
|
||||
case 2:
|
||||
Publish(topic + opName, content);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ConnectService()
|
||||
{
|
||||
switch (ConnectType)
|
||||
{
|
||||
case 1:
|
||||
ClientConnection(IpPortSub);
|
||||
break;
|
||||
case 2:
|
||||
var _task = StartAsync(IpPortSub);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
103
DT_SCADA/Core/ScadaConfig.cs
Normal file
103
DT_SCADA/Core/ScadaConfig.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public class ToolInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string TimeRated { get; set; }
|
||||
public string TimeUsed { get; set; }
|
||||
}
|
||||
|
||||
public class AxisInfo
|
||||
{
|
||||
public string AxisName { get; set; }
|
||||
public string AxisValue { get; set; }
|
||||
}
|
||||
|
||||
public class ParameterInfo
|
||||
{
|
||||
public string ParameterName { get; set; }
|
||||
public string ParameterValue { get; set; }
|
||||
}
|
||||
|
||||
public class AlarmInfo
|
||||
{
|
||||
public string AlarmCode { get; set; } = "83721";
|
||||
public string Alarm { get; set; } = "该吃饭了!";
|
||||
public string AlarmTime { get; set; } = DateTime.Now.ToString();
|
||||
}
|
||||
public class TipInfo
|
||||
{
|
||||
public string TipCode { get; set; } = "1123";
|
||||
public string Tip { get; set; } = "该睡觉了!";
|
||||
public string TipTime { get; set; } = DateTime.Now.ToString();
|
||||
}
|
||||
|
||||
public class DeviceInfo
|
||||
{
|
||||
public string order { get; set; } = "";
|
||||
public string Name { get; set; } = "";
|
||||
public string Id { get; set; } = "";
|
||||
public string Status { get; set; } = "";
|
||||
public string Program { get; set; } = "";
|
||||
public string Feed { get; set; } = "";
|
||||
public string Speed { get; set; } = "";
|
||||
public string Rapid { get; set; } = "";
|
||||
public string ProgramStatus { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 电流
|
||||
/// </summary>
|
||||
public string Current { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 电压
|
||||
/// </summary>
|
||||
public string Voltage { get; set; } = "";
|
||||
|
||||
public ToolInfo Tool { get; set; } = new ToolInfo();
|
||||
public List<AxisInfo> Axis { get; set; } = new List<AxisInfo>();
|
||||
|
||||
public List<ParameterInfo> OtherParameter { get; set; } = new List<ParameterInfo>();
|
||||
public List<AlarmInfo> Alarm { get; set; } = new List<AlarmInfo>();
|
||||
public List<TipInfo> Tip { get; set; } = new List<TipInfo>();
|
||||
|
||||
}
|
||||
|
||||
public class JointConfig
|
||||
{
|
||||
public string DeviceCode { get; set; }
|
||||
public string JointName { get; set; }
|
||||
public string ModelCode { get; set; }
|
||||
public string JointType { get; set; }
|
||||
public string Axis { get; set; }
|
||||
public string Flip { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string ValueFactor { get; set; }
|
||||
public string Delta { get; set; }
|
||||
}
|
||||
|
||||
public class MachineToolConfig
|
||||
{
|
||||
public string Enable { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string ConnectStr { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string DataTimeInterval { get; set; }
|
||||
public string AxesTimeInterval { get; set; }
|
||||
public List<JointConfig> Joints { get; set; }
|
||||
public string TagID_Clamp { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class ScadaConfig
|
||||
{
|
||||
public List<MachineToolConfig> MachineTool { get; set; }
|
||||
}
|
||||
}
|
||||
67
DT_SCADA/Core/SendProtocol.cs
Normal file
67
DT_SCADA/Core/SendProtocol.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using Newtonsoft.Json;
|
||||
using Opc.Ua;
|
||||
using OpcBasic;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public partial class Temp { }
|
||||
public partial class MesWorkForm
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 01
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagID"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void S_C_B_TagIDTrigger(string opName, string tagID, string tagValue)
|
||||
{
|
||||
SendMsg(MesServer_SendProtocol_Tag + "{\"DeviceCode\":\"" + opName + "\",\"TagID\":\"" + tagID + "\",\"TagValue\":\"" + tagValue + "\"}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 02
|
||||
/// </summary>
|
||||
/// <param name="joints"></param>
|
||||
/// <returns></returns>
|
||||
public static string Move_Joint(List<JointConfig> joints)
|
||||
{
|
||||
var sendStr = MesServer_SendProtocol_Joint + JsonConvert.SerializeObject(joints);
|
||||
return sendStr;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 11
|
||||
/// </summary>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void S_C_B_Info_Fast(List<JointConfig> tagValue)
|
||||
{
|
||||
SendMsg(MesServer_SendProtocol_Info_Fast + JsonConvert.SerializeObject(tagValue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 12
|
||||
/// </summary>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void S_C_B_Info_Slow(Param_Slow tagValue)
|
||||
{
|
||||
SendMsg(MesServer_SendProtocol_Info_Slow + JsonConvert.SerializeObject(tagValue));
|
||||
}
|
||||
|
||||
|
||||
public static string Make_DeviceInfo(List<DeviceInfo> di)
|
||||
{
|
||||
var sendStr = MesServer_SendProtocol_DeviceInfo + JsonConvert.SerializeObject(di);
|
||||
return sendStr;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
466
DT_SCADA/Core/TagTypeCodeID.cs
Normal file
466
DT_SCADA/Core/TagTypeCodeID.cs
Normal file
@@ -0,0 +1,466 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
///1 X WorkStart 2 工件到位(PLC) 工件到位。托盘到达工位,并且托盘上有工件。
|
||||
///2 X RepairPartStatusPLC 3 RepairPartStatusPLC 备用
|
||||
///3 STRING RepairPathString 4 RepairPathString "工位返修字符串(121211112222111),前2位是西门子字符串格式,第一位是总长度,第二位是实际长度"
|
||||
///4 X EngineTypeGetOverMES 5 传递机型(MES) MES传递总成信息给PLC(上线工位)
|
||||
///5 X PartPalletGoOver 6 PartPalletGoOver 上线工位。0:正常工作;1:空托盘放行,PLC读取到此标志不走申请上线逻辑。
|
||||
///6 X MaterialVerifyOver 7 MaterialVerifyOver MES保存完质量数据,物料数据等与PLC信号交互完成后通知PLC,所以工步都完成,才可以放行工件,正常工作时工件放行的必要条件。
|
||||
///7 X FalseGo 8 FalseGo 按MES界面[不合格放行]按钮,MES发送此信号。操作者判断工件不合格,通知设备,按不合格方式放行工件,工件流转到返修下线工位后,返修下线。MES工作完成MES0.3=1,MES合格放行MES0.5=0,MES0.4=1
|
||||
///8 INT EngineTypeID 9 EngineTypeID MES发动机机型标志(必须PLC)
|
||||
///9 STRING EngineID 10 EngineID MES发动机编号(必须PLC)
|
||||
///10 STRING EngineType 11 机型(MES) MES发动机机型(必须PLC)
|
||||
///11 X PartPalletStatus 13 PartPalletStatus MES激发变量托盘到位离开(必须PLC)
|
||||
///12 X HeartBeatPLC 14 HeartBeatPLC 心跳处理:PLC收到MES心跳信号后,PLC延时5秒后,数值取反再写回PLC,写回PLC开始计时,如果5秒钟MES无反馈报通讯故障。
|
||||
///13 X HeartBeatMIS 15 HeartBeatMIS 间隔时间5S,心跳处理。收到PLC心跳信号后,MES按原值回写。PLC收到MES信号后延时5秒,取反写入,以此循环。
|
||||
///14 X TargetTimeRead 16 TargetTimeRead MES允许可读工位运行时间
|
||||
///15 Int MachineTargetTime 17 MachineTargetTime 目标运行时间
|
||||
///16 Int MachineActualTime 18 MachineActualTime 实际运行时间
|
||||
///17 X MesRead 19 允许保存(PLC) 质量数据可以读数据
|
||||
///18 X MesReadOver 20 保存完成(MES) MES保存完数据(必须MIS)
|
||||
///19 INT QualityMask 21 合格标志(PLC) 质量数据工位合格标志0:没有工作;1:合格 ;2 :不合格(必须PLC)
|
||||
///20 B PalletInfo 22 PalletInfo 0空托盘,1合格件,2不合格件
|
||||
///21 INT RepairStatusPLC 23 RepairStatusPLC 0正常件,1返修件
|
||||
///22 INT OrderNo 24 订单号(MES) 订单号(MES)
|
||||
///23 X StorageNo 25 库位号(MES) 库位号(MES)
|
||||
///24 X AllowPass 26 允许放行(MES) 允许放行
|
||||
///25 X PartLoadFinish 27 PartLoadFinish PartLoadFinish
|
||||
///26 X Reserved_7 28 Reserved_7 备用
|
||||
///27 X Reserved_8 29 Reserved_8 备用
|
||||
///28 X Reserved_9 30 Reserved_9 备用
|
||||
///29 X Reserved_10 31 Reserved_10 备用
|
||||
///30 X Reserved_11 32 Reserved_11 备用
|
||||
///31 X Reserved_12 33 Reserved_12 备用
|
||||
///32 X Reserved_13 34 Reserved_13 备用
|
||||
///33 X Reserved_14 35 Reserved_14 备用
|
||||
///34 Int PLCSPareint1 36 PLCSPareint1 备用
|
||||
///35 Int PLCSPareint2 37 PLCSPareint2 备用
|
||||
///36 Int PLCSPareint3 38 PLCSPareint3 备用
|
||||
///37 STRING PLCSarestring1 39 PLCSarestring1 备用
|
||||
///38 STRING PLCSarestring2 40 PLCSarestring2 备用
|
||||
///39 STRING MarkID 42 MarkID 机体打标号(MES)前2位是西门子字符串格式,第一位是总长度,第二位是实际长度
|
||||
///40 X PartLoad 43 PartLoad 上线工位,PLC向MES申请总成编号。收到该信号后,MES将机型标志(DBB22 ~23)、总成号(DBB24 ~63)、总成机型DBB64 ~103写入PLC。之后MES通过信号“传递机型(DBX0.1)”通知PLC。
|
||||
///41 X EngineTypeGetOverPLC 44 传递机型(PLC) PLC将机型标志(DBB50…51)、工件编号(DBB52…101)、产品型号(DBB102…187)、托盘编号(DBB188…189)准备完毕后,通知MES。
|
||||
///42 X PartLoadOK 48 PartLoadOK 备用
|
||||
///43 X Reserved_18 49 Reserved_18 备用
|
||||
///44 X PalletDown 50 PalletDown 暂时保留,项目未使用
|
||||
///45 X ConfirmOkGo 51 ConfirmOkGo 按MES界面[合格放行]按钮,MES发送此信号。操作者判断工件合格,通知设备,工件按合格方式放行工件。MES工作完成MES0.3=1,MES合格放行MES0.5=1,MES0.4=0
|
||||
///46 X ResetDevice 52 ResetDevice 针对手动工位,无HMI,需要复位设备在MES页面操作。
|
||||
///47 X UnloadCompleted 53 UnloadCompleted 暂时保留,项目未使用
|
||||
///48 X MachineTime_ReadOver 54 MachineTime_ReadOver 备用
|
||||
///49 X Reserved_19 58 Reserved_19 备用
|
||||
///50 X FixOK 59 FixOK 手动拧紧工位,单工步螺栓拧紧完成,通知PC读取数据。
|
||||
///51 X Reserved_21 61 Reserved_21 备用
|
||||
///52 X Reserved_22 62 Reserved_22 备用
|
||||
///53 X Reserved_23 63 Reserved_23 备用
|
||||
///54 X Reserved_24 64 Reserved_24 备用
|
||||
///55 X Reserved_25 65 Reserved_25 备用
|
||||
///56 X FixAllow 66 FixAllow "设备工作的必须信号,对于有物料验证的工位,MES验证完成给出此信号,对于无物料验证工位,MES直接给出此信号。"
|
||||
///57 X FixOver 67 FixOver 用于手动拧紧且有质量数据工位。通知设备当前工步拧紧螺钉工作结束。
|
||||
///58 X MatchingCompleted 68 MatchingCompleted 分线上总线,匹配成功是1;不成功是0。
|
||||
///59 X Match 69 Match 分线上总线,匹配成功是1;不成功是0。
|
||||
///60 X Reserved_2 70 Reserved_2 备用
|
||||
///61 X IsAutoGetEngineID 71 IsAutoGetEngineID 自动手动申请工件编号。0是自动方式;1:手动方式。暂时保留,生成流水号方式是在数据库中实现的
|
||||
///62 X RepairUplineMES 72 RepairUplineMES 上线清空MOBY(针对上线工位):通知PLC从新开始申请上线流程
|
||||
///63 INT EngineTypeID_MES 73 机型代码(MES) MES发动机机型标志(必须MES)
|
||||
///64 STRING EngineID_MES 74 工件编号(MES) MES发动机编号(必须MES)
|
||||
///65 STRING EngineType_MES 75 EngineType_MES MES发动机机型(必须MES)
|
||||
///66 X Reserved_20 76 Reserved_20 备用
|
||||
///67 INT ProcessCode 77 ProcessCode 手动拧紧工位:由MES通知PLC拧紧序号
|
||||
///68 B OnLineState 79 OnLineState 通过线体工位PC实现下达工位工作状态:工位有三种状态:在线、离线、屏蔽。在线:0正常状态,实现正常功能。1离线:设备脱离MES工作,进入不交互模式。
|
||||
///69 INT PartPalletCode 80 托盘号(MES) 托盘编号(B5A)
|
||||
///70 INT BoltCode 88 BoltCode 手动拧紧工位:指导PLC所用套筒
|
||||
///71 INT RepairStatus 93 RepairStatus "0正常件,1返修件。对于上线工位MES给出是正常上线还是返修上线,返修路径"
|
||||
///72 DInt Reserved_15 110 Reserved_15 备用
|
||||
///73 DInt Reserved_16 111 Reserved_16 备用
|
||||
///74 B Reserved_17 112 Reserved_17 备用
|
||||
///75 INT SPareint1 113 SPareint1 备用int1
|
||||
///76 INT SPareint2 114 SPareint2 备用int2
|
||||
///77 INT SPareint3 115 SPareint3 备用int3
|
||||
///78 STRING Sparestring1 116 Sparestring1 备用字符串1
|
||||
///79 STRING Sparestring2 117 Sparestring2 备用字符串2
|
||||
///80 X MachineStatusPutOn 1000 机床上电(PLC) 机床上电(必须PLC)
|
||||
///81 X MachineStatusWorkOn 1001 循环开始(PLC) 循环开始(必须PLC)
|
||||
///82 X MachineStatusAlarm 1002 设备报警(PLC) 机床故障(必须PLC)
|
||||
///83 X MachineStatusNoPart 1003 MachineStatusNoPart 上料无件(必须PLC)
|
||||
///84 X MachineStatusBlock 1004 MachineStatusBlock 下料堵塞(必须PLC)
|
||||
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
/// <summary>
|
||||
/// 这是变量类型代码的配置,几乎是不变的
|
||||
/// 请不要随意修改,为了保证变量版本同一,并且方便维护,请联系发行人修改!
|
||||
/// 请注意,此修改为全局修改!
|
||||
/// </summary>
|
||||
public enum EnumTagTypeCodeID
|
||||
{
|
||||
/// <summary>
|
||||
/// 工件到位(PLC)
|
||||
/// 变量类型:Bool
|
||||
/// 解释:托盘到达工位,并且托盘上有工件。
|
||||
/// </summary>
|
||||
WorkStart = 2,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
RepairPartStatusPLC = 3,
|
||||
/// <summary>
|
||||
/// 工位返修字符串
|
||||
/// 变量类型:String
|
||||
/// 解释:工位返修字符串
|
||||
/// </summary>
|
||||
RepairPathString = 4,
|
||||
/// <summary>
|
||||
/// 传递机型(MES)
|
||||
/// 变量类型:Bool
|
||||
/// 解释:MES传递总成信息给PLC(上线工位)
|
||||
/// </summary>
|
||||
EngineTypeGetOverMES = 5,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
PartPalletGoOver = 6,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
MaterialVerifyOver = 7,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
FalseGo = 8,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EngineTypeID = 9,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EngineID = 10,
|
||||
/// <summary>
|
||||
/// 机型(MES)
|
||||
/// 变量类型:String
|
||||
/// </summary>
|
||||
EngineType = 11,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
PartPalletStatus = 13,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
HeartBeatPLC = 14,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
HeartBeatMIS = 15,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
TargetTimeRead = 16,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
MachineTargetTime = 17,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
MachineActualTime = 18,
|
||||
/// <summary>
|
||||
/// 允许保存(PLC)
|
||||
/// 变量类型:Bool
|
||||
/// </summary>
|
||||
MesRead = 19,
|
||||
/// <summary>
|
||||
/// 保存完成(MES)
|
||||
/// 变量类型:Bool
|
||||
/// </summary>
|
||||
MesReadOver = 20,
|
||||
/// <summary>
|
||||
/// 合格标志(PLC)
|
||||
/// 变量类型:Int
|
||||
/// </summary>
|
||||
QualityMask = 21,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
PalletInfo = 22,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
RepairStatusPLC = 23,
|
||||
/// <summary>
|
||||
/// 订单号(MES)
|
||||
/// 变量类型:Int
|
||||
/// </summary>
|
||||
OrderNo = 24,
|
||||
/// <summary>
|
||||
/// 库位号(MES)
|
||||
/// 变量类型:Bool
|
||||
/// </summary>
|
||||
StorageNo = 25,
|
||||
/// <summary>
|
||||
/// 允许放行(MES)
|
||||
/// 变量类型:Bool
|
||||
/// </summary>
|
||||
AllowPass = 26,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
PartLoadFinish = 27,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_7 = 28,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_8 = 29,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_9 = 30,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_10 = 31,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_11 = 32,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_12 = 33,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_13 = 34,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_14 = 35,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
PLCSPareint1 = 36,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
PLCSPareint2 = 37,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
PLCSPareint3 = 38,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
PLCSarestring1 = 39,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
PLCSarestring2 = 40,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
MarkID = 42,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
PartLoad = 43,
|
||||
/// <summary>
|
||||
/// 传递机型(PLC)
|
||||
/// 变量类型:Bool
|
||||
/// </summary>
|
||||
EngineTypeGetOverPLC = 44,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
PartLoadOK = 48,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_18 = 49,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
PalletDown = 50,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
ConfirmOkGo = 51,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
ResetDevice = 52,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
UnloadCompleted = 53,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
MachineTime_ReadOver = 54,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_19 = 58,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
FixOK = 59,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_21 = 61,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_22 = 62,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_23 = 63,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_24 = 64,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_25 = 65,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
FixAllow = 66,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
FixOver = 67,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
MatchingCompleted = 68,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Match = 69,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_2 = 70,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
IsAutoGetEngineID = 71,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
RepairUplineMES = 72,
|
||||
/// <summary>
|
||||
/// 机型代码(MES)
|
||||
/// 变量类型:Int
|
||||
/// </summary>
|
||||
EngineTypeID_MES = 73,
|
||||
/// <summary>
|
||||
/// 工件编号(MES)
|
||||
/// 变量类型:String
|
||||
/// </summary>
|
||||
EngineID_MES = 74,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EngineType_MES = 75,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_20 = 76,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
ProcessCode = 77,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
OnLineState = 79,
|
||||
/// <summary>
|
||||
/// 托盘号(MES)
|
||||
/// 变量类型:Int
|
||||
/// </summary>
|
||||
PartPalletCode = 80,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
BoltCode = 88,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
RepairStatus = 93,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_15 = 110,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_16 = 111,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reserved_17 = 112,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
SPareint1 = 113,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
SPareint2 = 114,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
SPareint3 = 115,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Sparestring1 = 116,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Sparestring2 = 117,
|
||||
/// <summary>
|
||||
/// 机床上电(PLC)
|
||||
/// 变量类型:Bool
|
||||
/// </summary>
|
||||
MachineStatusPutOn = 1000,
|
||||
/// <summary>
|
||||
/// 循环开始(PLC)
|
||||
/// 变量类型:Bool
|
||||
/// </summary>
|
||||
MachineStatusWorkOn = 1001,
|
||||
/// <summary>
|
||||
/// 设备报警(PLC)
|
||||
/// 变量类型:Bool
|
||||
/// </summary>
|
||||
MachineStatusAlarm = 1002,
|
||||
/// <summary>
|
||||
/// 上料无件(PLC)
|
||||
/// 变量类型:Bool
|
||||
/// </summary>
|
||||
MachineStatusNoPart = 1003,
|
||||
/// <summary>
|
||||
/// 下料堵塞(PLC)
|
||||
/// 变量类型:Bool
|
||||
/// </summary>
|
||||
MachineStatusBlock = 1004,
|
||||
/// <summary>
|
||||
/// 下料堵塞(PLC)
|
||||
/// 变量类型:Bool
|
||||
/// </summary>
|
||||
havePart70 = 10003,
|
||||
}
|
||||
}
|
||||
12890
DT_SCADA/Core/fwlib32.cs
Normal file
12890
DT_SCADA/Core/fwlib32.cs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user