コード例 #1
0
        public void TestClockSwitch()
        {
            var settings = new TimeSettings
            {
                InitialTime   = 60,
                MoveIncrement = 1
            };

            var clock = new ChessClock(settings);

            clock.StartClock(Base.Color.White);
            Thread.Sleep(1500);
            clock.StartClock(Base.Color.Black);
            Thread.Sleep(3000);
            clock.StartClock(Base.Color.White);
            Thread.Sleep(2000);
            clock.StopClock();

            Assert.AreEqual((double)0, (double)clock.Elapsed, (double)0);
            Assert.AreEqual(60000 - 1500 + 1000 - 2000 + 1000, (double)clock.TimeRemainingWhite, (double)10);
            Assert.AreEqual(60000 - 3000 + 1000, (double)clock.TimeRemainingBlack, (double)10);

            Assert.AreEqual((double)3500, (double)clock.TimeElapsedWhite, (double)0);
            Assert.AreEqual((double)3000, (double)clock.TimeElapsedBlack, (double)0);
        }
コード例 #2
0
        public MainPage()
        {
            this.InitializeComponent();

            //Set IoT Hub & Azure Storage connection string from container for app settings
            IoTHubConnTextBox.Text  = App.IOTHUBCONNSTRING;
            StorageConnTextBox.Text = App.STORAGECONNSTRING;
            if (App.IOTHUBCONNSTRING.Length > 0)
            {
                ListDevices();
                SettingsGrid.Visibility = Visibility.Collapsed;
            }

            //Set root MainPage for all User Controls
            DeviceInfo.SetMainPage(this);
            Applications.SetMainPage(this);
            WindowsTelemetry.SetMainPage(this);
            WindowsUpdate.SetMainPage(this);
            Reboot.SetMainPage(this);
            TimeSettings.SetMainPage(this);
            Certificates.SetMainPage(this);
            DiagnosticLogs.SetMainPage(this);
            FactoryReset.SetMainPage(this);
            Wifi.SetMainPage(this);
            DHA.SetMainPage(this);
        }
コード例 #3
0
ファイル: ChessClockTests.cs プロジェクト: adh2050/Chess
        public void TestClock1()
        {
            var settings = new TimeSettings
            {
                InitialTime = 60,
                MoveIncrement = 1
            };

            var clock = new ChessClock(settings);
            clock.StartClock(Base.Color.White);
            Thread.Sleep(1500);
            var elapsed = clock.Elapsed;
            clock.StopClock();
            Assert.AreEqual((double)1500, (double)elapsed, (double)10);
            Assert.AreEqual(1500, (double)clock.TimeElapsedWhite, (double)10);
            Assert.AreEqual(60000 - 1500 + 1000, (double)clock.TimeRemainingWhite, (double)10);
            Assert.AreEqual((double)0, (double)clock.Elapsed, (double)0);

            clock.StartClock(Base.Color.Black);
            Thread.Sleep(3000);
            elapsed = clock.Elapsed;
            clock.StopClock();
            Assert.AreEqual((double)3000, (double)elapsed, (double)10);
            Assert.AreEqual(3000, (double)clock.TimeElapsedBlack, (double)10);
            Assert.AreEqual(60000 - 3000 + 1000, (double)clock.TimeRemainingBlack, (double)10);
            Assert.AreEqual((double)0, (double)clock.Elapsed, (double)0);

            // assert white unaffected
            Assert.AreEqual(1500, (double)clock.TimeElapsedWhite, (double)10);
            Assert.AreEqual(60000 - 1500 + 1000, (double)clock.TimeRemainingWhite, (double)10);
        }
コード例 #4
0
        public static async Task <TimeSettings> getTimeSettings(string uid)
        {
            try
            {
                string url      = AppConstants.BaseUrl + AppConstants.timeSettingsUrl + "/" + uid;
                var    response = await client.GetStringAsync(url);

                //Debug.WriteLine("Getting user. User info below:");
                Debug.WriteLine("Time Settings");
                Debug.WriteLine(response);
                TimeResponse timeArr = new TimeResponse();
                timeArr.result = JsonConvert.DeserializeObject <List <Times> >(response);
                Times        times     = timeArr.result[0];
                TimeSettings userTimes = new TimeSettings()
                {
                    MorningStartTime   = DataParser.ToTimeSpan(times.morning_time),
                    AfterNoonStartTime = DataParser.ToTimeSpan(times.afternoon_time),
                    EveningStartTime   = DataParser.ToTimeSpan(times.evening_time),
                    NightStartTime     = DataParser.ToTimeSpan(times.night_time),
                    TimeZone           = times.time_zone,
                    DayStart           = DataParser.ToTimeSpan(times.day_start),
                    DayEnd             = DataParser.ToTimeSpan(times.day_end)
                };
                Debug.WriteLine(userTimes.MorningStartTime);
                Debug.WriteLine(userTimes.AfterNoonStartTime);
                Debug.WriteLine(userTimes.EveningStartTime);
                return(userTimes);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(null);
            }
        }
