Esempio n. 1
0
        private void loadState()
        {
            Console.WriteLine("Starting Proxy...");

            while (true)
            {
                try
                {
                    _nextState = new ConfigState();
                    _nextState._maskingModel         = ConfigHelper.populateMaskingModel();
                    _nextState._oidToTableSchemaName = ConfigHelper.populateTableOidsMapper();
                    _nextState._nonSystemTableOids   = ConfigHelper.populateNonSystemTableOids(_nextState._oidToTableSchemaName);
                    _nextState._oidToDataType        = ConfigHelper.populateDataTypeOids();
                    _nextState._keyedColumns         = ConfigHelper.populateAllPksAndFks();
                    _state     = _nextState;
                    _nextState = null;
                    break;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine("Failed to start.  This is most likely because we failed to connect to your database to run some preliminary queries.  Ensure the db_connection_details in config.json are correct and that your database is reachable from this machine.   Trying again 5 seconds...");
                    Thread.Sleep(5000);
                }
            }
        }
Esempio n. 2
0
 private void Awake()
 {
     //Cria a primeira instância
     instance = this;
     //Não deixa esse objeto ser destruino no carregamento de uma cena
     DontDestroyOnLoad(gameObject);
     //Cria a maquina de estados
     fsm = gameObject.AddComponent <FSM>();
     //Cria a comunicação com o console
     secretConsole = gameObject.AddComponent <SecretConsole>();
     //Get camera
     cameraObj = GameObject.Find("Main Camera");
     //Get statistics controller
     statiscsController = GameObject.Find("Statistics");            //.GetComponent<StatisticsController>();
     //Define os estados
     initState       = gameObject.AddComponent <InitState>();       //Init
     configState     = gameObject.AddComponent <ConfigState>();     //Config
     statisticsState = gameObject.AddComponent <StatisticsState>(); //StatisticsState
     //gameState = gameObject.AddComponent<GameState>();
     //seriousGameState = gameObject.AddComponent<SeriousGameState>();
     //holoState = gameObject.AddComponent<HoloState>();
     //creditState = gameObject.AddComponent<CreditsState>();
     //Inicializa a maquina de estado passando o primeiro estado
     fsm.Initialize(initState);
 }
Esempio n. 3
0
 public Config()
 {
     OpenFileDirection = "";
     TinyFSFile = "TinyFS.dll";
     LastOpenedFiles = new List<string>();
     State = ConfigState.None;
 }
Esempio n. 4
0
        public override void GetControl()
        {
            base.GetControl();
            _lastState = _state;

            SetSelectorPos();
        }
Esempio n. 5
0
        public ConfigState.ShardServer GetRandomShardServer(ConfigState configState, Random random, bool allowInactive)
        {
            var quorum = configState == null ? null : configState.quorums[0];

            if (configState == null)
            {
                return(null);
            }

            if (!allowInactive && quorum.inactiveNodes.Count > 0)
            {
                return(null);
            }

            var shardServers = configState.shardServers;
            var victimNodeID = quorum.activeNodes[random.Next(quorum.activeNodes.Count)];

            foreach (var shardServer in shardServers)
            {
                if (shardServer.nodeID == victimNodeID)
                {
                    bool isPrimary = (quorum.hasPrimary && quorum.primaryID == victimNodeID);
                    return(shardServer);
                }
            }

            return(null);
        }
Esempio n. 6
0
        private void loadState()
        {
            Console.WriteLine("Starting Proxy...");
            bool success = true;

            try
            {
                _nextState = new ConfigState();
                _nextState._maskingModel         = ConfigHelper.populateMaskingModel();
                _nextState._oidToTableSchemaName = ConfigHelper.populateTableOidsMapper();
                _nextState._nonSystemTableOids   = ConfigHelper.populateNonSystemTableOids(_nextState._oidToTableSchemaName);
                _nextState._oidToDataType        = ConfigHelper.populateDataTypeOids();
                _nextState._keyedColumns         = ConfigHelper.populateAllPksAndFks();
            }
            catch (Exception ex)
            {
                success = false;

                //we failed to load config on startup
                Console.WriteLine("Failed to start.  This is most likely because we failed to connect to your database to run some preliminary queries.  Ensure the db_connection_details in config.json are correct and that your database is reachable from this machine.");
                if (_state == null)
                {
                    throw ex;
                }
            }

            if (success)
            {
                _state     = _nextState;
                _nextState = null;
            }
        }
