This commit is contained in:
parent
a9666899a7
commit
39204672cd
|
@ -271,9 +271,9 @@ public class IDIS_DBContext:DbContext
|
|||
SaveChangesAsync();
|
||||
}
|
||||
|
||||
public bool Update(string handle, string format, string value)
|
||||
public bool Update(string handle, string name, string value)
|
||||
{
|
||||
var result = Datas.FirstOrDefault(x => x.Handle == handle && x.Format == format);
|
||||
var result = Datas.FirstOrDefault(x => x.Handle == handle && x.Name == name);
|
||||
if (result is null) return false;
|
||||
result.UpdateTime=DateTime.Now;
|
||||
result.Value = value;
|
||||
|
@ -313,5 +313,5 @@ public partial class IDIS_Service:Node
|
|||
public void RegisterReference(string handle,string refenceHandle) => Context.RegisterReference(handle,refenceHandle);
|
||||
public static string GenerateHandle() => $"88.123.99/{Mathf.Abs(Guid.NewGuid().GetHashCode())}";
|
||||
public bool Query(string key, out IDIS_Query query) => Context.Query(key, out query);
|
||||
public bool Update(string handle, string format, string value) => Context.Update(handle, format, value);
|
||||
public bool Update(string handle, string name, string value) => Context.Update(handle, name, value);
|
||||
}
|
|
@ -18,6 +18,7 @@ public partial class IDIS_THService : Node
|
|||
None,
|
||||
Update,
|
||||
Insert,
|
||||
UpdateAndInsert,
|
||||
}
|
||||
|
||||
[Export] private UpdateMode currentUpdateMode = UpdateMode.Insert;
|
||||
|
@ -104,20 +105,21 @@ public partial class IDIS_THService : Node
|
|||
service.Register(handle, "湿度","float", humidity, "环境");
|
||||
break;
|
||||
case UpdateMode.Update:
|
||||
if (service.Update(handle, "温度",temperature) is false)
|
||||
if (service.Update(handle, "当前温度",temperature) is false)
|
||||
{
|
||||
autoUpdateLabel.SetTextAsync("温度更新失败,未知异常");
|
||||
return;
|
||||
}
|
||||
|
||||
if (service.Update(handle, "湿度",humidity) is false)
|
||||
if (service.Update(handle, "当前湿度",humidity) is false)
|
||||
{
|
||||
autoUpdateLabel.SetTextAsync("湿度更新失败,未知异常");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case UpdateMode.UpdateAndInsert:
|
||||
service.Register(handle,"温度" ,"float", temperature, "环境");
|
||||
service.Register(handle, "湿度","float", humidity, "环境");
|
||||
goto case UpdateMode.Update;
|
||||
}
|
||||
autoUpdateLabel.SetTextAsync($"温湿度已自动更新:{DateTime.Now}");
|
||||
}
|
||||
|
|
|
@ -1152,7 +1152,6 @@ theme_override_constants/v_separation = 16
|
|||
columns = 2
|
||||
|
||||
[node name="温湿度传感器" type="MarginContainer" parent="Layout/UX Window Service/Horizontal Layout/内容/MarginContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 0
|
||||
theme_override_constants/margin_top = 0
|
||||
|
@ -1361,12 +1360,16 @@ text = "自动更新"
|
|||
[node name="更新模式-button" type="OptionButton" parent="Layout/UX Window Service/Horizontal Layout/内容/MarginContainer/温湿度传感器/VBoxContainer/PanelContainer2/VBoxContainer/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
item_count = 2
|
||||
selected = 0
|
||||
popup/item_0/text = "更新记录"
|
||||
item_count = 4
|
||||
selected = 3
|
||||
popup/item_0/text = "不更新"
|
||||
popup/item_0/id = 0
|
||||
popup/item_1/text = "添加记录"
|
||||
popup/item_1/text = "更新记录"
|
||||
popup/item_1/id = 1
|
||||
popup/item_2/text = "添加记录"
|
||||
popup/item_2/id = 2
|
||||
popup/item_3/text = "添加并更新"
|
||||
popup/item_3/id = 3
|
||||
|
||||
[node name="生成数据-button" type="Button" parent="Layout/UX Window Service/Horizontal Layout/内容/MarginContainer/温湿度传感器/VBoxContainer/PanelContainer2/VBoxContainer/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
@ -1379,6 +1382,7 @@ size_flags_horizontal = 3
|
|||
text = "更新已获取的温湿度数据到标识"
|
||||
|
||||
[node name="标识模板生成器" type="VBoxContainer" parent="Layout/UX Window Service/Horizontal Layout/内容/MarginContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="标题栏Template" parent="Layout/UX Window Service/Horizontal Layout/内容/MarginContainer/标识模板生成器" instance=ExtResource("13_7vm0l")]
|
||||
|
@ -1912,6 +1916,7 @@ categoryTemplate = ExtResource("20_kicyn")
|
|||
|
||||
[node name="温湿度标识更新服务" type="Node" parent="." node_paths=PackedStringArray("service", "thReader", "submitButton", "autoUpdateButton", "updateModeButton", "handleEdit", "temperatureEdit", "humidityEdit", "hintsLabel", "autoUpdateLabel")]
|
||||
script = ExtResource("30_jn688")
|
||||
currentUpdateMode = 3
|
||||
service = NodePath("../标识解析服务")
|
||||
thReader = NodePath("../温湿度传感器Reader")
|
||||
submitButton = NodePath("../Layout/UX Window Service/Horizontal Layout/内容/MarginContainer/温湿度传感器/VBoxContainer/HBoxContainer/PanelContainer3/VBoxContainer2/MarginContainer/VBoxContainer/更新温湿度-button2")
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
* 点击`创建模板`
|
||||
* 输入模板名称,例如:`温湿度传感器模板`,然后点击右侧的`保存`按钮
|
||||
* 接下来创建以下值
|
||||
* `当前温度` `float` `30` `设备`
|
||||
* `当前湿度` `float` `50` `设备`
|
||||
* `品牌` `string` `Intelli` `设备参数`
|
||||
* `型号` `string` `t.h.sensor` `设备参数`
|
||||
* `生产厂家` `string` `Intelli工业` `出厂参数`
|
||||
|
|
Loading…
Reference in New Issue