コード例 #5
0
    // Start is called before the first frame update
    void Start()
    {
        if (cam == null)
        {
            cam = Camera.main;
        }

        if (dirLight == null)
        {
            dirLight = GameObject.Find("Directional Light").GetComponent <Light>();
        }

        if (fogController == null)
        {
            fogController = GameObject.Find("FogController").GetComponent <FogController>();
        }

        if (oceanFloorScript == null)
        {
            oceanFloorScript = GameObject.Find("OceanFloorLight").GetComponent <SetupOceanFloorScript>();
        }

        if (watersurface == null)
        {
            watersurface = GameObject.Find("WaterSurface").GetComponent <WaterSurfaceScript>();
        }


        currentIndex  = 1;
        currentTarget = timeSettings[currentIndex];

        StartCoroutine(StartInTime(30));
    }
コード例 #6
0
        public void ToMappingModel_WithTimeSetrtings_ReturnsCorrectTimeSettings()
        {
            // Assign
            var start        = DateTime.Now;
            var ttl          = 100;
            var end          = start.AddSeconds(ttl);
            var request      = Request.Create();
            var response     = Response.Create();
            var timeSettings = new TimeSettings
            {
                Start = start,
                End   = end,
                TTL   = ttl
            };
            var mapping = new Mapping(Guid.NewGuid(), "", null, _settings, request, response, 42, null, null, null, null, null, timeSettings);

            // Act
            var model = _sut.ToMappingModel(mapping);

            // Assert
            model.Should().NotBeNull();
            model.TimeSettings.Should().NotBeNull();
            model.TimeSettings.Start.Should().Be(start);
            model.TimeSettings.End.Should().Be(end);
            model.TimeSettings.TTL.Should().Be(ttl);
        }
コード例 #7
0
ファイル: GoGameInfo.cs プロジェクト: nyoshi/strasgo
 public GoGameInfo()
 {
     m_size = 9;
     m_komi = 0.5f;
     m_handicap = 0;
     m_timeSettings = new TimeSettings();
 }
コード例 #8
0
        /// <summary>
        /// Create TimeSettings on the Device.
        /// </summary>
        private TimeSettings CreateAndValidateTimeSettings(string deviceName)
        {
            TimeSettings timeSettingsToCreate = new TimeSettings("Pacific Standard Time");

            timeSettingsToCreate.PrimaryTimeServer   = "time.windows.com";
            timeSettingsToCreate.SecondaryTimeServer = new List <string>()
            {
                "8.8.8.8"
            };

            this.Client.DeviceSettings.CreateOrUpdateTimeSettings(
                deviceName.GetDoubleEncoded(),
                timeSettingsToCreate,
                this.ResourceGroupName,
                this.ManagerName);

            var timeSettings = this.Client.DeviceSettings.GetTimeSettings(
                deviceName.GetDoubleEncoded(),
                this.ResourceGroupName,
                this.ManagerName);

            //validation
            Assert.True(timeSettings != null && timeSettings.PrimaryTimeServer.Equals("time.windows.com") &&
                        timeSettings.SecondaryTimeServer[0].Equals("8.8.8.8"), "Creation of Time Setting was not successful.");

            return(timeSettings);
        }
