/// <summary> /// Constructor for a single GPIO pin. /// </summary> /// <param name="desg">GPIO pin designator.</param> /// <param name="dir">Data direction.</param> /// <param name="state">Initial GPIO output state.</param> /// <param name="driver">Output driver setting.</param> /// <param name="edge">Interrupt edge setting.</param> /// <param name="polarity">Polarity setting.</param> public Pin(IO.Objects.libsimpleio.Device.Designator desg, IO.Interfaces.GPIO.Direction dir, bool state = false, Driver driver = Driver.PushPull, Edge edge = Edge.None, Polarity polarity = Polarity.ActiveHigh) { // Validate the GPIO pin designator if ((desg.chip == IO.Objects.libsimpleio.Device.Designator.Unavailable.chip) || (desg.chan == IO.Objects.libsimpleio.Device.Designator.Unavailable.chan)) { throw new Exception("Invalid designator"); } int flags; int events; int error; CalculateFlags(dir, driver, edge, polarity, out flags, out events, out this.kind); IO.Bindings.libsimpleio.GPIO_line_open((int)desg.chip, (int)desg.chan, flags, events, state ? 1 : 0, out this.myfd, out error); if (error != 0) { throw new Exception("GPIO_line_open() failed, " + errno.strerror(error)); } }
/// <summary> /// Change the polatity of the motor /// </summary> /// <param name="polarity">Polarity of the motor, backward, forward or opposite</param> public void SetPolarity(Polarity polarity) { switch (polarity) { case Polarity.Backward: if (brick.BrickPi.Motor[(int)Port].Speed > 0) { brick.BrickPi.Motor[(int)Port].Speed = -brick.BrickPi.Motor[(int)Port].Speed; } break; case Polarity.Forward: if (brick.BrickPi.Motor[(int)Port].Speed < 0) { brick.BrickPi.Motor[(int)Port].Speed = -brick.BrickPi.Motor[(int)Port].Speed; } break; case Polarity.OppositeDirection: brick.BrickPi.Motor[(int)Port].Speed = -brick.BrickPi.Motor[(int)Port].Speed; break; default: break; } }
public override MsDataScan GetOneBasedScan(int oneBasedScanNumber) { if (Scans[oneBasedScanNumber - 1] == null) { var representativeScanNumber = oneBasedScanNumber + (numScansToAverage - 1) / 2; var representative = raw.GetOneBasedScan(representativeScanNumber); if (representative.MsnOrder != 1) { throw new MzLibException("Scan " + representativeScanNumber + " is not MS1 scan"); } int msnOrder = 1; Polarity polarity = representative.Polarity; if (!representative.IsCentroid) { throw new MzLibException("Scan " + representativeScanNumber + " is not centroid scan"); } bool isCentroid = true; double retentionTime = representative.RetentionTime; MZAnalyzerType mzAnalyzer = representative.MzAnalyzer; MzSpectrum peaks = CombinePeaks(raw.GetAllScansList().Where(b => b.OneBasedScanNumber >= oneBasedScanNumber && b.OneBasedScanNumber <= oneBasedScanNumber + numScansToAverage - 1).Select(b => b.MassSpectrum).ToList(), ppmToleranceForPeakCombination); MzRange scanWindowRange = representative.ScanWindowRange; double totalIonCurrent = peaks.SumOfAllY; double injectionTime = double.NaN; double[,] noiseData = null; Scans[oneBasedScanNumber - 1] = new MsDataScan(peaks, oneBasedScanNumber, msnOrder, isCentroid, polarity, retentionTime, scanWindowRange, null, mzAnalyzer, totalIonCurrent, injectionTime, noiseData, "scan=" + oneBasedScanNumber); } return(Scans[oneBasedScanNumber - 1]); }
private bool TrySpawnPortal(Polarity polarity, RaycastHit hit) { Portal portal = polarity == Polarity.Left ? _leftPortal : _rightPortal; // Calculate the portal's rotation based off the hit object's normal. // Portals on walls should be upright, portals on the ground can be rotated in any way. Quaternion rotation = CalculateRotation(_camera.transform.forward, hit.normal); // Set portal position and rotation. Need to do this before calling FindFit so we can get // the portal's corners in world space portal.transform.position = hit.point; portal.transform.rotation = rotation; // Make sure the portal can fit flushly on the object we've hit. // If it can fit, but it's hanging off the edge, push it in. // Otherwise, disable the portal. Vector3 newPosition; portal.gameObject.SetActive(false); if (FindFit(portal, hit.collider, out newPosition)) { portal.transform.position = newPosition + hit.normal * _normalOffset; portal.IgnoredColliders = new Collider[] { hit.collider }; portal.gameObject.SetActive(true); // Scale the portal's renderer up from 0 to 1 for a nice visual pop-in Renderer portalRenderer = portal.GetComponentInChildren <MeshRenderer>(); SetScaleOverTime(portalRenderer.transform, Vector3.zero, Vector3.one, _portalSpawnCurve, _portalSpawnTime); return(true); } return(false); }
void Update() { YMoveSpeed = CameraController.Speed; var currentPosition = transform.position; if (Input.GetButton("Fire1")) { var moveToward = _polo == _pola ? new Vector3(_cameraWidth * -1, 0, 0) : new Vector3(0, 0, 0); _moveDirection = moveToward - new Vector3(currentPosition.x, 0, 0); _moveDirection.z = 0; _moveDirection.Normalize(); var target = _moveDirection * XMoveSpeed + currentPosition; currentPosition = Vector3.Lerp(currentPosition, target, Time.deltaTime); if (currentPosition.x <= (-_cameraWidth / 100) - 1f) { currentPosition.x = (-_cameraWidth / 100) - 1f; } } else if (Input.GetButtonUp("Fire1")) { if (Input.mousePosition.x > _cameraWidth / 2) { _polo = _polo == Polarity.Black ? Polarity.Red : Polarity.Black; } else { _pola = _pola == Polarity.Black ? Polarity.Red : Polarity.Black; } } currentPosition.y += Time.deltaTime * YMoveSpeed; transform.position = currentPosition; EnforceBounds(); }
/// <summary> /// Constructor for a single GPIO pin. /// </summary> /// <param name="chip">Linux kernel GPIO chip number.</param> /// <param name="line">Linux kernel GPIO line number.</param> /// <param name="dir">Data direction.</param> /// <param name="state">Initial output state.</param> /// <param name="driver">Output driver setting</param> /// <param name="edge">Interrupt edge setting.</param> /// <param name="polarity">Polarity setting.</param> public Pin(uint chip, uint line, IO.Interfaces.GPIO.Direction dir, bool state = false, Driver driver = Driver.PushPull, Edge edge = Edge.None, Polarity polarity = Polarity.ActiveHigh) { // Validate the GPIO chip and line numbers if (chip == Unavailable.chip) { throw new System.Exception("GPIO chip number is invalid"); } if (line == Unavailable.line) { throw new System.Exception("GPIO line number is invalid"); } int flags; int events; int error; CalculateFlags(dir, driver, edge, polarity, out flags, out events, out this.kind); IO.Bindings.libsimpleio.libGPIO.GPIO_line_open((int)chip, (int)line, flags, events, state ? 1 : 0, out this.myfd, out error); if (error != 0) { throw new Exception("GPIO_line_open() failed", error); } }
/* * The method Skolemize performs best-effort skolemization of the input expression expr. * If polarity == Polarity.Negative, a quantifier F embedded in expr is skolemized * provided it can be proved that F is a forall quantifier in the NNF version of expr. * If polarity == Polarity.Positive, a quantifier F embedded in expr is skolemized * provided it can be proved that F is an exists quantifier in the NNF version of expr. * * Factorization is performed on the resulting expression. */ public static VCExpr Skolemize(QuantifierInstantiationEngine qiEngine, Polarity polarity, VCExpr vcExpr) { var skolemizer = new Skolemizer(qiEngine, polarity, vcExpr); var skolemizedExpr = skolemizer.Mutate(vcExpr, true); return(Factorizer.Factorize(qiEngine, QuantifierCollector.Flip(polarity), skolemizedExpr)); }
void Start() { boxCollider = GetComponent <BoxCollider2D>(); player = GetComponent <Player>(); polarity = GetComponent <Polarity>(); CalculateRaySpacing(); }
public MsDataScan(MzSpectrum massSpectrum, int oneBasedScanNumber, int msnOrder, bool isCentroid, Polarity polarity, double retentionTime, MzRange scanWindowRange, string scanFilter, MZAnalyzerType mzAnalyzer, double totalIonCurrent, double?injectionTime, double[,] noiseData, string nativeId, double?selectedIonMz = null, int?selectedIonChargeStateGuess = null, double?selectedIonIntensity = null, double?isolationMZ = null, double?isolationWidth = null, DissociationType?dissociationType = null, int?oneBasedPrecursorScanNumber = null, double?selectedIonMonoisotopicGuessMz = null, string hcdEnergy = null) { OneBasedScanNumber = oneBasedScanNumber; MsnOrder = msnOrder; IsCentroid = isCentroid; Polarity = polarity; RetentionTime = retentionTime; ScanWindowRange = scanWindowRange; ScanFilter = scanFilter; MzAnalyzer = mzAnalyzer; TotalIonCurrent = totalIonCurrent; InjectionTime = injectionTime; NoiseData = noiseData; MassSpectrum = massSpectrum; NativeId = nativeId; OneBasedPrecursorScanNumber = oneBasedPrecursorScanNumber; IsolationMz = isolationMZ; IsolationWidth = isolationWidth; DissociationType = dissociationType; SelectedIonMZ = selectedIonMz; SelectedIonIntensity = selectedIonIntensity; SelectedIonChargeStateGuess = selectedIonChargeStateGuess; SelectedIonMonoisotopicGuessMz = selectedIonMonoisotopicGuessMz; HcdEnergy = hcdEnergy; }
/// <summary> /// Set the polarity (direction) of a motor. /// </summary> /// <param name="ports">Port or ports to change polarity</param> /// <param name="polarity">The new polarity (direction) value</param> /// <returns></returns> public async Task SetMotorPolarityAsync(OutputPort ports, Polarity polarity) { var c = new Command(CommandType.DirectNoReply); c.SetMotorPolarity(ports, polarity); await _brick.SendCommandAsyncInternal(c); }
/// <summary> /// Change the polatity of the motor /// </summary> /// <param name="polarity">Polarity of the motor, backward, forward or opposite</param> public void SetPolarity(Polarity polarity) { try { var motorstatus = _brick.GetMotorStatus((byte)Port); switch (polarity) { case Polarity.Backward when motorstatus.Speed > 0: _brick.SetMotorPower((byte)Port, -Speed); break; case Polarity.Forward when motorstatus.Speed < 0: _brick.SetMotorPower((byte)Port, -Speed); break; case Polarity.OppositeDirection: _brick.SetMotorPower((byte)Port, -Speed); break; default: break; } } catch (Exception) { } }
/// <summary> /// Change the polatity of the motor /// </summary> /// <param name="polarity">Polarity of the motor, backward, forward or opposite</param> public void SetPolarity(Polarity polarity) { try { MotorStatus motorstatus = _goPiGo.GetMotorStatus(Port); switch (polarity) { case Polarity.Backward: if (motorstatus.Speed > 0) { _goPiGo.SetMotorPower(Port, -Speed); } break; case Polarity.Forward: if (motorstatus.Speed < 0) { _goPiGo.SetMotorPower(Port, -Speed); } break; case Polarity.OppositeDirection: _goPiGo.SetMotorPower(Port, -Speed); break; default: break; } } catch (IOException) { } }
internal async Task SetMotorPolarityAsyncInternal(OutputPort ports, Polarity polarity) { Command c = new Command(CommandType.DirectNoReply); c.SetMotorPolarity(ports, polarity); await SendCommandAsyncInternal(c); }
public Unit(char element) { Type = char.ToLower(element); Polarity = char.IsUpper(element) ? Polarity.Positive : Polarity.Negative; }
/// <summary> /// Constructor for a single GPIO pin. /// </summary> /// <param name="pin">GPIO pin designator.</param> /// <param name="dir">Data direction.</param> /// <param name="state">Initial output state.</param> /// <param name="driver">Output driver setting</param> /// <param name="edge">Interrupt edge setting.</param> /// <param name="polarity">Polarity setting.</param> public Pin(Designator pin, IO.Interfaces.GPIO.Direction dir, bool state = false, Driver driver = Driver.PushPull, Edge edge = Edge.None, Polarity polarity = Polarity.ActiveHigh) { // Validate the GPIO pin designator if ((pin.chip == Unavailable.chip) || (pin.line == Unavailable.line)) { throw new Exception("GPIO pin designator is invalid"); } int flags; int events; int error; CalculateFlags(dir, driver, edge, polarity, out flags, out events, out this.kind); IO.Bindings.libsimpleio.libGPIO.GPIO_line_open((int)pin.chip, (int)pin.line, flags, events, state ? 1 : 0, out this.myfd, out error); if (error != 0) { throw new Exception("GPIO_line_open() failed", error); } }
public QuantifiedType(Polarity polarity, TypeConstraint left, Option <string> identifier, Term right) { Polarity = polarity; Left = left; Identifier = identifier; Right = right; }
public IrqDescriptor(int[] interruptNumbers, bool sharable, Polarity polarity, Mode mode) { this.interruptNumbers = interruptNumbers; this.sharable = sharable; this.polarity = polarity; this.mode = mode; }
/// <summary> /// Set the polarity (direction) of a motor. /// </summary> /// <param name="ports">Port or ports to change polarity</param> /// <param name="polarity">The new polarity (direction) value</param> /// <returns>A task.</returns> public Task SetMotorPolarityAsync(OutputPort ports, Polarity polarity) { return(ExecuteDirectWithoutReplyAsync(c => { c.SetMotorPolarity(ports, polarity); })); }
internal SynchronizedMotors(Motor motor1, Motor motor2) { if (motor1 == null || motor2 == null) { throw new InvalidOperationException("Must combine two valid motors. Can not be null."); } if (motor1.Equals(motor2)) { throw new InvalidOperationException("Can not sync motor with it self"); } if (motor1.Type != motor2.Type) { throw new InvalidOperationException("Must combine two motors of the same device type"); } if (motor1.Layer != motor2.Layer) { throw new InvalidOperationException("Must combine two motors on the same layer"); } Layer = motor1.Layer; PortFlag = motor1.PortFlag | motor2.PortFlag; Speed = INITIAL_SPEED; Polarity = motor1.Polarity; PortNumber = motor1.PortNumber; PortName = motor1.PortName; }
internal async Task SetMotorPolarityAsyncInternal(OutputPort ports, Polarity polarity) { Command c = _brick.NewCommand(CommandType.Direct); c.SetMotorPolarity(ports, polarity); await _brick.SendCommandAsyncInternal(c); }
public VerbInfo(string verb, CForm form, Polarity polarity = Polarity.Affirmative, Politeness politeness = Politeness.Plain) { Verb = verb ?? throw new ArgumentNullException(nameof(verb)); Form = form; this.polarity = polarity; this.politeness = politeness; }
/// <summary> /// Append the Set Polarity command to an existing Command object /// </summary> /// <param name="ports">Port or ports to change polarity</param> /// <param name="polarity">The new polarity (direction) value</param> public void SetMotorPolarity(OutputPort ports, Polarity polarity) { AddOpcode(Opcode.OutputPolarity); AddParameter(0x00); AddParameter((byte)ports); AddParameter((byte)polarity); }
private void Plot(int spectrumNumber, bool rescale = true) { zedGraphControl1.GraphPane.CurveList.Clear(); zedGraphControl2.GraphPane.CurveList.Clear(); var rawSpectrum = _rawFile.GetSpectrum(spectrumNumber); Polarity polarity = _rawFile.GetPolarity(spectrumNumber); double precursorMZ = _rawFile.GetPrecusorMz(spectrumNumber); int precursorZ = _rawFile.GetPrecusorCharge(spectrumNumber); double precursorMass = Mass.MassFromMz(precursorMZ, precursorZ); textBox2.Text = precursorMZ.ToString("f5"); textBox3.Text = ((polarity == Polarity.Positive) ? "+" : "") + precursorZ.ToString("N0"); textBox4.Text = precursorMass.ToString("f5"); List <IRange <double> > mzRangesToRemove = new List <IRange <double> >(); if (checkBox1.Checked) { double lowMZ = (double)numericUpDown1.Value; double highMZ = (double)numericUpDown2.Value; DtaGenerator.CleanPrecursor(mzRangesToRemove, precursorMZ, lowMZ, highMZ); } if (checkBox2.Checked) { double lowMZ = (double)numericUpDown3.Value; double highMZ = (double)numericUpDown4.Value; DtaGenerator.CleanETD(mzRangesToRemove, precursorMass, precursorZ, lowMZ, highMZ); } var cleanSpectrum = rawSpectrum.Filter(mzRangesToRemove); zedGraphControl1.GraphPane.AddStick("Raw", rawSpectrum.GetMasses(), rawSpectrum.GetIntensities(), Color.Black); zedGraphControl2.GraphPane.AddStick("Cleaned", cleanSpectrum.GetMasses(), cleanSpectrum.GetIntensities(), Color.Black); if (rescale) { zedGraphControl1.GraphPane.XAxis.Scale.Min = rawSpectrum.FirstMz; zedGraphControl2.GraphPane.XAxis.Scale.Min = rawSpectrum.FirstMz; zedGraphControl1.GraphPane.XAxis.Scale.Max = rawSpectrum.LastMZ; zedGraphControl2.GraphPane.XAxis.Scale.Max = rawSpectrum.LastMZ; } zedGraphControl1.GraphPane.Title.Text = _rawFile.GetScanFilter(spectrumNumber); //zedGraphControl2.GraphPane.Title.Text = dta.Name; zedGraphControl1.Invalidate(); zedGraphControl2.Invalidate(); zedGraphControl1.AxisChange(); zedGraphControl2.AxisChange(); zedGraphControl1.SetScrollRangeFromData(); zedGraphControl2.SetScrollRangeFromData(); _currentIndex = spectrumNumber; }
void Start() { controller = GetComponent <Controller2D>(); polarity = GetComponent <Polarity>(); gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2); jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; checkpointPos = transform.position; }
SetMotorPolarityAsync(OutputPort ports, Polarity polarity) { return(SetMotorPolarityAsyncInternal(ports, polarity) #if WINRT .AsAsyncAction() #endif ); }
/// <summary> /// Append the Set Polarity command to an existing Command object /// </summary> /// <param name="c">The command.</param> /// <param name="ports">Port or ports to change polarity</param> /// <param name="polarity">The new polarity (direction) value</param> /// <returns>The updated command.</returns> public static Command SetMotorPolarity(this Command c, OutputPort ports, Polarity polarity) { c.AddOpcode(Opcode.OutputPolarity); c.AddParameter(0x00); c.AddParameter((byte)ports); c.AddParameter((byte)polarity); return(c); }
/// <summary> /// Sets the polarity. /// </summary> /// <param name="polarity">Polarity of the output</param> public void SetPolarity(Polarity polarity) { var command = new ByteArrayCreator(); command.Append(KernelByteCodes.OutputPolarity); command.Append(BitField); command.Append((sbyte)polarity); pwmDevice.Write(command.Data); }
public override void Print() { string s = "Polarity: " + Polarity.ToString() + "\tIntensity: " + Intensity.ToString() + "\tSubjectivityType: " + SubjectivityType.ToString() + "\tSubjectivityPolarity: " + SubjectivityPolarity.ToString(); Console.WriteLine(s); base.Print(); }
public SyntacticTest(Polarity kind, APC pc, string tag, LazyEval <BoxedExpression> guard) { Contract.Requires(tag != null); Contract.Requires(guard != null); this.Kind = kind; this.PC = pc; this.Tag = tag; this.guard = guard; }
public WallMagnet(float initialx, float initialy, Polarity newPolarity) { pole = newPolarity; magneticMoment = 1.5f; horizontal_pos = initialx; vertical_pos = initialy; solid = true; }
/* private void Update() * { * _light.color = Color.Lerp(_light.color, _targetColor, _lerpT * Time.deltaTime); * }*/ public void ShiftPolarity(Polarity pol) { _polarity = pol; _targetColor = (_polarity == Polarity.On) ? _onColor : _offColor; if (!_isShifting) { StartCoroutine(ShiftRoutine()); } }
public virtual void SwitchPolarity() { if (CurrentPolarity == Polarity.Positive) { CurrentPolarity = Polarity.Negative; } else { CurrentPolarity = Polarity.Positive; } }
public Ship(SuperPolarity newGame) : base(newGame) { MagneticRadius = 250; RepelRadius = 100; HP = 2; FleeVelocity = 5; ActVelocity = 1; ChargeVelocity = 2.5f; CurrentPolarity = Polarity.Neutral; Magnetizing = false; }
public WalkingEnemy(float initialx, float initialy, Polarity newPole) { creation(); horizontal_pos = initialx; vertical_pos = initialy; width = 31.5f; height = 31.5f; velocity = Vector2.Zero; acceleration = Vector2.Zero; acceleration.X = 0.1f; acceleration.Y = 0.001f; pole = newPole; magneticMoment = 0.5f; solid = false; }
public override void SetPolarity(Polarity newPolarity) { base.SetPolarity(newPolarity); SwitchParticleEngine(newPolarity); }
protected void SwitchParticleEngine(Polarity polarity) { if (polarity == Polarity.Positive) { particleEngine.Color = MainShip.RedColor; } else if (polarity == Polarity.Negative) { particleEngine.Color = MainShip.BlueColor; } else { particleEngine.Color = Color.Gray; } }
public Window(string World, bool Nether , Dictionary<string, Scheme> Schemes) : base(640, 480, GraphicsMode.Default, DefaultTitle) { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmHelp)); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); GL.Enable(EnableCap.Lighting); GL.Enable(EnableCap.CullFace); GL.Enable(EnableCap.ColorMaterial); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Blend); // support transparencey GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); //GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); MinecraftLevel mcl; MinecraftLevel mclt; if (Nether) { mcl = new MinecraftLevel(World + Path.DirectorySeparatorChar + "DIM-1", false); mclt = new MinecraftLevel(World + Path.DirectorySeparatorChar + "DIM-1", true); } else { mcl = new MinecraftLevel(World, false); mclt = new MinecraftLevel(World, true); } int s = 128; DateTime starttime = DateTime.Now; string leveldat = World + Path.DirectorySeparatorChar + "level.dat"; // we still dont change this, level.dat is still used this._Renderer = new MinecraftRenderer(mcl); this._RendererTrans = new MinecraftRenderer(mclt); Scheme schm; Schemes.TryGetValue("Default", out schm); this._Renderer.CurrentScheme = schm; this._RendererTrans.CurrentScheme = schm; Vector<double> acpos = new Vector<double>(); if (File.Exists(leveldat) && !SMPInterface.IsSMP) { try { NBTCompound data = ((NBT.Read(File.OpenRead(leveldat)).Data as NBTCompound?).Value.Data["Data"].Data as NBTCompound?).Value; NBTNamedTag<INBTData> player = null; double hellscale = 8.0; bool tryget = data.Data.TryGetValue("Player", out player); bool nether = !(((player.Data as NBTCompound?).Value.Data["Dimension"].Data as NBTInt?).Value.Data == 0); if (tryget & Nether == nether) { NBTList pos = (((player.Data as NBTCompound?).Value.Data["Pos"]).Data as NBTList?).Value; acpos = new Vector<double>( (pos.Data[0] as NBTDouble?).Value.Data, (pos.Data[1] as NBTDouble?).Value.Data, (pos.Data[2] as NBTDouble?).Value.Data); } else if (tryget && !Nether) // the correct positions are not in the correct places { // Not the nether, but player location is in the nether // Lets make the view 16 times further away, this is the chunk they will come up on. NBTList pos = (((player.Data as NBTCompound?).Value.Data["Pos"]).Data as NBTList?).Value; acpos = new Vector<double>( (pos.Data[0] as NBTDouble?).Value.Data * hellscale, (pos.Data[1] as NBTDouble?).Value.Data, (pos.Data[2] as NBTDouble?).Value.Data * hellscale); } else if (tryget && Nether) // Lets see where we will end up on the nether from up top { NBTList pos = (((player.Data as NBTCompound?).Value.Data["Pos"]).Data as NBTList?).Value; acpos = new Vector<double>( (pos.Data[0] as NBTDouble?).Value.Data / hellscale, (pos.Data[1] as NBTDouble?).Value.Data, (pos.Data[2] as NBTDouble?).Value.Data / hellscale); } else { acpos = new Vector<double>( ((data.Data["SpawnX"]).Data as NBTInt?).Value.Data, ((data.Data["SpawnY"]).Data as NBTInt?).Value.Data, ((data.Data["SpawnZ"]).Data as NBTInt?).Value.Data); } } catch { } } else if (SMPInterface.IsSMP) { MineViewer.SMPPackets.PlayerSpawnPos.UpdateSpawnPos = new Action<Vector<int>>(delegate(Vector<int> pos) { Point<int> c; Point<int> o; MinecraftRenderer.ChunkOffset(new Point<int>((int)pos.Z, (int)pos.X), out c, out o); this._Renderer.GetChunk(c); this._RendererTrans.GetChunk(c); this._CamPos = new Vector<double>(s + 10.1 + c.X * MinecraftRenderer.ChunkSize, s + 10.1 + c.Y * MinecraftRenderer.ChunkSize, s + 10.1); }); } Point<int> chunk; Point<int> offset; MinecraftRenderer.ChunkOffset(new Point<int>((int)acpos.Z, (int)acpos.X), out chunk, out offset); if (!SMPInterface.IsSMP) { this._Renderer.GetChunk(chunk); this._RendererTrans.GetChunk(chunk); } this._CamPos = new Vector<double>(s + 10.1 + chunk.X * MinecraftRenderer.ChunkSize, s + 10.1 + chunk.Y * MinecraftRenderer.ChunkSize, s + 10.1); this._LookZAngle = 4.0; this._LookXAngle = -0.6; DateTime endtime = DateTime.Now; TimeSpan loadtime = endtime - starttime; this._LastHit = null; _Bookmarks = new Bookmarks(World + Path.DirectorySeparatorChar, delegate(Vector<double> vec, Vector<double> ang) { this._CamPos = vec; //this._LookXAngle = ang.X; //this._LookZAngle = ang.Z; Point<int> dchunk; Point<int> doffset; MinecraftRenderer.ChunkOffset(new Point<int>((int)vec.X, (int)vec.Y), out dchunk, out doffset); this._Renderer.GetChunk(dchunk); this._RendererTrans.GetChunk(dchunk); }); this.KeyPress += delegate(object sender, OpenTK.KeyPressEventArgs e) { char key = e.KeyChar.ToString().ToLower()[0]; if (key == 'b') { this._Bookmarks.ShowForm(this._CamPos, new Vector<double>(this._LookXAngle, 0.0, this._LookZAngle)); } if (key == ',') { this._SliceLevel = this._SlicePolarity == Polarity.Negative ? this._SliceLevel - 1 : this._SliceLevel + 1; } if (key == '.') { this._SliceLevel = this._SlicePolarity == Polarity.Negative ? this._SliceLevel + 1 : this._SliceLevel - 1; } if (key == 'h') { frmHelp frm = new frmHelp(); frm.Show(); } if (key == 'k') { frmKey k = new frmKey(this._Renderer.CurrentScheme); k.Show(); } if (key == 't') { frmSchemes schemeform = new frmSchemes(delegate(string item) { if (item.Length < 1) return; this._Renderer.CurrentScheme = this._Schemes[item]; this._RendererTrans.CurrentScheme = this._Schemes[item]; }); int index = 0; foreach(string k in this._Schemes.Keys) { ListViewItem item = new ListViewItem(k); schemeform.Schemes.Items.Add(item); Scheme o; this._Schemes.TryGetValue(k, out o); if (this._Renderer.CurrentScheme == o) schemeform.Schemes.Items[index].Selected = true; index++; } schemeform.Show(); } }; this.Keyboard.KeyDown += delegate(object sender, KeyboardKeyEventArgs e) { if (e.Key == Key.Escape) { this.Close(); } if (e.Key == Key.R) { this._SliceAxis = null; } }; this.Mouse.ButtonDown += delegate(object sender, MouseButtonEventArgs bea) { if (bea.Button == MouseButton.Left) { if (this._LastHit != null) { Border<MinecraftRenderer.HitBorder> hit = this._LastHit.Value; MinecraftRenderer.Chunk c; bool loaded = this._Renderer.Chunks.TryGetValue(hit.Value.Chunk.Value, out c); if (loaded) { if (this.Keyboard[Key.Q]) { this._Renderer.UnloadChunk(hit.Value.Chunk.Value); this._RendererTrans.UnloadChunk(hit.Value.Chunk.Value); } else if (this.Keyboard[Key.I]) { // TODO!!!!!!!!!!!!!!!!!! Point<int> pos = hit.Value.Chunk.Value; long regionX = (long)Math.Floor((decimal)pos.X / 32); long regionZ = (long)Math.Floor((decimal)pos.Y / 32); string file = Path.DirectorySeparatorChar + "region" + Path.DirectorySeparatorChar + "r." + Convert.ToString(regionX) + "." + Convert.ToString(regionZ) + ".mcr"; string msg = String.Format("Chunk: X {0} Y {1}\nFile: {2}", pos.X, pos.Y, file); msg += String.Format("\nX {0} Y {1} Z {2}", hit.Position.Y, hit.Position.Z, hit.Position.X); MessageBox.Show(msg); } else { this._SliceAxis = hit.Direction; this._SliceLevel = hit.Position[hit.Direction] + (hit.Value.Polarity == Polarity.Negative ? 1 : 0); this._SlicePolarity = hit.Value.Polarity; } } else { if (this.Keyboard[Key.E]) { bool a; Point<int> pos = hit.Value.Chunk.Value; if (this._Renderer.ChunksSelected.TryGetValue(pos, out a)) this._Renderer.ChunksSelected.Remove(pos); else this._Renderer.ChunksSelected.Add(pos, true); } else { if (this._Renderer.ChunksSelected.Count > 0) { foreach (KeyValuePair<Point<int>, bool> kv in this._Renderer.ChunksSelected) { this._Renderer.GetChunk(kv.Key); this._RendererTrans.GetChunk(kv.Key); } this._Renderer.ChunksSelected.Clear(); } else { this._Renderer.GetChunk(hit.Value.Chunk.Value); this._RendererTrans.GetChunk(hit.Value.Chunk.Value); } } } } } else { if (this._Renderer.ChunksSelected.Count > 0 && this.Keyboard[Key.E]) this._Renderer.ChunksSelected.Clear(); } }; this._Schemes = Schemes; this._Renderer.CurrentScheme = this._Schemes["Default"]; this._AverageFPS = 60.0; }
public PolarityWrapper(Polarity item) { this.Item = item; }
public virtual void SetPolarity(Polarity newPolarity) { CurrentPolarity = newPolarity; }
/// <summary> /// Change the polatity of the motor /// </summary> /// <param name="polarity">Polarity of the motor, backward, forward or opposite</param> public void SetPolarity(Polarity polarity) { switch (polarity) { case Polarity.Backward: if (brick.BrickPi.Motor[(int)Port].Speed > 0) brick.BrickPi.Motor[(int)Port].Speed = -brick.BrickPi.Motor[(int)Port].Speed; break; case Polarity.Forward: if (brick.BrickPi.Motor[(int)Port].Speed < 0) brick.BrickPi.Motor[(int)Port].Speed = -brick.BrickPi.Motor[(int)Port].Speed; break; case Polarity.OppositeDirection: brick.BrickPi.Motor[(int)Port].Speed = -brick.BrickPi.Motor[(int)Port].Speed; break; default: break; } }
internal async Task SetMotorPolarityAsyncInternal(OutputPort ports, Polarity polarity) { Command c = new Command(CommandType.DirectNoReply); c.SetMotorPolarity(ports, polarity); await _brick.SendCommandAsyncInternal(c); }
SetMotorPolarityAsync(OutputPort ports, Polarity polarity) { return SetMotorPolarityAsyncInternal(ports, polarity) #if WINRT .AsAsyncAction() #endif ; }
/// <summary> /// Sets the polarity. /// </summary> /// <param name="polarity">Polarity of the output</param> /// <param name="reply">If set to <c>true</c> reply from brick will be send.</param> public void SetPolarity(Polarity polarity, bool reply = false){ var command = new Command(0,0,206,reply); command.Append(ByteCodes.OutputPolarity); command.Append(this.DaisyChainLayer); command.Append(this.BitField); command.Append((sbyte) polarity, ParameterFormat.Short); connection.Send(command); if(reply){ var brickReply = connection.Receive(); Error.CheckForError(brickReply,206); } }
/// <summary> /// Set pin input polarity mask /// </summary> /// <param name="pin">pin</param> /// <param name="pol">polarity</param> public void PinPolarity(Pin pinMask, Polarity pol) { bool value = false; if (pol == Polarity.Invert) { value = true; } SetRegisterForPin(Register.GPINTEN, pinMask, value); }
public AnnotatedShortMessage(string rawContent, Polarity polarity) : base(rawContent) { Polarity = polarity; }
public static PropertyStates NewPolarity(Polarity polarity) { return new PolarityWrapper(polarity); }
/// <summary> /// Sets the polarity. /// </summary> /// <param name="polarity">Polarity of the output</param> public void SetPolarity(Polarity polarity){ var command = new ByteArrayCreator(); command.Append(KernelByteCodes.OutputPolarity); command.Append(BitField); command.Append((sbyte) polarity); pwmDevice.Write(command.Data); }
public Configuration(Order order, Polarity polarity, bool dumpOnly = false) { Order = order; Polarity = polarity; DumpOnly = dumpOnly; }