示例#1
0
        public ServerClient(IServiceProvider serviceProvider)
        {
            _serviceProvider = serviceProvider;
            _logger          = serviceProvider.GetService <ILoggerFactory>().CreateLogger <ServerClient>();

            controllerSettings = serviceProvider.GetService <ControllerSettings>();
            discoveryClient    = serviceProvider.GetService <DiscoveryClient>();

            enrollmentTimer.Elapsed    += EnrollmentTimer_Elapsed;
            autoReconnectTimer.Elapsed += AutoReconnectTimer_Elapsed;

            if (String.IsNullOrEmpty(controllerSettings.Guid))
            {
                _logger.LogInformation("Client is not enrolled. Starting enrollment timer.");
                enrollmentTimer.Start();
            }
            else
            {
                _logger.LogInformation("Client is enrolled. Attempting immediate connection.");

                serverUrl = String.Format("https://{0}:{1}", controllerSettings.CCSHostname, controllerSettings.CCSPort);
                CreateConnectionBuilder();
                Task.Run(Connect);
            }
        }
示例#2
0
        public virtual void Init(Rigidbody rb, ControllerSettings controller)
        {
            SetModeVoid();

            rigidBody       = rb;
            this.controller = controller;
        }
示例#3
0
        public override ControllerResult Start(ControllerSettings settings)
        {
            var gameSettings     = (GameSettings)settings;
            var controllerResult = NextController.Game;

            InitializeGameState(gameSettings);
            RegisterHotkeys();

            while (window.IsOpen() && controllerResult == NextController.Game)
            {
                worldView.Scroll();

                window.Cycle();
                window.DispatchEvents();
                window.Clear();
                window.Draw(worldView);
                window.Draw(guiView);
                window.Display();
            }

            return(new ControllerResult
            {
                Next = NextController.Exit,
                Settings = null
            });
        }
    int dupeCount = FRAMES_TO_SEND_DUPLICATES; //so it doesnt send anything out before it's touched

    public void Initialize(ControllerSettings _controller)
    {
        sender       = GetComponent <OscPropertySender>();
        myController = _controller;

        sender.SetAddress(myController.GetAddress());

        label.text = myController.name;
        name       = myController.name + " " + myController.controlType;

        //load default values
        int defaultValue = myController.defaultValue;

        modValue       = defaultValue;
        pModValue      = defaultValue;
        targetModValue = defaultValue;

        slider.maxValue = myController.max;
        slider.minValue = myController.min;

        sortLeftButton.onClick.AddListener(SortLeft);
        sortRightButton.onClick.AddListener(SortRight);

        SetSortButtonVisibility(false);
    }
示例#5
0
        /// <summary>
        /// Load the settings page for the given controller settings object
        /// </summary>
        /// <param name="controllerSettings">The object containing controller-specific configurations</param>
        protected void LoadSettingsPage(ControllerSettings controllerSettings)
        {
            // Save the settings
            //TODO: This doesn't work!
            //if (ActiveControllerType != null)
            //    Settings.Default[ActiveControllerType.FullName] = (ActiveController != null) ? ActiveController.Settings : scratchSettings;

            // Hook a notification for connection properties, which cause a complete controller re-load when changed
            // (So the user can verify that we can still connect for the new values)
            if (controllerSettings != null)
            {
                controllerSettings.ConnectionPropertyChanged += ControllerSettings_ConnectionPropertyChanged;
            }

            // Remove existing property page
            contentGrid.Children.Clear();

            if (controllerSettings != null)
            {
                // Set new propery page
                var page = controllerSettings.GetSettingsPage();
                if (page != null)
                {
                    contentGrid.Children.Add(page);
                    lblNotLoaded.Visibility = Visibility.Hidden;

                    page.DataContext = controllerSettings;
                    return;
                }
            }

            lblNotLoaded.Visibility = Visibility.Visible;
        }
        public override ControllerResult Start(ControllerSettings settings)
        {
            var mainMenuResult       = new AtomicReference <NextController>(NextController.MainMenu);
            var gameSettingsProvider = new AtomicReference <Func <GameSettings> >();

            pages.InitializeComponents(window, mainMenuResult, gameSettingsProvider);
            mainScreen.InitializeMainScreen(window, MAIN_SCR_IMAGE);

            while (window.IsOpen() && mainMenuResult.Value == NextController.MainMenu)
            {
                window.DispatchEvents();
                window.Clear();
                window.Draw(mainScreen);
                window.Draw(pages.Active);
                window.Display();
            }

            window.EnsureClosed();

            return(new ControllerResult
            {
                Next = mainMenuResult.Value,
                Settings = gameSettingsProvider.Value?.Invoke()
            });
        }
