예제 #1
0
        private void Update_Kuang()
        {
            path = Get_Newest_MuLu();
            ArrayList filelist = FileCaozuo.Read_All_Files(path + "\\", "*.txt");

            try
            {
                //path = Get_Newest_MuLu();
                line1_jizhun            = path + "\\" + Get_JiZhun();
                line1_jizhun_all_string = FileCaozuo.Read_All_Line(line1_jizhun);
            }
            catch { }

            try
            {
                foreach (string name in filelist)
                {
                    if (kuang1.IndexOf(name) == -1)
                    {
                        kuang1.Add(name);
                    }
                    if (kuang2.IndexOf(name) == -1)
                    {
                        kuang2.Add(name);
                    }
                }
            }
            catch { }
        }
예제 #2
0
        private void Show_Pic_List()
        {
            // 将pic文件夹中的bmp文件显示在列表中
            string path = System.Environment.CurrentDirectory + "\\mappic";

            FileCaozuo.Read_All_Files_Show_List(path, "*.bmp", listBox1);
        }
예제 #3
0
        private void button_line3_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string line1_jizhun = MainWindow.path + line3_jizhun_mulu_combo.Text + "\\" + line3_jizhun_wenjian_combo.Items[line3_jizhun_wenjian_combo.SelectedIndex].ToString();
                string line1_string = MainWindow.path + line3_mulu.Text + "\\" + line3_wenjian.Items[line3_wenjian.SelectedIndex].ToString();

                string[] line1_jizhun_all_string = FileCaozuo.Read_All_Line(line1_jizhun);
                string[] line1_all_string        = FileCaozuo.Read_All_Line(line1_string);

                chart.chart1.Series[1].Points.Clear();

                for (int i = 0; i < line1_jizhun_all_string.Length; i++)
                {
                    try
                    {
                        string str_new   = line1_jizhun_all_string[i];
                        string str_old   = line1_all_string[i];
                        double position  = double.Parse(string_caozuo.Get_Table_String(str_new, 1));
                        double value     = double.Parse(string_caozuo.Get_Table_String(str_new, 2));
                        double value_old = double.Parse(string_caozuo.Get_Table_String(str_old, 2));

                        double myvalue = Math.Abs(value - value_old) / 0.0482;
                        if (i % 10 == 0)
                        {
                            chart.Insert_Point2(position, MainWindow.Jisuan_Weiyi(myvalue));
                        }
                    }
                    catch { }
                }
            }
            catch { }
        }
예제 #4
0
        private void combobox_shijian_DropDownClosed(object sender, EventArgs e)
        {
            ArrayList table_list = new ArrayList();                                        // 表格的数据

            try
            {
                string   name  = combobox_riqi.Text + " " + combobox_shijian.Text;        // 名称
                string[] lines = FileCaozuo.Read_All_Line("D:\\config\\warning\\" + name);
                //mychart1.ReSet();
                foreach (string line in lines)
                {
                    try
                    {
                        string   zhu_name = string_caozuo.Get_KongGe_String(line, 1);
                        double   position = double.Parse(string_caozuo.Get_KongGe_String(line, 2));
                        double   value    = double.Parse(string_caozuo.Get_KongGe_String(line, 3));
                        WarnData warndata = new WarnData();
                        warndata.报警段 = zhu_name;
                        warndata.地点  = position;
                        warndata.位移  = value;
                        table_list.Add(warndata);
                        //mychart1.Insert_Point(position,value);
                    }
                    catch { }
                }

                Set_Table(table_list);
            }
            catch { }
        }
예제 #5
0
        private string  Get_Newest_MuLu()
        {
            DirectoryInfo[] dirs    = FileCaozuo.Read_All_FilesDirect(MainWindow.path); // 所有的目录
            bool            is_exit = false;                                            // 是否在柱子上
            DateTime        newtime = new DateTime();

            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 = MainWindow.path + "data" + newtime.ToString("yyyyMMddHHmm") + "\\";

            return(newpath);
        }