Esempio n. 7
0
		public AppConfig( string configFile ) {
			this.saveFile = configFile;
			this.configState = ConfigState.Loading;
			this.currencies = new List<Currency>(24);
			try {
				config = Configuration.LoadFromFile(configFile, Encoding.UTF8);
				foreach (Section sec in config) {
					Currency c = sec.CreateObject<Currency>();
					if (sec["Name"].StringValue.Contains("Chaos")) { c.Value = 1; }
					this.currencies.Add(c);
				}
			}
			catch (Exception) {
				InitializeCurrency();
				config = new Configuration();
				byte id = 0;
				var currencyData = currencies.OfType<Currency>().OrderBy(item => item.Name).GetEnumerator();
				while (currencyData.MoveNext()) {
					config.Add(Section.FromObject(SECTION_CURRENCY + id, currencyData.Current));
					id++;
				}
				config.SaveToFile(configFile, Encoding.UTF8);
			}
			configState = ConfigState.Clean;
		}
Esempio n. 8
0
    void Update()
    {
        switch (_state)
        {
        case ConfigState.PreparePlacement:
            _placementComponent.enabled = true;
            _interactivity.IsEnabled    = false;

            State = ConfigState.StartPlacement;
            break;

        case ConfigState.StartPlacement:
            _interactivity.enabled = false;

            State = ConfigState.Placing;
            break;

        case ConfigState.StopPlacement:
            _placementComponent.enabled = false;
            _interactivity.enabled      = true;
            _interactivity.IsEnabled    = true;

            State = ConfigState.Using;
            break;
        }
    }
 public void OnClickConfirm()
 {
     UpdateValues();
     ConfigModule.Apply();
     ConfigState.Save();
     Modal.PushMessageModal("Applied settings changes!", "Changes Applied", null, OnConfirmed, true);
 }
Esempio n. 10
0
        private void init(LiveSplitState state, USB2SnesW.USB2SnesW usb2snesw)
        {
            _state           = state;
            _config_state    = ConfigState.NONE;
            _proto_state     = ProtocolState.NONE;
            _ready_timer     = new Stopwatch();
            _attached_device = string.Empty;
            _settings        = new ComponentSettings(_state)
            {
                Dock = DockStyle.Fill,
            };
            _model = new TimerModel()
            {
                CurrentState = _state
            };
            _state.RegisterTimerModel(_model);
            _stateChanged = false;
            _splits       = new List <string>();
            _inTimer      = false;

            _update_timer = new Timer()
            {
                Interval = 1000
            };
            _update_timer.Tick   += (sender, args) => UpdateSplitsWrapper();
            _update_timer.Enabled = true;

            _state.OnReset += _state_OnReset;
            _state.OnStart += _state_OnStart;
            HorizontalWidth = 3;
            VerticalHeight  = 3;
            _usb2snes       = usb2snesw;
        }
Esempio n. 11
0
 public void OnClickConfirm()
 {
     UpdateValues();
     ConfigState.Save();
     ConfigModule.Apply();
     //MappedInput.SetMapper(ConfigState.Instance.InputMapper); //we need to do this manually unfortunately...
     Modal.PushMessageModal("Applied settings changes!", "Changes Applied", null, OnConfirmed, true);
 }
Esempio n. 12
0
 private void SetConfigState(ConfigState state)
 {
     if (_config_state != state)
     {
         _stateChanged = true;
         _config_state = state;
     }
 }
Esempio n. 13
0
 private void SaveControlMap()
 {
     //commit our modified control map to ConfigState
     InputMap.SaveToConfig();
     if (MappedInput.GetCurrentMapper() is ExplicitKBMInputMapper kMapper)
     {
         kMapper.ReloadControlMap();
     }
     ConfigState.Save(); //do we want this? probably
 }
Esempio n. 14
0
        public override void Update()
        {
            if (_lastState != _state)
            {
                _lastState = _state;
                SetSelectorPos();
                SoundManager.PlaySoundEffect("menu_move");
            }

            base.Update();
        }
