public ControlSystemDto Map (ControlSystem entity) { return new ControlSystemDto { Id = entity.Id, Description = entity.Description, DocumentLibraryId = entity.DocumentLibraryId.GetValueOrDefault() }; }
public StabilityAugmentation(Vessel vessel) { _vessel = vessel; systemDropdown = new GUIDropDown<int>(systemLabel, new int[] { 0, 1, 2, 3, 4, 5 }, 0); LoadSettings(); systemInstances = new ControlSystem[systemTemplates.Length]; for (int i = 0; i < systemInstances.Length; i++) { systemInstances[i] = new ControlSystem(systemTemplates[i]); } _vessel.OnAutopilotUpdate += OnAutoPilotUpdate; }
public void When_SetLastRecommendedControlSystem_Then_set_correct_properties() { // Given var riskAssessment = new HazardousSubstanceRiskAssessment(); var controlSystem = new ControlSystem(); var user = new UserForAuditing(); // When riskAssessment.SetLastRecommendedControlSystem(controlSystem, user); // Then Assert.That(riskAssessment.LastRecommendedControlSystem, Is.EqualTo(controlSystem)); Assert.That(riskAssessment.LastModifiedBy, Is.EqualTo(user)); Assert.That(riskAssessment.LastModifiedOn.Value.Date, Is.EqualTo(DateTime.Now.Date)); }
public void Given_valid_request_When_Calculate_Then_should_call_correct_methods() { //Given var controlSystemService = CreateControlSystemService(); var controlSystem = new ControlSystem(); _calculationService .Setup(x => x.Calculate(groupCode, matterState, quantity, dustinessOrVolatility)) .Returns(controlSystem); //When controlSystemService.Calculate(groupCode, matterState, quantity, dustinessOrVolatility); //Then _calculationService.VerifyAll(); }
public void ShouldCleanupAtTheSpecifiedCycle() { //Arrange var mockConveyor = MockRepository.GenerateStub<IConveyor>(); var mockRobot = MockRepository.GenerateStub<IRobot>(); var mockVacuumPort = MockRepository.GenerateStub<IVacuumPort>(); mockRobot.Stub(x => x.Build()).Return(new List<Widget>()); var target = new ControlSystem(mockConveyor, mockRobot, mockVacuumPort); //Act var result = target.DoStuff(2, 1); //Assert Assert.AreEqual(2, result.Cleanups.Count()); Assert.AreEqual(1,result.Cleanups.First().CycleCleanedAfter); Assert.AreEqual(2, result.Cleanups.Last().CycleCleanedAfter); }
public void When_SaveLastRecommendedControlSystem_calls_correct_methods() { // Given var riskAssessment = new Mock<HazardousSubstanceRiskAssessment>(); var target = GetTarget(); var request = new SaveLastRecommendedControlSystemRequest { Id = 10L, CompanyId = 100L, ControlSystemId = 1000L, UserId = Guid.NewGuid() }; _hazardousSubstanceAssessmentRepository .Setup(x => x.GetByIdAndCompanyId( request.Id, request.CompanyId)) .Returns(riskAssessment.Object); _userRepository .Setup(x => x.GetByIdAndCompanyId( request.UserId, request.CompanyId)) .Returns(_userForAuditing); var controlSystem = new ControlSystem(); _controlSystemRepository .Setup(x => x.LoadById(request.ControlSystemId)) .Returns(controlSystem); // When target.SaveLastRecommendedControlSystem(request); // Then _hazardousSubstanceAssessmentRepository.Verify(x => x.SaveOrUpdate(riskAssessment.Object)); riskAssessment.Verify(x => x.SetLastRecommendedControlSystem(controlSystem, _userForAuditing)); _controlSystemRepository.VerifyAll(); }
public void ShouldMoveConveyorOnDoStuff() { //Arrange var mockConveyor = MockRepository.GenerateStrictMock<IConveyor>(); var mockRobot = MockRepository.GenerateStub<IRobot>(); mockRobot.Stub(x => x.Build()).Return(new List<Widget>()); var mockVacuumPort = MockRepository.GenerateStub<IVacuumPort>(); mockConveyor.Expect(x => x.Run()).Repeat.Once(); var target = new ControlSystem(mockConveyor, mockRobot, mockVacuumPort); //Act var result = target.DoStuff(1, 100); //Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.Movements.Count()); mockConveyor.VerifyAllExpectations(); }
protected override void LoadContent() { MyraEnvironment.Game = this; spriteBatch = new SpriteBatch(GraphicsDevice); var sprites = new Sprites(new Sprite(Content.Load <Texture2D>("anki")), new Sprite(Content.Load <Texture2D>("bronch"))); var spawnSystem = new SpawnSystem(sharedState); var renderSystem = new RenderSystem(sharedState, spriteBatch, sprites); var controlSystem = new ControlSystem(sharedState, mouseListener, random, graphics, sprites); var playerSystem = new PlayerSystem(); var physicsSystem = new PhysicsSystem(graphics); world = new WorldBuilder() .AddSystem(controlSystem) .AddSystem(spawnSystem) .AddSystem(playerSystem) .AddSystem(physicsSystem) .AddSystem(renderSystem) .Build(); }
public void OnRemovedFromGroup(MyGridPhysicalGroupData group) { ControlSystem.RemoveGrid(CubeGrid); if (m_blocksRegistered) { foreach (var block in m_cubeGrid.GetBlocks()) { if (block.FatBlock == null) { continue; } var controllerBlock = block.FatBlock as MyShipController; if (controllerBlock != null && controllerBlock.ControllerInfo.Controller != null && controllerBlock.EnableShipControl) { ControlSystem.RemoveControllerBlock(controllerBlock); } } } ControlSystem = null; }
public virtual void UpdateBeforeSimulation() { ProfilerShort.Begin("Thrusters and gyro"); ThrustSystem.UpdateBeforeSimulation(); GyroSystem.UpdateBeforeSimulation(); ProfilerShort.End(); if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT) { ProfilerShort.Begin("Wheels"); WheelSystem.UpdateBeforeSimulation(); ProfilerShort.End(); } ProfilerShort.Begin("Conveyors"); ConveyorSystem.UpdateBeforeSimulation(); ProfilerShort.End(); ProfilerShort.Begin("Control"); ControlSystem.UpdateBeforeSimulation(); ProfilerShort.End(); ProfilerShort.Begin("Cameras"); CameraSystem.UpdateBeforeSimulation(); ProfilerShort.End(); if (MySession.Static.Settings.EnableOxygen) { ProfilerShort.Begin("Oxygen"); OxygenSystem.UpdateBeforeSimulation(); ProfilerShort.End(); } ProfilerShort.Begin("Jump"); JumpSystem.UpdateBeforeSimulation(); ProfilerShort.End(); }
public static void BuildDefaultSystems() { ControlSystem sys = new ControlSystem(); //Roll system sys.kP = 0.05; sys.kD = 1; sys.kI = 0.5; systemTemplates[0] = sys; //Yaw system sys.kP = 0; sys.kD = 1; sys.kI = 0; systemTemplates[1] = sys; //Pitch system sys.kP = 0; sys.kD = 1; sys.kI = 0; systemTemplates[2] = sys; //AoA system sys.kP = 0.25; sys.kD = 0; sys.kI = 0; aoALowLim = -10; aoAHighLim = 20; systemTemplates[3] = sys; scalingDynPres = 20; }
public void SettingsDisplay() { if (boxStyle == null) { boxStyle = FlightGUI.boxStyle; } GUILayout.Label("Control System Tweaking"); systemDropdown.GUIDropDownDisplay(GUILayout.Width(120)); int selectedItem = systemDropdown.ActiveSelection; ControlSystem sys = systemInstances[selectedItem]; GUILayout.BeginVertical(boxStyle); if (selectedItem != 4) { sys.kP = GUIUtils.TextEntryForDouble("Proportional Gain:", 120, sys.kP); sys.kD = GUIUtils.TextEntryForDouble("Derivative Gain:", 120, sys.kD); sys.kI = GUIUtils.TextEntryForDouble("Integral Gain:", 120, sys.kI); if (selectedItem == 3) { aoALowLim = GUIUtils.TextEntryForDouble("Min AoA Lim:", 120, aoALowLim); aoAHighLim = GUIUtils.TextEntryForDouble("Min AoA Lim:", 120, aoAHighLim); } else { sys.zeroPoint = GUIUtils.TextEntryForDouble("Desired Point:", 120, sys.zeroPoint); } } else { scalingDynPres = GUIUtils.TextEntryForDouble("Dyn Pres For Control Scaling:", 150, scalingDynPres); } GUILayout.EndVertical(); }
public void SettingsDisplay() { if (boxStyle == null) { boxStyle = FlightGUI.boxStyle; } GUILayout.Label(Localizer.Format("FARFlightStabLabel")); systemDropdown.GUIDropDownDisplay(GUILayout.Width(120)); int selectedItem = systemDropdown.ActiveSelection; ControlSystem sys = systemInstances[selectedItem]; GUILayout.BeginVertical(boxStyle); if (selectedItem != 4) { sys.kP = GUIUtils.TextEntryForDouble(Localizer.Format("FARFlightStabPropGain"), 120, sys.kP); sys.kD = GUIUtils.TextEntryForDouble(Localizer.Format("FARFlightStabDerivGain"), 120, sys.kD); sys.kI = GUIUtils.TextEntryForDouble(Localizer.Format("FARFlightStabIntGain"), 120, sys.kI); if (selectedItem == 3) { aoALowLim = GUIUtils.TextEntryForDouble(Localizer.Format("FARFlightStabAoALow"), 120, aoALowLim); aoAHighLim = GUIUtils.TextEntryForDouble(Localizer.Format("FARFlightStabAoAHigh"), 120, aoAHighLim); } else { sys.zeroPoint = GUIUtils.TextEntryForDouble(Localizer.Format("FARFlightStabOffset"), 120, sys.zeroPoint); } } else { scalingDynPres = GUIUtils.TextEntryForDouble(Localizer.Format("FARFlightStabQScaling"), 150, scalingDynPres); } GUILayout.EndVertical(); }
public void Given_valid_request_When_Calculate_Then_should_return_correct_results() { //Given var controlSystemService = CreateControlSystemService(); var controlSystem = new ControlSystem() { Id = 250, Description = "This Description", DocumentLibraryId = 1021L }; _calculationService .Setup(x => x.Calculate(groupCode, matterState, quantity, dustinessOrVolatility)) .Returns(controlSystem); //When var result = controlSystemService.Calculate(groupCode, matterState, quantity, dustinessOrVolatility); //Then Assert.That(result, Is.Not.Null); Assert.That(result.Id, Is.EqualTo(controlSystem.Id)); Assert.That(result.Description, Is.EqualTo(controlSystem.Description)); Assert.That(result.DocumentLibraryId, Is.EqualTo(controlSystem.DocumentLibraryId)); }
/// <summary> /// 스크립트 실행 /// </summary> /// <param name="filepath"></param> /// <param name="session">실행 중에 사용할 Session. 지정하지 않을 경우 새 세션을 사용</param> /// <param name="snapshotIndex">불러오기 시에만 사용. 시작할 Snapshot Index를 지정</param> public void RunScript(string filepath, ExecuteType exeType = ExecuteType.NewStart, int snapshotIndex = 0) { FSNResourceCache.StartLoadingSession(FSNResourceCache.Category.Script); // 리소스 로딩 세션 시작 if (exeType == ExecuteType.NewStart) // 새 세션을 열어야하는 경우 미리 세션 생성하기 (새 게임) { m_seqEngine.PrepareNewSession(); } FSNScriptSequence scriptSeq = FSNScriptSequence.Parser.FromAsset(filepath, m_seqEngine.CurrentSession); // 스크립트 해석 // TODO : header 적용, 여기에 코드를 삽입하는 것이 맞는지는 잘 모르겠음. 리팩토링이 필요할수도. // 인게임 세팅 var stchain = new FSNInGameSetting.Chain(FSNInGameSetting.DefaultInGameSetting); // 디폴트 속성을 베이스로 chain 만들기 foreach (var pair in scriptSeq.Header.InGameSettings) { var alias = FSNInGameSetting.ConvertPropertyNameAlias(pair.Key); stchain.SetPropertyByString(alias, pair.Value); } m_inGameSetting = stchain.Freeze(); // 속성값 고정, 현재 엔진의 디폴트 속성을 덮어씌운다. // var sshotSeq = FSNSnapshotSequence.Builder.BuildSnapshotSequence(scriptSeq); // Snapshot 시퀀스 생성 FSNResourceCache.EndLoadingSession(); // 리소스 로딩 세션 종료 bool overwriteScriptInfoToSession = exeType != ExecuteType.LoadFromSession; // 불러오기한 경우가 아니면 스크립트 정보를 세션에 덮어써야한다. m_seqEngine.StartSnapshotSequence(sshotSeq, overwriteScriptInfoToSession, snapshotIndex); // 실행 ControlSystem.ScriptLoadComplete(); // 스크립트 로딩 완료 이벤트 }
public void TestGetConnectingStreetSegments() { List <StreetConnector> sc1 = new List <StreetConnector>(); StreetConnector c1 = new StreetConnector(0, 0); StreetConnector c2 = new StreetConnector(0, 50); StreetConnector c3 = new StreetConnector(0, 120); sc1.Add(c1); sc1.Add(c2); sc1.Add(c3); List <StreetSegment> ss1 = new List <StreetSegment>(); StreetSegment s1 = new StreetSegment(c1, c2); StreetSegment s2 = new StreetSegment(c2, c3); ss1.Add(s1); ss1.Add(s2); List <StreetSegment> sTest1 = ControlSystem.GetConnectingStreetSegments(sc1); Assert.AreEqual(2, sTest1.Count()); Assert.AreEqual(true, sTest1.Contains(s1)); Assert.AreEqual(true, sTest1.Contains(s2)); }
public void ExtractActionType_NoParameters_Extracts() { var result = ControlSystem.ExtractActionType("InventoryMenu"); result.Should().Be(ActionType.InventoryMenu); }
public VTS__Climate_MainMethods(ControlSystem ControlSystem, Panel Panel) { this.ControlSystem = ControlSystem; this.Panel = Panel; }
/// <summary> /// Initalizes a new instance of <see cref="MissingSystem"/> /// </summary> /// <param name="controlSystem"><see cref="ControlSystem"/> that does not exist</param> public MissingSystem(ControlSystem controlSystem) : base($"System '{controlSystem}' does not exist") { }
public void WhenIRunTheseCycles() { var controlSystem = new ControlSystem(_conveyor, _robot, new VaccumPort()); results = controlSystem.DoStuff(_maxRunCycles,_cleanUpBound); }
public DmSwitcher(ControlSystem controlSystem, SwitcherConfig switcherConfig) { ControlSystem = controlSystem; var assembly = Assembly.Load(typeof(DmMd32x32Cpu3).AssemblyName()); #if DEBUG CrestronConsole.PrintLine("DMSwitcher - Creating instance of {0}", switcherConfig.FrameType); #endif try { var frameType = assembly.GetType(switcherConfig.FrameType).GetCType(); var frameCtor = frameType.GetConstructor(new CType[] { typeof(uint), typeof(CrestronControlSystem) }); Chassis = (Switch)frameCtor.Invoke(new object[] { switcherConfig.Id, controlSystem }); for (var i = 1U; i <= Chassis.NumberOfOutputs; i++) { _outInit[i] = false; } } catch (Exception e) { CloudLog.Exception(e, "Error loading DM Frame type"); throw e; } foreach (var cardConfig in switcherConfig.InputCards) { CardDevice card = null; try { var cardType = assembly.GetType(cardConfig.Type).GetCType(); var ctor = cardType.GetConstructor(new CType[] { typeof(uint), typeof(Switch) }); card = (CardDevice)ctor.Invoke(new object[] { cardConfig.Number, Chassis }); } catch (Exception e) { CloudLog.Error("Could not create DM Input Card {0} with ID {1}, {2}", cardConfig.Type, cardConfig.Number, e.Message); } if (card == null) { continue; } try { var inputConfig = switcherConfig.Inputs.FirstOrDefault(i => i.Number == card.SwitcherInputOutput.Number); if (inputConfig == null) { continue; } if (string.IsNullOrEmpty(inputConfig.EndpointType)) { continue; } var endpointType = assembly.GetType(inputConfig.EndpointType).GetCType(); var ctor = endpointType.GetConstructor(new CType[] { typeof(DMInput) }); var endpoint = (DMEndpointBase)ctor.Invoke(new object[] { card.SwitcherInputOutput as DMInput }); endpoint.Description = inputConfig.Name; } catch (Exception e) { CloudLog.Error("Could not create DM Input {0}, {1}", cardConfig.Number, e.Message); } } foreach (var cardConfig in switcherConfig.OutputCards) { DmcOutputSingle card = null; try { var bladeType = assembly.GetType(cardConfig.Type).GetCType(); var ctor = bladeType.GetConstructor(new CType[] { typeof(uint), typeof(Switch) }); card = (DmcOutputSingle)ctor.Invoke(new object[] { cardConfig.Number, Chassis }); } catch (Exception e) { CloudLog.Error("Could not create DM Output Card {0} with ID {1}, {2}", cardConfig.Type, cardConfig.Number, e.Message); } if (card == null) { continue; } for (var cardOutput = 1U; cardOutput <= 2; cardOutput++) { var propName = "Card" + cardOutput; var cardSingle = (CardDevice) card.GetCType() .GetProperties(BindingFlags.Public | BindingFlags.Instance) .First(p => p.Name == propName) .GetValue(card); try { var outputConfig = switcherConfig.Outputs.FirstOrDefault(i => i.Number == cardSingle.SwitcherInputOutput.Number); if (outputConfig == null) { continue; } if (string.IsNullOrEmpty(outputConfig.EndpointType)) { continue; } var endpointType = assembly.GetType(outputConfig.EndpointType).GetCType(); var ctor = endpointType.GetConstructor(new CType[] { typeof(DMOutput) }); var endpoint = (DMEndpointBase)ctor.Invoke(new object[] { cardSingle.SwitcherInputOutput as DMOutput }); endpoint.Description = outputConfig.Name; } catch (Exception e) { CloudLog.Error("Could not create DM Output {0}, {1}", cardSingle.SwitcherInputOutput.Number, e.Message); } } } Chassis.OnlineStatusChange += Chassis_OnlineStatusChange; Chassis.DMInputChange += OnDmInputChange; Chassis.DMOutputChange += OnDmOutputChange; try { var regResult = Chassis.Register(); if (regResult != eDeviceRegistrationUnRegistrationResponse.Success) { CloudLog.Error("Error registering DM Frame, result = {0}", regResult); } } catch (Exception e) { CloudLog.Error("Error trying to register DM Frame, {0}", e.Message); } try { foreach (var inputConfig in switcherConfig.Inputs) { if (inputConfig.Number == 0 || inputConfig.Number > Chassis.NumberOfInputs) { continue; } Chassis.Inputs[inputConfig.Number].Name.StringValue = inputConfig.Name; } foreach (var outputConfig in switcherConfig.Outputs) { if (outputConfig.Number == 0 || outputConfig.Number > Chassis.NumberOfOutputs) { continue; } Chassis.Outputs[outputConfig.Number].Name.StringValue = outputConfig.Name; } } catch (Exception e) { CloudLog.Error("Error setting names on DM switcher, {0}", e.Message); } }
public ILightingSystem createLightingSystem(ControlSystem system) { return(new LightingSystem(system, new SettingsManager(), new RoomManager(), new SceneManager(), new LoadManager(), new TouchPanelManager())); }
public void ExtractActionType_WithParameters_Extracts() { var result = ControlSystem.ExtractActionType("Move(1,0)"); result.Should().Be(ActionType.Move); }
public void ExtractParameters_WithParameters_Extracts() { var result = ControlSystem.ExtractParameters("Move(1,0)"); result.Should().Be("1,0"); }
// void Awake() { if(_control == null) { DontDestroyOnLoad(gameObject); _control = this; // _running = true; // _camera = GameObject.Find("Camera"); _playerObject = GameObject.Find("Player"); // _timer = new System.Timers.Timer(30000); _timer.AutoReset = true; _timer.Elapsed += OnTimerElapsed; // _timeOutTimer = new System.Timers.Timer(30000); _timeOutTimer.Elapsed += OnTimeOutElapsed; _timeOutTimer.AutoReset = true; // Load(); } else if(_control != this) { Destroy(this.gameObject); } }
public void UpdateBeforeSimulation() { ProfilerShort.Begin("Control"); ControlSystem.UpdateBeforeSimulation(); ProfilerShort.End(); VRage.Profiler.ProfilerShort.Begin("Thrusters"); MyEntityThrustComponent thrustComp; if (CubeGrid.Components.TryGet(out thrustComp)) { thrustComp.UpdateBeforeSimulation(Sync.IsServer || CubeGrid.GridSystems.ControlSystem.IsLocallyControlled); } VRage.Profiler.ProfilerShort.End(); // Only update gyros if there are gyros in the system if (GyroSystem.GyroCount > 0) { ProfilerShort.Begin("Gyros"); GyroSystem.UpdateBeforeSimulation(); ProfilerShort.End(); } if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT) { ProfilerShort.Begin("Wheels"); WheelSystem.UpdateBeforeSimulation(); ProfilerShort.End(); } /*ProfilerShort.Begin("Conveyors"); * ConveyorSystem.UpdateBeforeSimulation(); * ProfilerShort.End();*/ ProfilerShort.Begin("Cameras"); CameraSystem.UpdateBeforeSimulation(); ProfilerShort.End(); if (MySession.Static.Settings.EnableOxygen && MySession.Static.Settings.EnableOxygenPressurization) { ProfilerShort.Begin("Oxygen"); GasSystem.UpdateBeforeSimulation(); ProfilerShort.End(); } if (MyPerGameSettings.EnableJumpDrive) { ProfilerShort.Begin("Jump"); JumpSystem.UpdateBeforeSimulation(); ProfilerShort.End(); } ProfilerShort.Begin("Ship sounds"); if (ShipSoundComponent != null) { ShipSoundComponent.Update(); } ProfilerShort.End(); UpdatePower(); }
public VTS__Resi_Main_Media_Room_SelectMethods(ControlSystem ControlSystem, Panel Panel) { this.ControlSystem = ControlSystem; this.Panel = Panel; }
public GameStateMachine( IGameplaySystem gameplayProxy, UserInterfaceSystem ui, ControlSystem control, StageSystem stage, BallSystem ball, KeysSystem keys, GameCurrencySystem currencies, MonetizationSystem monetization) : base() { // Iterate through all states and link UI (and other capable systems) to every state events. var allStates = (GameState[])System.Enum.GetValues(typeof(GameState)); foreach (var state in allStates) { AddCallbackOnEnter(state, () => ui.OnEnterState(state)); } // Define gameplay initialization callbacks. System.Action initFirstSubstageAction = stage.CreateFirstSubstage; System.Action initCurrentSubstageAction = stage.CreateCurrentSubstage; initFirstSubstageAction += ball.SpawnFirstBall; initCurrentSubstageAction += ball.SpawnFirstBall; // Link gameplay initialization systems to the correct callbacks. AddCallbackOnEnter(GameState.StartScreen, initFirstSubstageAction); AddCallbackOnEnter(GameState.PreStage, initFirstSubstageAction); AddCallbackOnEnter(GameState.Gameplay, control.Reset); AddCallbackOnTransition(GameState.NoMoreBalls, GameState.Gameplay, initCurrentSubstageAction); AddCallbackOnTransition(GameState.GetExtraBall, GameState.Gameplay, ball.SpawnFirstBall); AddCallbackOnTransition(GameState.NextSubstage, GameState.Gameplay, initCurrentSubstageAction); // Link currency gain system to the correct callbacks. AddCallbackOnEnter(GameState.StageFinished, () => { int coinsAmount = monetization.GetCoinsForVictory(); currencies.SetBuffer(GameCurrency.Coins, coinsAmount); ball.SpawnBallsInCollector(coinsAmount); }); AddCallbackOnExit(GameState.BallsSold, () => { currencies.AddFromBuffer(GameCurrency.Coins); ball.ClearCollector(); }); // Link resolutions to the "instant pass" states. AddCallbackOnEnter(GameState.GetExtraBall, () => Advance(GameState.Gameplay)); AddCallbackOnEnter(GameState.NextSubstage, () => { bool didPassLastSubstage; stage.PassCurrentSubstage(out didPassLastSubstage); if (didPassLastSubstage) { Advance(GameState.StageFinished); } else { Advance(GameState.Gameplay); } }); AddCallbackOnEnter(GameState.Chests, () => { if (!keys.IsEnough(3)) { Advance(GameState.PreStage); } }); AddCallbackOnExit(GameState.Chests, () => { if (keys.IsEnough(3)) { keys.Spend(3); } }); AddCallbackOnEnter(GameState.PreStage, () => Advance(GameState.Gameplay)); // Link gameplay proxy to the gameplay state callbacks. AddCallbackOnEnter(GameState.Gameplay, gameplayProxy.OnGameplayStarted); AddCallbackOnExit(GameState.Gameplay, gameplayProxy.OnGameplayStopped); // Link the state machine operations to UI (and other capable systems). ui.RegisterAdvanceToStateAction(Advance); control.AddCallbackOnBeginPull(() => Advance(GameState.Gameplay)); stage.SetSubstageFailedAction(() => Advance(GameState.NoMoreBalls)); stage.SetNextSubstageAction(() => Advance(GameState.NextSubstage)); monetization.SetAdvanceToStateCallbackForVideoRewardButton(rewardType => { switch (rewardType) { case VideoRewardType.ExtraBall: Advance(GameState.GetExtraBall); break; case VideoRewardType.SellBalls: Advance(GameState.BallsSold); break; } }); // Register every possible transition. AddTransition(GameState.StartScreen, GameState.Gameplay); AddTransition(GameState.StartScreen, GameState.BallShop); AddTransition(GameState.BallShop, GameState.StartScreen); AddTransition(GameState.Gameplay, GameState.NoMoreBalls); AddTransition(GameState.Gameplay, GameState.NextSubstage); AddTransition(GameState.NoMoreBalls, GameState.GetExtraBall); AddTransition(GameState.NoMoreBalls, GameState.Gameplay); AddTransition(GameState.GetExtraBall, GameState.Gameplay); AddTransition(GameState.NextSubstage, GameState.Gameplay); AddTransition(GameState.NextSubstage, GameState.StageFinished); AddTransition(GameState.StageFinished, GameState.BallsSold); AddTransition(GameState.BallsSold, GameState.Chests); AddTransition(GameState.Chests, GameState.PreStage); AddTransition(GameState.PreStage, GameState.Gameplay); // Finally, enter the initial state... Enter(GameState.StartScreen); }
public virtual void SetLastRecommendedControlSystem(ControlSystem controlSystem, UserForAuditing userForAuditing) { LastRecommendedControlSystem = controlSystem; SetLastModifiedDetails(userForAuditing); }
public void ExtractParameters_NoParameters_Extracts() { var result = ControlSystem.ExtractParameters("InventoryMenu"); result.Should().Be(null); }
public void LoadSettings() { List<ConfigNode> flightGUISettings = FARSettingsScenarioModule.FlightGUISettings; ConfigNode node = null; for (int i = 0; i < flightGUISettings.Count; i++) if (flightGUISettings[i].name == "StabilityAugmentationSettings") { node = flightGUISettings[i]; break; } if (systemTemplates == null) { systemTemplates = new ControlSystem[5]; for (int i = 0; i < systemTemplates.Length; i++) systemTemplates[i] = new ControlSystem(); if (node != null) { for (int i = 0; i < systemTemplates.Length; i++) { string nodeName = "ControlSys" + i; if (node.HasNode(nodeName)) TryLoadSystem(node.GetNode(nodeName), i); } if (node.HasValue("aoALowLim")) double.TryParse(node.GetValue("aoALowLim"), out aoALowLim); if (node.HasValue("aoAHighLim")) double.TryParse(node.GetValue("aoAHighLim"), out aoAHighLim); if (node.HasValue("scalingDynPres")) double.TryParse(node.GetValue("scalingDynPres"), out scalingDynPres); } else { BuildDefaultSystems(); } } }
public BigDmSwitcher(ControlSystem controlSystem, SwitcherConfig switcherConfig) { ControlSystem = controlSystem; var assembly = Assembly.Load(typeof(BladeSwitch).AssemblyName()); #if DEBUG CrestronConsole.PrintLine("DMSwitcher - Creating instance of {0}", switcherConfig.FrameType); #endif try { var frameType = assembly.GetType(switcherConfig.FrameType).GetCType(); var frameCtor = frameType.GetConstructor(new CType[] { typeof(uint), typeof(CrestronControlSystem) }); Chassis = (Switch)frameCtor.Invoke(new object[] { switcherConfig.Id, controlSystem }); for (var i = 1U; i <= Chassis.NumberOfOutputs; i++) { _outInit[i] = false; } } catch (Exception e) { CloudLog.Error("Error loading DM Frame type"); throw e; } foreach (var bladeConfig in switcherConfig.InputBlades) { DmInputBlade blade = null; try { var bladeType = assembly.GetType(bladeConfig.Type).GetCType(); var ctor = bladeType.GetConstructor(new CType[] { typeof(uint), typeof(Switch) }); blade = (DmInputBlade)ctor.Invoke(new object[] { bladeConfig.Number, Chassis }); } catch (Exception e) { CloudLog.Error("Could not create DM Input Blade {0} with ID {1}, {2}", bladeConfig.Type, bladeConfig.Number, e.Message); } if (blade == null) { continue; } for (var bladeInput = 1U; bladeInput <= 8; bladeInput++) { var inputNumber = ((blade.Number - 1) * 8) + bladeInput; try { var inputConfig = switcherConfig.Inputs.FirstOrDefault(i => i.Number == inputNumber); if (inputConfig == null) { continue; } if (string.IsNullOrEmpty(inputConfig.EndpointType)) { continue; } var endpointType = assembly.GetType(inputConfig.EndpointType).GetCType(); var ctor = endpointType.GetConstructor(new CType[] { typeof(DMInput) }); var endpoint = (DMEndpointBase)ctor.Invoke(new object[] { blade.Inputs[bladeInput] }); endpoint.Description = inputConfig.Name; } catch (Exception e) { CloudLog.Error("Could not create DM Input {0}, {1}", inputNumber, e.Message); } } } foreach (var bladeConfig in switcherConfig.OutputBlades) { DmOutputBlade blade = null; try { var bladeType = assembly.GetType(bladeConfig.Type).GetCType(); var ctor = bladeType.GetConstructor(new CType[] { typeof(uint), typeof(Switch) }); blade = (DmOutputBlade)ctor.Invoke(new object[] { bladeConfig.Number, Chassis }); } catch (Exception e) { CloudLog.Error("Could not create DM Output Blade {0} with ID {1}, {2}", bladeConfig.Type, bladeConfig.Number, e.Message); } if (blade == null) { continue; } for (var bladeOutput = 1U; bladeOutput <= 8; bladeOutput++) { var outputNumber = ((blade.Number - 1) * 8) + bladeOutput; try { var outputConfig = switcherConfig.Outputs.FirstOrDefault(i => i.Number == outputNumber); if (outputConfig == null) { continue; } if (string.IsNullOrEmpty(outputConfig.EndpointType)) { continue; } var endpointType = assembly.GetType(outputConfig.EndpointType).GetCType(); var ctor = endpointType.GetConstructor(new CType[] { typeof(DMOutput) }); var endpoint = (DMEndpointBase)ctor.Invoke(new object[] { blade.Outputs[bladeOutput] }); endpoint.Description = outputConfig.Name; } catch (Exception e) { CloudLog.Error("Could not create DM Output {0}, {1}", outputNumber, e.Message); } } } Chassis.OnlineStatusChange += Chassis_OnlineStatusChange; Chassis.DMInputChange += OnDmInputChange; Chassis.DMOutputChange += OnDmOutputChange; try { var regResult = Chassis.Register(); if (regResult != eDeviceRegistrationUnRegistrationResponse.Success) { CloudLog.Error("Error registering DM Frame, result = {0}", regResult); } } catch (Exception e) { CloudLog.Error("Error trying to register DM Frame, {0}", e.Message); } try { foreach (var inputConfig in switcherConfig.Inputs) { if (inputConfig.Number == 0 || inputConfig.Number > Chassis.NumberOfInputs) { continue; } Chassis.Inputs[inputConfig.Number].Name.StringValue = inputConfig.Name; } foreach (var outputConfig in switcherConfig.Outputs) { if (outputConfig.Number == 0 || outputConfig.Number > Chassis.NumberOfOutputs) { continue; } Chassis.Outputs[outputConfig.Number].Name.StringValue = outputConfig.Name; } } catch (Exception e) { CloudLog.Error("Error setting names on DM switcher, {0}", e.Message); } }
public ControlSystem(ControlSystem sys) { this.active = sys.active; this.zeroPoint = sys.zeroPoint; this.kP = sys.kP; this.kD = sys.kD; this.kI = sys.kI; this.lastError = 0; this.errorIntegral = 0; }
public override void Start(Vector2 _pos, ControlSystem.Direction _dir) { switch (state) { case AttackState.Ready: //attacker.stunTimer += TimeSpan.FromMilliseconds(50); position = _pos; offset = _pos - attacker.GetPosition(); direction = _dir; state = AttackState.Charging; timeAlive = TimeSpan.Zero; chargeTime = TimeSpan.Zero; break; case AttackState.Charging: if (!attacker.isStunned) { state = AttackState.Firing; Sound.QueueEffect(EffectType.Crit); size = new Vector2(SizeFromCharge(), SizeFromCharge()); moveStrength = 10f; attackBody = BodyFactory.CreateRectangle(world, size.X / PPM, size.Y / PPM, 5, this); attackBody.Position = (attacker.GetPosition() + offset) / PPM; attackBody.CollisionCategories = Category.Cat3; attackBody.CollidesWith = Category.Cat2; attackBody.OnCollision += attackOnCollision; attackBody.OnSeparation += attackOnSeperation; attackBody.IsSensor = true; } break; case AttackState.Firing: break; default: break; } }
/// <summary> /// Initializes a new instance of <see cref="MissingTagInSystem"/> /// </summary> /// <param name="controlSystem"><see cref="System"/> the <see cref="Tag"/> is missing</param> /// <param name="tag"><see cref="Tag"/> that is missing</param> public MissingTagInSystem(ControlSystem controlSystem, Tag tag) : base($"Tag '{tag}' is missing in control system '{controlSystem}'") { }
public ControlSystemController(ControlSystem newControlSystem) { controlSystem = newControlSystem; controlSystem.NotifyBedsideAlarmRaised += NotifyUI; }
public Office(ControlSystem cs, string cfgFileName) : base(cs, cfgFileName) { }
public VTS__Shades_MainMethods(ControlSystem ControlSystem, Panel Panel) { this.ControlSystem = ControlSystem; this.Panel = Panel; }
public IterativeSimulator(ISystem system, IController controller) { ControlSystem = new ControlSystem(system, controller); SignalsGenerator = new SignalsGenerator(); }
/// <summary> /// The class constructor. /// </summary> /// <param name="controlSystem">The control system of the participant.</param> public Participant(GameObject controlSystem) { this.controlSystem = controlSystem.GetComponentRequired <ControlSystem>(); }
/// <inheritdoc/> public Dolittle.TimeSeries.Modules.TimeSeries GetTimeSeriesFor(ControlSystem controlSystem, Tag tag) { ThrowIfMissingSystem(controlSystem); ThrowIfTagIsMissingInSystem(controlSystem, tag); return(_timeSeriesMap[controlSystem][tag]); }
private void OnAutoPilotUpdate(FlightCtrlState state) { if (_vessel.srfSpeed < 5) { return; } ControlSystem sys = systemInstances[0]; //wing leveler if (sys.active) { double phi = info.rollAngle - sys.zeroPoint; if (sys.kP < 0) { phi += 180; if (phi > 180) { phi -= 360; } } else { phi = -phi; } phi *= -FARMathUtil.deg2rad; double output = ControlStateChange(sys, phi); if (Math.Abs(state.roll - state.rollTrim) < 0.01) { if (output > 1) { output = 1; } else if (output < -1) { output = -1; } state.roll = (float)output + state.rollTrim; } } else { sys.errorIntegral = 0; } sys = systemInstances[1]; if (sys.active) { double beta = -(info.sideslipAngle - sys.zeroPoint) * FARMathUtil.deg2rad; double output = ControlStateChange(sys, beta); if (Math.Abs(state.yaw - state.yawTrim) < 0.01) { if (output > 1) { output = 1; } else if (output < -1) { output = -1; } state.yaw = (float)output + state.yawTrim; } } else { sys.errorIntegral = 0; } sys = systemInstances[2]; if (sys.active) { double pitch = (info.aoA - sys.zeroPoint) * FARMathUtil.deg2rad; double output = ControlStateChange(sys, pitch); if (Math.Abs(state.pitch - state.pitchTrim) < 0.01) { if (output > 1) { output = 1; } else if (output < -1) { output = -1; } state.pitch = (float)output + state.pitchTrim; } } else { sys.errorIntegral = 0; } sys = systemInstances[3]; if (sys.active) { if (info.aoA > aoAHighLim) { state.pitch = (float)FARMathUtil.Clamp(ControlStateChange(sys, info.aoA - aoAHighLim), -1, 1) + state.pitchTrim; } else if (info.aoA < aoALowLim) { state.pitch = (float)FARMathUtil.Clamp(ControlStateChange(sys, info.aoA - aoALowLim), -1, 1) + state.pitchTrim; } } else { sys.errorIntegral = 0; } sys = systemInstances[4]; if (sys.active) { double scalingFactor = scalingDynPres / info.dynPres; if (scalingFactor > 1) { scalingFactor = 1; } state.pitch = state.pitchTrim + (state.pitch - state.pitchTrim) * (float)scalingFactor; state.yaw = state.yawTrim + (state.yaw - state.yawTrim) * (float)scalingFactor; state.roll = state.rollTrim + (state.roll - state.rollTrim) * (float)scalingFactor; } }
public SystemFacade() { m_controlSystem = new ControlSystem(); m_monitorSystem = new MonitorSystem(); m_navigationSystem = new NavigationSystem(); }
private double ControlStateChange(ControlSystem system, double error) { double state = 0; double dt = TimeWarp.fixedDeltaTime; double dError_dt = error - system.lastError; dError_dt /= dt; system.errorIntegral += error * dt; state -= system.kP * error + system.kD * dError_dt + system.kI * system.errorIntegral; system.lastError = error; return state; }
protected virtual void Move() { ControlSystem.Move(transform, speed); }
public void loadXML() { CS = XMLSerialization.DeserializeObject<ControlSystem>("system.xml"); // // TODO:: if settings already loaded, compare them and copy over instance + connection data of non-changes // Keep old settings in memory untill change is propagated, then overwrite with new settings // propagateSettingsChange(); }