예제 #6
0
        public string Read_Init(string ini_path_name, string section, string key)
        {
            // 如果没有文件,创建文件

            FileCaozuo.Create_File(System.Web.HttpContext.Current.Server.MapPath("~/" + ini_path_name));
            StringBuilder temp = new StringBuilder(255);

            int i = GetPrivateProfileString(section, key, "", temp, 255, System.Web.HttpContext.Current.Server.MapPath("~/" + ini_path_name));

            return(temp.ToString());
        }
예제 #7
0
        private void ReFlush_Chart()
        {
            Chart1.Series[0].Points.Clear();
            Chart1.Series[1].Points.Clear();
            try
            {
                string   jizhun_file = ListBox1.Items[0].Value.ToString();
                string   filename    = ListBox1.Items[ListBox1.SelectedIndex].Value.ToString();
                string[] jizhun_list = FileCaozuo.Read_All_Line("D:\\data\\" + jizhun_file);
                string[] now_list    = FileCaozuo.Read_All_Line("D:\\data\\" + filename);
                Label_select1.Text = "第一曲线(红色)选择文件为:" + filename;

                for (int i = 0; i < jizhun_list.Length; i++)
                {
                    string position_string     = string_caozuo.Get_Table_String(jizhun_list[i], 1);
                    double position            = double.Parse(position_string);
                    string value_jizhun_string = string_caozuo.Get_Table_String(jizhun_list[i], 2);
                    string value_now_string    = string_caozuo.Get_Table_String(now_list[i], 2);
                    double jizhun = double.Parse(value_jizhun_string);
                    double now    = double.Parse(value_now_string);

                    double value = Math.Round(Math.Abs(now - jizhun) * (1 - Math.Sqrt(3) / 2) / 0.0482, 3);
                    if (position >= start1 && position <= end2)
                    {
                        Chart1.Series[0].Points.AddXY(position, value);
                    }
                }
            }
            catch { }
            try
            {
                string   jizhun_file = ListBox2.Items[0].Value.ToString();
                string   filename    = ListBox2.Items[ListBox2.SelectedIndex].Value.ToString();
                string[] jizhun_list = FileCaozuo.Read_All_Line("D:\\data\\" + jizhun_file);
                string[] now_list    = FileCaozuo.Read_All_Line("D:\\data\\" + filename);
                Label_select2.Text = "第二曲线(蓝色)选择文件为:" + filename;
                for (int i = 0; i < jizhun_list.Length; i++)
                {
                    string position_string     = string_caozuo.Get_Table_String(jizhun_list[i], 1);
                    double position            = double.Parse(position_string);
                    string value_jizhun_string = string_caozuo.Get_Table_String(jizhun_list[i], 2);
                    string value_now_string    = string_caozuo.Get_Table_String(now_list[i], 2);
                    double jizhun = double.Parse(value_jizhun_string);
                    double now    = double.Parse(value_now_string);

                    double value = Math.Round(Math.Abs(now - jizhun) * (1 - Math.Sqrt(3) / 2) / 0.0482, 3);
                    if (position >= start1 && position <= end2)
                    {
                        Chart1.Series[1].Points.AddXY(position, value);
                    }
                }
            }
            catch { }
        }
예제 #8
0
        private void ReFlush_List()
        {
            ArrayList filelist = FileCaozuo.Read_All_Files("D:\\data\\", "*.txt");

            ListBox1.Items.Clear();
            ListBox2.Items.Clear();
            foreach (string myline in filelist)
            {
                ListBox1.Items.Add(myline);
                ListBox2.Items.Add(myline);
            }
        }
예제 #9
0
 private void line3_mulu_DropDownOpened(object sender, EventArgs e)
 {
     try
     {
         DirectoryInfo[] dirs = FileCaozuo.Read_All_FilesDirect(MainWindow.path);
         line3_mulu.Items.Clear();
         for (int i = 0; i < dirs.Length; i++)
         {
             line3_mulu.Items.Add(dirs[i].Name);
         }
     }
     catch { }
 }
