internal IIniWrapper CreateWithFileSystem(IniSettings iniSettings, IIniParser iniParser, IFileSystem fileSystem) { var converterFactory = new IniConverterFactory(new TypeManager(), iniSettings); var savingManager = new SavingManager(new IniValueManager(new IniValueAttributeManager()), iniParser, converterFactory); var readingManager = new ReadingManager(new IniValueManager(new IniValueAttributeManager()), converterFactory, iniParser); var defaultConfigurationCreationStrategy = new ConfigurationLoadingChecker(fileSystem, iniSettings); var iniWrapperInternal = new IniWrapperInternal(savingManager, readingManager); var iniWrapperForImmutableTypeFactory = new IniWrapperForImmutableTypeFactory(iniWrapperInternal, readingManager); var iniInternalFactory = new IniWrapperInternalFactory(new IniConstructorChecker(), iniWrapperInternal, iniWrapperForImmutableTypeFactory); var iniWrapper = new IniWrapper(defaultConfigurationCreationStrategy, iniInternalFactory, new MemberInfoFactory()); var iniWrapperWithCustomMemberInfoForImmutableTypeFactory = new IniWrapperWithCustomMemberInfoForImmutableTypeFactory(iniWrapperInternal, readingManager); var iniWrapperWithCustomMemberInfoManager = new IniWrapperWithCustomMemberInfoManager(iniWrapperInternal, new IniConstructorChecker(), iniWrapperWithCustomMemberInfoForImmutableTypeFactory); converterFactory.IniWrapper = iniWrapper; converterFactory.IniWrapperWithCustomMemberInfo = iniWrapperWithCustomMemberInfoManager; return(iniWrapper); }
/// <summary> /// 构造函数 /// </summary> static BaseServices() { //实例化DB的查询接口 query = new ReadingManager(); //实例化DB操作接口 excute = new WritingManager(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif // First thing is to load any current round. It is OK if there is not one that loads. await RoundManager.LoadCurrentRoundAsync(); // Second thing is to load any readings that have been created. await ReadingManager.LoadCurrentReadingsAsync(); Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += this.OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(HomeScreen), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } }
private async void SaveInput(ReadingInputViewModel newData) { if (this.input.ItemId == Guid.Empty) { return; } var io = ServiceResolver.Resolve <IFileHandler>(); var existingReading = ReadingManager.Find(newData.ItemId); //reading already exists or was just created, so just update the values. var item = this.station.Items.FirstOrDefault(i => i.Id == newData.ItemId); if (newData.IsBooleanInput) { existingReading.Value = newData.BooleanValue.ToString(); } else { existingReading.Value = newData.StringValue; } existingReading.Comments = newData.Comments; existingReading.TimeTaken = DateTime.UtcNow; // Now validate the users input var validator = ComparisonTypeViewModel.Locate(newData.InputType); if (validator.UsesOneInput) { existingReading.IsOutOfSpec = validator.Validate( value: existingReading.Value, max: item.Specification.UpperBound) == false; } else { existingReading.IsOutOfSpec = validator.Validate( value: existingReading.Value, min: item.Specification.LowerBound, max: item.Specification.UpperBound) == false; } //finally, write out the result to file so that way it doesn't get lost. item.CurrentReading = existingReading; this.ListModel.SetSelectedAsVisited(); await ReadingManager.SaveReadingsToDiskAsync(); //place binding for completed items here. probably. }
private async Task UploadReadingsAsync(Guid roundId) { foreach (var reading in ReadingManager.Readings) { //skip anything that was added, but not really entered. if (string.IsNullOrEmpty(reading.Value)) { continue; } //set the round id for all the readings. reading.RoundId = roundId; //for each reading that we have, upload it to the server. var readingResult = await this.Api.PostAsync <ReadingModel>(Constants.Endpoints.Readings, reading); //TODO: Figure out what to do if one of the uploads fails... } //all good, so remove the items. await ReadingManager.Reset(); }
/// <summary> /// Initializes a new instance of the <see cref="ReadingInputScreenViewModel"/> class. /// Represents the full view model for the page. /// </summary> public ReadingInputScreenViewModel(RegionModelSource region, StationModel station) { var regionNav = new AsyncCommand((obj) => { Navigator.Navigate(Shared.Navigation.NavigationType.StationSelect); }); this.Save = new AsyncCommand((obj) => this.SaveInput(this.input), this.CanSave); this.station = station; this.Crumbs.Add(new BreadcrumbItemModel("Areas", region.NavigateRoot)); this.Crumbs.Add(new BreadcrumbItemModel(region.Name, region.Navigate)); this.Crumbs.Add(new BreadcrumbItemModel(station.Name, station.Navigate)); this.Input = new ReadingInputViewModel(this.Save, null); this.ListModel = new ReadingInputListViewModel(this); foreach (var item in station.Items) { if (item.StationId == station.Id) { var newMeter = new Meter(item.Meter, item) { Id = item.Id, Name = item.Name, MeterName = item.Meter }; var currentReading = ReadingManager.Find(item.Id); newMeter.LastReading = new ReadingInput(); newMeter.TwoReadingsAgo = new ReadingInput(); newMeter.ThreeReadingsAgo = new ReadingInput(); newMeter.FourReadingsAgo = new ReadingInput(); newMeter.ComparisonType = ComparisonTypeViewModel.Locate(item.Specification.ComparisonType); newMeter.TodaysReading = new ReadingInput() { MinimumValue = item.Specification.LowerBound, MaximumValue = item.Specification.UpperBound, UnitAbbreviation = item.Specification.UnitOfMeasure.Abbreviation, ValueBounds = newMeter.ComparisonType.AsEnum(), IsWithinSpec = false, }; if (!string.IsNullOrEmpty(currentReading.Value)) { bool boolVal = false; if (bool.TryParse(currentReading.Value, out boolVal)) { newMeter.TodaysReading.BooleanValue = boolVal; } else { //just a string value. newMeter.TodaysReading.StringValue = currentReading.Value; } newMeter.TodaysReading.IsWithinSpec = !currentReading.IsOutOfSpec; newMeter.IsComplete = true; } var count = item.PastFourReadings.Count(); if (count > 0) { newMeter.LastReading.StringValue = item.PastFourReadings.ElementAt(0).Value; newMeter.LastReading.IsWithinSpec = !item.PastFourReadings.ElementAt(0).IsOutOfSpec; newMeter.LastReading.Notes = item.PastFourReadings.ElementAt(0).Comments; } if (count > 1) { newMeter.TwoReadingsAgo.StringValue = item.PastFourReadings.ElementAt(1).Value; newMeter.TwoReadingsAgo.IsWithinSpec = !item.PastFourReadings.ElementAt(1).IsOutOfSpec; } if (count > 2) { newMeter.ThreeReadingsAgo.StringValue = item.PastFourReadings.ElementAt(2).Value; newMeter.ThreeReadingsAgo.IsWithinSpec = !item.PastFourReadings.ElementAt(2).IsOutOfSpec; } if (count > 3) { newMeter.FourReadingsAgo.StringValue = item.PastFourReadings.ElementAt(3).Value; newMeter.FourReadingsAgo.IsWithinSpec = !item.PastFourReadings.ElementAt(3).IsOutOfSpec; } this.ListModel.Meters.Add(newMeter); } } }
public void Demo() { // Load data _userList = ReadingManager.ReadData(@"C:\Users\RustamSalakhutdinov\Documents\visual studio 2015\Projects\signatureChecker\data_new"); // Create network _net = new Net(); _net.AddLayer(new InputLayer(imageSize, imageSize, 1)); _net.AddLayer(new ConvLayer(5, 5, 16) { Stride = 1, Pad = 1, Activation = Activation.Relu }); _net.AddLayer(new PoolLayer(2, 2) { Stride = 2 }); _net.AddLayer(new ConvLayer(5, 5, 8) { Stride = 1, Pad = 1, Activation = Activation.Relu }); _net.AddLayer(new PoolLayer(2, 2) { Stride = 2 }); _net.AddLayer(new SoftmaxLayer(2)); _trainer = new Trainer(_net) { BatchSize = 20, L2Decay = 0.001, TrainingMethod = Trainer.Method.Adagrad }; Stopwatch sw = Stopwatch.StartNew(); do { var sample = GenerateTrainingInstance(); if (!Step(sample)) { break; } } while (!Console.KeyAvailable); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds / 1000.0); foreach (User user in _userList) { Random random = new Random(); var signature = user.SignatureList[random.Next(user.SignatureList.Count)]; var x = new Volume(imageSize, imageSize, 1, 0.0); foreach (var point in signature.SignaturePointList) { x.Weights[point.X * imageSize + point.Y] = 1; } x = x.Augment(imageSize); var result = _net.Forward(x); Console.WriteLine("UserId: {0}. Result: {1} | {2}", user.UserId, result.Weights[0], result.Weights[1]); } }