예제 #1
0
        public Control(ISensor sensor, ISettings settings, float minSoftwareValue,
            float maxSoftwareValue)
        {
            this.identifier = new Identifier(sensor.Identifier, "control");
              this.settings = settings;
              this.minSoftwareValue = minSoftwareValue;
              this.maxSoftwareValue = maxSoftwareValue;

              if (!float.TryParse(settings.GetValue(
              new Identifier(identifier, "value").ToString(), "0"),
            NumberStyles.Float, CultureInfo.InvariantCulture,
            out this.softwareValue))
              {
            this.softwareValue = 0;
              }
              int mode;
              if (!int.TryParse(settings.GetValue(
              new Identifier(identifier, "mode").ToString(),
              ((int)ControlMode.Default).ToString(CultureInfo.InvariantCulture)),
            NumberStyles.Integer, CultureInfo.InvariantCulture,
            out mode))
              {
            this.mode = ControlMode.Default;
              } else {
            this.mode = (ControlMode)mode;
              }
        }
예제 #2
0
 protected override void OnControlModeChanged(ControlMode newMode)
 {
     base.OnControlModeChanged(newMode);
     removeColumn.Visibility = (newMode == ControlMode.ReadOnly)
                                       ? Visibility.Collapsed
                                       : Visibility.Visible;
 }
예제 #3
0
파일: Player.cs 프로젝트: sean-h/spacegame
    private void ChangeControlMode(ControlMode controlMode)
    {
        _controlModeRTS.enabled = false;
        shipController.enabled = false;

        controlMode.enabled = true;
        _currentControlMode = controlMode;
    }
예제 #4
0
        public Control(ISensor sensor, float minSoftwareValue,
      float maxSoftwareValue, int defaultPolicy, int defaultLevel)
        {
            this.identifier = new Identifier(sensor.Identifier, "control");
              this.minSoftwareValue = minSoftwareValue;
              this.maxSoftwareValue = maxSoftwareValue;
              this.defaultPolicy = defaultPolicy;
              this.defaultLevel = defaultLevel;

              this.softwareValue = 0;
              int mode = 0;
              this.mode = (ControlMode)mode;
        }
예제 #5
0
        protected override void OnControlModeChanged(ControlMode newMode)
        {
            var a = new Binding("UserName");

            switch (newMode)
            {
                case ControlMode.New:
                    a.Mode = BindingMode.TwoWay;
                    break;
                default:
                    emailTextBox.DataContext = DataContext;
                    a.Mode = BindingMode.OneWay;
                    break;
            }
        }
        public void SetControlMode(ControlMode newControlMode)
        {
            switch (newControlMode)
            {
                case ControlMode.Rocket:
                    if (InvertPitch)
                    {
                        GameSettings.PITCH_UP                       = _pitchUp;
                        GameSettings.PITCH_DOWN                     = _pitchDown;
                        GameSettings.AXIS_PITCH.primary.inverted    = _pitchAxisPrimaryInverted;
                        GameSettings.AXIS_PITCH.secondary.inverted  = _pitchAxisSecondaryInverted;
                    }

                    GameSettings.ROLL_LEFT  = _rollLeft;
                    GameSettings.ROLL_RIGHT = _rollRight;
                    GameSettings.AXIS_ROLL  = _rollAxis;

                    GameSettings.YAW_LEFT   = _yawLeft;
                    GameSettings.YAW_RIGHT  = _yawRight;
                    GameSettings.AXIS_YAW   = _yawAxis;

                    break;
                case ControlMode.Plane:
                    if (InvertPitch)
                    {
                        GameSettings.PITCH_UP                       = _pitchDown;
                        GameSettings.PITCH_DOWN                     = _pitchUp;
                        GameSettings.AXIS_PITCH.primary.inverted    = !_pitchAxisPrimaryInverted;
                        GameSettings.AXIS_PITCH.secondary.inverted  = !_pitchAxisSecondaryInverted;
                    }

                    GameSettings.ROLL_LEFT  = _yawLeft;
                    GameSettings.ROLL_RIGHT = _yawRight;
                    GameSettings.AXIS_ROLL  = _yawAxis;

                    GameSettings.YAW_LEFT   = _rollLeft;
                    GameSettings.YAW_RIGHT  = _rollRight;
                    GameSettings.AXIS_YAW   = _rollAxis;

                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(newControlMode));
            }
        }
예제 #7
0
        public World(Rectangle rect, int offset, ControlMode controlMode, bool muteShape = true)
        {
            this.rect = rect;
            this.borderOffset = offset;
            this.controlMode = controlMode;
            this.mute = muteShape;

            this.currentShape = new Shape(this, controlMode);

            //Combo emitters
            List<ParticleModifier> p = new List<ParticleModifier>();
            p.Add(new GravityModifier(new Vector2(0, -0.5f)));
            p.Add(new RandomSpeedModifier(new Vector2(0.1f, 0.1f)));
            this.comboEmitter = new Emitter(rect.Width / 100f, 0f, Color.Orange * 0.6f, Color.Red, 20, 1, new RandomSpawnSpeed(Vector2.Zero, Vector2.Zero), Assets.Textures.Particle, new RectangleSpawnShape(rect.Width, rect.Height), p);
            this.comboEmitter.Position = new Vector2(rect.Center.X, rect.Center.Y);

            List<ParticleModifier> cp = new List<ParticleModifier>();
            cp.Add(new GravityModifier(new Vector2(0, -0.5f)));
            cp.Add(new RandomSpeedModifier(new Vector2(1f, 1f)));
            this.epicComboEmitter = new Emitter(rect.Width / 90f, 0f, Color.Orange * 0.5f, Color.Blue, 20, 1.5f, new RandomSpawnSpeed(Vector2.Zero), Assets.Textures.Particle, new RectangleSpawnShape(rect.Width, rect.Height), cp);
            this.epicComboEmitter.Position = new Vector2(rect.Center.X, rect.Center.Y);

            //Get rect of one block for size
            Rectangle blockRect = CalculateBlockRectangle(0,0);
            List<ParticleModifier> ep = new List<ParticleModifier>();
            ep.Add(new GravityModifier(new Vector2(0, 0.3f)));
            explosionEmitter = new Emitter(
                (float)blockRect.Width / (float)Assets.Textures.Block.Width,
                (float)blockRect.Width / (float)Assets.Textures.Block.Width,
                Color.Red,
                Color.Red,
                1,
                2f,
                new RandomSpawnSpeed(new Vector2(12, -rect.Width / 30), new Vector2(-12, -rect.Width / 50)),
                Assets.Textures.Block,
                new RectangleSpawnShape(0, 0),
                ep
            );
            stats = new Stats(Assets.Fonts.BasicFont, Color.White, rect);

            //Tetris emitter
            tetrisEmitter = new Emitter(rect.Width / 100f, 0f, Color.Red * 0.4f, Color.Blue, 100, 0.5f, new RandomSpawnSpeed(new Vector2(-30,-9), new Vector2(30,-4)), Assets.Textures.Particle, new RectangleSpawnShape(rect.Width, 0), new List<ParticleModifier>());
            tetrisEmitter.Position = new Vector2(rect.Center.X, rect.Bottom);
        }
예제 #8
0
 private Config(
     KeyBinding toggleControlMode,
     KeyBinding holdControlMode,
     bool pitchInvert,
     bool enableAppLauncherButton,
     ControlMode defaultControlMode,
     ControlMode defaultVabControlMode,
     ControlMode defaultSphControlMode,
     LogLevel logLevel
     )
 {
     ToggleControlMode = toggleControlMode;
     HoldControlMode = holdControlMode;
     PitchInvert = pitchInvert;
     EnableAppLauncherButton = enableAppLauncherButton;
     DefaultControlMode = defaultControlMode;
     DefaultVabControlMode = defaultVabControlMode;
     DefaultSphControlMode = defaultSphControlMode;
     LogLevel = logLevel;
 }
