浏览代码

修改PLC变量添加及手动测试

user_lt 1 年之前
父节点
当前提交
00713efc87

+ 1 - 4
BlankApp1/BizService/BizTestRecordDtlService.cs

@@ -14,9 +14,6 @@ namespace BizService
             return base.GetFirst(x => x.scheme_dtl_id == schDtlID);
         }
 
-        public Task<bool> SavePredicitionFinal(biz_test_record_dtl testRecord)
-        {
-            return base.UpdateAsync(testRecord);
-        }
+       
     }
 }

+ 1 - 1
BlankApp1/BizService/IBizTestRecordDtlService.cs

@@ -16,6 +16,6 @@ namespace BizService
         public biz_test_record_dtl FindRecordDetailBySchDtlID(long schDtlID);
 
 
-        public Task<bool> SavePredicitionFinal(biz_test_record_dtl testRecord);
+        
     }
 }

+ 4 - 1
BlankApp1/BlankApp1/App.xaml.cs

@@ -61,7 +61,10 @@ namespace BlankApp1
             containerRegistry.RegisterForNavigation<PLCPointView, PLCPointViewModel>();
             containerRegistry.RegisterForNavigation<PLCReadView, PLCReadViewModel>();
             containerRegistry.RegisterForNavigation<PLCWriteView, PLCWriteViewModel>();
-           
+            containerRegistry.RegisterForNavigation<PLCConfigView, PLCConfigViewModel>();
+            
+
+
             containerRegistry.RegisterDialog<AddOrEditSchView, AddOrEditSchViewModel>();
             containerRegistry.RegisterDialog<AddDetailView, AddDetailViewModel>();
             containerRegistry.RegisterDialog<AutoTestView, AutoTestViewModel>();

+ 1 - 0
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/AddDetailViewModel.cs

@@ -48,6 +48,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             {
                 id = findResult.Id;
                 PLCItem = findResult.PlcItem;
+                SelectPLCType = findResult.PlcAddType;
                 PLCValue = findResult.PlcValue;
                 PLCDescribe = findResult.Remark;
             }

+ 1 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/BaseConfigViewModel.cs

@@ -33,7 +33,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         private readonly IMenuService _menuService;
 
         private List<BasicPlcTestSchemeDto> allConfigList = new List<BasicPlcTestSchemeDto>();//所有方案
-        private List<BasicPlcTestSchemeDto> conditionConfig = new List<BasicPlcTestSchemeDto>();//所有方案
+        private List<BasicPlcTestSchemeDto> conditionConfig = new List<BasicPlcTestSchemeDto>();//符合条件的方案
 
         private const int PageCount = 1; //每一页显示个数
         public BaseConfigViewModel(IDialogService dialog, IMenuService menuService, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService ,IMapper mapper, ILogger logger)

+ 195 - 0
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/PLCConfigViewModel.cs

@@ -0,0 +1,195 @@
+using AutoMapper;
+using BizService;
+using Model.Dto;
+using Model.Entities;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics.Metrics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
+
+namespace PLCTool.ViewModels.BasicConfigViewModel
+{
+    public class PLCConfigViewModel : BindableBase
+    { 
+        private readonly IBasicPlcItemConfigService _iBasPlcItemConfigService;
+        private readonly IMapper _mapper;
+        private readonly IDialogService _dialog;
+        private List<BasPlcItemConfigDto> allPLCConfigList = new List<BasPlcItemConfigDto>();//所有方案
+        private List<BasPlcItemConfigDto> conditionConfig = new List<BasPlcItemConfigDto>();//符合条件的方案
+        public PLCConfigViewModel(IBasicPlcItemConfigService iBasPlcItemConfigService, IMapper mapper,IDialogService dialog)
+        {
+            _iBasPlcItemConfigService = iBasPlcItemConfigService;
+            _mapper = mapper;
+            _dialog = dialog;
+            QueryCommand = new DelegateCommand<object>(Query);
+            AddCommand= new DelegateCommand<object>(Add);
+            GetPLCConfig();
+        }
+
+       
+
+
+        #region 私有方法
+        /// <summary>
+        /// 查询
+        /// </summary>
+        /// <param name="obj"></param>
+        private void Query(object obj)
+        {
+            conditionConfig = (from a in allPLCConfigList
+                               where  (string.IsNullOrEmpty(PLCItem) ? true : (a.PlcItem == PLCItem))
+                               && (string.IsNullOrEmpty(PLCAddr) ? true : (a.PlcAddress == PLCAddr))
+                               select a).ToList();
+            //默认显示的第一页
+            Getpage();
+        }
+        /// <summary>
+        /// 添加PLC变量
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <exception cref="NotImplementedException"></exception>
+        private void Add(object obj)
+        {
+            DialogParameters parm = new DialogParameters();
+            parm.Add("Key", "");
+            //弹出详情对话框
+            _dialog.ShowDialog("AddDetailView", parm, async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    BasPlcItemConfigDto returnValue = callback.Parameters.GetValue<BasPlcItemConfigDto>("ReturnValue");
+                    if (returnValue != null)
+                    {
+                        var plcCon = _mapper.Map<BasPlcItemConfigDto,bas_plc_item_config >(returnValue);
+                        var findPlc=allPLCConfigList.FirstOrDefault(x=>(x.PlcAddress==returnValue.PlcAddress)||(x.PlcItem==returnValue.PlcAddress));
+                        if(findPlc != null)
+                        {
+                            MessageBox.Show("已有次PLC变量地址或名称,请更改名称!", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
+                            return;
+                        }
+                        bool isSucc=_iBasPlcItemConfigService.Add(plcCon);
+                        if(isSucc)
+                        {
+                            //重新读取PLC
+                            GetPLCConfig();
+                            MessageBox.Show("添加PLC变量成功", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
+                        }
+                    }
+                }
+
+            });
+        }
+        /// <summary>
+        /// 获取PLC配置
+        /// </summary>
+        private void GetPLCConfig()
+        {
+            allPLCConfigList.Clear();
+            conditionConfig.Clear();
+            var plclist = _iBasPlcItemConfigService.QueryList();
+            var allPlc = _mapper.Map<List<bas_plc_item_config>, List<BasPlcItemConfigDto>>(plclist);
+            foreach (var plc in allPlc)
+            {
+                    allPLCConfigList.Add(plc);
+                    conditionConfig.Add(plc);
+            }
+            Getpage();
+        }
+        /// <summary>
+        /// 获取页面
+        /// </summary>
+        private void Getpage()
+        {
+            CurrentPage = 1;
+            TotalCount = conditionConfig.Count;
+            CurrentPageChanged();
+
+
+        }
+        /// <summary>
+        /// 页面变化
+        /// </summary>
+        private void CurrentPageChanged()
+        {
+
+            PLCItemList.Clear();
+
+            foreach (var i in conditionConfig.Skip((CurrentPage - 1) * CountPerPage).Take(CountPerPage))
+            {
+                PLCItemList.Add(i);
+            }
+        }
+
+        #endregion
+        #region 命令绑定
+
+        public DelegateCommand<object> QueryCommand { set; get; }
+        public DelegateCommand<object> AddCommand { set; get; }
+        #endregion
+
+        #region 数据绑定
+        private ObservableCollection<BasPlcItemConfigDto> plcItemList = new ObservableCollection<BasPlcItemConfigDto>();
+        public ObservableCollection<BasPlcItemConfigDto> PLCItemList
+        {
+            get { return plcItemList; }
+            set { plcItemList = value; RaisePropertyChanged(); }
+        }
+
+        /// <summary>
+        /// plc地址
+        /// </summary>
+        private string plcAddr;
+        public string PLCAddr
+        {
+            get { return plcAddr; }
+            set { plcAddr = value; RaisePropertyChanged(); }
+        }
+
+        /// <summary>
+        /// plc变量名
+        /// </summary>
+        private string plcItem;
+        public string PLCItem
+        {
+            get { return plcItem; }
+            set { plcItem = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 总条数
+        /// </summary>
+        private int totalCount;
+        public int TotalCount
+        {
+            get { return totalCount; }
+            set { totalCount = value; RaisePropertyChanged(); CurrentPageChanged(); }
+        }
+        /// <summary>
+        /// 每页数量
+        /// </summary>
+        private int countPerPage = 1;
+        public int CountPerPage
+        {
+            get { return countPerPage; }
+            set { countPerPage = value; RaisePropertyChanged(); CurrentPageChanged(); }
+        }
+        /// <summary>
+        /// 单前页
+        /// </summary>
+        private int currentPage = 1;
+        public int CurrentPage
+        {
+            get { return currentPage; }
+            set { currentPage = value; RaisePropertyChanged(); CurrentPageChanged(); }
+        }
+
+        #endregion
+    }
+}

+ 27 - 15
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/ManualTestViewModel.cs

@@ -238,26 +238,36 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 recordId = findRecordID.record_id;
             }
             testStatus = 99;//测试状态赋值为99
+                            //状态status 没有赋值
+
+            bizTestRecordDtlDto.RecordId = recordId;
+            bizTestRecordDtlDto.SchemeDtlId = schDetailId;
+            bizTestRecordDtlDto.StartTestTime = startTime;
+            bizTestRecordDtlDto.FinishTestTime = endTime;
+            bizTestRecordDtlDto.TestMode = TestMode;
+            bizTestRecordDtlDto.Status = testStatus;
+            bizTestRecordDtlDto.TestResult = testResult;
+            bizTestRecordDtlDto.CreateBy = Appsession.UserName;
+            bizTestRecordDtlDto.CreateTime = DateTime.Now;
+            bizTestRecordDtlDto.UpdateBy = Appsession.UserName;
+            bizTestRecordDtlDto.UpdateTime = DateTime.Now;
             //记录记录明细表中是否有这个方案明细ID的记录,没有则添加,有则更新记录状态
             var findRecordDetail = _iBizTestRecordDtlService.FindRecordDetailBySchDtlID(schDetailId);
             if (findRecordDetail == null)
             {
-                //状态status 没有赋值
-
-                bizTestRecordDtlDto.RecordId = recordId;
-                bizTestRecordDtlDto.SchemeDtlId = schDetailId;
-                bizTestRecordDtlDto.StartTestTime = startTime;
-                bizTestRecordDtlDto.FinishTestTime = endTime;
-                bizTestRecordDtlDto.TestMode = TestMode;
-                bizTestRecordDtlDto.Status = testStatus;
-                bizTestRecordDtlDto.TestResult = testResult;
-                bizTestRecordDtlDto.CreateBy = Appsession.UserName;
-                bizTestRecordDtlDto.CreateTime = DateTime.Now;
-                bizTestRecordDtlDto.UpdateBy = Appsession.UserName;
-                bizTestRecordDtlDto.UpdateTime = DateTime.Now;
+               
                 var testRecordDtl = _mapper.Map<BizTestRecordDtlDto, biz_test_record_dtl>(bizTestRecordDtlDto);
                 _iBizTestRecordDtlService.Add(testRecordDtl);
             }
+            else
+            {
+                bizTestRecordDtlDto.RecordDtlId = findRecordDetail.record_dtl_id;
+                //更新时间
+                bizTestRecordDtlDto.UpdateBy = Appsession.UserName;
+                bizTestRecordDtlDto.UpdateTime = DateTime.Now;
+                UpdateTesDtltRecord();
+            }
+            
            
         }
 
@@ -279,6 +289,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
 
         private void Next(object obj)
         {
+            StepIndex = 0;
             ///查找方案下的所有方案明细,并排序,
             var basicSchDtls = _basicPlcTestSchemeDtlService.FindAllBySchId(schId)?.OrderBy(x=>x.scheme_dtl_id);
             foreach(var item in basicSchDtls)
@@ -467,6 +478,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                                                 {
                                                     ///单个测试项合格
                                                     item.TestResult = "合格";
+                                                    countCond++;
                                                 }
                                                 else
                                                 {
@@ -570,8 +582,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
 
                             }
                             //测试记录存入数据库
-                            //前置项测试结果json转化
-                            string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
+                            //输出项测试结果json转化
+                            string prefixJsonStr = ModelToJsonToStr(SelectOutJudge, OutSelectLogic, OutDetail, OutConList);
                             //json字符串
                             bizTestRecordDtlDto.JudgementResultFinal = prefixJsonStr;
                             //条件满足

+ 10 - 1
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/TestOperViewModel.cs

@@ -49,14 +49,22 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             //手动  自动测试
             AutoTestCommand = new DelegateCommand<object>(AutoDest);
             ManualTestCommand = new DelegateCommand<object>(ManualTest);
+            OnLoadCommand = new DelegateCommand(OnLoad);
             GetConfigOption();
-            GetContent();
+            
         }
 
 
 
 
+
+
         #region 私有方法
+
+        private void OnLoad()
+        {
+            GetContent();
+        }
         private void ManualTest(object obj)
         {
              //测试方案明细主键ID
@@ -330,6 +338,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         public DelegateCommand<object> AutoTestCommand { set; get; }
 
         public DelegateCommand<object> ManualTestCommand { set; get; }
+        public DelegateCommand OnLoadCommand { set; get; }
         #endregion
         #region 数据绑定
         /// <summary>

+ 1 - 17
BlankApp1/BlankApp1/ViewModels/MonitorManageViewModel/PLCReadViewModel.cs

@@ -41,23 +41,6 @@ namespace PLCTool.ViewModels.MonitorManageViewModel
             }
         }
 
-        private  void ReadPLCValue()
-        {
-            Task.Run(async() =>
-            {
-                while (true)
-                {
-                    //更新界面上的值
-                    Application.Current.Dispatcher.Invoke(() =>
-                    {
-                       
-                    });
-                    await Task.Delay(5000);
-                }
-              
-            });
-            
-        }
         #endregion
         #region 命令绑定
         private ObservableCollection<BasPlcItemConfigDto> plcItemList=new ObservableCollection<BasPlcItemConfigDto>();
@@ -67,5 +50,6 @@ namespace PLCTool.ViewModels.MonitorManageViewModel
             set { plcItemList = value; RaisePropertyChanged(); }
         }
         #endregion
+  
     }
 }

+ 69 - 0
BlankApp1/BlankApp1/Views/BasicConfigView/PLCConfigView.xaml

@@ -0,0 +1,69 @@
+<UserControl x:Class="PLCTool.Views.BasicConfigView.PLCConfigView"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:PLCTool.Views.BasicConfigView"
+                    xmlns:myContr="clr-namespace:BlankApp1.Controls"
+         xmlns:hc="https://handyorg.github.io/handycontrol"
+         xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+         xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
+         mc:Ignorable="d" 
+         d:DesignHeight="450" d:DesignWidth="800">
+    <Grid >
+        <b:Interaction.Triggers>
+            <b:EventTrigger EventName="Loaded">
+                <b:InvokeCommandAction Command="{Binding OnLoadCommand}"/>
+            </b:EventTrigger>
+        </b:Interaction.Triggers>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"/>
+          
+            <RowDefinition/>
+            <RowDefinition Height="40"/>
+
+        </Grid.RowDefinitions>
+        <UniformGrid Grid.Row="0" Columns="3">
+            <StackPanel Orientation="Horizontal">
+                <TextBlock Text="PLC地址:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
+                <TextBox  Height="28" Width="120" Text="{Binding PLCAddr}" />
+            </StackPanel>
+            <StackPanel Orientation="Horizontal">
+                <TextBlock Text="PLC变量名:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
+                <TextBox  Height="28" Width="120" Text="{Binding PLCItem}"/>
+            </StackPanel>
+            
+            <StackPanel Orientation="Horizontal">
+                <Button Content="查询" Width="80"  Margin="5,0"  Command="{Binding QueryCommand}" Style="{StaticResource NormalButtonStyle}" />
+                <Button Content="新增PLC变量" Width="80"  Margin="5,0"  Command="{Binding AddCommand}" Style="{StaticResource NormalButtonStyle}" />
+                <Button Content="导出Excel" Width="80"  Margin="5,0"  Command="{Binding ExportCommand}" Style="{StaticResource NormalButtonStyle}" />
+               
+            </StackPanel>
+
+
+        </UniformGrid>
+
+        <DataGrid Grid.Row="1"   ColumnWidth="*" AutoGenerateColumns="False" HeadersVisibility="All" CanUserAddRows="False"  SelectionUnit="FullRow" SelectionMode="Single"   RowHeaderWidth="0"
+ ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
+ItemsSource="{Binding PLCItemList}" IsReadOnly="True"  Padding="0">
+            <DataGrid.Columns >
+                <DataGridTextColumn Header="序号" Binding="{Binding Id}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                <DataGridTextColumn Header="PLC变量编码" Binding="{Binding PlcItem}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="PLC地址" Binding="{Binding PlcAddress}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="描述" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="数据类型" Binding="{Binding PlcAddType}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="当前值" Binding="{Binding RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+            </DataGrid.Columns>
+
+        </DataGrid>
+        <Grid Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center">
+            <wpfdev:Pagination IsLite="False"    Margin="0"  Width="auto" Height="30" HorizontalAlignment="Center"  
+                 Count="{Binding TotalCount,Mode=TwoWay}" 
+                 CountPerPage="{Binding CountPerPage,Mode=TwoWay}"
+                 Current="{Binding CurrentPage,Mode=TwoWay}"/>
+
+        </Grid>
+
+
+    </Grid>
+</UserControl>

+ 28 - 0
BlankApp1/BlankApp1/Views/BasicConfigView/PLCConfigView.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+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;
+
+namespace PLCTool.Views.BasicConfigView
+{
+    /// <summary>
+    /// PLCConfigView.xaml 的交互逻辑
+    /// </summary>
+    public partial class PLCConfigView : UserControl
+    {
+        public PLCConfigView()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 3 - 25
BlankApp1/BlankApp1/Views/BusinessManageView/AutoTestView.xaml

@@ -108,32 +108,10 @@
                         <DataGridTextColumn Header="PLC地址" Binding="{Binding PlcAddress}" CellStyle="{StaticResource MyDataGridCellStyle}" />
                         <DataGridTextColumn Header="PLC变量名" Binding="{Binding PlcItem}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                         <DataGridTextColumn Header="判定值" Binding="{Binding PlcValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                        <DataGridTextColumn Header="结果" Binding="{Binding RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                         <DataGridTextColumn Header="描述" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                        <DataGridTemplateColumn Header="操作" Width="160"  CellStyle="{StaticResource MyDataGridCellStyle}">
-                            <DataGridTemplateColumn.CellTemplate>
-                                <DataTemplate>
-                                    <UniformGrid Columns="2">
-                                        <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-                Command="{Binding DataContext.EditBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Cursor="Hand" Margin="0,0,10,0" >
-
-                                            <StackPanel Orientation="Horizontal">
-                                                <TextBlock  Text="编辑" VerticalAlignment="Center" Foreground="Blue"/>
-                                            </StackPanel>
-                                        </Button>
-                                        <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-                Command="{Binding DataContext.DeleteBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}"   Cursor="Hand" >
-
-                                            <StackPanel Orientation="Horizontal">
-                                                <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
-                                            </StackPanel>
-                                        </Button>
-
-                                    </UniformGrid>
-                                </DataTemplate>
-                            </DataGridTemplateColumn.CellTemplate>
-                        </DataGridTemplateColumn>
-
+                        <DataGridTextColumn Header="测试时间" Binding="{Binding TestTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTextColumn Header="实际值" Binding="{Binding RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTextColumn Header="结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                     </DataGrid.Columns>
 
                 </DataGrid>

+ 12 - 28
BlankApp1/BlankApp1/Views/BusinessManageView/ManualTestView.xaml

@@ -108,9 +108,11 @@
                         <DataGridTextColumn Header="PLC地址" Binding="{Binding PlcAddress}" CellStyle="{StaticResource MyDataGridCellStyle}" />
                         <DataGridTextColumn Header="PLC变量名" Binding="{Binding PlcItem}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                         <DataGridTextColumn Header="判定值" Binding="{Binding PlcValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                        <DataGridTextColumn Header="结果" Binding="{Binding RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                         <DataGridTextColumn Header="描述" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                        
+                        <DataGridTextColumn Header="测试时间" Binding="{Binding TestTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTextColumn Header="实际值" Binding="{Binding RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTextColumn Header="结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+
                     </DataGrid.Columns>
 
                 </DataGrid>
@@ -175,9 +177,11 @@
                         <DataGridTextColumn Header="PLC地址" Binding="{Binding PlcAddress}" CellStyle="{StaticResource MyDataGridCellStyle}" />
                         <DataGridTextColumn Header="PLC变量名" Binding="{Binding PlcItem}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                         <DataGridTextColumn Header="判定值" Binding="{Binding PlcValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                        <DataGridTextColumn Header="结果" Binding="{Binding RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                         <DataGridTextColumn Header="描述" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                    
+                        <DataGridTextColumn Header="测试时间" Binding="{Binding TestTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTextColumn Header="实际值" Binding="{Binding RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTextColumn Header="结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+
                     </DataGrid.Columns>
 
                 </DataGrid>
@@ -238,35 +242,15 @@
        ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
          ItemsSource="{Binding OutConList}"  IsReadOnly="True" Padding="0">
                     <DataGrid.Columns >
+
                         <DataGridTextColumn Header="序号" Width="40" Binding="{Binding Id}" CellStyle="{StaticResource MyDataGridCellStyle}" />
                         <DataGridTextColumn Header="PLC地址" Binding="{Binding PlcAddress}" CellStyle="{StaticResource MyDataGridCellStyle}" />
                         <DataGridTextColumn Header="PLC变量名" Binding="{Binding PlcItem}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                         <DataGridTextColumn Header="判定值" Binding="{Binding PlcValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                        <DataGridTextColumn Header="结果" Binding="{Binding RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                         <DataGridTextColumn Header="描述" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                        <DataGridTemplateColumn Header="操作" Width="160"  CellStyle="{StaticResource MyDataGridCellStyle}">
-                            <DataGridTemplateColumn.CellTemplate>
-                                <DataTemplate>
-                                    <UniformGrid Columns="2">
-                                        <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-     Command="{Binding DataContext.EditOutCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Cursor="Hand" Margin="0,0,10,0" >
-
-                                            <StackPanel Orientation="Horizontal">
-                                                <TextBlock  Text="编辑" VerticalAlignment="Center" Foreground="Blue"/>
-                                            </StackPanel>
-                                        </Button>
-                                        <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-     Command="{Binding DataContext.DeleteOutCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}"   Cursor="Hand" >
-
-                                            <StackPanel Orientation="Horizontal">
-                                                <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
-                                            </StackPanel>
-                                        </Button>
-
-                                    </UniformGrid>
-                                </DataTemplate>
-                            </DataGridTemplateColumn.CellTemplate>
-                        </DataGridTemplateColumn>
+                        <DataGridTextColumn Header="测试时间" Binding="{Binding TestTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTextColumn Header="实际值" Binding="{Binding RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTextColumn Header="结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
 
                     </DataGrid.Columns>
 

+ 6 - 0
BlankApp1/BlankApp1/Views/BusinessManageView/TestOperView.xaml

@@ -7,9 +7,15 @@
              xmlns:hc="https://handyorg.github.io/handycontrol"
              xmlns:myContr="clr-namespace:BlankApp1.Controls"
              xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
     <Grid >
+        <b:Interaction.Triggers>
+            <b:EventTrigger EventName="Loaded">
+                <b:InvokeCommandAction Command="{Binding OnLoadCommand}"/>
+            </b:EventTrigger>
+        </b:Interaction.Triggers>
         <Grid.RowDefinitions>
             <RowDefinition Height="40"/>
             <RowDefinition Height="40"/>