// Use this for initialization void Start() { bool exploding = true; //Camera rotation - uses 0 as interval for smooth movement Pulse.Every(0).Do(() => { Cam.transform.RotateAround(Room.transform.position, Vector3.up, 1f); }); Pulse.Every(0).Do(() => { Spotlight.transform.RotateAround(Room.transform.position, Vector3.up, -1f); DiscoBall.transform.RotateAround(Room.transform.position, Vector3.up, -0.5f); }).Until(() => { return(!exploding); }).Then(() => { Spotlight.gameObject.SetActive(false); DiscoBall.SetActive(false); MainLight.gameObject.SetActive(true); }); Pulse.Every(1).Do(() => { if (DiscoBall.activeSelf) { DiscoBall.SetActive(false); } else { DiscoBall.SetActive(true); } }).For(20).Until(() => { return(!exploding); }).Then(() => { DiscoBall.SetActive(false); }); //Apply an explosive force every second Pulse.Every(1).Do(() => { foreach (var rb in Explodable) { rb.AddExplosionForce(ExplodeForce, ExplodePoint.position, ExplodeRadius, 2f, ForceMode.Impulse); } }).For(15).Then(() => { exploding = false; }); //Move the explosive force every second Pulse.Every(1).Do(() => { ExplodePoint.RotateAround(Room.transform.position, Vector3.up, 45f); }); }
public void PulseOutput(PulseAPI A) { G3_Measure_Pulse B = new G3_Measure_Pulse(); B.Userid = A.Userid; B.Pulse = A.Pulse; B.MeasurementDate = DateTime.Now; if (B.Pulse < 60) { B.Status = "心跳過緩"; B.Score = 10; } else if (B.Pulse > 100) { B.Status = "心跳過速"; B.Score = 10; } else { B.Status = "心跳正常"; B.Score = 0; } using (Pulse db = new Pulse()) { db.G3_Measure_Pulse.Add(B); db.SaveChanges(); } }
public MMC5Audio(Action<int> enqueuer, Action<bool> RaiseIRQ) { this.enqueuer = enqueuer; this.RaiseIRQ = RaiseIRQ; for (int i = 0; i < pulse.Length; i++) pulse[i] = new Pulse(PulseAddDiff); }
public Pulse.Base.PictureList GetPictures(Pulse.Base.PictureSearch ps) { WebClient wc = new WebClient(); //download archive webpage var pg = wc.DownloadString(_url); //regex out the links to the individual pages Regex reg = new Regex("<a href=\"(?<picPage>ap.*\\.html)\">"); Regex regPic = new Regex("<IMG SRC=\"(?<picURL>image.*)\""); var matches = reg.Matches(pg); var pl = new Pulse.Base.PictureList() { FetchDate = DateTime.Now }; //if max picture count is 0, then no maximum, else specified max var maxPictureCount = ps.MaxPictureCount > 0 ? (ps.MaxPictureCount + ps.BannedURLs.Where(u => u.StartsWith("http://apod.nasa.gov/apod/")).Count()) : int.MaxValue; maxPictureCount = Math.Min(matches.Count, maxPictureCount); //counts might be a bit off in the event of bannings, but hopefully it won't be too far off. var matchesToGet = (from Match c in matches select c) .OrderBy(x => Guid.NewGuid()) .Take(maxPictureCount); //build url's, skip banned items, randomly sort the items and only bring back the desired number // all in one go pl.Pictures.AddRange((from Match c in matchesToGet let photoPage = new WebClient().DownloadString("http://apod.nasa.gov/apod/" + c.Groups["picPage"].Value) let photoURL = "http://apod.nasa.gov/apod/" + regPic.Match(photoPage).Groups["picURL"].Value where !ps.BannedURLs.Contains(photoURL) select new Picture() {Url = photoURL, Id=System.IO.Path.GetFileNameWithoutExtension(photoURL)})); return pl; }
public Pulse GetLastPulseInSession(int sessionId) { using (logger.BeginScope(nameof(this.GetLastPulseInSession))) { if (sessionId <= 0) { logger.LogWarning("Ivalid Session ID"); throw new ArgumentException("Session ID cannot be equal zero or less"); } using (var context = new PsqlContext()) { try { var pulses = from p in context.Pulse where p.SessionId == sessionId select p; var pulse = pulses.OrderByDescending(d => d).FirstOrDefault(); if (pulse == null) { logger.LogWarning("Pulse is not found"); throw new Exception("Pulse of session with that ID is not found"); } Pulse result = pulse.ToDomainEntity(); logger.LogDebug("Pulse is found"); return result; } catch { logger.LogWarning("Error"); throw; } } } }
public bool Update(Pulse entity) { using (logger.BeginScope(nameof(this.Update))) { if (entity == null) { logger.LogWarning("ArgumentNullException while updating pulse in DB"); return false; } using (var context = new PsqlContext()) { try { DbPulse dbPulse = entity.ToDbEntity(); context.Pulse.Update(dbPulse); context.SaveChanges(); logger.LogDebug("Pulse updated successfully"); return true; } catch (Exception e) { logger.LogWarning(e.ToString() + " while updating pulse in DB"); return false; } } } }
public void Count() { while (ShouldCount) { try { CurrentTime.Timer(); TimeLabel.Invoke(new Action(() => TimeLabel.Text = CurrentTime.ToString())); Distance += (Speed / 3600); DistanceLabel.Invoke(new Action(() => DistanceLabel.Text = $"{Distance:f2}")); RPM = Speed * 2.8; RpmLabel.Invoke(new Action(() => RpmLabel.Text = RPM.ToString())); Pulse = 90 + (int)((Power / 6) * (Speed / 20)); PulseLabel.Invoke(new Action(() => PulseLabel.Text = Pulse.ToString())); SpeedTrackbar.Invoke(new Action(() => SpeedTrackbar.Value = (int)Speed)); SpeedLabel.Invoke(new Action(() => SpeedLabel.Text = Speed.ToString())); PowerTrackbar.Invoke(new Action(() => PowerTrackbar.Value = (int)Power)); PowerLabel.Invoke(new Action(() => PowerLabel.Text = Power.ToString())); } catch (Exception e) { } Thread.Sleep(1000); } }
public MainWindow() { InitializeComponent(); _activePages = new HashSet <Page>(); _dataManager = new DataManager <AppData>("prefs.json"); try { _appData = _dataManager.Load(); } catch (Exception ex) { MessageHelper.Error(ex.Message); Close(); } _context = CreateContext(); _pulse = new Pulse(_context, () => StartInspector()); _inspector = new InspectorService(); Loaded += MainWindow_Loaded; StateChanged += MainWindow_StateChanged; Closing += MainWindow_Closing; Start(); }
public static Pulse SelectPulseData(int uniqueID, bool dbconOpened) { if (!dbconOpened) { Sqlite.Open(); } dbcmd.CommandText = "SELECT * FROM " + Constants.PulseTable + " WHERE uniqueID == " + uniqueID; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); reader.Read(); Pulse myPulse = new Pulse(DataReaderToStringArray(reader, 9)); reader.Close(); if (!dbconOpened) { Sqlite.Close(); } return(myPulse); }
protected override string [] getLineToStore(System.Object myObject) { Pulse newPulse = (Pulse)myObject; //if fixedPulse is not defined, comparate each pulse with the averave string myTypeComplet = newPulse.Type; if (newPulse.Simulated == Constants.Simulated) { myTypeComplet += Constants.SimulatedTreeview + " "; } if (newPulse.FixedPulse != -1) { myTypeComplet += "(" + Util.TrimDecimals(newPulse.FixedPulse.ToString(), 3) + ")"; } string [] myData = new String [getColsNum()]; int count = 0; myData[count++] = myTypeComplet; /* * myData[count++] = Util.TrimDecimals(Util.GetAverage(newPulse.TimesString).ToString(), pDN); * myData[count++] = "+/- " + Util.TrimDecimals( newPulse.GetErrorAverage(false).ToString(), pDN ); * myData[count++] = "+/- " + Util.TrimDecimals( newPulse.GetErrorAverage(true).ToString(), pDN ); */ myData[count++] = ""; myData[count++] = ""; myData[count++] = ""; myData[count++] = newPulse.Description; myData[count++] = newPulse.UniqueID.ToString(); return(myData); }
protected void SetStatus(Pulse.Base.PictureDownload.DownloadStatus status) { if (pbStatus.IsDisposed) return; switch (status) { case Pulse.Base.PictureDownload.DownloadStatus.Stopped: pbStatus.Image = Properties.Resources.StatusAnnotations_Stop_16xLG_color; break; case Pulse.Base.PictureDownload.DownloadStatus.Downloading: pbStatus.Image = Properties.Resources.StatusAnnotations_Play_16xLG_color; break; case Pulse.Base.PictureDownload.DownloadStatus.Complete: pbStatus.Image = Properties.Resources.StatusAnnotations_Complete_and_ok_16xLG_color; break; case Pulse.Base.PictureDownload.DownloadStatus.Cancelled: pbStatus.Image = Properties.Resources.action_Cancel_16xLG; break; case Pulse.Base.PictureDownload.DownloadStatus.Error: pbStatus.Image = Properties.Resources.StatusAnnotations_Critical_16xLG_color; break; default: break; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.addPulse_layout); IHealthAPI healthAPI; healthAPI = RestService.For <IHealthAPI>(sessionUser.uriSession); var edt_addBpm = FindViewById <EditText>(Resource.Id.txt_addPulse); var btn_cancelPulse = FindViewById <Button>(Resource.Id.btn_cancelPulse); var btn_savePulse = FindViewById <Button>(Resource.Id.btn_savePulse); btn_cancelPulse.Click += (s, e) => { Finish(); }; btn_savePulse.Click += delegate { Pulse pulse = new Pulse() { Bpm = int.Parse(edt_addBpm.Text), Date = DateTime.Now, userId = sessionUser.Id }; healthAPI.PostPulse(pulse); Finish(); Intent nextActivity = new Intent(this, typeof(PulseActivity)); StartActivity(nextActivity); }; }
/// <summary> /// /// </summary> /// <param name="freq">frequency of the M2 clock in hz</param> /// <param name="enqueuer">a place to dump deltas to</param> public VRC6Alt(Action <int> enqueuer) { this.enqueuer = enqueuer; pulse1 = new Pulse(PulseAddDiff); pulse2 = new Pulse(PulseAddDiff); saw = new Saw(SawAddDiff); }
/// <summary> /// Generates a new waveform. /// </summary> /// <param name="parameters">Parameters for waveform.</param> /// <param name="context">A context.</param> /// <returns> /// A new waveform. /// </returns> public override IWaveformDescription Generate(ParameterCollection parameters, ICircuitContext context) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } if (parameters.Count != 7) { context.Result.Validation.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Warning, "Wrong number of arguments for pulse", parameters.LineInfo)); return(null); } var w = new Pulse(); w.InitialValue = context.Evaluator.EvaluateDouble(parameters.Get(0)); w.PulsedValue = context.Evaluator.EvaluateDouble(parameters.Get(1)); w.Delay = context.Evaluator.EvaluateDouble(parameters.Get(2)); w.RiseTime = context.Evaluator.EvaluateDouble(parameters.Get(3)); w.FallTime = context.Evaluator.EvaluateDouble(parameters.Get(4)); w.PulseWidth = context.Evaluator.EvaluateDouble(parameters.Get(5)); w.Period = context.Evaluator.EvaluateDouble(parameters.Get(6)); return(w); }
internal PulseConfig(byte[] config) : base(config[0]) { input = (byte)(config[1] + 1); threshold = Util.bytesLeToInt(config, 4); samples = Util.bytesLeToUshort(config, 8); mode = (Pulse)config[3]; }
void AddBit(GpioPinEdge edge, Pulse pulse = Pulse.Data0) { if (edge != GpioPinEdge.FallingEdge) { return; } if (!swReadingTimer.IsRunning) { swReadingTimer.Start(); timerWatcher = CreateWatcherTimer(); } if (isAddBitMethodLocked == false) { isAddBitMethodLocked = true; //left-shift bits valueBuffer <<= 1; if (pulse == Pulse.Data1) { valueBuffer |= 1; } bitCount++; timerWatcher.Change(TIME_IDLEFLAG, TimeSpan.FromMilliseconds(-1)); isAddBitMethodLocked = false; } CheckReceivedData(); }
//Compare each pulse with the block positioned above it (in the bottom row of the grid) //If the above block is a source node, create energy at that block. public void CreateEnergy(Pulse pulse) { GameObject[,] currentNodeGrid = Grid.nodeGrid; int pulseColumn = pulse.CurrentGridColumn; if (currentNodeGrid[pulseColumn, 4] != null) { Node_Block currentBlock = currentNodeGrid[pulseColumn, 4].GetComponent <Node_Block>(); //Proceed if the block is a source node and doesn't already contain energy if (currentBlock.IsSource && currentBlock.HasEnergy == false) { //TODO: Instantiate energy prefab, set position to correct block and set that block's hasEnergy and possessedEnergy GameObject newEnergyObject = Instantiate(energyObject, currentBlock.transform.position, Quaternion.identity); newEnergyObject.transform.position += new Vector3(0, -0.09f, 0); Energy newEnergy = newEnergyObject.GetComponent <Energy>(); newEnergy.GridPosition = new Vector2(pulseColumn, 4); currentBlock.PossessedEnergy = newEnergy; currentBlock.HasEnergy = true; Debug.Log("Creating energy in column " + pulseColumn); } } }
public Pulse.Base.PictureList GetPictures(Pulse.Base.PictureSearch ps) { PictureList pl = new PictureList() { FetchDate = DateTime.Now }; //general purpose downloader WebClient wc = new WebClient(); //download pictures page var content = wc.DownloadString(_baseURL + "/wallpaper/download"); //get paths to the xml files var xmlPaths = ParseXMLPaths(content); //download and parse each xml file foreach (string xmlFile in xmlPaths) { try { var pics = ParsePictures(xmlFile); //clear out banned images pics = (from c in pics where !ps.BannedURLs.Contains(c.Url) select c).ToList(); pl.Pictures.AddRange(pics); } catch(Exception ex) { Log.Logger.Write(string.Format("Error loading/parsing National Geographic pictures from XML. XML file URL: '{0}'. Exception details: {1}", _baseURL + xmlFile, ex.ToString()), Log.LoggerLevels.Errors); } if (pl.Pictures.Count >= (ps.MaxPictureCount > 0 ? ps.MaxPictureCount : int.MaxValue)) break; } return pl; }
public IActionResult AcceptPulse([FromBody] AcceptPulseRequest request) { using (_logger.BeginScope(nameof(AcceptPulse))) { if (request == null) { _logger.LogInformation("request is null"); return(BadRequest("request is null")); } _logger.LogInformation("Pulse accepted. User tries to save pulse"); try { var session = _sessionRepository.GetLastSessionForUser(request.SessionId); string errorMessage; if (_sessionValidator.IsNullOrFinishedSession(session, out errorMessage)) { _logger.LogInformation(errorMessage); return(BadRequest(errorMessage)); } var pulse = new Pulse(session.SessionID, request.Pulse, request.TimeStamp); _pulseRepository.Add(pulse); _logger.LogInformation("Pulse of user with sessionId {0} stored in database", request.SessionId); return(Ok()); } catch (Exception exception) { _logger.LogError("Exception caught: {0}, {1}", exception.Message, exception.StackTrace); return(BadRequest(exception.Message)); } } }
public void Count() { while (ShouldCount) { long beginTime = DateTime.Now.Ticks; try { CurrentTime.Timer(); TimeLabel.Invoke(new Action(() => TimeLabel.Text = CurrentTime.ToString())); Distance += (Speed / 3600); DistanceLabel.Invoke(new Action(() => DistanceLabel.Text = $"{Distance:f2}")); RPM = Speed * 2.8; RpmLabel.Invoke(new Action(() => RpmLabel.Text = RPM.ToString())); Pulse = 90 + (int)((Power / 6) * (Speed / 10)); PulseLabel.Invoke(new Action(() => PulseLabel.Text = Pulse.ToString())); SpeedTrackbar.Invoke(new Action(() => SpeedTrackbar.Value = (int)Speed)); SpeedLabel.Invoke(new Action(() => SpeedLabel.Text = Speed.ToString())); PowerTrackbar.Invoke(new Action(() => PowerTrackbar.Value = (int)Power)); PowerLabel.Invoke(new Action(() => PowerLabel.Text = Power.ToString())); } catch (Exception e) { } Wait1s(beginTime); } }
public static PULS_Block GetPulse(byte[] _buffer, int _counter, uint size) { PULS_Block block = new PULS_Block(); int baseCount = _counter; while (_counter < baseCount + size) { Pulse p = new Pulse(); p.count = 1; p.duration = (System.BitConverter.ToUInt16(_buffer, _counter)); _counter += 2; if (p.duration > 0x8000) { p.count = (ushort)(p.duration & 0x7FFF); p.duration = System.BitConverter.ToUInt16(_buffer, _counter); _counter += 2; } if (p.duration >= 0x8000) { p.duration &= 0x7FFF; p.duration <<= 16; p.duration |= System.BitConverter.ToUInt16(_buffer, _counter); _counter += 2; } block.pulse.Add(p); } return(block); }
internal PulseConfig(byte input, int threshold, ushort samples, Pulse mode) : base(ID) { this.input = input; this.threshold = threshold; this.samples = samples; this.mode = mode; }
protected override void write() { int totalPulsesNum = 0; totalPulsesNum = Util.GetNumberOfJumps(timesString, false); uniqueID = SqlitePulse.Insert(false, Constants.PulseTable, "NULL", personID, sessionID, type, fixedPulse, totalPulsesNum, timesString, "", Util.BoolToNegativeInt(simulated) //description ); //define the created object eventDone = new Pulse(uniqueID, personID, sessionID, type, fixedPulse, totalPulsesNum, timesString, "", Util.BoolToNegativeInt(simulated)); //string myStringPush = Catalog.GetString("Last pulse") + ": " + personName + " " + type ; if (simulated) { feedbackMessage = Catalog.GetString(Constants.SimulatedMessage); } else { feedbackMessage = ""; } needShowFeedbackMessage = true; //app1.PreparePulseGraph(Util.GetLast(timesString), timesString); PrepareEventGraphPulseObject = new PrepareEventGraphPulse(Util.GetLast(timesString), timesString); needUpdateGraphType = eventType.PULSE; needUpdateGraph = true; needEndEvent = true; //used for hiding some buttons on eventWindow, and also for updateTimeProgressBar here }
protected override string [] getSubLineToStore(System.Object myObject, int lineCount) { Pulse newPulse = (Pulse)myObject; string timeInterval = getTimeInterval(newPulse, lineCount); double pulseToComparate = getPulseToComparate(newPulse); double absoluteError = Convert.ToDouble(timeInterval) - pulseToComparate; double relativeError = absoluteError * 100 / pulseToComparate; //write line for treeview string [] myData = new String [getColsNum()]; int count = 0; myData[count++] = (lineCount + 1).ToString(); myData[count++] = Util.TrimDecimals(timeInterval, pDN); myData[count++] = Util.TrimDecimals(absoluteError.ToString(), pDN); myData[count++] = Util.TrimDecimals(relativeError.ToString(), pDN); myData[count++] = ""; //myData[count++] = newPulse.UniqueID.ToString(); myData[count++] = "-1"; //mark to non select here, select first line return(myData); }
//execution public PulseExecute(int personID, string personName, int sessionID, string type, double fixedPulse, int totalPulsesNum, Chronopic cp, Gtk.Window app, int pDN, bool volumeOn, Preferences.GstreamerTypes gstreamer, //double progressbarLimit, ExecutingGraphData egd ) { this.personID = personID; this.personName = personName; this.sessionID = sessionID; this.type = type; this.fixedPulse = fixedPulse; this.totalPulsesNum = totalPulsesNum; this.cp = cp; this.app = app; this.pDN = pDN; this.volumeOn = volumeOn; this.gstreamer = gstreamer; // this.progressbarLimit = progressbarLimit; this.egd = egd; fakeButtonUpdateGraph = new Gtk.Button(); fakeButtonThreadDyed = new Gtk.Button(); simulated = false; needUpdateEventProgressBar = false; needUpdateGraph = false; //initialize eventDone as a Pulse eventDone = new Pulse(); }
/// <summary> /// /// </summary> /// <param name="freq">frequency of the M2 clock in hz</param> /// <param name="enqueuer">a place to dump deltas to</param> public VRC6Alt(uint freq, Action<int> enqueuer) { this.enqueuer = enqueuer; pulse1 = new Pulse(PulseAddDiff); pulse2 = new Pulse(PulseAddDiff); saw = new Saw(SawAddDiff); }
public Sunsoft5BAudio(Action <int> enqueuer) { this.enqueuer = enqueuer; for (int i = 0; i < pulse.Length; i++) { pulse[i] = new Pulse(PulseAddDiff); } }
private PulseEditor createAndRegisterPulseEditor(Pulse pulse) { PulseEditor pe = new PulseEditor(pulse); pulseEditors.Add(pe); pe.pulseDeleted += new EventHandler(pe_pulseDeleted); return(pe); }
public Sunsoft5BAudio(Action<int> enqueuer) { this.enqueuer = enqueuer; for (int i = 0; i < pulse.Length; i++) { pulse[i] = new Pulse(PulseAddDiff); } }
public override void Activation() { foreach (var Dendrite in Dendrites) { OutputPulse = new Pulse(); } Weight += Bias; }
private void duplicateButton_Click(object sender, EventArgs e) { Pulse newPulse = new Pulse(pulse); int currentIndex = Storage.sequenceData.DigitalPulses.IndexOf(pulse); Storage.sequenceData.DigitalPulses.Insert(currentIndex + 1, newPulse); WordGenerator.MainClientForm.instance.RefreshSequenceDataToUI(); }
protected override int getNumOfSubEvents(System.Object myObject) { Pulse newPulse = (Pulse)myObject; string [] myStringFull = newPulse.TimesString.Split(new char[] { '=' }); return(myStringFull.Length); }
public void Validate() { When.ValidateRequired("When"); Systolic.ValidateRequired("Systolic"); Diastolic.ValidateRequired("Diastolic"); Pulse.ValidateOptional("Pulse"); IrregularHeartbeat.ValidateOptional("IrregularHeartbeat"); }
public async Task TestPost() { var pulse = new Pulse { HeartRate = 75 }; const string baseUrl = Settings.ServiceUrl; var client = new HttpClient(); await client.PostAsJsonAsync(new Uri(baseUrl), pulse); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (ThumbnailGenerator.IsDrawingThumbnail) { return; } Pulse.Begin(); }
void OnConnectedToServer() { if (Server.g && Server.g.IsClient()) { m_networkView = GetComponent<NetworkView>(); Server.g.SyncViewIds (m_networkView, "HeartBeat"); m_pulseComponent = GetComponent<Pulse>(); } }
public MMC5Audio(Action <int> enqueuer, Action <bool> RaiseIRQ) { this.enqueuer = enqueuer; this.RaiseIRQ = RaiseIRQ; for (int i = 0; i < pulse.Length; i++) { pulse[i] = new Pulse(PulseAddDiff); } }
void Awake() { if( pulse == null ) { pulse = GameObject.Instantiate( pulsePrefab ) as Pulse; pulse.transform.parent = transform; pulse.transform.localPosition = Vector3.zero; pulse.transform.localRotation = Quaternion.identity; } }
private Pulse CreatePulse(Vector2 center) { GameObject sonarWave = null; if (this.pulseWave != null) { sonarWave = Instantiate(this.pulseWave, this.transform.position, this.transform.rotation) as GameObject; } Pulse wave = new Pulse(sonarWave, center, this.pulseWaveDuration, this.pulseStartRadius, this.pulseWaveSpeed); activePulses_.Add(wave.Id, wave); return wave; }
public void ProcessPicture(Pulse.Base.PictureBatch pb, string config) { List<Picture> lp = pb.GetPictures(1); if (!lp.Any()) return; Picture p = lp.First(); ManualResetEvent mre = new ManualResetEvent(false); int stepCount = 13; //get color to start with Color currentAero = Desktop.GetCurrentAeroColor(); Color endAeroColor; //load file using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(p.LocalPath))) { using (Bitmap bmp = (Bitmap)Bitmap.FromStream(ms)) { //get final color endAeroColor = PictureManager.CalcAverageColor(bmp); } } //build transition Color[] transitionColors = CalcColorTransition(currentAero, endAeroColor, stepCount); //build timer System.Timers.Timer t = new System.Timers.Timer(100); int currentStep = 0; t.Elapsed += delegate(object sender, System.Timers.ElapsedEventArgs e) { //double check (I've seen cases where timer fires even though currentStep is past {stepCount} if (currentStep >= stepCount) { mre.Set(); t.Stop(); return; } //set to next color Desktop.SetAeroColor(transitionColors[currentStep]); //increment steps and check if we should stop the timer currentStep++; if (currentStep >= stepCount) { mre.Set(); t.Stop(); } }; t.Start(); mre.WaitOne(); }
private void Atomize() { AtomizerEffectGroup effectGroup = Atomizer.CreateEffectGroup(); SwapColours swapColours = new SwapColours(); int modeIndex = Random.Range(0, System.Enum.GetValues(typeof(ColourSwapMode)).Length); swapColours.ColourSwapMode = (ColourSwapMode) modeIndex; swapColours.Duration = 5f; effectGroup.Combine(swapColours); Pulse pulseEffect = new Pulse(); pulseEffect.PulseLength = Random.Range(0.1f, 0.6f); pulseEffect.PulseStrength = Random.Range(0.2f, 0.8f); pulseEffect.Duration = 5f; effectGroup.Combine(pulseEffect); Pop popEffect = new Pop(); popEffect.Duration = 5f; popEffect.Force = Random.Range(0.1f, 4.0f); effectGroup.Combine(popEffect); Percolate percolateEffect = new Percolate(); percolateEffect.PercolationTime = Random.Range(1.0f, 4.0f); percolateEffect.PercolationSpeed = Random.Range(0.5f, 6.0f); percolateEffect.Duration = 5f; int directionIndex = Random.Range(0, System.Enum.GetValues(typeof(PercolationDirection)).Length); percolateEffect.Direction = (PercolationDirection) directionIndex; effectGroup.Combine(percolateEffect); Disintegrate disintegrateEffect = new Disintegrate(); disintegrateEffect.Duration = 5f; disintegrateEffect.FadeColour = new Color(Random.value, Random.value, Random.value, Random.value); effectGroup.Combine(disintegrateEffect); Vacuum vacuumEffect = new Vacuum(); vacuumEffect.VacuumPoint = new Vector3( transform.position.x, transform.position.y + 2f, transform.position.z); vacuumEffect.MoveSpeed = 5f; vacuumEffect.Duration = 5.0f; effectGroup.Chain(vacuumEffect); Atomizer.Atomize(gameObject, effectGroup, null); }
public float getPulseAudio(Pulse pulse, int timeInSamples) { if (!pulse.ENABLED || pulse.current_length_counter == 0) { return 0.0f; } //Frequency is the clock speed of the CPU ~ 1.7MH divided by 16 divied by the timer. //TODO pretty much everything here, only looking at frequency flag right now double frequency = 106250.0 / pulse.TIMER; double normalizedSampleTime = timeInSamples * frequency / sampleRate; double fractionalNormalizedSampleTime = normalizedSampleTime - Math.Floor(normalizedSampleTime); float dutyPulse = fractionalNormalizedSampleTime < dutyMap[pulse.DUTY] ? 1 : -1; byte volume = pulse.ENVELOPE_DIVIDER_PERIOD_OR_VOLUME; if (!pulse.CONSTANT_VOLUME) { volume = pulse.envelope_volume; } return dutyPulse * volume / 15; }
public override void SetState(Status status, Pulse pulse) { RunCommandOnAllDevices(GenerateCommand(status, pulse)); }
void Awake() { if(initializeOnAwake){ InitializeEntity(); } if( pulsePrefab != null && pulse == null ) { pulse = GameObject.Instantiate( pulsePrefab ) as Pulse; pulse.transform.parent = transform; pulse.transform.localPosition = Vector3.zero; pulse.transform.localRotation = Quaternion.identity; pulse.range = pulseRange; } }
public int UploadPulse(Pulse myTest) { int temp = myTest.UniqueID; myTest.UniqueID = -1; int id = myTest.InsertAtDB(false, Constants.PulseTable); myTest.UniqueID = temp; return id; //uniqueID of person at server }
static void collector_OnInterrupt(uint data1, uint data2, DateTime time) { // Right Engine: data1 == 41 // Left Engine: data1 == 40 if (data1 == 41) { currentEngine = leftEngine; } else if (data1 == 40) { currentEngine = rightEngine; } else { Debug.Print("Unknown engine: " + data1); return; } if (data2 == 0) // Edge going low, start of pulse. { currentEngine.sample = time; } else // Edge going high, end of pulse. { currentEngine.lastSample = currentEngine.sample; currentEngine.sample = time; currentEngine.pulseCodeComplete = !currentEngine.pulseCodeComplete; if (!currentEngine.pulseCodeComplete) { currentEngine.interval = (currentEngine.sample - currentEngine.lastSample).Ticks / 10000; } else { currentEngine.lastInterval = currentEngine.interval; currentEngine.interval = (currentEngine.sample - currentEngine.lastSample).Ticks / 10000; if (USBClientController.GetState() == USBClientController.State.Running) { if (currentEngine == leftEngine) { Debug.Print("x"); keyboardDevice.KeyTap(USBC_Key.X); } else { Debug.Print("."); keyboardDevice.KeyTap(USBC_Key.Period); } } Debug.Print(currentEngine.lastInterval + "/" + currentEngine.interval + ", rotation direction: " + (currentEngine.IsForward ? "+" : "-")); // Reset timers. currentEngine.lastInterval = 0; currentEngine.interval = 0; currentEngine.sample = DateTime.MinValue; currentEngine.lastSample = DateTime.MinValue; } } }
private void tickSweep(Pulse pulse) { if (pulse.sweep_period_counter == 0) { if (pulse.SWEEP_ENABLED) { int periodAdjustment = pulse.TIMER >> pulse.SWEEP_SHIFT; int newPeriod; if (pulse.SWEEP_NEGATE) { newPeriod = pulse.TIMER - periodAdjustment; } else { newPeriod = (pulse.TIMER + periodAdjustment); } if (0 < newPeriod && newPeriod < 0x7FF && pulse.SWEEP_SHIFT != 0) { pulse.TIMER = (ushort)newPeriod; } } pulse.sweep_period_counter = pulse.SWEEP_PERIOD; } else { pulse.sweep_period_counter--; } }
private void RemovePulse(Pulse pulse) { if (pulse.SonarWave != null) { Destroy(pulse.SonarWave.gameObject); } activePulses_.Remove(pulse.Id); }
//execution public PulseExecute(int personID, string personName, int sessionID, string type, double fixedPulse, int totalPulsesNum, Chronopic cp, Gtk.TextView event_execute_textview_message, Gtk.Window app, int pDN, bool volumeOn, //double progressbarLimit, ExecutingGraphData egd ) { this.personID = personID; this.personName = personName; this.sessionID = sessionID; this.type = type; this.fixedPulse = fixedPulse; this.totalPulsesNum = totalPulsesNum; this.cp = cp; this.event_execute_textview_message = event_execute_textview_message; this.app = app; this.pDN = pDN; this.volumeOn = volumeOn; // this.progressbarLimit = progressbarLimit; this.egd = egd; fakeButtonUpdateGraph = new Gtk.Button(); fakeButtonEventEnded = new Gtk.Button(); fakeButtonFinished = new Gtk.Button(); simulated = false; needUpdateEventProgressBar = false; needUpdateGraph = false; //initialize eventDone as a Pulse eventDone = new Pulse(); }
public void UploadPulseAsync(Pulse myTest, object userState) { if ((this.UploadPulseOperationCompleted == null)) { this.UploadPulseOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUploadPulseCompleted); } this.InvokeAsync("UploadPulse", new object[] { myTest}, this.UploadPulseOperationCompleted, userState); }
public void UploadPulseAsync(Pulse myTest) { this.UploadPulseAsync(myTest, null); }
public int UploadPulse(Pulse myTest) { object[] results = this.Invoke("UploadPulse", new object[] { myTest}); return ((int)(results[0])); }
private void treeviewPulsesContextMenu(Pulse myPulse) { Menu myMenu = new Menu (); Gtk.MenuItem myItem; /* myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + myPulse.Type + " (" + myPulse.PersonName + ")"); if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, Constants.TestTypes.PULSE, myTreeViewPulses.EventSelectedID))) { myItem.Activated += on_video_play_selected_pulse_clicked; myItem.Sensitive = true; } else myItem.Sensitive = false; myMenu.Attach( myItem, 0, 1, 0, 1 ); */ myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myPulse.Type + " (" + myPulse.PersonName + ")"); myItem.Activated += on_edit_selected_pulse_clicked; myMenu.Attach( myItem, 0, 1, 0, 1 ); myItem = new MenuItem ( Catalog.GetString("Repair selected") + " " + myPulse.Type + " (" + myPulse.PersonName + ")"); myItem.Activated += on_repair_selected_pulse_clicked; myMenu.Attach( myItem, 0, 1, 1, 2 ); Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem(); myMenu.Attach( mySep, 0, 1, 2, 3 ); myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myPulse.Type + " (" + myPulse.PersonName + ")"); myItem.Activated += on_delete_selected_pulse_clicked; myMenu.Attach( myItem, 0, 1, 3, 4 ); myMenu.Popup(); myMenu.ShowAll(); }
private void tickEnvelopCounter(Pulse pulse) { if (pulse.envelope_counter == 0) { if (pulse.envelope_volume == 0) { if(pulse.ENVELOPE_LOOP) { pulse.envelope_volume = 15; } } else { pulse.envelope_volume--; } pulse.envelope_counter = pulse.ENVELOPE_DIVIDER_PERIOD_OR_VOLUME; } else { pulse.envelope_counter--; } }
public System.IAsyncResult BeginUploadPulse(Pulse myTest, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("UploadPulse", new object[] { myTest}, callback, asyncState); }
private void on_pulse_finished(object o, EventArgs args) { Log.WriteLine("pulse finished"); currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_pulse_finished); if ( ! currentEventExecute.Cancel ) { /* * CURRENTLY NOT NEEDED... check //if user clicked in finish earlier if(currentPulse.Finish) { currentRunInterval.Tracks = Util.GetNumberOfJumps(currentRunInterval.IntervalTimesString, false); if(currentRunInterval.TracksLimited) { currentRunInterval.Limited = currentRunInterval.Tracks.ToString() + "R"; } else { currentRunInterval.Limited = Util.GetTotalTime( currentRunInterval.IntervalTimesString) + "T"; } } */ currentPulse = (Pulse) currentEventExecute.EventDone; //move video file if exists Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.PULSE, currentPulse.UniqueID); myTreeViewPulses.Add(currentPerson.Name, currentPulse); //since 0.7.4.1 when test is done, treeview select it. action event button have to be shown showHideActionEventButtons(true, "Pulse"); //show if(createdStatsWin) { showUpdateStatsAndHideData(true); } //unhide buttons for delete last jump sensitiveGuiYesEvent(); //put correct time value in eventWindow (put the time from chronopic and not onTimer soft chronometer) event_execute_LabelTimeValue = Util.GetTotalTime(currentPulse.TimesString); } else if( currentEventExecute.ChronopicDisconnected ) { Log.WriteLine("DISCONNECTED gui/cj"); createChronopicWindow(true); } //unhide buttons that allow jumping, running sensitiveGuiEventDone(); }
public abstract void SetState(Status status, Pulse pulse);
private void RenderElement(Pulse.Pulse pulse, GradientLevelPair gradientLevelPair, TimeSpan startTime, ElementNode element, EffectIntents effectIntents) { pulse.ColorGradient = gradientLevelPair.ColorGradient; pulse.LevelCurve = gradientLevelPair.Curve; pulse.TargetNodes = new[] { element }; var result = pulse.Render(); result.OffsetAllCommandsByTime(startTime); effectIntents.Add(result); }
private byte[] GenerateCommand(Status status, Pulse pulse) { return GenerateCommand(_status[status],_pulse[pulse]); }
private void tickLengthCounter(Pulse pulse) { if (!pulse.LENGTH_COUNTER_HALT) { pulse.current_length_counter -= 1; if (pulse.current_length_counter < 0) { pulse.current_length_counter = 0; } } }