예제 #9
0
        public LoginControl(ControlMode controlMode,
            Form owner, 
            ILoginUserSettings settingsStorage,
            EventHandler onClose,
            EventHandler onRegLinkClicked,
            AuthenticateDel onAuthenticate)
            : this()
        {
            this.owner = owner;
            this.settingsStorage = settingsStorage;
            this.onClose = onClose;
            this.onAuthenticate = onAuthenticate;
            this.controlMode = controlMode;
            this.onRegLinkClicked = onRegLinkClicked;

            if (controlMode == ControlMode.ModeControl)
            {
                btnLogin.Text = Localizer.GetString("TitleSave");
            }
        }
 void Update()
 {
     if (mode == ControlMode.individual &&
         Input.GetKeyDown(KeyAtlas.toggle1) &&
         toggleKeyUp) {
         mode = ControlMode.rts;
         Debug.Log("RTS MODE");
         toggleKeyUp = false;
     }
     if (mode == ControlMode.rts &&
         Input.GetKeyDown(KeyAtlas.toggle1) &&
         toggleKeyUp) {
         mode = ControlMode.individual;
         Debug.Log("INDIVIDUAL MODE"); ;
         toggleKeyUp = false;
     }
     if (Input.GetKeyUp(KeyAtlas.toggle1)) {
         toggleKeyUp = true;
     }
 }
 /// <summary>
 /// Returns true iff this structure can be built at the specified location.
 /// </summary>
 public abstract bool canBeBuilt(Location baseLoc, ControlMode cm);
 protected override void OnControlModeChanged(ControlMode newMode)
 {
     base.OnControlModeChanged(newMode);
     activeProductcollumn.Visibility = editItemCollum.Visibility = newMode == ControlMode.ReadOnly ? Visibility.Hidden : Visibility.Visible;
 }
