|
@@ -25,6 +25,7 @@ using IMCS_CCS.Service.Impl;
|
|
|
using IMCS_CCS.Service;
|
|
|
using IMCS_CCS.Entitys;
|
|
|
using static Google.Protobuf.Reflection.SourceCodeInfo.Types;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
|
|
|
namespace IMCS.CCS.Services
|
|
|
{
|
|
@@ -46,7 +47,7 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
private readonly ICcsActionDeviceSourceCheckService _ccsActionDeviceSourceCheckService;
|
|
|
|
|
|
- private int SLEEP_TIME = 1000;
|
|
|
+ private int SLEEP_TIME = 100;
|
|
|
|
|
|
string LocalPath = "D:\\PROG";
|
|
|
|
|
@@ -413,11 +414,31 @@ namespace IMCS.CCS.Services
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(actionAddress.Address) && !string.IsNullOrEmpty(actionAddress.Value))
|
|
|
{
|
|
|
- string operateResult = s7.ReadBool(actionAddress.Address).Content.ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string operateResult = "";
|
|
|
+ if (actionAddress.AddressType.Equals(TagValueReadTypeEnum.BOOL.ToString()))
|
|
|
+ {
|
|
|
+ operateResult = s7.ReadBool(actionAddress.Address).Content.ToString();
|
|
|
+ }
|
|
|
+ else if (actionAddress.AddressType.Equals(TagValueReadTypeEnum.SHORT.ToString()))
|
|
|
+ {
|
|
|
+ operateResult = s7.ReadInt16(actionAddress.Address).Content.ToString();
|
|
|
+ }
|
|
|
+ else if (actionAddress.AddressType.Equals(TagValueReadTypeEnum.String.ToString()))
|
|
|
+ {
|
|
|
+ operateResult = s7.ReadString(actionAddress.Address).Content.ToString();
|
|
|
+ }
|
|
|
+ else if (actionAddress.AddressType.Equals(TagValueReadTypeEnum.Byte.ToString()))
|
|
|
+ {
|
|
|
+ operateResult = s7.ReadByte(actionAddress.Address).Content.ToString();
|
|
|
+ }
|
|
|
+
|
|
|
if (actionAddress.CheckType ? operateResult != actionAddress.Value : operateResult == actionAddress.Value)
|
|
|
{
|
|
|
s7.ConnectClose();
|
|
|
- Log.Instance.WriteLogAdd(ActionTypeEnum.RobotAction + "异常===>>" + "条件不满足" + actionAddress.Address + "值应为:" + actionAddress.Value + "====实际为:" + operateResult + JsonConvert.SerializeObject(req),
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.RobotAction + "异常===>>" + "条件不满足" + actionAddress.Address + "值应为:" + actionAddress.Value + "====实际为:" + operateResult +",要查询的参数"+ JsonConvert.SerializeObject(actionAddress) +", 请求参数"+ JsonConvert.SerializeObject(req),
|
|
|
EnumHelper.GetDescription(ActionTypeEnum.RobotAction));
|
|
|
responseData.result = "false";
|
|
|
responseData.resultMsg = "异常===>>" + "条件不满足" + actionAddress.Address + "值应为:" + actionAddress.Value + "==实际为:" + operateResult;
|
|
@@ -797,7 +818,7 @@ namespace IMCS.CCS.Services
|
|
|
/// <returns></returns>
|
|
|
public async Task<ResponseECSData> CutterDeviceTakeOrPutRequest(RequestData<CutterLocationData> req)
|
|
|
{
|
|
|
- Log.Instance.WriteLogAdd("查询刀具上下料站、机床刀具位是否允许放===>> " + JsonConvert.SerializeObject(req), "刀具取放状态");
|
|
|
+ Log.Instance.WriteLogAdd("CNC刀具库请求上下料动作===>> " + JsonConvert.SerializeObject(req), "CNC刀具库请求上下料动作");
|
|
|
|
|
|
ResponseECSData responseData = new ResponseECSData(req.taskId, req.taskNodeId, "执行成功");
|
|
|
SiemensS7Net s7 = null;
|
|
@@ -875,11 +896,19 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
string before = "EMPTY00000";
|
|
|
if (req.data.Location != null && req.data.Location.Length>0) {
|
|
|
- before = "ATC00" + req.data.LocationNo + req.data.Location.Substring(7, 3);
|
|
|
+
|
|
|
+ int separatorIndex = req.data.LocationNo.IndexOf(".");
|
|
|
+ string substring = req.data.LocationNo.Substring(separatorIndex+1); // 从第7个字符开始截取5个字符
|
|
|
+
|
|
|
+ before = "ATC00" + substring + req.data.Location.Substring(7, 3);
|
|
|
}
|
|
|
string theTail = "EMPTY00000";
|
|
|
if (req.data.DestLocation != null && req.data.DestLocation.Length>0) {
|
|
|
- theTail = "ATC00" + req.data.DestLocationNo + req.data.DestLocation.Substring(7, 3);
|
|
|
+
|
|
|
+ int separatorIndex = req.data.DestLocationNo.IndexOf(".");
|
|
|
+ string substring = req.data.DestLocationNo.Substring(separatorIndex+1); // 从第7个字符开始截取5个字符
|
|
|
+
|
|
|
+ theTail = "ATC00" + substring + req.data.DestLocation.Substring(7, 3);
|
|
|
}
|
|
|
parValue = before + theTail;
|
|
|
|
|
@@ -1294,8 +1323,15 @@ namespace IMCS.CCS.Services
|
|
|
{
|
|
|
List<Device> devices = _deviceService.GetDeviceList();
|
|
|
|
|
|
- Device device = devices.Where(x => x.Ip.Equals(req.url) && x.Port.Equals(req.port)).FirstOrDefault();
|
|
|
+ List<Device> deviceList = devices.Where(x => x.Ip.Equals(req.url) && x.Port.Equals(req.port)).ToList();
|
|
|
+
|
|
|
+ if (deviceList ==null || deviceList.Count <= 0) {
|
|
|
+ throw new InvalidOperationException("没查询到设备数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ Device device = deviceList.FirstOrDefault();
|
|
|
List<ResponseToolData> list = new List<ResponseToolData>();
|
|
|
+
|
|
|
if (device.ProtocolType == ProtocalTypeEnum.OPCUA.ToString())
|
|
|
{
|
|
|
CcsTagValue tagValueQuery = new CcsTagValue();
|
|
@@ -1543,16 +1579,28 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
var Result = await _apiRequestService.RequestAsync(RequsetModeEnum.Post, hdhUrlContext, hdhReq, null);
|
|
|
ResponseHeidhData responseHeidhData = JsonConvert.DeserializeObject<ResponseHeidhData>(Result.Message);
|
|
|
+ JObject jsonObject = JObject.Parse(Result.Message);
|
|
|
+
|
|
|
if (!Result.IsSuccess || !responseHeidhData.result)
|
|
|
{
|
|
|
Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "机外对刀仪数据上传异常===>>" + JsonConvert.SerializeObject(req)+"======结果数据:"+ Result, "机外对刀仪");
|
|
|
responseData.result = "false";
|
|
|
- responseData.resultMsg = Result.Message;
|
|
|
+ responseData.resultMsg = jsonObject.GetValue("msg").ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- responseData.result = "true";
|
|
|
- responseData.resultMsg = "消费成功";
|
|
|
+
|
|
|
+ if (jsonObject.GetValue("result")!=null && bool.Parse(jsonObject.GetValue("result").ToString())) {
|
|
|
+ responseData.result = "true";
|
|
|
+ responseData.resultMsg = jsonObject.GetValue("msg").ToString();
|
|
|
+ responseData.returnData = jsonObject.GetValue("returnData").ToString();
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "机外对刀仪数据上传异常===>>" + JsonConvert.SerializeObject(req) + "======结果数据:" + Result, "机外对刀仪");
|
|
|
+ responseData.result = "false";
|
|
|
+ responseData.resultMsg = jsonObject.GetValue("msg").ToString();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -1661,10 +1709,13 @@ namespace IMCS.CCS.Services
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 关闭连接
|
|
|
+ s7.ConnectClose();
|
|
|
+
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
-
|
|
|
+ s7.ConnectClose();
|
|
|
Log.Instance.WriteLogAdd(ActionTypeEnum.ThreeDimensionalTakeStatus + "任务下发异常===>>" + ex.Message + JsonConvert.SerializeObject(req),
|
|
|
EnumHelper.GetDescription(ActionTypeEnum.ThreeDimensionalTakeStatus));
|
|
|
responseData.result = "false";
|
|
@@ -1762,9 +1813,14 @@ namespace IMCS.CCS.Services
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 关闭连接
|
|
|
+ s7.ConnectClose();
|
|
|
+
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
+ // 关闭连接
|
|
|
+ s7.ConnectClose();
|
|
|
|
|
|
Log.Instance.WriteLogAdd(ActionTypeEnum.ThreeDimensionalPutStatus + "任务下发异常===>>" + ex.Message + JsonConvert.SerializeObject(req),
|
|
|
EnumHelper.GetDescription(ActionTypeEnum.ThreeDimensionalPutStatus));
|
|
@@ -2140,9 +2196,14 @@ namespace IMCS.CCS.Services
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 关闭连接
|
|
|
+ s7.ConnectClose();
|
|
|
+
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
+ // 关闭连接
|
|
|
+ s7.ConnectClose();
|
|
|
|
|
|
Log.Instance.WriteLogAdd("CutterTake" + req.data.location + "任务下发异常===>>" + ex.Message + JsonConvert.SerializeObject(req),
|
|
|
"刀具取放状态");
|
|
@@ -2304,10 +2365,15 @@ namespace IMCS.CCS.Services
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 关闭连接
|
|
|
+ s7.ConnectClose();
|
|
|
+
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
+ // 关闭连接
|
|
|
+ s7.ConnectClose();
|
|
|
Log.Instance.WriteLogAdd("CutterPut" + req.data.location + "任务下发异常===>>" + ex.Message + JsonConvert.SerializeObject(req),
|
|
|
"刀具取放状态");
|
|
|
responseData.result = "false";
|