alielie
2026-04-23 ef52fd6fd07508883dce4eb002acda59f0169e59
优化;
16个文件已修改
1个文件已添加
444 ■■■■■ 已修改文件
HMI.LogViewer/HMI.LogViewer.csproj 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HMI.LogViewer/LogData.cs 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HMI.LogViewer/LogViewer.xaml 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HMI.LogViewer/LogViewer.xaml.cs 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HMI.UI/Util/MaskHolder.cs 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Plugin.TestResult/DataTable.xaml.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Plugin.TestResult/SingleCell.xaml.cs 154 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Plugin.TestResult/TestResultView.xaml.cs 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Plugin.TsExecution/ScreenTouch.xaml.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Plugin.TsExecution/TsExecution.xaml.cs 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Util.ManualDebug/ManualDebug.xaml.cs 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WPFProject/Controls/MainTabControl.xaml.cs 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WPFProject/PanuonWindow.xaml 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WPFProject/PanuonWindow.xaml.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WPFProject/Properties/AssemblyInfo.cs 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WPFProject/ResourceListener.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WPFProject/WPFProject.sln 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HMI.LogViewer/HMI.LogViewer.csproj
@@ -81,6 +81,7 @@
      <Generator>MSBuild:Compile</Generator>
      <SubType>Designer</SubType>
    </Page>
    <Compile Include="LogData.cs" />
    <Compile Include="LogViewer.xaml.cs">
      <DependentUpon>LogViewer.xaml</DependentUpon>
      <SubType>Code</SubType>
@@ -123,6 +124,10 @@
      <Project>{f17de6b5-af1d-48c6-94a0-6b763a6546a6}</Project>
      <Name>HMI.UI</Name>
    </ProjectReference>
    <ProjectReference Include="..\HMI.Util\HMI.Util.csproj">
      <Project>{afea100a-9223-448d-ab10-3015d93dd98c}</Project>
      <Name>HMI.Util</Name>
    </ProjectReference>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <PropertyGroup>
HMI.LogViewer/LogData.cs
New file
@@ -0,0 +1,19 @@
using HMI.Core;
namespace HMI.LogViewer
{
    public class LogData
    {
        [ExcelColumn("级别")]
        public string level { get; set; }
        [ExcelColumn("时间")]
        public string time { get; set; }
        [ExcelColumn("来源")]
        public string source { get; set; }
        [ExcelColumn("内容")]
        public string text { get; set; }
    }
}
HMI.LogViewer/LogViewer.xaml
@@ -73,8 +73,8 @@
                            x:Name="queryBtn" Click="Button_Click"/>
                    <Button Style="{StaticResource ResetBtn}"
                            x:Name="resetBtn" Click="Button_Click"/>
                    <!--<Button x:Name="exportBtn"
                            Style="{StaticResource ExportBtn}" Click="Button_Click"/>-->
                    <Button x:Name="exportBtn"
                            Style="{StaticResource ExportBtn}" Click="Button_Click"/>
                </StackPanel>
                <StackPanel Style="{StaticResource ButtonGroup}" HorizontalAlignment="Left">
