mirror of
https://gitee.com/iioter/iotgateway.git
synced 2024-11-29 18:28:09 +08:00
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.
|
||||
public void Configure(IApplicationBuilder app, IOptionsMonitor<Configs> configs, DeviceService deviceService, ModbusSlaveService modbusSlaveService)
|
||||
public void Configure(IApplicationBuilder app, IOptionsMonitor<Configs> configs)
|
||||
{
|
||||
IconFontsHelper.GenerateIconFont();
|
||||
app.UseExceptionHandler(configs.CurrentValue.ErrorHandler);
|
||||
|
@ -631,7 +631,9 @@ namespace PLC.ModBusMaster
|
||||
break;
|
||||
case DataTypeEnum.Float:
|
||||
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);
|
||||
await _master.WriteMultipleRegistersAsync(slaveAddress, address, toWriteArray);
|
||||
break;
|
||||
|
@ -289,7 +289,8 @@ namespace Plugin
|
||||
{
|
||||
Address = deviceVariable.DeviceAddress,
|
||||
Value = para.Value,
|
||||
ValueType = deviceVariable.DataType
|
||||
ValueType = deviceVariable.DataType,
|
||||
EndianType = deviceVariable.EndianType
|
||||
};
|
||||
var writeResponse = Driver
|
||||
.WriteAsync(e.RequestId, deviceVariable.Method, ioArgModel).Result;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using IoTGateway.DataAccess;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
|
||||
@ -11,8 +12,14 @@ namespace Plugin
|
||||
public static DBTypeEnum DbType;
|
||||
public static string connnectSetting;
|
||||
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>();
|
||||
configRoot.Bind("Connections", connnectSettings);
|
||||
connnectSetting = connnectSettings[0].Value;
|
||||
@ -53,6 +60,7 @@ namespace Plugin
|
||||
}
|
||||
public override Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_appLifeTime.ApplicationStarted.Register(OnStarted);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@ -60,5 +68,10 @@ namespace Plugin
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private void OnStarted()
|
||||
{
|
||||
_ = _serviceProvider.GetRequiredService<DeviceService>();
|
||||
_ = _serviceProvider.GetRequiredService<ModbusSlaveService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user