Esempio n. 15
0
        public void TestConfigState() // debug purposes only
        {
            Client client = new Client(Utils.GetConfigNodes());

            client.SetGlobalTimeout(15000);

            string config_string = client.GetJSONConfigState();

            System.Console.WriteLine(config_string);

            ConfigState conf = Utils.JsonDeserialize <ConfigState>(System.Text.Encoding.UTF8.GetBytes(config_string));
        }
Esempio n. 16
0
 // 获取配置信息
 private static ConfigState getConf()
 {
     try
     {
         xmlDoc.Load(confPath);
     }
     catch
     {
         ConfigState cstmp = initConfFile();
         if (cstmp > ConfigState.WARING)
         {
             return(cstmp);
         }
         xmlDoc.LoadXml(confPath);
     }
     try
     {
         rootNode = xmlDoc.DocumentElement;
         XmlNode node;
         node    = rootNode.SelectSingleNode("Project");
         Author  = node.SelectSingleNode("Author").InnerText;
         Version = node.SelectSingleNode("Version").InnerText;
         Name    = node.SelectSingleNode("Name").InnerText;
         try
         {
             Name = "f**k";
         }
         catch (Exception ex)
         {
             //Name = "f**k";
             MessageBox.Show(ex.Message);
         }
         node = rootNode.SelectSingleNode("Config");
         foreach (XmlNode userNode in node.SelectNodes("Server"))
         {
             ServerIp        = IPAddress.Parse(userNode.SelectSingleNode("IPAddress").InnerText);
             ServerTcpPort   = int.Parse(userNode.SelectSingleNode("PortTcp").InnerText);
             ServerUdpPort   = int.Parse(userNode.SelectSingleNode("PortUdp").InnerText);
             TimeOut         = int.Parse(userNode.SelectSingleNode("TimeOut").InnerText);
             MaxRepeatTimes  = int.Parse(userNode.SelectSingleNode("MaxRepeatTimes").InnerText);
             MaxContextBytes = int.Parse(userNode.SelectSingleNode("MaxContextBytes").InnerText);
         }
     }
     catch (Exception)
     {
         log.loging("读取链接配置文件出现错误", CJLog.LogLevel.COMMON_ERROR);
         return(ConfigState.DEFAULT);
         //System.Environment.Exit(-1);
     }
     return(ConfigState.OK);
 }
