private async Task RemoteRecord(RecordCommand command) { _heartbeat.Disable(); var uploader = new FrameUploader(_listener.LocalHost.ToString(), command.Address, command.Port); _model.FramesProcessed += uploader.Upload; uploader.UploadComplete += () => { _model.FramesProcessed -= uploader.Upload; }; await Dispatch(() => _model.Record.Execute(null)); _heartbeat.Enable(TimeSpan.FromSeconds(3)); }
void CheckFunctionalityAvailability() { var audioAvailable = AudioViewModel.AudioSource.AudioAvailable; var videoAvailable = VideoViewModel.SelectedVideoSourceKind != VideoSourceKind.NoVideo; RecordCommand.RaiseCanExecuteChanged(audioAvailable || videoAvailable); ScreenShotCommand.RaiseCanExecuteChanged(videoAvailable); }
void CheckFunctionalityAvailability() { var audioAvailable = Settings.Audio.Enabled; var videoAvailable = !(VideoViewModel.SelectedVideoSourceKind is NoVideoSourceProvider); RecordCommand.RaiseCanExecuteChanged(audioAvailable || videoAvailable); ScreenShotCommand.RaiseCanExecuteChanged(videoAvailable); }
/// <summary> /// Displaies the temperature reading. /// </summary> /// <param name="temperature">Temperature.</param> /// <param name="autoRecord"></param> private void DisplayTemperatureReading(double temperature, bool autoRecord) { var mintemp = HACCPUtil.ConvertToDouble(SelectedItem.Min); var maxtemp = HACCPUtil.ConvertToDouble(SelectedItem.Max); if (TemperatureUnit == TemperatureUnit.Celcius) { mintemp = HACCPUtil.ConvertFahrenheitToCelsius(mintemp); maxtemp = HACCPUtil.ConvertFahrenheitToCelsius(maxtemp); } if (temperature < mintemp) { OptimumTemperatureIndicator = false; HighTemperatureIndicator = false; LowTemperatureIndicator = true; } else if (temperature > maxtemp) { OptimumTemperatureIndicator = false; HighTemperatureIndicator = true; LowTemperatureIndicator = false; } else { OptimumTemperatureIndicator = true; HighTemperatureIndicator = false; LowTemperatureIndicator = false; } var diff = Math.Round(temperature - prevtemp, 1); if (diff > 2.8) { diff = 2.8; } else if (diff < -2.8) { diff = -2.8; } Rotation = HACCPUtil.GetSlope(diff); Blue2Temperature = temperature; prevtemp = temperature; DisplayBlue2Temperature = string.Format("{0}{1}", Blue2Temperature.ToString("0.0"), UnitString); LineBreakMode = LineBreakMode.NoWrap; if (autoRecord) { Device.BeginInvokeOnMainThread(() => { RecordCommand.Execute(null); }); } }
public void WhenCommandIsExecutedThenNotificationIsSended() { var inputMessenger = new MessengerFake(); var expectedMessage = new Record(Recording.Start, Lightman.Lightman1); var startRecordCommand = new RecordCommand(inputMessenger, Recording.Start); startRecordCommand.Execute(Lightman.Lightman1); Assert.IsNotNull(inputMessenger.SendedMessage); Assert.AreEqual(expectedMessage, inputMessenger.SendedMessage.First()); }
//private void OnLocationServiceStatusChanged(object sender, LocationServiceStatusChangedEventArgs e) //{ //} private async Task ViewLoaded() { _loading = true; var activityRecordingType = await _settingsService.GetStoredActivityRecordingTypeAsync(); ActivityText = activityRecordingType.ToString(); //TODO: Glenn - Better the GPS tracking based on sport type and during activity /* * Wondering about similar as questioned here: https://social.msdn.microsoft.com/Forums/en-US/ac03380d-4872-4161-b450-57a3c064f0a3/uwp-how-to-determine-if-a-device-has-gps-capabilities * For creating GPS tracking we want to be sure the user can only start that if accuracy is high enough * So wondering what the best threshold should be in meters... * AND how 'fast' I should set the recording milliseconds * * Some suggestions already given by Atley Hunter ( and I'm also seeing this in my Garmin GPX files ) * Tweak the ReportInterval during the tracking, to ensure better app performance * Set Geolocator settings depending on cycling or running * Strava app will show halo around current location indicating accuracy, how smaller the halo, the more accurate the position ( would guess this is the distance in meter? ) */ //DistanceUnitType distanceUnitType = await _settingsService.GetStoredDistanceUnitTypeAsync(); //SelectedMeasurementUnit = distanceUnitType.ToString(); var accessStatus = await _locationService.RequestAccessAsync(); switch (accessStatus) { case LocationServiceRequestResult.Allowed: var position = await _locationService.GetPositionAsync(LocationServiceAccuracy.High); if (!position.IsUnknown) { _canRecord = true; RecordCommand.RaiseCanExecuteChanged(); CurrentLocation = new Geopoint(new BasicGeoposition() { Latitude = position.Latitude, Longitude = position.Longitude }); } break; case LocationServiceRequestResult.Denied: //TODO: Glenn - Location request denied, show user information! break; } _loading = false; }
public DevicePacket Create() { var record = new RecordCommand(new List <AvlData>()); while (DeviceManager.AvlDataBufferes.TryDequeue(out var avlData)) { record.Records.Add(avlData); } if (record.Records.Count != 0) { return(new DevicePacket(DeviceManager.Device.Modem.Imei, record)); } return(null); }
private async Task RemoteRecord(RecordCommand command) { await ReportState(CameraClientState.Preparing); var uploader = new FrameUploader(_listener.LocalHost.ToString(), command.Address, command.Port); _model.FramesProcessed += uploader.Upload; uploader.UploadComplete += () => { _model.FramesProcessed -= uploader.Upload; State = CameraClientState.Idle; }; await Dispatch(() => { _model.Record.Execute(null); }); }
public void Setup() { var pipeServer = new AnonymousPipeServerStream(); var pipeClient = new AnonymousPipeClientStream(pipeServer.GetClientHandleAsString()); Console.SetIn(new StreamReader(pipeClient)); _stdinWriter = new StreamWriter(pipeServer); var tempFile = Path.GetTempFileName(); var recordArgs = new RecordArgs { Filename = tempFile }; _recordCommand = new RecordCommand(recordArgs); _filePath = tempFile; }
public void TestRecordCommand_Successful() { // Preconditions Debug.Assert(managerMock != null); Debug.Assert(outputMock != null); Debug.Assert(commandLineMock != null); Debug.Assert(messageLoopMock != null); /* GIVEN */ var mockSequence = new MockSequence(); managerMock.InSequence(mockSequence)?.Setup(manager => manager.StartRecording()); managerMock.InSequence(mockSequence)?.Setup(manager => manager.StopRecording()); commandLineMock .Setup(cli => cli.Launch(It.IsAny <Action>()))? .Callback((Action action) => action?.Invoke())? .Verifiable(); var command = new RecordCommand(managerMock.Object, outputMock.Object, commandLineMock.Object, messageLoopMock.Object); var options = new RecordOptions { IsVerbose = false, ConfigPath = Assembly.GetExecutingAssembly().Location }; /* WHEN */ var returnCode = command.Execute(options); /* THEN */ // We test if the command was successful and returned code 0. Assert.AreEqual(successCode, returnCode); managerMock.VerifyAll(); managerMock.Verify(manager => manager.StartRecording(), Times.Once); managerMock.Verify(manager => manager.StopRecording(), Times.Once); messageLoopMock.Verify(loop => loop.Start(), Times.Once); messageLoopMock.Verify(loop => loop.Stop(), Times.Once); }
public void TestRecordCommand_NullOptions() { // Preconditions Debug.Assert(managerMock != null); Debug.Assert(outputMock != null); Debug.Assert(commandLineMock != null); Debug.Assert(messageLoopMock != null); /* GIVEN */ var command = new RecordCommand(managerMock.Object, outputMock.Object, commandLineMock.Object, messageLoopMock.Object); /* WHEN */ var returnCode = command.Execute(null); /* THEN */ // We test if the command was unsuccessful and returned code -1. Assert.AreEqual(-1, returnCode); managerMock.Verify(manager => manager.StartRecording(), Times.Never); managerMock.Verify(manager => manager.StopRecording(), Times.Never); }
public void TestRecordCommand_IsVerbosePropagation() { // Preconditions Debug.Assert(managerMock != null); Debug.Assert(outputMock != null); Debug.Assert(commandLineMock != null); Debug.Assert(messageLoopMock != null); /* GIVEN */ outputMock.SetupSet(output => output.IsVerbose = true); var command = new RecordCommand(managerMock.Object, outputMock.Object, commandLineMock.Object, messageLoopMock.Object); var options = new RecordOptions { IsVerbose = true, ConfigPath = "" }; /* WHEN */ command.Execute(options); /* THEN */ outputMock.VerifySet(output => output.IsVerbose = true); }
/// <summary> /// Autos the advance. /// </summary> public async void CheckAutoAdvance() { try { await Page.PopPage(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { if (HaccpAppSettings.SharedInstance.DeviceSettings.AutoAdvance) { MessagingCenter.Send(new AutoAdvanceLocationMessage { CurrentId = SelectedItem.ItemId }, HaccpConstant.AutoadvancelocationMessage); } IsBusy = false; RecordCommand.ChangeCanExecute(); } }
public void TestRecordCommand_OnStartError() { // Preconditions Debug.Assert(managerMock != null); Debug.Assert(outputMock != null); Debug.Assert(commandLineMock != null); Debug.Assert(messageLoopMock != null); /* GIVEN */ managerMock .Setup(manager => manager.StartRecording())? .Throws(new InvalidOperationException()); var command = new RecordCommand(managerMock.Object, outputMock.Object, commandLineMock.Object, messageLoopMock.Object); var options = new RecordOptions { IsVerbose = false, ConfigPath = Assembly.GetExecutingAssembly().Location }; /* WHEN */ var returnCode = command.Execute(options); /* THEN */ // We test if the command failed and returned code -1. Assert.AreEqual(failCode, returnCode); managerMock.Verify(manager => manager.StartRecording(), Times.Once); managerMock.Verify(manager => manager.StopRecording(), Times.Never); outputMock.Verify(output => output.PrintError(It.IsAny <InvalidOperationException>()), Times.Once); messageLoopMock.Verify(loop => loop.Start(), Times.Never); messageLoopMock.Verify(loop => loop.Stop(), Times.Never); }
private void UpdateCommands() { RecordCommand.OnCanExecuteChanged(); PauseCommand.OnCanExecuteChanged(); StopCommand.OnCanExecuteChanged(); }
private static void Main(string[] args) { var record = new Command("rec") { new Argument <FileInfo>("file") { Description = "The filename to save the record" }, new Option(new [] { "--command", "-c" }, "The command to record, default to be powershell.exe", typeof(string)) }; record.Description = "Record and save a session"; record.Handler = CommandHandler.Create((FileInfo file, string command) => { var recordCmd = new RecordCommand(new RecordArgs { Filename = file.FullName, Command = command }); recordCmd.Execute(); }); var play = new Command("play") { new Argument <FileInfo>("file") { Description = "The record session" } }; play.Description = "Play a recorded session"; play.Handler = CommandHandler.Create((FileInfo file) => { var playCommand = new PlayCommand(new PlayArgs { Filename = file.FullName, EnableAnsiEscape = true }); playCommand.Execute(); }); var auth = new Command("auth") { Handler = CommandHandler.Create(() => { var authCommand = new AuthCommand(); authCommand.Execute(); }), Description = "Auth with asciinema.org" }; var upload = new Command("upload") { new Argument <FileInfo>("file") { Description = "The file to be uploaded" } }; upload.Description = "Upload a session to ascinema.org"; upload.Handler = CommandHandler.Create((FileInfo file) => { var uploadCommand = new UploadCommand(file.FullName); uploadCommand.Execute(); }); var rooCommand = new RootCommand { record, play, auth, upload }; rooCommand.Description = "Record, Play and Share your PowerShell Session."; rooCommand.InvokeAsync(args).Wait(); }
/// <summary> /// Executes the record command. /// </summary> private async void ExecuteRecordCommand() { if (IsBusy) { return; } try { bool connected; bool gotTemperartureReading; if (HaccpAppSettings.SharedInstance.IsWindows) { gotTemperartureReading = WindowsBLEManager.SharedInstance.GotTemperartureReading; connected = WindowsBLEManager.SharedInstance.HasAnyPairedDevice; } else { connected = BLEManager.SharedInstance.IsConnected; gotTemperartureReading = BLEManager.SharedInstance.GotTemperartureReading; } if (!IsManualEntryOn && !connected) { if (HaccpAppSettings.SharedInstance.IsWindows) { return; } if (!BLEManager.SharedInstance.Adapter.IsBluetoothEnabled) { await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("TurnONBluetoothonyourdevice")); return; } await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("Blue2TurnOnMessage")); return; } if (!IsManualEntryOn && !gotTemperartureReading) { return; } if (IsManualEntryOn && string.IsNullOrEmpty(ManualTemperature)) { await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("SpecifyTemperature")); return; } if (IsManualEntryOn) { try { double.Parse(ManualTemperature); } catch { Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("Specifyavalidtemperaturevalue")); return; } } else if (DisplayBlue2Temperature == HACCPUtil.GetResourceString("ConnectBlue2Label") || DisplayBlue2Temperature == HACCPUtil.GetResourceString("Blue2SleepString") || DisplayBlue2Temperature == HACCPUtil.GetResourceString("Blue2LowString") || DisplayBlue2Temperature == HACCPUtil.GetResourceString("Blue2HighString") && DisplayBlue2Temperature == HACCPUtil.GetResourceString("Blue2BatteryString")) { await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("InvalidTemperatureAlert")); return; } var allowedMax = HaccpAppSettings.SharedInstance.DeviceSettings.TempScale == 0 ? 9999.9 : 5537.7; var allowedMin = HaccpAppSettings.SharedInstance.DeviceSettings.TempScale == 0 ? -9999.9 : -5537.7; if (IsManualEntryOn) { if (ManualEntryTemperature > allowedMax || ManualEntryTemperature < allowedMin) { await Page.ShowAlert(string.Empty, HACCPUtil.GetResourceString("InvalidTemperatureAlert")); return; } } else { var lastReading = HaccpAppSettings.SharedInstance.IsWindows ? WindowsBLEManager.SharedInstance.LastReading : BLEManager.SharedInstance.LastReading; var lastunit = HaccpAppSettings.SharedInstance.IsWindows ? WindowsBLEManager.SharedInstance.LastUnit : BLEManager.SharedInstance.LastUnit; if (TemperatureUnit == TemperatureUnit.Celcius && lastunit != TemperatureUnit.Celcius) { lastReading = HACCPUtil.ConvertFahrenheitToCelsius(lastReading); } else if (TemperatureUnit == TemperatureUnit.Fahrenheit && lastunit != TemperatureUnit.Fahrenheit) { lastReading = HACCPUtil.ConvertCelsiusToFahrenheit(lastReading); } Blue2Temperature = lastReading; } IsBusy = true; RecordCommand.ChangeCanExecute(); var temp = IsManualEntryOn ? ManualEntryTemperature : Blue2Temperature; var minTemp = HACCPUtil.ConvertToDouble(SelectedItem.Min); var maxTemp = HACCPUtil.ConvertToDouble(SelectedItem.Max); var convertedTemp = temp; if (TemperatureUnit == TemperatureUnit.Celcius) { minTemp = Math.Round(HACCPUtil.ConvertFahrenheitToCelsius(minTemp)); maxTemp = Math.Round(HACCPUtil.ConvertFahrenheitToCelsius(maxTemp)); //convertedTemp = HACCPUtil.ConvertFahrenheitToCelsius (temp); } if (convertedTemp >= minTemp && convertedTemp <= maxTemp && HaccpAppSettings.SharedInstance.DeviceSettings.SkipRecordPreview) { var date = DateTime.Now; long ccpid; long.TryParse(SelectedItem.Ccpid, out ccpid); var location = dataStore.GetLocationById(SelectedItem.LocationId); if (TemperatureUnit == TemperatureUnit.Celcius) { convertedTemp = HACCPUtil.ConvertCelsiusToFahrenheit(temp); } var itemTemperature = new ItemTemperature { IsManualEntry = IsManualEntryOn ? (short)1 : (short)0, ItemID = SelectedItem.ItemId, Temperature = convertedTemp.ToString("0.0"), ItemName = SelectedItem.Name, Max = SelectedItem.Max, Min = SelectedItem.Min, CorrAction = HACCPUtil.GetResourceString("None"), LocationID = SelectedItem.LocationId, Ccp = SelectedItem.Ccp, CCPID = ccpid, IsNA = 0, Hour = date.Hour.ToString(), Day = date.Day.ToString(), Minute = date.Minute.ToString(), Month = date.Month.ToString(), Sec = date.Second.ToString(), Year = date.Year.ToString(), SiteID = HaccpAppSettings.SharedInstance.SiteSettings.SiteId, UserName = HaccpAppSettings.SharedInstance.UserName, DeviceId = HaccpAppSettings.SharedInstance.DeviceId, MenuID = HaccpAppSettings.SharedInstance.SiteSettings.MenuId, TZID = HaccpAppSettings.SharedInstance.SiteSettings.TimeZoneId, LocName = location.Name, Note = NoteText, Blue2ID = SelectedItem.Blue2Id }; dataStore.AddTemperature(itemTemperature); SelectedItem.RecordStatus = 1; dataStore.RecordLocationItem(SelectedItem); if (HaccpAppSettings.SharedInstance.IsWindows) { WindowsBLEManager.SharedInstance.ResetBlue2AutoOff(); } else { BLEManager.SharedInstance.ResetBlue2AutoOff(); } MessagingCenter.Send(SelectedItem, HaccpConstant.RecorditemMessage); dataStore.UpdateLocationItemRecordStatus(SelectedItem.LocationId); MessagingCenter.Send(new MenuLocationId { LocationId = SelectedItem.LocationId }, HaccpConstant.MenulocationMessage); MessagingCenter.Send(new RecordSaveCompleteToast(), HaccpConstant.ToastMessage); } else { SelectedItem.IsManualEntry = IsManualEntryOn; SelectedItem.RecordedTemperature = temp.ToString("0.0"); SelectedItem.TemperatureUnit = TemperatureUnit; SelectedItem.Blue2Id = IsManualEntryOn ? string.Empty : Blue2Id; SelectedItem.Note = NoteText; if (HaccpAppSettings.SharedInstance.IsWindows) { WindowsBLEManager.SharedInstance.ResetBlue2AutoOff(); } else { BLEManager.SharedInstance.ResetBlue2AutoOff(); } await Page.NavigateToWithSelectedObject(PageEnum.RecordComplete, true, SelectedItem); IsBusy = false; RecordCommand.ChangeCanExecute(); } } catch (Exception ex) { Debug.WriteLine("Error on recording {0}", ex.Message); } }
/// <summary> /// Initialize the object. /// </summary> public PlaybackViewModel() : base("PlaybackViewModel") { // Get Project Manager _pm = IoC.Get <PulseManager>(); _events = IoC.Get <IEventAggregator>(); _events.Subscribe(this); _adcpConn = IoC.Get <AdcpConnection>(); _buffer = new ConcurrentQueue <PlaybackArgs>(); IsAdmin = Pulse.Commons.IsAdmin(); // Get ScreenData VM _screenDataVM = IoC.Get <ScreenDataBaseViewModel>(); // Get Averaging VM _averagingVM = IoC.Get <AveragingBaseViewModel>(); // Set the record image SetRecorderImage(); // Initialize the total number of ensembles CurrentFileSize = MathHelper.MemorySizeString(0); PlaybackSpeed = DEFAULT_PLAYBACK_SPEED; PlaybackIndex = DEFAULT_PLAYBACK_INDEX; SetPlaybackSpeedIndicatorImage(); // Timer to move the slider _timer = new Timer(); _timer.AutoReset = true; _timer.Interval = _PlaybackSpeed; _timer.Elapsed += new ElapsedEventHandler(On_TimerElapsed); IsLooping = false; IsLoading = false; _isProcessingBuffer = false; // Recorder Timer _recorderTimer = new Timer(); _recorderTimer.AutoReset = true; _recorderTimer.Interval = 2000; _recorderTimer.Elapsed += new ElapsedEventHandler(On_recorderTimerElapsed); _recorderTimer.Start(); // Command to set recording on or off RecordCommand = ReactiveCommand.Create(); RecordCommand.Subscribe(_ => { IsRecordEnabled = !IsRecordEnabled; }); // Command to begin playing back data PlayCommand = ReactiveCommand.Create(); // Start the playback PlayCommand.Subscribe(_ => PlaybackCommandExecute()); // Command to move the ensemble forward StepEnsembleFowardCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => StepEnsembleForward())); // Command to move the ensemble backward StepEnsembleBackwardCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => StepEnsembleBackward())); // Command to increase playback speed // Reduce the timer interval IncreaseSpeedCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => IncreasePlaybackSpeedCommandExec())); // Command to decrease playback speed // Reduce the timer interval DecreaseSpeedCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => DecreasePlaybackSpeedCommandExec())); // Blink Record image in background BlinkRecordImageCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => BlinkRecordImage())); // Command to display all the data in the project DisplayAllDataCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => DisplayAllData())); }
public void StartRecording() { RecordCommand.Execute(null); }