예제 #13
0
파일: Ship.cs 프로젝트: rghassem/Code
    void switchMode(ControlMode newMode)
    {
        if(newMode == ControlMode.Tactical)
        {
            Game.lockSelection = false;
            Game.SelectObject(gameObject, false);
            if(Game.mainCamera.currentViewAngle == Game.mainCamera.VIEW_ANGLE_LOW)
                Game.mainCamera.SwitchViewAngle();
            Game.gui.shipDisplay.Hide();
        }
        else if( newMode == ControlMode.Flight)
        {
            Game.SelectObject(gameObject, true);
            Game.lockSelection = true;
            if(Game.mainCamera.currentViewAngle == Game.mainCamera.VIEW_ANGLE_HIGH)
                Game.mainCamera.SwitchViewAngle();
            Game.gui.shipDisplay.Show(this);
        }

        mode = newMode;
    }
        protected override void InitConfig() {
            //General
            ExperimentName = GetStr("ExperimentName", "Experiment", "The name of the experiment. Controls the folder where the results will be written to.");
            //mRunInfo = GetGeneralParam("RunInfo", Mode.ToString(), "The name of the specific run happening.");
            RunInfo = GetStr("RunInfo", Mode.ToString(), "The name of the specific run happening.");
            OneSecMininum = Get("LimitFrequency", true, "Whether to limit the maximum log frequency to one log per second. Viewer timestamps only go to the second so finer grained logging is not possible.");
            TimestampFormat = GetStr("TimestampFormat", TimestampFormat, "The format that all timestamps will be saved as. Should match second life's log's timestamps.");
            IncludeTimestamp = Get("IncludeTimestamp", true, "Whether to include a timestamp in file names when saving results.");
            ProcessOnFinish = Get("ProcessResults", false, "Whether to process the log files to  <ExperimentName>/RunInfo(-<Timestamp>).csv file when closing.");
            string outputKeysStr = GetSection("Recorder", "OutputKeys", "CFPS,SFPS,FT", "The columns the output table should have. Each column is separted by a comma. Valid keys are: CFPS, SFPS, FT, PingTime.");
            OutputKeys = outputKeysStr.Split(',');
            RepeatCode = Get("RepeatCode", 12, "The exit code to use if the application should be launched again.");

            //Movement Tracker
            ExperimentFile = GetFileSection("MovementTracker", "File", null, "The xml file which defines the experiment.");
            FPSFolder = GetFolderSection("MovementTracker", "FPSFolder", "FPS", "The folder where FPS results will be written to.");

            //Avatar movement
            NodesFile = GetFileSection("AvatarMovement", "NodesFile", "Experiments/Cathedral.xml", "The xml file where the nodes which are potential targets for navigating to are stored.");
            TargetsFile = GetFileSection("AvatarMovement", "TargetsFile", "Experiments/CathedralRoute.xml", "The xml file where the nodes which make up a route are stored.");
            MapFile = GetFileSection("AvatarMovement", "MapFile", null, "The file where the map image one which the route is to be drawn on is stored.");

            UserSettingsFolder = GetFolderSection("AvatarMovement", "UserSettingsFolder", "C:/Users/johnmcc/AppData/Roaming/Firestorm/user_settings/", "The folder where the settings file will be loaded from.");
            SettingsFile = GetFileSection("AvatarMovement", "SettingsFile", null, "The file where the configuration of the client is to be loaded from.");
            Region = GetSection("AvatarMovement", "Region", "Cathedral 1", "The region to connect to.");

            Mode = GetEnum<ControlMode>("AvatarMovement", "Mode", ControlMode.Delta, "What mode the system should be in for the run.", LogManager.GetLogger("Experiments"));
            StartWaitMS = Get("AvatarMovement", "StartWaitMS", 0, "How many MS to wait before starting the loop.");
            AutoStart = Get("AvatarMovement", "AutoStart", false, "Whether to start the loop as soon as the plugin is enabled.");
            AutoShutdown = Get("AvatarMovement", "AutoShutdown", false, "Whether to stop Chimera when the route is completed. Will only work if Loop is disabled.");
            Loop = Get("AvatarMovement", "Loop", false, "Whether to start the loop again when it finishes.");
            StartAtHome = Get("AvatarMovement", "StartAtHome", false, "Whether to teleport the avatar home before starting. Overrides TeleportToStart if set.");
            SaveResults = Get("AvatarMovement", "SaveFPS", true, "Whether to save the log 'Experiments/<ExperimentName>/<Timestamp>-RunInfo(-Frame).log'.");
            TeleportToStart = Get("AvatarMovement", "TeleportToStart", false, "<CURRENTLY DOES NOT WORK> Whether to use the map dialog to teleport the avatar to the start location specified in RecorderBot / StartIsland/StartLocation. Won't work if StartAtHome is enabled.");
            MoveMouseOffscreen = Get("AvatarMovement", "MoveMouseOffscreen", true, "Whether the mouse should be moved off screen before the run starts.");
            StartupKeyPresses = GetSection("AvatarMovement", "StartupKeyPress", "", "Key presses which will be sent to the viewer before the run starts, separated by commas.").Split(',');

            TurnRate = Get("AvatarMovement", "TurnRate", .01, "How far the camera will turn each tick.");
            MoveRate = Get("AvatarMovement", "MoveRate", .03f, "How far the camera will move each tick.");
            HeightOffset = Get("AvatarMovement", "HeightOffset", 1f, "How much above the floor nodes the target is.");
            DistanceThreshold = Get("AvatarMovement", "DistanceThreshold", .5f, "How far away from a target the position has to be before the target is considered hit.");

            //Recorder Bot
            FirstName = GetSection("RecorderBot", "FirstName", "Recorder", "The first name of the bot that will be logged in to track server stats.");
            LastName = GetSection("RecorderBot", "LastName", "Bot", "The last name of the bot that will be logged in to track server stats.");
            Password = GetSection("RecorderBot", "Password", "password", "The password for the bot that will be logged in to track server stats.");

            AutoLogin = Get("RecorderBot", "AutoLogin", false, "Whether the bot should automatically log in as soon as the plugin is enabled.");
            StartLocation = GetV("RecorderBot", "StartLocation", new Vector3(128f, 128f, 24f), "Where on the island the bot should be logged in to.");
            StartIsland = GetSection("RecorderBot", "StartIsland", "Cathedral 1", "Which island the bot should log in to.");
            UpdateStatsGUI = Get("RecorderBot", "UpdateStatsGUI", false, "Whether to regularly update the Recorder's GUI with Recorder bot stats.");

            //Settings Changer
            Setting = GetSection("SettingsChanger", "Setting", null, "Which of the viewer's debug settings to change each launch.");
            mIncrement = GetParam("SettingsChanger", "Increment", .01f, "The amount to increment 'Value' for before the next run.");
            IncrementMultiplier = Get("SettingsChanger", "IncrementMultiplier", 1f, "How much to multiply the increment by after every run. Allows log scales. Leave at 1 for normal incrementing.");
            Max = Get("SettingsChanger", "Max", .2f, "The amount for value to reach before the test stops.");
            mValue = GetParam("SettingsChanger", "Value", .01f, "The current value to set 'Setting' to on this run. Will be incremented by 'Increment' after being set.");
            SettingsChangerEnabled = Get("SettingsChanger", "Enabled", true, "Whether the settings changer pluging should be enabled. If false 'Setting' will not be changed.");
예제 #15
0
 public AD9854_v2(ControlMode mode)
 {
     byte[] default_vals = {   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                               0x00, 0x40, 0x00, 0x00, 0x00, 0x10, 0x64, 0x01,
                               0x20, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00 };
     write_reg = new Register8WriteDel(WriteRegister);
     registers = new Register8[40];
     for(int i=0; i<40; i++)
         registers[i] = new Register8(i.ToString(), write_reg, (byte)i, default_vals[i]);
     current_control_mode = mode;
 }
예제 #16
0
        //void LateUpdate()
        //{
        //    if (env.input.GetButtonDown(InputButtonNames.Button1)) {
        //        if (EventSystem.current.IsPointerOverGameObject())
        //        {
        //            if (isPropertyVisible)
        //                isPropertyVisible = false;
        //        }
        //        else
        //        {
        //            if (isPropertyVisible)
        //                isPropertyVisible = false;
        //            else
        //            {
        //                colorPanel.SetActive(false);
        //            }
        //        }
        //    }
        //}

        public void SetControlMode(ControlMode m)
        {
            controlMode = m;
        }
예제 #17
0
    private void FixedUpdate()
    {
        // Default actions.
        if (playerInput.GetButton("Jump"))
        {
            movement.JumpHold();
        }
        else
        {
            movement.TryJumpRelease();
        }

        if (playerInput.GetButton("Accelerate"))
        {
            movement.DebugMove();
        }

        if (playerInput.GetButtonDown("Flip Over"))
        {
            movement.FlipOver();
        }

        // Switch control scheme
        if (playerInput.GetButton("Set Controls 1"))
        {
            controlMode = ControlMode.SkidAndCarve;
        }
        else if (playerInput.GetButton("Set Controls 2"))
        {
            controlMode = ControlMode.FrontBack;
        }
        else if (playerInput.GetButton("Set Controls 3"))
        {
            controlMode = ControlMode.TurnAndLean;
        }
        else if (playerInput.GetButton("Set Controls 4"))
        {
            controlMode = ControlMode.FrontBackLocal;
        }

        Vector3 leftStickInputSpace = new Vector3(playerInput.GetAxis("Left Stick Horizontal"), 0.0f, playerInput.GetAxis("Left Stick Vertical"));
        Vector3 rightStickInputSpace = new Vector3(playerInput.GetAxis("Right Stick Horizontal"), 0.0f, playerInput.GetAxis("Right Stick Vertical"));

        switch (controlMode)
        {
            case ControlMode.SkidAndCarve:
                UpdateSkidAndCarve(leftStickInputSpace, rightStickInputSpace);
                break;
            case ControlMode.SlalomAndCarve:
                UpdateSlalomAndCarve(leftStickInputSpace, rightStickInputSpace);
                break;
            case ControlMode.TurnAndLean:
                UpdateTurnAndLean(leftStickInputSpace, rightStickInputSpace);
                break;
            case ControlMode.Warthog:
                UpdateWarthog(leftStickInputSpace, rightStickInputSpace);
                break;
            case ControlMode.FrontBack:
                UpdateFrontBackSteering(leftStickInputSpace, rightStickInputSpace);
                break;
            case ControlMode.FrontBackLocal:
                UpdateFrontBackSteering(leftStickInputSpace, rightStickInputSpace, false);
                break;
        }
    }
예제 #18
0
    void Update()
    {
        if (pausing)
        {
            return;
        }
        var x_in = 0f;
        var y_in = 0f;

        switch (controlMode)
        {
        case ControlMode.mouse:
        {
            var graceWidth = 50;
            var mouse      = Input.mousePosition;
            var midX       = Screen.width / 2;
            var midY       = Screen.height / 2;

            if (midX + graceWidth <= mouse.x)
            {
                x_in = 1;
            }
            else if (mouse.x <= midX - graceWidth)
            {
                x_in = -1;
            }

            if (midY + graceWidth <= mouse.y)
            {
                y_in = 1;
            }
            else if (mouse.y <= midY - graceWidth)
            {
                y_in = -1;
            }
        }
        break;

        case ControlMode.normalized:
        {
            x_in = Input.GetAxis("Horizontal");
            y_in = Input.GetAxis("Vertical");
        }
        break;

        case ControlMode.gyro:
        {
            var graceWidth = 0.01;
            var gyro       = Input.acceleration;

            if (graceWidth < gyro.x)
            {
                x_in = 1;
            }
            else if (gyro.x < -graceWidth)
            {
                x_in = -1;
            }

            if (graceWidth < gyro.y)
            {
                y_in = 1;
            }
            else if (gyro.y < -graceWidth)
            {
                y_in = -1;
            }
        }
        break;

        default:
        {
            controlMode = ControlMode.mouse;
        }
        break;
        }

        if (x_in != 0 || y_in != 0)
        {
            var vel = new Vector2(x_in, y_in);
            vel *= 2.3f;
            body.AddForce(vel);
            body.velocity = Vector2.ClampMagnitude(body.velocity, maxLength);
        }
    }
예제 #19
0
 public void SetControlMode(ControlMode mode)
 {
     controlMode = mode;
 }
예제 #20
0
 /// <summary>
 /// 执行此VBO的渲染操作。
 /// <para>Render using this VBO.</para>
 /// </summary>
 /// <param name="controlMode">index buffer is accessable randomly or only by frame.</param>
 public abstract void Draw(ControlMode controlMode);
예제 #21
0
 public DTO_Device(string id, string name, string mAC, string iP, string subnet, string gateWay, string hostIp, FAMode fAMode, ControlMode ctrMode, List <DTO_DeviceSocket> sockets, string description)
 {
     Id          = id;
     Name        = name;
     MAC         = mAC;
     IP          = iP;
     Subnet      = subnet;
     GateWay     = gateWay;
     HostIp      = hostIp;
     FAMode      = fAMode;
     CtrMode     = ctrMode;
     Sockets     = sockets;
     Description = description;
 }
예제 #22
0
        public JsonResult SaveProperties(int nodeId, string type)
        {
            var node = _Storage.GetNode(nodeId);
            var xml  = new XmlSerializer(typeof(Sequencing));

            var xelement = nodeId == 0 ? _CurrentCourse.Sequencing : node.Sequencing;

            var sequencing = xelement == null ? new Sequencing() : (Sequencing)xml.DeserializeXElement(xelement);

            object model;

            if (type == "ControlMode")
            {
                model = new ControlMode();
                TryUpdateModel(model as ControlMode);
                sequencing.ControlMode = model as ControlMode;
            }
            else if (type == "LimitConditions")
            {
                model = new LimitConditions();
                TryUpdateModel(model as LimitConditions);
                sequencing.LimitConditions = model as LimitConditions;
            }
            else if (type == "ConstrainedChoiceConsiderations")
            {
                model = new ConstrainedChoiceConsiderations();
                TryUpdateModel(model as ConstrainedChoiceConsiderations);
                sequencing.ConstrainedChoiceConsiderations = model as ConstrainedChoiceConsiderations;
            }
            else if (type == "RandomizationControls")
            {
                model = new RandomizationControls();
                TryUpdateModel(model as RandomizationControls);
                sequencing.RandomizationControls = model as RandomizationControls;
            }
            else if (type == "DeliveryControls")
            {
                model = new DeliveryControls();
                TryUpdateModel(model as DeliveryControls);
                sequencing.DeliveryControls = model as DeliveryControls;
            }
            else if (type == "RollupRules")
            {
                model = new RollupRules();
                TryUpdateModel(model as RollupRules);
                sequencing.RollupRules = model as RollupRules;
            }
            else if (type == "RollupConsiderations")
            {
                model = new RollupConsiderations();
                TryUpdateModel(model as RollupConsiderations);
                sequencing.RollupConsiderations = model as RollupConsiderations;
            }
            else
            {
                throw new NotImplementedException();
            }

            if (nodeId == 0)
            {
                _CurrentCourse.Sequencing = xml.SerializeToXElemet(sequencing);
                _Storage.UpdateCourse(_CurrentCourse.Id, _CurrentCourse);
            }
            else
            {
                node.Sequencing = xml.SerializeToXElemet(sequencing);
                _Storage.UpdateNode(nodeId, node);
            }


            return(Json(new { status = true }));
        }
예제 #23
0
        public Control(ISensor sensor, ISettings settings, float minSoftwareValue,
                       float maxSoftwareValue, ISensor affect = null)
        {
            this.identifier       = new Identifier(sensor.Identifier, "control");
            this.settings         = settings;
            this.minSoftwareValue = minSoftwareValue;
            this.maxSoftwareValue = maxSoftwareValue;
            this.affects          = affect;



            int mode;

            if (!int.TryParse(settings.GetValue(
                                  new Identifier(identifier, "mode").ToString(),
                                  ((int)ControlMode.Undefined).ToString(CultureInfo.InvariantCulture)),
                              NumberStyles.Integer, CultureInfo.InvariantCulture,
                              out mode))
            {
                this.mode = ControlMode.Undefined;
            }
            else
            {
                this.mode = (ControlMode)mode;
            }

            if (settings.Contains(new Identifier(identifier, "calibration_curve", "values").ToString()))
            {
                calibrated = new FanControlCurve(new Identifier(identifier, "calibration_curve"), settings, false);
                maxRPM     = calibrated[calibrated.Count - 1].X;
                Debug.WriteLine("max " + maxRPM);
            }


            byte temp = 0;

            if (!byte.TryParse(settings.GetValue(
                                   new Identifier(identifier, "uprate").ToString(), "2"),
                               NumberStyles.Integer, CultureInfo.InvariantCulture,
                               out temp))
            {
                this.FanUpRate = 2;
            }
            else
            {
                this.FanUpRate = temp;
            }
            if (!byte.TryParse(settings.GetValue(
                                   new Identifier(identifier, "downrate").ToString(), "2"),
                               NumberStyles.Integer, CultureInfo.InvariantCulture,
                               out temp))
            {
                this.FanDownRate = 2;
            }
            else
            {
                this.FanDownRate = temp;
            }

            if (!bool.TryParse(settings.GetValue(
                                   new Identifier(identifier, "use_calibrated").ToString(), "false"),
                               out useCalibrated))
            {
                this.useCalibrated = false;
            }

            if (!float.TryParse(settings.GetValue(
                                    new Identifier(identifier, "value").ToString(), "0"),
                                NumberStyles.Float, CultureInfo.InvariantCulture,
                                out this.internalSoftwareValue))
            {
                this.internalSoftwareValue = 0;
            }
            if (internalSoftwareValue < 0)
            {
                internalSoftwareValue = 0;
            }
            if (internalSoftwareValue > 100)
            {
                internalSoftwareValue = 100;
            }
            this.SoftwareValue = internalSoftwareValue;
        }
예제 #24
0
        float GetValue(ControlMode controlMode, ValueToGet ValueToGet)
        {
            switch (controlMode)
            {
            case ControlMode.ConfidenceThreshold:
                switch (ValueToGet)
                {
                case ValueToGet.Max:
                    return(9);

                case ValueToGet.Min:
                    return(0);

                case ValueToGet.Value:
                    return(sliders[(int)controlMode].value);

                case ValueToGet.Add:
                    return(1f);

                case ValueToGet.DefaultValue:
                    return(3);

                default:
                    return(-1);
                }

            case ControlMode.DenoiseGuidedFilter:
                switch (ValueToGet)
                {
                case ValueToGet.Max:
                    return(7);

                case ValueToGet.Min:
                    return(0);

                case ValueToGet.Value:
                    return(sliders[(int)controlMode].value);

                case ValueToGet.Add:
                    return(1);

                case ValueToGet.DefaultValue:
                    return(3);

                default:
                    return(-1);
                }

            case ControlMode.DenoiseMedianFilter:
                switch (ValueToGet)
                {
                case ValueToGet.Max:
                    return(2);

                case ValueToGet.Min:
                    return(0);

                case ValueToGet.Value:
                    return(sliders[(int)controlMode].value);

                case ValueToGet.Add:
                    return(1);

                case ValueToGet.DefaultValue:
                    return(2);

                default:
                    return(-1);
                }

            default:
                return(-1);
            }
        }
예제 #25
0
 public void SelectMode(bool toggleOn)
 {
     controlMode = toggleOn ? ControlMode.Selection : ControlMode.ViewMovement;
 }
예제 #26
0
 private ControlCommand(ControlMode controlMode)
 {
     _controlMode = controlMode;
 }
예제 #27
0
    void Update()
    {
        bool trigger_pinch = false;

        HandModel hand_model = GetComponent<HandModel>();
        if (hand_model == null)
            return;

        Hand leap_hand = hand_model.GetLeapHand();
        if (leap_hand == null)
            return;
        if (null==prevFrame_)
        {
            prevFrame_ = leap_hand.Frame;
            return;
        }

        //MyTest
        {
            if(leap_hand.IsRight)
            {
                var tgtObj = GameObject.Find("GameObject_meshTest");

                if (controlMode_ == ControlMode.Move)
                {
                    float pitch = -leap_hand.Direction.Pitch;
                    float yaw = leap_hand.Direction.Yaw;
                    float roll = leap_hand.PalmNormal.Roll;
                    var rQ = new Quaternion();
                    rQ.eulerAngles = new Vector3(pitch * Mathf.Rad2Deg, yaw * Mathf.Rad2Deg, roll * Mathf.Rad2Deg);

                    leap_hand.PalmVelocity.ToUnityScaled();

                    tgtObj.transform.position += leap_hand.PalmVelocity.ToUnityScaled();
                    //tgtObj.transform.localRotation = rQ;
                }
            }
            else
            {
                if (leap_hand.PinchStrength > 0.5f)
                {
                    if (controlMode_ == ControlMode.None)
                    {
                        controlMode_ = ControlMode.Move;
                    }
                    else
                    {
                        var rotAngle = leap_hand.RotationAxis(prevFrame_);
                        Debug.Log(string.Format("{0}", rotAngle.ToString()));
                    }
                }
                else
                {
                    controlMode_ = ControlMode.None;
                }
            }
        }

        // Scale trigger distance by thumb proximal bone length.
        Vector leap_thumb_tip = leap_hand.Fingers[0].TipPosition;
        float proximal_length = leap_hand.Fingers[0].Bone(Bone.BoneType.TYPE_PROXIMAL).Length;
        float trigger_distance = proximal_length * TRIGGER_DISTANCE_RATIO;

        // Check thumb tip distance to joints on all other fingers.
        // If it's close enough, start pinching.
        for (int i = 1; i < HandModel.NUM_FINGERS && !trigger_pinch; ++i)
        {
            Finger finger = leap_hand.Fingers[i];

            for (int j = 0; j < FingerModel.NUM_BONES && !trigger_pinch; ++j)
            {
                Vector leap_joint_position = finger.Bone((Bone.BoneType)j).NextJoint;
                if (leap_joint_position.DistanceTo(leap_thumb_tip) < trigger_distance)
                    trigger_pinch = true;
            }
        }

        Vector3 pinch_position = hand_model.fingers[0].GetTipPosition();

        // Only change state if it's different.
        if (trigger_pinch && !pinching_)
            OnPinch(pinch_position);
        else if (!trigger_pinch && pinching_)
            OnRelease();

        // Accelerate what we are grabbing toward the pinch.
        if (grabbed_ != null)
        {
            Vector3 distance = pinch_position - grabbed_.transform.position;
            grabbed_.rigidbody.AddForce(forceSpringConstant * distance);
        }
    }
예제 #28
0
 public void StopPlacing()
 {
     CurrentMode = ControlMode.None;
     itemBeingPlaced.DestroyGameObject();
     itemBeingPlaced = null;
 }
예제 #29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="baseLoc"></param>
 /// <param name="cm"></param>
 /// <returns></returns>
 public override bool CanBeBuilt(Location baseLoc, ControlMode cm)
 {
     return(RailStationaryStructure.canBeBuilt(baseLoc, Size, cm));
 }
예제 #30
0
 public void SetControlMode(ControlMode mode)
 {
     _dilutentController.SetControlMode(mode);
     _analyteController.SetControlMode(mode);
 }
예제 #31
0
    public void Update()
    {
        HandleKeysForThrust();
        if (Input.GetKey(KeyCode.Space))
        {
            spacecraft.FirePrimary();
        }
        if (Input.GetKeyDown(KeyCode.Z))
        {
            controlMode = controlMode==ControlMode.MouseFollow?ControlMode.Keyboard:ControlMode.MouseFollow;
        }

        spacecraft.turretTarget = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        if (godMode)
        {
            foreach (var s in spacecraft.shields)
            {
                s.ShieldPercentage = 1;
            }
            spacecraft.SetHealth(spacecraft.MAX_HEALTH);
        }
    }
예제 #32
0
 public void Initialize(ILayoutGenerator layoutGenerator, IZoneGenerator zoneGenerator, int seed, int numberOfLevels, ControlMode mode)
 {
     currentSeed          = seed;
     this.numberOfLevels  = numberOfLevels;
     mapGenerationManager = Locator.Get <MapGenerationManager>();
     mapGenerationManager.SetLayoutGenerator(layoutGenerator);
     mapGenerationManager.SetZoneGenerator(zoneGenerator);
     Initialize(mode);
 }
예제 #33
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="controlMode">index buffer is accessable randomly or only by frame.</param>
        public void Draw(ControlMode controlMode)
        {
            int instanceCount = this.InstanceCount;

            if (instanceCount < 1)
            {
                throw new Exception("error: instanceCount is less than 1.");
            }
            int frameCount = this.FrameCount;

            if (frameCount < 1)
            {
                throw new Exception("error: frameCount is less than 1.");
            }

            uint                   mode        = (uint)this.Mode;
            IndexBuffer            indexBuffer = this.indexBuffer;
            int                    vertexCount = indexBuffer.Length;
            IndexBufferElementType elementType = indexBuffer.ElementType;
            IntPtr                 offset      = GetOffset(elementType, this.FirstVertex);

            uint rs = this.PrimitiveRestartIndex;

            if (rs != 0)
            {
                GL.Instance.Enable(GL.GL_PRIMITIVE_RESTART);
                glPrimitiveRestartIndex(rs);
            }
            GLBuffer.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.BufferId);
            switch (controlMode)
            {
            case ControlMode.ByFrame:
                if (instanceCount == 1)
                {
                    if (frameCount == 1)
                    {
                        GL.Instance.DrawElements(mode, vertexCount, (uint)elementType, offset);
                    }
                    else
                    {
                        glDrawElementsBaseVertex(mode, vertexCount, (uint)elementType, offset, this.CurrentFrame * vertexCount);
                    }
                }
                else
                {
                    if (frameCount == 1)
                    {
                        glDrawElementsInstanced(mode, vertexCount, (uint)elementType, offset, instanceCount);
                    }
                    else
                    {
                        glDrawElementsInstancedBaseVertex(mode, vertexCount, (uint)elementType, offset, instanceCount, this.CurrentFrame * vertexCount);
                    }
                }
                break;

            case ControlMode.Random:
                if (instanceCount == 1)
                {
                    if (frameCount == 1)
                    {
                        GL.Instance.DrawElements(mode, this.RenderingVertexCount, (uint)elementType, offset);
                    }
                    else
                    {
                        glDrawElementsBaseVertex(mode, this.RenderingVertexCount, (uint)elementType, offset, this.CurrentFrame * vertexCount);
                    }
                }
                else
                {
                    if (frameCount == 1)
                    {
                        glDrawElementsInstanced(mode, this.RenderingVertexCount, (uint)elementType, offset, instanceCount);
                    }
                    else
                    {
                        glDrawElementsInstancedBaseVertex(mode, this.RenderingVertexCount, (uint)elementType, offset, instanceCount, this.CurrentFrame * vertexCount);
                    }
                }
                break;

            default:
                throw new NotDealWithNewEnumItemException(typeof(ControlMode));
            }

            GLBuffer.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
            if (rs != 0)
            {
                GL.Instance.Disable(GL.GL_PRIMITIVE_RESTART);
            }
        }