示例#7
0
 protected override void OnClosed(EventArgs e)
 {
     ControllerSettings.Dispose();
     _currentAssigner?.Cancel();
     _currentAssigner = null;
     base.OnClosed(e);
 }
示例#8
0
        private void SaveAndExit(object sender, MouseButtonEventArgs e)
        {
            ControllerSettings.SaveModel(this.modelGroupItem, this, this.viewGroupItem);

            ControllerGroupItem.ChangeGroupItem(this.modelGroupItem);

            this.Close(MessageBoxResult.Yes);
        }
    GameObject SpawnControllerObject(ControllerSettings _config, GameObject _controlObject)
    {
        GameObject control = Instantiate(_controlObject);

        control.transform.SetParent(controllerParent, false);
        control.GetComponentInChildren <FaderControl>().Initialize(_config);
        return(control);
    }
    public void RespawnController(ControllerSettings _config)
    {
        DestroyController(_config);
        GameObject control = SpawnController(_config);

        control.transform.SetSiblingIndex(_config.GetPosition()); //there are bound to be issues here with ordering when faders are deleted and stuff
        ipSetter.TryConnect();                                    //quick and easy way - reconnect all sliders when done respawning a controller
    }
示例#11
0
        public void Initialize()
        {
            _controllerSettings = _settingsService.GetSettings <ControllerSettings>();

            lock (_syncRoot)
            {
                TryLoadResources();
            }
        }
    public void NewController()
    {
        ControllerSettings newControl    = new ControllerSettings(NEW_CONTROLLER_NAME, ControlType.Fader, AddressType.CC, ValueRange.SevenBit, DefaultValueType.Min, MIDIChannel.All, CurveType.Linear);
        GameObject         newController = SpawnController(newControl);

        if (newController != null)
        {
            newControl.SetPosition(newController.transform.GetSiblingIndex());
        }
    }
示例#13
0
 ControllerUIGroup GetButtonGroupByConfig(ControllerSettings _config)
 {
     foreach (ControllerUIGroup cbg in controllerUIs)
     {
         if (cbg.controllerConfig == _config)
         {
             return(cbg);
         }
     }
     return(null);
 }
示例#14
0
        private void OnPortChanged(object sender, EventArgs eventArgs)
        {
            byte port = (byte)(controllerIdComboBox.SelectedIndex + 1);
            ControllerSettings controllerSettimgs = inputSettings[port];

            if (controllerSettimgs != null)
            {
                TypeDescriptor.AddAttributes(controllerSettimgs, new Attribute[] { new ReadOnlyAttribute(true) });
            }
            mappingsPropertyGrid.SelectedObject = controllerSettimgs;
        }
示例#15
0
 private void Construct(InputManager inputManager, PlayerMovement movement, ControllerSettings controllerSettings,
                        GameplaySettings gameplaySettings, BulletManager bulletManager)
 {
     _inputManager       = inputManager;
     _movement           = movement;
     _controllerSettings = controllerSettings;
     _settings           = gameplaySettings.PlayerSettings;
     _gameplaySettings   = gameplaySettings;
     _bulletManager      = bulletManager;
     //_fogManager = fogManager;
 }
示例#16
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (result == MessageBoxResult.No)
     {
         result = System.Windows.MessageBox.Show("Сохранить изменения?", "Yes/No", MessageBoxButton.YesNo);
         if (result == MessageBoxResult.Yes)
         {
             ControllerSettings.SaveModel(this.modelGroupItem, this, this.viewGroupItem);
             ControllerGroupItem.ChangeGroupItem(this.modelGroupItem);
         }
     }
 }
示例#17
0
        protected void TurnOnUser(GameObject user)
        {
            EPSONcamera = user.transform.FindChild("HeadControl/NeckJoint/Camera BT-200/Stereoscopic Camera").gameObject;
            EPSONcamera.SetActive(true);

            LeftEyeCamera  = EPSONcamera.transform.FindChild("leftCam").GetComponent <Camera>();
            RightEyeCamera = EPSONcamera.transform.FindChild("rightCam").GetComponent <Camera>();;

            cSettings = user.transform.GetComponentInChildren <ControllerSettings>();
            cSettings.IsActiveUser = true;
            cSettings.SetCurrentController(cSettings.ControllerType);
        }
示例#18
0
        private async Task SaveSettings()
        {
            await ViewModel.SaveSettings();

            ControllerSettings?.SaveCurrentProfile();

            if (Owner is MainWindow window && ViewModel.DirectoryChanged)
            {
                window.ViewModel.LoadApplications();
            }

            ViewModel.DirectoryChanged = false;
        }
