You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
6.2 KiB
142 lines
6.2 KiB
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]);
|
|
}
|
|
for (int i = 0; i < MainWindowViewModel.Machines.Rows.Count; i++)
|
|
{
|
|
DataRow[] rows= MainWindowViewModel.Whole_dat.Select("Machine='" + inf[i].name.Text+"'");
|
|
inf[i].DataROW(rows);
|
|
}
|
|
|
|
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";
|
|
}
|
|
}
|
|
|
|
int t30S = 0;
|
|
private void CountDown()
|
|
{
|
|
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
|
{
|
|
Interval = TimeSpan.FromSeconds(1)//秒
|
|
};
|
|
timer1s.Tick += Tick_Event_S;
|
|
timer1s.Start();
|
|
}//时间周期初始化
|
|
|
|
void Tick_Event_S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
|
{
|
|
DateTime dateTime = DateTime.Now;
|
|
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(0, 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);
|
|
|
|
if ((t30S > 10)&&(State_!="800"))
|
|
{
|
|
t30S = 0;
|
|
inf[i].DataAdd(dateTime,Convert.ToDouble( Selet_Machines(MainWindowViewModel.Machines, "Temperature", i)));
|
|
|
|
// DataRow whole_Dat = MainWindowViewModel.Whole_dat.NewRow();
|
|
// whole_Dat["Machine"] = Selet_Machines(MainWindowViewModel.Machines, "NAME", i).ToString();
|
|
// whole_Dat["DateTime"] = dateTime;
|
|
// whole_Dat["DAT"] = (double)Selet_Machines(MainWindowViewModel.Machines, "Temperature", i);
|
|
// MainWindowViewModel.Whole_dat.Rows.Add(whole_Dat);
|
|
}
|
|
|
|
}
|
|
t30S++;
|
|
}
|
|
}
|
|
}
|
|
|