예제 #34
0
        private void ChangeControlMode(ControlMode controlMode)
        {
            // Disable the previous mode
            DisableControl();

            // Update the local mode
            m_controlMode = controlMode;
            m_controlModeVerified = false;
        }
예제 #35
0
        public Shape(World world, ControlMode controlMode)
        {
            //Select random shape
            switch (GameManager.Random.Next(0, 7))
            {
                case 0:
                    grid = IShape;
                    Color = Color.Red;
                    break;
                case 1:
                    grid = LShape;
                    Color = Color.Blue;
                    break;
                case 2:
                    grid = JShape;
                    Color = Color.Yellow;
                    break;
                case 3:
                    grid = ZShape;
                    Color = Color.Green;
                    break;
                case 4:
                    grid = SShape;
                    Color = Color.Purple;
                    break;
                case 5:
                    grid = TShape;
                    Color = Color.Orange;
                    break;
                case 6:
                    grid = OShape;
                    Color = Color.White;
                    break;
            }

            gridCenter = new Vector2(grid.GetLength(0) - 1, grid.GetLength(1) - 1) / 2;
            location = new Point(world.Columns / 2 - 1, (int)gridCenter.Y);
            this.controlMode = controlMode;
            this.world = world;

            //If can't spawn. kill world
            if (!CanMove(new Point(0, 0), grid))
            {
                world.Kill();
            }

            if (controlMode == ControlMode.Player)
                shadow = new Shadow(world, this);
        }
 void IGXDLMSBase.SetValue(int index, object value)
 {
     if (index == 1)
     {
         if (value is string)
         {
             LogicalName = value.ToString();
         }
         else
         {
             LogicalName = GXDLMSClient.ChangeType((byte[])value, DataType.OctetString).ToString();
         }                
     }
     else if (index == 2)
     {
         OutputState = Convert.ToBoolean(value);
     }
     else if (index == 3)
     {
         ControlState = (ControlState) Convert.ToInt32(value);
     }
     else if (index == 4)
     {
         ControlMode = (ControlMode) Convert.ToInt32(value);
     }
     else
     {
         throw new ArgumentException("SetValue failed. Invalid attribute index.");
     }
 }