예제 #10
0
        private void ReFlush_List()
        {
            ArrayList filelist = FileCaozuo.Read_All_Files("D:\\data\\", "*.txt");


            ArrayList alldirs = FileCaozuo.Read_All_Dir("D:\\data\\");

            ListBox3.Items.Clear();
            foreach (DirectoryInfo info in alldirs)
            {
                ListBox3.Items.Add(info.Name);
            }
        }
예제 #11
0
        private void combo_select_save_DropDownOpened(object sender, EventArgs e)
        {
            ArrayList filelist = FileCaozuo.Read_All_Files(MainWindow.path + combo_select_jizhun.Text + "\\", "*.txt");

            combo_select_save.Items.Clear();
            try
            {
                foreach (string name in filelist)
                {
                    combo_select_save.Items.Add(name);
                }
            }
            catch { }
        }
예제 #12
0
        public void Read_Project_List()
        {
            //listBox1.Items.Clear();

            // 读取项目文件
            string[] allproject = FileCaozuo.Read_All_Line(Form1.Project_Config_File);
            for (int i = 0; i < allproject.Length; i++)
            {
                if (allproject[i] != null)
                {
                    //listBox1.Items.Add(allproject[i]);
                }
            }
        }
예제 #13
0
        private void line3_wenjian_DropDownOpened(object sender, EventArgs e)
        {
            ArrayList filelist = FileCaozuo.Read_All_Files(MainWindow.path + line3_mulu.Text + "\\", "*.txt");

            line3_wenjian.Items.Clear();
            try
            {
                foreach (string name in filelist)
                {
                    line3_wenjian.Items.Add(name);
                }
            }
            catch { }
        }
예제 #14
0
 private void combobox_wenjianjia_DropDownOpened(object sender, EventArgs e)
 {
     // 刷新基准 与 日期
     try
     {
         DirectoryInfo[] dirs = FileCaozuo.Read_All_FilesDirect(MainWindow.path);
         //combobox_wenjianjia.Items.Clear();
         //for (int i = 0; i < dirs.Length; i++)
         //{
         //    combobox_wenjianjia.Items.Add(dirs[i].Name);
         //}
     }
     catch { }
 }
예제 #15
0
 private void combo_select_jizhun_DropDownOpened(object sender, EventArgs e)
 {
     // 刷新基准 与 日期
     try
     {
         DirectoryInfo[] dirs = FileCaozuo.Read_All_FilesDirect(MainWindow.path);
         combo_select_jizhun.Items.Clear();
         for (int i = 0; i < dirs.Length; i++)
         {
             combo_select_jizhun.Items.Add(dirs[i].Name);
         }
     }
     catch { }
 }
예제 #16
0
        private void Show_Thread1()
        {
            line1_all_string = FileCaozuo.Read_All_Line(line1_string);

            // 组二
            //try
            //{
            //    //line2_jizhun = path + "\\" + Get_JiZhun();


            //    //line2_jizhun_all_string = FileCaozuo.Read_All_Line(line2_jizhun);

            //    allcount = line2_jizhun_all_string.Length;
            //}
            //catch { }
            // chulizhongview.Close();
        }
예제 #17
0
        private void cob_select_jizhun_MouseEnter(object sender, MouseEventArgs e)
        {
            // 更新所有的数据信息
            ArrayList filelist = FileCaozuo.Read_All_Files(MainWindow.path, "*.txt");

            cob_select_jizhun.Items.Clear();
            //combo_select_save.Items.Clear();
            try
            {
                foreach (string name in filelist)
                {
                    cob_select_jizhun.Items.Add(name);
                    //combo_select_save.Items.Add(name);
                }
            }
            catch { }
        }
