添加了标识更新
但是只有界面没有功能
This commit is contained in:
62
Mods/工业数据采集与分析应用分享/Scripts/IDIS_THService.cs
Normal file
62
Mods/工业数据采集与分析应用分享/Scripts/IDIS_THService.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using BITFactory;
|
||||
|
||||
namespace BITFactory;
|
||||
public partial class IDIS_THService : Node
|
||||
{
|
||||
[ExportCategory("Services")]
|
||||
[Export] private IDIS_Service service;
|
||||
|
||||
[Export] private 温湿度Reader thReader;
|
||||
|
||||
[ExportCategory("UI 绑定")]
|
||||
[Export] private Button submitButton;
|
||||
[Export] private LineEdit handleEdit;
|
||||
[Export] private LineEdit temperatureEdit;
|
||||
[Export] private LineEdit humidityEdit;
|
||||
[Export] private RichTextLabel hintsLabel;
|
||||
public override void _Ready()
|
||||
{
|
||||
submitButton.Pressed += Submit;
|
||||
}
|
||||
private void Submit()
|
||||
{
|
||||
switch (handleEdit.Text, temperatureEdit.Text, humidityEdit.Text)
|
||||
{
|
||||
case ("", _, _):
|
||||
hintsLabel.Text = "请输入标识码";
|
||||
return;
|
||||
case (_, "", _):
|
||||
hintsLabel.Text = "请输入温度";
|
||||
return;
|
||||
case (_, _, ""):
|
||||
hintsLabel.Text = "请输入湿度";
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (service.Update(handleEdit.Text, "温度", humidityEdit.Text) is false)
|
||||
{
|
||||
hintsLabel.Text = "温度更新失败: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
return;
|
||||
}
|
||||
if (service.Update(handleEdit.Text, "湿度", temperatureEdit.Text) is false)
|
||||
{
|
||||
hintsLabel.Text = "湿度更新失败: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
return;
|
||||
}
|
||||
hintsLabel.Text = "更新成功: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
hintsLabel.Text = e.Message;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateByReader()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user