예제 #37
0
 public GameSettings(ILayoutGenerator layoutGenerator, IZoneGenerator zoneGenerator, int seed, int numLevels, bool generateStatsLog, ControlMode controlMode)
 {
     LayoutGenerator  = layoutGenerator;
     ZoneGenerator    = zoneGenerator;
     Seed             = seed;
     NumLevels        = numLevels;
     GenerateStatsLog = generateStatsLog;
     ControlMode      = controlMode;
 }
예제 #38
0
 /// <summary>
 /// 执行此VBO的渲染操作。
 /// <para>Render using this VBO.</para>
 /// </summary>
 /// <param name="controlMode">index buffer is accessable randomly or only by frame.</param>
 public void Draw(ControlMode controlMode)
 {
     GL.Instance.MultiDrawArrays((uint)this.Mode, this.First, this.Count, this.First.Length);
 }
예제 #39
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="controlMode">index buffer is accessable randomly or only by frame.</param>
        public override void Draw(ControlMode controlMode)
        {
            uint mode = (uint)this.Mode;

            int primCount = this.PrimCount;

            if (primCount < 1)
            {
                throw new Exception("error: primCount is less than 1.");
            }
            int frameCount = this.FrameCount;

            if (FrameCount < 1)
            {
                throw new Exception("error: frameCount is less than 1.");
            }

            switch (controlMode)
            {
            case ControlMode.ByFrame:
                int vertexCount = this.VertexCount;
                if (primCount == 1)
                {
                    if (frameCount == 1)
                    {
                        GL.Instance.DrawArrays(mode, 0, vertexCount);
                    }
                    else
                    {
                        int vertexCountPerFrame = vertexCount / frameCount;
                        GL.Instance.DrawArrays(mode, this.CurrentFrame * vertexCountPerFrame, vertexCountPerFrame);
                    }
                }
                else
                {
                    if (frameCount == 1)
                    {
                        glDrawArraysInstanced(mode, 0, this.VertexCount, primCount);
                    }
                    else
                    {
                        int vertexCountPerFrame = vertexCount / frameCount;
                        glDrawArraysInstanced(mode, this.CurrentFrame * vertexCountPerFrame, vertexCountPerFrame, primCount);
                    }
                }
                break;

            case ControlMode.Random:
                if (primCount == 1)
                {
                    GL.Instance.DrawArrays(mode, this.FirstVertex, this.RenderingVertexCount);
                }
                else
                {
                    glDrawArraysInstanced(mode, this.FirstVertex, this.RenderingVertexCount, primCount);
                }
                break;

            default:
                throw new NotDealWithNewEnumItemException(typeof(ControlMode));
            }
        }
