Merge branch 'iioter:master' into master
This commit is contained in:
commit
56f965ec76
@ -81,7 +81,7 @@ namespace IoTGateway
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IOptionsMonitor<Configs> configs, DeviceService deviceService, ModbusSlaveService modbusSlaveService)
|
public void Configure(IApplicationBuilder app, IOptionsMonitor<Configs> configs)
|
||||||
{
|
{
|
||||||
IconFontsHelper.GenerateIconFont();
|
IconFontsHelper.GenerateIconFont();
|
||||||
app.UseExceptionHandler(configs.CurrentValue.ErrorHandler);
|
app.UseExceptionHandler(configs.CurrentValue.ErrorHandler);
|
||||||
|
@ -631,7 +631,9 @@ namespace PLC.ModBusMaster
|
|||||||
break;
|
break;
|
||||||
case DataTypeEnum.Float:
|
case DataTypeEnum.Float:
|
||||||
var f = float.Parse(ioArg.Value.ToString());
|
var f = float.Parse(ioArg.Value.ToString());
|
||||||
ModBusDataConvert.SetReal(shortArray, 0, f);
|
var fValue = BitConverter.SingleToUInt32Bits(f);
|
||||||
|
shortArray[1] = (ushort)(fValue & 0xffff);
|
||||||
|
shortArray[0] = (ushort)(fValue >> 16 & 0xffff);
|
||||||
toWriteArray = ChangeBuffersOrder(shortArray, ioArg.EndianType);
|
toWriteArray = ChangeBuffersOrder(shortArray, ioArg.EndianType);
|
||||||
await _master.WriteMultipleRegistersAsync(slaveAddress, address, toWriteArray);
|
await _master.WriteMultipleRegistersAsync(slaveAddress, address, toWriteArray);
|
||||||
break;
|
break;
|
||||||
|
@ -289,7 +289,8 @@ namespace Plugin
|
|||||||
{
|
{
|
||||||
Address = deviceVariable.DeviceAddress,
|
Address = deviceVariable.DeviceAddress,
|
||||||
Value = para.Value,
|
Value = para.Value,
|
||||||
ValueType = deviceVariable.DataType
|
ValueType = deviceVariable.DataType,
|
||||||
|
EndianType = deviceVariable.EndianType
|
||||||
};
|
};
|
||||||
var writeResponse = Driver
|
var writeResponse = Driver
|
||||||
.WriteAsync(e.RequestId, deviceVariable.Method, ioArgModel).Result;
|
.WriteAsync(e.RequestId, deviceVariable.Method, ioArgModel).Result;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using IoTGateway.DataAccess;
|
using IoTGateway.DataAccess;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using WalkingTec.Mvvm.Core;
|
using WalkingTec.Mvvm.Core;
|
||||||
|
|
||||||
@ -11,8 +12,14 @@ namespace Plugin
|
|||||||
public static DBTypeEnum DbType;
|
public static DBTypeEnum DbType;
|
||||||
public static string connnectSetting;
|
public static string connnectSetting;
|
||||||
public static Guid? VariableSelectDeviceId, ConfigSelectDeviceId;
|
public static Guid? VariableSelectDeviceId, ConfigSelectDeviceId;
|
||||||
public IoTBackgroundService(IConfiguration configRoot)
|
private readonly IHostApplicationLifetime _appLifeTime;
|
||||||
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
|
||||||
|
public IoTBackgroundService(IConfiguration configRoot, IHostApplicationLifetime appLifeTime, IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
|
_appLifeTime = appLifeTime;
|
||||||
|
_serviceProvider = serviceProvider;
|
||||||
|
|
||||||
var connnectSettings = new List<ConnnectSettingsModel>();
|
var connnectSettings = new List<ConnnectSettingsModel>();
|
||||||
configRoot.Bind("Connections", connnectSettings);
|
configRoot.Bind("Connections", connnectSettings);
|
||||||
connnectSetting = connnectSettings[0].Value;
|
connnectSetting = connnectSettings[0].Value;
|
||||||
@ -53,6 +60,7 @@ namespace Plugin
|
|||||||
}
|
}
|
||||||
public override Task StartAsync(CancellationToken cancellationToken)
|
public override Task StartAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
_appLifeTime.ApplicationStarted.Register(OnStarted);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,5 +68,10 @@ namespace Plugin
|
|||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
private void OnStarted()
|
||||||
|
{
|
||||||
|
_ = _serviceProvider.GetRequiredService<DeviceService>();
|
||||||
|
_ = _serviceProvider.GetRequiredService<ModbusSlaveService>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user