public static void StoreTelescopes(List <TelescopeDTO> telescopes) { using (var context = new PlanetHuntersContext()) { foreach (var t in telescopes) { if (t.Name == null || t.Location == null || t.MirrorDiameter == null) { Console.WriteLine("Invalid data format."); continue; } try { var currrentTelescope = new Telescope() { Name = t.Name, Location = t.Location, MirrorDiameter = (decimal)t.MirrorDiameter }; context.Telescopes.Add(currrentTelescope); context.SaveChanges(); Console.WriteLine($"Record {t.Name} successfully imported."); } catch (Exception ex) { if (ex is DbEntityValidationException || ex is ArgumentOutOfRangeException) { Console.WriteLine("Invalid data format."); } } } } }
public TelescopeControl() { progID = Telescope.Choose("ScopeSim.Telescope"); myTel = new Telescope(progID); myTel.SetupDialog(); myTel.Connected = true; }
public void Edit_WithNotExistingName_ShouldEditTelescope() { // Arrange StarStuffDbContext db = this.Database; TelescopeService telescopeService = new TelescopeService(db); this.SeedDatabase(db); const int telescopeId = 1; Telescope expected = new Telescope { Id = telescopeId, Name = "Test Name", Location = "Test Location", Description = "Test Description", MirrorDiameter = 55.62, ImageUrl = "Test Image Url" }; // Act telescopeService.Edit( telescopeId, expected.Name, expected.Location, expected.Description, expected.MirrorDiameter, expected.ImageUrl); Telescope actual = db.Telescopes.Find(telescopeId); // Assert this.CompareTelescopes(expected, actual); }
private void DeserializeTelescopes() { var telescopeDtos = JsonFileOperations.DeserializeJsonCollection <TelescopeDto>(Constants.TelescopeJsonFile); using (PlanetHuntersContext ctx = new PlanetHuntersContext()) { TelescopeRepo repo = new TelescopeRepo(ctx); foreach (var dto in telescopeDtos) { if (dto.Name != null && dto.Location != null) { if (dto.MirrorDiameter != null && dto.MirrorDiameter <= 0) { continue; } var t = new Telescope(); Mapper.Map(dto, t); repo.Insert(t); this.DebugLog.AppendLine($"Record {dto.Name} successfully imported."); } else { this.DebugLog.AppendLine(Constants.InvalidDataFormat); } } DbUtil.ExecTransaction(ctx); } }
public static void AddTelescopes(IEnumerable <TelescopeDto> telescopes) { using (var context = new PlanetHuntersContext()) { foreach (var telescope in telescopes) { if (telescope.Name == null || telescope.Location == null || telescope.Name.Length > Telescope.NameMaxLength || telescope.Location.Length > Telescope.LocationMaxLength || (telescope.MirrorDiameter <= Telescope.MirrorDiameterMinSize && telescope.MirrorDiameter != null)) { Console.WriteLine("Invalid data format."); } else { Telescope newTelescope = new Telescope() { Name = telescope.Name, Location = telescope.Location, MirrorDiameter = telescope.MirrorDiameter }; context.Telescopes.Add(newTelescope); Console.WriteLine($"Record {telescope.Name} successfully imported."); } } context.SaveChanges(); } }
public static void AddTelescopes(IEnumerable <TelescopesDto> telescopesDtos) { Console.WriteLine("Storing <Telescopes> data in DB ..."); using (PlanetHuntersContext context = new PlanetHuntersContext()) { foreach (TelescopesDto telescopeDto in telescopesDtos) { double telescopeMirrorDiamDouble = telescopeDto.MirrorDiameter == null ? 0 : telescopeDto.MirrorDiameter.Value; if (telescopeDto.Name == null || telescopeDto.Location == null || !(telescopeMirrorDiamDouble > 0.0)) { Console.WriteLine("ERROR: Invalid data format."); } else { Telescope telescope = new Telescope() { Name = telescopeDto.Name, Location = telescopeDto.Location, MirrorDiameter = telescopeMirrorDiamDouble }; context.Telescopes.Add(telescope); Console.WriteLine($"Record {telescope.Name} successfully imported."); } } context.SaveChanges(); } Console.WriteLine("<Telescopes> table stored!"); }
private void buttonChooseMount_Click(object sender, EventArgs e) { _mountId = Telescope.Choose(_mountId); UpdateAscomDeviceLabels(); Properties.Settings.Default["MountId"] = _mountId; Properties.Settings.Default.Save(); }
private void btnSelect_Click(object sender, EventArgs e) { try { Chooser choose = new Chooser(); choose.DeviceType = "Telescope"; string ProgId = choose.Choose(progId); if (ProgId != "") { if (Driver != null) { Driver.Dispose(); } Driver = new Telescope(ProgId); btnSetup.Enabled = true; nameTextBox.Text = Driver.Name; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <bool> Sync(Coordinates coordinates) { try { var transform = coordinates.Transform(TelescopeInfo.EquatorialSystem); if (!profileService.ActiveProfile.TelescopeSettings.NoSync && TelescopeInfo.Connected) { progress.Report(new ApplicationStatus() { Status = Locale.Loc.Instance["LblSync"] }); bool result = Telescope.Sync(transform); await Task.Delay(TimeSpan.FromSeconds(Math.Max(2, profileService.ActiveProfile.TelescopeSettings.SettleTime))); return(result); } else { return(false); } } finally { progress.Report(new ApplicationStatus() { Status = string.Empty }); } }
public SetupDialogForm(Telescope telescope) { InitializeComponent(); // Initialise current values of user settings from the ASCOM Profile InitUI(); // If we're already connected if (telescope != null) { ts = telescope; textBoxLatitude.ReadOnly = false; textBoxLatitude.Text = new ASCOM.Utilities.Util().DegreesToDMS(ts.SiteLatitude); textBoxLongitude.ReadOnly = false; textBoxLongitude.Text = new ASCOM.Utilities.Util().DegreesToDMS(ts.SiteLongitude); textBoxGuideSpeed.ReadOnly = false; textBoxGuideSpeed.Text = (ts.GuideRateRightAscension / Telescope.sidereal_speed).ToString(); buttonSyncTime.Enabled = true; // COM port cannot be changed when connected comboBoxComPort.Enabled = false; } else { textBoxLatitude.Text = ""; textBoxLongitude.Text = ""; textBoxGuideSpeed.Text = ""; } }
/// <inheritdoc/> public string Connect(string telescopeId) { try { lock (locker) { string id = Telescope.Choose(telescopeId); if (!string.IsNullOrEmpty(id)) { DoDisconnect(); telescope = new Telescope(id); telescope.Connected = true; NotifyPropertyChanged(nameof(IsConnected)); RaiseOnMessageShow(Text.Get("Ascom.Messages.Connected", ("telescopeName", telescope.Name))); watcherResetEvent.Set(); } return(id); } } catch (Exception ex) { RaiseOnMessageShow("$Ascom.Messages.UnableChoose"); Trace.TraceError($"Unable to choose telescope: {ex}"); return(null); } }
/// <summary> /// Does disconnecting logic /// </summary> private void DoDisconnect() { if (telescope != null) { telescope.Connected = false; if (!telescope.Connected) { watcherResetEvent.Reset(); } else { Trace.TraceWarning($"Unable to disconnect."); } try { telescope.Dispose(); } catch { } telescope = null; Position.Alpha = 0; Position.Delta = 0; NotifyPropertyChanged(nameof(IsConnected)); NotifyPropertyChanged(nameof(IsSlewing)); NotifyPropertyChanged(nameof(AtHome)); NotifyPropertyChanged(nameof(AtPark)); NotifyPropertyChanged(nameof(IsTracking)); } }
public void All_ShouldReturnValidTelescopes() { // Arrange StarStuffDbContext db = this.Database; TelescopeService telescopeService = new TelescopeService(db); this.SeedDatabase(db); const int page = 2; const int pageSize = 5; List <Telescope> fakeTelescopes = this.GetFakeTelescopes() .OrderBy(t => t.MirrorDiameter) .Skip((page - 1) * pageSize) .Take(pageSize) .ToList(); int i = -1; // Act IEnumerable <ListTelescopesServiceModel> telescopes = telescopeService.All(page, pageSize); // Assert foreach (var actual in telescopes) { Telescope expected = fakeTelescopes[++i]; this.CompareTelescopes(expected, actual); } }
private void CompareTelescopes(Telescope expected, ListTelescopesServiceModel actual) { Assert.Equal(expected.Id, actual.Id); Assert.Equal(expected.Name, actual.Name); Assert.Equal(expected.Description, actual.Description); Assert.Equal(expected.ImageUrl, actual.ImageUrl); }
public void UnparkTelescope() { if (Telescope.Connected && Telescope.CanUnpark && Telescope.AtPark) { Telescope.Unpark(); } }
public void PulseGuide(GuideDirections direction, int duration) { if (TelescopeInfo.Connected) { Telescope.PulseGuide(direction, duration); } }
private static void ImportTelescopes(SystemContext context) { var json = File.ReadAllText("../../Import/Json/telescopes.json"); var telescopes = JsonConvert.DeserializeObject <List <TelescopeDto> >(json); foreach (var telescope in telescopes) { if (telescope.Location != null && telescope.Name != null && telescope.MirrorDiameter > 0.0) { Telescope t = new Telescope() { Name = telescope.Name, Location = telescope.Location, MirrorDiameter = telescope.MirrorDiameter }; context.Telescopes.Add(t); Console.WriteLine($"Record {telescope.Name} successfully imported."); } else { Console.WriteLine("Invalid data format."); } } context.SaveChanges(); }
/// <inheritdoc/> public Task <string> Connect(string telescopeId) { return(Task.Run(() => { try { bool needShowMessage = false; string id = null; lock (locker) { id = Telescope.Choose(telescopeId); if (!string.IsNullOrEmpty(id)) { DoDisconnect(); telescope = new Telescope(id); telescope.Connected = true; IsConnected = true; needShowMessage = true; watcherResetEvent.Set(); } } if (needShowMessage) { RaiseOnMessageShow(Text.Get("Ascom.Messages.Connected", ("telescopeName", telescope.Name))); } return id; } catch (Exception ex) { RaiseOnMessageShow("$Ascom.Messages.UnableChoose"); Log.Error($"Unable to choose telescope: {ex}"); return null; } })); }
public int Create( string name, string location, string description, double mirrorDiameter, string imageUrl) { if (this.Exists(name)) { return(-1); } Telescope telescope = new Telescope { Name = name, Location = location, Description = description, MirrorDiameter = mirrorDiameter, ImageUrl = imageUrl }; this.db.Telescopes.Add(telescope); this.db.SaveChanges(); return(telescope.Id); }
public bool Edit( int id, string name, string location, string description, double mirrorDiameter, string imageUrl) { Telescope telescope = this.db.Telescopes.Find(id); if (telescope == null || (telescope.Name != name && this.Exists(name))) { return(false); } telescope.Name = name; telescope.Location = location; telescope.Description = description; telescope.MirrorDiameter = mirrorDiameter; telescope.ImageUrl = imageUrl; this.db.SaveChanges(); return(true); }
private static void ImportTelescopes(PlanetHunterContext context) { var json = File.ReadAllText("../../datasets/telescopes.json"); var telescopes = JsonConvert.DeserializeObject <ICollection <TelescopesDTO> >(json); using (context) { foreach (var telescope in telescopes) { if (telescope.MirrorDiameter <= 0 || telescope.Name == null || telescope.Location == null) { Console.WriteLine("Invalid data format."); continue; } var tel = new Telescope { Name = telescope.Name, Location = telescope.Location, MirrorDiameter = telescope.MirrorDiameter }; context.Telescopes.Add(tel); Console.WriteLine($"Record {telescope.Name} successfully imported."); } context.SaveChanges(); } }
public static void AddTelescopes(List <TelescopeDTO> telescopes) { using (var ctx = new PlanetHunterContext()) { foreach (var telescopeDTO in telescopes) { if (telescopeDTO.Name != null && telescopeDTO.Name != null) { if (telescopeDTO.MirrorDiameter < 0) { telescopeDTO.MirrorDiameter = null; } if (telescopeDTO.MirrorDiameter == 0) { telescopeDTO.MirrorDiameter = null; } var telescope = new Telescope() { Location = telescopeDTO.Location, MirrorDiameter = telescopeDTO.MirrorDiameter, Name = telescopeDTO.Name }; ctx.Telescopes.Add(telescope); Console.WriteLine($"Record {telescope.Name} successfully imported."); ctx.SaveChanges(); } else { Console.WriteLine("Error. Invalid data provided."); } } } }
public static Telescope Factory(string hero) { Telescope telescope = Telescope.Factory(); GameManager.instance.findHero(hero).heroInventory.AddItem(telescope); return(telescope); }
public static void Buy() { Hero hero = GameManager.instance.MainHero; int cost = 2; if (hero.timeline.Index != 0) { if (hero.heroInventory.numOfGold >= cost) { Telescope toAdd = Telescope.Factory(); if (hero.heroInventory.AddSmallToken(toAdd)) { hero.heroInventory.RemoveGold(cost); } else { return; } } else { EventManager.TriggerError(0); return; } } else { EventManager.TriggerError(2); return; } }
public static Telescope Factory(int cellID) { Telescope telescope = Telescope.Factory(); telescope.Cell = Cell.FromId(cellID); return(telescope); }
public void CreateDevice(string id) { if (Initialized) { throw new Exception("The telescope service attempted to re-initialize the telescope."); } if (Telescope == null) { if (String.IsNullOrEmpty(id)) { throw new Exception("The telescope service is unable to create a telescope until a Telescope has been chosen."); } DeviceID = id; try { Telescope = new Telescope(DeviceID); Initialized = true; } catch (Exception xcp) { throw new Exception("Unable to create the Telescope object", xcp); } } }
public void MoveAxis(TelescopeAxes axis, double rate) { if (TelescopeInfo.Connected) { Telescope.MoveAxis(axis, rate); } }
public static Telescope Factory() { GameObject telescopeGO = PhotonNetwork.Instantiate("Prefabs/Tokens/Telescope", Vector3.zero, Quaternion.identity, 0); Telescope telescope = telescopeGO.GetComponent <Telescope>(); telescope.Cell = null; return(telescope); }
private static Func <float> AlterProgBar(Func <float> originalFunc, Telescope instance) { if (IsEndlessWorking(instance)) { return(() => instance.worker.GetComponent <AttributeLevels>().GetPercentComplete("Learning")); } return(originalFunc); }
private void CompareTelescopes(Telescope expected, TelescopeFormServiceModel actual) { Assert.Equal(expected.Name, actual.Name); Assert.Equal(expected.Location, actual.Location); Assert.Equal(expected.Description, actual.Description); Assert.Equal(expected.MirrorDiameter, actual.MirrorDiameter); Assert.Equal(expected.ImageUrl, actual.ImageUrl); }
public ASCOM_Telescope() { progID = Telescope.Choose("ScopeSim.Telescope"); if (progID != "") { _telescope = new Telescope(progID); _telescope.Connected = true; } else { } }
//private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); static void Main(string[] args) { NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); Console.WriteLine("\r\nTelescope:"); logger.Debug("Starting application"); Telescope T; string ProgId = Telescope.Choose(""); if (ProgId != "") { T = new Telescope(ProgId); //VXAscom.SetupDialogForm F = new VXAscom.SetupDialogForm(); //T.SetupDialog(); Console.WriteLine(" {0}", T.Connected); T.Connected = true; } //Console.WriteLine(" Current LST = " + T.SiderealTime); //IAxisRates AxR = T.AxisRates(TelescopeAxes.axisPrimary); //Console.WriteLine(" " + AxR.Count + " rates"); //if (AxR.Count == 0) // Console.WriteLine(" Empty AxisRates!"); //else // foreach (IRate r in AxR) // Console.WriteLine(" Max=" + r.Maximum + " Min=" + r.Minimum); //ITrackingRates TrR = T.TrackingRates; //if (TrR.Count == 0) // Console.WriteLine(" Empty TrackingRates!"); //else // foreach (DriveRates dr in TrR) // Console.WriteLine(" DriveRate=" + dr); //Console.Write("\r\nPress enter to quit..."); //Console.ReadLine(); }
private void Chooser() { ASCOM.Utilities.Chooser chooser = new ASCOM.Utilities.Chooser(); chooser.DeviceType = "Telescope"; devId = chooser.Choose(); if (devId != "") scope = new ASCOM.DriverAccess.Telescope(devId); else return; // ASCOM.DriverAccess.Telescope scope = new ASCOM.DriverAccess.Telescope(devId); Log("connected to " + devId); FileLog2("connected to " + devId); scope.Connected = true; if (scope.Connected) { timer2.Enabled = true; timer2.Start(); } usingASCOM = true; button49.BackColor = System.Drawing.Color.Lime; // button49.Text = "Connected"; }