private void buttonCamera_Click(object sender, RoutedEventArgs e) { if (webcam == null) { webcam = new cameraControl(webcamDevice, ProcessFrame); // lepton initial List <Lepton.Handle> devices = Lepton.GetDevices(); leptonDevice = devices[0]; lepton = leptonDevice.Open(); // get color palette lepton.vid.GetPcolorLut(); foreach (object value in Enum.GetValues(typeof(Lepton.Vid.PcolorLut))) { string[] parts = Enum.GetName(typeof(Lepton.Vid.PcolorLut), value).Split(new char[] { '_' }); string result = ""; for (int i = 0; i < parts.Length - 1; i += 1) { result += " " + parts[i][0].ToString() + parts[i].Substring(1).ToLower(); } if (result != " User") { comboBoxPalette.Items.Add(result); } } comboBoxPalette.IsEnabled = true; // set default color palette to fusion comboBoxPalette.SelectedIndex = 1; lepton.vid.SetPcolorLut((Lepton.Vid.PcolorLut) 1); // radiometer initial leptonRoi = lepton.rad.GetSpotmeterRoi(); rectStart.X = leptonRoi.startCol; rectStart.Y = leptonRoi.startRow; rectEnd.X = leptonRoi.endCol; rectEnd.Y = leptonRoi.endRow; } if (captureInProgress) { buttonCamera.Content = "Camera Restart"; webcam.stopTimer(); } else { buttonCamera.Content = "Camera Stop"; webcam.startTimer(); buttonSave.IsEnabled = true; } captureInProgress = !captureInProgress; }
private string DisplayLeptonsTable() { StringBuilder str = new StringBuilder(); str.Append("LEPTONS"); str.Append("<TABLE BORDER=1 BGCOLOR=#CFCFCF STYLE='COLOR=#000000'>"); str.Append("<TR ALIGN=CENTER BGCOLOR=#AAAAAA STYLE='COLOR=#FFFFFF'>"); str.Append("<TD>SYMBOL</TD>"); str.Append("<TD>NAME</TD>"); str.Append("<TD>CHARGE</TD>"); str.Append("<TD>T<SUB>Z</SUB></TD>"); str.Append("<TD>Y<SUB>W</SUB></TD>"); str.Append("<TR>"); foreach (Particle particle in particles) { if (particle is Lepton) { Lepton p = (Lepton)particle; str.Append("<TR ALIGN=CENTER BGCOLOR=#EAEAEA>"); str.Append("<TD>" + p.Symbol + "</TD>"); str.Append("<TD>" + p.GetType().Name + "</TD>"); IInteractElectromagnetic e = p as IInteractElectromagnetic; if (e != null) { str.Append("<TD>" + e.ElectricCharge + "</TD>"); } else { str.Append("<TD>0</TD>"); } str.Append("<TD>" + p.WeakIsospin + "</TD>"); str.Append("<TD>" + p.WeakHypercharge + "</TD>"); str.Append("<TR>"); } } str.Append("</TABLE>"); return(str.ToString()); }
private void Process(Entity entity) { var pose = this.world.Registry.Get <PoseComponent>(entity); var loco = this.world.Registry.Get <DriveComponent>(entity); var position = pose.Position; var facing = pose.Facing; var speedType = loco.SpeedType; var speed = loco.Speed; var state = loco.State; var flowField = loco.FlowField; var movementVector = loco.MovementVector; var destination = loco.Destination; var currentPosition = position.V1; var nextPosition = position.V1; var currentCell = CPos.FromXPos(currentPosition); // The PreMove state determines the next cell in the path and whether the // final destination has been reached. if (state == DriveState.PreMove) { CardinalDirection dir; // destination reached -> Idle if (flowField == null || flowField.IsDestination(currentCell)) { state = DriveState.Idle; flowField = null; } // Get the next cell in the path and the movement direction and speed -> Moving else if (flowField.TryGetDirection(currentCell, out dir)) { var dirvec = dir.ToVector(); var spd = flowField.SpeedAt(currentCell, speedType, speed); movementVector = dirvec.Multiply(spd); destination = XPos.FromCell(currentCell.Translate(dirvec.X, dirvec.Y)); facing = new BinaryAngle(dir); state = DriveState.Moving; } // Destination not reached but no next cell found -> Stuck else { state = DriveState.Stuck; flowField = null; Console.WriteLine("I'm stuck!"); } } // The Moving state moves towards the destination cell at the predetermined speed, // then it will transition the state back to PreMove. if (state == DriveState.Moving) { var diff = XPos.Sub(destination, currentPosition); var contheading = true; var movlepx = Lepton.FromPixel(movementVector.X); var movlepy = Lepton.FromPixel(movementVector.Y); // reaching end of cell if (Math.Abs(diff.LeptonsX) < Math.Abs(movlepx) || Math.Abs(diff.LeptonsY) < Math.Abs(movlepy)) { // check if next cell in the path follows the same direction var dirvec = facing.CardinalDirection.ToVector(); var next = currentCell.Translate(dirvec.X, dirvec.Y); CardinalDirection nextdir; var notAtEndOfPath = flowField.TryGetDirection(next, out nextdir); contheading = notAtEndOfPath && (nextdir == facing.CardinalDirection); state = DriveState.PreMove; } if (contheading) { nextPosition = XPos.Add(currentPosition, XPos.FromLeptons(movlepx, movlepy)); } else { nextPosition = destination; } } // Write the new state to the registry. position = position.Advance(nextPosition); pose = new PoseComponent(position, facing); loco = new DriveComponent(speedType, speed, state, flowField, movementVector, destination); this.world.Registry.Set(entity, pose); this.world.Registry.Set(entity, loco); }