public Tsp(int numberOfCities, PositionSelection positionSelection = PositionSelection.Random) { cities = new List<City>(); for (int i = 0; i < numberOfCities; i++) { PointF position; if (positionSelection == PositionSelection.Random) { RandomGenerator rnd = RandomGenerator.GetInstance(); position = new PointF((float) rnd.NextDouble(), (float) rnd.NextDouble()); } else { double angle = (float) (Math.PI*2/numberOfCities*i); position = new PointF((float) (Math.Sin(angle)*CIRCLE_RADIUS + 0.5), (float) (Math.Cos(angle)*CIRCLE_RADIUS + 0.5)); } cities.Add(new City(((char) ("A"[0] + i)).ToString(), position)); } BuildEngine(); }
private void RefreshProgress() { try { _putAwayRack = RackSelection.Text; _putAwayShelf = ShelfSelection.Text; if (string.IsNullOrEmpty(_putAwayShelf)) { ShelfSelection.Focus(); return; } _putAwayPosition = PositionSelection.Text; if (string.IsNullOrEmpty(_putAwayPosition)) { PositionSelection.Focus(); return; } using (var ppTA = new PhysicalProgressTableAdapter()) { uxGridProgress.DataSource = ppTA.GetCycleCountProgressByAddress(Plant, _putAwayRack, _putAwayShelf, _putAwayPosition); } using (var ppsTA = new PhysicalProgressSummaryTableAdapter()) { var ppsDT = ppsTA.GetCycleCountProgressSummary(Plant, _putAwayRack, _putAwayShelf, _putAwayPosition); switch (ppsDT.Rows.Count) { case 1: uxLabelProgress.Text = ppsDT[0].FoundCount + " Found, " + ppsDT[0].MissingCount + " Missing, " + ppsDT[0].TotalCount + " Total"; break; default: throw new Exception("Unable to retrieve summary."); } } } catch (SqlException ex) { foreach (SqlError sqlErr in ex.Errors) { MessageBox.Show(sqlErr.Message); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected override void OnInitialized() { var positionsResult = _posService.GetPositions(); if (positionsResult.Successful) { positions = positionsResult.Data; } if (PositionSelection.Count() == 0) { foreach (var position in positions) { PositionSelection.Add(position.Id, new PositionSelection { PositionWasSelected = false }); } } }
private int TryProcessSerial(Int32 boxSerial) { try { // Verify that shelf and subshelf are selected. _putAwayRack = RackSelection.Text; _putAwayShelf = ShelfSelection.Text; if (string.IsNullOrEmpty(_putAwayShelf)) { ShelfSelection.Focus(); throw new Exception("Shelf not selected."); } _putAwayPosition = PositionSelection.Text; if (string.IsNullOrEmpty(_putAwayPosition)) { PositionSelection.Focus(); throw new Exception("Subshelf not selected."); } // Scan object to location. using (var ppTA = new PhysicalProgressTableAdapter()) { DateTime?tranDT = null; Int32? result = null; ppTA.ScanSerial(OperatorCode, boxSerial, Plant, _putAwayRack, _putAwayShelf, _putAwayPosition, ref tranDT, ref result); } // Refresh screen and find row. using (var wiTA = new WarehouseInventoryTableAdapter()) { var wiDT = wiTA.GetInventoryBySerial(boxSerial); switch (wiDT.Rows.Count) { case 1: uxLabelMessage.Text = "Serial " + boxSerial + " Part " + wiDT[0].Part; break; default: throw new Exception("Part not found!"); } } RefreshProgress(); return(1); } catch (SqlException ex) { foreach (SqlError sqlErr in ex.Errors) { MessageBox.Show(sqlErr.Message); } return(-1); } catch (Exception ex) { uxLabelMessage.Text = ex.Message; const int DURATION = 1500; //millisec const int FREQUENCY = 2670; //hz try { _myAudioController.PlayAudio(DURATION, FREQUENCY); //play Default beep } catch { MessageBox.Show("PlayAudio failed. Speaker may not be present", "PlayAudio"); } return(-1); } }