mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-24 04:17:08 +08:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6cf53fefec | ||
![]() |
45132f3503 |
@@ -324,13 +324,21 @@ public class ObjectPool<T> : DisposeBase, IPool<T> where T : notnull
|
||||
// 移除扩展空闲集合里面的超时项
|
||||
while (_free2.TryPeek(out var pi) && pi.LastTime < exp)
|
||||
{
|
||||
// 取出来销毁
|
||||
if (_free2.TryDequeue(out pi))
|
||||
// 取出来销毁。在并行操作中,此时返回可能是另一个对象
|
||||
if (_free2.TryDequeue(out var pi2))
|
||||
{
|
||||
pi.Value.TryDispose();
|
||||
if (pi2.LastTime < exp)
|
||||
{
|
||||
pi2.Value.TryDispose();
|
||||
|
||||
count++;
|
||||
Interlocked.Decrement(ref _FreeCount);
|
||||
count++;
|
||||
Interlocked.Decrement(ref _FreeCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 可能是另一个对象,放回去
|
||||
_free2.Enqueue(pi2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -51,48 +51,6 @@ public static class GenericExtensions
|
||||
return differences;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public static IEnumerable<PropertyInfo> GetProperties(this IEnumerable<dynamic> value, params string[] names)
|
||||
{
|
||||
// 获取动态对象集合的类型
|
||||
var type = value.GetType().GetGenericArguments().LastOrDefault() ?? throw new ArgumentNullException(nameof(value));
|
||||
|
||||
var namesStr = System.Text.Json.JsonSerializer.Serialize(names);
|
||||
// 构建缓存键,包括属性名和类型信息
|
||||
var cacheKey = $"{namesStr}-{type.FullName}-{type.TypeHandle.Value}";
|
||||
|
||||
// 从缓存中获取属性信息,如果缓存不存在,则创建并缓存
|
||||
var result = Instance.GetOrAdd(cacheKey, a =>
|
||||
{
|
||||
// 获取动态对象类型中指定名称的属性信息
|
||||
var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty)
|
||||
.Where(pi => names.Contains(pi.Name)) // 筛选出指定属性名的属性信息
|
||||
.Where(pi => pi != null) // 过滤空属性信息
|
||||
.AsEnumerable();
|
||||
|
||||
// 检查是否找到了所有指定名称的属性,如果没有找到,则抛出异常
|
||||
if (names.Length != properties.Count())
|
||||
{
|
||||
throw new InvalidOperationException($"Couldn't find properties on type:{type.Name},{Environment.NewLine}names:{namesStr}");
|
||||
}
|
||||
|
||||
return properties; // 返回属性信息集合
|
||||
}, 3600); // 缓存有效期为3600秒
|
||||
|
||||
return result!; // 返回属性信息集合
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public static IEnumerable<IGrouping<object[], dynamic>> GroupByKeys(this IEnumerable<dynamic> values, IEnumerable<string> keys)
|
||||
{
|
||||
// 获取动态对象集合中指定键的属性信息
|
||||
var properties = GetProperties(values, keys.ToArray());
|
||||
|
||||
// 使用对象数组作为键进行分组
|
||||
return values.GroupBy(v => properties.Select(property => property.GetValue(v)).ToArray(), new ArrayEqualityComparer());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否都包含
|
||||
/// </summary>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BootstrapBlazor.FontAwesome" Version="9.0.2" />
|
||||
<PackageReference Include="BootstrapBlazor" Version="9.6.2" />
|
||||
<PackageReference Include="BootstrapBlazor" Version="9.6.3" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<PluginVersion>10.6.2</PluginVersion>
|
||||
<ProPluginVersion>10.6.2</ProPluginVersion>
|
||||
<PluginVersion>10.6.3</PluginVersion>
|
||||
<ProPluginVersion>10.6.3</ProPluginVersion>
|
||||
<AuthenticationVersion>2.1.7</AuthenticationVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@@ -23,7 +23,7 @@ namespace ThingsGateway.Gateway.Application;
|
||||
/// <summary>
|
||||
/// 业务插件,额外实现脚本切换实体
|
||||
/// </summary>
|
||||
public abstract partial class BusinessBaseWithCacheIntervalScript<VarModel, DevModel, AlarmModel> : BusinessBaseWithCacheIntervalAlarmModel<VarModel, DevModel, AlarmModel> where DevModel : class where VarModel : class where AlarmModel : class
|
||||
public abstract partial class BusinessBaseWithCacheIntervalScript<VarModel, DevModel, AlarmModel> : BusinessBaseWithCacheIntervalAlarmModel<VarModel, DevModel, AlarmModel>
|
||||
{
|
||||
protected sealed override BusinessPropertyWithCacheInterval _businessPropertyWithCacheInterval => _businessPropertyWithCacheIntervalScript;
|
||||
|
||||
@@ -65,7 +65,7 @@ public abstract partial class BusinessBaseWithCacheIntervalScript<VarModel, DevM
|
||||
|
||||
protected List<TopicJson> GetAlarms(IEnumerable<AlarmModel> item)
|
||||
{
|
||||
IEnumerable<dynamic>? data = Application.DynamicModelExtension.GetDynamicModel<AlarmModel>(item, _businessPropertyWithCacheIntervalScript.BigTextScriptAlarmModel);
|
||||
var data = Application.DynamicModelExtension.GetDynamicModel<AlarmModel>(item, _businessPropertyWithCacheIntervalScript.BigTextScriptAlarmModel);
|
||||
var topicJsonList = new List<TopicJson>();
|
||||
var topics = Match(_businessPropertyWithCacheIntervalScript.AlarmTopic);
|
||||
if (topics.Count > 0)
|
||||
@@ -133,7 +133,7 @@ public abstract partial class BusinessBaseWithCacheIntervalScript<VarModel, DevM
|
||||
|
||||
protected List<TopicJson> GetDeviceData(IEnumerable<DevModel> item)
|
||||
{
|
||||
IEnumerable<dynamic>? data = Application.DynamicModelExtension.GetDynamicModel<DevModel>(item, _businessPropertyWithCacheIntervalScript.BigTextScriptDeviceModel);
|
||||
var data = Application.DynamicModelExtension.GetDynamicModel<DevModel>(item, _businessPropertyWithCacheIntervalScript.BigTextScriptDeviceModel);
|
||||
var topicJsonList = new List<TopicJson>();
|
||||
var topics = Match(_businessPropertyWithCacheIntervalScript.DeviceTopic);
|
||||
if (topics.Count > 0)
|
||||
@@ -200,7 +200,7 @@ public abstract partial class BusinessBaseWithCacheIntervalScript<VarModel, DevM
|
||||
|
||||
protected List<TopicJson> GetVariable(IEnumerable<VarModel> item)
|
||||
{
|
||||
IEnumerable<dynamic>? data = Application.DynamicModelExtension.GetDynamicModel<VarModel>(item, _businessPropertyWithCacheIntervalScript.BigTextScriptVariableModel);
|
||||
var data = Application.DynamicModelExtension.GetDynamicModel<VarModel>(item, _businessPropertyWithCacheIntervalScript.BigTextScriptVariableModel);
|
||||
var topicJsonList = new List<TopicJson>();
|
||||
var topics = Match(_businessPropertyWithCacheIntervalScript.VariableTopic);
|
||||
if (topics.Count > 0)
|
||||
@@ -376,7 +376,7 @@ public abstract partial class BusinessBaseWithCacheIntervalScript<VarModel, DevM
|
||||
|
||||
protected List<TopicArray> GetAlarmTopicArrays(IEnumerable<AlarmModel> item)
|
||||
{
|
||||
IEnumerable<dynamic>? data = Application.DynamicModelExtension.GetDynamicModel<AlarmModel>(item, _businessPropertyWithCacheIntervalScript.BigTextScriptAlarmModel);
|
||||
var data = Application.DynamicModelExtension.GetDynamicModel<AlarmModel>(item, _businessPropertyWithCacheIntervalScript.BigTextScriptAlarmModel);
|
||||
List<TopicArray> topicArrayList = new List<TopicArray>();
|
||||
var topics = Match(_businessPropertyWithCacheIntervalScript.AlarmTopic);
|
||||
if (topics.Count > 0)
|
||||
@@ -441,7 +441,7 @@ public abstract partial class BusinessBaseWithCacheIntervalScript<VarModel, DevM
|
||||
|
||||
protected List<TopicArray> GetDeviceTopicArray(IEnumerable<DevModel> item)
|
||||
{
|
||||
IEnumerable<dynamic>? data = Application.DynamicModelExtension.GetDynamicModel<DevModel>(item, _businessPropertyWithCacheIntervalScript.BigTextScriptDeviceModel);
|
||||
var data = Application.DynamicModelExtension.GetDynamicModel<DevModel>(item, _businessPropertyWithCacheIntervalScript.BigTextScriptDeviceModel);
|
||||
List<TopicArray> topicArrayList = new List<TopicArray>();
|
||||
var topics = Match(_businessPropertyWithCacheIntervalScript.DeviceTopic);
|
||||
if (topics.Count > 0)
|
||||
@@ -508,7 +508,7 @@ public abstract partial class BusinessBaseWithCacheIntervalScript<VarModel, DevM
|
||||
|
||||
protected List<TopicArray> GetVariableTopicArray(IEnumerable<VarModel> item)
|
||||
{
|
||||
IEnumerable<dynamic>? data = Application.DynamicModelExtension.GetDynamicModel<VarModel>(item, _businessPropertyWithCacheIntervalScript.BigTextScriptVariableModel);
|
||||
var data = Application.DynamicModelExtension.GetDynamicModel<VarModel>(item, _businessPropertyWithCacheIntervalScript.BigTextScriptVariableModel);
|
||||
List<TopicArray> topicArrayList = new List<TopicArray>();
|
||||
var topics = Match(_businessPropertyWithCacheIntervalScript.VariableTopic);
|
||||
if (topics.Count > 0)
|
||||
|
@@ -22,17 +22,17 @@ public static class DynamicModelExtension
|
||||
/// <summary>
|
||||
/// GetDynamicModel
|
||||
/// </summary>
|
||||
public static IEnumerable<dynamic> GetDynamicModel<T>(this IEnumerable<T> datas, string script) where T : class
|
||||
public static IEnumerable<object> GetDynamicModel<T>(this IEnumerable<T> datas, string script)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(script))
|
||||
{
|
||||
//执行脚本,获取新实体
|
||||
var getDeviceModel = CSharpScriptEngineExtension.Do<IDynamicModel>(script);
|
||||
return getDeviceModel.GetList(datas);
|
||||
return getDeviceModel.GetList(datas.Cast<object>());
|
||||
}
|
||||
else
|
||||
{
|
||||
return datas;
|
||||
return datas.Cast<object>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public static class DynamicModelExtension
|
||||
return null; // 未找到对应的业务设备Id,返回null
|
||||
}
|
||||
|
||||
public static IEnumerable<IGrouping<object[], dynamic>> GroupByKeys(this IEnumerable<dynamic> values, IEnumerable<string> keys)
|
||||
public static IEnumerable<IGrouping<object[], T>> GroupByKeys<T>(this IEnumerable<T> values, IEnumerable<string> keys)
|
||||
{
|
||||
// 获取动态对象集合中指定键的属性信息
|
||||
var properties = GetProperties(values, keys.ToArray());
|
||||
@@ -87,7 +87,7 @@ public static class DynamicModelExtension
|
||||
return values.GroupBy(v => properties.Select(property => property.GetValue(v)).ToArray(), new ArrayEqualityComparer());
|
||||
}
|
||||
|
||||
private static PropertyInfo[] GetProperties(this IEnumerable<dynamic> value, params string[] names)
|
||||
private static PropertyInfo[] GetProperties<T>(this IEnumerable<T> value, params string[] names)
|
||||
{
|
||||
// 获取动态对象集合的类型
|
||||
var type = value.GetType().GetGenericArguments().FirstOrDefault() ?? throw new ArgumentNullException(nameof(value));
|
||||
|
@@ -467,6 +467,8 @@ public static class GlobalData
|
||||
/// <param name="deviceRuntime">设备运行时对象</param>
|
||||
internal static void DeviceStatusChange(DeviceRuntime deviceRuntime)
|
||||
{
|
||||
deviceRuntime.Driver?.LogMessage?.LogInformation($"Status changed: {deviceRuntime.DeviceStatus}");
|
||||
|
||||
if (DeviceStatusChangeEvent != null)
|
||||
{
|
||||
// 触发设备状态变化事件,并将设备运行时对象转换为设备数据对象进行传递
|
||||
|
@@ -17,13 +17,17 @@ namespace ThingsGateway.Gateway.Application;
|
||||
/// <summary>
|
||||
/// 设备业务变化数据
|
||||
/// </summary>
|
||||
public class DeviceBasicData : IPrimaryIdEntity
|
||||
public class DeviceBasicData
|
||||
{
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public DeviceRuntime DeviceRuntime{ get; set; }
|
||||
|
||||
/// <inheritdoc cref="PrimaryIdEntity.Id"/>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <inheritdoc cref="Device.Name"/>
|
||||
public string Name { get; set; }
|
||||
public string Name => DeviceRuntime?.Name;
|
||||
|
||||
/// <inheritdoc cref="DeviceRuntime.ActiveTime"/>
|
||||
public DateTime ActiveTime { get; set; }
|
||||
@@ -37,37 +41,37 @@ public class DeviceBasicData : IPrimaryIdEntity
|
||||
public string LastErrorMessage { get; set; }
|
||||
|
||||
/// <inheritdoc cref="DeviceRuntime.PluginName"/>
|
||||
public string PluginName { get; set; }
|
||||
public string PluginName => DeviceRuntime?.PluginName;
|
||||
|
||||
/// <inheritdoc cref="Device.Description"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Description { get; set; }
|
||||
public string? Description => DeviceRuntime?.Description;
|
||||
|
||||
/// <inheritdoc cref="Device.Remark1"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string Remark1 { get; set; }
|
||||
public string Remark1 => DeviceRuntime?.Remark1;
|
||||
|
||||
/// <inheritdoc cref="Device.Remark2"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string Remark2 { get; set; }
|
||||
public string Remark2 => DeviceRuntime?.Remark2;
|
||||
|
||||
/// <inheritdoc cref="Device.Remark3"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string Remark3 { get; set; }
|
||||
public string Remark3 => DeviceRuntime?.Remark3;
|
||||
|
||||
/// <inheritdoc cref="Device.Remark4"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string Remark4 { get; set; }
|
||||
public string Remark4 => DeviceRuntime?.Remark4;
|
||||
|
||||
/// <inheritdoc cref="Device.Remark5"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string Remark5 { get; set; }
|
||||
public string Remark5 => DeviceRuntime?.Remark5;
|
||||
|
||||
|
||||
}
|
||||
@@ -75,26 +79,30 @@ public class DeviceBasicData : IPrimaryIdEntity
|
||||
/// <summary>
|
||||
/// 变量业务变化数据
|
||||
/// </summary>
|
||||
public class VariableBasicData : IPrimaryIdEntity
|
||||
public class VariableBasicData
|
||||
{
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public VariableRuntime VariableRuntime { get; set; }
|
||||
|
||||
/// <inheritdoc cref="PrimaryIdEntity.Id"/>
|
||||
public long Id { get; set; }
|
||||
public long Id => VariableRuntime.Id;
|
||||
|
||||
/// <inheritdoc cref="Variable.Name"/>
|
||||
public string Name { get; set; }
|
||||
public string Name => VariableRuntime.Name;
|
||||
|
||||
/// <inheritdoc cref="Variable.CollectGroup"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string CollectGroup { get; set; }
|
||||
public string CollectGroup => VariableRuntime.CollectGroup;
|
||||
|
||||
/// <inheritdoc cref="Variable.BusinessGroup"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string BusinessGroup { get; set; }
|
||||
public string BusinessGroup => VariableRuntime.BusinessGroup;
|
||||
|
||||
/// <inheritdoc cref="VariableRuntime.DeviceName"/>
|
||||
public string DeviceName { get; set; }
|
||||
public string DeviceName => VariableRuntime.DeviceName;
|
||||
|
||||
/// <inheritdoc cref="VariableRuntime.RuntimeType"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
@@ -130,48 +138,48 @@ public class VariableBasicData : IPrimaryIdEntity
|
||||
/// <inheritdoc cref="Variable.RegisterAddress"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? RegisterAddress { get; set; }
|
||||
public string? RegisterAddress => VariableRuntime.RegisterAddress;
|
||||
|
||||
/// <inheritdoc cref="Variable.Unit"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Unit { get; set; }
|
||||
public string? Unit => VariableRuntime.Unit;
|
||||
|
||||
/// <inheritdoc cref="Variable.Description"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Description { get; set; }
|
||||
public string? Description => VariableRuntime.Description;
|
||||
|
||||
/// <inheritdoc cref="Variable.ProtectType"/>
|
||||
public ProtectTypeEnum ProtectType { get; set; }
|
||||
public ProtectTypeEnum ProtectType => VariableRuntime.ProtectType;
|
||||
|
||||
/// <inheritdoc cref="Variable.DataType"/>
|
||||
public DataTypeEnum DataType { get; set; }
|
||||
public DataTypeEnum DataType => VariableRuntime.DataType;
|
||||
|
||||
/// <inheritdoc cref="Device.Remark1"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string Remark1 { get; set; }
|
||||
public string Remark1 => VariableRuntime.Remark1;
|
||||
|
||||
/// <inheritdoc cref="Device.Remark2"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string Remark2 { get; set; }
|
||||
public string Remark2 => VariableRuntime.Remark2;
|
||||
|
||||
/// <inheritdoc cref="Device.Remark3"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string Remark3 { get; set; }
|
||||
public string Remark3 => VariableRuntime.Remark3;
|
||||
|
||||
/// <inheritdoc cref="Device.Remark4"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string Remark4 { get; set; }
|
||||
public string Remark4 => VariableRuntime.Remark4;
|
||||
|
||||
/// <inheritdoc cref="Device.Remark5"/>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string Remark5 { get; set; }
|
||||
public string Remark5 => VariableRuntime.Remark5;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -22,5 +22,12 @@ public class VariableMapper : IRegister
|
||||
|
||||
config.ForType<VariableRuntime, VariableRuntime>()
|
||||
.Ignore(dest => dest.DeviceRuntime);
|
||||
|
||||
config.ForType<VariableRuntime, VariableBasicData>()
|
||||
.BeforeMapping((a, b) => b.VariableRuntime = a);
|
||||
config.ForType<DeviceRuntime, DeviceBasicData>()
|
||||
.BeforeMapping((a, b) => b.DeviceRuntime = a);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -32,7 +32,10 @@ public class VariableRuntime : Variable, IVariable, IDisposable
|
||||
private bool? _isOnlineChanged;
|
||||
protected object? _value;
|
||||
|
||||
|
||||
public VariableRuntime()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 变化时间
|
||||
/// </summary>
|
||||
|
@@ -36,92 +36,18 @@ public partial class PropertyComponent : IPropertyUIBase
|
||||
|
||||
private async Task CheckScript(BusinessPropertyWithCacheIntervalScript businessProperty, string pname)
|
||||
{
|
||||
IEnumerable<object> data = null;
|
||||
string script = null;
|
||||
if (pname == nameof(BusinessPropertyWithCacheIntervalScript.BigTextScriptAlarmModel))
|
||||
{
|
||||
data = new List<AlarmVariable>() { new() {
|
||||
Name = "testName",
|
||||
DeviceName = "testDevice",
|
||||
AlarmCode = "1",
|
||||
AlarmTime = DateTime.Now,
|
||||
EventTime = DateTime.Now,
|
||||
AlarmLimit = "3",
|
||||
AlarmType = AlarmTypeEnum.L,
|
||||
EventType=EventTypeEnum.Alarm,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
},
|
||||
new() {
|
||||
Name = "testName2",
|
||||
DeviceName = "testDevice",
|
||||
AlarmCode = "1",
|
||||
AlarmTime = DateTime.Now,
|
||||
EventTime = DateTime.Now,
|
||||
AlarmLimit = "3",
|
||||
AlarmType = AlarmTypeEnum.L,
|
||||
EventType=EventTypeEnum.Alarm,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
}};
|
||||
script = businessProperty.BigTextScriptAlarmModel;
|
||||
}
|
||||
else if (pname == nameof(BusinessPropertyWithCacheIntervalScript.BigTextScriptVariableModel))
|
||||
{
|
||||
data = new List<VariableBasicData>() { new() {
|
||||
Name = "testName",
|
||||
DeviceName = "testDevice",
|
||||
Value = "1",
|
||||
ChangeTime = DateTime.Now,
|
||||
CollectTime = DateTime.Now,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
} ,
|
||||
new() {
|
||||
Name = "testName2",
|
||||
DeviceName = "testDevice",
|
||||
Value = "1",
|
||||
ChangeTime = DateTime.Now,
|
||||
CollectTime = DateTime.Now,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
} };
|
||||
script = businessProperty.BigTextScriptVariableModel;
|
||||
|
||||
}
|
||||
else if (pname == nameof(BusinessPropertyWithCacheIntervalScript.BigTextScriptDeviceModel))
|
||||
{
|
||||
data = new List<DeviceBasicData>() { new() {
|
||||
Name = "testDevice",
|
||||
ActiveTime = DateTime.Now,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
} ,
|
||||
new() {
|
||||
Name = "testDevice2",
|
||||
ActiveTime = DateTime.Now,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
}};
|
||||
|
||||
script = businessProperty.BigTextScriptDeviceModel;
|
||||
}
|
||||
else
|
||||
@@ -141,7 +67,7 @@ public partial class PropertyComponent : IPropertyUIBase
|
||||
|
||||
op.Component = BootstrapDynamicComponent.CreateComponent<ScriptCheck>(new Dictionary<string, object?>
|
||||
{
|
||||
{nameof(ScriptCheck.Data),data },
|
||||
{nameof(ScriptCheck.Data),Array.Empty<object>() },
|
||||
{nameof(ScriptCheck.Script),script },
|
||||
{nameof(ScriptCheck.OnGetDemo),()=>
|
||||
{
|
||||
|
@@ -401,6 +401,9 @@ public partial class SiemensS7Master : DeviceBase
|
||||
var result2 = await SendThenReturnMessageBaseAsync(new S7Send(ISO_CR), channel).ConfigureAwait(false);
|
||||
if (!result2.IsSuccess)
|
||||
{
|
||||
if(result2.Exception is OperationCanceledException)
|
||||
return true;
|
||||
|
||||
Logger?.LogWarning(SiemensS7Resource.Localizer["HandshakeError1", channel.ToString(), result2]);
|
||||
await channel.CloseAsync().ConfigureAwait(false);
|
||||
return true;
|
||||
@@ -418,6 +421,9 @@ public partial class SiemensS7Master : DeviceBase
|
||||
var result2 = await SendThenReturnMessageBaseAsync(new S7Send(S7_PN), channel).ConfigureAwait(false);
|
||||
if (!result2.IsSuccess)
|
||||
{
|
||||
if (result2.Exception is OperationCanceledException)
|
||||
return true;
|
||||
|
||||
Logger?.LogWarning(SiemensS7Resource.Localizer["HandshakeError2", channel.ToString(), result2]);
|
||||
await channel.CloseAsync().ConfigureAwait(false);
|
||||
return true;
|
||||
|
@@ -46,33 +46,8 @@ namespace ThingsGateway.Debug
|
||||
|
||||
private async Task CheckScript(SqlDBProducerProperty businessProperty, string pname)
|
||||
{
|
||||
IEnumerable<object> data = null;
|
||||
string script = null;
|
||||
{
|
||||
data = new List<VariableBasicData>() { new() {
|
||||
Name = "testName",
|
||||
DeviceName = "testDevice",
|
||||
Value = "1",
|
||||
ChangeTime = DateTime.Now,
|
||||
CollectTime = DateTime.Now,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
} ,
|
||||
new() {
|
||||
Name = "testName2",
|
||||
DeviceName = "testDevice",
|
||||
Value = "1",
|
||||
ChangeTime = DateTime.Now,
|
||||
CollectTime = DateTime.Now,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
} };
|
||||
script = pname == businessProperty.BigTextScriptHistoryTable ? businessProperty.BigTextScriptHistoryTable : businessProperty.BigTextScriptRealTable;
|
||||
|
||||
}
|
||||
@@ -90,7 +65,7 @@ namespace ThingsGateway.Debug
|
||||
|
||||
op.Component = BootstrapDynamicComponent.CreateComponent<ScriptCheck>(new Dictionary<string, object?>
|
||||
{
|
||||
{nameof(ScriptCheck.Data),data },
|
||||
{nameof(ScriptCheck.Data),Array.Empty < object >() },
|
||||
{nameof(ScriptCheck.Script),script },
|
||||
{nameof(ScriptCheck.OnGetDemo),()=>
|
||||
{
|
||||
|
@@ -127,7 +127,7 @@ public class ModbusSlave : BusinessBase
|
||||
_modbusVariableQueue?.Clear();
|
||||
IdVariableRuntimes.ForEach(a =>
|
||||
{
|
||||
VariableValueChange(a.Value, null);
|
||||
VariableValueChange(a.Value, default);
|
||||
});
|
||||
|
||||
ModbusVariables = IdVariableRuntimes.ToDictionary(a =>
|
||||
|
@@ -136,92 +136,18 @@ namespace ThingsGateway.Plugin.Mqtt
|
||||
|
||||
private async Task CheckScript(BusinessPropertyWithCacheIntervalScript businessProperty, string pname)
|
||||
{
|
||||
IEnumerable<object> data = null;
|
||||
string script = null;
|
||||
if (pname == nameof(BusinessPropertyWithCacheIntervalScript.BigTextScriptAlarmModel))
|
||||
{
|
||||
data = new List<AlarmVariable>() { new() {
|
||||
Name = "testName",
|
||||
DeviceName = "testDevice",
|
||||
AlarmCode = "1",
|
||||
AlarmTime = DateTime.Now,
|
||||
EventTime = DateTime.Now,
|
||||
AlarmLimit = "3",
|
||||
AlarmType = AlarmTypeEnum.L,
|
||||
EventType=EventTypeEnum.Alarm,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
},
|
||||
new() {
|
||||
Name = "testName2",
|
||||
DeviceName = "testDevice",
|
||||
AlarmCode = "1",
|
||||
AlarmTime = DateTime.Now,
|
||||
EventTime = DateTime.Now,
|
||||
AlarmLimit = "3",
|
||||
AlarmType = AlarmTypeEnum.L,
|
||||
EventType=EventTypeEnum.Alarm,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
}};
|
||||
script = businessProperty.BigTextScriptAlarmModel;
|
||||
}
|
||||
else if (pname == nameof(BusinessPropertyWithCacheIntervalScript.BigTextScriptVariableModel))
|
||||
{
|
||||
data = new List<VariableBasicData>() { new() {
|
||||
Name = "testName",
|
||||
DeviceName = "testDevice",
|
||||
Value = "1",
|
||||
ChangeTime = DateTime.Now,
|
||||
CollectTime = DateTime.Now,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
} ,
|
||||
new() {
|
||||
Name = "testName2",
|
||||
DeviceName = "testDevice",
|
||||
Value = "1",
|
||||
ChangeTime = DateTime.Now,
|
||||
CollectTime = DateTime.Now,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
} };
|
||||
script = businessProperty.BigTextScriptVariableModel;
|
||||
|
||||
}
|
||||
else if (pname == nameof(BusinessPropertyWithCacheIntervalScript.BigTextScriptDeviceModel))
|
||||
{
|
||||
data = new List<DeviceBasicData>() { new() {
|
||||
Name = "testDevice",
|
||||
ActiveTime = DateTime.Now,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
} ,
|
||||
new() {
|
||||
Name = "testDevice2",
|
||||
ActiveTime = DateTime.Now,
|
||||
Remark1="1",
|
||||
Remark2="2",
|
||||
Remark3="3",
|
||||
Remark4="4",
|
||||
Remark5="5",
|
||||
}};
|
||||
|
||||
script = businessProperty.BigTextScriptDeviceModel;
|
||||
}
|
||||
else
|
||||
@@ -241,14 +167,16 @@ namespace ThingsGateway.Plugin.Mqtt
|
||||
|
||||
op.Component = BootstrapDynamicComponent.CreateComponent<ScriptCheck>(new Dictionary<string, object?>
|
||||
{
|
||||
{nameof(ScriptCheck.Data),data },
|
||||
{nameof(ScriptCheck.Data),Array.Empty<object>() },
|
||||
{nameof(ScriptCheck.Script),script },
|
||||
{nameof(ScriptCheck.OnGetDemo),()=>
|
||||
{
|
||||
return
|
||||
pname == nameof(BusinessPropertyWithCacheIntervalScript.BigTextScriptDeviceModel)?
|
||||
"""
|
||||
|
||||
using ThingsGateway.Foundation;
|
||||
|
||||
using System.Dynamic;
|
||||
using TouchSocket.Core;
|
||||
public class S1 : IDynamicModel
|
||||
{
|
||||
@@ -287,6 +215,9 @@ namespace ThingsGateway.Plugin.Mqtt
|
||||
|
||||
"""
|
||||
|
||||
using ThingsGateway.Foundation;
|
||||
|
||||
using System.Dynamic;
|
||||
using TouchSocket.Core;
|
||||
public class S2 : IDynamicModel
|
||||
{
|
||||
|
@@ -65,7 +65,7 @@ public partial class MqttCollect : CollectBase
|
||||
}
|
||||
|
||||
比如vendor/device;ModuleUnoccupied.EquipId,结果是"E12"
|
||||
比如vendor/device;ModuleUnoccupied.EquipId;raw.SelectToken("ModuleUnoccupied.LotId").ToString().ToInt()==1,结果是"E12"
|
||||
比如vendor/device;ModuleUnoccupied.EquipId;((JToken)raw).SelectToken("ModuleUnoccupied.LotId").ToString().ToInt()==1,结果是"E12"
|
||||
|
||||
""";
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>10.6.2</Version>
|
||||
<Version>10.6.3</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user