HMI.LogViewer/LogViewer.xaml.cs
@@ -1,6 +1,8 @@
using HMI.Base;
using HMI.Core.Util;
using HMI.UI.Util;
using HMI.Util;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Data;
@@ -131,8 +133,26 @@
            }
        }
        private void DoExport() {
        private void DoExport()
        {
            try
            {
                SaveFileDialog sfd = new SaveFileDialog
                {
                    Filter = "Excel Files (*.xls)|*.xls",
                };
                if (sfd.ShowDialog() == true)
                {
                    var dt = GetDataTable(false, 1, 1, out long totalPage);
                    ExcelHelper.ExportExcel<LogData>(sfd.FileName, dt);
                    ToastHelper.Success(this.lang("App.ExportSuccess"));
                }
            }
            catch (Exception ex)
            {
                log.Error("Export Log Failed.", ex);
                MsgBoxHelper2.Error($"导出失败: {ex.Message}");
            }
        }
        private void QueryLog()
@@ -180,16 +200,14 @@
            endTimeInput.SelectedDateTime = end;
        }
        private void Filtrate(long page, long size)
        public DataTable GetDataTable(bool usePage, long page, long size, out long totalPage)
        {
            try
            {
            totalPage = 0;
                var files = GetOldDbFiles(PathHelper.LogViewerDir, new DateTime?[] { startTimeInput.SelectedDateTime,
                endTimeInput.SelectedDateTime });
                if (files.Length <= 0)
                {
                    table.ItemsSource = new DataTable().DefaultView;
                    return;
                return new DataTable();
                }
                using (Sqlite3Helper helper = new Sqlite3Helper(files[0]))
@@ -209,16 +227,62 @@
                    string countSql = $"SELECT COUNT(1) FROM ({sql}) as __temp";
                    long total = (long)helper.SelectOne(countSql);
                    long pages = (total/pageSize)+ ((total % pageSize) > 0 ? 1 : 0);
                totalPage = (total / pageSize) + ((total % pageSize) > 0 ? 1 : 0);
                if (usePage)
                {
                    sql = $"{baseSql} ORDER BY {sortName} {sortDirection} LIMIT {size} OFFSET {(page - 1) * size} ";
                    DataTable dt = helper.GetDataTable(sql);
                    table.ItemsSource = dt.DefaultView;
                    MaxPage = pages;
                }
                else
                {
                    sql = $"{baseSql} ORDER BY {sortName} {sortDirection}";
                }
                DataTable dt = helper.GetDataTable(sql);
                return dt;
            }
        }
        private void Filtrate(long page, long size)
        {
            try
            {
                //var files = GetOldDbFiles(PathHelper.LogViewerDir, new DateTime?[] { startTimeInput.SelectedDateTime,
                //endTimeInput.SelectedDateTime });
                //if (files.Length <= 0)
                //{
                //    table.ItemsSource = new DataTable().DefaultView;
                //    return;
                //}
                //using (Sqlite3Helper helper = new Sqlite3Helper(files[0]))
                //{
                //    for (int i = 0; i < files.Length; i++)
                //    {
                //        var attach = $"ATTACH DATABASE '{files[i]}' AS 'db{i}'";
                //        helper.Execute(attach);
                //    }
                //    string sql = string.Join(" UNION ALL ", GetSqls(files));
                //    string sortName = "time", sortDirection = "DESC";
                //    string baseSql = $"SELECT level,time,source,text FROM ({sql}) as _temp";
                //    string countSql = $"SELECT COUNT(1) FROM ({sql}) as __temp";
                //    long total = (long)helper.SelectOne(countSql);
                //    long pages = (total/pageSize)+ ((total % pageSize) > 0 ? 1 : 0);
                //    sql = $"{baseSql} ORDER BY {sortName} {sortDirection} LIMIT {size} OFFSET {(page - 1) * size} ";
                //    DataTable dt = helper.GetDataTable(sql);
                //    table.ItemsSource = dt.DefaultView;
                //    MaxPage = pages;
                //}
                table.ItemsSource = GetDataTable(true, page, size, out long totalPage).DefaultView;
                MaxPage = totalPage;
            }
            catch (Exception ex)
            {
HMI.UI/Util/MaskHolder.cs
@@ -1,43 +1,39 @@
using Panuon.WPF.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HMI.UI.Util
{
    public class MaskHolder
    {
        private static Dictionary<WindowX, List<object>> Container;
        private static Dictionary<object, WindowX> ReverseContainer;
    //public class MaskHolder
    //{
    //    private static Dictionary<WindowX, List<object>> Container;
    //    private static Dictionary<object, WindowX> ReverseContainer;
        public static void AddMask(WindowX window, object source)
        {
            if (Container.ContainsKey(window))
            {
                Container[window].Add(source);
            }
            else
            {
                Container[window] = new List<object> { source };
            }
            ReverseContainer.Add(source, window);
            window.IsMaskVisible = true;
        }
    //    public static void AddMask(WindowX window, object source)
    //    {
    //        if (Container.ContainsKey(window))
    //        {
    //            Container[window].Add(source);
    //        }
    //        else
    //        {
    //            Container[window] = new List<object> { source };
    //        }
    //        ReverseContainer.Add(source, window);
    //        window.IsMaskVisible = true;
    //    }
        public static void RemoveMask(object source)
        {
            if (!ReverseContainer.ContainsKey(source))
            {
                return;
            }
            WindowX win = ReverseContainer[source];
            if (!Container.ContainsKey(win) || Container[win] == null || Container[win].Count <= 0)
            {
                win.IsMaskVisible = false;
            }
            ReverseContainer.Remove(source);
        }
    }
    //    public static void RemoveMask(object source)
    //    {
    //        if (!ReverseContainer.ContainsKey(source))
    //        {
    //            return;
    //        }
    //        WindowX win = ReverseContainer[source];
    //        if (!Container.ContainsKey(win) || Container[win] == null || Container[win].Count <= 0)
    //        {
    //            win.IsMaskVisible = false;
    //        }
    //        ReverseContainer.Remove(source);
    //    }
    //}
}
Plugin.TestResult/DataTable.xaml.cs
@@ -92,7 +92,7 @@
            set { RaiseAndSetIfchanged(ref tcpServerInfo, value); }
        }
        public int index { get; private set; }
        private readonly int cellCount;
        public readonly int cellCount;
        private readonly string chartTitle;
        public readonly TestResultView parent;
Plugin.TestResult/SingleCell.xaml.cs
@@ -15,6 +15,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Dynamic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Windows;
@@ -616,7 +617,7 @@
            }
        }
        private void NormalCSV(string filePath)
        public void NormalCSV(string filePath)
        {
            try
            {
@@ -644,7 +645,7 @@
            }
        }
        private void ReverseCSV(string filePath)
        public void ReverseCSV_Bak(string filePath)
        {
            try
            {
@@ -720,6 +721,150 @@
                        datas.Add(new string[titleRow.Count]);
                    }
                    var arr = datas[rowPoint];
                    arr[col] = info.value;
                    if (!string.IsNullOrEmpty(info.limitDown))
                    {
                        string key2 = $"{info.step}下限";
                        int col2 = titleRow.IndexOf(key2);
                        arr[col2] = info.limitDown;
                    }
                    if (!string.IsNullOrEmpty(info.limitUp))
                    {
                        string key2 = $"{info.step}上限";
                        int col2 = titleRow.IndexOf(key2);
                        arr[col2] = info.limitUp;
                    }
                    if (!string.IsNullOrEmpty(info.limitUp))
                    {
                        string key2 = $"{info.step}测试结果";
                        int col2 = titleRow.IndexOf(key2);
                        arr[col2] = info.result;
                    }
                    if (!string.IsNullOrEmpty(info.updateTime))
                    {
                        string key2 = "测试时间";// $"{info.step}测试时间";
                        int col2 = titleRow.IndexOf(key2);
                        arr[col2] = info.updateTime;
                    }
                }
                FileInfo fi = new FileInfo(filePath);
                if (!fi.Directory.Exists)
                {
                    fi.Directory.Create();  //文件不存在,创建文件
                }
                using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write))
                using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8))
                {
                    string title = string.Join(",", titleRow);
                    sw.WriteLine(title);
                    foreach (var info in datas)
                    {
                        string row = string.Join(",", info);
                        sw.WriteLine(row);
                    }
                }
            }
            catch (Exception ex)
            {
                ViewControl.Logger.Error($"Cell[{title}] SaveInfoToCSV Error.", ex);
            }
        }
        public void ReverseCSV(string filePath)
        {
            try
            {
                if (allInfos == null || allInfos.Count < 4) return;
                Dictionary<string, int> columnMap = new Dictionary<string, int>();
                int colPoint = 0;
                List<string> titleRow = new List<string>();
                List<string[]> datas = new List<string[]>();
                List<string> timeRow = new List<string>();
                void AddTitle(string title)
                {
                    if (titleRow.IndexOf(title) < 0)
                    {
                        titleRow.Add(title);
                    }
                }
                // 先设置表头
                for (int i = 0; i < allInfos.Count; i++)
                {
                    var info = allInfos[i];
                    if (IgnoreTestItem.Contains(info.step.ToLower()))
                    {
                        continue;
                    }
                    string testTime = info.updateTime;
                    int rowIndex = timeRow.IndexOf(testTime);
                    if (rowIndex < 0)
                    {
                        timeRow.Add(testTime);
                    }
                    string title = $"{info.step}{(string.IsNullOrEmpty(info.unit) ? "" : $"({info.unit})")}";
                    AddTitle("测试时间");
                    AddTitle(title);
                    if (!string.IsNullOrEmpty(info.limitDown))
                    {
                        string key2 = $"{info.step}下限";
                        AddTitle(key2);
                    }
                    if (!string.IsNullOrEmpty(info.limitUp))
                    {
                        string key2 = $"{info.step}上限";
                        AddTitle(key2);
                    }
                    if (!string.IsNullOrEmpty(info.limitUp))
                    {
                        string key2 = $"{info.step}测试结果";
                        AddTitle(key2);
                    }
                    //if (!string.IsNullOrEmpty(info.updateTime))
                    //{
                    //    string key2 = $"{info.step}测试时间";
                    //    AddTitle(key2);
                    //}
                }
                for (int i = 0; i < allInfos.Count; i++)
                {
                    var info = allInfos[i];
                    if (IgnoreTestItem.Contains(info.step.ToLower()))
                    {
                        continue;
                    }
                    string testTime = info.updateTime;
                    int row = timeRow.IndexOf(testTime);
                    if (row < 0)
                    {
                        continue;
                    }
                    string title = $"{info.step}{(string.IsNullOrEmpty(info.unit) ? "" : $"({info.unit})")}";
                    int col = titleRow.IndexOf(title);
                    if (datas.Count <= row)
                    {
                        datas.Add(new string[titleRow.Count]);
                    }
                    var arr = datas[row];
                    arr[col] = info.value;
@@ -910,6 +1055,7 @@
                return;
            }
            string modelPath = table.parent.testModelFile;
            int dutNo = table.index * table.cellCount + this.index;
            var win = new ManualDebugWindow(manualDebugSeq, modelPath)
            {
                Title = $"{this.title}手动调试",
@@ -917,7 +1063,7 @@
                OvenIndex = this.table.index,
                OvenName = this.table.title,
                CellIndex = this.index,
                CellIndex = dutNo,
                CellName = this.title
            };
            win.ShowDialog();
@@ -934,7 +1080,7 @@
            };
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.SaveInfoToCSV(sfd.FileName);
                this.NormalCSV(sfd.FileName);
            }
        }