예제 #40
0
 private ControlCommand(ControlMode controlMode)
 {
     _controlMode = controlMode;
 }
예제 #41
0
        private void SetControlMode(ControlMode controlMode)
        {
            m_ControlMode = controlMode;

            if (m_ControlMode == ControlMode.Macro)
            {
                // Stop script and remove
                if (m_ScriptHost != null && m_ScriptHost.IsRunning)
                {
                    m_ScriptHost.Stop();
                    m_ScriptHost = null;
                }

                // Setup callback to interceptor
                Interceptor.Callback = new InterceptionDelegate(m_MacroPlayer.OnReceiveData);

                recordButton.Enabled                   = true;
                recordToolStripMenuItem.Enabled        = true;
                loopCheckBox.Enabled                   = true;
                loopCheckBox.Checked                   = m_MacroPlayer.Loop;
                loopToolStripMenuItem.Enabled          = true;
                recordOnTouchToolStripMenuItem.Enabled = true;
                scriptButton.Enabled                   = false;
                saveToolStripMenuItem.Enabled          = true;
                saveAsToolStripMenuItem.Enabled        = true;
                clearMacroToolStripMenuItem.Enabled    = true;
                trimMacroToolStripMenuItem.Enabled     = true;
            }
            else if (m_ControlMode == ControlMode.Script)
            {
                // Stop macro player
                if (m_MacroPlayer.IsRecording)
                {
                    m_MacroPlayer.Record();
                }
                m_MacroPlayer.Stop();

                // Setup callback to interceptor
                Interceptor.Callback = new InterceptionDelegate(m_ScriptHost.OnReceiveData);

                recordButton.Enabled                   = false;
                recordToolStripMenuItem.Enabled        = false;
                loopCheckBox.Enabled                   = false;
                loopCheckBox.Checked                   = false;
                loopToolStripMenuItem.Enabled          = false;
                recordOnTouchToolStripMenuItem.Enabled = false;
                scriptButton.Enabled                   = true;
                saveToolStripMenuItem.Enabled          = false;
                saveAsToolStripMenuItem.Enabled        = false;
                clearMacroToolStripMenuItem.Enabled    = false;
                trimMacroToolStripMenuItem.Enabled     = false;
                currentTickToolStripStatusLabel.Text   = CURRENT_TICK_DEFAULT_TEXT;
            }
            else if (m_ControlMode == ControlMode.Remapper)
            {
                // Stop macro player
                if (m_MacroPlayer.IsRecording)
                {
                    m_MacroPlayer.Record();
                }
                m_MacroPlayer.Stop();

                // Stop script
                if (m_ScriptHost != null && m_ScriptHost.IsRunning)
                {
                    m_ScriptHost.Stop();
                }

                // Setup callback to interceptor
                Interceptor.Callback = new InterceptionDelegate(m_Remapper.OnReceiveData);
            }
            else if (m_ControlMode == ControlMode.StatusChecker)
            {
                // Stop macro player
                if (m_MacroPlayer.IsRecording)
                {
                    m_MacroPlayer.Record();
                }
                m_MacroPlayer.Stop();

                // Stop script
                if (m_ScriptHost != null && m_ScriptHost.IsRunning)
                {
                    m_ScriptHost.Stop();
                }

                // Setup callback to interceptor
                Interceptor.Callback = new InterceptionDelegate(m_StatusChecker.OnReceiveData);
            }
        }
예제 #42
0
        void SwitchMode(object sender, GestureEventArgs e)
        {
            if (!CheckEventInterval(ref _switchModeHit, SwitchModeEventInterval)) return;

            switch (_currentMode)
            {
                case ControlMode.MouseControl: _currentMode = ControlMode.AngryBirds; break;
                case ControlMode.AngryBirds: _currentMode = ControlMode.MouseControl; break;
                default: return;
            }

            WindowMessage = "Switching mode to " + _currentMode;
            AngryBirdsMode = _currentMode == ControlMode.AngryBirds ? Visibility.Visible : Visibility.Hidden;

            UnBindAllGestures();
            switch (_currentMode)
            {
                case ControlMode.MouseControl:
                    _righthandRightHipCollision.Filtered += FireMouseUp;
                    _righthandRightHipGesture.SelfTouchDetected += FireMouseDown;
                    _righthandHeadGesture.SelfTouchDetected += FireMouseClick;
                break;
                case ControlMode.AngryBirds:
                    _lefthandRighthandCollision.Filtered += FireMouseUp;
                    _lefthandRighthandGesture.SelfTouchDetected += FireMouseDown;
                    _lefthandHeadGesture.SelfTouchDetected += FireMouseClick;
                break;
            }
        }
