public void putong_warn() { try { bool warning_is = false; foreach (putongpoint point in all_putong_point) { try { double position = double.Parse(point.key); int index = MainWindow.Dizhi_Index.IndexOf(position); DataList.Data_Struct data_struct = (DataList.Data_Struct)MainWindow.Real_Data_List[index]; point.weiyi = data_struct.应变量; if (point.key == data_struct.位置.ToString()) { //Console.WriteLine(point.key); try { point.weiyi = data_struct.位移量; if (point.weiyi >= 2) { point.Set_Warn_is(); warning_is = true; warn_bofang = true; } else { point.Set_Warn_is_not(); } } catch { } } } catch { } } if (warning_is == false) { warn_bofang = false; } } catch { } }
private void Thread_Tick() { try { DateTime newtime = new DateTime(); DirectoryInfo[] dirs = FileCaozuo.Read_All_FilesDirect(path); ArrayList allpoints = Point_ini.ReadSections(); // 地图上所有的点 bool is_exit = false; // 是否在柱子上 foreach (DirectoryInfo dir in dirs) { try { string nowtime_string = dir.Name; string nowtime_sub_string = nowtime_string.Substring(4, nowtime_string.Length - 4); string year = nowtime_sub_string.Substring(0, 4); string month = nowtime_sub_string.Substring(4, 2); string day = nowtime_sub_string.Substring(6, 2); string hour = nowtime_sub_string.Substring(8, 2); string min = nowtime_sub_string.Substring(10, 2); DateTime nowtime = DateTime.Parse(year + "-" + month + "-" + day + " " + hour + ":" + min + ":00"); if (nowtime > newtime) { newtime = nowtime; } } catch { } } string newpath = path + "data" + newtime.ToString("yyyyMMddHHmm") + "\\"; ArrayList filelist = FileCaozuo.Read_All_Files(newpath, "*.txt"); ArrayList timelist = new ArrayList(); // 时间列表 foreach (string name in filelist) { // 每个文件的的名称 string filename = string_caozuo.Get_Dian_String(name, 1); string mydate = string_caozuo.Get_HengGang_String(filename, 1); string mytime = string_caozuo.Get_HengGang_String(filename, 2); string year = string_caozuo.Get_Xiahuaxian_String(mydate, 1); string month = string_caozuo.Get_Xiahuaxian_String(mydate, 2); string day = string_caozuo.Get_Xiahuaxian_String(mydate, 3); string hour = string_caozuo.Get_Xiahuaxian_String(mytime, 1); string min = string_caozuo.Get_Xiahuaxian_String(mytime, 2); string sec = string_caozuo.Get_Xiahuaxian_String(mytime, 3); DateTime nowtime = DateTime.Parse(year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec); timelist.Add(nowtime); } DateTime maxtime = new DateTime(); DateTime mintime = DateTime.Now; // 找出最近的时候 foreach (DateTime time in timelist) { if (time >= maxtime) { maxtime = time; } if (time < mintime) { mintime = time; } } updatetime = maxtime; //更新时间 // 最新的文件就是maxtime的文件 string nowfilename = maxtime.ToString("yyyy_MM_dd-HH_mm_ss") + ".txt"; string oldfilename = mintime.ToString("yyyy_MM_dd-HH_mm_ss") + ".txt"; // 读取些文件信息 // 最新值 string[] all_line = FileCaozuo.Read_All_Line(newpath + nowfilename); double position = 0; double value = 0; // 标准值 string[] all_line_old = FileCaozuo.Read_All_Line(newpath + oldfilename); double value_old = 0; //Real_Data_List.Clear(); for (int i = 0; i < all_line.Length; i++) { try { string str_new = all_line[i]; string str_old = all_line_old[i]; position = double.Parse(string_caozuo.Get_Table_String(str_new, 1)); value = double.Parse(string_caozuo.Get_Table_String(str_new, 2)); value_old = double.Parse(string_caozuo.Get_Table_String(str_old, 2)); DataList.Data_Struct datasrtuct = new DataList.Data_Struct(); datasrtuct.位置 = position; datasrtuct.位置X = 0; datasrtuct.位置Y = 0; datasrtuct.应变量 = double.Parse(Math.Abs(value - value_old).ToString("#0.0000")); datasrtuct.位移量 = double.Parse(Jisuan_Weiyi(Math.Abs(value - value_old)).ToString("#0.0000")); // 将值放入数据队列中 if (Real_Data_List.Count < all_line.Length) { Real_Data_List.Add(datasrtuct); Dizhi_Index.Add(position); } else { Real_Data_List[i] = datasrtuct; Dizhi_Index[i] = position; } } catch { } //int a = 0; } myreal_data_list = Real_Data_List; } catch { } }
public void ReSet(ArrayList list) { thislist = list; subgrid.Children.Clear(); Image topimage = new Image(); string path = System.Environment.CurrentDirectory + "\\zhu_tou.png"; BitmapImage imagetop = new BitmapImage(new Uri(path, UriKind.Absolute)); topimage.Source = imagetop; topimage.Margin = new Thickness(left, 0, 0, 0); subgrid.Children.Add(topimage); topimage.VerticalAlignment = VerticalAlignment.Top; topimage.HorizontalAlignment = HorizontalAlignment.Left; topimage.Height = height; int shu = thislist.Count; int tu_shu = (shu + 1) / 2; double my_tu_shu = (double)tu_shu / 2 / 3 + 1; int a = (int)Math.Ceiling(my_tu_shu); for (int i = 1; i <= a; i++) { Image shenimage = new Image(); string shenpath = System.Environment.CurrentDirectory + "\\zhu_shen.png"; BitmapImage imageshen = new BitmapImage(new Uri(shenpath, UriKind.Absolute)); shenimage.Height = height; shenimage.Source = imageshen; shenimage.Margin = new Thickness(left, topimage.Height * i, 0, 0); // shenimage.Width = width; subgrid.Children.Add(shenimage); shenimage.VerticalAlignment = VerticalAlignment.Top; shenimage.HorizontalAlignment = HorizontalAlignment.Left; } Image dimage = new Image(); string dipath = System.Environment.CurrentDirectory + "\\zhu_di.png"; BitmapImage imagedi = new BitmapImage(new Uri(dipath, UriKind.Absolute)); dimage.Height = height; //dimage.Width = width; dimage.Source = imagedi; dimage.Margin = new Thickness(left, (my_tu_shu + 1) * topimage.Height, 0, 0); subgrid.Children.Add(dimage); dimage.VerticalAlignment = VerticalAlignment.Top; dimage.HorizontalAlignment = HorizontalAlignment.Left; subgrid.VerticalAlignment = VerticalAlignment.Top; subgrid.HorizontalAlignment = HorizontalAlignment.Left; subgrid.Margin = new Thickness(left, 0, 0, 0); subgrid.Height = (my_tu_shu + 3) * topimage.Height; for (int i = 0; i < shu / 2 + 3; i++) { try { DataList.Data_Struct datastruct = (DataList.Data_Struct)thislist[i]; Label position = new Label(); position.Content = datastruct.位移量.ToString("#0.000") + " mm"; position.FontSize = 10; position.Margin = new Thickness(0, topimage.Height + (double)i * ((my_tu_shu - 1) * topimage.Height) / ((double)shu / 2), 0, 0); subgrid.Children.Add(position); position.Foreground = System.Windows.Media.Brushes.White; Label yidong = new Label(); yidong.Content = " "; yidong.FontSize = 10; yidong.Width = datastruct.位移量 * 10; yidong.Height = topimage.Height / 3; yidong.VerticalAlignment = VerticalAlignment.Top; yidong.HorizontalAlignment = HorizontalAlignment.Left; yidong.Margin = new Thickness(140 - yidong.Width, topimage.Height + (double)i * ((my_tu_shu - 1) * topimage.Height) / ((double)shu / 2), 0, 0); if (datastruct.位移量 <= 0.5) { yidong.Background = System.Windows.Media.Brushes.Blue; } if (datastruct.位移量 > 0.5 && datastruct.位移量 < 2) { yidong.Background = System.Windows.Media.Brushes.Yellow; } if (datastruct.位移量 >= 2) { yidong.Background = System.Windows.Media.Brushes.Red; } subgrid.Children.Add(yidong); Label position1 = new Label(); position1.Content = datastruct.位置.ToString("#0"); position1.FontSize = 10; position1.Margin = new Thickness(150, topimage.Height + i * ((my_tu_shu - 1) * topimage.Height) / (shu / 2), 0, 0); subgrid.Children.Add(position1); DataList.Data_Struct datastruct1 = (DataList.Data_Struct)thislist[shu - 1 - i]; Label position2 = new Label(); position2.Content = datastruct1.位移量.ToString("#0.000") + " mm"; position2.FontSize = 10; position2.Margin = new Thickness(width, topimage.Height + (double)i * ((my_tu_shu - 1) * topimage.Height) / ((double)shu / 2), 0, 0); subgrid.Children.Add(position2); position2.Foreground = System.Windows.Media.Brushes.White; Label yidong1 = new Label(); yidong1.Content = " "; yidong1.FontSize = 10; yidong1.Width = datastruct1.位移量 * 10; yidong1.Height = topimage.Height / 3; yidong1.Margin = new Thickness(271, topimage.Height + (double)i * ((my_tu_shu - 1) * topimage.Height) / ((double)shu / 2), 0, 0); yidong1.VerticalAlignment = VerticalAlignment.Top; yidong1.HorizontalAlignment = HorizontalAlignment.Left; if (datastruct1.位移量 <= 0.5) { yidong1.Background = System.Windows.Media.Brushes.Blue; } if (datastruct1.位移量 > 0.5 && datastruct.位移量 < 2) { yidong1.Background = System.Windows.Media.Brushes.Yellow; } if (datastruct1.位移量 >= 2) { yidong1.Background = System.Windows.Media.Brushes.Red; } subgrid.Children.Add(yidong1); Label position3 = new Label(); position3.Content = datastruct1.位置.ToString("#0"); position3.FontSize = 10; position3.Margin = new Thickness(230, topimage.Height + i * ((my_tu_shu - 1) * topimage.Height) / (shu / 2), 0, 0); subgrid.Children.Add(position3); } catch { } } }