<commit_before>﻿using MultiMiner.Coin.Api;
using MultiMiner.Engine.Configuration;
using MultiMiner.Utility;
using MultiMiner.Xgminer;
using MultiMiner.Xgminer.Api.Responses;
using System;
using System.Collections.Generic;
using System.Linq;

namespace MultiMiner.Win.ViewModels
{
    class MainFormViewModel
    {
        public List<DeviceViewModel> Devices { get; set; }

        public MainFormViewModel()
        {
            Devices = new List<DeviceViewModel>();
        }

        public void ApplyDeviceModels(List<Device> deviceModels)
        {
            foreach (Device deviceModel in deviceModels)
            {
                DeviceViewModel deviceViewModel = Devices.SingleOrDefault(d => d.Equals(deviceModel));
                if (deviceViewModel == null)
                {
                    deviceViewModel = new DeviceViewModel();
                    Devices.Add(deviceViewModel);
                }

                ObjectCopier.CopyObject(deviceModel, deviceViewModel);
            }
        }

        public void ApplyCoinInformationModels(List<CoinInformation> coinInformationModels)
        {
            //check for Coin != null, device may not have a coin configured
            foreach (DeviceViewModel deviceViewModel in Devices.Where(d => d.Coin != null))
            {
                CoinInformation coinInformationModel = coinInformationModels.SingleOrDefault(c => c.Symbol.Equals(deviceViewModel.Coin.Symbol, StringComparison.OrdinalIgnoreCase));
                if (coinInformationModel != null)
                {
                    string oldName = deviceViewModel.Name;
                    ObjectCopier.CopyObject(coinInformationModel, deviceViewModel, "Exchange");
                    deviceViewModel.Name = oldName;
                }
            }
        }

        public void ClearDeviceInformationFromViewModel()
        {
            foreach (DeviceViewModel deviceViewModel in Devices)
            {
                deviceViewModel.AverageHashrate = 0;
                deviceViewModel.CurrentHashrate = 0;
                deviceViewModel.AcceptedShares = 0;
                deviceViewModel.RejectedShares = 0;
                deviceViewModel.HardwareErrors = 0;
                deviceViewModel.Utility = 0;
                deviceViewModel.WorkUtility = 0;
                deviceViewModel.RejectedSharesPercent = 0;
                deviceViewModel.HardwareErrorsPercent = 0;
                deviceViewModel.Workers.Clear();<commit_msg>Clear all device stats (not just running totals)<commit_after>﻿using MultiMiner.Coin.Api;
using MultiMiner.Engine.Configuration;
using MultiMiner.Utility;
using MultiMiner.Xgminer;
using MultiMiner.Xgminer.Api.Responses;
using System;
using System.Collections.Generic;
using System.Linq;

namespace MultiMiner.Win.ViewModels
{
    class MainFormViewModel
    {
        public List<DeviceViewModel> Devices { get; set; }

        public MainFormViewModel()
        {
            Devices = new List<DeviceViewModel>();
        }

        public void ApplyDeviceModels(List<Device> deviceModels)
        {
            foreach (Device deviceModel in deviceModels)
            {
                DeviceViewModel deviceViewModel = Devices.SingleOrDefault(d => d.Equals(deviceModel));
                if (deviceViewModel == null)
                {
                    deviceViewModel = new DeviceViewModel();
                    Devices.Add(deviceViewModel);
                }

                ObjectCopier.CopyObject(deviceModel, deviceViewModel);
            }
        }

        public void ApplyCoinInformationModels(List<CoinInformation> coinInformationModels)
        {
            //check for Coin != null, device may not have a coin configured
            foreach (DeviceViewModel deviceViewModel in Devices.Where(d => d.Coin != null))
            {
                CoinInformation coinInformationModel = coinInformationModels.SingleOrDefault(c => c.Symbol.Equals(deviceViewModel.Coin.Symbol, StringComparison.OrdinalIgnoreCase));
                if (coinInformationModel != null)
                {
                    string oldName = deviceViewModel.Name;
                    ObjectCopier.CopyObject(coinInformationModel, deviceViewModel, "Exchange");
                    deviceViewModel.Name = oldName;
                }
            }
        }

        public void ClearDeviceInformationFromViewModel()
        {
            foreach (DeviceViewModel deviceViewModel in Devices)
            {
                deviceViewModel.AverageHashrate = 0;
                deviceViewModel.CurrentHashrate = 0;
                deviceViewModel.AcceptedShares = 0;
                deviceViewModel.RejectedShares = 0;
                deviceViewModel.HardwareErrors = 0;
                deviceViewModel.Utility = 0;
                deviceViewModel.WorkUtility = 0;
                deviceViewModel.RejectedSharesPercent = 0;
                deviceViewModel.HardwareErrorsPercent = 0;

                deviceViewModel.Pool = String.Empty;
                deviceViewModel.PoolIndex = -1;
                deviceViewModel.FanPercent = 0;
                deviceViewModel.Temperature = 0;
                deviceViewModel.Intensity = String.Empty;

                deviceViewModel.Workers.Clear();
{'fraction_non_alphanumeric': 0.07187678265830005, 'fraction_numerical': 0.003993154592127781, 'mean_word_length': 1.953396967995508, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2970938', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1187, 'n_words': 250}