コード例 #9
0
        private async void initialiseTodaysOccurances(string userID)
        {
            try
            {
                TimeSettings timeSettings = await RdsConnect.getTimeSettings(userID);

                if (timeSettings != null)
                {
                    DateTime morning = today.Date + timeSettings.MorningStartTime;
                    morningStart = morning;
                    DateTime afternoon = today.Date + timeSettings.AfterNoonStartTime;
                    afternoonStart = afternoon;
                    DateTime evening = today.Date + timeSettings.EveningStartTime;
                    eveningStart = evening;
                    Debug.WriteLine(morningStart.ToString() + ", " + afternoonStart.ToString() + ", " + eveningStart.ToString());
                }

                string url = AppConstants.BaseUrl + AppConstants.goalsAndRoutinesUrl + "/" + userID;
                todaysOccurances = await RdsConnect.getOccurances(url);

                todaysOccurances = todaysOccurances.Concat(todaysEvents).ToList();
                SortOccurancesAndGroupGoals();
                CreateList();
            }
            catch (Exception e)
            {
                await DisplayAlert("Alert", "Error in TodaysListTest initialiseTodaysOccurances. Error: " + e.ToString(), "OK");
            }
        }
コード例 #10
0
 void OnEnable()
 {
     _settingUpdates = _gameSettingsProvider.SettingChanges.Subscribe(settings => {
         _time    = settings.Gameplay.Time;
         _weather = settings.Gameplay.Weather;
     });
 }
コード例 #11
0
        public TimeRequired GetTimeRequiredToRead()
        {
            double timeInvesmentPerPage = TimeSettings.GetFractionFormat();
            var    minuteOfInvesment    = Book.Pages * timeInvesmentPerPage;
            int    hour   = (int)minuteOfInvesment / 60; //60 second
            int    minute = (int)minuteOfInvesment % 60;

            return(new TimeRequired(hour, minute, 0));
        }
コード例 #12
0
ファイル: TimeSetting.cs プロジェクト: wurunduk/SI
        public TimeSetting(string name, TimeSettings timeSettings, TimeSettingsTypes timeSettingsType, int value, int maximum)
        {
            Name = name;
            this._timeSettings     = timeSettings;
            this._timeSettingsType = timeSettingsType;
            Maximum = maximum;

            DefaultValue = value;
        }
コード例 #13
0
 public Base(SpellsSettings spellSetting, TimeSettings timeSetting, OtherSettings otherSetting,short evadeMode, bool useEvade,bool useEvadeSkills)
 {
     SpellSetting = spellSetting;
     TimeSetting = timeSetting;
     OtherSetting = otherSetting;
     EvadeMode = evadeMode;
     UseEvade = useEvade;
     UseEvadeSkills = useEvadeSkills;
 }
コード例 #14
0
ファイル: TimeSettingsDTO.cs プロジェクト: StruCal/StruCal
 public static TimeSettingsDTO ToTimeSettingsDTO(this TimeSettings timeSettings)
 {
     return(new TimeSettingsDTO
     {
         deltaTime = timeSettings.DeltaTime,
         startTime = timeSettings.StartTime,
         endTime = timeSettings.EndTime,
         deltaTimeResults = timeSettings.DeltaTimeResults,
     });
 }
コード例 #15
0
ファイル: GoClock.cs プロジェクト: nyoshi/strasgo
        public GoClock(TimeSettings settings)
        {
            BlackInfiniteTime = false;
            WhiteInfiniteTime = false;
            CanLooseOnTime = true;

            BlackTime = new TimeSettings(settings);
            WhiteTime = new TimeSettings(settings);
            OrginialTime = new TimeSettings(settings);

            m_stopwatch = new Stopwatch();
        }
コード例 #16
0
        private TimeSettings ToTimeSettings(UserDto dto)
        {
            TimeSettings timeSettings = new TimeSettings();

            timeSettings.TimeZone           = dto.time_zone;
            timeSettings.MorningStartTime   = DataParser.ToTimeSpan(dto.morning_time);
            timeSettings.AfterNoonStartTime = DataParser.ToTimeSpan(dto.afternoon_time);
            timeSettings.EveningStartTime   = DataParser.ToTimeSpan(dto.evening_time);
            timeSettings.NightStartTime     = DataParser.ToTimeSpan(dto.night_time);
            timeSettings.DayStart           = DataParser.ToTimeSpan(dto.day_start);
            timeSettings.DayEnd             = DataParser.ToTimeSpan(dto.day_end);
            return(timeSettings);
        }
