Exemple #1
0
        private void MainWindowLoaded(object sender, RoutedEventArgs e)
        {
            DisplayMngr = new DisplayManager(this);
            String[] ports = ArduinoLink.CheckComPorts();
            foreach (var item in ports)
            {
                ComPortBox.Items.Add(item);
            }
            ComPortBox.SelectedIndex = 0;
            StartButtonLabel.Content = "Start";
            StartButtonImage.Source  = this.startImage;

            this.ArduinoConnection                         = new ArduinoLink();
            this.ArduinoMessagesReceivingMngr              = new ArduinoMessagesReceiving();
            this.ArduinoMessagesSendingMngr                = new ArduinoMessagesSending();
            this.ArduinoConnection.SerialMessageReceived  += ArduinoMessagesReceivingMngr.SerialMessageReceiver;
            this.ArduinoMessagesReceivingMngr.ButtonPress += this.ArduinoSLIButtonPress;
            this.ArduinoMessagesSendingMngr.TestFinished  += this.ArduinoSLITestFinished;

            // Create a new instance of the SdkWrapper object
            this.wrapper = new SdkWrapper
            {
                EventRaiseType           = SdkWrapper.EventRaiseTypes.CurrentThread,
                TelemetryUpdateFrequency = 30    //60  //NEWBUILD
            };
            // Tell it to raise events on the current thread (don't worry if you don't know what a thread is)
            // Only update telemetry 60 times per second
            // Attach some useful events so you can respond when they get raised
            this.wrapper.Connected          += this.WrapperConnected;
            this.wrapper.Disconnected       += this.WrapperDisconnected;
            this.wrapper.SessionInfoUpdated += this.WrapperSessionInfoUpdated;
            this.wrapper.TelemetryUpdated   += this.WrapperTelemetryUpdated;

            DisplayMngr.ArduinoConnection = this.ArduinoConnection;
            DisplayMngr.Wrapper           = this.wrapper;

            if (ComPortBox.SelectedIndex >= 0)
            {
                if (DisplayMngr.ConfSet)
                {
                    StartButton.IsEnabled = true;
                }
            }
            else
            {
                StartButton.IsEnabled = false;
            }
            LoadConfsinDirectory();
            DisplayMngr.ShiftLightData = ShiftLightData.LoadShiftData(AppDomain.CurrentDomain.BaseDirectory + "ShiftLightData.xml"); //Load ShiftLightData.xml

            if (StartButton.IsEnabled)
            {
                DisplayMngr.Test = true;
                this._conect();
                this.TMDisplayTest();
            }

            //this.MyNotifyIcon.ShowBalloonTip("iRduino", "Estamos Rodando", Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info);
            this.Hide();
        }
 public ArduinoMessagesSending(ArduinoLink arduinoConnectionIn)
 {
     this.arduinoConnection  = arduinoConnectionIn;
     this.testTimer          = new DispatcherTimer();
     this.testTimer.Tick    += this.TestTimerTick;
     this.testTimer.Interval = new TimeSpan(0, 0, 0, 0, 150);
     this.testCounter        = 0;
 }
 public void TMDisplayTest(List <bool> tmUnitTypes, ArduinoLink currentArduinoConnection)
 {
     if (tmUnitTypes == null || currentArduinoConnection == null)
     {
         return;
     }
     this.unitTypes         = tmUnitTypes;
     this.arduinoConnection = currentArduinoConnection;
     this.testCounter       = 0;
     this.testTimer.Start();
 }