硬件介绍、解决表达式偶尔失效的bug

This commit is contained in:
iioter 2022-07-24 22:31:27 +08:00
parent a3d635f192
commit c55fb59442
3 changed files with 44 additions and 7 deletions

View File

@ -22,7 +22,6 @@ namespace Plugin
private IMqttServer _MqttServer;
private string connnectSetting = IoTBackgroundService.connnectSetting;
private DBTypeEnum DBType = IoTBackgroundService.DBType;
private Interpreter interpreter = new();
public DeviceService(IConfiguration ConfigRoot, DriverService drvierManager, MyMqttClient myMqttClient, UAService uAService, IMqttServer mqttServer, ILogger<DeviceService> logger)
{
_logger = logger;
@ -137,7 +136,7 @@ namespace Plugin
p.SetValue(DeviceObj, value);
}
var deviceThread = new DeviceThread(Device, DeviceObj, systemManage.GatewayName, _MyMqttClient, interpreter, _MqttServer, _logger);
var deviceThread = new DeviceThread(Device, DeviceObj, systemManage.GatewayName, _MyMqttClient, _MqttServer, _logger);
DeviceThreads.Add(deviceThread);
}

View File

@ -15,21 +15,21 @@ namespace Plugin
public readonly Device _device;
public readonly IDriver _driver;
private readonly MyMqttClient _myMqttClient;
private Interpreter _interpreter ;
public Dictionary<Guid, DriverReturnValueModel> DeviceValues { get; set; } = new();
internal List<MethodInfo> Methods { get; set; }
private Task task { get; set; } = null;
private DateTime TsStartDt = new DateTime(1970, 1, 1);
private CancellationTokenSource tokenSource = new CancellationTokenSource();
private Interpreter Interpreter = null;
private object _lock = new object();
private bool lastConnected = false;
public DeviceThread(Device device, IDriver driver, string ProjectId, MyMqttClient myMqttClient, Interpreter interpreter, IMqttServer mqttServer, ILogger logger)
public DeviceThread(Device device, IDriver driver, string ProjectId, MyMqttClient myMqttClient, IMqttServer mqttServer, ILogger logger)
{
_myMqttClient = myMqttClient;
_myMqttClient.OnExcRpc += MyMqttClient_OnExcRpc;
_device = device;
_driver = driver;
Interpreter = interpreter;
_interpreter = new Interpreter();
_logger = logger;
Methods = _driver.GetType().GetMethods().Where(x => x.GetCustomAttribute(typeof(MethodAttribute)) != null).ToList();
if (_device.AutoStart)
@ -91,7 +91,7 @@ namespace Plugin
{
try
{
ret.CookedValue = interpreter.Eval(DealMysqlStr(item.Expressions).Replace("raw", ret.Value?.ToString()));
ret.CookedValue = _interpreter.Eval(DealMysqlStr(item.Expressions).Replace("raw", ret.Value?.ToString()));
}
catch (Exception)
{
@ -268,6 +268,9 @@ namespace Plugin
public void Dispose()
{
_driver.Dispose();
_interpreter = null;
DeviceValues = null;
Methods = null;
_logger.LogInformation($"线程释放,{_device.DeviceName}");
}

View File

@ -3,6 +3,8 @@
## [教程文档:http://iotgateway.net](http://iotgateway.net/)
## [在线体验:http://online.iotgateway.net](http://online.iotgateway.net/)
## [配套硬件产品:http://iotgateway.net/docs/hardware/selection/](http://iotgateway.net/docs/hardware/selection/)
> 基于.NET6的跨平台物联网网关
>
@ -20,7 +22,40 @@
| ------ | ---- |
| ![wx](./images/wx.jpg) | ![qq](./images/qq.png) |
## 重磅推出硬件网关
受益于.netcore**跨平台**能力,此项目并**不限于**下面推荐的硬件设备,你可以在任何主机上运行,但是会针对特定硬件设备做**优化适配**,如
\- **性能监控**cpu、内存、磁盘等主机指标监控
\- **硬件交互**:模拟量采集、继电器控制等
### 为何推荐
如果你购买了硬件网关:
- **间接为开源项目做贡献**,收益的一部分会投入到开源项目建设中去,包括但不限于云服务器资源租赁、先上线向下活动等
- 可以**免费使用**后续"企业版网关项目(筹)"
- 可以**免费使用**网络透传等服务
- 提供详细的**教程文档**,包括**Linux系统**、**dotnet跨平台等**
- 可用于**学习、评估、和生产环境**使用
### 产品列表
- 下列型号均有"**蓝牙BLE 5.0**、**Wi-Fi**"
- 搭载**Linux**操作系统```debian.11```
- 时间关系,目前只整理了 [A080](http://iotgateway.net/docs/hardware/A080/introduction) 型号的资料,其他用法差不多,后续会更新
- 9月后会推出**24v**版本
| 型号 | 触摸屏 | USB | 网口 |通讯口| SD扩展 | 4G | 电源|RTC|
| ------ | ---- |---- |---- |---- |------ | ---- |---- |---- |
| D070 | 无 | 4 | 千兆×1 | 无 |无|无| 5V|无|
| [A080](/docs/hardware/A080/introduction) | 无 | 2 | 千兆×1 | 232×1;485×4;can×1 |有|可选|12V|有|
| B100 | 无 | 2 | 百兆×1;千兆×1 | 232×1;485×1 |有|可选|12V|有|
| C210 | 10寸电容 | 2 | 千兆×1 | 232×4;485×2 |有|可选| 6~36V|有|
## 运行
- [直接运行:http://iotgateway.net/docs/iotgateway/run/release-run](http://iotgateway.net/docs/iotgateway/run/release-run)
- [Docker运行:http://iotgateway.net/docs/iotgateway/run/docker-run](http://iotgateway.net/docs/iotgateway/run/docker-run)
- [源码运行:http://iotgateway.net/docs/iotgateway/run/build-run](http://iotgateway.net/docs/iotgateway/run/build-run)
@ -56,7 +91,7 @@
![variables](./images/variables.gif)
- 3D数字孪生Demo
![3d](./images/3d.gif)
![3d](./images/3d.gif)
- 支持接入web组态项目
![scada](./images/scada.gif)