Plugin.TestResult/TestResultView.xaml.cs
@@ -543,6 +543,17 @@
                    tables[ovenIndex].GetSingleCell(cellIndex).SaveInfoToCSV(filePath);
                    return;
                }
                if (MethodCode == 180)
                {
                    /// 保存穴位测试数据到CSV
                    strData = e.uiMsg.StringData;
                    string[] datas = strData.Split(';');
                    int ovenIndex = int.Parse(datas[0]);
                    int cellIndex = int.Parse(datas[1]);
                    string filePath = datas[2];
                    tables[ovenIndex].GetSingleCell(cellIndex).NormalCSV(filePath);
                    return;
                }
                if (MethodCode == 19)
                {
Plugin.TsExecution/ScreenTouch.xaml.cs
@@ -130,10 +130,12 @@
        public void DrawPoints(int[][] points)
        {
            var temp = new ObservableCollection<bool>(new bool[rows * columns]);
            foreach (int[] point in points)
            for (int i = 0; i < points.Length; i++)
            {
                int[] point = points[i];
                int index = point[1] * columns + point[0];
                //children[point[0]][point[1]].Background = Brushes.Green;
                temp[point[1] * columns + point[0]] = true;
                temp[index] = true;
            }
            Values = temp;
        }
Plugin.TsExecution/TsExecution.xaml.cs
@@ -1061,8 +1061,16 @@
        /// </summary>
        private void StartSequence()
        {
            log.Info($"Start ATE Seq isLoadOK:{isLoadOK}");
            if (!isLoadOK) return;
            engine?.Globals.SetValBoolean("StationState.StopTest", 0, false);
            try
            {
                engine?.Globals.SetValBoolean("StationState.StopTest", 1, false);
            }
            catch (Exception ex)
            {
                log.Error("Reset StopTest Failed.", ex);
            }
            if (ParamSetting.EnableAutoModel)
            {
                try
@@ -1135,14 +1143,15 @@
        {
            try
            {
                if (this.tsSockets.Count > 0)
                {
                    for (int i = 0; i < tsSockets.Count; i++)
                    {
                        var context = this.tsSockets[i].SequenceFileContext;
                        context?.StationGlobals.SetValBoolean("StationState.StopTest", 1, true);
                    }
                }
                //if (this.tsSockets.Count > 0)
                //{
                //    for (int i = 0; i < tsSockets.Count; i++)
                //    {
                //        var context = this.tsSockets[i].SequenceFileContext;
                //        context?.StationGlobals.SetValBoolean("StationState.StopTest", 1, true);
                //    }
                //}
                engine.Globals.SetValBoolean("StationState.StopTest", 1, true);
                if (this.execution == null) return true;
                //bool res = this.execution.WaitForEndEx(-1, true, null, null);
Util.ManualDebug/ManualDebug.xaml.cs
@@ -203,6 +203,19 @@
                if (e.EventCode == 10000)
                {
                    executionWrapper?.SetContext(e.Data);
                    string key = $"Running.OvenName";
                    executionWrapper?.SetFileGlobalValue(key, 1, OvenName);
                    key = $"Running.CellName";
                    executionWrapper?.SetFileGlobalValue(key, 1, CellName);
                    key = $"Running.OvenIndex";
                    executionWrapper?.SetFileGlobalValue(key, 1, OvenIndex);
                    key = $"Running.CellIndex";
                    executionWrapper?.SetFileGlobalValue(key, 1, CellIndex);
                    return;
                }
                if (e.EventCode == 10001)
@@ -254,19 +267,7 @@
        {
            try
            {
                string key = $"Running.OvenName";
                executionWrapper?.SetFileGlobalValue(key, 1, OvenName);
                key = $"Running.CellName";
                executionWrapper?.SetFileGlobalValue(key, 1, CellName);
                key = $"Running.OvenIndex";
                executionWrapper?.SetFileGlobalValue(key, 1, OvenIndex);
                key = $"Running.CellIndex";
                executionWrapper?.SetFileGlobalValue(key, 1, CellIndex);
                key = $"Running.ActionName";
                string key = $"Running.ActionName";
                executionWrapper?.SetFileGlobalValue(key, 1, name);
            }
            catch (Exception ex)
WPFProject/Controls/MainTabControl.xaml.cs
@@ -193,13 +193,14 @@
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            var ss = ((WindowX)Window.GetWindow(this));
            Binding binding = new Binding("IsMaskVisible")
            {
                Source = ((WindowX)Window.GetWindow(this)),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };
            winFormHolder.SetBinding(WinFormHolder.MaskVisiableProperty, binding);
            /// binding WinformHost 遮罩
            //Binding binding = new Binding("IsMaskVisible")
            //{
            //    Source = ((WindowX)Window.GetWindow(this)),
            //    Mode = BindingMode.TwoWay,
            //    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            //};
            //winFormHolder.SetBinding(WinFormHolder.MaskVisiableProperty, binding);
            if (MenuItems != null && MenuItems.Count > 0)
            {
                SelectedMenu = MenuItems[0];
WPFProject/PanuonWindow.xaml
@@ -23,7 +23,6 @@
            Title="TestPlatform"
            pu:WindowXCaption.Background="Transparent"
            pu:WindowXCaption.Height="60"
            IsOverlayerVisible="True"
            pu:WindowXCaption.Foreground="#FFF">
    <Window.Resources>
        <hc:LangConverter x:Key="lc"/>
WPFProject/PanuonWindow.xaml.cs
@@ -116,12 +116,15 @@
                Application.Current.MainWindow = this;
                SystemSetting.SystemSettingChanged += SystemSetting_SystemSettingChanged;
                if (Environment.Is64BitProcess)
                {
                Task.Run(() =>
                {
                    ResourceListener.Instance.RefreshEvent += this.resourceUI.Refresh;
                    ResourceListener.Instance.Start();
                });
            }
            }
            catch (Exception ex)
            {
                log.Error("Window Loaded Error.", ex);
WPFProject/Properties/AssemblyInfo.cs
@@ -53,6 +53,6 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.2")]
[assembly: AssemblyFileVersion("1.0.0.2")]
[assembly: XmlConfigurator(ConfigFile = "Config/log4net.config", Watch = true)]
WPFProject/ResourceListener.cs
@@ -98,10 +98,10 @@
                        totalRemRate = usagePercent
                    });
                    log.Info(info);
                    if (usagePercent > 80)
                    {
                    //if (usagePercent > 80)
                    //{
                        // AlarmUtil.CreateAlarm("App", "内存占用过高,超80%", out _);
                    }
                    //}
                }
            }
            catch (Exception ex)
WPFProject/WPFProject.sln
@@ -573,8 +573,8 @@
        {D0944E62-EE52-4ABE-832A-A09D98814DB1}.Release|Any CPU.Build.0 = Release|Any CPU
        {D0944E62-EE52-4ABE-832A-A09D98814DB1}.Release|x64.ActiveCfg = Release|Any CPU
        {D0944E62-EE52-4ABE-832A-A09D98814DB1}.Release|x64.Build.0 = Release|Any CPU
        {D0944E62-EE52-4ABE-832A-A09D98814DB1}.Release|x86.ActiveCfg = Release|Any CPU
        {D0944E62-EE52-4ABE-832A-A09D98814DB1}.Release|x86.Build.0 = Release|Any CPU
        {D0944E62-EE52-4ABE-832A-A09D98814DB1}.Release|x86.ActiveCfg = Release|x86
        {D0944E62-EE52-4ABE-832A-A09D98814DB1}.Release|x86.Build.0 = Release|x86
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE