using CCDCount.DLL; using CCDCount.DLL.AlarmTools; using CCDCount.DLL.SqlDataClass; using CCDCount.DLL.Tools; using CCDCount.MODEL.AuditTrailModel; using CCDCount.MODEL.ConfigModel; using CCDCountWpf.Language; using LogClass; using MvCameraControl; using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; using System.Threading; 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.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; using static System.Net.Mime.MediaTypeNames; namespace CCDCountWpf.WpfPage { /// /// MainPage.xaml 的交互逻辑 /// public partial class MainPage : Page { #region 变量与实例 #endregion public MainPage() { InitializeComponent(); DataContext = ShowMessageBus.ShowBinding; InitFormationItems(); } private void DataClear_Click(object sender, RoutedEventArgs e) { if(MessageBus.NowSettingLoadMainThread == null) return; MessageBus.NowSettingLoadMainThread.ClearHistoryActive(); MessageBus.NowSettingLoadMainThread.ClearSendQueue(); PlcSettingMessageBus.pLCManagement.ClearBottSpeed(); } private void Page_Loaded(object sender, RoutedEventArgs e) { this.Width = double.NaN; // 等效于 Auto this.Height = double.NaN; LOG.log("生产界面初始化语言切换事件", 6); LanguageManager.LanguageChangeEvent += ChangeLanguage; LOG.log("生产界面运行一次语言切换", 6); ChangeLanguage(null, EventArgs.Empty); StopIdentifyBtn.IsEnabled = false; StopIdentifyBtn.Opacity = 0.5; LOG.log("运行状态初始化", 6); if(MessageBus.NowSettingLoadMainThread != null) { if (MessageBus.NowSettingLoadMainThread.CameraRunStatic) { StartIdentifyBtn.IsEnabled = false; StartIdentifyBtn.Opacity = 0.5; StopIdentifyBtn.IsEnabled = true; StopIdentifyBtn.Opacity = 1; } else { StartIdentifyBtn.IsEnabled = true; StartIdentifyBtn.Opacity = 1; StopIdentifyBtn.IsEnabled = false; StopIdentifyBtn.Opacity = 0.5; } } } /// /// 启动相机识别 /// private bool RunCameraIdentify() { if(MessageBus.NowSettingLoadMainThread != null) { MessageBus.NowSettingLoadMainThread.BatchNumber = ShowMessageBus.ShowBinding.BatchNumber; if (MessageBus.NowSettingLoadMainThread.CameraConfigIsChange) { MessageBus.NowSettingLoadMainThread.ReLoadCameraConfig(); } //启动单相机实例的全部线程 if (!MessageBus.NowSettingLoadMainThread.StartMianThread()) { FaultLog.RecordErrorMessage(MessageBus.NowSettingLoadMainThread.cameraConfig.DeviceName + "_" + MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum + "Failed to open", "CCDCountWpf:MainPage-RunCameraIdentify"); //LOG.error(MessageBus.MainThreadS[i].cameraConfig.DeviceName + "_" + MessageBus.MainThreadS[i].cameraConfig.CameraSNNum + "启动失败"); MessageBox.Show(MessageBus.NowSettingLoadMainThread.cameraConfig.DeviceName + "_" + MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum + "Failed to open"); return false; } } MessageBus.NowLoadCammeraSN = MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum; return true; } /// /// 停止相机识别 /// private void StopCameraIdentify() { if(MessageBus.NowSettingLoadMainThread != null) { //启动单相机实例的全部线程 if (!MessageBus.NowSettingLoadMainThread.StopMianThread()) { FaultLog.RecordErrorMessage(MessageBus.NowSettingLoadMainThread.cameraConfig.DeviceName + "_" + MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum + "Failed to close", "CCDCountWpf:MainPage-StopCameraIdentify"); MessageBox.Show(MessageBus.NowSettingLoadMainThread.cameraConfig.DeviceName + "_" + MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum + "Failed to close"); } } } private bool RunBatchIsRun =false; /// /// 运行批次记录 /// /// private void RunBatchRecord(string BatchNumber) { if (RunBatchIsRun) { return; } List batchRecordModels = new List(); Stopwatch stopwatch = new Stopwatch(); BatchMessSqliteDataClass batchMessSqliteData = new BatchMessSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\BatchData\\BatchData_{BatchNumber}.db"); RunBatchIsRun = true; Task.Run(() => { while (RunBatchIsRun) { try { stopwatch.Restart(); DateTime RecordTime = DateTime.Now; var OutTimeBatch = batchRecordModels.Where(x => x.RecordTime.AddMinutes(1) < RecordTime).ToList(); OutTimeBatch.ForEach(x => batchRecordModels.Remove(x)); if(!PlcSettingMessageBus.pLCManagement.ReadBottingVibrationTableHighSpeedValue(out ushort BottingVibrationTableHighSpeedValue, out ushort FilterVibrationTableHighSpeedValue, out ushort CountVibrationTableHighSpeedValue)) { continue ; } if(!PlcSettingMessageBus.pLCManagement.ReadBottingCount(out ushort BottingCount)) { continue ; } ushort CountSPeed = (ushort)(batchRecordModels.Count() > 0 ? (BottingCount - batchRecordModels.Min(o => o.BottingCount)) > 0 ? BottingCount - batchRecordModels.Min(o => o.BottingCount) : 0 : 0); ShowMessageBus.ShowBinding.BottingSpeed = CountSPeed; BatchRecordModel batchRecordModel = new BatchRecordModel { BatchNunber = BatchNumber, MaterialCylinderVibrationTableSpeed = BottingVibrationTableHighSpeedValue, FilterVibrationTableSpeed = FilterVibrationTableHighSpeedValue, CountVibrationTableSpeed = CountVibrationTableHighSpeedValue, BottingCount = BottingCount, BottingSpeed = CountSPeed, RecordTime = RecordTime }; batchMessSqliteData.InsertBatchMessage(batchRecordModel); batchRecordModels.Add(batchRecordModel); stopwatch.Stop(); int SleepTime = 998 - (int)stopwatch.ElapsedMilliseconds; if (SleepTime > 0) { Thread.Sleep(SleepTime); } } catch(Exception ex) { LOG.error("MianPage-RunBatchRecord:Error:" + ex.Message); } } }); } private void StopBatchRecord() { RunBatchIsRun = false; } private void StartIdentifyBtn_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrWhiteSpace(ShowMessageBus.ShowBinding.BatchNumber)) { MessageBox.Show("请输入批次号!"); return; } RunBatchRecord(ShowMessageBus.ShowBinding.BatchNumber); if (!RunCameraIdentify()) { return; } StartIdentifyBtn.IsEnabled = false; StartIdentifyBtn.Opacity = 0.5; StopIdentifyBtn.IsEnabled = true; StopIdentifyBtn.Opacity = 1; if (PlcSettingMessageBus.pLCManagement.IsConnect) { PlcSettingMessageBus.pLCManagement.MachineRunToTrue(); PlcSettingMessageBus.pLCManagement.WriteCameraRunState(1); } } private void StopIdentifyBtn_Click(object sender, RoutedEventArgs e) { StopCameraIdentify(); LOG.log("停止相机成功",6); StopBatchRecord(); StartIdentifyBtn.IsEnabled = true; StartIdentifyBtn.Opacity = 1; StopIdentifyBtn.IsEnabled = false; StopIdentifyBtn.Opacity = 0.5; if (PlcSettingMessageBus.pLCManagement.IsConnect) { PlcSettingMessageBus.pLCManagement.MachineStopToTrue(); PlcSettingMessageBus.pLCManagement.WriteCameraRunState(0); } } private void BottingMaterialCylinderVibrationTableHighSpeedValueUpUpBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed + 10) > PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed) { PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed += 10; } } } private void BottingMaterialCylinderVibrationTableHighSpeedValueUpBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed + 1) > PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed) { PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed += 1; } } } private void BottingMaterialCylinderVibrationTableHighSpeedValueDownBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed - 1) < PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed) { PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed -= 1; } } } private void BottingMaterialCylinderVibrationTableHighSpeedValueDownDownBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed - 10) < PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed) { PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed -= 10; } } } private void BottingFilterVibrationTableHighSpeedValueUpUpBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed + 10) > PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed) { PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed += 10; } } } private void BottingFilterVibrationTableHighSpeedValueUpBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed + 1) > PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed) { PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed += 1; } } } private void BottingFilterVibrationTableHighSpeedValueDownBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed - 1) < PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed) { PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed -= 1; } } } private void BottingFilterVibrationTableHighSpeedValueDownDownBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed - 10) < PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed) { PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed -= 10; } } } private void BottingCountVibrationTableHighSpeedValueUpUpBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed + 10) > PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed) { PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed += 10; } } } private void BottingCountVibrationTableHighSpeedValueUpBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed + 1) > PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed) { PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed += 1; } } } private void BottingCountVibrationTableHighSpeedValueDownBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed - 1) < PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed) { PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed -= 1; } } } private void BottingCountVibrationTableHighSpeedValueDownDownBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed - 10) < PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed) { PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed -= 10; } } } private void BottValueSetUpUpBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet + 5) > PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet) { PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet += 5; } } } private void BottValueSetUpBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet + 1) > PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet) { PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet += 1; } } } private void BottValueSetDownBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet - 1) < PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet) { PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet -= 1; } } } private void BottValueSetDownDownBtn_Click(object sender, RoutedEventArgs e) { if (SystemAlarm.CheckAlarmStatic(AlarmMessageList.PLC连接中)) { MessageBox.Show("PLC Connecting,Please Wait"); return; } if (PlcSettingMessageBus.pLCManagement != null && PlcSettingMessageBus.pLCManagement.IsConnect) { if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet - 5) < PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet) { PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet -= 5; } } } private void TextBox_KeyDown(object sender,KeyEventArgs e) { if (e.Key == Key.Enter) { TextBox textBox = sender as TextBox; if (textBox != null) { // 强制更新源数据 BindingExpression bindingExpression = textBox.GetBindingExpression(TextBox.TextProperty); bindingExpression.UpdateSource(); } } } /// /// 初始化配方列表 /// private void InitFormationItems() { string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}Formulations"; if (!Directory.Exists(folderPath)) { // 创建文件夹 Directory.CreateDirectory(folderPath); } try { // 获取文件列表(包含子目录) string[] files = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories); ShowMessageBus.ShowBinding.FormulationItems.Clear(); foreach (string file in files) { ShowMessageBus.ShowBinding.FormulationItems.Add(Path.GetFileNameWithoutExtension(file)); } if (ShowMessageBus.ShowBinding.FormulationName != null && ShowMessageBus.ShowBinding.FormulationName != string.Empty) { try { FormulationCoBox.SelectedItem = ShowMessageBus.ShowBinding.FormulationName; } catch { } } } catch { } } private void SaveFormulationBtn_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(ShowMessageBus.ShowBinding.FormulationName)) { MessageBox.Show("请输入配方名称!"); return; } var ParaValue = PlcSettingMessageBus.pLCManagement.ReadAllPara(); FormulationConfigClass formulationConfigClass = FormulationClass.InitFormulation( MessageBus.NowSettingLoadMainThread.cameraConfig, MessageBus.NowSettingLoadMainThread.shuLiConfig,ParaValue); if (formulationConfigClass == null) { MessageBox.Show("获取参数失败,请检查与PLC的连接"); return; } formulationConfigClass.FormulationName = ShowMessageBus.ShowBinding.FormulationName; string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}Formulations"; string FilePath = folderPath + "\\" + ShowMessageBus.ShowBinding.FormulationName + ".xml"; if (File.Exists(FilePath)) { var confirmResult = MessageBox.Show("配方已存在,是否覆盖?", "保存确认", MessageBoxButton.YesNo); if (confirmResult == MessageBoxResult.No) { return; } } if (!Directory.Exists(folderPath)) Directory.CreateDirectory(folderPath); { XmlStorage.SerializeToXml(formulationConfigClass, FilePath); InitFormationItems(); MessageBus.NowSettingLoadMainThread.FormulationName = formulationConfigClass.FormulationName; MessageBus.NowSettingLoadMainThread.IsLoadFormulation = true; MessageBox.Show("保存成功"); } } private void ReadFormulationBtn_Click(object sender, RoutedEventArgs e) { string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}Formulations\\{FormulationCoBox.SelectedItem}.xml"; if (!File.Exists(folderPath)) { MessageBox.Show("指定文件不存在,请选择一个正确的配方"); return; } try { FormulationConfigClass formulationConfigClass = null; formulationConfigClass = XmlStorage.DeserializeFromXml(folderPath); LoadFormulation(formulationConfigClass); MessageBus.NowSettingLoadMainThread.FormulationName = formulationConfigClass.FormulationName; MessageBus.NowSettingLoadMainThread.IsLoadFormulation = true; MessageBox.Show("加载成功"); } catch (Exception ex) { MessageBox.Show($"读取文件时出错:{ex.Message}"); } } /// /// 加载配方 /// /// private void LoadFormulation(FormulationConfigClass FormulationConfig) { ShowMessageBus.ShowBinding.AcquistionLineRate = FormulationConfig.AcquistionLineRateValue.ToString(); ShowMessageBus.ShowBinding.ExposureTimeValue = FormulationConfig.ExposureTimeValue.ToString(); ShowMessageBus.ShowBinding.Channel = FormulationConfig.Channel.ToString(); ShowMessageBus.ShowBinding.FormulationName = FormulationConfig.FormulationName; ShowMessageBus.ShowBinding.MAX_OBJECT_LENGTH = FormulationConfig.MAX_Object_LENGTH.ToString(); ShowMessageBus.ShowBinding.MIN_OBJECT_LENGTH = FormulationConfig.MIN_Object_LENGTH.ToString(); ShowMessageBus.ShowBinding.PandingCode = FormulationConfig.PandingCode.ToString(); ShowMessageBus.ShowBinding.RegionThreshold = FormulationConfig.RegionThreshold.ToString(); PlcSettingMessageBus.PlcMessageShowBindage.FillingModel = FormulationConfig.FillingMode; PlcSettingMessageBus.PlcMessageShowBindage.BeltsSpeed = FormulationConfig.BeltsSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed = FormulationConfig.ShakeTable1H_FillingSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed = FormulationConfig.ShakeTable2H_FillingSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed = FormulationConfig.ShakeTable3H_FillingSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1M_FillingSpeed = FormulationConfig.ShakeTable1M_FillingSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2M_FillingSpeed = FormulationConfig.ShakeTable2M_FillingSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3M_FillingSpeed = FormulationConfig.ShakeTable3M_FillingSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1L_FillingSpeed = FormulationConfig.ShakeTable1L_FillingSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2L_FillingSpeed = FormulationConfig.ShakeTable2L_FillingSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3L_FillingSpeed = FormulationConfig.ShakeTable3L_FillingSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_CacheSpeed = FormulationConfig.ShakeTable1H_CacheSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_CacheSpeed = FormulationConfig.ShakeTable2H_CacheSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_CacheSpeed = FormulationConfig.ShakeTable3H_CacheSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1M_CacheSpeed = FormulationConfig.ShakeTable1M_CacheSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2M_CacheSpeed = FormulationConfig.ShakeTable1M_CacheSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3M_CacheSpeed = FormulationConfig.ShakeTable3M_CacheSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1L_CacheSpeed = FormulationConfig.ShakeTable1L_CacheSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2L_CacheSpeed = FormulationConfig.ShakeTable1L_CacheSpeed; PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3L_CacheSpeed = FormulationConfig.ShakeTable3L_CacheSpeed; PlcSettingMessageBus.PlcMessageShowBindage.FillingValveCloseSpeed = FormulationConfig.FillingValveCloseSpeed.ToString(); PlcSettingMessageBus.PlcMessageShowBindage.FillingValveClosePosition = FormulationConfig.FillingValveClosePosition.ToString(); PlcSettingMessageBus.PlcMessageShowBindage.ValveDelytime = FormulationConfig.ValveDelytime; PlcSettingMessageBus.PlcMessageShowBindage.ScrewJogSpeed = FormulationConfig.ScrewJogSpeed.ToString(); PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet = FormulationConfig.BottValueSet; PlcSettingMessageBus.PlcMessageShowBindage.FillingValveOpenSpeed = FormulationConfig.FillingValveOpenSpeed.ToString(); PlcSettingMessageBus.PlcMessageShowBindage.FillingValveOpenPosition = FormulationConfig.FillingValveOpenPosition.ToString(); PlcSettingMessageBus.PlcMessageShowBindage.CacheShutdownValue = FormulationConfig.CacheShutdownValue; } private void ChangeLanguage(object o, EventArgs e) { DataGridTextColumn MessageTypeColumn = FindName("DataGridMessageTypeColumn") as DataGridTextColumn; var MessageTypeHeard = MessageTypeColumn?.Header as TextBlock; //if (MessageTypeHeard.Text.ToString().Contains("类型")) //{ // //修改绑定路径到本地化属性 // MessageTypeColumn.Binding = new Binding("AlarmChType"); //} //else if (MessageTypeHeard.Text.ToString().Contains("MessageType")) //{ // MessageTypeColumn.Binding = new Binding("AlarmEnType"); //} DataGridTextColumn MessageColumn = FindName("DataGridMessageColumn") as DataGridTextColumn; var MessageHeard = MessageColumn?.Header as TextBlock; if (MessageHeard.Text.ToString().Contains("信息")) { // 修改绑定路径到本地化属性 MessageColumn.Binding = new Binding("AlarmChMess"); } else if (MessageHeard.Text.ToString().Contains("Message")) { MessageColumn.Binding = new Binding("AlarmEnMess"); } } private void BatchNumberTbx_GotFocus(object sender, RoutedEventArgs e) { OnScreenKeyboard.KeyBoardShow(); } private void FormulationName_GotFocus(object sender, RoutedEventArgs e) { OnScreenKeyboard.KeyBoardShow(); } } }