private void LegoBrick_BrickChanged(object sender, BrickChangedEventArgs e) { if (BrickChanged != null) { BrickChanged(this, e); } }
static void _brick_BrickChanged(object sender, BrickChangedEventArgs e) { foreach (var port in e.Ports) { Console.WriteLine(port.Key + " " + port.Value); } }
private void Brick_BrickChanged(object sender, BrickChangedEventArgs e) { //throw new NotImplementedException(); gyroTextBox.Text = legobot.GyroSensor.SIValue.ToString(); colourTextBox.Text = legobot.ColourSensor.SIValue.ToString(); ultraTextBox.Text = legobot.UltrasonicSensor.SIValue.ToString(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void brick_BrickChanged(object sender, BrickChangedEventArgs e) { textBoxReturns.Text = "-----------------------------------------------------------------------" + Environment.NewLine + textBoxReturns.Text; textBoxReturns.Text += "Sensorwert 1 (One) : " + brick.Ports[InputPort.One].SIValue.ToString() + Environment.NewLine + textBoxReturns.Text; textBoxReturns.Text += "Sensorwert 2 (Two) : " + brick.Ports[InputPort.Two].SIValue.ToString() + Environment.NewLine + textBoxReturns.Text; textBoxReturns.Text += "Sensorwert 3 (Three): " + brick.Ports[InputPort.Three].SIValue.ToString() + Environment.NewLine + textBoxReturns.Text; textBoxReturns.Text += "Sensorwert 4 (Four) : " + brick.Ports[InputPort.Four].SIValue.ToString() + Environment.NewLine + textBoxReturns.Text; }
private void Brick_BrickChanged(object sender, BrickChangedEventArgs e) { //throw new NotImplementedException(); //Console.WriteLine(DateTime.Now); //Console.WriteLine(DateTime.Now + " + " + DateTime.Now.Millisecond); sensorStored = brick.Ports[InputPort.Four].SIValue; notifyObservers((int)brick.Ports[InputPort.Four].SIValue, "realtime"); }
private void _brick_BrickChanged(object sender, BrickChangedEventArgs e) { Debug.WriteLine("Brick changed!"); this._distanceMeasured = (int)e.Ports[InputPort.Four].SIValue; txtDistance.Text = this._distanceMeasured.ToString(); Debug.WriteLine(this._distanceMeasured.ToString()); }
private void _brick_BrickChanged(object sender, BrickChangedEventArgs e) { if (Commands.Count <= 0) { return; } var com = Commands.Dequeue(); com(); }
//Event Fired when the brick changes private void _brick_BrickChanged(object sender, BrickChangedEventArgs e) { float portOneValue = e.Ports[InputPort.One].SIValue; Debug.WriteLine("Port One Results: " + portOneValue); //Update the Ui With the Ports Value UpdateUi("Proximity: " + portOneValue.ToString()); CheckForCollision(portOneValue); }
public static void EventCalled(object sender, BrickChangedEventArgs e) { int[] colorArray = new int[10]; for (int i = 0; i < 10; i++) { float color = e.Ports[InputPort.Four].SIValue; colorArray[0] = Convert.ToInt32(color); } Console.WriteLine(Convert.ToString(colorArray)); }
void _brick_BrickChanged(object sender, BrickChangedEventArgs e) { MotorA.Update(_brick); MotorB.Update(_brick); MotorC.Update(_brick); MotorD.Update(_brick); InputOne.Update(_brick); InputTwo.Update(_brick); InputThree.Update(_brick); InputFour.Update(_brick); }
public void ColorAverage(BrickChangedEventArgs e, Brick brick) { colorArray = new int[10]; for (int i = 0; i < 10; i++) { float color = e.Ports[InputPort.Four].SIValue; colorArray[i++] = Convert.ToInt32(color); } Console.WriteLine(colorArray); }
private void brick_BrickChanged(object sender, BrickChangedEventArgs e) { _portText.Clear(); foreach (Port port in e.Ports.Values) { _portText.AppendFormat("{0}: {1}, {2}, {3}", port.Name, port.Type, port.Mode, port.SIValue); _portText.AppendLine(); } _ports.Text = _portText.ToString(); }
private void Brick_BrickChanged1(object sender, BrickChangedEventArgs e) { if (BrickManager.Bricks.All(x => x.Brick != sender)) { return; } var brickControler = BrickManager.Bricks.First(x => x.Brick == sender); var data = (ColorSensorColor)e.Ports[InputPort.One].RawValue; Console.WriteLine(data); UpdateColor(brickControler, data); }
private async void brickChanged(object o, BrickChangedEventArgs e) { txtDistance.Text = e.Ports[InputPort.Four].SIValue.ToString(); txtTouch.Text = e.Ports[InputPort.One].SIValue.ToString(); txtColor.Text = ((ColorSensorColor)e.Ports[InputPort.Three].SIValue).ToString(); this.currentcolor = (ColorSensorColor)e.Ports[InputPort.Three].SIValue; if (this.currentcolor == ColorSensorColor.Blue) { await brick.DirectCommand.TurnMotorAtPowerForTimeAsync(OutputPort.B, 100, 500, false); await brick.DirectCommand.TurnMotorAtPowerForTimeAsync(OutputPort.C, -25, 500, false); } }
private void Brick_BrickChanged(object sender, BrickChangedEventArgs e) { if (e.Buttons.Down) { brick.DirectCommand.TurnMotorAtSpeedAsync(OutputPort.C, 10); } else if (e.Buttons.Up) { brick.DirectCommand.StopMotorAsync(OutputPort.C, true); } else if (e.Ports[InputPort.Two].SIValue == 1) { brick.DirectCommand.StopMotorAsync(OutputPort.A, false); } }
public void HomeBase(int[] homebase, BrickChangedEventArgs e, Brick brick) { DetectColor dc = new DetectColor(); Turn turns = new Turn(); DriveMotors dm = new DriveMotors(); // takes two numbers as a homebase // reads a color and checks if that value is in the array int[] arena = { 2, 5, 1, 4, }; int color = dc.ColorDetection(e, brick); var index = Array.IndexOf(arena, color); int Left; switch (index) { case 0: Left = 3; break; default: Left = index - 1; break; } if (homebase.Contains(color)) { if (homebase.Contains(arena[Left])) { turns.Turn90Left(brick); dm.Drive(brick); } else { turns.Turn90Right(brick); } dm.Drive(brick); } else { turns.Turn180(brick); } dm.Drive(brick); //HomeBase(dhomebase, sender, e, brick); }
void brick_BrickChanged(object sender, BrickChangedEventArgs e) { // hack to workaround XAML trying to typecast the Port dictionary to something unbindable... List <KeyValue> temp = new List <KeyValue>(); foreach (KeyValuePair <InputPort, Port> p in e.Ports) { temp.Add(new KeyValue { Key = p.Key, Value = p.Value }); } InputPorts.DataContext = temp; Buttons.DataContext = null; Buttons.DataContext = e.Buttons; }
/// <summary> /// Fires when new data comes from the lego _brick /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void Brick_BrickChanged(object sender, BrickChangedEventArgs e) { //Console.WriteLine("Brick changed!"); //Console.WriteLine(GetSensorValue()); if (_mainWindow.chckFollow.IsChecked.HasValue && _mainWindow.chckFollow.IsChecked.Value) { try { //_eegControllerMindWave.Attention await FollowBlackLine(GetSensorValue(), _eegControllerMindWave.Attention); } catch (Exception ex) { Console.WriteLine("Error while following line. Included message: {0}", ex.Message); } } }
private static void _brick_BrickChanged(object sender, BrickChangedEventArgs e) { // add offset to the measurements if (process_type == PhysicalProcessType.SEGWAY || process_type == PhysicalProcessType.INVPENDULUM) { if (measurement_offset == 0 || measurement_offset > 360 || measurement_offset < -360) { measurement_offset = e.Ports[InputPort.One].SIValue; } } EV3measurement = e.Ports[InputPort.One].SIValue - measurement_offset; Console.WriteLine("Measurement: " + EV3measurement); // local controller for debugging //updateLocalPID(); }
async void _lego_BrickChanged(object sender, BrickChangedEventArgs e) { try { //Only send if >= 2 centimeter change if (Math.Abs(_distance - (int)e.Ports[InputPort.Two].SIValue) >= 2) { _distance = (int)e.Ports[InputPort.Two].SIValue; //Send the new distance to the SignalRHub await _hubProxy.Invoke("SendUpdatedSensorData", _distance); } } catch (Exception ex) { Debug.WriteLine("exception:" + ex); } }
private void _brick_BrickChanged(object sender, BrickChangedEventArgs e) { _distanceMeasured = (int)e.Ports[InputPort.Four].SIValue; //txtDistance.Text = _distanceMeasured.ToString(); _brick.BatchCommand.Initialize(CommandType.DirectNoReply); _brick.BatchCommand.StopMotor(OutputPort.A, false); _brick.BatchCommand.StopMotor(OutputPort.D, false); _brick.BatchCommand.SendCommandAsync(); if (_distanceMeasured <= 30) { _brick.DirectCommand.StopMotorAsync(OutputPort.All, true); //StopMoving(); System.Console.WriteLine("StopMotor"); } }
void OnBrickChanged(object sender, BrickChangedEventArgs e) { Debug.WriteLine("MainWindowcs: change"); try { LblSensor1.Content = e.Ports[InputPort.One].Type; LblValue1.Content = e.Ports[InputPort.One].SIValue; LblSensor2.Content = e.Ports[InputPort.Two].Type; LblValue2.Content = e.Ports[InputPort.Two].SIValue; LblSensor3.Content = e.Ports[InputPort.Three].Type; LblValue3.Content = e.Ports[InputPort.Three].SIValue; LblSensor4.Content = e.Ports[InputPort.Four].Type; LblValue4.Content = e.Ports[InputPort.Four].SIValue; } catch (System.Exception ex) { Lbl1.Content = "Brick Disconnected"; } }
public void BrickChanged(object sender, BrickChangedEventArgs e) { DetectColor detectcolor = new DetectColor(); DHomeBase dhomebase = new DHomeBase(); DriveMotors drivemotors = new DriveMotors(); Turn turn = new Turn(); DistanceText.Text = e.Ports[InputPort.Two].SIValue.ToString(); ColorText.Text = e.Ports[InputPort.Four].SIValue.ToString(); float distance = e.Ports[InputPort.Two].SIValue; float color = e.Ports[InputPort.Four].SIValue; if (color == 1) { turn.Turn90Left(brick.brick); } else { turn.Turn90Right(brick.brick); } detectcolor.ColorDetection(e, brick.brick); if (distance > 10) { drivemotors.Stop(brick.brick); Thread.Sleep(1000); dhomebase.HomeBase(homebase, e, brick.brick); } if (distance <= 6) { drivemotors.Stop(brick.brick); Thread.Sleep(1000); dhomebase.HomeBase(homebase, e, brick.brick); } }
private async void _brick_BrickChanged(object sender, BrickChangedEventArgs e) { label2.Text = "Gyroscope Value" + e.Ports[inputPort].SIValue; if (e.Ports[inputPort].SIValue < 0) { _brick.BatchCommand.TurnMotorAtPower(OutputPort.A, 100); _brick.BatchCommand.TurnMotorAtSpeed(OutputPort.B, 95); label3.Text = "Go Right"; await _brick.BatchCommand.SendCommandAsync(); } else if (e.Ports[inputPort].SIValue > 0) { _brick.BatchCommand.TurnMotorAtPower(OutputPort.A, 95); _brick.BatchCommand.TurnMotorAtPower(OutputPort.B, 100); label3.Text = "Go Left"; await _brick.BatchCommand.SendCommandAsync(); } else if (e.Ports[inputPort].SIValue == 0) { await _brick.DirectCommand.TurnMotorAtPowerAsync(OutputPort.A | OutputPort.B, 100); label3.Text = "Go Straight"; } }
private void buttonSensor4_Click(object sender, RoutedEventArgs e) { BrickChangedEventArgs aBrickChangedEventArgs = new BrickChangedEventArgs(); textBoxReturns.Text = "Sensorwert 4 (Four): " + brick.Ports[InputPort.Four].SIValue.ToString() + Environment.NewLine + textBoxReturns.Text; }
void _lego_BrickChanged(object sender, BrickChangedEventArgs e) { txtDistance.Text = e.Ports[InputPort.Two].SIValue.ToString(); txtTouch.Text = e.Ports[InputPort.Four].SIValue.ToString(); }
public async static void brick_BrickChanged(object sender, BrickChangedEventArgs e) { }
private void Brick_BrickChanged(object sender, BrickChangedEventArgs e) { Console.WriteLine("brick changed"); Distance = e.Ports[InputPort.Four].SIValue; }
private void _brick_BrickChanged(object sender, BrickChangedEventArgs e) { Debug.WriteLine("Brick Changed!"); }
static void _brick_BrickChanged(object sender, BrickChangedEventArgs e) { System.Console.WriteLine(e.Ports[InputPort.One].SIValue); }