Beispiel #1
0
        public static void UpdateTimeUnit(TimeUnitType unit)
        {
            switch (unit)
            {
            case TimeUnitType.Hour:
                TimeUnit = 1.0 / 24.0;
                break;

            case TimeUnitType.Day:
                TimeUnit = 1;
                break;

            case TimeUnitType.Week:
                TimeUnit = 7;
                break;

            case TimeUnitType.Month:
                TimeUnit = 30;
                break;

            case TimeUnitType.Year:
                TimeUnit = 365;
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Determines the oldest date based on the type of time units and the number of time units
        /// </summary>
        /// <param name="numUnits"></param>
        /// <param name="typeUnits"></param>
        /// <returns></returns>
        public static DateTime GetOldestDate(int numUnits, TimeUnitType typeUnits)
        {
            DateTime result = DateTime.Now;

            switch (typeUnits)
            {
            case TimeUnitType.Week:
            {
                result = (DateTime.Now).AddDays(-1 * 7 * numUnits);
                break;
            }

            case TimeUnitType.Month:
            {
                result = (DateTime.Now).AddMonths(-1 * numUnits);
                break;
            }

            case TimeUnitType.Year:
            {
                result = (DateTime.Now).AddYears(-1 * numUnits);
                break;
            }

            default:
            {
                result = (DateTime.Now).AddDays(-1 * numUnits);
                break;
            }
            }

            return(result);
        }
Beispiel #3
0
        internal static long GetScaleUnitTicks(TimeUnitType timeUnit)
        {
            long tick = 1;

            switch (timeUnit)
            {
            case TimeUnitType.Day:
                tick = 864000000000;
                break;

            case TimeUnitType.Hour:
                tick = 36000000000;
                break;

            case TimeUnitType.Minute:
                tick = 600000000;
                break;

            case TimeUnitType.Second:
                tick = 10000000;
                break;
            }

            return(tick);
        }
Beispiel #4
0
        /// <summary>
        /// TicksToTime
        /// One Tick == 1.0 clock cycle, so this converts from clock ticks to time in NanoSecs, TenNanoSecs, OneHundredNanoSecs, or MilliSecs.
        /// NOTE: This only works for QBox time data for which TimeScale == _clockRate * 1000.
        /// </summary>
        /// <param name="inTicks">Clock Ticks</param>
        /// <param name="inOutputUnits">Choice of which time unit to output</param>
        /// <returns></returns>
        public ulong TicksToTime(ulong inTicks, TimeUnitType inOutputUnits)
        {
            if (inTicks == 0)
            {
                return(0);
            }
            double unit = 0;

            if (inOutputUnits == TimeUnitType.NanoSeconds)
            {
                unit = 1000000.0;
            }
            if (inOutputUnits == TimeUnitType.TenNanoSeconds)
            {
                unit = 100000.0;
            }
            if (inOutputUnits == TimeUnitType.OneHundredNanoSeconds)
            {
                unit = 10000.0;
            }
            if (inOutputUnits == TimeUnitType.MicroSeconds)
            {
                unit = 1000.0;
            }
            if (inOutputUnits == TimeUnitType.MilliSeconds)
            {
                unit = 1.0;
            }
            ulong ans = (ulong)(unit * ((double)inTicks / _clockRate));

            return(ans);
        }
Beispiel #5
0
        private void CreateDefaultUnit(string name, TemperatureUnitType temperature, PressureUnitType pressure,
                                       LiquidHeadUnitType liquidHead, MassFlowRateUnitType massFlowRate, VolumeFlowRateUnitType volumeFlowRate,
                                       VolumeRateFlowLiquidsUnitType volumeRateFlowLiquids, VolumeRateFlowGasesUnitType volumeRateFlowGases,
                                       MoistureContentUnitType moistureContent, FractionUnitType fraction, SpecificEnergyUnitType specificEnergy,
                                       SpecificEntropyUnitType specificEntropy, SpecificHeatUnitType specificHeat,
                                       EnergyUnitType energy, PowerUnitType power, DensityUnitType density,
                                       SpecificVolumeUnitType specificVolume, DynamicViscosityUnitType dynamicViscosity,
                                       KinematicViscosityUnitType kinematicViscosity, ThermalConductivityUnitType thermalConductivity,
                                       HeatTransferCoefficientUnitType heatTransferCoefficient, VolumeHeatTransferCoefficientUnitType volumeHeatTransferCoefficient,
                                       FoulingFactorUnitType foulingFactor,
                                       HeatFluxUnitType heatFluxDensity, DiffusivityUnitType diffusivity,
                                       SurfaceTensionUnitType surfaceTension, VelocityUnitType velocity, MassUnitType mass,
                                       LengthUnitType length, SmallLengthUnitType smallLength, MicroLengthUnitType microLength,
                                       AreaUnitType area, VolumeUnitType volume, MassVolumeConcentrationUnitType massVolumeConcentration,
                                       TimeUnitType time, PlaneAngleUnitType planeAngle)
        {
            UnitSystem us = new UnitSystem(name, true, temperature, pressure, liquidHead, massFlowRate,
                                           volumeFlowRate, volumeRateFlowLiquids, volumeRateFlowGases, moistureContent,
                                           fraction, specificEnergy, specificEntropy, specificHeat, energy, power,
                                           density, specificVolume, dynamicViscosity, kinematicViscosity, thermalConductivity,
                                           heatTransferCoefficient, volumeHeatTransferCoefficient, foulingFactor, heatFluxDensity,
                                           diffusivity, surfaceTension, velocity, mass, length, smallLength, microLength, area, volume,
                                           massVolumeConcentration, time, planeAngle);

            unitSystemList.Add(us);
            if (!us.IsReadOnly)
            {
                us.UnitSystemChanged += new UnitSystemChangedEventHandler(unitSystem_UnitSystemChanged);
            }
        }
Beispiel #6
0
 // methods
 public void SetDefaults()
 {
     ConfigFileVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
     Language          = LanguageType.En;
     ForceCPUExtension = CpuExtensionType.Automatic;
     BitcoinAddress    = "";
     WorkerName        = "worker1";
     TimeUnit          = TimeUnitType.Day;
     ServiceLocation   = 0;
     AutoStartMining   = false;
     //LessThreads = 0;
     DebugConsole                       = false;
     HideMiningWindows                  = false;
     MinimizeToTray                     = false;
     BenchmarkTimeLimits                = new BenchmarkTimeLimitsConfig();
     DeviceDetection                    = new DeviceDetectionConfig();
     DisableAMDTempControl              = true;
     DisableDefaultOptimizations        = false;
     AutoScaleBTCValues                 = true;
     StartMiningWhenIdle                = false;
     DisableWhileInVR                   = true;
     DisableWhileUnrealLightmassRunning = true;
     LogToFile                     = true;
     LogMaxFileSize                = 1048576;
     ShowDriverVersionWarning      = true;
     DisableWindowsErrorReporting  = true;
     ShowInternetConnectionWarning = true;
     NVIDIAP0State                 = false;
     MinerRestartDelayMS           = 500;
     ethminerDefaultBlockHeight    = 2000000;
     SwitchMinSecondsFixed         = 90;
     SwitchMinSecondsDynamic       = 30;
     SwitchMinSecondsAMD           = 90;
     SwitchProfitabilityThreshold  = 0.05; // percent
     MinIdleSeconds                = 60;
     DisplayCurrency               = "USD";
     ApiBindPortPoolStart          = 4000;
     MinimumProfit                 = 0;
     EthminerDagGenerationType     = DagGenerationType.SingleKeep;
     DownloadInit                  = false;
     //ContinueMiningIfNoInternetAccess = false;
     IdleWhenNoInternetAccess = true;
     Use3rdPartyMiners        = Use3rdPartyMiners.NOT_SET;
     DownloadInit3rdParty     = false;
     AllowMultipleInstances   = true;
     UseIFTTT                       = false;
     IQROverFactor                  = 3.0;
     NormalizedProfitHistory        = 15;
     IQRNormalizeFactor             = 0.0;
     CoolDownCheckEnabled           = true;
     RunScriptOnCUDA_GPU_Lost       = false;
     ForceSkipAMDNeoscryptLyraCheck = false;
     OverrideAMDBusIds              = "";
     SwitchSmaTimeChangeSeconds     = new Interval(34, 55);
     SwitchSmaTicksStable           = new Interval(2, 3);
     SwitchSmaTicksUnstable         = new Interval(5, 13);
     UseSmaCache                    = true;
     UseEthlargement                = false;
 }
Beispiel #7
0
 public static void SendPasswordResetKey(string username, string password, TimeUnitType unit)
 {
     //Uri u = System.Web.HttpContext.Current.Request.Url;
     //string resetUrl = GetUrl(username, password, unit);
     //string template = Helper.GetTranslation(TranslationKey.PasswordResetTemplate);
     //string body = template.Replace("{Username}", user.FullName).Replace("{Host}", u.Host).Replace("{ResetKey}", resetUrl);
     //string subject = string.Format("Reset your {0} password", u.Host);
     //Engine.Mail.Current.Send(user.Membership.Email, user.FullName, subject, body, JocysCom.ClassLibrary.Mail.MailTextType.Plain);
 }
Beispiel #8
0
        /// <summary>
        /// Converts time unit type to a string.
        /// </summary>
        /// <param name="tut">Time unit to convert.</param>
        /// <returns>A string version of the time unit.</returns>
        public static string TimeUnitTypeToString(TimeUnitType tut)
        {
            if (tut == TimeUnitType.Minutes)
            {
                return("minutes");
            }

            return("seconds");
        }
Beispiel #9
0
 public UnitSystem(string name, bool readOnly, TemperatureUnitType temperature,
                   PressureUnitType pressure, LiquidHeadUnitType liquidHead, MassFlowRateUnitType massFlowRate,
                   VolumeFlowRateUnitType volumeFlowRate, VolumeRateFlowLiquidsUnitType volumeRateFlowLiquids,
                   VolumeRateFlowGasesUnitType volumeRateFlowGases, MoistureContentUnitType moistureContent,
                   FractionUnitType fraction, SpecificEnergyUnitType enthalpy, SpecificEntropyUnitType entropy,
                   SpecificHeatUnitType specificHeat, EnergyUnitType energy, PowerUnitType power, DensityUnitType density,
                   SpecificVolumeUnitType specificVolume,
                   DynamicViscosityUnitType dynamicViscosity, KinematicViscosityUnitType kinematicViscosity,
                   ThermalConductivityUnitType conductivity, HeatTransferCoefficientUnitType heatTransferCoefficient,
                   VolumeHeatTransferCoefficientUnitType volumeHeatTransferCoefficient, FoulingFactorUnitType foulingFactor, HeatFluxUnitType heatFlux,
                   DiffusivityUnitType diffusivity, SurfaceTensionUnitType surfaceTension, VelocityUnitType velocity,
                   MassUnitType mass, LengthUnitType length, SmallLengthUnitType smallLength, MicroLengthUnitType microLength,
                   AreaUnitType area, VolumeUnitType volume, MassVolumeConcentrationUnitType massVolumeConcentration, TimeUnitType time,
                   PlaneAngleUnitType planeAngle, MoleFlowRateUnitType moleFlowRate)
 {
     this.name                          = name;
     this.temperature                   = temperature;
     this.pressure                      = pressure;
     this.liquidHead                    = liquidHead;
     this.massFlowRate                  = massFlowRate;
     this.volumeFlowRate                = volumeFlowRate;
     this.volumeRateFlowLiquids         = volumeRateFlowLiquids;
     this.volumeRateFlowGases           = volumeRateFlowGases;
     this.moistureContent               = moistureContent;
     this.fraction                      = fraction;
     this.enthalpy                      = enthalpy;
     this.entropy                       = entropy;
     this.specificHeat                  = specificHeat;
     this.energy                        = energy;
     this.power                         = power;
     this.density                       = density;
     this.specificVolume                = specificVolume;
     this.dynamicViscosity              = dynamicViscosity;
     this.kinematicViscosity            = kinematicViscosity;
     this.conductivity                  = conductivity;
     this.diffusivity                   = diffusivity;
     this.heatTransferCoefficient       = heatTransferCoefficient;
     this.volumeHeatTransferCoefficient = volumeHeatTransferCoefficient;
     this.foulingFactor                 = foulingFactor;
     this.heatFlux                      = heatFlux;
     this.surfaceTension                = surfaceTension;
     this.velocity                      = velocity;
     this.mass                          = mass;
     this.length                        = length;
     this.smallLength                   = smallLength;
     this.microLength                   = microLength;
     this.area                          = area;
     this.volume                        = volume;
     this.massVolumeConcentration       = massVolumeConcentration;
     this.time                          = time;
     this.planeAngle                    = planeAngle;
     this.moleFlowRate                  = moleFlowRate;
     this.readOnly                      = readOnly;
 }
Beispiel #10
0
 /// <summary>
 /// TicksToTime
 /// One Tick == 1.0 clock cycle, so this converts from clock ticks to time in NanoSecs, TenNanoSecs, OneHundredNanoSecs, or MilliSecs.
 /// NOTE: This only works for QBox time data for which TimeScale == _clockRate * 1000.
 /// </summary>
 /// <param name="inTicks">Clock Ticks</param>
 /// <param name="inOutputUnits">Choice of which time unit to output</param>
 /// <returns></returns>
 public ulong TicksToTime(ulong inTicks, TimeUnitType inOutputUnits)
 {
     if (inTicks == 0) return (0);
      double unit = 0;
      if (inOutputUnits == TimeUnitType.NanoSeconds) unit = 1000000.0;
      if (inOutputUnits == TimeUnitType.TenNanoSeconds) unit = 100000.0;
      if (inOutputUnits == TimeUnitType.OneHundredNanoSeconds) unit = 10000.0;
        if (inOutputUnits == TimeUnitType.MicroSeconds) unit = 1000.0;
      if (inOutputUnits == TimeUnitType.MilliSeconds) unit = 1.0;
     ulong ans = (ulong)(unit * ((double)inTicks / _clockRate));
     return(ans);
 }
Beispiel #11
0
        /// <summary>
        /// Get current time unit value.
        /// </summary>
        /// <param name="unit">Time unit type.</param>
        /// <returns>Time unit value.</returns>
        public static double GetTimeUnitValue(TimeUnitType unit)
        {
            switch (unit)
            {
            case TimeUnitType.Seconds: return(Math.Floor(DateTime.Now.Subtract(DateTime.MinValue).TotalSeconds));

            case TimeUnitType.Minutes: return(Math.Floor(DateTime.Now.Subtract(DateTime.MinValue).TotalMinutes));

            case TimeUnitType.Hours: return(Math.Floor(DateTime.Now.Subtract(DateTime.MinValue).TotalHours));

            case TimeUnitType.Days: return(Math.Floor(DateTime.Now.Subtract(DateTime.MinValue).TotalDays));
            }
            return(0);
        }
 // methods
 public void SetDefaults()
 {
     ConfigFileVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
     Language          = LanguageType.En;
     ForceCPUExtension = CPUExtensionType.Automatic;
     BitcoinAddress    = "18Lmq3vwAC5RG8W6DWV8uVDr2Mu5paaHCm";
     WorkerName        = "NC1";
     TimeUnit          = TimeUnitType.Day;
     ServiceLocation   = 0;
     AutoStartMining   = false;
     //LessThreads = 0;
     DebugConsole                = false;
     HideMiningWindows           = true;
     MinimizeToTray              = true;
     BenchmarkTimeLimits         = new BenchmarkTimeLimitsConfig();
     DeviceDetection             = new DeviceDetectionConfig();
     DisableAMDTempControl       = true;
     DisableDefaultOptimizations = false;
     AutoScaleBTCValues          = true;
     StartMiningWhenIdle         = true;
     LogToFile                     = true;
     LogMaxFileSize                = 1048576;
     ShowDriverVersionWarning      = true;
     DisableWindowsErrorReporting  = true;
     ShowInternetConnectionWarning = true;
     NVIDIAP0State                 = false;
     MinerRestartDelayMS           = 500;
     ethminerDefaultBlockHeight    = 2000000;
     SwitchMinSecondsFixed         = 90;
     SwitchMinSecondsDynamic       = 30;
     SwitchMinSecondsAMD           = 90;
     SwitchProfitabilityThreshold  = 0.07; // percent
     MinIdleSeconds                = 60;
     DisplayCurrency               = "GBP";
     ApiBindPortPoolStart          = 4000;
     MinimumProfit                 = 0;
     EthminerDagGenerationType     = DagGenerationType.Parallel;
     DownloadInit                  = true;
     //ContinueMiningIfNoInternetAccess = false;
     IdleWhenNoInternetAccess = true;
     Use3rdPartyMiners        = Use3rdPartyMiners.NOT_SET;
     DownloadInit3rdParty     = true;
     AllowMultipleInstances   = true;
     UseIFTTT                 = false;
     IQROverFactor            = 3.0;
     NormalizedProfitHistory  = 15;
     IQRNormalizeFactor       = 0.0;
     CoolDownCheckEnabled     = true;
     RunScriptOnCUDA_GPU_Lost = true;
 }
Beispiel #13
0
        public virtual void SetObjectData(SerializationInfo info, StreamingContext context)
        {
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionUnitSystem", typeof(int));

            if (persistedClassVersion >= 1)
            {
                this.name                          = (string)info.GetValue("Name", typeof(string));
                this.readOnly                      = (bool)info.GetValue("IsReadOnly", typeof(bool));
                this.area                          = (AreaUnitType)info.GetValue("AreaUnit", typeof(AreaUnitType));
                this.density                       = (DensityUnitType)info.GetValue("DensityUnit", typeof(DensityUnitType));
                this.diffusivity                   = (DiffusivityUnitType)info.GetValue("DiffusivityUnit", typeof(DiffusivityUnitType));
                this.dynamicViscosity              = (DynamicViscosityUnitType)info.GetValue("DynamicViscosityUnit", typeof(DynamicViscosityUnitType));
                this.energy                        = (EnergyUnitType)info.GetValue("EnergyUnit", typeof(EnergyUnitType));
                this.foulingFactor                 = (FoulingFactorUnitType)info.GetValue("FoulingFactorUnit", typeof(FoulingFactorUnitType));
                this.fraction                      = (FractionUnitType)info.GetValue("FractionUnit", typeof(FractionUnitType));
                this.heatFlux                      = (HeatFluxUnitType)info.GetValue("HeatFluxUnit", typeof(HeatFluxUnitType));
                this.heatTransferCoefficient       = (HeatTransferCoefficientUnitType)info.GetValue("HeatTransferCoefficientUnit", typeof(HeatTransferCoefficientUnitType));
                this.volumeHeatTransferCoefficient = (VolumeHeatTransferCoefficientUnitType)info.GetValue("VolumeHeatTransferCoefficientUnit", typeof(VolumeHeatTransferCoefficientUnitType));
                this.kinematicViscosity            = (KinematicViscosityUnitType)info.GetValue("KinematicViscosityUnit", typeof(KinematicViscosityUnitType));
                this.length                        = (LengthUnitType)info.GetValue("LengthUnit", typeof(LengthUnitType));
                this.liquidHead                    = (LiquidHeadUnitType)info.GetValue("LiquidHeadUnit", typeof(LiquidHeadUnitType));
                this.massFlowRate                  = (MassFlowRateUnitType)info.GetValue("MassFlowRateUnit", typeof(MassFlowRateUnitType));
                this.mass                          = (MassUnitType)info.GetValue("MassUnit", typeof(MassUnitType));
                this.massVolumeConcentration       = (MassVolumeConcentrationUnitType)info.GetValue("MassVolumeConcentrationUnit", typeof(MassVolumeConcentrationUnitType));
                this.microLength                   = (MicroLengthUnitType)info.GetValue("MicroLengthUnit", typeof(MicroLengthUnitType));
                this.moistureContent               = (MoistureContentUnitType)info.GetValue("MoistureContentUnit", typeof(MoistureContentUnitType));
                this.planeAngle                    = (PlaneAngleUnitType)info.GetValue("PlaneAngleUnit", typeof(PlaneAngleUnitType));
                this.power                         = (PowerUnitType)info.GetValue("PowerUnit", typeof(PowerUnitType));
                this.pressure                      = (PressureUnitType)info.GetValue("PressureUnit", typeof(PressureUnitType));
                this.smallLength                   = (SmallLengthUnitType)info.GetValue("SmallLengthUnit", typeof(SmallLengthUnitType));
                this.enthalpy                      = (SpecificEnergyUnitType)info.GetValue("SpecificEnergyUnit", typeof(SpecificEnergyUnitType));
                this.entropy                       = (SpecificEntropyUnitType)info.GetValue("SpecificEntropyUnit", typeof(SpecificEntropyUnitType));
                this.specificHeat                  = (SpecificHeatUnitType)info.GetValue("SpecificHeatUnit", typeof(SpecificHeatUnitType));
                this.specificVolume                = (SpecificVolumeUnitType)info.GetValue("SpecificVolumeUnit", typeof(SpecificVolumeUnitType));
                this.surfaceTension                = (SurfaceTensionUnitType)info.GetValue("SurfaceTensionUnit", typeof(SurfaceTensionUnitType));
                this.temperature                   = (TemperatureUnitType)info.GetValue("TemperatureUnit", typeof(TemperatureUnitType));
                this.conductivity                  = (ThermalConductivityUnitType)info.GetValue("ThermalConductivityUnit", typeof(ThermalConductivityUnitType));
                this.time                          = (TimeUnitType)info.GetValue("TimeUnit", typeof(TimeUnitType));
                this.velocity                      = (VelocityUnitType)info.GetValue("VelocityUnit", typeof(VelocityUnitType));
                this.volumeFlowRate                = (VolumeFlowRateUnitType)info.GetValue("VolumeFlowRateUnit", typeof(VolumeFlowRateUnitType));
                this.volumeRateFlowGases           = (VolumeRateFlowGasesUnitType)info.GetValue("VolumeRateFlowGasesUnit", typeof(VolumeRateFlowGasesUnitType));
                this.volumeRateFlowLiquids         = (VolumeRateFlowLiquidsUnitType)info.GetValue("VolumeRateFlowLiquidsUnit", typeof(VolumeRateFlowLiquidsUnitType));
                this.volume                        = (VolumeUnitType)info.GetValue("VolumeUnit", typeof(VolumeUnitType));
            }
            if (persistedClassVersion >= 2)
            {
                this.moleFlowRate = (MoleFlowRateUnitType)info.GetValue("MoleFlowRateUnit", typeof(MoleFlowRateUnitType));
            }
        }
Beispiel #14
0
        /// <summary>
        /// Get current time unit value.
        /// </summary>
        /// <param name="unit">Time unit type.</param>
        /// <returns>Time unit value.</returns>
        public static long GetTimeUnitValue(TimeUnitType unit, DateTime?date = null)
        {
            var d = date.HasValue ? date.Value : DateTime.Now;

            switch (unit)
            {
            case TimeUnitType.Seconds: return((long)d.Subtract(DateTime.MinValue).TotalSeconds);

            case TimeUnitType.Minutes: return((long)d.Subtract(DateTime.MinValue).TotalMinutes);

            case TimeUnitType.Hours: return((long)d.Subtract(DateTime.MinValue).TotalHours);

            case TimeUnitType.Days: return((long)d.Subtract(DateTime.MinValue).TotalDays);
            }
            return(0);
        }
Beispiel #15
0
        public static TimeSpan Duration(double duration, TimeUnitType unit)
        {
            TimeSpan result;

            if (unit == TimeUnitType.Second)
            {
                int sec = (int)Math.Round(duration);
                result = new TimeSpan(0, 0, 0, sec);
            }
            else
            {
                int min = (int)Math.Truncate(duration);
                int sec = (int)Math.Truncate((duration - min) * 60);
                result = new TimeSpan(0, 0, min, sec);
            }
            return(result);
        }
Beispiel #16
0
        public static TimeUnitType GetUnitAsEnum(string unitString)
        {
            IDictionaryEnumerator myEnumerator = unitStringTable.GetEnumerator();
            String       name;
            TimeUnitType type = TimeUnitType.Second;

            while (myEnumerator.MoveNext())
            {
                name = myEnumerator.Value as String;
                if (name.Equals(unitString))
                {
                    type = (TimeUnitType)myEnumerator.Key;
                    break;
                }
            }
            return(type);
        }
Beispiel #17
0
        private static double GetTimeUnit(TimeUnitType type)
        {
            switch (type)
            {
            case TimeUnitType.Hour: return(1.0 / 24.0);

            case TimeUnitType.Day: return(1);

            case TimeUnitType.Week: return(7);

            case TimeUnitType.Month: return(30);

            case TimeUnitType.Year: return(365);

            default: return(1);    // Day
            }
        }
Beispiel #18
0
        private int GetScaleNum(TimeUnitType timeUnitType)
        {
            switch (timeUnitType)
            {
            case TimeUnitType.Millisecond:
                return(1000);

            case TimeUnitType.Second:
            case TimeUnitType.Min:
                return(60);

            case TimeUnitType.Hour:
                return(24);

            default:
                throw new System.Exception("请设置所有枚举的返回值");
            }
        }
Beispiel #19
0
        public void Commit(UnitSystem us)
        {
            this.name                          = us.Name; //ep
            this.temperature                   = us.temperature;
            this.pressure                      = us.pressure;
            this.liquidHead                    = us.liquidHead;
            this.massFlowRate                  = us.massFlowRate;
            this.volumeFlowRate                = us.volumeFlowRate;
            this.volumeRateFlowLiquids         = us.volumeRateFlowLiquids;
            this.volumeRateFlowGases           = us.volumeRateFlowGases;
            this.moistureContent               = us.moistureContent;
            this.fraction                      = us.fraction;
            this.enthalpy                      = us.enthalpy;
            this.entropy                       = us.entropy;
            this.specificHeat                  = us.specificHeat;
            this.energy                        = us.energy;
            this.power                         = us.power;
            this.density                       = us.density;
            this.specificVolume                = us.specificVolume;
            this.dynamicViscosity              = us.dynamicViscosity;
            this.kinematicViscosity            = us.kinematicViscosity;
            this.conductivity                  = us.conductivity;
            this.diffusivity                   = us.diffusivity;
            this.heatTransferCoefficient       = us.heatTransferCoefficient;
            this.volumeHeatTransferCoefficient = us.volumeHeatTransferCoefficient;
            this.foulingFactor                 = us.foulingFactor;
            this.heatFlux                      = us.heatFlux;
            this.surfaceTension                = us.surfaceTension;
            this.velocity                      = us.velocity;
            this.mass                          = us.mass;
            this.length                        = us.length;
            this.smallLength                   = us.smallLength;
            this.microLength                   = us.microLength;
            this.area                          = us.area;
            this.volume                        = us.volume;
            this.massVolumeConcentration       = us.massVolumeConcentration;

            this.time         = us.time;
            this.planeAngle   = us.planeAngle;
            this.moleFlowRate = us.moleFlowRate;

            this.OnUnitSystemChanged(this);
        }
Beispiel #20
0
 public UnitSystem()
 {
     this.name                          = "SI"; //ep
     this.temperature                   = TemperatureUnitType.Kelvin;
     this.pressure                      = PressureUnitType.Kilopascal;
     this.liquidHead                    = LiquidHeadUnitType.Meter;
     this.massFlowRate                  = MassFlowRateUnitType.KgPerHour;
     this.volumeFlowRate                = VolumeFlowRateUnitType.CubicMeterPerHour;
     this.volumeRateFlowLiquids         = VolumeRateFlowLiquidsUnitType.CubicMeterPerHour;
     this.volumeRateFlowGases           = VolumeRateFlowGasesUnitType.CubicMeterPerHour;
     this.moistureContent               = MoistureContentUnitType.KgPerKg;
     this.fraction                      = FractionUnitType.Percent;
     this.enthalpy                      = SpecificEnergyUnitType.KilojoulePerKg;
     this.entropy                       = SpecificEntropyUnitType.KilojoulePerKgKelvin;
     this.specificHeat                  = SpecificHeatUnitType.KilojoulePerKgKelvin;
     this.energy                        = EnergyUnitType.Kilojoule;
     this.power                         = PowerUnitType.Kilowatt;
     this.density                       = DensityUnitType.KgPerCubicMeter;
     this.specificVolume                = SpecificVolumeUnitType.CubicMeterPerKg;
     this.dynamicViscosity              = DynamicViscosityUnitType.PascalSecond;
     this.kinematicViscosity            = KinematicViscosityUnitType.SquareMeterPerSec;
     this.conductivity                  = ThermalConductivityUnitType.WattPerMeterKelvin;
     this.diffusivity                   = DiffusivityUnitType.SquareMeterPerSec;
     this.velocity                      = VelocityUnitType.MeterPerSec;
     this.mass                          = MassUnitType.Kilogram;
     this.length                        = LengthUnitType.Meter;
     this.smallLength                   = SmallLengthUnitType.Centimeter;
     this.microLength                   = MicroLengthUnitType.Micrometer;
     this.heatTransferCoefficient       = HeatTransferCoefficientUnitType.WattPerSquareMeterKelvin;
     this.volumeHeatTransferCoefficient = VolumeHeatTransferCoefficientUnitType.WattPerCubicMeterKelvin;
     this.foulingFactor                 = FoulingFactorUnitType.SquareMeterKelvinPerWatt;
     this.surfaceTension                = SurfaceTensionUnitType.NewtonPerMeter;
     this.area                          = AreaUnitType.SquareMeter;
     this.volume                        = VolumeUnitType.CubicMeter;
     this.massVolumeConcentration       = MassVolumeConcentrationUnitType.KgPerCubicMeter;
     this.time                          = TimeUnitType.Second;
     this.heatFlux                      = HeatFluxUnitType.WattPerSquareMeter;
     this.planeAngle                    = PlaneAngleUnitType.Radian;
     this.moleFlowRate                  = MoleFlowRateUnitType.KmolePerSec;
     this.readOnly                      = true;
 }
Beispiel #21
0
        /// <summary>
        /// Check if token is valid.
        /// </summary>
        /// <param name="token">Token to check.</param>
        /// <param name="userId">User id (Integer or GUID).</param>
        /// <param name="password">Password or secure key/hash.</param>
        /// <param name="unit">Time unit type.</param>
        /// <param name="count">How many units in past mus be checked.</param>
        /// <returns>True if token is valid, False if not valid.</returns>
        public static bool CheckUnlockToken(string token, string value, TimeUnitType unit, int count, string hmacHashKey = null)
        {
            // Time which passed.
            double u = GetTimeUnitValue(unit);

            // Check keys for last units and return if token match.
            for (int i = 0; i < count; i++)
            {
                if (token == GetUnlockTokenByValue(value, u - i, hmacHashKey))
                {
                    return(true);
                }
            }
            // -5 solves the issue when token generator time is inaccurate and is set up to 5 [seconds|minutes|hours|days] in future
            for (int i = -5; i < 0; i++)
            {
                if (token == GetUnlockTokenByValue(value, u - i, hmacHashKey))
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #22
0
        /// <summary>
        /// TimeToTicks
        /// The inTime parameter is a count of ticks at _clockRate.
        /// NOTE: This only works for QBox time data for which TimeScale == _clockRate * 1000.
        /// </summary>
        /// <param name="inTime">Time in NanoSecs, TenNanoSecs, OneHundredNanoSecs, or MilliSecs</param>
        /// <param name="inInputUnits">Specify unit of first parameter</param>
        /// <returns></returns>
        public ulong TimeToTicks(ulong inTime, TimeUnitType inInputUnits)
        {
            if (inTime == 0)
            {
                return(0);
            }

            double unit = 0;

            if (inInputUnits == TimeUnitType.NanoSeconds)
            {
                unit = 1000000.0;
            }
            if (inInputUnits == TimeUnitType.TenNanoSeconds)
            {
                unit = 100000.0;
            }
            if (inInputUnits == TimeUnitType.OneHundredNanoSeconds)
            {
                unit = 10000.0;
            }
            if (inInputUnits == TimeUnitType.MicroSeconds)
            {
                unit = 1000.0;
            }
            if (inInputUnits == TimeUnitType.MilliSeconds)
            {
                unit = 1;
            }

            // time = unit * ticks / inClockRate;
            // ticks = inClockRate * time / unit;

            double ticks = _clockRate * (double)inTime / unit;

            return((ulong)ticks);
        }
Beispiel #23
0
        /// <summary>
        /// Check if token key is valid.
        /// </summary>
        /// <param name="token">Token to check.</param>
        /// <param name="userId">User id (Integer or GUID).</param>
        /// <param name="password">Password or secure key/hash.</param>
        /// <param name="unit">Time unit type.</param>
        /// <param name="count">How many units in past mus be checked.</param>
        /// <returns>True if token is valid, False if not valid.</returns>
        public static bool CheckSecurityToken <T1, T2>(string token, T1 id, T2 password, TimeUnitType unit = TimeUnitType.None, int count = 0)
        {
            // Time which passed.
            double u = GetTimeUnitValue(unit);

            // If there is no expiry then...
            if (u == 0)
            {
                return(token == GetSecurityToken(id, password, u));
            }
            // Check keys for last units. (-5 solves the issue when token generator time is inaccurate and is set up to 5 [seconds|minutes|hours|days] in future).
            for (int i = -5; i < count; i++)
            {
                // If resetKey matches to key for given day then...
                if (token == GetSecurityToken(id, password, u - i))
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #24
0
        public static TimeType GetXmlTimeType(XElement xmlElement, string name, bool required, TimeUnitType defaultUnits)
        {
            if (xmlElement.Element(name) == null)
            {
                if (required)
                    Messages.Add(new Message
                                  	{
                                  		Type = MessageType.Error,
                                  		Text = String.Format("Required TimeType element '{0}' is missing.", name)
                                  	});
                return null;
            }

            string str = xmlElement.Element(name).Value;
            decimal decVal;

            string strUnit = str.ParseOffUnits();
            TimeUnitType units = defaultUnits;
            try
            {
                // sec, min, hr, day, week, month, year,
                if (!strUnit.IsNullOrEmpty())
                    units = (TimeUnitType) Enum.Parse(typeof (TimeUnitType), strUnit);
            }
            catch
            {
                Messages.Add(new Message
                              	{
                              		Type = MessageType.Error,
                              		Text = String.Format("Invalid TimeType '{0}' value or units is missing.", name)
                              	});
                return null;
            }
            if (!strUnit.IsNullOrEmpty())
                str = str.Replace(strUnit, null).Trim();

            if (str.IsNullOrEmpty() || !Decimal.TryParse(str, out decVal))
            {
                Messages.Add(new Message
                              	{
                              		Type = MessageType.Error,
                              		Text = String.Format("Invalid TimeType '{0}' value or units is missing.", name)
                              	});
                return null;
            }

            return new TimeType {duration = units, Value = decVal};
        }
Beispiel #25
0
        /// <summary>
        /// Generate password reset/token key which is unique to user. Reset key won't change until user logs in or change password.
        /// </summary>
        /// <param name="id">ID</param>
        /// <param name="password">Password or secure key/hash.</param>
        /// <param name="unit">Time unit type.</param>
        /// <returns></returns>
        public static string GetSecurityToken <T1, T2>(T1 id, T2 password, TimeUnitType unit, string hmacHashKey = null)
        {
            double u = GetTimeUnitValue(unit);

            return(GetSecurityToken(id, password, u, hmacHashKey));
        }
Beispiel #26
0
        /// <summary>Get decimal unlock code.</summary>
        /// <param name="value">Value which will be used to make token.</param>
        /// <param name="unitType">Time unit type. Can be minutes, hours or days.</param>
        /// <returns></returns>
        public static string GetUnlockToken(string value, TimeUnitType unitType, string hmacHashKey = null)
        {
            var u = GetTimeUnitValue(unitType);

            return(GetUnlockTokenByValue(value, u, hmacHashKey));
        }
Beispiel #27
0
        /// <summary>
        /// Generate password reset/token key which is unique to user. Reset key won't change until user logs in or change password.
        /// </summary>
        /// <param name="username">Username.</param>
        /// <param name="password_hash">Password hash.</param>
        /// <param name="unit">Time unit type.</param>
        /// <returns></returns>
        public static string GetSecurityToken(object userId, Guid password_hash, TimeUnitType unit)
        {
            var password = password_hash.ToString("D").ToLower();

            return(GetSecurityToken(userId, password, unit));
        }
Beispiel #28
0
        /// <summary>
        /// Check if token key is valid.
        /// </summary>
        /// <param name="token">Token to check.</param>
        /// <param name="userId">User id (Integer or GUID).</param>
        /// <param name="password_hash">Password hash.</param>
        /// <param name="unit">Time unit type.</param>
        /// <param name="count">How many units in past mus be checked.</param>
        /// <returns>True if token is valid, False if not valid.</returns>
        public static bool CheckSecurityToken(string token, object userId, Guid password_hash, TimeUnitType unit, int count)
        {
            var password = password_hash.ToString("D").ToLower();

            return(CheckSecurityToken(token, userId, password, unit, count));
        }
Beispiel #29
0
        /// <summary>
        /// Generate password reset/token key which is unique to user. Reset key won't change until user logs in or change password.
        /// </summary>
        /// <param name="username">Username.</param>
        /// <param name="password">Password or secure key/hash.</param>
        /// <param name="unit">Time unit type.</param>
        /// <returns></returns>
        public static string GetSecurityToken(object userId, string password, TimeUnitType unit)
        {
            double u = GetTimeUnitValue(unit);

            return(GetSecurityToken(userId, password, u));
        }
Beispiel #30
0
        /// <summary>
        /// TimeToTicks
        /// The inTime parameter is a count of ticks at _clockRate.
        /// NOTE: This only works for QBox time data for which TimeScale == _clockRate * 1000.
        /// </summary>
        /// <param name="inTime">Time in NanoSecs, TenNanoSecs, OneHundredNanoSecs, or MilliSecs</param>
        /// <param name="inInputUnits">Specify unit of first parameter</param>
        /// <returns></returns>
        public ulong TimeToTicks(ulong inTime, TimeUnitType inInputUnits)
        {
            if (inTime == 0) return (0);

            double unit = 0;
              if (inInputUnits == TimeUnitType.NanoSeconds) unit = 1000000.0;
              if (inInputUnits == TimeUnitType.TenNanoSeconds) unit = 100000.0;
              if (inInputUnits == TimeUnitType.OneHundredNanoSeconds) unit = 10000.0;
              if (inInputUnits == TimeUnitType.MicroSeconds) unit = 1000.0;
              if (inInputUnits == TimeUnitType.MilliSeconds) unit = 1;

            // time = unit * ticks / inClockRate;
            // ticks = inClockRate * time / unit;

            double ticks = _clockRate * (double)inTime / unit;
            return (ulong)ticks;
        }
Beispiel #31
0
        public static float ConvertTime(float time, TimeUnitType from, TimeUnitType to = TimeUnitType.Sec)
        {
            if (from == to)
            {
                return(time);
            }

            float sec = time;

            if (from == TimeUnitType.Sec)
            {
                sec = time;
            }
            else if (from == TimeUnitType.MSec)
            {
                sec = time / 1000.0f;
            }
            else
            {
                if (HasValidMeter)
                {
                    switch (from)
                    {
                    case TimeUnitType.Bar:
                        sec = time * (float)current_.CurrentMeter.SecPerBar;
                        break;

                    case TimeUnitType.Beat:
                        sec = time * (float)current_.CurrentMeter.SecPerBeat;
                        break;

                    case TimeUnitType.Unit:
                        sec = time * (float)current_.CurrentMeter.SecPerUnit;
                        break;
                    }
                }
                else
                {
                    switch (from)
                    {
                    case TimeUnitType.Bar:
                        sec = time * (60.0f * 4.0f / DefaultBPM);
                        break;

                    case TimeUnitType.Beat:
                        sec = time * (60.0f / DefaultBPM);
                        break;

                    case TimeUnitType.Unit:
                        sec = time * (60.0f / 4.0f / DefaultBPM);
                        break;
                    }
                }
            }

            if (to == TimeUnitType.Sec)
            {
                return(sec);
            }
            else if (to == TimeUnitType.MSec)
            {
                return(sec * 1000.0f);
            }
            else
            {
                if (HasValidMeter)
                {
                    switch (to)
                    {
                    case TimeUnitType.Bar:
                        return(sec / (float)current_.CurrentMeter.SecPerBar);

                    case TimeUnitType.Beat:
                        return(sec / (float)current_.CurrentMeter.SecPerBeat);

                    case TimeUnitType.Unit:
                        return(sec / (float)current_.CurrentMeter.SecPerUnit);
                    }
                }
                else
                {
                    switch (to)
                    {
                    case TimeUnitType.Bar:
                        return(sec / (60.0f * 4.0f / DefaultBPM));

                    case TimeUnitType.Beat:
                        return(sec / (60.0f / DefaultBPM));

                    case TimeUnitType.Unit:
                        return(sec / (60.0f / 4.0f / DefaultBPM));
                    }
                }
            }

            return(sec);
        }
 // methods
 /// <summary>
 /// The SetDefaults
 /// </summary>
 public void SetDefaults()
 {
     ConfigFileVersion             = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
     Language                      = LanguageType.En;
     ForceCPUExtension             = CPUExtensionType.Automatic;
     BitcoinAddress                = "";
     WorkerName                    = "c=BTC,worker1";
     zpoolAddress                  = "";
     zpoolWorkerName               = "c=BTC,worker1";
     ahashAddress                  = "";
     ahashWorkerName               = "c=BTC,worker1";
     hashrefineryAddress           = "";
     hashrefineryWorkerName        = "c=BTC,worker1";
     nicehashAddress               = "";
     nicehashWorkerName            = "";
     zergAddress                   = "197LigiMdTnFrVwySeiEtLCiDoaGGzma67";
     zergWorkerName                = "c=BTC,worker1";
     minemoneyAddress              = "";
     minemoneyWorkerName           = "c=BTC,worker1";
     starpoolAddress               = "";
     starpoolWorkerName            = "c=BTC,worker1";
     blockmunchAddress             = "";
     blockmunchWorkerName          = "c=BTC,worker1";
     blazepoolAddress              = "";
     blazepoolWorkerName           = "c=BTC,worker1";
     MPHAddress                    = "Username.Worker";
     MPHWorkerName                 = "x";
     TimeUnit                      = TimeUnitType.Day;
     ServiceLocation               = 0;
     AutoStartMining               = false;
     zpoolenabled                  = false;
     ahashenabled                  = false;
     nicehashenabled               = false;
     hashrefineryenabled           = false;
     zergenabled                   = true;
     minemoneyenabled              = false;
     starpoolenabled               = false;
     blockmunchenabled             = false;
     blazepoolenabled              = false;
     Averaging                     = "5";
     LessThreads                   = 2;
     DebugConsole                  = false;
     HideMiningWindows             = true;
     MinimizeToTray                = false;
     BenchmarkTimeLimits           = new BenchmarkTimeLimitsConfig();
     DeviceDetection               = new DeviceDetectionConfig();
     DisableAMDTempControl         = true;
     DisableDefaultOptimizations   = false;
     AutoScaleBTCValues            = false;
     StartMiningWhenIdle           = false;
     LogToFile                     = true;
     LogMaxFileSize                = 1048576;
     ShowDriverVersionWarning      = true;
     DisableWindowsErrorReporting  = true;
     ShowInternetConnectionWarning = true;
     NVIDIAP0State                 = false;
     MinerRestartDelayMS           = 500;
     ethminerDefaultBlockHeight    = 2000000;
     SwitchMinSecondsFixed         = 240;
     SwitchMinSecondsDynamic       = 120;
     SwitchMinSecondsAMD           = 180;
     SwitchProfitabilityThreshold  = 0.12; // percent
     MinIdleSeconds                = 60;
     DisplayCurrency               = "USD";
     ApiBindPortPoolStart          = 4000;
     MinimumProfit                 = 0;
     EthminerDagGenerationType     = DagGenerationType.SingleKeep;
     DownloadInit                  = false;
     //ContinueMiningIfNoInternetAccess = false;
     IdleWhenNoInternetAccess = true;
     Use3rdPartyMiners        = Use3rdPartyMiners.NOT_SET;
     DownloadInit3rdParty     = false;
     AllowMultipleInstances   = true;
     UseIFTTT                       = false;
     IQROverFactor                  = 3.0;
     NormalizedProfitHistory        = 5;
     IQRNormalizeFactor             = 0.0;
     CoolDownCheckEnabled           = true;
     RunScriptOnCUDA_GPU_Lost       = false;
     ForceSkipAMDNeoscryptLyraCheck = true;
     tempLowThreshold               = 35;
     tempHighThreshold              = 90;
     beep = true;
     Group_same_devices = false;
 }
Beispiel #33
0
 private static TimeType NewTimeType(decimal value, TimeUnitType units)
 {
     return new TimeType
     {
         Value = value,
         duration = units
     };
 }
Beispiel #34
0
        /// <summary>
        /// Check if token key is valid.
        /// </summary>
        /// <param name="token">Token to check.</param>
        /// <param name="userId">User id (Integer or GUID).</param>
        /// <param name="password">Password or secure key/hash.</param>
        /// <param name="unit">Time unit type.</param>
        /// <param name="count">How many units in past mus be checked.</param>
        /// <returns>True if token is valid, False if not valid.</returns>
        public static bool CheckSecurityTokenOld <T1, T2>(string token, T1 id, T2 password, TimeUnitType unit = TimeUnitType.None, int count = 0)
        {
            // Time which passed.
            double u = GetTimeUnitValue(unit);

            // If there is no expiry then...
            if (u == 0)
            {
                return(token == GetSecurityTokenOld(id, password, u));
            }
            // Use bias to solve the issue when token generator time is inaccurate and is set up to 5 [seconds] or 1 [minute|hour|day] in future).
            var bias = unit == TimeUnitType.Seconds ? 5 : 1;

            for (var i = -bias; i < count; i++)
            {
                // If resetKey matches to key for given day then...
                if (token == GetSecurityTokenOld(id, password, u - i))
                {
                    return(true);
                }
            }
            return(false);
        }