コード例 #17
0
        public bool TrySetTimeControl(string numMoves, string timeControl)
        {
            if (!int.TryParse(numMoves, out int movesCount))
            {
                logger.Error($"Parameter numMoves not int value -> {numMoves}"); return(false);
            }
            if (!int.TryParse(timeControl, out int timeControlValue))
            {
                logger.Error($"Parameter timeControl not int value -> {timeControl}"); return(false);
            }

            if (movesCount == 40)
            {
                if (timeControlValue >= 0 && timeControlValue < 5)
                {
                    GameTimeSettings = TimeSettings.Moves40In1Minute; return(true);
                }
                if (timeControlValue >= 5 && timeControlValue < 10)
                {
                    GameTimeSettings = TimeSettings.Moves40In5Minutes; return(true);
                }
                if (timeControlValue >= 10 && timeControlValue < 20)
                {
                    GameTimeSettings = TimeSettings.Moves40In10Minutes; return(true);
                }
                if (timeControlValue >= 20 && timeControlValue < 30)
                {
                    GameTimeSettings = TimeSettings.Moves40In20Minutes; return(true);
                }
                if (timeControlValue >= 30 && timeControlValue < 40)
                {
                    GameTimeSettings = TimeSettings.Moves40In30Minutes; return(true);
                }
                if (timeControlValue >= 40 && timeControlValue < 60)
                {
                    GameTimeSettings = TimeSettings.Moves40In40Minutes; return(true);
                }
                if (timeControlValue >= 60 && timeControlValue < 90)
                {
                    GameTimeSettings = TimeSettings.Moves40In60Minutes; return(true);
                }
                if (timeControlValue >= 90)
                {
                    GameTimeSettings = TimeSettings.Moves40In90Minutes;
                }
                return(true);
            }

            logger.Error($"Supplied values {numMoves} {timeControl} don't match supported values.");
            return(false);
        }
コード例 #18
0
ファイル: Worker.cs プロジェクト: svonidze/MediaAccess
        public Worker(
            ILogger <Worker> logger,
            IOptionsMonitor <TimeSettings> optionsSnapshot,
            IModulDengiClient client,
            IConfirmationManager confirmationManager,
            IAccountant accountant)
        {
            this.logger = logger;
            this.confirmationCheckTimeSettings = optionsSnapshot.Get(nameof(this.confirmationCheckTimeSettings));
            this.newProjectCheckTimeSettings   = optionsSnapshot.Get(nameof(this.newProjectCheckTimeSettings));

            this.client = client;
            this.confirmationManager = confirmationManager;
            this.accountant          = accountant;
        }
コード例 #19
0
    private void Awake()
    {
        _time = new TimeSettings();
        _time.DayLengthInMinutes = 2f;
        _time.CurrentDateTime    = new DateTime(2015, 3, 1, 5, 0, 0);
        _time.IsNightSkipped     = false;
        _time.IsTimeSimulated    = true;
        // Lauterbrunnen, Switzerland
        _time.Longitude = -28f;
        _time.Latitude  = 55f;

        _weather = new WeatherSettings();
        _weather.SnowAltitude       = 2750f;
        _weather.IsWeatherSimulated = true;
        _weather.DaysPerSeason      = 2f;
    }
コード例 #20
0
ファイル: MatchRunnerTests.cs プロジェクト: adh2050/Chess
        public void TestMatchRunner1()
        {
            var config = new UciEngineSettings
            {
                Name    = "Rybka",
                Command = @"C:\chess\arena_3.0\Engines\Rybka\Rybka v2.2n2.mp.w32.exe"
            };

            var white        = new UciEnginePlayer(config);
            var black        = new UciEnginePlayer(config);
            var timeSettings = new TimeSettings {
                Name = "60 Sec Match", InitialTime = 60, TimeModeMachine = TimeMode.Blitz
            };
            var runner = new MatchRunner(white, black, timeSettings);

            runner.LoadAndSetup();
        }