예제 #18
0
        private void combobox_riqi_DropDownOpened(object sender, EventArgs e)
        {
            // 更新combobox_riqi
            combobox_riqi.Items.Clear();            // 清空列表

            try
            {
                ArrayList list = FileCaozuo.Read_All_Files("D:\\config\\warning\\", "*.txt");
                foreach (string name in list)
                {
                    string data = string_caozuo.Get_KongGe_String(name, 1) + " " + string_caozuo.Get_KongGe_String(name, 2) + " " + string_caozuo.Get_KongGe_String(name, 3);
                    if (combobox_riqi.Items.Contains(data) == false)
                    {
                        combobox_riqi.Items.Add(data);
                    }
                }
            }
            catch { }
        }
예제 #19
0
 private void combobox_shijian_DropDownOpened(object sender, EventArgs e)
 {
     combobox_shijian.Items.Clear();
     try
     {
         ArrayList list = FileCaozuo.Read_All_Files("D:\\config\\warning\\", "*.txt");
         foreach (string name in list)
         {
             try
             {
                 string data = string_caozuo.Get_KongGe_String(name, 1) + " " + string_caozuo.Get_KongGe_String(name, 2) + " " + string_caozuo.Get_KongGe_String(name, 3);
                 string time = string_caozuo.Get_KongGe_String(name, 4) + " " + string_caozuo.Get_KongGe_String(name, 5) + " " + string_caozuo.Get_KongGe_String(name, 6);
                 if (combobox_shijian.Items.Contains(time) == false && data != "" && data == combobox_riqi.Text)
                 {
                     combobox_shijian.Items.Add(time);
                 }
             }
             catch { }
         }
     }
     catch { }
 }
예제 #20
0
        public static View.ProjectManager projectmanager = new View.ProjectManager();               // 项目管理配置

        public Form1()
        {
            InitializeComponent();
            // 初始化
            projectmanager.TopLevel = false;

            // 最开始显示的是工程管理界面
            Show_View(projectmanager);

            // 新建数据库
            master_sql_builder.Create_Database("MyMES");

            // 设置比例
            ViewCaoZuo.Max_Form(this);
            ViewCaoZuo.Object_Position(0, 0, 0.1, 1, treeView_select, this.Controls);
            ViewCaoZuo.Object_Position(0.12, 0.08, 0.8, 0.9, panel_view, this.Controls);

            string[] a = FileCaozuo.Read_All_Line(Project_Config_File);
            if (a != null)
            {
                // 当配置文件不为空时
            }
        }
예제 #21
0
        private void button2_Click(object sender, EventArgs e)
        {
            string project_name = textBox_project_name.Text.Trim();
            string path         = label_path.Text.Trim();
            string pathfile     = "";

            // 创建项目
            if (project_name == "")
            {
                // 项目名称为空
                MessageBox.Show("项目名称不能为空!");
                return;
            }
            pathfile = path + "\\" + project_name;

            // 检查当前文件夹是否有这个文件夹
            bool exits = DirectoryCaozuo.Directory_Exits(pathfile);

            if (exits == true)
            {
                // 项目文件夹已经存在了
                MessageBox.Show("项目文件夹已经存在!");
                return;
            }
            if (exits == false)
            {
                // 创建项目文件夹与项目文件
                DirectoryCaozuo.Create_Directory(pathfile);
                // 在项目文件夹里创建必要的文件


                // 在配置文件中加入这个路径
                FileCaozuo.Write_Lind_Add(Form1.Project_Config_File, pathfile);
                this.DialogResult = DialogResult.OK;                             // 创建了一个项目
                this.Dispose();
            }
        }
