/** * Setup the bullet */ public void Setup(Vector3 targetPosition, float speed, float damages, Focuser shooter) { _speed = speed; _damages = damages; _shooter = shooter; _direction = (targetPosition - transform.position).normalized; }
/** * Damage the entity of the given amount */ public void Damage(Focuser source, float amount) { _healthSystem.Damage(amount); if (GetHealth() <= 0f) { if (source.GetComponent <Entity>()) { source.GetComponent <Entity>().AddKill(1); } if (this == EntityManager.GetFocusedEntity() && _isLowHealthSoundPlaying) { SoundManager.StopLowHealthSound(EntityManager.GetFocusedEntity().GetName()); } EntityManager.Remove(this); SoundManager.PlayDeadSound(transform.position, .5f); Destroy(gameObject); } // Trigger damage sound SoundManager.PlayDamageSound(GetArmor() > 0f, transform.position, .5f); StopCoroutine(PlayDamageAnimation()); StartCoroutine(PlayDamageAnimation()); }
public GameFrame(Focuser _focuser, Location l, Character _player) : base(l, _player, new List <GameAction>(), String.Format("[{0}]", l.Name), null, true, null) { RepeatCondition = () => !QuitGame; Focuser = _focuser; AddAction( new CallbackAction( "Move", "Control your movement.", Player.Body, (action) => { Focuser.IntroduceFrame( new MovementFrame(l, Player) ); } ) ); AddAction( new CallbackAction( "Interact", "Manipulate your surroundings.", Player.Body, (action) => { Focuser.IntroduceFrame( new MovementFrame(l, Player) ); } ) ); AddAction( new CallbackAction( "Use Item", "Utilize an item from your inventory.", Player.Body, (action) => { Focuser.IntroduceFrame( new MovementFrame(l, Player) ); } ) ); AddAction( new CallbackAction( "Game Options", "View Game Options.", Player.Body, (action) => { Focuser.IntroduceFrame( new MovementFrame(l, Player) ); } ) ); }
/** * Add the picked ingestible to the interacting entity inventory */ protected override void Pickup(Focuser focuser) { if (_focuserInventory.Add(this)) { gameObject.SetActive(false); base.Pickup(focuser); } }
/** * Add the picked weapon to the interacting entity inventory */ protected override void Pickup(Focuser focuser) { if (!_isThrown && !_isCarried) { base.Pickup(focuser); Destroy(GetComponent <Rigidbody>()); } }
public void InterfaceVersion() { debug.WriteLine($"InterfaceVersion => Device[{DriverType}][{DeviceName}]"); Focuser device = CreateDevice <Focuser>(DriverType, DeviceName); var info = device.InterfaceVersion; Assert.IsNotNull(info, "Verify data returned"); debug.WriteLine($"\t{info}"); }
public void DriverInfo() { debug.WriteLine($"DriverInfo => Device[{DriverType}][{DeviceName}]"); Focuser device = CreateDevice <Focuser>(DriverType, DeviceName); var info = device.DriverInfo; Assert.IsNotNull(info, "Verify data returned"); debug.WriteLine($"\t{info}"); }
private void StopHelperProcesses() { try { Focuser.Kill(); } catch (Exception err) { } }
public void PushBundle(Focuser focuser, GameEventArgument args) { do { focuser.PushFrame(new FrameMeta(PushedFrames[PushedIndex], args)); focuser.PopFrame(); PushedIndex++; }while (PushedIndex < PushedFrames.Length); }
public void SupportedActions() { debug.WriteLine($"SupportedActions => Device[{DriverType}][{DeviceName}]"); Focuser device = CreateDevice <Focuser>(DriverType, DeviceName); var info = device.SupportedActions.ToStrings(); Assert.IsNotNull(info, "Verify data returned"); foreach (var item in info) { debug.WriteLine($"\t{item}"); } }
private void HaltFocuser() { Logger.Info("Halting Focuser"); if (Focuser?.Connected == true) { try { Focuser.Halt(); } catch (Exception ex) { Logger.Error(ex); } } }
public async Task <int> MoveFocuser(int position, CancellationToken ct) { int pos = -1; await Task.Run(async() => { try { using (ct.Register(() => HaltFocuser())) { var tempComp = false; if (Focuser.TempCompAvailable && Focuser.TempComp) { tempComp = true; ToggleTempComp(false); } Logger.Info($"Moving Focuser to position {position}"); progress.Report(new ApplicationStatus() { Status = string.Format(Locale.Loc.Instance["LblFocuserMoveToPosition"], position) }); while (Focuser.Position != position) { FocuserInfo.IsMoving = true; ct.ThrowIfCancellationRequested(); await Focuser.Move(position, ct); } FocuserInfo.Position = this.Position; pos = this.Position; ToggleTempComp(tempComp); BroadcastFocuserInfo(); //Wait for focuser to settle if (profileService.ActiveProfile.FocuserSettings.FocuserSettleTime > 0) { FocuserInfo.IsSettling = true; await Utility.Utility.Wait(TimeSpan.FromSeconds(profileService.ActiveProfile.FocuserSettings.FocuserSettleTime), ct, progress, Locale.Loc.Instance["LblSettle"]); } } } catch (OperationCanceledException) { } finally { FocuserInfo.IsSettling = false; FocuserInfo.IsMoving = false; progress.Report(new ApplicationStatus() { Status = string.Empty }); } }); return(pos); }
public DamageEventArgument( LocationObjectBearing _locationObjectBearing, GameObject _invokee, GameObject[] _targets, Focuser _focuser, EnviromentFrame _frame, double _amount, DamageType _damageType, bool _trueDamage = false) : base(_locationObjectBearing, _invokee, _targets, _focuser, _frame) { SetValues(_amount, _damageType, _trueDamage); }
public async Task Disconnect() { if (updateTimer != null) { await updateTimer.Stop(); } Focuser?.Disconnect(); Focuser = null; FocuserInfo = DeviceInfo.CreateDefaultInstance <FocuserInfo>(); BroadcastFocuserInfo(); RaisePropertyChanged(nameof(Focuser)); Logger.Info("Disconnected Focuser"); }
static void Main(string[] args) { try { var progId = Focuser.Choose(string.Empty); var driver = new Focuser(progId); var thing = driver.IsMoving; // Just to give a place to set a breakpoint. driver.SetupDialog(); while (Console.ReadLine() != "e") { driver.Link = true; driver.TempComp = true; Console.WriteLine("In temp comp mode"); Console.WriteLine("IsMoving = " + driver.IsMoving.ToString()); Console.WriteLine("Moving to 3500..."); try{ driver.Move((int)3500); } catch{ Console.WriteLine("Exception thrown as expected!"); } driver.TempComp = false; Console.WriteLine("Moving to 3500..."); driver.Move((int)3500); Console.WriteLine("IsMoving = " + driver.IsMoving.ToString()); Console.WriteLine("Current Position = " + driver.Position.ToString()); Console.WriteLine("Moving to 1000..."); driver.Move((int)1000); Console.WriteLine("IsMoving = " + driver.IsMoving.ToString()); Console.WriteLine("Current Position = " + driver.Position.ToString()); Console.WriteLine("Moving to 3000..."); driver.Move((int)3000); Console.WriteLine("IsMoving = " + driver.IsMoving.ToString()); Console.WriteLine("Current Position = " + driver.Position.ToString()); while (driver.IsMoving) { } driver.Link = false; Console.WriteLine("Current Position = " + driver.Position.ToString()); Console.WriteLine("IsMoving = " + driver.IsMoving.ToString()); Console.WriteLine("Press ESC key to exit"); } //Console.ReadLine(); } catch (Exception ex) { EventLogger.LogMessage(ex); Debug.Print(ex.Message); } }
private void Window_Deactivated(object sender, EventArgs e) { MainWindow window = (MainWindow)sender; if (window.ShouldStealFocus) { window.Topmost = true; Focuser.Start(); } else { window.Topmost = false; } }
public void Disconnect() { debug.WriteLine($"Disconnect => Device[{DriverType}][{DeviceName}]"); Focuser device = CreateDevice <Focuser>(DriverType, DeviceName); if (!device.Connected) { debug.WriteLine($"Device[{DriverType}][{DeviceName}]: not connected, Connecting"); device.Connected = true; Assert.IsTrue(device.Connected, "Verify connect completed"); } device.Connected = false; Assert.IsFalse(device.Connected, "Verify connect completed"); }
/** * Use the item */ public override bool Use(Pickable pickable) { Focuser user = pickable.GetFocuser(); if (user == null) { return(false); } Initialize(); Consume(pickable); SoundManager.PlayIngestibleSound(user.transform.position, .6f); return(true); }
//急停 public void FocuserStop() { try { if (m_focuser != null && m_focuser.Connected == true) { m_focuser.Halt(); } } catch (System.Exception ex) { m_focuser = null; m_focParams.errMsg = ex.Message; } }
//日志记录 public void FocuserLog() { try { if (null != m_focuser && m_focuser.Connected == true) { //保存数据到文件,主要是温度和位置 } } catch (System.Exception ex) { m_focuser = null; m_focParams.errMsg = ex.Message; } }
/** * Add the picked weapon to the interacting entity inventory */ protected override void Pickup(Focuser focuser) { if (_isCarried) { return; } if (!_focuserInventory.Add(this)) { return; } gameObject.SetActive(false); _isCarried = true; base.Pickup(focuser); }
/** * Consume the ingestible */ protected override void Consume(Pickable pickable) { Focuser user = pickable.GetFocuser(); if (user == null) { return; } if (user is ICanModify == false) { return; } ((ICanModify)user).SetHealthModifier(_modifier); }
//指定位置移动 public void FocuserMoveToPos(double targetPos) { try { targetPos *= 1000; targetPos = System.Math.Round(targetPos); if (m_focuser != null && m_focuser.Connected == true) { m_focuser.Move((int)targetPos); } } catch (System.Exception ex) { m_focuser = null; m_focParams.errMsg = ex.Message; } }
void OnEnable() { Camera mainCam = Camera.main; // get a reference now so even if the new Camera gets elected to be main, we have a reference the actual Camera we want to be main focuser = (Focuser)target; camGO = EditorUtility.CreateGameObjectWithHideFlags("z!!!!!!!!!!!!!!SHOULDN'T STILL BE IN SCENE!!!!!!!!!!!!!!!!!", HideFlags.HideAndDontSave); previewCam = camGO.AddComponent <Camera>(); previewCam.CopyFrom(mainCam); previewCam.tag = "Untagged"; previewPlayer = EditorUtility.CreateGameObjectWithHideFlags("z!!!!!!!!!!!!!!SHOULDN'T STILL BE IN SCENE!!!!!!!!!!!!!!!!!", HideFlags.HideAndDontSave); SpriteRenderer s = previewPlayer.AddComponent <SpriteRenderer>(); s.sprite = previewPlayerSprite; startPos = focuser.transform.position - Vector3.down * 10; }
public T CreateDeviceInstance <T>(DeviceConfiguration configuration) where T : IDevice { Type deviceType = typeof(T); switch (deviceType.Name) { case nameof(FilterWheel): IDevice device = new FilterWheel(configuration, _clientTransactionIdGenerator); return((T)device); case nameof(SafetyMonitor): IDevice safetyMonitor = new SafetyMonitor(configuration, _clientTransactionIdGenerator); return((T)safetyMonitor); case nameof(Dome): IDevice dome = new Dome(configuration, _clientTransactionIdGenerator); return((T)dome); case nameof(Camera): IDevice camera = new Camera(configuration, _clientTransactionIdGenerator); return((T)camera); case nameof(Focuser): IDevice focuser = new Focuser(configuration, _clientTransactionIdGenerator); return((T)focuser); case nameof(ObservingConditions): IDevice observingConditions = new ObservingConditions(configuration, _clientTransactionIdGenerator); return((T)observingConditions); case nameof(Rotator): IDevice rotator = new Rotator(configuration, _clientTransactionIdGenerator); return((T)rotator); case nameof(Switch): IDevice @switch = new Switch(configuration, _clientTransactionIdGenerator); return((T)@switch); case nameof(Telescope): IDevice telescope = new Telescope(configuration, _clientTransactionIdGenerator); return((T)telescope); default: throw new InvalidOperationException($"Type {deviceType.Name} is not supported"); } }
private void ConnectButton_Click(object sender, EventArgs e) { if (ConnectButton.Text == "Connect" && _progID != "") { if (_focuser == null) { _focuser = new Focuser(_progID); } _focuser.Link =true; ConnectButton.Text = "Disconnect"; } else { _focuser.Link = false; ConnectButton.Text = "Connect"; } }
private void ConnectButton_Click(object sender, EventArgs e) { if (ConnectButton.Text == "Connect" && _progID != "") { if (_focuser == null) { _focuser = new Focuser(_progID); } _focuser.Link = true; ConnectButton.Text = "Disconnect"; } else { _focuser.Link = false; ConnectButton.Text = "Connect"; } }
//步长移动 public void FocuserStepMove(double step) { try { int curPos = 0; step *= 1000; if (m_focuser != null && m_focuser.Connected == true) { curPos = m_focuser.Position; m_focuser.Move(curPos + (int)step); } } catch (System.Exception ex) { m_focuser = null; m_focParams.errMsg = ex.Message; } }
//设置温度补偿 public void SetTempComp(bool tempComp) { try { if (null != m_focuser && m_focuser.Connected == true) { if (m_focuser.TempCompAvailable) { m_focuser.TempComp = tempComp; } } } catch (System.Exception ex) { m_focuser = null; m_focParams.errMsg = ex.Message; } }
/** * Use the item */ public override bool Use(Pickable pickable) { Focuser user = pickable.GetFocuser(); if (user == null) { return(false); } if (user is ICanEquip <Weapon> == false) { return(false); } ((ICanEquip <Weapon>)user).Equip((Weapon)pickable); SoundManager.PlaySelectWeaponSound(user.transform.position); return(true); }
//连接ASCOM驱动接口,启动ASA自带控制程序 public void ConnectDevice() { try { if (m_focuser == null) { //从配置文件获取Focuser ID //TBD m_deviceID = "ACCServer.Focuser"; if (m_deviceID == "") { m_deviceID = Focuser.Choose("ACCServer.Focuser"); if (m_deviceID == null || m_deviceID == "") { m_focParams.errMsg = "Can not find \'ACCServer.Focuser\' in ASCOM driver"; Debug.Write(m_focParams.errMsg); } else { //保存调焦器名称到配置文件 //TBD m_focuser = new Focuser(m_deviceID); m_focParams.connected = true; } } else { m_focuser = new Focuser(m_deviceID); m_focParams.connected = true; } } //else if (m_focuser.Dispose()) //{ // //断开后再连接 // m_focuser = new Focuser(m_deviceID); // m_focParams.connected = true; //} } catch (System.Exception ex) { m_focParams.connected = false; m_focParams.errMsg = ex.Message; } }
public IFocuserV3Ex GetFocuser(string focuserId, bool connect) { var ascomFocuser = new Focuser(focuserId); if (connect) { ascomFocuser.Connected = true; } if (ascomFocuser.Absolute) { Logger.Debug($"Absolute ASCOM Focuser detected {focuserId}"); return(new AbsoluteAscomFocuser(ascomFocuser)); } else { Logger.Debug($"Relative ASCOM Focuser detected {focuserId}"); return(new RelativeAscomFocuser(ascomFocuser)); } }
public Firmware_Upgrade_Assistant(Focuser focuser) { InitializeComponent(); myFocuser = focuser; clsds30Loader.Writeing += new clsds30Loader.WriteingDelegate(clsds30Loader_Writeing); }
private void Form1_Load(object sender, EventArgs e) { try { // Set the view menu checked states positionAndTemperatureToolStripMenuItem.Checked = Properties.Settings.Default.DisplayPositionAndTemperature; relativeFocusAdjustToolStripMenuItem.Checked = Properties.Settings.Default.DisplayRelativeFocusAdjust; temperatureCompensationToolStripMenuItem.Checked = Properties.Settings.Default.DisplayTempComp; absoluteFocusAdjustToolStripMenuItem.Checked = Properties.Settings.Default.DisplayAbsoluteFocusAdjust; relativeFocusOffsetsToolStripMenuItem.Checked = Properties.Settings.Default.DisplayRelativeFocusOffsets; absoluteFocusPresetsToolStripMenuItem.Checked = Properties.Settings.Default.DisplayAbsoluteFocusPresets; if (Properties.Settings.Default.Focuser2Disabled) { //Only Focuser 1 is disabled if (Properties.Settings.Default.SwitchF1F2) Foc1_CHK.Checked = !Properties.Settings.Default.Focuser2Disabled; //Only Focuser 2 is disabled else Foc2_CHK.Checked = !Properties.Settings.Default.Focuser2Disabled; } //Both are enabled else { Foc1_CHK.Checked = !Properties.Settings.Default.Focuser2Disabled; Foc2_CHK.Checked = !Properties.Settings.Default.Focuser2Disabled; } // hook up the view item checked_changed events positionAndTemperatureToolStripMenuItem.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged); relativeFocusAdjustToolStripMenuItem.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged); temperatureCompensationToolStripMenuItem.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged); absoluteFocusAdjustToolStripMenuItem.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged); relativeFocusOffsetsToolStripMenuItem.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged); absoluteFocusPresetsToolStripMenuItem.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged); Foc1_CHK.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged); Foc2_CHK.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged); alwaysOnTopToolStripMenuItem.CheckedChanged += new EventHandler(alwaysOnTopToolStripMenuItem_CheckedChanged); alwaysOnTopToolStripMenuItem.Checked = Properties.Settings.Default.AlwaysOnTop; // We do this after so the change takes affect now... // adjust form height for user preferences setFormHeight(); if (!Properties.Settings.Default.SwitchF1F2) { EventLogger.LogMessage("Creating 2 ASCOM driver focuser objects", TraceLevel.Info); myFoc1 = new ASCOM.DriverAccess.Focuser("ASCOM.FocusLynx.Focuser"); myFoc2 = new ASCOM.DriverAccess.Focuser("ASCOM.FocusLynx2.Focuser"); } else { EventLogger.LogMessage("Creating 2 ASCOM driver focuser objects", TraceLevel.Info); myFoc1 = new ASCOM.DriverAccess.Focuser("ASCOM.FocusLynx2.Focuser"); myFoc2 = new ASCOM.DriverAccess.Focuser("ASCOM.FocusLynx.Focuser"); } F1LastConnectedState = !myFoc1.Link; // Set these to the opposite so that controls are immediatly refreshed. F2LastConnectedState = !myFoc2.Link; } catch (Exception ex) { EventLogger.LogMessage("An error occurred while creating instances of Focuser Hub ASCOM Driver. " + ex.Message, TraceLevel.Error); CustomErrorBox error = new CustomErrorBox("An error occurred while creating the initial instances of the FocusLynx ASCOM Driver." + " The program cannot continue. Please contact technical support.", ex.Message); error.ShowDialog(); Application.Exit(); } LoadFocusOffsets_F1(); LoadFocusPresets_F1(); LoadFocusOffsets_F2(); LoadFocusPresets_F2(); setFormWidth(); //setFormHeight(); Automatically occurs. }
private void swapFocusers() { ASCOM.DriverAccess.Focuser temp = myFoc1; myFoc1 = myFoc2; myFoc2 = temp; }
public void FocusChooser() { ASCOM.Utilities.Chooser chooser = new ASCOM.Utilities.Chooser(); chooser.DeviceType = "Focuser"; devId2 = chooser.Choose(); // ASCOM.DriverAccess.Focuser focuser = new ASCOM.DriverAccess.Focuser(devId2); if (devId2 != "") focuser = new Focuser(devId2); else return; focuser.Connected = true; //***************** I think this needs to be changes so it SETs the value not GETs*************** //go back to previous method for storing the maxtravel in settings, then when gets it //after selecting equipement it sets the value. //**************************************************************************************** travel = focuser.MaxStep; textBox2.Text = travel.ToString(); count = focuser.Position; textBox1.Text = count.ToString(); Log("connected to " + devId2); FileLog2("connected to " + devId2); button8.BackColor = System.Drawing.Color.Lime; // button8.Text = "Connected"; /* if (focuser.Connected) { MessageBox.Show("ASCOM Focuser connected"); } */ numericUpDown6.Value = focuser.Position; usingASCOMFocus = true; // focuser.CommandString("C", true); }
public TempCompWizard(Focuser focuser) { InitializeComponent(); myFocuser = focuser; this.Name = myFocuser.Action("GetDeviceNickname", ""); }