优化FanucHsl驱动
This commit is contained in:
parent
086700c8c7
commit
79d74b9fd4
@ -1,7 +1,4 @@
|
|||||||
|
using PluginInterface;
|
||||||
using PluginInterface;
|
|
||||||
using System;
|
|
||||||
using System.Text;
|
|
||||||
using HslCommunication.CNC.Fanuc;
|
using HslCommunication.CNC.Fanuc;
|
||||||
using HslCommunication;
|
using HslCommunication;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -9,29 +6,25 @@ using Microsoft.Extensions.Logging;
|
|||||||
namespace DriverFanucHsl
|
namespace DriverFanucHsl
|
||||||
{
|
{
|
||||||
[DriverSupported("Fanuc-0i")]
|
[DriverSupported("Fanuc-0i")]
|
||||||
[DriverInfoAttribute("Fanuc-0i", "V11.0.0", "Copyright HSL ")]
|
[DriverInfo("Fanuc-0i", "V11.0.0", "Copyright HSL ")]
|
||||||
public class FanucHsl : IDriver
|
public class FanucHsl : IDriver
|
||||||
{
|
{
|
||||||
private FanucSeries0i fanuc;
|
private FanucSeries0i _fanuc;
|
||||||
|
|
||||||
public ILogger _logger { get; set; }
|
public ILogger _logger { get; set; }
|
||||||
private readonly string _device;
|
private readonly string _device;
|
||||||
|
|
||||||
#region 配置参数
|
#region 配置参数
|
||||||
|
|
||||||
[ConfigParameter("设备Id")]
|
[ConfigParameter("设备Id")] public string DeviceId { get; set; }
|
||||||
public Guid DeviceId { get; set; }
|
|
||||||
|
|
||||||
[ConfigParameter("IP地址")]
|
[ConfigParameter("IP地址")] public string IpAddress { get; set; } = "127.0.0.1";
|
||||||
public string IpAddress { get; set; } = "127.0.0.1";
|
|
||||||
|
|
||||||
[ConfigParameter("端口号")]
|
[ConfigParameter("端口号")] public int Port { get; set; } = 8193;
|
||||||
public int Port { get; set; } = 8193;
|
|
||||||
|
|
||||||
[ConfigParameter("超时时间ms")]
|
[ConfigParameter("超时时间ms")] public int Timeout { get; set; } = 3000;
|
||||||
public int Timeout { get; set; } = 3000;
|
|
||||||
|
|
||||||
[ConfigParameter("最小通讯周期ms")]
|
[ConfigParameter("最小通讯周期ms")] public uint MinPeriod { get; set; } = 3000;
|
||||||
public uint MinPeriod { get; set; } = 3000;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -54,21 +47,16 @@ namespace DriverFanucHsl
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (fanuc == null)
|
if (_fanuc == null)
|
||||||
return false;
|
return false;
|
||||||
else
|
|
||||||
|
OperateResult<int[]> read = _fanuc.ReadProgramList();
|
||||||
|
if (read.IsSuccess)
|
||||||
{
|
{
|
||||||
OperateResult<int[]> read = fanuc.ReadProgramList();
|
return true;
|
||||||
if (read.IsSuccess)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,46 +64,42 @@ namespace DriverFanucHsl
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fanuc?.ConnectClose();
|
_fanuc.ConnectClose();
|
||||||
fanuc = new FanucSeries0i(IpAddress, Port);
|
_fanuc = new FanucSeries0i(IpAddress, Port);
|
||||||
return fanuc.ConnectServer().IsSuccess;
|
return _fanuc.ConnectServer().IsSuccess;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return IsConnected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Close()
|
public bool Close()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fanuc.ConnectClose();
|
_fanuc.ConnectClose();
|
||||||
return !IsConnected;
|
return !IsConnected;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "读系统状态")]
|
[Method("Fanuc", description: "读系统状态")]
|
||||||
public DriverReturnValueModel ReadSysStatusInfo(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadSysStatusInfo(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<SysStatusInfo> read = fanuc.ReadSysStatusInfo();
|
OperateResult<SysStatusInfo> read = _fanuc.ReadSysStatusInfo();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = Newtonsoft.Json.JsonConvert.SerializeObject(read.Content);
|
ret.Value = Newtonsoft.Json.JsonConvert.SerializeObject(read.Content);
|
||||||
else
|
else
|
||||||
@ -135,18 +119,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "读报警信息")]
|
[Method("Fanuc", description: "读报警信息")]
|
||||||
public DriverReturnValueModel ReadSystemAlarm(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadSystemAlarm(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<SysAlarm[]> read = fanuc.ReadSystemAlarm();
|
OperateResult<SysAlarm[]> read = _fanuc.ReadSystemAlarm();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = Newtonsoft.Json.JsonConvert.SerializeObject(read.Content);
|
ret.Value = Newtonsoft.Json.JsonConvert.SerializeObject(read.Content);
|
||||||
else
|
else
|
||||||
@ -166,18 +151,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "坐标数据")]
|
[Method("Fanuc", description: "坐标数据")]
|
||||||
public DriverReturnValueModel ReadSysAllCoors(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadSysAllCoors(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<SysAllCoors> read = fanuc.ReadSysAllCoors();
|
OperateResult<SysAllCoors> read = _fanuc.ReadSysAllCoors();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = Newtonsoft.Json.JsonConvert.SerializeObject(read.Content);
|
ret.Value = Newtonsoft.Json.JsonConvert.SerializeObject(read.Content);
|
||||||
else
|
else
|
||||||
@ -197,18 +183,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "程序列表")]
|
[Method("Fanuc", description: "程序列表")]
|
||||||
public DriverReturnValueModel ReadProgramList(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadProgramList(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<int[]> read = fanuc.ReadProgramList();
|
OperateResult<int[]> read = _fanuc.ReadProgramList();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -228,62 +215,29 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "当前程序名")]
|
[Method("Fanuc", description: "当前程序名")]
|
||||||
public DriverReturnValueModel ReadSystemProgramCurrent(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadSystemProgramCurrent(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<string, int> read = fanuc.ReadSystemProgramCurrent();
|
OperateResult<string, int> read = _fanuc.ReadSystemProgramCurrent();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = Newtonsoft.Json.JsonConvert.SerializeObject(
|
ret.Value = Newtonsoft.Json.JsonConvert.SerializeObject(
|
||||||
new Dictionary<string, object>() { { "ProgramName", read.Content1 }, { "ProgramNo", read.Content2 } }
|
new Dictionary<string, object>()
|
||||||
);
|
{ { "ProgramName", read.Content1 }, { "ProgramNo", read.Content2 } }
|
||||||
else
|
|
||||||
{
|
|
||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
|
||||||
ret.Message = $"读取失败";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
|
||||||
ret.Message = $"读取失败,{ex.Message}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
|
||||||
ret.Message = "连接失败";
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Method("Fanuc", description: "主轴转进速")]
|
|
||||||
public DriverReturnValueModel ReadSpindleSpeedAndFeedRate(DriverAddressIoArgModel Ioarg)
|
|
||||||
{
|
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
|
||||||
if (IsConnected)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
OperateResult<double, double> read = fanuc.ReadSpindleSpeedAndFeedRate();
|
|
||||||
if (read.IsSuccess)
|
|
||||||
ret.Value = Newtonsoft.Json.JsonConvert.SerializeObject(
|
|
||||||
new Dictionary<string, object>() { { "SpindleSpeed", read.Content1 }, { "FeedRate", read.Content2 } }
|
|
||||||
);
|
);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = $"读取失败";
|
ret.Message = $"读取失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -296,18 +250,54 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "伺服负载")]
|
[Method("Fanuc", description: "主轴转进速")]
|
||||||
public DriverReturnValueModel ReadFanucAxisLoad(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadSpindleSpeedAndFeedRate(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<double[]> read = fanuc.ReadFanucAxisLoad();
|
OperateResult<double, double> read = _fanuc.ReadSpindleSpeedAndFeedRate();
|
||||||
|
if (read.IsSuccess)
|
||||||
|
ret.Value = Newtonsoft.Json.JsonConvert.SerializeObject(
|
||||||
|
new Dictionary<string, object>()
|
||||||
|
{ { "SpindleSpeed", read.Content1 }, { "FeedRate", read.Content2 } }
|
||||||
|
);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
|
ret.Message = $"读取失败";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
|
ret.Message = $"读取失败,{ex.Message}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
|
ret.Message = "连接失败";
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Method("Fanuc", description: "伺服负载")]
|
||||||
|
public DriverReturnValueModel ReadFanucAxisLoad(DriverAddressIoArgModel ioarg)
|
||||||
|
{
|
||||||
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
|
if (IsConnected)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OperateResult<double[]> read = _fanuc.ReadFanucAxisLoad();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -327,18 +317,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "道具补偿")]
|
[Method("Fanuc", description: "道具补偿")]
|
||||||
public DriverReturnValueModel ReadCutterInfos(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadCutterInfos(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<CutterInfo[]> read = fanuc.ReadCutterInfos();
|
OperateResult<CutterInfo[]> read = _fanuc.ReadCutterInfos();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = Newtonsoft.Json.JsonConvert.SerializeObject(read.Content);
|
ret.Value = Newtonsoft.Json.JsonConvert.SerializeObject(read.Content);
|
||||||
else
|
else
|
||||||
@ -358,18 +349,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "程序路径")]
|
[Method("Fanuc", description: "程序路径")]
|
||||||
public DriverReturnValueModel ReadCurrentForegroundDir(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadCurrentForegroundDir(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<string> read = fanuc.ReadCurrentForegroundDir();
|
OperateResult<string> read = _fanuc.ReadCurrentForegroundDir();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -389,18 +381,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "工件尺寸")]
|
[Method("Fanuc", description: "工件尺寸")]
|
||||||
public DriverReturnValueModel ReadDeviceWorkPiecesSize(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadDeviceWorkPiecesSize(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<double[]> read = fanuc.ReadDeviceWorkPiecesSize();
|
OperateResult<double[]> read = _fanuc.ReadDeviceWorkPiecesSize();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -420,18 +413,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "报警代号")]
|
[Method("Fanuc", description: "报警代号")]
|
||||||
public DriverReturnValueModel ReadAlarmStatus(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadAlarmStatus(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<int> read = fanuc.ReadAlarmStatus();
|
OperateResult<int> read = _fanuc.ReadAlarmStatus();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -451,18 +445,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "机床时间")]
|
[Method("Fanuc", description: "机床时间")]
|
||||||
public DriverReturnValueModel ReadCurrentDateTime(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadCurrentDateTime(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<DateTime> read = fanuc.ReadCurrentDateTime();
|
OperateResult<DateTime> read = _fanuc.ReadCurrentDateTime();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -482,18 +477,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "已加工数量")]
|
[Method("Fanuc", description: "已加工数量")]
|
||||||
public DriverReturnValueModel ReadCurrentProduceCount(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadCurrentProduceCount(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<int> read = fanuc.ReadCurrentProduceCount();
|
OperateResult<int> read = _fanuc.ReadCurrentProduceCount();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -513,18 +509,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "总加工数量")]
|
[Method("Fanuc", description: "总加工数量")]
|
||||||
public DriverReturnValueModel ReadExpectProduceCount(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadExpectProduceCount(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<int> read = fanuc.ReadExpectProduceCount();
|
OperateResult<int> read = _fanuc.ReadExpectProduceCount();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -544,18 +541,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "系统语言")]
|
[Method("Fanuc", description: "系统语言")]
|
||||||
public DriverReturnValueModel ReadLanguage(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadLanguage(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<ushort> read = fanuc.ReadLanguage();
|
OperateResult<ushort> read = _fanuc.ReadLanguage();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = (LanguageType)read.Content;
|
ret.Value = (LanguageType)read.Content;
|
||||||
else
|
else
|
||||||
@ -575,18 +573,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "当前程序")]
|
[Method("Fanuc", description: "当前程序")]
|
||||||
public DriverReturnValueModel ReadCurrentProgram(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadCurrentProgram(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<string> read = fanuc.ReadCurrentProgram();
|
OperateResult<string> read = _fanuc.ReadCurrentProgram();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -606,18 +605,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "开机时间")]
|
[Method("Fanuc", description: "开机时间")]
|
||||||
public DriverReturnValueModel ReadOnLineTime(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadOnLineTime(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<long> read = fanuc.ReadTimeData(0);
|
OperateResult<long> read = _fanuc.ReadTimeData(0);
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -637,18 +637,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "运行时间")]
|
[Method("Fanuc", description: "运行时间")]
|
||||||
public DriverReturnValueModel ReadRunTime(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadRunTime(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<long> read = fanuc.ReadTimeData(1);
|
OperateResult<long> read = _fanuc.ReadTimeData(1);
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -668,18 +669,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "切割时间")]
|
[Method("Fanuc", description: "切割时间")]
|
||||||
public DriverReturnValueModel ReadCuttingTime(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadCuttingTime(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<long> read = fanuc.ReadTimeData(2);
|
OperateResult<long> read = _fanuc.ReadTimeData(2);
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -699,18 +701,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "空闲时间")]
|
[Method("Fanuc", description: "空闲时间")]
|
||||||
public DriverReturnValueModel ReadIdleTime(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadIdleTime(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<long> read = fanuc.ReadTimeData(3);
|
OperateResult<long> read = _fanuc.ReadTimeData(3);
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -730,18 +733,19 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "当前道具号")]
|
[Method("Fanuc", description: "当前道具号")]
|
||||||
public DriverReturnValueModel ReadCutterNumber(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadCutterNumber(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OperateResult<int> read = fanuc.ReadCutterNumber();
|
OperateResult<int> read = _fanuc.ReadCutterNumber();
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -761,25 +765,26 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "读宏变量")]
|
[Method("Fanuc", description: "读宏变量")]
|
||||||
public DriverReturnValueModel ReadSystemMacroValue(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadSystemMacroValue(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!int.TryParse(Ioarg.Address, out int address))
|
if (!int.TryParse(ioarg.Address, out int address))
|
||||||
{
|
{
|
||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = $"宏变量地址错误";
|
ret.Message = $"宏变量地址错误";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OperateResult<double> read = fanuc.ReadSystemMacroValue(address);
|
OperateResult<double> read = _fanuc.ReadSystemMacroValue(address);
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -800,25 +805,26 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Method("Fanuc", description: "读取程序")]
|
[Method("Fanuc", description: "读取程序")]
|
||||||
public DriverReturnValueModel ReadProgramAsync(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel ReadProgramAsync(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good };
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!int.TryParse(Ioarg.Address, out int address))
|
if (!int.TryParse(ioarg.Address, out int address))
|
||||||
{
|
{
|
||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = $"程序号错误";
|
ret.Message = $"程序号错误";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OperateResult<string> read = fanuc.ReadProgram(address);
|
OperateResult<string> read = _fanuc.ReadProgram(address);
|
||||||
if (read.IsSuccess)
|
if (read.IsSuccess)
|
||||||
ret.Value = read.Content;
|
ret.Value = read.Content;
|
||||||
else
|
else
|
||||||
@ -839,17 +845,18 @@ namespace DriverFanucHsl
|
|||||||
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
ret.StatusType = VaribaleStatusTypeEnum.Bad;
|
||||||
ret.Message = "连接失败";
|
ret.Message = "连接失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<RpcResponse> WriteAsync(string RequestId, string Method, DriverAddressIoArgModel Ioarg)
|
public async Task<RpcResponse> WriteAsync(string requestId, string method, DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
RpcResponse rpcResponse = new() { IsSuccess = false, Description = "设备驱动内未实现写入功能" };
|
RpcResponse rpcResponse = new() { IsSuccess = false, Description = "设备驱动内未实现写入功能" };
|
||||||
return rpcResponse;
|
return rpcResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DriverReturnValueModel Read(DriverAddressIoArgModel Ioarg)
|
public DriverReturnValueModel Read(DriverAddressIoArgModel ioarg)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user