예제 #43
0
 public void SetControlMode(ControlMode mode)
 {
     // Nothing to do here.
 }
예제 #44
0
 public void switchControlMode()
 {
     controlMode = 1 - controlMode;
 }
예제 #45
0
파일: Player.cs 프로젝트: sean-h/spacegame
    // Use this for initialization
    private void Start()
    {
        shipController.gameObject.SetActive(false);
        _squadronController = this.GetComponent<SquadronController>();

        _controlModeRTS = this.GetComponent<ControlModeRTS>();
        movementIndicator.SetActive(false);
        _currentControlMode = _controlModeRTS;

        battleManager = GameObject.Find("BattleManager").GetComponent<BattleManager>();
        fleet = battleManager.atkFleet;
    }
예제 #46
0
 public void SetControlMode(ControlMode mode)
 {
     CurrentContolMode = mode;
 }
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         if (e.Value is string)
         {
             LogicalName = e.Value.ToString();
         }
         else
         {
             LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 2)
     {
         OutputState = Convert.ToBoolean(e.Value);
     }
     else if (e.Index == 3)
     {
         ControlState = (ControlState)Convert.ToInt32(e.Value);
     }
     else if (e.Index == 4)
     {
         ControlMode = (ControlMode)Convert.ToInt32(e.Value);
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
예제 #48
0
 public void SetControlMode(ControlMode controlMode, IEnumerator coroutine = null)
 {
     m_controlMode = controlMode;
     SetControlProgram(coroutine);
 }
예제 #49
0
파일: UI.cs 프로젝트: Lambosaurus/StarPixel
        public void HackyManualKeyEvents()
        {

            if (inputs.kb.IsKeyDown(Keys.LeftShift))
            {
                if (focus_phys != null && focus_phys is Ship)
                {
                    Ship ship = (Ship)focus_phys;
                    if (ship.ai != null)
                    {
                        List<UIMarker> markers = ship.ai.GetUiMarkers();
                        if (markers != null)
                        {
                            camera_widget.markers = markers;
                        }
                    }
                }
            }

            if (inputs.kb.IsKeyDown(Keys.Tab))
            {
                if (camera_widget.markers == null) { camera_widget.markers = new List<UIMarker>(); }

                foreach (Physical phys in focus_universe.physicals)
                {
                    if (phys is Ship)
                    {
                        if (camera_widget.camera.ContainsCircle(phys.pos, phys.radius))
                        {
                            camera_widget.markers.Add(new MarkerPhysicalDefence(phys));
                        }
                    }
                }
            }

            if (inputs.KeyDownEvent(Keys.F3))
            {
                camera_widget.camera.DRAW_HITBOXES = !camera_widget.camera.DRAW_HITBOXES;
            }

            if (inputs.KeyDownEvent(Keys.OemTilde))
            {
                mode = (mode == ControlMode.Control) ? ControlMode.Observe : ControlMode.Control;
            }
        }
 void IGXDLMSBase.Load(GXXmlReader reader)
 {
     OutputState  = reader.ReadElementContentAsInt("OutputState") != 0;
     ControlState = (ControlState)reader.ReadElementContentAsInt("ControlState");
     ControlMode  = (ControlMode)reader.ReadElementContentAsInt("ControlMode");
 }
예제 #51
0
 private void OnChangeControlMode(ControlMode value)
 {
     if (value == controlMode)
         return;
     // turn off any old things
     switch (controlMode)
     {
         case ControlMode.Selection:
             break;
         case ControlMode.SelectionMovement:
             renderContext.RemoveSelectionMovementItems();
             break;
         case ControlMode.SelectionRotation:
             break;
         case ControlMode.ViewMovement:
             break;
     }
     // turn on new items
     switch (value)
     {
         case ControlMode.Selection:
             break;
         case ControlMode.SelectionMovement:
             renderContext.AddSelectionMovementItems();
             break;
         case ControlMode.SelectionRotation:
             break;
         case ControlMode.ViewMovement:
             break;
     }
 }
예제 #52
0
        /// <summary>
        /// 运行器
        /// </summary>
        private void RunController()
        {
            while (!IsExited)
            {
                if (!IsWorking)
                {
                    System.Threading.Thread.Sleep(1000);
                    continue;
                }
                ControlMode mode = Server.Config.ControlMode;
                if (mode == ControlMode.Singleton)
                {
                    System.Threading.Thread.Sleep(100); //不进行调度
                }
                else if (mode == ControlMode.Self)
                {
                    System.Threading.Thread.Sleep(100);//不进行调度
                }
                else if (mode == ControlMode.Parallel)
                {
                    #region
                    IRunDevice[] list = this.Server.DeviceManager.GetDevices(CommunicateType.NET);

                    if (list.Length <= 0)
                    {
                        System.Threading.Thread.Sleep(100);
                        continue;
                    }

                    for (int i = 0; i < list.Length; i++)
                    {
                        if (IsExited || !IsWorking)
                        {
                            break;
                        }

                        Send(list[i], list[i].GetSendBytes());
                    }

                    System.Threading.Thread.Sleep(1000);
                    #endregion
                }
                else if (mode == ControlMode.Loop)
                {
                    #region
                    IRunDevice[] devList = this.Server.DeviceManager.GetDevices(CommunicateType.NET);

                    if (devList.Length <= 0)
                    {
                        System.Threading.Thread.Sleep(100);
                        continue;
                    }

                    //检测当前控制器的运行优化级
                    IRunDevice dev = this.Server.DeviceManager.GetPriorityDevice(devList);

                    if (dev != null) //如果有优先级设备,则直接调度设备
                    {
                        this.RunDevice(dev);
                    }
                    else //如果没有优先级设备,则轮询调度设备
                    {
                        for (int i = 0; i < devList.Length; i++)
                        {
                            if (IsExited || !IsWorking)
                            {
                                break;
                            }

                            //---------每次循环都检测优先级,保证及时响应----------//
                            dev = this.Server.DeviceManager.GetPriorityDevice(devList);

                            if (dev != null)
                            {
                                this.RunDevice(dev);
                            }
                            //-------------------------------------------------//

                            this.RunDevice(devList[i]);
                        }
                    }
                    #endregion
                }
            }
        }
예제 #53
0
파일: Control.cs 프로젝트: fkpwolf/tinyFan
        public Control(ISensor sensor, ISettings settings, float minSoftwareValue,
            float maxSoftwareValue)
        {
            this.identifier = new Identifier(sensor.Identifier, "control");
              this.settings = settings;
              this.minSoftwareValue = minSoftwareValue;
              this.maxSoftwareValue = maxSoftwareValue;
              //fan add
              this.sensorType = sensor.SensorType;

              float softValue = 0;
              if (!float.TryParse(settings.GetValue(
              new Identifier(identifier, "value").ToString(), "-a"),
            NumberStyles.Float, CultureInfo.InvariantCulture,
            out softValue)){
              this.softwareValue = 0;
              if (this.sensorType.Equals(SensorType.TinyFanControl))
              this.SoftwareValue = 50; //init value(when .config was not exist)
              }
              else
              this.softwareValue = softValue;
              int mode;
              if (!int.TryParse(settings.GetValue(
              new Identifier(identifier, "mode").ToString(),
              ((int)ControlMode.Default).ToString(CultureInfo.InvariantCulture)),
            NumberStyles.Integer, CultureInfo.InvariantCulture,
            out mode))
              {
            this.mode = ControlMode.Default;
              } else {
            this.mode = (ControlMode)mode;
              }
              int fanMode;
              if (!int.TryParse(settings.GetValue(
              new Identifier(identifier, "fanMode").ToString(),
              ((int)FanMode.Pin4).ToString(CultureInfo.InvariantCulture)),
            NumberStyles.Integer, CultureInfo.InvariantCulture,
            out fanMode))
              {
              this.fanMode = FanMode.Pin4;
              }
              else
              {
              this.fanMode = (FanMode)fanMode;
              }
              int fanFollow;//again
              if (!int.TryParse(settings.GetValue(
              new Identifier(identifier, "fanFollow").ToString(),
              ((int)FanFollow.NONE).ToString(CultureInfo.InvariantCulture)),
            NumberStyles.Integer, CultureInfo.InvariantCulture,
            out fanFollow))
              {
              this.fanFollow = FanFollow.NONE;
              }
              else
              {
              this.fanFollow = (FanFollow)fanFollow;
              }
        }
예제 #54
0
 public ModeInitializedEventArgs(ControlMode mode)
 {
     Mode = mode;
 }
예제 #55
0
 private void mCoordinator_CameraModeChanged(Core coordinator, ControlMode mode)
 {
     if (!mGuiUpdate) {
         mExternalUpdate = true;
         Invoke(() => {
             if (mCore.ControlMode == ControlMode.Absolute) {
                 deltaModeButton.Checked = false;
                 absoluteModeButton.Checked = true;
                 virtualPositionPanel.Text = "Camera Position";
                 virtualOrientationPanel.Text = "Camera Orientation";
                 virtualPositionPanel.Value = mCore.Position;
                 virtualOrientationPanel.Pitch = mCore.Orientation.Pitch;
                 virtualOrientationPanel.Yaw = mCore.Orientation.Yaw;
             } else {
                 deltaModeButton.Checked = true;
                 absoluteModeButton.Checked = false;
                 virtualPositionPanel.Text = "Camera Position Delta";
                 virtualOrientationPanel.Text = "Camera Orientation Delta";
                 virtualPositionPanel.Value = mCore.PositionDelta;
                 virtualOrientationPanel.Pitch = mCore.OrientationDelta.Pitch;
                 virtualOrientationPanel.Yaw = mCore.OrientationDelta.Yaw;
             }
         });
         mExternalUpdate = false;
     }
 }
예제 #56
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="controlMode">index buffer is accessable randomly or only by frame.</param>
        public override void Draw(ControlMode controlMode)
        {
            int primCount = this.PrimCount;

            if (primCount < 1)
            {
                throw new Exception("error: primCount is less than 1.");
            }
            int frameCount = this.FrameCount;

            if (FrameCount < 1)
            {
                throw new Exception("error: frameCount is less than 1.");
            }

            uint   mode        = (uint)this.Mode;
            int    vertexCount = this.VertexCount;
            IntPtr offset      = GetOffset(this.ElementType, this.FirstVertex);


            glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, this.BufferId);
            switch (controlMode)
            {
            case ControlMode.ByFrame:
                if (primCount == 1)
                {
                    if (frameCount == 1)
                    {
                        GL.Instance.DrawElements(mode, vertexCount, (uint)this.ElementType, offset);
                    }
                    else
                    {
                        glDrawElementsBaseVertex(mode, vertexCount, (uint)this.ElementType, offset, this.CurrentFrame * vertexCount);
                    }
                }
                else
                {
                    if (frameCount == 1)
                    {
                        glDrawElementsInstanced(mode, vertexCount, (uint)this.ElementType, offset, primCount);
                    }
                    else
                    {
                        glDrawElementsInstancedBaseVertex(mode, vertexCount, (uint)this.ElementType, offset, primCount, this.CurrentFrame * vertexCount);
                    }
                }
                break;

            case ControlMode.Random:
                if (primCount == 1)
                {
                    if (frameCount == 1)
                    {
                        GL.Instance.DrawElements(mode, this.RenderingVertexCount, (uint)this.ElementType, offset);
                    }
                    else
                    {
                        glDrawElementsBaseVertex(mode, this.RenderingVertexCount, (uint)this.ElementType, offset, this.CurrentFrame * vertexCount);
                    }
                }
                else
                {
                    if (frameCount == 1)
                    {
                        glDrawElementsInstanced(mode, this.RenderingVertexCount, (uint)this.ElementType, offset, primCount);
                    }
                    else
                    {
                        glDrawElementsInstancedBaseVertex(mode, this.RenderingVertexCount, (uint)this.ElementType, offset, primCount, this.CurrentFrame * vertexCount);
                    }
                }
                break;

            default:
                throw new ArgumentException(string.Format("Invalid value[{0}]", controlMode));
            }

            glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
        }
