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