예제 #22
0
        private void btn_save_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFile = new SaveFileDialog();

            saveFile.Filter = "文本文件(*.txt)|*.txt";
            if (saveFile.ShowDialog() == true)
            {
                try
                {
                    StreamWriter sw    = new StreamWriter(saveFile.FileName, true);
                    string[]     lines = FileCaozuo.Read_All_Line(MainWindow.path + combo_select_jizhun.Text + "\\" + combo_select_save.Text);

                    foreach (string line in lines)
                    {
                        sw.WriteLine(line);
                    }

                    sw.Close();
                    MessageBox.Show("文件保存成功!", "温馨提示");
                }
                catch { MessageBox.Show("文件保存失败!", "温馨提示"); }
                //filePath = saveFile.FileName;
            }

            //if (textFileName.Equals(""))
            //{
            //    FileInfo fileInfo = new FileInfo(saveFile.FileName);
            //    //Text = fileInfo.Name;
            //    //textFileName = fileInfo.Name;
            //}
            //else
            //{

            //    //Text = textFileName;
            //}
        }
예제 #23
0
        private void Show_Voice()
        {
            string path = System.Environment.CurrentDirectory + "\\voice";

            FileCaozuo.Read_All_Files_Show_ComboBox(path, "*.wav", comboBox_voice);
        }
예제 #24
0
        public string old_update_file = "";                     // 上次更新的文件名

        //[DllImport("FreeConsole")]
        //public static extern bool FreeConsole();
        //[DllImport("FreeConsole")]
        //public static extern bool AllocConsole();

        public MainWindow()
        {
            //AllocConsole();
            InitializeComponent();
            // 屏幕参数
            this.Top    = 0;
            this.Left   = 0;
            this.Width  = screen_width;
            this.Height = scree_height;
            init_view();
            All_Sub_Hide();      // 所有的界面隐藏起来

            // 登陆界面
            Page1 login    = new Page1();
            bool? login_is = login.ShowDialog();

            if (login_is == true)
            {
                // 如果是登录
                if (Page1.UserName == "admin" && Page1.PassWord == "admin")
                {
                    // 超级管理员登录
                    User_Name     = "admin";
                    User_QuanXian = "管理员";
                }
            }
            else
            {
                // 如果是取消,就退出程序
                System.Environment.Exit(0);
            }

            FileCaozuo.Create_File("D:\\config\\Map.ini");
            Point_ini = new IniFile("D:\\config\\Map.ini");



            // 读取柱子数组
            ArrayList list = MainWindow.Point_ini.ReadSections();

            zhuzi_name = new string[list.Count];    // 定义柱子数组
            rukou      = new int[list.Count];       // 定义入口数组
            chukou     = new int[list.Count];       // 定义出口数组

            for (int i = 0; i < list.Count; i++)
            {
                string name = (string)list[i];
                zhuzi_name[i] = name;
                rukou[i]      = int.Parse(MainWindow.Point_ini.IniReadValue(name, "rukou"));
                chukou[i]     = int.Parse(MainWindow.Point_ini.IniReadValue(name, "chukou"));
            }



            mygrid.Background = new ImageBrush
            {
                ImageSource = new BitmapImage(new Uri(rootpath + "\\bg.jpg"))
            };

            Show_SubView(myview);
            myview.Read_Real_Data();
            myview.Read_All_Point();
        }
예제 #25
0
        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 { }
        }