示例#19
0
        protected void TurnOffUser(GameObject user)
        {
            EPSONcamera = user.transform.FindChild("HeadControl/NeckJoint/Camera BT-200/Stereoscopic Camera").gameObject;
            EPSONcamera.SetActive(false);

            EPSONcamera    = null;
            LeftEyeCamera  = null;
            RightEyeCamera = null;

            cSettings = user.transform.GetComponentInChildren <ControllerSettings>();
            cSettings.IsActiveUser = false;
            cSettings.SetCurrentController(cSettings.ControllerType);
        }
    void SpawnDefaultControllers()
    {
        Debug.Log("Spawning Defaults");
        NukeControllers();
        controllers = new List <ControllerSettings>();

        for (int i = 0; i < defaultControllers.Length; i++)
        {
            ControllerSettings c = new ControllerSettings(defaultControllers[i]);
            c.SetPosition(i);
            controllers.Add(c);
        }

        SpawnControllers(true);
    }
    public GameObject SpawnController(ControllerSettings _config)
    {
        bool       error      = true;
        string     errorDebug = "doesn't exist!";
        GameObject control    = null;

        foreach (ControllerType t in controllerTypes)
        {
            if (t.controlType == _config.controlType)
            {
                //spawn this type
                if (t.controlObject != null)
                {
                    control = SpawnControllerObject(_config, t.controlObject);
                    controllerObjects.Add(_config, control);
                    error = false;
                    break;
                }
                else
                {
                    //let it continue looking for one that does have a game object if it exists, but throw an appropriate error
                    errorDebug = "exists, but doesn't have a game object!";
                }
            }
        }

        if (error)
        {
            Debug.LogError($"{typeof(ControllerType).ToString()} for {_config.controlType.ToString()} {errorDebug}!");
        }

        if (control == null)
        {
            Debug.LogError("Null control object! not in controller types?");
        }

        uiManager.SpawnFaderOptions(_config, control);

        if (!controllers.Contains(_config))
        {
            controllers.Add(_config);
        }

        return(control);
    }
    void LoadControllers(string _profile)
    {
        Debug.Log($"Loading");

        if (_profile != DEFAULT_SAVE_NAME)
        {
            string json = LoadFile(_profile);

            if (json != null)
            {
                FaderSaver loadedData = JsonUtility.FromJson <FaderSaver>(json);
                NukeControllers();

                if (loadedData != null || loadedData.GetControllers().Count > 0)
                {
                    List <ControllerSettings> temp = loadedData.GetControllers();

                    //properly initialize each controller settings
                    for (int i = 0; i < temp.Count; i++)
                    {
                        temp[i] = new ControllerSettings(temp[i]);
                    }

                    controllers = temp;
                    SpawnControllers();
                }
                else
                {
                    //spawn defaults if no save data
                    SpawnDefaultControllers();
                    Debug.LogError("Saved data was empty");
                }
            }
            else
            {
                Debug.LogError($"JSON object was null");
                SpawnDefaultControllers();
            }
        }
        else
        {
            Debug.Log($"Profile was default");
            SpawnDefaultControllers();
        }
    }
示例#23
0
        /// <summary>
        /// Handles communication to and from
        /// the Alarm Failsafe Management Controller (FMC).
        /// </summary>
        public FmcController(IServiceProvider serviceProvider)
        {
            controllerSettings = serviceProvider.GetService <ControllerSettings>();
            serverClient       = serviceProvider.GetService <ServerClient>();

            ILoggerFactory factory = serviceProvider.GetService <ILoggerFactory>();

            logger = factory.CreateLogger <FmcController>();

            serialController = new SerialController(serviceProvider);
            serialController.SerialInitialized += SerialController_SerialInitialized;
            serialController.SerialRecieved    += SerialController_SerialRecieved;

            serverClient.ServerCommandRecieved += ServerClient_ServerCommandRecieved;

            syncTimer.Start();
            syncTimer.Elapsed += SyncTimer_Elapsed;
        }
示例#24
0
    public void SpawnFaderOptions(ControllerSettings _config, GameObject _control)
    {
        //check if any other controller buttons exist for this, then destroy all its contents
        //make sure to destroy faderOptions as well
        ControllerUIGroup dupe = GetButtonGroupByConfig(_config);

        if (dupe != null)
        {
            DestroyControllerGroup(dupe);
        }

        ControllerUIGroup buttonGroup = new ControllerUIGroup(_config, faderOptionsPrefab, faderOptionsActivationPrefab, _control);

        buttonGroup.faderOptions.transform.SetParent(optionsPanel.transform, false);
        controllerUIs.Add(buttonGroup);
        SetFaderWidth(buttonGroup);
        SortOptionsButtons();
        RefreshFaderLayoutGroup();
    }
