diff --git a/Plugins/Drivers/DriverAllenBradley/AllenBradley.cs b/Plugins/Drivers/DriverAllenBradley/AllenBradley.cs index 94e322e..8843e5d 100644 --- a/Plugins/Drivers/DriverAllenBradley/AllenBradley.cs +++ b/Plugins/Drivers/DriverAllenBradley/AllenBradley.cs @@ -3,7 +3,6 @@ using IoTClient.Enums; using PluginInterface; using System; using System.Text; -using IoTGateway.Model; using Microsoft.Extensions.Logging; namespace DriverAllenBradley @@ -15,7 +14,7 @@ namespace DriverAllenBradley private AllenBradleyClient plc = null; public ILogger _logger { get; set; } - private readonly Device _device; + private readonly string _device; #region 配置参数 [ConfigParameter("设备Id")] @@ -35,12 +34,12 @@ namespace DriverAllenBradley #endregion - public AllenBradley(Device device, ILogger logger) + public AllenBradley(string device, ILogger logger) { _device = device; _logger = logger; - _logger.LogInformation($"Device:[{_device.DeviceName}],Create()"); + _logger.LogInformation($"Device:[{device}],Create()"); } diff --git a/Plugins/Drivers/DriverAllenBradley/DriverAllenBradley.csproj b/Plugins/Drivers/DriverAllenBradley/DriverAllenBradley.csproj index b460b4d..d2e828e 100644 --- a/Plugins/Drivers/DriverAllenBradley/DriverAllenBradley.csproj +++ b/Plugins/Drivers/DriverAllenBradley/DriverAllenBradley.csproj @@ -14,6 +14,5 @@ - diff --git a/Plugins/Drivers/DriverFanuc/DriverFanuc.csproj b/Plugins/Drivers/DriverFanuc/DriverFanuc.csproj index 579346d..41dcdda 100644 --- a/Plugins/Drivers/DriverFanuc/DriverFanuc.csproj +++ b/Plugins/Drivers/DriverFanuc/DriverFanuc.csproj @@ -9,6 +9,5 @@ - diff --git a/Plugins/Drivers/DriverFanuc/Fanuc.cs b/Plugins/Drivers/DriverFanuc/Fanuc.cs index d1c7d8d..2265d72 100644 --- a/Plugins/Drivers/DriverFanuc/Fanuc.cs +++ b/Plugins/Drivers/DriverFanuc/Fanuc.cs @@ -1,5 +1,4 @@ -using IoTGateway.Model; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using PluginInterface; namespace DriverFaunc @@ -23,7 +22,7 @@ namespace DriverFaunc private int _result = -1; public ILogger _logger { get; set; } - private readonly Device _device; + private readonly string _device; public bool IsConnected { @@ -44,12 +43,12 @@ namespace DriverFaunc } } - public Fanuc(Device device, ILogger logger) + public Fanuc(string device, ILogger logger) { _device = device; _logger = logger; - _logger.LogInformation($"Device:[{_device.DeviceName}],Create()"); + _logger.LogInformation($"Device:[{device}],Create()"); } public bool Close() diff --git a/Plugins/Drivers/DriverFanucHsl/DriverFanucHsl.csproj b/Plugins/Drivers/DriverFanucHsl/DriverFanucHsl.csproj index 4f81f30..cb96cdd 100644 --- a/Plugins/Drivers/DriverFanucHsl/DriverFanucHsl.csproj +++ b/Plugins/Drivers/DriverFanucHsl/DriverFanucHsl.csproj @@ -15,6 +15,5 @@ - diff --git a/Plugins/Drivers/DriverFanucHsl/FanucHsl.cs b/Plugins/Drivers/DriverFanucHsl/FanucHsl.cs index 1acab67..db75c8f 100644 --- a/Plugins/Drivers/DriverFanucHsl/FanucHsl.cs +++ b/Plugins/Drivers/DriverFanucHsl/FanucHsl.cs @@ -4,7 +4,6 @@ using System; using System.Text; using HslCommunication.CNC.Fanuc; using HslCommunication; -using IoTGateway.Model; using Microsoft.Extensions.Logging; namespace DriverFanucHsl @@ -16,7 +15,7 @@ namespace DriverFanucHsl private FanucSeries0i fanuc; public ILogger _logger { get; set; } - private readonly Device _device; + private readonly string _device; #region 配置参数 [ConfigParameter("设备Id")] @@ -36,7 +35,7 @@ namespace DriverFanucHsl #endregion - public FanucHsl(Device device, ILogger logger) + public FanucHsl(string device, ILogger logger) { // 授权示例 Authorization example if (!Authorization.SetAuthorizationCode("输入你的授权号")) @@ -48,7 +47,7 @@ namespace DriverFanucHsl _logger = logger; - _logger.LogInformation($"Device:[{_device.DeviceName}],Create()"); + _logger.LogInformation($"Device:[{_device}],Create()"); } public bool IsConnected diff --git a/Plugins/Drivers/DriverMTConnect/DriverMTConnect.csproj b/Plugins/Drivers/DriverMTConnect/DriverMTConnect.csproj index 17cf3d3..82c2e3e 100644 --- a/Plugins/Drivers/DriverMTConnect/DriverMTConnect.csproj +++ b/Plugins/Drivers/DriverMTConnect/DriverMTConnect.csproj @@ -14,6 +14,5 @@ - diff --git a/Plugins/Drivers/DriverMTConnect/MTConnectClient.cs b/Plugins/Drivers/DriverMTConnect/MTConnectClient.cs index 04516a3..3b1e26d 100644 --- a/Plugins/Drivers/DriverMTConnect/MTConnectClient.cs +++ b/Plugins/Drivers/DriverMTConnect/MTConnectClient.cs @@ -2,7 +2,6 @@ using System; using Microsoft.Extensions.Logging; using OpenNETCF.MTConnect; -using Device = IoTGateway.Model.Device; namespace DriverMTConnect { @@ -30,14 +29,14 @@ namespace DriverMTConnect EntityClient m_client = null; public ILogger _logger { get; set; } - private readonly Device _device; + private readonly string _device; - public MTConnectClient(Device device, ILogger logger) + public MTConnectClient(string device, ILogger logger) { _device = device; _logger = logger; - _logger.LogInformation($"Device:[{_device.DeviceName}],Create()"); + _logger.LogInformation($"Device:[{_device}],Create()"); } public bool Close() diff --git a/Plugins/Drivers/DriverMitsubishi/DriverMitsubishi.csproj b/Plugins/Drivers/DriverMitsubishi/DriverMitsubishi.csproj index e88f3f4..42df9f2 100644 --- a/Plugins/Drivers/DriverMitsubishi/DriverMitsubishi.csproj +++ b/Plugins/Drivers/DriverMitsubishi/DriverMitsubishi.csproj @@ -14,6 +14,5 @@ - diff --git a/Plugins/Drivers/DriverMitsubishi/Mitsubishi.cs b/Plugins/Drivers/DriverMitsubishi/Mitsubishi.cs index 47b0725..9157926 100644 --- a/Plugins/Drivers/DriverMitsubishi/Mitsubishi.cs +++ b/Plugins/Drivers/DriverMitsubishi/Mitsubishi.cs @@ -3,7 +3,6 @@ using IoTClient.Enums; using PluginInterface; using System; using System.Text; -using IoTGateway.Model; using Microsoft.Extensions.Logging; namespace DriverMitsubishi @@ -16,7 +15,7 @@ namespace DriverMitsubishi private MitsubishiClient plc = null; public ILogger _logger { get; set; } - private readonly Device _device; + private readonly string _device; #region 配置参数 [ConfigParameter("设备Id")] @@ -39,12 +38,12 @@ namespace DriverMitsubishi #endregion - public Mitsubishi(Device device, ILogger logger) + public Mitsubishi(string device, ILogger logger) { _device = device; _logger = logger; - _logger.LogInformation($"Device:[{_device.DeviceName}],Create()"); + _logger.LogInformation($"Device:[{_device}],Create()"); } diff --git a/Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj b/Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj index 68b50e8..bca6eb3 100644 --- a/Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj +++ b/Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj @@ -12,7 +12,6 @@ - diff --git a/Plugins/Drivers/DriverModbusMaster/ModbusMaster.cs b/Plugins/Drivers/DriverModbusMaster/ModbusMaster.cs index 60ae502..9e37f47 100644 --- a/Plugins/Drivers/DriverModbusMaster/ModbusMaster.cs +++ b/Plugins/Drivers/DriverModbusMaster/ModbusMaster.cs @@ -1,5 +1,4 @@ -using IoTGateway.Model; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using Modbus.Device; using Modbus.Serial; using PluginInterface; @@ -23,7 +22,7 @@ namespace DriverModbusMaster private SerialPortAdapter? _adapter; public ILogger _logger { get; set; } - private readonly Device _device; + private readonly string _device; #region 配置参数 [ConfigParameter("设备Id")] @@ -67,12 +66,12 @@ namespace DriverModbusMaster #endregion - public ModbusMaster(Device device, ILogger logger) + public ModbusMaster(string device, ILogger logger) { _device = device; _logger = logger; - _logger.LogInformation($"Device:[{_device.DeviceName}],Create()"); + _logger.LogInformation($"Device:[{_device}],Create()"); } public bool IsConnected @@ -102,7 +101,7 @@ namespace DriverModbusMaster { try { - _logger.LogInformation($"Device:[{_device.DeviceName}],Connect()"); + _logger.LogInformation($"Device:[{_device}],Connect()"); switch (Master_TYPE) { case Master_TYPE.Tcp: @@ -163,7 +162,7 @@ namespace DriverModbusMaster } catch (Exception ex) { - _logger.LogError($"Device:[{_device.DeviceName}],Connect(),Error", ex); + _logger.LogError($"Device:[{_device}],Connect(),Error", ex); return false; } return IsConnected; @@ -173,7 +172,7 @@ namespace DriverModbusMaster { try { - _logger.LogInformation($"Device:[{_device.DeviceName}],Close()"); + _logger.LogInformation($"Device:[{_device}],Close()"); _tcpClient?.Close(); _udpClient?.Close(); _serialPort?.Close(); @@ -181,7 +180,7 @@ namespace DriverModbusMaster } catch (Exception ex) { - _logger.LogError($"Device:[{_device.DeviceName}],Close(),Error", ex); + _logger.LogError($"Device:[{_device}],Close(),Error", ex); return false; } } @@ -194,11 +193,11 @@ namespace DriverModbusMaster _udpClient?.Dispose(); _serialPort?.Dispose(); _master?.Dispose(); - _logger.LogInformation($"Device:[{_device.DeviceName}],Dispose()"); + _logger.LogInformation($"Device:[{_device}],Dispose()"); } catch (Exception ex) { - _logger.LogError($"Device:[{_device.DeviceName}],Dispose(),Error", ex); + _logger.LogError($"Device:[{_device}],Dispose(),Error", ex); } } @@ -220,7 +219,7 @@ namespace DriverModbusMaster { ret.StatusType = VaribaleStatusTypeEnum.UnKnow; ret.Message = ex.Message; - _logger.LogInformation($"Device:[{_device.DeviceName}],ReadHoldingRegisters(),Error", ex); + _logger.LogInformation($"Device:[{_device}],ReadHoldingRegisters(),Error", ex); } return ret; @@ -245,7 +244,7 @@ namespace DriverModbusMaster { ret.StatusType = VaribaleStatusTypeEnum.UnKnow; ret.Message = ex.Message; - _logger.LogInformation($"Device:[{_device.DeviceName}],ReadInputRegisters(),Error", ex); + _logger.LogInformation($"Device:[{_device}],ReadInputRegisters(),Error", ex); } return ret; @@ -282,7 +281,7 @@ namespace DriverModbusMaster { ret.StatusType = VaribaleStatusTypeEnum.UnKnow; ret.Message = ex.Message; - _logger.LogInformation($"Device:[{_device.DeviceName}],ReadCoil(),Error", ex); + _logger.LogInformation($"Device:[{_device}],ReadCoil(),Error", ex); } return ret; @@ -318,7 +317,7 @@ namespace DriverModbusMaster { ret.StatusType = VaribaleStatusTypeEnum.UnKnow; ret.Message = ex.Message; - _logger.LogInformation($"Device:[{_device.DeviceName}],ReadInput(),Error", ex); + _logger.LogInformation($"Device:[{_device}],ReadInput(),Error", ex); } return ret; @@ -387,7 +386,7 @@ namespace DriverModbusMaster { ret.StatusType = VaribaleStatusTypeEnum.Bad; ret.Message = ex.Message; - _logger.LogInformation($"Device:[{_device.DeviceName}],ReadRegistersBuffers(),Error", ex); + _logger.LogInformation($"Device:[{_device}],ReadRegistersBuffers(),Error", ex); } } @@ -497,7 +496,7 @@ namespace DriverModbusMaster ret.Message = ex.Message; StartAddress = 0; ReadCount = 0; - _logger.LogInformation($"Device:[{_device.DeviceName}],AnalyzeAddress(),Error", ex); + _logger.LogInformation($"Device:[{_device}],AnalyzeAddress(),Error", ex); return ret; } } @@ -555,7 +554,7 @@ namespace DriverModbusMaster catch (Exception ex) { rpcResponse.Description = $"写入失败,[Method]:{method},[Ioarg]:{ioarg},[ex]:{ex}"; - _logger.LogInformation($"Device:[{_device.DeviceName}],WriteAsync(),Error", ex); + _logger.LogInformation($"Device:[{_device}],WriteAsync(),Error", ex); } return rpcResponse; } diff --git a/Plugins/Drivers/DriverOPCDaClient/DriverOPCDaClient.csproj b/Plugins/Drivers/DriverOPCDaClient/DriverOPCDaClient.csproj index dd205ed..ed5f48e 100644 --- a/Plugins/Drivers/DriverOPCDaClient/DriverOPCDaClient.csproj +++ b/Plugins/Drivers/DriverOPCDaClient/DriverOPCDaClient.csproj @@ -10,7 +10,6 @@ - diff --git a/Plugins/Drivers/DriverOPCDaClient/OPCDaClient.cs b/Plugins/Drivers/DriverOPCDaClient/OPCDaClient.cs index 3cd6b1c..ef16a5e 100644 --- a/Plugins/Drivers/DriverOPCDaClient/OPCDaClient.cs +++ b/Plugins/Drivers/DriverOPCDaClient/OPCDaClient.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Automation.OPCClient; -using IoTGateway.Model; using Microsoft.Extensions.Logging; namespace DriverOPCDaClient @@ -15,7 +14,7 @@ namespace DriverOPCDaClient OPCClientWrapper opcDaClient = null; public ILogger _logger { get; set; } - private readonly Device _device; + private readonly string _device; #region 配置参数 @@ -33,12 +32,12 @@ namespace DriverOPCDaClient #endregion - public OPCDaClient(Device device, ILogger logger) + public OPCDaClient(string device, ILogger logger) { _device = device; _logger = logger; - _logger.LogInformation($"Device:[{_device.DeviceName}],Create()"); + _logger.LogInformation($"Device:[{_device}],Create()"); } diff --git a/Plugins/Drivers/DriverOPCUaClient/DriverOPCUaClient.csproj b/Plugins/Drivers/DriverOPCUaClient/DriverOPCUaClient.csproj index af13809..037b055 100644 --- a/Plugins/Drivers/DriverOPCUaClient/DriverOPCUaClient.csproj +++ b/Plugins/Drivers/DriverOPCUaClient/DriverOPCUaClient.csproj @@ -14,6 +14,5 @@ - diff --git a/Plugins/Drivers/DriverOPCUaClient/OPCUaClient.cs b/Plugins/Drivers/DriverOPCUaClient/OPCUaClient.cs index 43ac181..aea8d90 100644 --- a/Plugins/Drivers/DriverOPCUaClient/OPCUaClient.cs +++ b/Plugins/Drivers/DriverOPCUaClient/OPCUaClient.cs @@ -6,7 +6,6 @@ using Opc.Ua; using Opc.Ua.Client; using System.Collections.Generic; using System.Threading.Tasks; -using IoTGateway.Model; using Microsoft.Extensions.Logging; using Opc.Ua.Configuration; using OpcUaHelper; @@ -20,7 +19,7 @@ namespace DriverOPCUaClient OpcUaClientHelper opcUaClient = null; public ILogger _logger { get; set; } - private readonly Device _device; + private readonly string _device; #region 配置参数 [ConfigParameter("设备Id")] @@ -37,12 +36,12 @@ namespace DriverOPCUaClient #endregion - public OPCUaClient(Device device, ILogger logger) + public OPCUaClient(string device, ILogger logger) { _device = device; _logger = logger; - _logger.LogInformation($"Device:[{_device.DeviceName}],Create()"); + _logger.LogInformation($"Device:[{_device}],Create()"); } diff --git a/Plugins/Drivers/DriverOmronFins/DriverOmronFins.csproj b/Plugins/Drivers/DriverOmronFins/DriverOmronFins.csproj index e88f3f4..42df9f2 100644 --- a/Plugins/Drivers/DriverOmronFins/DriverOmronFins.csproj +++ b/Plugins/Drivers/DriverOmronFins/DriverOmronFins.csproj @@ -14,6 +14,5 @@ - diff --git a/Plugins/Drivers/DriverOmronFins/OmronFins.cs b/Plugins/Drivers/DriverOmronFins/OmronFins.cs index ea78abc..71b9b23 100644 --- a/Plugins/Drivers/DriverOmronFins/OmronFins.cs +++ b/Plugins/Drivers/DriverOmronFins/OmronFins.cs @@ -3,7 +3,6 @@ using IoTClient.Enums; using PluginInterface; using System; using System.Text; -using IoTGateway.Model; using Microsoft.Extensions.Logging; namespace DriverOmronFins @@ -15,7 +14,7 @@ namespace DriverOmronFins private OmronFinsClient plc = null; public ILogger _logger { get; set; } - private readonly Device _device; + private readonly string _device; #region 配置参数 [ConfigParameter("设备Id")] @@ -35,12 +34,12 @@ namespace DriverOmronFins #endregion - public OmronFins(Device device, ILogger logger) + public OmronFins(string device, ILogger logger) { _device = device; _logger = logger; - _logger.LogInformation($"Device:[{_device.DeviceName}],Create()"); + _logger.LogInformation($"Device:[{_device}],Create()"); } diff --git a/Plugins/Drivers/DriverSiemensS7/DriverSiemensS7.csproj b/Plugins/Drivers/DriverSiemensS7/DriverSiemensS7.csproj index 80504e5..2617eb5 100644 --- a/Plugins/Drivers/DriverSiemensS7/DriverSiemensS7.csproj +++ b/Plugins/Drivers/DriverSiemensS7/DriverSiemensS7.csproj @@ -9,6 +9,5 @@ - diff --git a/Plugins/Drivers/DriverSiemensS7/SiemensS7.cs b/Plugins/Drivers/DriverSiemensS7/SiemensS7.cs index 085f471..cd9c6e1 100644 --- a/Plugins/Drivers/DriverSiemensS7/SiemensS7.cs +++ b/Plugins/Drivers/DriverSiemensS7/SiemensS7.cs @@ -2,7 +2,6 @@ using S7.Net; using System; using System.Text; -using IoTGateway.Model; using Microsoft.Extensions.Logging; namespace DriverSiemensS7 @@ -19,7 +18,7 @@ namespace DriverSiemensS7 private Plc plc = null; public ILogger _logger { get; set; } - private readonly Device _device; + private readonly string _device; #region 配置参数 [ConfigParameter("设备Id")] @@ -48,12 +47,12 @@ namespace DriverSiemensS7 #endregion - public SiemensS7(Device device, ILogger logger) + public SiemensS7(string device, ILogger logger) { _device = device; _logger = logger; - _logger.LogInformation($"Device:[{_device.DeviceName}],Create()"); + _logger.LogInformation($"Device:[{_device}],Create()"); } diff --git a/Plugins/Drivers/DriverSimTcpClient/DriverSimTcpClient.csproj b/Plugins/Drivers/DriverSimTcpClient/DriverSimTcpClient.csproj index 89ee96d..c517682 100644 --- a/Plugins/Drivers/DriverSimTcpClient/DriverSimTcpClient.csproj +++ b/Plugins/Drivers/DriverSimTcpClient/DriverSimTcpClient.csproj @@ -11,6 +11,5 @@ - \ No newline at end of file diff --git a/Plugins/Drivers/DriverSimTcpClient/SimTcpClient.cs b/Plugins/Drivers/DriverSimTcpClient/SimTcpClient.cs index 6d67fcc..63035e6 100644 --- a/Plugins/Drivers/DriverSimTcpClient/SimTcpClient.cs +++ b/Plugins/Drivers/DriverSimTcpClient/SimTcpClient.cs @@ -2,7 +2,6 @@ using SimpleTCP; using System; using System.Text; -using IoTGateway.Model; using Microsoft.Extensions.Logging; namespace DriverSimTcpClient @@ -21,7 +20,7 @@ namespace DriverSimTcpClient private byte[] latestRcvData; public ILogger _logger { get; set; } - private readonly Device _device; + private readonly string _device; #region 配置参数 [ConfigParameter("设备Id")] @@ -47,12 +46,12 @@ namespace DriverSimTcpClient #endregion - public SimTcpClient(Device device, ILogger logger) + public SimTcpClient(string device, ILogger logger) { _device = device; _logger = logger; - _logger.LogInformation($"Device:[{_device.DeviceName}],Create()"); + _logger.LogInformation($"Device:[{_device}],Create()"); } diff --git a/Plugins/Plugin/DeviceService.cs b/Plugins/Plugin/DeviceService.cs index 3df256b..3285aa8 100644 --- a/Plugins/Plugin/DeviceService.cs +++ b/Plugins/Plugin/DeviceService.cs @@ -85,8 +85,8 @@ namespace Plugin { var settings = DC.Set().Where(x => x.DeviceId == Device.ID).AsNoTracking().ToList(); - Type[] types = new Type[2] { typeof(Device) ,typeof(ILogger) }; - object[] param = new object[2] { Device , _logger }; + Type[] types = new Type[2] { typeof(string) ,typeof(ILogger) }; + object[] param = new object[2] { Device.DeviceName , _logger }; ConstructorInfo constructor = driver.Type.GetConstructor(types); var DeviceObj = constructor.Invoke(param) as IDriver; diff --git a/Plugins/Plugin/DrvierService.cs b/Plugins/Plugin/DrvierService.cs index a1db1b8..fbbb467 100644 --- a/Plugins/Plugin/DrvierService.cs +++ b/Plugins/Plugin/DrvierService.cs @@ -77,11 +77,12 @@ namespace Plugin { using (var DC = new DataContext(IoTBackgroundService.connnectSetting, IoTBackgroundService.DBType)) { + var device = DC.Set().Where(x => x.ID == dapID).AsNoTracking().SingleOrDefault(); var driver = DC.Set().Where(x => x.ID == DriverId).AsNoTracking().SingleOrDefault(); var type = DriverInfos.Where(x => x.Type.FullName == driver.AssembleName).SingleOrDefault(); - Type[] types = new Type[1] { typeof(Guid) }; - object[] param = new object[1] { Guid.Parse("88888888-8888-8888-8888-888888888888") }; + Type[] types = new Type[2] { typeof(string), typeof(ILogger) }; + object[] param = new object[2] { device.DeviceName, _logger }; ConstructorInfo constructor = type.Type.GetConstructor(types); var iObj = constructor.Invoke(param) as IDriver;