Esempio n. 17
0
 private bool Open()
 {
     try
     {
         this._connection.ConnectionString = "URI=file:" + this._configFile + ",version=3";
         this._connection.Open();
         this._state = ConfigState.Connected;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 18
0
        public override void HandleInput()
        {
            if (_selectedOption != null)
            {
                _selectedOption.Update();

                if (_selectedOption.Exit)
                {
                    _selector.visible = true;

                    _selectedOption.Enabled = false;
                    _selectedOption.Exit    = false;
                    _selectedOption         = null;
                    _state = _lastState;
                    SetSelectorPos();
                }
            }
            else
            {
                if (KeyInput.JustPressedRebindableKey(KeyFunctions.Up))
                {
                    if (_state == ConfigState.KeybindsLabel)
                    {
                        return;
                    }

                    _state--;
                }
                else if (KeyInput.JustPressedRebindableKey(KeyFunctions.Down))
                {
                    if (_state >= ConfigState.LanguageLabel)
                    {
                        return;
                    }

                    _state++;
                }
                else if (KeyInput.JustPressedRebindableKey(KeyFunctions.Accept))
                {
                    SetSettingsState();
                }
                else
                {
                    base.HandleInput();
                }
            }
        }
Esempio n. 19
0
        private IConfig CreateConfig(Type confType, ConfigState state, string loadError)
        {
            var config = (IConfig)Activator.CreateInstance(confType);

            config.ConfigState = state;
            config.LoadError   = loadError;

            // Initialize ConfigBase
            var configBase = config as ConfigBase;

            configBase?.Initialize();

            // Fill default values
            ValueProviderExecutor.Execute(config, new ValueProviderExecutorSettings().AddProviders(ValueProviders));

            return(config);
        }
Esempio n. 20
0
 private void UpdateConfigState(ConfigState state)
 {
     if (state == ConfigState.Stopped)
     {
         SafeThread.SetEnableControl(textOPCNodeName, true);
         SafeThread.SetEnableControl(nudOPCUpdateRate, true);
         SafeThread.SetEnableControl(btnApply, true);
         SafeThread.SetEnableControl(btnTest, true);
     }
     else
     {
         SafeThread.SetEnableControl(textOPCNodeName, false);
         SafeThread.SetEnableControl(nudOPCUpdateRate, false);
         SafeThread.SetEnableControl(btnApply, false);
         SafeThread.SetEnableControl(btnTest, false);
     }
 }
Esempio n. 21
0
        private void SetSettingsState()
        {
            switch (_state)
            {
            //case ConfigState.KeybindsLabel:
            //    _state = ConfigState.SettingKeyBinds;
            //break;
            case ConfigState.SetBgmLabel:
                _selectedOption = _musicSlider;
                break;

            case ConfigState.SetSfxLabel:
                _selectedOption = _sfxSlider;
                break;

            case ConfigState.AutosaveLabel:
                _selectedOption = _autosaveSetter;
                break;

            //case ConfigState.ResolutionLabel:
            //    _state = ConfigState.SettingResolution;
            //    break;
            //case ConfigState.ScalingLabel:
            //    _state = ConfigState.SettingScale;
            //    break;
            case ConfigState.LanguageLabel:
                _selectedOption = _languageSetter;
                break;

            default:
                _state          = ConfigState.KeybindsLabel;
                _selectedOption = null;
                break;
            }

            if (_selectedOption != null)
            {
                _selector.visible       = false;
                _selectedOption.Enabled = true;
            }

            SoundManager.PlaySoundEffect("menu_select");

            SetSelectorPos();
        }
Esempio n. 22
0
 private void UpdateConfigState(ConfigState state)
 {
     if (state == ConfigState.Stopped)
     {
         SafeThread.SetEnableControl(btnApply, true);
         SafeThread.SetEnableControl(btnTest, true);
         SafeThread.SetEnableControl(comboBoxDSN, true);
         SafeThread.SetEnableControl(textBoxUserName, true);
         SafeThread.SetEnableControl(textBoxPassword, true);
     }
     else
     {
         SafeThread.SetEnableControl(btnApply, false);
         SafeThread.SetEnableControl(btnTest, false);
         SafeThread.SetEnableControl(comboBoxDSN, false);
         SafeThread.SetEnableControl(textBoxUserName, false);
         SafeThread.SetEnableControl(textBoxPassword, false);
     }
 }
Esempio n. 23
0
        private void Constructor(string section, string configFile)
        {
            this._state      = ConfigState.Disconnected;
            this._connection = new SqliteConnection();
            if (configFile.Length >= 4)
            {
                if (configFile.Substring(configFile.Length - 4) != ".db3")
                {
                    configFile += ".db3";
                }
            }
            else
            {
                configFile += ".db3";
            }
            if (section != null && section != string.Empty)
            {
                section = ConfigPath + Path.DirectorySeparatorChar + section;
                if (!Directory.Exists(section))
                {
                    Directory.CreateDirectory(section);
                }
                configFile = section + Path.DirectorySeparatorChar + configFile;
            }
            else
            {
                configFile = ConfigPath + Path.DirectorySeparatorChar + configFile;
            }
            this._configFile = configFile;

            if (File.Exists(this._configFile) == false)
            {
                BotShell.Output("[Configuration] No " + this._configFile + " Detected, Creating it...", true);
            }
            if (!this.Open())
            {
                BotShell.Output("[Error] Unable to load configuration file: " + this.ConfigFile);
                this._state = ConfigState.Error;
                return;
            }
            BotShell.Output("[Configuration] Loaded " + this._configFile);
        }
Esempio n. 24
0
 private void UpdateConfigState(ConfigState state)
 {
     if (state == ConfigState.Stopped)
     {
         SafeThread.SetEnableControl(btnApply, true);
         SafeThread.SetReadOnlyDataGridView(dataGridTrn, false);
         SafeThread.SetAllowUserToAddRowsDataGridView(dataGridTrn, true);
         SafeThread.SetVisibleStripItem(navigatorTran, navigatorAddNewItem, true);
         SafeThread.SetVisibleStripItem(navigatorTran, navigatorDeleteItem, true);
     }
     else
     {
         SafeThread.SetEnableControl(btnApply, false);
         SafeThread.CancelEditDataGridView(dataGridTrn);
         SafeThread.SetReadOnlyDataGridView(dataGridTrn, true);
         SafeThread.SetAllowUserToAddRowsDataGridView(dataGridTrn, false);
         SafeThread.SetVisibleStripItem(navigatorTran, navigatorAddNewItem, false);
         SafeThread.SetVisibleStripItem(navigatorTran, navigatorDeleteItem, false);
     }
 }
Esempio n. 25
0
        public ConfigState.ShardServer GetRandomShardServer(ConfigState configState, Random random, bool allowInactive)
        {
            var quorum = configState == null ? null : configState.quorums[0];
            if (configState == null)
                return null;

            if (!allowInactive && quorum.inactiveNodes.Count > 0)
                return null;

            var shardServers = configState.shardServers;
            var victimNodeID = quorum.activeNodes[random.Next(quorum.activeNodes.Count)];
            foreach (var shardServer in shardServers)
            {
                if (shardServer.nodeID == victimNodeID)
                {
                    bool isPrimary = (quorum.hasPrimary && quorum.primaryID == victimNodeID);
                    return shardServer;
                }
            }

            return null;
        }
Esempio n. 26
0
        private void UpdateConfigState(ConfigState state)
        {
            trayNotifyIcon.Text = Application.ProductName + " - " + state.ToString();

            SafeThread.SetTextStripItem(statusbar, statusConfigLabel, "Configuration state: " + state.ToString());
            switch (state)
            {
            case ConfigState.Starting:
                trayNotifyIcon.Icon = Properties.Resources.servicepaused;
                SafeThread.SetImageStripItem(statusbar, statusConfigLabel, Resources.Pause);
                SafeThread.SetEnableStripItem(toolbar, startButton, false);
                SafeThread.SetEnableStripItem(menu, startMenuItem, false);
                SafeThread.SetEnableStripItem(trayMenu, startTrayMenuItem, false);
                SafeThread.SetEnableStripItem(toolbar, stopButton, true);
                SafeThread.SetEnableStripItem(menu, stopMenuItem, true);
                SafeThread.SetEnableStripItem(trayMenu, stopTrayMenuItem, true);
                break;

            case ConfigState.Started:
                trayNotifyIcon.Icon = Properties.Resources.servicerunning;
                SafeThread.SetImageStripItem(statusbar, statusConfigLabel, Resources.Run);
                SafeThread.SetEnableStripItem(toolbar, startButton, false);
                SafeThread.SetEnableStripItem(menu, startMenuItem, false);
                SafeThread.SetEnableStripItem(trayMenu, startTrayMenuItem, false);
                SafeThread.SetEnableStripItem(toolbar, stopButton, true);
                SafeThread.SetEnableStripItem(menu, stopMenuItem, true);
                SafeThread.SetEnableStripItem(trayMenu, stopTrayMenuItem, true);
                break;

            case ConfigState.Stopping:
                trayNotifyIcon.Icon = Properties.Resources.servicepaused;
                SafeThread.SetImageStripItem(statusbar, statusConfigLabel, Resources.Pause);
                SafeThread.SetEnableStripItem(toolbar, startButton, false);
                SafeThread.SetEnableStripItem(menu, startMenuItem, false);
                SafeThread.SetEnableStripItem(trayMenu, startTrayMenuItem, false);
                SafeThread.SetEnableStripItem(toolbar, stopButton, false);
                SafeThread.SetEnableStripItem(menu, stopMenuItem, false);
                SafeThread.SetEnableStripItem(trayMenu, stopTrayMenuItem, false);
                break;

            case ConfigState.Stopped:
                trayNotifyIcon.Icon = Properties.Resources.servicestopped;
                SafeThread.SetImageStripItem(statusbar, statusConfigLabel, Resources.Stop);
                if (Config.Ready)
                {
                    SafeThread.SetEnableStripItem(toolbar, startButton, true);
                    SafeThread.SetEnableStripItem(menu, startMenuItem, true);
                    SafeThread.SetEnableStripItem(trayMenu, startTrayMenuItem, true);
                }
                else
                {
                    SafeThread.SetEnableStripItem(toolbar, startButton, false);
                    SafeThread.SetEnableStripItem(menu, startMenuItem, false);
                    SafeThread.SetEnableStripItem(trayMenu, startTrayMenuItem, false);
                }
                SafeThread.SetEnableStripItem(toolbar, stopButton, false);
                SafeThread.SetEnableStripItem(menu, stopMenuItem, false);
                SafeThread.SetEnableStripItem(trayMenu, stopTrayMenuItem, false);
                break;
            }
        }
Esempio n. 27
0
            private async Task TestImpl(
                IReadOnlyCollection <TestParams> testParamsPerStep
                , int spansToExecCountForInitialRequest
                , int?maxSpansLocalConfig   = null
                , bool?isSampledLocalConfig = null)
            {
                var srcPageData = SampleAppUrlPaths.GenNSpansPage;

                // AssertReceivedDataSampledStatus(receivedData, isSampled, pageData.SpansCount); below relies on number of transactions being 1
                srcPageData.TransactionsCount.Should().Be(1);

                var maxSpansLocalConfigValue  = maxSpansLocalConfig ?? ConfigConsts.DefaultValues.TransactionMaxSpans;
                var isSampledLocalConfigValue = isSampledLocalConfig ?? true;

                MockApmServer.GetAgentsConfig = (httpRequest, httpResponse) => ConfigState.BuildResponse(httpRequest, httpResponse);

                // Send first request before updating central configuration to make sure application is running
                await SendRequestAssertReceivedData(maxSpansLocalConfigValue, isSampledLocalConfigValue, spansToExecCountForInitialRequest);

                await testParamsPerStep.ForEach(async testParams =>
                {
                    ClearState();

                    await ConfigState.UpdateAndWaitForAgentToApply(new Dictionary <string, string>
                    {
                        { TransactionMaxSpansKey, testParams.MaxSpansCfg },
                        { TransactionSampleRateKey, testParams.SampleRateCfg }
                    });

                    var maxSpans = testParams.MaxSpansCfg == null
                                                ? maxSpansLocalConfigValue
                                                : int.TryParse(testParams.MaxSpansCfg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var maxSpansCfgParsed)
                                                        ? maxSpansCfgParsed
                                   // If option value in central config is invalid then agent should fall back on default and not local config
                                                        : ConfigConsts.DefaultValues.TransactionMaxSpans;

                    var isSampled = testParams.SampleRateCfg == null ? isSampledLocalConfigValue : testParams.SampleRateCfg != "0";

                    await SendRequestAssertReceivedData(maxSpans, isSampled, testParams.SpansToExecCount);
                });

                async Task SendRequestAssertReceivedData(int maxSpans, bool isSampled, int spansToExecCount)
                {
                    var urlPath  = srcPageData.RelativeUrlPath + $"?{HomeController.NumberOfSpansQueryStringKey}={spansToExecCount}";
                    var pageData = srcPageData.Clone(urlPath, spansCount: isSampled ? Math.Min(spansToExecCount, maxSpans) : 0);

                    await SendGetRequestToSampleAppAndVerifyResponse(pageData.RelativeUrlPath, pageData.StatusCode);

                    await WaitAndCustomVerifyReceivedData(receivedData =>
                    {
                        VerifyReceivedDataSharedConstraints(pageData, receivedData);

                        // Relies on srcPageData.TransactionsCount.Should().Be(1);
                        AssertReceivedDataSampledStatus(receivedData, isSampled, pageData.SpansCount);

                        if (isSampled)
                        {
                            receivedData.Transactions.First().SpanCount.Dropped.Should().Be(spansToExecCount - pageData.SpansCount);
                        }

                        receivedData.Spans.ForEachIndexed((span, i) =>
                        {
                            span.Name.Should().Be($"Span_#{i}_name");
                            span.Type.Should().Be($"Span_#{i}_type");
                        });
                    }, /* shouldGatherDiagnostics: */ false);
                }
            }
Esempio n. 28
0
 private void ParseConfigLine(string input)
 {
     if (input.StartsWith("###")) return;
     if (input.StartsWith("[onjoin]"))
     {
         _configState = ConfigState.OnJoin;
     }
     else if (input.StartsWith("[timed]"))
     {
         _configState = ConfigState.Timed;
     }
     else if (input.StartsWith("CONSOLE"))
     {
         if (_configState != ConfigState.OnJoin) return;
         var data = input.Substring("CONSOLE ".Length);
         _onJoin.Add(new ConfigItemBase(ItemType.Console, data));
     }
     else if (input.StartsWith("BACKUP"))
     {
         BackupWorld();
     }
     else if (input.Contains("CONSOLE"))
     {
         int i;
         var subs = Regex.Split(input, " CONSOLE ");
         int.TryParse(subs[0], out i);
         var command = subs[1];
         _timed.Add(new ConfigItemTimed(ItemType.Console, command, i, Handler));
     }
     else if (input.Contains("BACKUP"))
     {
         int i;
         var subs = Regex.Split(input, " BACKUP");
         int.TryParse(subs[0], out i);
         _timed.Add(new ConfigItemTimed(ItemType.Backup, " ", i, Handler));
     }
 }
Esempio n. 29
0
 public static string GetControllerURL(ConfigState.Controller controller, uint controllerPort = 8080)
 {
     return "http://" + GetEndpointWithPort(controller.endpoint, controllerPort) + "/";
 }
 //Set ISELF rotation and save world anchor
 void setRotation()
 {
     WorldAnchorManager.Instance.saveAnchor(anchorParent.gameObject);
     configState = ConfigState.CLEAR;
 }
Esempio n. 31
0
        public static List<ConfigState.ShardServer> GetShardServersByTable(ConfigState.Table table, ConfigState configState)
        {
            var shardServers = new List<ConfigState.ShardServer>();

            foreach (var quorum in configState.quorums)
            {
                if (quorum.shards.Intersect(table.shards).Sum() > 0)
                {
                    var quorumServers = GetQuorumActiveShardServers(configState, quorum);
                    foreach (var quorumServer in quorumServers)
                    {
                        if (!shardServers.Contains(quorumServer))
                            shardServers.Add(quorumServer);
                    }
                }
            }

            return shardServers;
        }
Esempio n. 32
0
 public static string GetShardServerURL(ConfigState.ShardServer shardServer)
 {
     return "http://" + GetEndpointWithPort(shardServer.endpoint, shardServer.httpPort) + "/";
 }
Esempio n. 33
0
        public static ConfigState.ShardServer GetShardServer(ConfigState configState, Int64 nodeID)
        {
            foreach (var shardServer in configState.shardServers)
            {
                if (shardServer.nodeID == nodeID)
                    return shardServer;
            }

            return null;
        }
Esempio n. 34
0
        public static List<ConfigState.ShardServer> GetQuorumActiveShardServers(ConfigState configState, ConfigState.Quorum quorum)
        {
            var shardServers = new List<ConfigState.ShardServer>();
            foreach (var nodeID in quorum.activeNodes)
            {
                var shardServer = GetShardServer(configState, nodeID);
                if (shardServer != null)
                    shardServers.Add(shardServer);
            }

            return shardServers;
        }
Esempio n. 35
0
        public static ConfigState.Quorum GetQuorum(ConfigState configState, Int64 quorumID)
        {
            foreach (var quorum in configState.quorums)
            {
                if (quorum.quorumID == quorumID)
                    return quorum;
            }

            return null;
        }
Esempio n. 36
0
 public void Setup()
 {
     this.stateContext = new StateContext();
     this.configState  = new ConfigState(this.stateContext);
     this.stateContext.SetState(this.configState);
 }
Esempio n. 37
0
        public static List<ConfigState.Shard> GetTableShards(ConfigState.Table table, List<ConfigState.Shard> allShards)
        {
            var shards = new List<ConfigState.Shard>();

            foreach (var shard in allShards)
            {
                if (shard.tableID == table.tableID)
                    shards.Add(shard);
            }

            return shards;
        }
 //Set ISELF position to cursor position
 void setPosition()
 {
     anchorParent.position = UIManager.Instance.getAirTapHit();
     configState           = ConfigState.SET_ROTATION;
 }
Esempio n. 39
0
        public static SpeedHacksOptions GetSpeedHacksOptions(this ConfigState configState)
        {
            configState.AddCustomVarIfNotExists(nameof(SpeedHacksOptions), () => new SpeedHacksOptions());

            return(configState.CustomConfigVars[nameof(SpeedHacksOptions)] as SpeedHacksOptions);
        }
 //Delete ISELF world anchor
 void clear()
 {
     WorldAnchorManager.Instance.deleteAnchor(anchorParent.gameObject);
     configState = ConfigState.SET_POSITION;
 }
 public LedViewModel(ConfigState state)
 {
     State = state;
 }
Esempio n. 42
0
        public static ConfigState.Table GetTable(ConfigState configState, Int64 tableID)
        {
            foreach (var table in configState.tables)
            {
                if (table.tableID == tableID)
                    return table;
            }

            return null;
        }
Esempio n. 43
0
        private LimitConfig ReadConfig()
        {
            var lc = new LimitConfig();

            TextReader r = File.OpenText(@"C:\ProgramData\SoftwareLimiter\config.txt");
            // Config format
            // as simple as possible
            // hour:minute floatmax
            // bear in mind that it is not carried after midnight, as in if you want to limit to 35% between 22:00 and 8:00 _of the next day_,
            // your config would look like this:
            // 00:00 35.0
            // 08:00 100.0
            // 22:00 35.0
            // anything after # will be ignored.

            int         hour = -1, minute = -1;
            float       vol;
            string      acc   = "";
            ConfigState state = ConfigState.Hour;

            string toparse = r.ReadToEnd(); // I think the config files will be reasonably small.

            foreach (char c in toparse)
            {
                if (state == ConfigState.Hour)
                {
                    if (acc == "" && c == '#')
                    {
                        state = ConfigState.Comment;
                        continue;
                    }
                    if ("0123456789".Contains(c))
                    {
                        acc += c;
                        continue;
                    }
                    else if (c == ':')
                    {
                        hour  = int.Parse(acc);
                        state = ConfigState.Minute;
                        acc   = "";
                        continue;
                    }
                    if (acc == "" && c == '\n')
                    {
                        // empty line, ignore.
                        continue;
                    }
                }
                else if (state == ConfigState.Minute)
                {
                    if ("0123456789".Contains(c))
                    {
                        acc += c;
                        continue;
                    }
                    else if (c == ' ')
                    {
                        minute = int.Parse(acc);
                        state  = ConfigState.Volume;
                        acc    = "";
                        continue;
                    }
                }
                else if (state == ConfigState.Volume)
                {
                    if ("0123456789.".Contains(c))
                    {
                        acc += c;
                        continue;
                    }
                    if (c == '#')
                    {
                        state = ConfigState.LineEndComment;
                        continue;
                    }
                }
                if (c == '\r')
                {
                    // carriage return will be ignored.
                    continue;
                }
                if (c == '\n' && (state == ConfigState.Volume || state == ConfigState.LineEndComment))
                {
                    vol = float.Parse(acc, CultureInfo.InvariantCulture);
                    TimeSpan d = new TimeSpan(hour, minute, 0);
                    lc.Mappings.Add(d, vol);
                    acc    = "";
                    hour   = -1;
                    minute = -1;
                    state  = ConfigState.Hour;
                    continue;
                }
                if (c == '\n' && state == ConfigState.Comment)
                {
                    state = ConfigState.Hour;
                    continue;
                }
                if (state == ConfigState.Comment)
                {
                    continue;
                }
                throw new Exception("Parser error. Pls fix your config file :(");
            }
            // no newline at end?
            if (hour != -1 && minute != -1)
            {
                vol = float.Parse(acc, CultureInfo.InvariantCulture);
                TimeSpan d = new TimeSpan(hour, minute, 0);
                lc.Mappings.Add(d, vol);
            }
            return(lc);
        }