终端一体化运控平台
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

MainWindow.xaml.cs 1.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.Markup;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. using BPA.Communication;
  17. using BPA.Helper;
  18. namespace Test
  19. {
  20. /// <summary>
  21. /// Interaction logic for MainWindow.xaml
  22. /// </summary>
  23. public partial class MainWindow : Window
  24. {
  25. public MainWindow()
  26. {
  27. InitializeComponent();
  28. }
  29. ICommunication mySiemens = new Siemens();
  30. byte bit = 0;
  31. private void Button_Click(object sender, RoutedEventArgs e)
  32. {
  33. bit++;
  34. for (int i = 0; i < 32; i++)
  35. {
  36. int data = 0;
  37. int item = data.SetBitValue(bit, true).ToBytes(BPA.Helper.DataFormat.BADC).ToInt();
  38. mySiemens.Write($"DB4.DBD{2 + i * 4}", item).OnFail(s =>
  39. {
  40. MessageBox.Show(s);
  41. });
  42. }
  43. MessageBox.Show("写入完成");
  44. }
  45. private void Button_Click_1(object sender, RoutedEventArgs e)
  46. {
  47. mySiemens.WithSiemens(CpuType.S71200, "192.168.1.13").UseConnected(() =>
  48. {
  49. MessageBox.Show("设备连接成功");
  50. });
  51. }
  52. }
  53. }