终端一体化运控平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

MainWindow.xaml.cs 5.9 KiB

2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. using BPASmartClient.Compiler;
  2. using BPASmartClient.MessageCommunication;
  3. using BPASmartClient.MessageCommunication.MsgControl;
  4. using BPASmartClient.MessageName;
  5. using BPASmartClient.MessageName.EnumHelp;
  6. using BPASmartClient.MessageName.发送消息Model;
  7. using BPASmartClient.MessageName.接收消息Model;
  8. using BPASmartClient.MessageName.接收消息Model.物料仓;
  9. using Microsoft.Win32;
  10. using Newtonsoft.Json;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Text;
  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.Markup;
  23. using System.Windows.Media;
  24. using System.Windows.Media.Imaging;
  25. using System.Windows.Navigation;
  26. using System.Windows.Shapes;
  27. namespace SCADA.Test
  28. {
  29. /// <summary>
  30. /// Interaction logic for MainWindow.xaml
  31. /// </summary>
  32. public partial class MainWindow :Window
  33. {
  34. /// <summary>
  35. /// 控件集合
  36. /// </summary>
  37. List<FrameworkElement> Children = new List<FrameworkElement>();
  38. /// <summary>
  39. /// 接收消息集合
  40. /// </summary>
  41. List<EventReceiveMessage> eventReceiveMessages = new List<EventReceiveMessage>();
  42. FRedisClient fRedisClient = new FRedisClient();
  43. public MainWindow()
  44. {
  45. InitializeComponent();
  46. fRedisClient.Connect("124.222.238.75:16000,password=123456,defaultDatabase=1");
  47. Dictionary<string,string> sdsd= fRedisClient.GetKeys();
  48. string _code = " public string main(string message) \n { \n //请在此填写你的代码\n\n return message; \n }\n";
  49. string GenerateData = (string)CSharpConfig.GetInstance().RunCSharp(_code,new object[] { "ERERERERE" });
  50. xxnc.ItemsSource = System.Enum.GetNames(typeof(MessageNameEnum))?.ToList();
  51. mlname.ItemsSource = System.Enum.GetNames(typeof(MessageNameEnum))?.ToList();
  52. xx.ItemsSource = System.Enum.GetNames(typeof(RunEnum))?.ToList();
  53. Class_InnerMessageBus.GetInstance().ListenMessage(this,MessageNameEnum.SendMessageName.ToString(),"MainWindowHandler");
  54. }
  55. public void MainWindowHandler(object sender,InnerMessageEventArgs e)
  56. {
  57. try
  58. {
  59. if (e.obj_MessageObj is EventSendMessage)//接收到运行消息
  60. {
  61. EventSendMessage mode = (EventSendMessage)e.obj_MessageObj;
  62. LogShowText(JsonConvert.SerializeObject(mode));
  63. }
  64. }
  65. catch (Exception ex)
  66. {
  67. }
  68. }
  69. #region 加载数据
  70. public void LogShowText(string str)
  71. {
  72. LogShow.Text += str + "\n";
  73. }
  74. /// <summary>
  75. /// 加载数据
  76. /// </summary>
  77. public void LoadingData(string path)
  78. {
  79. //加载控件
  80. Children.Clear();
  81. FileStream fs = new FileStream(path,FileMode.Open,FileAccess.Read,FileShare.ReadWrite);
  82. using (StreamReader sr = new StreamReader(fs,System.Text.Encoding.Unicode))
  83. {
  84. while (sr.Peek() > -1)
  85. {
  86. string str = sr.ReadLine();
  87. //if (!str.Contains("NewConveyorBelt"))
  88. {
  89. var ele = XamlReader.Parse(str) as FrameworkElement;
  90. Children.Add(ele);
  91. }
  92. }
  93. }
  94. if (Children.Count > 0)
  95. {
  96. eventReceiveMessages = runCanvas.Run(Children);
  97. }
  98. }
  99. #endregion
  100. private void Button_Click(object sender,RoutedEventArgs e)
  101. {
  102. OpenFileDialog ofd = new OpenFileDialog();
  103. ofd.Filter = "布局文件|*.lay";
  104. if (ofd.ShowDialog() == true)
  105. {
  106. LoadingData(ofd.FileName);
  107. }
  108. }
  109. private void Button_Click_1(object sender,RoutedEventArgs e)
  110. {
  111. if (string.IsNullOrEmpty(mlname.Text))
  112. {
  113. MessageBox.Show("消息名称不能为空!");
  114. return;
  115. }
  116. if (string.IsNullOrEmpty(xx.Text))
  117. {
  118. MessageBox.Show("命令不能为空!");
  119. return;
  120. }
  121. RunEnumModel runEnumModel = new RunEnumModel();
  122. runEnumModel.Run = ToEnumValue<RunEnum>(xx.Text);
  123. runEnumModel.MessageID = hm.Text;
  124. Class_InnerMessageBus.GetInstance().PostMessage(this,mlname.Text,runEnumModel);
  125. }
  126. /// <summary>
  127. /// 根据枚举名称获取枚举值
  128. /// </summary>
  129. public T ToEnumValue<T>(string name)
  130. {
  131. return (T)Enum.Parse(typeof(T),name);
  132. }
  133. private void Button_Click_2(object sender,RoutedEventArgs e)
  134. {
  135. if (string.IsNullOrEmpty(xxnc.Text))
  136. {
  137. MessageBox.Show("消息名称不能为空!");
  138. return;
  139. }
  140. if (string.IsNullOrEmpty(ch.Text))
  141. {
  142. MessageBox.Show("仓号不能为空!");
  143. return;
  144. }
  145. if (string.IsNullOrEmpty(bt.Text))
  146. {
  147. MessageBox.Show("标题不能为空!");
  148. return;
  149. }
  150. if (string.IsNullOrEmpty(zl.Text))
  151. {
  152. MessageBox.Show("重量不能为空!");
  153. return;
  154. }
  155. SilosMessageModel silosMessage = new SilosMessageModel();
  156. silosMessage.MessageID = ch.Text;
  157. silosMessage.Value = zl.Text;
  158. silosMessage.Title = bt.Text;
  159. silosMessage.Text = cgs.Text;
  160. Class_InnerMessageBus.GetInstance().PostMessage(this,xxnc.Text,silosMessage);
  161. }
  162. }
  163. }