예제 #57
0
 public void LoadPlayerPrefs()
 {
     if (PlayerPrefs.HasKey("tiltSensitivity")) {
         rollSensitivity = PlayerPrefs.GetFloat("tiltSensitivity");
         pitchSensitivity = PlayerPrefs.GetFloat("tiltSensitivity");
     }
     if (PlayerPrefs.HasKey("yawSensitivity")) {
         yawSensitivity = PlayerPrefs.GetFloat("yawSensitivity");
     }
     if (PlayerPrefs.HasKey("heightSensitivity")) {
         heightSensitivity = PlayerPrefs.GetFloat("heightSensitivity");
     }
     if (PlayerPrefs.HasKey("squareMapping")) {
         squareMapping = (PlayerPrefs.GetInt("squareMapping") > 0);
     }
     if (PlayerPrefs.HasKey("invertAxisT")) {
         invertAxisT = (PlayerPrefs.GetInt("invertAxisT") > 0);
     }
     if (PlayerPrefs.HasKey("invertAxisR")) {
         invertAxisR = (PlayerPrefs.GetInt("invertAxisR") > 0);
     }
     if (PlayerPrefs.HasKey("invertAxisE")) {
         invertAxisE = (PlayerPrefs.GetInt("invertAxisE") > 0);
     }
     if (PlayerPrefs.HasKey("invertAxisA")) {
         invertAxisA = (PlayerPrefs.GetInt("invertAxisA") > 0);
     }
     if (PlayerPrefs.HasKey("tiltRateKp")) {
         tiltRateKp = PlayerPrefs.GetFloat("tiltRateKp");
     }
     if (PlayerPrefs.HasKey("yawRateKp")) {
         yawRateKp = PlayerPrefs.GetFloat("yawRateKp");
     }
     if (PlayerPrefs.HasKey("enableStabilization")) {
         bool enableStabilization = (PlayerPrefs.GetInt("enableStabilization") > 0);
         if (enableStabilization) {
             anglesControl = ControlMode.Stabilized;
             heightControl = ControlMode.Stabilized;
         } else {
             anglesControl = ControlMode.Manual;
             heightControl = ControlMode.Manual;
         }
     }
     if (PlayerPrefs.HasKey("tiltAngle")) {
         tiltAngle = PlayerPrefs.GetFloat("tiltAngle");
     }
     if (PlayerPrefs.HasKey("verticalSpeed")) {
         verticalSpeedSensitivity = PlayerPrefs.GetFloat("verticalSpeed");
     }
     if (PlayerPrefs.HasKey("tiltAngleKp")) {
         tiltAngleKp = PlayerPrefs.GetFloat("tiltAngleKp");
     }
     if (PlayerPrefs.HasKey("yawAngleKp")) {
         yawAngleKp = PlayerPrefs.GetFloat("yawAngleKp");
     }
     if (PlayerPrefs.HasKey("verticalSpeedKp")) {
         verticalSpeedKp = PlayerPrefs.GetFloat("verticalSpeedKp");
     }
 }
예제 #58
0
파일: WebModel.cs 프로젝트: rassilon/NModel
 public static void Initialize()
 {
     state = ControlMode.Running;
 }