|
|
@@ -30,6 +30,7 @@ using static AutoMapper.Internal.ExpressionFactory;
|
|
|
using Microsoft.EntityFrameworkCore.Internal;
|
|
|
using Org.BouncyCastle.Asn1.Ocsp;
|
|
|
using Ubiety.Dns.Core;
|
|
|
+using static IMCS.CCS.Models.vo.ResponseECSData;
|
|
|
|
|
|
namespace IMCS.CCS.Services
|
|
|
{
|
|
|
@@ -111,31 +112,31 @@ namespace IMCS.CCS.Services
|
|
|
}
|
|
|
if (sxlzxlqq.Count == 0)
|
|
|
{
|
|
|
- sxlzslqq.Add("129", "DB1001.112");
|
|
|
- sxlzslqq.Add("446", "DB1001.112");
|
|
|
+ sxlzxlqq.Add("129", "DB1001.112");
|
|
|
+ sxlzxlqq.Add("446", "DB1001.112");
|
|
|
|
|
|
- sxlzslqq.Add("130", "DB1001.114");
|
|
|
- sxlzslqq.Add("447", "DB1001.114");
|
|
|
+ sxlzxlqq.Add("130", "DB1001.114");
|
|
|
+ sxlzxlqq.Add("447", "DB1001.114");
|
|
|
}
|
|
|
|
|
|
if (sxlzslwcxh.Count == 0)
|
|
|
{
|
|
|
- sxlzslqq.Add("129", "DB1000.42");
|
|
|
- sxlzslqq.Add("446", "DB1000.42");
|
|
|
+ sxlzslwcxh.Add("129", "DB1000.42");
|
|
|
+ sxlzslwcxh.Add("446", "DB1000.42");
|
|
|
|
|
|
|
|
|
|
|
|
- sxlzslqq.Add("130", "DB1000.44");
|
|
|
- sxlzslqq.Add("447", "DB1000.44");
|
|
|
+ sxlzslwcxh.Add("130", "DB1000.44");
|
|
|
+ sxlzslwcxh.Add("447", "DB1000.44");
|
|
|
}
|
|
|
if (sxlzxlwcxh.Count == 0)
|
|
|
{
|
|
|
- sxlzslqq.Add("129", "DB1001.112");
|
|
|
- sxlzslqq.Add("446", "DB1001.112");
|
|
|
+ sxlzxlwcxh.Add("129", "DB1001.112");
|
|
|
+ sxlzxlwcxh.Add("446", "DB1001.112");
|
|
|
|
|
|
|
|
|
- sxlzslqq.Add("130", "DB1000.48");
|
|
|
- sxlzslqq.Add("447", "DB1000.50");
|
|
|
+ sxlzxlwcxh.Add("130", "DB1000.48");
|
|
|
+ sxlzxlwcxh.Add("447", "DB1000.50");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -318,7 +319,7 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
//查询出需要检查的地址列表
|
|
|
List<CcsActionAddress> CcsActionAddressChecks = CcsActionAddresses.Where(o => o.Type == ActionAddressTypeEnum.CHECK.ToString()).ToList();
|
|
|
- foreach (CcsActionAddress actionAddress in CcsActionAddressChecks)
|
|
|
+ /*foreach (CcsActionAddress actionAddress in CcsActionAddressChecks)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(actionAddress.Address) && !string.IsNullOrEmpty(actionAddress.Value))
|
|
|
{
|
|
|
@@ -351,10 +352,10 @@ namespace IMCS.CCS.Services
|
|
|
return responseData;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
//写入子盘编码,让plc去校验编码是否正确
|
|
|
- if (req.data.TrayLatheType == "1")
|
|
|
+ /*if (req.data.TrayLatheType == "1")
|
|
|
{
|
|
|
s7.Write("DB1001.6", ToolUtils.ReturnBtyesWtitString(req.data.TrayLatheCode, 39));
|
|
|
|
|
|
@@ -362,7 +363,7 @@ namespace IMCS.CCS.Services
|
|
|
else if (req.data.TrayLatheType == "4")
|
|
|
{
|
|
|
s7.Write("DB1001.54", ToolUtils.ReturnBtyesWtitString(req.data.TrayLatheCode, 39));
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
//查询写入地址列表
|
|
|
string log = "任务【" + req.taskNodeId + "】写入:";
|
|
|
@@ -383,7 +384,7 @@ namespace IMCS.CCS.Services
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- s7.Write(actionAddress.Address, Convert.ToInt16(actionAddress.Value));
|
|
|
+ s7.Write(actionAddress.Address, Convert.ToBoolean(actionAddress.Value));
|
|
|
log = log + "地址:" + actionAddress.Address + "【" + actionAddress.Value + "】";
|
|
|
}
|
|
|
}
|
|
|
@@ -393,9 +394,25 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
s7.ConnectClose();
|
|
|
|
|
|
+ //查询回调表是否存在此数据(避免在数据重复下发时,产生多条回调数据)
|
|
|
+ TaskCallback vo = new TaskCallback(null, ActionTypeEnum.RobotAction.ToString(),
|
|
|
+ null, req.taskId, req.taskNodeId);
|
|
|
+
|
|
|
+ List<TaskCallback> taskCallbackList = await _taskCallbackService.GetListByCondition(vo);
|
|
|
//插入回调
|
|
|
- TaskCallback taskCallbackData = new TaskCallback(req.url, ActionTypeEnum.RobotAction.ToString(),
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.RobotAction), req.taskId, req.taskNodeId);
|
|
|
+ TaskCallback taskCallbackData = new TaskCallback();
|
|
|
+ if (taskCallbackList != null && taskCallbackList.Count > 0)
|
|
|
+ {
|
|
|
+ taskCallbackData = taskCallbackList[0];
|
|
|
+
|
|
|
+ taskCallbackData.State = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ taskCallbackData = new TaskCallback(req.url, ActionTypeEnum.RobotAction.ToString(),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.RobotAction), req.taskId, req.taskNodeId);
|
|
|
+ }
|
|
|
+
|
|
|
taskCallbackData = setCallBackValue(CcsActionAddresses, taskCallbackData);
|
|
|
|
|
|
|
|
|
@@ -440,10 +457,17 @@ namespace IMCS.CCS.Services
|
|
|
{
|
|
|
string name = item.Name;
|
|
|
object value = item.GetValue(t, null);
|
|
|
- if ((item.PropertyType.IsValueType || item.PropertyType.Name.StartsWith("String")) && name == propertyName)
|
|
|
+ /*if ((item.PropertyType.IsValueType || item.PropertyType.Name.StartsWith("String")) && name == propertyName)
|
|
|
{
|
|
|
tStr = value.ToString();
|
|
|
break;
|
|
|
+ }*/
|
|
|
+
|
|
|
+ if ((item.PropertyType.IsValueType || item.PropertyType == typeof(string))
|
|
|
+ && string.Equals(name, propertyName, StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ tStr = value?.ToString() ?? string.Empty;
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -2842,5 +2866,77 @@ EnumHelper.GetDescription(ActionTypeEnum.StartDryMachine));
|
|
|
return responseData;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public async Task<ResponseECSData> writePoint(RequestData<RequestPoint> req)
|
|
|
+ {
|
|
|
+ ResponseECSData responseData = new ResponseECSData(req.taskId, req.taskNodeId);
|
|
|
+
|
|
|
+ List<string> pointList = req.data.pointList;
|
|
|
+
|
|
|
+ if (pointList == null || pointList.Count == 0)
|
|
|
+ {
|
|
|
+ responseData.result = "false";
|
|
|
+ responseData.msg = "参数点位集合为空";
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+
|
|
|
+ SiemensS7Net s7 = DevicePlcS7.SiemensS7(req.url);
|
|
|
+ OperateResult ConnectionResult = s7.ConnectServer();
|
|
|
+ if (!ConnectionResult.IsSuccess)
|
|
|
+ {
|
|
|
+ s7.ConnectClose();
|
|
|
+ responseData.result = "false";
|
|
|
+ responseData.msg = "PLC连接不上";
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (string point in pointList)
|
|
|
+ {
|
|
|
+ s7.Write(point, Convert.ToInt16("0"));
|
|
|
+
|
|
|
+ }
|
|
|
+ responseData.result = "true";
|
|
|
+ s7.ConnectClose();
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public async Task<ResponseCCSData<List<ResponseEcsPoint>>> readPoint(RequestData<RequestPoint> req)
|
|
|
+ {
|
|
|
+ ResponseCCSData<List<ResponseEcsPoint>> responseData = new ResponseCCSData<List<ResponseEcsPoint>>();
|
|
|
+
|
|
|
+ List<string> pointList = req.data.pointList;
|
|
|
+
|
|
|
+ if (pointList == null || pointList.Count == 0)
|
|
|
+ {
|
|
|
+ responseData.result = "false";
|
|
|
+ responseData.msg = "参数点位集合为空";
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+
|
|
|
+ SiemensS7Net s7 = DevicePlcS7.SiemensS7(req.url);
|
|
|
+ OperateResult ConnectionResult = s7.ConnectServer();
|
|
|
+ if (!ConnectionResult.IsSuccess)
|
|
|
+ {
|
|
|
+ s7.ConnectClose();
|
|
|
+ responseData.result = "false";
|
|
|
+ responseData.msg = "PLC连接不上," + ConnectionResult.ErrorCode + "," + ConnectionResult.Message;
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+ List<ResponseEcsPoint> responseEcsPointList = new List<ResponseEcsPoint>();
|
|
|
+ foreach (string point in pointList)
|
|
|
+ {
|
|
|
+ ResponseEcsPoint responseEcsPoint = new ResponseEcsPoint();
|
|
|
+ string result = s7.ReadInt16(point).Content.ToString();
|
|
|
+ responseEcsPoint.point = point;
|
|
|
+ responseEcsPoint.result = result;
|
|
|
+ responseEcsPointList.Add(responseEcsPoint);
|
|
|
+ }
|
|
|
+ responseData.result = "true";
|
|
|
+ responseData.data = responseEcsPointList;
|
|
|
+ s7.ConnectClose();
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
}
|
|
|
}
|