コード例 #21
0
        private async void initialiseTodaysOccurances(string userID)
        {
            try
            {
                await CheckVersion();

                TimeSettings timeSettings = await RdsConnect.getTimeSettings(userID);

                if (timeSettings != null)
                {
                    DateTime morning = today.Date + timeSettings.MorningStartTime;
                    morningStart = morning;
                    DateTime afternoon = today.Date + timeSettings.AfterNoonStartTime;
                    afternoonStart = afternoon;
                    DateTime evening = today.Date + timeSettings.EveningStartTime;
                    eveningStart = evening;
                    Debug.WriteLine(morningStart.ToString() + ", " + afternoonStart.ToString() + ", " + eveningStart.ToString());
                    previousTimeSettings = timeSettings;
                }

                string url = AppConstants.BaseUrl + AppConstants.goalsAndRoutinesUrl + "/" + userID;
                Debug.WriteLine("ENDPOINT: " + url);
                todaysOccurances = await RdsConnect.getOccurances(url);

                // COMMENT OUT EVENTS
                if (MainPage.account.isCalendarActive)
                {
                    await CallGetEvents();
                }
                UserDialogs.Instance.ShowLoading("Loading...");
                todaysOccurances = todaysOccurances.Concat(todaysEvents).ToList();
                SortOccurancesAndGroupGoals();
                CreateList();
                UserDialogs.Instance.HideLoading();
            }
            catch (Exception e)
            {
                await DisplayAlert("Alert", "Error in TodaysListTest initialiseTodaysOccurances. Error: " + e.ToString(), "OK");
            }
        }
コード例 #22
0
    private void LerpTowardsTargetTime()
    {
        //Fog distance
        fogController._fogEnd =
            Mathf.Lerp(fogController._fogEnd, currentTarget.fogEnd, t);
        //light color
        dirLight.color = Color.Lerp(dirLight.color,
                                    currentTarget.dirLightColor, t);
        //background / ocean and fog color
        cam.backgroundColor = Color.Lerp(cam.backgroundColor,
                                         currentTarget.cameraColor, t);
        //surface color
        watersurface.color = Color.Lerp(watersurface.color,
                                        currentTarget.waterSurfaceColor, t);
        //the light pattern on floor color
        oceanFloorScript.lightColor = Color.Lerp(oceanFloorScript.lightColor,
                                                 currentTarget.oceanFloorColor, t);

        //If lerped close enough
        if (Mathf.Abs(currentTarget.fogEnd - fogController._fogEnd) < closeEnough)
        {
            //if we have reached the end, turn back
            if (ascending && currentIndex + 1 >= timeSettings.Length)
            {
                ascending = false;
            }

            if (!ascending && currentIndex - 1 < 0)
            {
                ascending = true;
            }

            //fx 1=>2 || 2=>1
            currentIndex += ascending ? 1 : -1;

            currentTarget = timeSettings[currentIndex];

            t = 0;
        }
    }
コード例 #23
0
ファイル: TimeArgs.cs プロジェクト: benjalon/evolution-sim
 public TimeArgs(TimeSettings timeSetting) : base()
 {
     TimeSetting = timeSetting;
 }
コード例 #24
0
ファイル: TimeModels.cs プロジェクト: walklook/Cubizer
 public override void Reset()
 {
     _settings = TimeSettings.defaultSettings;
 }
コード例 #25
0
ファイル: TimeViewModel.cs プロジェクト: adh2050/Chess
 private void DeleteTimeSetting()
 {
     MasterState.Instance.RemoveTimeSetting(SelectedSetting);
     SelectedSetting = TimeSettings.FirstOrDefault();
     NotifyChanged(() => TimeSettings);
 }
 /// <summary>
 /// Creates or updates the time settings of the specified device.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='deviceName'>
 /// The device name
 /// </param>
 /// <param name='parameters'>
 /// The time settings to be added or updated.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The resource group name
 /// </param>
 /// <param name='managerName'>
 /// The manager name
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <TimeSettings> BeginCreateOrUpdateTimeSettingsAsync(this IDeviceSettingsOperations operations, string deviceName, TimeSettings parameters, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateOrUpdateTimeSettingsWithHttpMessagesAsync(deviceName, parameters, resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Creates or updates the time settings of the specified device.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='deviceName'>
 /// The device name
 /// </param>
 /// <param name='parameters'>
 /// The time settings to be added or updated.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The resource group name
 /// </param>
 /// <param name='managerName'>
 /// The manager name
 /// </param>
 public static TimeSettings BeginCreateOrUpdateTimeSettings(this IDeviceSettingsOperations operations, string deviceName, TimeSettings parameters, string resourceGroupName, string managerName)
 {
     return(operations.BeginCreateOrUpdateTimeSettingsAsync(deviceName, parameters, resourceGroupName, managerName).GetAwaiter().GetResult());
 }
コード例 #28
0
ファイル: ResultCreator.cs プロジェクト: StruCal/StruCal
 public ResultCreator(IGradient gradient, TimeSettings timeSettings)
 {
     this.colorFactory = new ColorProviderFactory(gradient);
     this.timeSettings = timeSettings;
 }