예제 #26
0
        private void cob_select_jizhun_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // 更新树形图的信息

            // 0-10 的点
            item0        = new TreeViewItem();
            item0.Header = "0-10";

            // 11-20 的点
            item11        = new TreeViewItem();
            item11.Header = "11-20";

            // 21-30的点
            item21        = new TreeViewItem();
            item21.Header = "21-30";

            // 31-40的点
            item31        = new TreeViewItem();
            item31.Header = "31-40";

            // 41-50的点
            item41        = new TreeViewItem();
            item41.Header = "41-50";

            // 51-60的点
            item51        = new TreeViewItem();
            item51.Header = "51-60";

            // 61-70的点
            item61        = new TreeViewItem();
            item61.Header = "61-70";

            // 71-80的点
            item71        = new TreeViewItem();
            item71.Header = "71-80";

            // 81-90的点
            item81        = new TreeViewItem();
            item81.Header = "81-90";

            // 91-100的点
            item91        = new TreeViewItem();
            item91.Header = "91-100";

            // 101-110的点
            item101        = new TreeViewItem();
            item101.Header = "101-110";

            // 111-120的点
            item111        = new TreeViewItem();
            item111.Header = "111-120";

            // 121-130的点
            item121        = new TreeViewItem();
            item121.Header = "121-130";

            // 131-140的点
            item131        = new TreeViewItem();
            item131.Header = "131-140";

            // 141-150的点
            item141        = new TreeViewItem();
            item141.Header = "141-150";

            // 151-160的点
            item151        = new TreeViewItem();
            item151.Header = "151-160";

            // 161-170的点
            item161        = new TreeViewItem();
            item161.Header = "161-170";

            // 171-180的点
            item171        = new TreeViewItem();
            item171.Header = "171-180";



            mytreeview.Items.Clear();
            mytreeview.Items.Add(item0);
            mytreeview.Items.Add(item11);
            mytreeview.Items.Add(item21);
            mytreeview.Items.Add(item31);
            mytreeview.Items.Add(item41);
            mytreeview.Items.Add(item51);
            mytreeview.Items.Add(item61);
            mytreeview.Items.Add(item71);
            mytreeview.Items.Add(item81);
            mytreeview.Items.Add(item91);
            mytreeview.Items.Add(item101);
            mytreeview.Items.Add(item111);
            mytreeview.Items.Add(item121);
            mytreeview.Items.Add(item131);
            mytreeview.Items.Add(item141);
            mytreeview.Items.Add(item151);
            mytreeview.Items.Add(item161);
            mytreeview.Items.Add(item171);
            try
            {
                string filename = MainWindow.path + cob_select_jizhun.Items[cob_select_jizhun.SelectedIndex].ToString();

                // 将点加入曲线中
                string[] all_line = FileCaozuo.Read_All_Line(filename);
                foreach (string str in all_line)
                {
                    double position = double.Parse(string_caozuo.Get_Table_String(str, 1));
                    if (position >= 0 && position < 11)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item0.Items.Add(item);
                    }
                    if (position >= 11 && position < 21)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item11.Items.Add(item);
                    }
                    if (position >= 21 && position < 31)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item21.Items.Add(item);
                    }

                    if (position >= 31 && position < 41)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item31.Items.Add(item);
                    }

                    if (position >= 41 && position < 51)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item41.Items.Add(item);
                    }

                    if (position >= 51 && position < 61)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item51.Items.Add(item);
                    }
                    if (position >= 61 && position < 71)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item61.Items.Add(item);
                    }
                    if (position >= 71 && position < 81)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item71.Items.Add(item);
                    }

                    if (position >= 81 && position < 91)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item81.Items.Add(item);
                    }

                    if (position >= 91 && position < 101)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item91.Items.Add(item);
                    }

                    if (position >= 101 && position < 111)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item101.Items.Add(item);
                    }

                    if (position >= 111 && position < 121)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item111.Items.Add(item);
                    }

                    if (position >= 121 && position < 131)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item121.Items.Add(item);
                    }

                    if (position >= 131 && position < 141)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item131.Items.Add(item);
                    }

                    if (position >= 141 && position < 151)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item141.Items.Add(item);
                    }

                    if (position >= 151 && position < 161)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item151.Items.Add(item);
                    }

                    if (position >= 161 && position < 171)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item161.Items.Add(item);
                    }

                    if (position >= 171 && position < 181)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = position.ToString();
                        item171.Items.Add(item);
                    }
                }
            }
            catch { }
        }
예제 #27
0
        private string Get_JiZhun()
        {
            DirectoryInfo[] dirs    = FileCaozuo.Read_All_FilesDirect(MainWindow.path); // 所有的目录
            bool            is_exit = false;                                            // 是否在柱子上
            DateTime        newtime = new DateTime();

            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 = MainWindow.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;
                }
            }

            MainWindow.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";

            return(oldfilename);
        }
