MainPage.xaml.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. 
  2. using CCDCount.DLL;
  3. using CCDCount.DLL.SqlDataClass;
  4. using CCDCount.MODEL.AuditTrailModel;
  5. using CCDCount.MODEL.ConfigModel;
  6. using CCDCountWpf.Language;
  7. using LogClass;
  8. using MvCameraControl;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Diagnostics;
  12. using System.Drawing;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Threading;
  16. using System.Threading.Tasks;
  17. using System.Windows;
  18. using System.Windows.Controls;
  19. using System.Windows.Data;
  20. using System.Windows.Documents;
  21. using System.Windows.Input;
  22. using System.Windows.Interop;
  23. using System.Windows.Media;
  24. using System.Windows.Media.Imaging;
  25. using static System.Net.Mime.MediaTypeNames;
  26. namespace CCDCountWpf.WpfPage
  27. {
  28. /// <summary>
  29. /// MainPage.xaml 的交互逻辑
  30. /// </summary>
  31. public partial class MainPage : Page
  32. {
  33. #region 变量与实例
  34. #endregion
  35. public MainPage()
  36. {
  37. InitializeComponent();
  38. DataContext = ShowMessageBus.ShowBinding;
  39. InitFormationItems();
  40. }
  41. private void DataClear_Click(object sender, RoutedEventArgs e)
  42. {
  43. if(MessageBus.NowSettingLoadMainThread == null)
  44. return;
  45. MessageBus.NowSettingLoadMainThread.ClearHistoryActive();
  46. MessageBus.NowSettingLoadMainThread.ClearSendQueue();
  47. PlcSettingMessageBus.pLCManagement.ClearBottSpeed();
  48. }
  49. private void Page_Loaded(object sender, RoutedEventArgs e)
  50. {
  51. this.Width = double.NaN; // 等效于 Auto
  52. this.Height = double.NaN;
  53. LOG.log("生产界面初始化语言切换事件", 6);
  54. LanguageManager.LanguageChangeEvent += ChangeLanguage;
  55. LOG.log("生产界面运行一次语言切换", 6);
  56. ChangeLanguage(null, EventArgs.Empty);
  57. StopIdentifyBtn.IsEnabled = false;
  58. StopIdentifyBtn.Opacity = 0.5;
  59. LOG.log("运行状态初始化", 6);
  60. if(MessageBus.NowSettingLoadMainThread != null)
  61. {
  62. if (MessageBus.NowSettingLoadMainThread.CameraRunStatic)
  63. {
  64. StartIdentifyBtn.IsEnabled = false;
  65. StartIdentifyBtn.Opacity = 0.5;
  66. StopIdentifyBtn.IsEnabled = true;
  67. StopIdentifyBtn.Opacity = 1;
  68. }
  69. else
  70. {
  71. StartIdentifyBtn.IsEnabled = true;
  72. StartIdentifyBtn.Opacity = 1;
  73. StopIdentifyBtn.IsEnabled = false;
  74. StopIdentifyBtn.Opacity = 0.5;
  75. }
  76. }
  77. }
  78. /// <summary>
  79. /// 启动相机识别
  80. /// </summary>
  81. private bool RunCameraIdentify()
  82. {
  83. if(MessageBus.NowSettingLoadMainThread != null)
  84. {
  85. MessageBus.NowSettingLoadMainThread.BatchNumber = ShowMessageBus.ShowBinding.BatchNumber;
  86. if (MessageBus.NowSettingLoadMainThread.CameraConfigIsChange)
  87. {
  88. MessageBus.NowSettingLoadMainThread.ReLoadCameraConfig();
  89. }
  90. //启动单相机实例的全部线程
  91. if (!MessageBus.NowSettingLoadMainThread.StartMianThread())
  92. {
  93. FaultLog.RecordErrorMessage(MessageBus.NowSettingLoadMainThread.cameraConfig.DeviceName + "_" + MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum + "Failed to open", "CCDCountWpf:MainPage-RunCameraIdentify");
  94. //LOG.error(MessageBus.MainThreadS[i].cameraConfig.DeviceName + "_" + MessageBus.MainThreadS[i].cameraConfig.CameraSNNum + "启动失败");
  95. MessageBox.Show(MessageBus.NowSettingLoadMainThread.cameraConfig.DeviceName + "_" + MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum + "Failed to open");
  96. return false;
  97. }
  98. }
  99. MessageBus.NowLoadCammeraSN = MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum;
  100. return true;
  101. }
  102. /// <summary>
  103. /// 停止相机识别
  104. /// </summary>
  105. private void StopCameraIdentify()
  106. {
  107. if(MessageBus.NowSettingLoadMainThread != null)
  108. {
  109. //启动单相机实例的全部线程
  110. if (!MessageBus.NowSettingLoadMainThread.StopMianThread())
  111. {
  112. FaultLog.RecordErrorMessage(MessageBus.NowSettingLoadMainThread.cameraConfig.DeviceName + "_" + MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum + "Failed to close", "CCDCountWpf:MainPage-StopCameraIdentify");
  113. MessageBox.Show(MessageBus.NowSettingLoadMainThread.cameraConfig.DeviceName + "_" + MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum + "Failed to close");
  114. }
  115. }
  116. }
  117. private bool RunBatchIsRun =false;
  118. /// <summary>
  119. /// 运行批次记录
  120. /// </summary>
  121. /// <param name="BatchNumber"></param>
  122. private void RunBatchRecord(string BatchNumber)
  123. {
  124. if (RunBatchIsRun)
  125. {
  126. return;
  127. }
  128. List<BatchRecordModel> batchRecordModels = new List<BatchRecordModel>();
  129. Stopwatch stopwatch = new Stopwatch();
  130. BatchMessSqliteDataClass batchMessSqliteData = new BatchMessSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\BatchData\\BatchData_{BatchNumber}.db");
  131. RunBatchIsRun = true;
  132. Task.Run(() =>
  133. {
  134. while (RunBatchIsRun)
  135. {
  136. try
  137. {
  138. stopwatch.Restart();
  139. DateTime RecordTime = DateTime.Now;
  140. var OutTimeBatch = batchRecordModels.Where(x => x.RecordTime.AddMinutes(1) < RecordTime).ToList();
  141. OutTimeBatch.ForEach(x => batchRecordModels.Remove(x));
  142. if(!PlcSettingMessageBus.pLCManagement.ReadBottingVibrationTableHighSpeedValue(out ushort BottingVibrationTableHighSpeedValue, out ushort FilterVibrationTableHighSpeedValue, out ushort CountVibrationTableHighSpeedValue))
  143. {
  144. continue ;
  145. }
  146. if(!PlcSettingMessageBus.pLCManagement.ReadBottingCount(out ushort BottingCount))
  147. {
  148. continue ;
  149. }
  150. ushort CountSPeed = (ushort)(batchRecordModels.Count() > 0 ? (BottingCount - batchRecordModels.Min(o => o.BottingCount)) > 0 ? BottingCount - batchRecordModels.Min(o => o.BottingCount) : 0 : 0);
  151. ShowMessageBus.ShowBinding.BottingSpeed = CountSPeed;
  152. BatchRecordModel batchRecordModel = new BatchRecordModel
  153. {
  154. BatchNunber = BatchNumber,
  155. MaterialCylinderVibrationTableSpeed = BottingVibrationTableHighSpeedValue,
  156. FilterVibrationTableSpeed = FilterVibrationTableHighSpeedValue,
  157. CountVibrationTableSpeed = CountVibrationTableHighSpeedValue,
  158. BottingCount = BottingCount,
  159. BottingSpeed = CountSPeed,
  160. RecordTime = RecordTime
  161. };
  162. batchMessSqliteData.InsertBatchMessage(batchRecordModel);
  163. batchRecordModels.Add(batchRecordModel);
  164. stopwatch.Stop();
  165. int SleepTime = 998 - (int)stopwatch.ElapsedMilliseconds;
  166. if (SleepTime > 0)
  167. {
  168. Thread.Sleep(SleepTime);
  169. }
  170. }
  171. catch(Exception ex)
  172. {
  173. LOG.error("MianPage-RunBatchRecord:Error:" + ex.Message);
  174. }
  175. }
  176. });
  177. }
  178. private void StopBatchRecord()
  179. {
  180. RunBatchIsRun = false;
  181. }
  182. private void StartIdentifyBtn_Click(object sender, RoutedEventArgs e)
  183. {
  184. if (String.IsNullOrWhiteSpace(ShowMessageBus.ShowBinding.BatchNumber))
  185. {
  186. MessageBox.Show("请输入批次号!");
  187. return;
  188. }
  189. RunBatchRecord(ShowMessageBus.ShowBinding.BatchNumber);
  190. if (!RunCameraIdentify())
  191. {
  192. return;
  193. }
  194. StartIdentifyBtn.IsEnabled = false;
  195. StartIdentifyBtn.Opacity = 0.5;
  196. StopIdentifyBtn.IsEnabled = true;
  197. StopIdentifyBtn.Opacity = 1;
  198. if (PlcSettingMessageBus.pLCManagement.IsConnect)
  199. {
  200. PlcSettingMessageBus.pLCManagement.MachineRunToTrue();
  201. }
  202. }
  203. private void StopIdentifyBtn_Click(object sender, RoutedEventArgs e)
  204. {
  205. StopCameraIdentify();
  206. LOG.log("停止相机成功");
  207. //StopBatchRecord();
  208. StartIdentifyBtn.IsEnabled = true;
  209. StartIdentifyBtn.Opacity = 1;
  210. StopIdentifyBtn.IsEnabled = false;
  211. StopIdentifyBtn.Opacity = 0.5;
  212. //if (PlcSettingMessageBus.pLCManagement.IsConnect)
  213. //{
  214. // PlcSettingMessageBus.pLCManagement.MachineStopToTrue();
  215. //}
  216. }
  217. private void BottingMaterialCylinderVibrationTableHighSpeedValueUpUpBtn_Click(object sender, RoutedEventArgs e)
  218. {
  219. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed + 10) >
  220. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed)
  221. {
  222. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed += 10;
  223. }
  224. }
  225. private void BottingMaterialCylinderVibrationTableHighSpeedValueUpBtn_Click(object sender, RoutedEventArgs e)
  226. {
  227. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed + 1) >
  228. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed)
  229. {
  230. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed += 1;
  231. }
  232. }
  233. private void BottingMaterialCylinderVibrationTableHighSpeedValueDownBtn_Click(object sender, RoutedEventArgs e)
  234. {
  235. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed - 1) <
  236. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed)
  237. {
  238. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed -= 1;
  239. }
  240. }
  241. private void BottingMaterialCylinderVibrationTableHighSpeedValueDownDownBtn_Click(object sender, RoutedEventArgs e)
  242. {
  243. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed - 10) <
  244. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed)
  245. {
  246. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed -= 10;
  247. }
  248. }
  249. private void BottingFilterVibrationTableHighSpeedValueUpUpBtn_Click(object sender, RoutedEventArgs e)
  250. {
  251. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed + 10) >
  252. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed)
  253. {
  254. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed += 10;
  255. }
  256. }
  257. private void BottingFilterVibrationTableHighSpeedValueUpBtn_Click(object sender, RoutedEventArgs e)
  258. {
  259. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed + 1) >
  260. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed)
  261. {
  262. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed += 1;
  263. }
  264. }
  265. private void BottingFilterVibrationTableHighSpeedValueDownBtn_Click(object sender, RoutedEventArgs e)
  266. {
  267. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed - 1) <
  268. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed)
  269. {
  270. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed -= 1;
  271. }
  272. }
  273. private void BottingFilterVibrationTableHighSpeedValueDownDownBtn_Click(object sender, RoutedEventArgs e)
  274. {
  275. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed - 10) <
  276. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed)
  277. {
  278. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed -= 10;
  279. }
  280. }
  281. private void BottingCountVibrationTableHighSpeedValueUpUpBtn_Click(object sender, RoutedEventArgs e)
  282. {
  283. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed + 10) >
  284. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed)
  285. {
  286. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed += 10;
  287. }
  288. }
  289. private void BottingCountVibrationTableHighSpeedValueUpBtn_Click(object sender, RoutedEventArgs e)
  290. {
  291. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed + 1) >
  292. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed)
  293. {
  294. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed += 1;
  295. }
  296. }
  297. private void BottingCountVibrationTableHighSpeedValueDownBtn_Click(object sender, RoutedEventArgs e)
  298. {
  299. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed - 1) <
  300. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed)
  301. {
  302. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed -= 1;
  303. }
  304. }
  305. private void BottingCountVibrationTableHighSpeedValueDownDownBtn_Click(object sender, RoutedEventArgs e)
  306. {
  307. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed - 10) <
  308. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed)
  309. {
  310. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed -= 10;
  311. }
  312. }
  313. private void BottValueSetUpUpBtn_Click(object sender, RoutedEventArgs e)
  314. {
  315. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet + 5) >
  316. PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet)
  317. {
  318. PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet += 5;
  319. }
  320. }
  321. private void BottValueSetUpBtn_Click(object sender, RoutedEventArgs e)
  322. {
  323. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet + 1) >
  324. PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet)
  325. {
  326. PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet += 1;
  327. }
  328. }
  329. private void BottValueSetDownBtn_Click(object sender, RoutedEventArgs e)
  330. {
  331. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet - 1) <
  332. PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet)
  333. {
  334. PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet -= 1;
  335. }
  336. }
  337. private void BottValueSetDownDownBtn_Click(object sender, RoutedEventArgs e)
  338. {
  339. if ((ushort)(PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet - 5) <
  340. PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet)
  341. {
  342. PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet -= 5;
  343. }
  344. }
  345. private void TextBox_KeyDown(object sender,KeyEventArgs e)
  346. {
  347. if (e.Key == Key.Enter)
  348. {
  349. TextBox textBox = sender as TextBox;
  350. if (textBox != null)
  351. {
  352. // 强制更新源数据
  353. BindingExpression bindingExpression = textBox.GetBindingExpression(TextBox.TextProperty);
  354. bindingExpression.UpdateSource();
  355. }
  356. }
  357. }
  358. /// <summary>
  359. /// 初始化配方列表
  360. /// </summary>
  361. private void InitFormationItems()
  362. {
  363. string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}Formulations";
  364. if (!Directory.Exists(folderPath))
  365. {
  366. // 创建文件夹
  367. Directory.CreateDirectory(folderPath);
  368. }
  369. try
  370. {
  371. // 获取文件列表(包含子目录)
  372. string[] files = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories);
  373. ShowMessageBus.ShowBinding.FormulationItems.Clear();
  374. foreach (string file in files)
  375. {
  376. ShowMessageBus.ShowBinding.FormulationItems.Add(Path.GetFileNameWithoutExtension(file));
  377. }
  378. if (ShowMessageBus.ShowBinding.FormulationName != null && ShowMessageBus.ShowBinding.FormulationName != string.Empty)
  379. {
  380. try
  381. {
  382. FormulationCoBox.SelectedItem = ShowMessageBus.ShowBinding.FormulationName;
  383. }
  384. catch { }
  385. }
  386. }
  387. catch
  388. { }
  389. }
  390. private void SaveFormulationBtn_Click(object sender, RoutedEventArgs e)
  391. {
  392. if (string.IsNullOrEmpty(ShowMessageBus.ShowBinding.FormulationName))
  393. {
  394. MessageBox.Show("请输入配方名称!");
  395. return;
  396. }
  397. var ParaValue = PlcSettingMessageBus.pLCManagement.ReadAllPara();
  398. FormulationConfigClass formulationConfigClass = FormulationClass.InitFormulation(
  399. MessageBus.NowSettingLoadMainThread.cameraConfig, MessageBus.NowSettingLoadMainThread.shuLiConfig,ParaValue);
  400. if (formulationConfigClass == null)
  401. {
  402. MessageBox.Show("获取参数失败,请检查与PLC的连接");
  403. return;
  404. }
  405. formulationConfigClass.FormulationName = ShowMessageBus.ShowBinding.FormulationName;
  406. string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}Formulations";
  407. string FilePath = folderPath + "\\" + ShowMessageBus.ShowBinding.FormulationName + ".xml";
  408. if (File.Exists(FilePath))
  409. {
  410. var confirmResult = MessageBox.Show("配方已存在,是否覆盖?",
  411. "保存确认", MessageBoxButton.YesNo);
  412. if (confirmResult == MessageBoxResult.No)
  413. {
  414. return;
  415. }
  416. }
  417. if (!Directory.Exists(folderPath)) Directory.CreateDirectory(folderPath);
  418. {
  419. XmlStorage.SerializeToXml(formulationConfigClass, FilePath);
  420. InitFormationItems();
  421. MessageBus.NowSettingLoadMainThread.FormulationName = formulationConfigClass.FormulationName;
  422. MessageBus.NowSettingLoadMainThread.IsLoadFormulation = true;
  423. MessageBox.Show("保存成功");
  424. }
  425. }
  426. private void ReadFormulationBtn_Click(object sender, RoutedEventArgs e)
  427. {
  428. string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}Formulations\\{FormulationCoBox.SelectedItem}.xml";
  429. if (!File.Exists(folderPath))
  430. {
  431. MessageBox.Show("指定文件不存在,请选择一个正确的配方");
  432. return;
  433. }
  434. try
  435. {
  436. FormulationConfigClass formulationConfigClass = null;
  437. formulationConfigClass = XmlStorage.DeserializeFromXml<FormulationConfigClass>(folderPath);
  438. LoadFormulation(formulationConfigClass);
  439. MessageBus.NowSettingLoadMainThread.FormulationName = formulationConfigClass.FormulationName;
  440. MessageBus.NowSettingLoadMainThread.IsLoadFormulation = true;
  441. MessageBox.Show("加载成功");
  442. }
  443. catch (Exception ex)
  444. {
  445. MessageBox.Show($"读取文件时出错:{ex.Message}");
  446. }
  447. }
  448. /// <summary>
  449. /// 加载配方
  450. /// </summary>
  451. /// <param name="FormulationConfig"></param>
  452. private void LoadFormulation(FormulationConfigClass FormulationConfig)
  453. {
  454. ShowMessageBus.ShowBinding.AcquistionLineRate = FormulationConfig.AcquistionLineRateValue.ToString();
  455. ShowMessageBus.ShowBinding.ExposureTimeValue = FormulationConfig.ExposureTimeValue.ToString();
  456. ShowMessageBus.ShowBinding.Channel = FormulationConfig.Channel.ToString();
  457. ShowMessageBus.ShowBinding.FormulationName = FormulationConfig.FormulationName;
  458. ShowMessageBus.ShowBinding.MAX_OBJECT_LENGTH = FormulationConfig.MAX_Object_LENGTH.ToString();
  459. ShowMessageBus.ShowBinding.MIN_OBJECT_LENGTH = FormulationConfig.MIN_Object_LENGTH.ToString();
  460. ShowMessageBus.ShowBinding.PandingCode = FormulationConfig.PandingCode.ToString();
  461. ShowMessageBus.ShowBinding.RegionThreshold = FormulationConfig.RegionThreshold.ToString();
  462. PlcSettingMessageBus.PlcMessageShowBindage.FillingModel =
  463. FormulationConfig.FillingMode;
  464. PlcSettingMessageBus.PlcMessageShowBindage.BeltsSpeed =
  465. FormulationConfig.BeltsSpeed;
  466. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_FillingSpeed =
  467. FormulationConfig.ShakeTable1H_FillingSpeed;
  468. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_FillingSpeed =
  469. FormulationConfig.ShakeTable2H_FillingSpeed;
  470. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_FillingSpeed =
  471. FormulationConfig.ShakeTable3H_FillingSpeed;
  472. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1M_FillingSpeed =
  473. FormulationConfig.ShakeTable1M_FillingSpeed;
  474. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2M_FillingSpeed =
  475. FormulationConfig.ShakeTable2M_FillingSpeed;
  476. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3M_FillingSpeed =
  477. FormulationConfig.ShakeTable3M_FillingSpeed;
  478. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1L_FillingSpeed =
  479. FormulationConfig.ShakeTable1L_FillingSpeed;
  480. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2L_FillingSpeed =
  481. FormulationConfig.ShakeTable2L_FillingSpeed;
  482. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3L_FillingSpeed =
  483. FormulationConfig.ShakeTable3L_FillingSpeed;
  484. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1H_CacheSpeed =
  485. FormulationConfig.ShakeTable1H_CacheSpeed;
  486. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2H_CacheSpeed =
  487. FormulationConfig.ShakeTable2H_CacheSpeed;
  488. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3H_CacheSpeed =
  489. FormulationConfig.ShakeTable3H_CacheSpeed;
  490. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1M_CacheSpeed =
  491. FormulationConfig.ShakeTable1M_CacheSpeed;
  492. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2M_CacheSpeed =
  493. FormulationConfig.ShakeTable1M_CacheSpeed;
  494. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3M_CacheSpeed =
  495. FormulationConfig.ShakeTable3M_CacheSpeed;
  496. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable1L_CacheSpeed =
  497. FormulationConfig.ShakeTable1L_CacheSpeed;
  498. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable2L_CacheSpeed =
  499. FormulationConfig.ShakeTable1L_CacheSpeed;
  500. PlcSettingMessageBus.PlcMessageShowBindage.ShakeTable3L_CacheSpeed =
  501. FormulationConfig.ShakeTable3L_CacheSpeed;
  502. PlcSettingMessageBus.PlcMessageShowBindage.FillingValveCloseSpeed =
  503. FormulationConfig.FillingValveCloseSpeed.ToString();
  504. PlcSettingMessageBus.PlcMessageShowBindage.FillingValveClosePosition =
  505. FormulationConfig.FillingValveClosePosition.ToString();
  506. PlcSettingMessageBus.PlcMessageShowBindage.ValveDelytime =
  507. FormulationConfig.ValveDelytime;
  508. PlcSettingMessageBus.PlcMessageShowBindage.ScrewJogSpeed =
  509. FormulationConfig.ScrewJogSpeed.ToString();
  510. PlcSettingMessageBus.PlcMessageShowBindage.BottValueSet =
  511. FormulationConfig.BottValueSet;
  512. PlcSettingMessageBus.PlcMessageShowBindage.FillingValveOpenSpeed =
  513. FormulationConfig.FillingValveOpenSpeed.ToString();
  514. PlcSettingMessageBus.PlcMessageShowBindage.FillingValveOpenPosition =
  515. FormulationConfig.FillingValveOpenPosition.ToString();
  516. PlcSettingMessageBus.PlcMessageShowBindage.CacheShutdownValue =
  517. FormulationConfig.CacheShutdownValue;
  518. }
  519. private void ChangeLanguage(object o, EventArgs e)
  520. {
  521. DataGridTextColumn MessageTypeColumn = FindName("DataGridMessageTypeColumn") as DataGridTextColumn;
  522. var MessageTypeHeard = MessageTypeColumn?.Header as TextBlock;
  523. //if (MessageTypeHeard.Text.ToString().Contains("类型"))
  524. //{
  525. // //修改绑定路径到本地化属性
  526. // MessageTypeColumn.Binding = new Binding("AlarmChType");
  527. //}
  528. //else if (MessageTypeHeard.Text.ToString().Contains("MessageType"))
  529. //{
  530. // MessageTypeColumn.Binding = new Binding("AlarmEnType");
  531. //}
  532. DataGridTextColumn MessageColumn = FindName("DataGridMessageColumn") as DataGridTextColumn;
  533. var MessageHeard = MessageColumn?.Header as TextBlock;
  534. if (MessageHeard.Text.ToString().Contains("信息"))
  535. {
  536. // 修改绑定路径到本地化属性
  537. MessageColumn.Binding = new Binding("AlarmChMess");
  538. }
  539. else if (MessageHeard.Text.ToString().Contains("Message"))
  540. {
  541. MessageColumn.Binding = new Binding("AlarmEnMess");
  542. }
  543. }
  544. }
  545. }