终端一体化运控平台
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

91 righe
3.2 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using BPASmartClient.S7Net;
  16. namespace WpfApp1
  17. {
  18. /// <summary>
  19. /// Interaction logic for MainWindow.xaml
  20. /// </summary>
  21. public partial class MainWindow : Window
  22. {
  23. public MainWindow()
  24. {
  25. InitializeComponent();
  26. SiemensHelper siemensHelper = new SiemensHelper();
  27. siemensHelper.Connect(S7.Net.CpuType.S71200, "192.168.101.16");
  28. if (siemensHelper.IsConnected)
  29. {
  30. siemensHelper.WriteString(S7.Net.DataType.DataBlock, 1, 0, "cccc");
  31. var res = siemensHelper.ReadClass<XL_Start_DB>(1);
  32. //XL_Start_DB xL_Start_DB = new XL_Start_DB();
  33. //xL_Start_DB.RecipeCode = "编码";
  34. //xL_Start_DB.RecipeName = "名称";
  35. //xL_Start_DB.StockCode = 1;
  36. //xL_Start_DB.TrayCode = 2;
  37. //for (int i = 0; i < xL_Start_DB.Powder.Length; i++)
  38. //{
  39. // xL_Start_DB.Powder[i].Powder_Name = $"料{i}";
  40. // xL_Start_DB.Powder[i].Powder_Weight = (float)(5.0 + i);
  41. //}
  42. //for (int i = 0; i < xL_Start_DB.Material.Length; i++)
  43. //{
  44. // xL_Start_DB.Material[i].Material_Name = $"原料{i}";
  45. // xL_Start_DB.Material[i].Material_Weight = (float)(50.0 + i);
  46. // xL_Start_DB.Material[i].Material_BarrelNum = (short)(i + 1);
  47. //}
  48. //xL_Start_DB.Order_Request_ACK = true;
  49. //xL_Start_DB.Order_Request = true;
  50. //for (int i = 0; i < xL_Start_DB.Standby.Length; i++)
  51. //{
  52. // xL_Start_DB.Standby[i] = (short)(i + 100);
  53. // xL_Start_DB.Standby1[i] = (short)(i + 300);
  54. //}
  55. res.RecipeCode = "";
  56. res.RecipeName = "";
  57. res.StockCode = 0;
  58. res.TrayCode = 0;
  59. for (int i = 0; i < res.Powder.Length; i++)
  60. {
  61. res.Powder[i].Powder_Name = "";
  62. res.Powder[i].Powder_Weight = 0;
  63. }
  64. for (int i = 0; i < res.Material.Length; i++)
  65. {
  66. res.Material[i].Material_Name = "";
  67. res.Material[i].Material_Weight = 0;
  68. res.Material[i].Material_BarrelNum = 0;
  69. }
  70. res.Order_Request_ACK = false;
  71. res.Order_Request = false;
  72. for (int i = 0; i < res.Standby.Length; i++)
  73. {
  74. res.Standby[i] = 0;
  75. res.Standby1[i] = 0;
  76. }
  77. siemensHelper.WriteClass<XL_Start_DB>(res, 1);
  78. var res1 = siemensHelper.ReadClass<XL_Start_DB>(1);
  79. }
  80. }
  81. }
  82. }