|
- 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.Markup;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using BPA.Communication;
- using BPA.Helper;
-
- namespace Test
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
-
- ICommunication mySiemens = new Siemens();
- byte bit = 0;
-
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- bit++;
- for (int i = 0; i < 32; i++)
- {
- int data = 0;
- int item = data.SetBitValue(bit, true).ToBytes(BPA.Helper.DataFormat.BADC).ToInt();
- mySiemens.Write($"DB4.DBD{2 + i * 4}", item).OnFail(s =>
- {
- MessageBox.Show(s);
- });
- }
- MessageBox.Show("写入完成");
- }
-
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
- mySiemens.WithSiemens(CpuType.S71200, "192.168.1.13").UseConnected(() =>
- {
- MessageBox.Show("设备连接成功");
- });
- }
- }
- }
|