예제 #28
0
 private void Show_Thread2()
 {
     line2_all_string = FileCaozuo.Read_All_Line(line2_string);
 }
예제 #29
0
        private void Warn_Timer_Tick(object sender, EventArgs e)
        {
            bool warning_is = false;                              // 是否产生了报警

            try
            {
                bool gengxin_is = false;                              // 更新标志


                //warn_bofang = false;
                //Show_Warning_List();
                ArrayList show_arraylist = new ArrayList();
                //myDataList.Set_Table(MainWindow.Real_Data_List);
                label_updatetime.Content = "更新时间:" + MainWindow.updatetime.ToString("yyyy-MM-dd HH:mm:ss");
                if (MainWindow.updatetime != oldupdate_time)
                {
                    oldupdate_time = MainWindow.updatetime;   // 更新了
                    gengxin_is     = true;
                }

                // 在表格上显示有效的数据
                if (show_point_name != "")
                {
                    datascrollviewer.Visibility = Visibility.Visible;
                    foreach (DataList.Data_Struct data_struct in MainWindow.Real_Data_List)
                    {
                        bool isexit = false;
                        for (int i = 0; i < MainWindow.zhuzi_name.Length; i++)
                        {
                            if (data_struct.位置 >= MainWindow.rukou[i] && data_struct.位置 <= MainWindow.chukou[i] && MainWindow.zhuzi_name[i] == show_point_name)
                            {
                                // 选定特定的名称
                                isexit = true;
                                break;
                            }
                        }
                        if (isexit == true)
                        {
                            show_arraylist.Add(data_struct);
                        }
                    }
                    myDataList.Set_Table(show_arraylist);
                }

                foreach (DiZhuang_Item item in all_dizhuang_list)
                {
                    item.Background = System.Windows.Media.Brushes.Transparent;
                }

                foreach (myline item in all_line_list)
                {
                    item.warn_is = false;
                    item.Draw_Line();
                }
                if (true)
                {
                    // 全部展示
                    foreach (DataList.Data_Struct data_struct in MainWindow.Real_Data_List)
                    {
                        bool isexit = false;
                        for (int i = 0; i < MainWindow.zhuzi_name.Length; i++)
                        {
                            if (data_struct.位置 >= MainWindow.rukou[i] && data_struct.位置 <= MainWindow.chukou[i])
                            {
                                isexit = true;

                                // 在这里判断报警信息
                                if (data_struct.位移量 >= MainWindow.yuzhi && warning_is == false && gengxin_is == true)
                                {
                                    // 产生了报警
                                    // 报警信息:点名称  位置  位移量
                                    warning_is = true;
                                    FileCaozuo.Create_File("D:\\config\\warning\\" + MainWindow.updatetime.ToString("yyyy MM dd HH mm ss") + ".txt");
                                    string warn_string = "报警位置:" + data_struct.位置.ToString() + "  位移值:" + data_struct.位移量.ToString() + "mm";
                                    all_warn_list.Add(warn_string);
                                }

                                if (data_struct.位移量 >= MainWindow.yuzhi)
                                {
                                    foreach (DiZhuang_Item item in all_dizhuang_list)
                                    {
                                        if (item.label_center.Content.ToString() == MainWindow.zhuzi_name[i])
                                        {
                                            item.Background = System.Windows.Media.Brushes.Red;
                                            warning_is      = true;
                                            warn_bofang2    = true;
                                            break;
                                        }
                                    }

                                    foreach (myline item in all_line_list)
                                    {
                                        if (item.Key == MainWindow.zhuzi_name[i])
                                        {
                                            item.warn_is = true;
                                            warning_is   = true;
                                            warn_bofang2 = true;
                                            item.Draw_Line();
                                            break;
                                        }
                                    }
                                }
                                if (data_struct.位移量 >= MainWindow.yuzhi && gengxin_is == true)
                                {
                                    // 写入报警信息
                                    StreamWriter sw = new StreamWriter("D:\\config\\warning\\" + MainWindow.updatetime.ToString("yyyy MM dd HH mm ss") + ".txt", true);    // 向文件尾加入报警信息
                                    sw.WriteLine(MainWindow.zhuzi_name[i] + " " + data_struct.位置.ToString() + " " + data_struct.位移量.ToString());
                                    sw.Close();
                                }
                                break;
                            }
                        }
                        if (isexit == true && show_point_name == "")
                        {
                            show_arraylist.Add(data_struct);
                        }
                    }
                    if (show_point_name == "")
                    {
                        datascrollviewer.Visibility = Visibility.Hidden;
                        myDataList.Set_Table(show_arraylist);
                    }
                    if (warning_is == false)
                    {
                        warn_bofang2 = false;
                    }
                }
            }
            catch
            {
            }
        }
