|
- 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;
- using BPASmartClient.S7Net;
-
- namespace WpfApp1
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- SiemensHelper siemensHelper = new SiemensHelper();
- siemensHelper.Connect(S7.Net.CpuType.S71200, "192.168.101.16");
- if (siemensHelper.IsConnected)
- {
- siemensHelper.WriteString(S7.Net.DataType.DataBlock, 1, 0, "cccc");
- var res = siemensHelper.ReadClass<XL_Start_DB>(1);
-
- //XL_Start_DB xL_Start_DB = new XL_Start_DB();
- //xL_Start_DB.RecipeCode = "编码";
- //xL_Start_DB.RecipeName = "名称";
- //xL_Start_DB.StockCode = 1;
- //xL_Start_DB.TrayCode = 2;
- //for (int i = 0; i < xL_Start_DB.Powder.Length; i++)
- //{
- // xL_Start_DB.Powder[i].Powder_Name = $"料{i}";
- // xL_Start_DB.Powder[i].Powder_Weight = (float)(5.0 + i);
- //}
- //for (int i = 0; i < xL_Start_DB.Material.Length; i++)
- //{
- // xL_Start_DB.Material[i].Material_Name = $"原料{i}";
- // xL_Start_DB.Material[i].Material_Weight = (float)(50.0 + i);
- // xL_Start_DB.Material[i].Material_BarrelNum = (short)(i + 1);
- //}
- //xL_Start_DB.Order_Request_ACK = true;
- //xL_Start_DB.Order_Request = true;
-
- //for (int i = 0; i < xL_Start_DB.Standby.Length; i++)
- //{
- // xL_Start_DB.Standby[i] = (short)(i + 100);
- // xL_Start_DB.Standby1[i] = (short)(i + 300);
- //}
-
- res.RecipeCode = "";
- res.RecipeName = "";
- res.StockCode = 0;
- res.TrayCode = 0;
- for (int i = 0; i < res.Powder.Length; i++)
- {
- res.Powder[i].Powder_Name = "";
- res.Powder[i].Powder_Weight = 0;
- }
- for (int i = 0; i < res.Material.Length; i++)
- {
- res.Material[i].Material_Name = "";
- res.Material[i].Material_Weight = 0;
- res.Material[i].Material_BarrelNum = 0;
- }
- res.Order_Request_ACK = false;
- res.Order_Request = false;
-
- for (int i = 0; i < res.Standby.Length; i++)
- {
- res.Standby[i] = 0;
- res.Standby1[i] = 0;
- }
-
- siemensHelper.WriteClass<XL_Start_DB>(res, 1);
-
- var res1 = siemensHelper.ReadClass<XL_Start_DB>(1);
- }
-
- }
- }
- }
|