Example #1
0
        private async void UpdateVaildList_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                foreach (var tag in this.activeTags)
                {
                    tag.Value.LatestEpc = null;
                    tag.Value.ReadCount = 0;
                    tag.Value.ReadRate  = 0.0;
                    tag.Value.Valid     = false;
                }

                await this.reader.Inventory(TimeSpan.FromSeconds(1));

                foreach (var tag in this.activeTags)
                {
                    tag.Value.Valid = tag.Value.ReadCount != 0;
                }

                foreach (var tag in this.TagList)
                {
                    tag.OnPropertyChanged(nameof(tag.BackgroundColor));
                }
            }
            catch (TaskCanceledException) { }
            catch (Exception ex)
            {
                BasicMessageBox.Show($"{ex.Message}\n{ex.StackTrace}", "Failed to run inventory command");
            }
        }
Example #2
0
        private void LoadProgramButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog();

            if (dialog.ShowDialog() == true)
            {
                try
                {
                    this.firmware = new MspFirmware(dialog.FileName);
                    this.UpdateFirmwareSource(this.firmware);

                    this.bytesToSend         = MspBoot.EncodeProgram(this.firmware);
                    this.loadedFileName.Text = $"{dialog.FileName} ({this.bytesToSend.Length} bytes)";

                    Console.WriteLine($"Sending: {this.bytesToSend.ToByteString("0x", ",")} Length = {this.bytesToSend.Length}");
                    this.sendDataAllButton.IsEnabled    = (this.bytesToSend != null && this.isConnected);
                    this.sendDataAllButton100.IsEnabled = (this.bytesToSend != null && this.isConnected);

                    this.UpdateEncryptedDataTextBox();
                    this.UpdateEnryptedKey();
                }
                catch (Exception ex)
                {
                    BasicMessageBox.Show($"{ex.Message}\n{ex.StackTrace}", "Failed to load program");
                }
            }
        }
Example #3
0
        public void Connect()
        {
            var status = this.reader.Connect(this.ReaderIpText.Trim());

            if (status != ENUM_ConnectionAttemptStatusType.Success)
            {
                if ((int)status == -1)
                {
                    BasicMessageBox.Show(
                        $"An unknown error occured.\n\nThis is probably a TCP error, check that the reader IP address is correct: '{this.ReaderIpText.Trim()}'",
                        "Error connecting to reader"
                        );
                }
                else
                {
                    BasicMessageBox.Show(status.ToString(), "Error connecting to reader");
                }
                this.UpdateConnectionStatus(false);
                return;
            }

            Properties.Settings.Default.ConnectionString = this.ReaderIpText.Trim();
            Properties.Settings.Default.Save();

            this.reader.reader.OnRoAccessReportReceived += this.Reader_OnRoAccessReportReceived;
            this.reader.ResetState();
        }
Example #4
0
 public static BasicMessageBox Show(string content, string title = "")
 {
     return(Application.Current.Dispatcher.Invoke(() =>
     {
         var msgBox = new BasicMessageBox(title, content);
         msgBox.Show();
         return msgBox;
     }));
 }
Example #5
0
 private async void SendToAll_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         await this.RunUpdate();
     }
     catch (Exception ex)
     {
         BasicMessageBox.Show($"Failed to broadcast to all tags {ex}", "Send to all failed");
     }
 }
Example #6
0
 private void LoadTagList()
 {
     try
     {
         var config = File.ReadAllText(Properties.Settings.Default.TagList);
         this.tagConfig = Toml.ReadString <Dictionary <string, Tag> >(config);
     }
     catch (Exception ex)
     {
         BasicMessageBox.Show($"Failed to load tag list {ex}", "Failed to load tag list");
     }
 }
Example #7
0
 private async void InventoryButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         await this.reader.Inventory(TimeSpan.FromSeconds(1000));
     }
     catch (TaskCanceledException) { }
     catch (Exception ex)
     {
         BasicMessageBox.Show($"{ex.Message}\n{ex.StackTrace}", "Failed to run inventory command");
     }
 }
Example #8
0
 private async void SendDataAllButton100_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var repeatTimes = int.Parse(this.repeatTimes.Text.Trim());
         var logName     = $"SecureBroadcast_log_{ this.GetSendMode()}.csv";
         await Task.Run(async() => await this.RunBenchmark(repeatTimes, logName, this.RunUpdate, "SendToAll"));
     }
     catch (Exception ex)
     {
         BasicMessageBox.Show($"Failed to run benchmark {ex}", "Benchmark failed");
     }
 }
Example #9
0
 private async void GoToUserMode_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         foreach (var tag in this.activeTags.Where(t => t.Value.Valid))
         {
             _ = await this.reader.SendRestartInUserMode(tag.Value.TagId, TimeSpan.FromSeconds(1));
         }
     }
     catch (Exception ex)
     {
         BasicMessageBox.Show($"Failed to set tags into user mode {ex}", "Go To User Mode failed");
     }
 }