示例#25
0
        /// <summary>
        /// Attempt to load the given controller type,
        /// and show the appropriate settings page for it
        /// </summary>
        /// <param name="controllerType">The type of the class of the controller</param>
        protected void LoadController(Type controllerType)
        {
            // Try load the controller
            if (controllerType != null)
            {
                ActiveControllerType = controllerType;

                if (ActiveController != null)
                {
                    ActiveController = null;    // Close any existing connections
                }
                try
                {
                    ActiveController = Controllers.LoadController(Settings.Default, controllerType);
                    SetError(null);
                }
                catch (Exception ex)
                {
                    // Couldn't load the controller, show the error message and destroy the active controller
                    SetError(ex);
                    ActiveController = null;
                }
            }
            else
            {
                // Loading a null controller
                ActiveController     = null;
                ActiveControllerType = null;
                SetError(null);
            }

            if (ActiveController != null)
            {
                // Controller loaded, use its settings
                LoadSettingsPage(ActiveController.Settings);
            }
            else
            {
                // Create a temporary scratch settings page until we can properly instantiate the controller
                scratchSettings = Controllers.GetControllerSettings(HexLight.Properties.Settings.Default, controllerType);
                LoadSettingsPage(scratchSettings);
            }
        }
示例#26
0
        private void Positions_Load(object sender, EventArgs e)
        {
            toolStripStatusLabel.Text = "";

            _machine  = Machine.GetMachine();
            _settings = _machine.Settings;

            // Subscribe to events
            _machine.OnCommandResponse   += Machine_OnCommandResponse;
            _machine.OnCommandSending    += Machine_OnCommandSending;
            _machine.OnLocationChanged   += Machine_OnLocationChanged;
            _machine.OnEStopNotification += Machine_OnEStopNotification;

            txtSpeed.Text = _machine.Settings.FeedRateManual.ToString();

            UpdateCurrentPositionDisplay();
            UpdateDisplayLabels();

            PopulateOffsetSetting();
        }
示例#27
0
        public ControllerUIGroup(ControllerSettings _config, GameObject _faderOptionsPrefab, GameObject _optionsActivateButtonPrefab, GameObject _controlObject)
        {
            faderOptions = Instantiate(_faderOptionsPrefab).GetComponent <FaderOptions>();
            faderOptions.gameObject.name  = _config.name + " Options Panel";
            faderOptions.controllerConfig = _config;

            controllerConfig = _config;

            faderMenuButton = Instantiate(_optionsActivateButtonPrefab).GetComponent <Button>();
            faderMenuButton.gameObject.name = _config.name + " Options";
            faderMenuButton.GetComponentInChildren <Text>().text = _config.name + " Options"; // change visible button title
            faderMenuButton.onClick.AddListener(DisplayFaderOptions);

            activationToggle = faderMenuButton.GetComponentInChildren <Toggle>();
            activationToggle.onValueChanged.AddListener(ToggleControlVisibility);
            controlObject          = _controlObject;
            controlObjectTransform = _controlObject.GetComponent <RectTransform>();

            control = _controlObject.GetComponent <FaderControl>();
        }
示例#28
0
        private async Task RunController()
        {
            controllerSettings = await ControllerSettings.ReadAsync();

            // Build the service collection
            IServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging(builder => builder
                                         .AddDebug()
                                         .SetMinimumLevel(LogLevel.Debug));

            ILoggerFactory logger = serviceCollection.BuildServiceProvider().GetRequiredService <ILoggerFactory>();

            serviceCollection.AddSingleton(new DiscoveryClient(logger.CreateLogger(typeof(DiscoveryClient)), Guid.Parse(controllerSettings.Guid)));
            serviceCollection.AddSingleton(typeof(ControllerSettings), controllerSettings);
            serviceCollection.AddSingleton(new ServerClient(serviceCollection.BuildServiceProvider()));
            IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();

            FmcController alarmController = new FmcController(serviceProvider);

            alarmController.FmcReadyEvent += AlarmController_FmcReadyEvent;
            await alarmController.Initialize();
        }
示例#29
0
 private void Construct(ControllerSettings controllerSettings)
 {
     _deadZone = controllerSettings.DeadZone;
 }
 public ControllerSettings(ControllerSettings _c)
 {
     SetVariables(_c.name, _c.controlType, _c.addressType, _c.range, _c.defaultType, _c.channel, _c.curveType, _c.ccNumber, _c.smoothTime);
     id       = ControlsManager.GetUniqueID();
     position = _c.position;
 }