示例#1
0
 private void ComPortBox_Closed(object sender, EventArgs e)
 {
     if (ComPortBox.SelectedItem == null)
     {
         return;
     }
     Settings.Com = ComPortBox.SelectedItem.ToString();
     ComPort.InitComPort(Settings.Com, Settings.BaudRate);
 }
示例#2
0
 private void MainWindow_Closing(object sender, RoutedEventArgs args) //действия при закрытии приложения через меню
 {
     if (MessageBoxResult.No == MessageBox.Show("Вы действительно хотите закрыть программу?", "Закрытие клиента", MessageBoxButton.YesNo, MessageBoxImage.Warning))
     {
         return;
     }
     ComPort.Close();
     App.Current.Shutdown();
 }
示例#3
0
 private void BaudrateComboBox_DropDownClosed(object sender, EventArgs e)
 {
     if (BaudrateComboBox.SelectedItem == null)
     {
         return;
     }
     Settings.BaudRate = Convert.ToInt32(BaudrateComboBox.SelectedItem);
     ComPort.InitComPort(Settings.Com, Settings.BaudRate);
 }
示例#4
0
 private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) //действия при закрытии приложения
 {
     if (MessageBoxResult.No == MessageBox.Show("Вы действительно хотите закрыть программу?", "Закрытие клиента", MessageBoxButton.YesNo, MessageBoxImage.Warning))
     {
         e.Cancel = true;
         return;
     }
     ComPort.Close();
     App.Current.Shutdown();
 }
示例#5
0
        private void ComPortBox_Opened(object sender, EventArgs e)
        {
            ComPortBox.Items.Clear();
            ComPortBox.SelectedItem = ComPort.CurrentPort;

            foreach (string s in ComPort.GetPorts())
            {
                ComPortBox.Items.Add($"{s}");
            }
        }
示例#6
0
        public MainWindow()
        {
            InitializeComponent();
            Closing += MainWindow_Closing;

            #region COM_INIT and COM_EVENTS
            ComPort.NewDataRecived    += rdata => WriteLog(rdata, true);
            ComPort.NewDataRecived    += rdata => Manager(rdata);
            ComPort.NewDataTransfered += tdata => WriteLog(tdata, false);
            ComPortBox.Items.Add(Settings.Com);
            ComPortBox.SelectedIndex = 0;
            ComPort.InitComPort(Settings.Com, Settings.BaudRate);
            #endregion

            #region SendTimerInit
            System.Windows.Threading.DispatcherTimer interrogatorTimer = new System.Windows.Threading.DispatcherTimer();
            interrogatorTimer.Tick    += new EventHandler(DataTransferTimer_Tick);
            interrogatorTimer.Interval = new TimeSpan(0, 0, 0, 0, 250); //инит таймера отправки: дни; часы; минуты; секунды; милсек.
            interrogatorTimer.Start();
            #endregion
        }
示例#7
0
 private void SendButton_Click(object sender, RoutedEventArgs e)
 {
     //ComPort.Write(WriteBox.Text);
     byte[] X = { 0xAB, 0x10 };
     ComPort.Write(X);
 }
示例#8
0
 public static void Trash_off() => ComPort.Write(new byte[] { 0xAB, 0x10 });
示例#9
0
 public static void State_electrometer() => ComPort.Write(new byte[] { 0xAB, 0x05 });
示例#10
0
 public static void State_full() => ComPort.Write(new byte[] { 0xAB, 0x07 });
示例#11
0
 public static void State_pressure() => ComPort.Write(new byte[] { 0xAB, 0x06 });
示例#12
0
 public static void State_valve() => ComPort.Write(new byte[] { 0xAB, 0x03 });