|
|
|
using DyeingComputer.UserClass;
|
|
|
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Data;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Windows;
|
|
|
|
using System.Windows.Controls;
|
|
|
|
using System.Windows.Data;
|
|
|
|
using System.Windows.Documents;
|
|
|
|
using System.Windows.Input;
|
|
|
|
using System.Windows.Media;
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
using System.Windows.Threading;
|
|
|
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
|
|
|
|
|
|
|
namespace SunlightCentralizedControlManagement_SCCM_.View
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Whole.xaml 的交互逻辑
|
|
|
|
/// </summary>
|
|
|
|
public partial class Whole : UserControl
|
|
|
|
{
|
|
|
|
public Whole()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
UserControls.info[] inf = new UserControls.info[999]; //定义总览信息卡
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// 生成总览信息卡
|
|
|
|
/// </summary>
|
|
|
|
//View.info[] inf = new View.info[999];
|
|
|
|
for (int i = 0; i < MainWindowViewModel.Machines.Rows.Count; i++)
|
|
|
|
{
|
|
|
|
inf[i] = new UserControls.info();
|
|
|
|
inf[i].Margin = new Thickness(5, 5, 0, 5);
|
|
|
|
inf[i].Width = 300;
|
|
|
|
inf[i].Height = 400;
|
|
|
|
inf[i].name.Text = Selet_Machines(MainWindowViewModel.Machines, "name",i).ToString();
|
|
|
|
|
|
|
|
string State_ = Selet_Machines(MainWindowViewModel.Machines, "State",i).ToString();
|
|
|
|
if (State_ == "101")
|
|
|
|
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(100, 100, 100)); }
|
|
|
|
else if (State_ == "201")
|
|
|
|
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(0, 255, 0)); }
|
|
|
|
else if (State_ == "202")
|
|
|
|
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(255, 255, 0)); }
|
|
|
|
else
|
|
|
|
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(255, 0, 0)); }
|
|
|
|
|
|
|
|
inf[i].temp.Text = Selet_Machines(MainWindowViewModel.Machines, "Temperature", i).ToString() + "°C";
|
|
|
|
inf[i].Process.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "Process", i);
|
|
|
|
inf[i].Step.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "Step", i);
|
|
|
|
inf[i].Message.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "Message", i);
|
|
|
|
inf[i].Orders.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "WorkOrder", i);
|
|
|
|
inf[i].time.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "time", i);
|
|
|
|
|
|
|
|
WholeView.Children.Add(inf[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
CountDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static object Selet_Machines(DataTable DB,string name ,int key)//查询
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
lock (DB)
|
|
|
|
{
|
|
|
|
DataRow drEmployee = DB.Rows[key];
|
|
|
|
object index = drEmployee.Field<object>(name);
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception)
|
|
|
|
{
|
|
|
|
// LogGing.LogGingDATA("SDTD:" + ex.ToString());
|
|
|
|
return "ERR";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void CountDown()
|
|
|
|
{
|
|
|
|
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
|
|
|
{
|
|
|
|
Interval = TimeSpan.FromSeconds(1)//秒
|
|
|
|
};
|
|
|
|
timer1s.Tick += Tick_Event_1S;
|
|
|
|
timer1s.Start();
|
|
|
|
}//时间周期初始化
|
|
|
|
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
|
|
|
{
|
|
|
|
for (int i = 0; i < MainWindowViewModel.Machines.Rows.Count; i++)
|
|
|
|
{
|
|
|
|
string State_ = Selet_Machines(MainWindowViewModel.Machines, "State", i).ToString();
|
|
|
|
if (State_ == "101")
|
|
|
|
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(100, 100, 100)); }
|
|
|
|
else if (State_ == "201")
|
|
|
|
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(0, 255, 0)); }
|
|
|
|
else if (State_ == "202")
|
|
|
|
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(255, 255, 0)); }
|
|
|
|
else
|
|
|
|
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(255, 0, 0)); }
|
|
|
|
|
|
|
|
inf[i].temp.Text = Selet_Machines(MainWindowViewModel.Machines, "Temperature", i).ToString() + "°C";
|
|
|
|
inf[i].Process.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "Process", i);
|
|
|
|
inf[i].Step.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "Step", i);
|
|
|
|
inf[i].Message.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "Message", i);
|
|
|
|
inf[i].Orders.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "WorkOrder", i);
|
|
|
|
inf[i].time.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "time", i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|