예제 #30
0
        private void button_line2_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                chart.chart1.Series[0].Points.Clear();
                chart.chart1.Series[1].Points.Clear();
                try
                {
                    allcount = line1_jizhun_all_string.Length;
                }
                catch { }
                //MessageBox.Show()

                // 读最大的文件


                // 组一
                //Thread thread = new Thread(Show_Thread1);
                //thread.Start();
                //chulizhongview.ShowDialog();
                try
                {
                    line1_string     = path + "\\" + line1_wenjian.Items[line1_wenjian.SelectedIndex].ToString();
                    line1_all_string = FileCaozuo.Read_All_Line(line1_string);
                }
                catch { }
                try
                {
                    line2_string = path + "\\" + line2_wenjian.Items[line2_wenjian.SelectedIndex].ToString();

                    line2_all_string = FileCaozuo.Read_All_Line(line2_string);
                }
                catch { }

                for (int i = 0; i < allcount; i++)
                {
                    try
                    {
                        // 一号组

                        string str_new   = line1_jizhun_all_string[i];
                        string str_old   = line1_all_string[i];
                        double position  = double.Parse(string_caozuo.Get_Table_String(str_new, 1));
                        double value     = double.Parse(string_caozuo.Get_Table_String(str_new, 2));
                        double value_old = double.Parse(string_caozuo.Get_Table_String(str_old, 2));

                        double myvalue = Math.Abs(value - value_old);

                        if (i % 10 == 0)
                        {
                            chart.Insert_Point(position, MainWindow.Jisuan_Weiyi(myvalue));
                            //chart.Insert_Point(position, myvalue2);
                        }
                    }
                    catch {}
                    try{
                        // if (i % 10 == 0)
                        //chart.Insert_Point(position, MainWindow.Jisuan_Weiyi(myvalue));
                        // 二号组

                        string str_new2   = line1_jizhun_all_string[i];
                        string str_old2   = line2_all_string[i];
                        double position2  = double.Parse(string_caozuo.Get_Table_String(str_new2, 1));
                        double value2     = double.Parse(string_caozuo.Get_Table_String(str_new2, 2));
                        double value_old2 = double.Parse(string_caozuo.Get_Table_String(str_old2, 2));

                        //string str_new = line1_jizhun_all_string[i];
                        //string str_old = line1_all_string[i];
                        //double position = double.Parse(string_caozuo.Get_Table_String(str_new, 1));
                        //double value = double.Parse(string_caozuo.Get_Table_String(str_new, 2));
                        //double value_old = double.Parse(string_caozuo.Get_Table_String(str_old, 2));

                        double myvalue2 = Math.Abs(value2 - value_old2);
                        if (i % 10 == 0)
                        {
                            // chart.Insert_Point1(position, myvalue);
                            chart.Insert_Point1(position2, MainWindow.Jisuan_Weiyi(myvalue2));
                        }
                    }
                    catch { }
                }
            }
            catch { }
        }