private HotFixClient() { "log".Log("Application will run almost in hot fix client.."); mCommonUpdaters = new CommonUpdaters(); mStateMapper = new KeyValueList <IState, IUpdate>(); mFSMMapper = new KeyValueList <IStateMachine, IUpdate>(); Modulars = new DecorativeModulars(); Configs = new ConfigHelper(); Datas = new DataWarehouse(); FSMs = new StateMachines { FSMFrameUpdater = OnFSMFrameUpdater, StateFrameUpdater = OnStateFrameUpdater, }; Sounds = new SoundEffects(); Sounds.Init(); #region 对主工程框架中热更端需要覆盖的各功能单元做重填充,以使得相同功能的代码定义转移到热更端 Framework framework = Framework.Instance; framework.ReloadUnit(new IFrameworkUnit[] { framework.CreateUnitByBridge(Framework.UNIT_MODULARS, Modulars), framework.CreateUnitByBridge(Framework.UNIT_CONFIG, Configs), framework.CreateUnitByBridge(Framework.UNIT_DATA, Datas), framework.CreateUnitByBridge(Framework.UNIT_FSM, FSMs), framework.CreateUnitByBridge(Framework.UNIT_SOUND, Sounds), }); #endregion }
public void LoadNewSM(StateMachines selectedMachine) { StopAllCoroutines(); switch (selectedMachine) { case StateMachines.BlitzFlank: ConfigureBlitzFlank(); break; case StateMachines.Patrol: ConfigurePatrol(); break; case StateMachines.FrontCover: ConfigureFrontCover(); break; case StateMachines.BackCover: ConfigureBackCover(); break; case StateMachines.CautiousApproach: ConfigureCautiousAttack(); break; case StateMachines.SquadApproach: ConfigureSquadLeader(); break; default: ConfigureAttack(); break; } }
void LoadNewAISM(AIController ai, StateMachines s) { if (ai != null) { ai.stateMachine.LoadNewSM(s); } }
private void NewStateMachine() { try { var textEditService = new TextEditService(); string initialName = StateMachines .Select(sm => sm.Name) .CreateUniqueName("State Machine {0}"); textEditService.EditText(initialName, "State Machine Name", "Create State Machine", name => { var model = new StateMachine() { Name = name, Actions = new StateMachineOutputAction[] { }, Inputs = new StateMachineInput[] { } }; var viewService = ApplicationContainer.Container.Resolve <IViewService>(); var viewModel = new StateMachineReferenceViewModel(model, viewService, DirtyService, _messageBoxService); StateMachines.Add(viewModel); _dirtyService.MarkDirty(); }); } catch (Exception ex) { _messageBoxService.Show(ex); } }
public static void AddStateOnce(PedHandle ped, State state) { if (!StateMachines.HasState(ped, state.GetType())) { StateMachines.Add(ped, new State.Machine(state)); } }
public void Start(int ticks) { Tester.Instance.Log(TesterBaseApp.LOG, IsStarted, "warning: ShipDockApplication has started"); if (IsStarted) { return; } Notificater = new Notifications <int>(); ABs = new AssetBundles(); Servers = new Servers(OnServersInit); Datas = new DataWarehouse(); AssetsPooling = new AssetsPooling(); StateMachines = new StateMachines { FSMFrameUpdater = OnFSMFrameUpdater, StateFrameUpdater = OnStateFrameUpdater }; mFSMUpdaters = new KeyValueList <IStateMachine, IUpdate>(); mStateUpdaters = new KeyValueList <IState, IUpdate>(); if (ticks > 0) { TicksUpdater = new TicksUpdater(ticks); } ShipDockConsts.NOTICE_APPLICATION_STARTUP.Broadcast(); IsStarted = true; mAppStarted?.Invoke(); mAppStarted = null; }
public StateMachineProxyFactory(StateMachines stateMachines, StateMachineConversations conversations, InstanceId me, LogProvider logProvider) { this._stateMachines = stateMachines; this._conversations = conversations; this._me = me; this._log = logProvider.getLog(this.GetType()); }
public virtual void VerifyConfigurations(string description) { Logger.Logger.fine("Verify configurations"); IList <URI> members = null; IDictionary <string, InstanceId> roles = null; ISet <InstanceId> failed = null; IList <AssertionError> errors = new LinkedList <AssertionError>(); IList <TestProtocolServer> protocolServers = Network.Servers; for (int j = 0; j < protocolServers.Count; j++) { StateMachines stateMachines = protocolServers[j].Server.StateMachines; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.cluster.statemachine.State<?, ?> clusterState = stateMachines.getStateMachine(ClusterMessage.class).getState(); State <object, ?> clusterState = stateMachines.GetStateMachine(typeof(ClusterMessage)).State; if (!clusterState.Equals(ClusterState.Entered)) { Logger.Logger.fine("Instance " + (j + 1) + " is not in the cluster (" + clusterState + ")"); continue; } ClusterContext context = ( ClusterContext )stateMachines.GetStateMachine(typeof(ClusterMessage)).Context; HeartbeatContext heartbeatContext = ( HeartbeatContext )stateMachines.GetStateMachine(typeof(HeartbeatMessage)).Context; ClusterConfiguration clusterConfiguration = context.Configuration; if (clusterConfiguration.MemberURIs.Count > 0) { Logger.Logger.fine(" Server " + (j + 1) + ": Cluster:" + clusterConfiguration.MemberURIs + ", Roles:" + clusterConfiguration.Roles + ", Failed:" + heartbeatContext.Failed); if (members == null) { members = clusterConfiguration.MemberURIs; roles = clusterConfiguration.Roles; failed = heartbeatContext.Failed; } else { VerifyConfigurations(stateMachines, members, roles, failed, errors); } } } assertEquals(description + ": In:" + In + ", Out:" + Out, protocolServers.Count, Iterables.count(Iterables.flatten(In, Out))); if (errors.Count > 0) { foreach (AssertionError error in errors) { Logger.Logger.severe(error.ToString()); } throw errors[0]; } }
public virtual void VerifyConfigurations(VerifyInstanceConfiguration[] toCheckAgainst) { Logger.Logger.fine("Verify configurations against given"); IList <URI> members; IDictionary <string, InstanceId> roles; ISet <InstanceId> failed; IList <AssertionError> errors = new LinkedList <AssertionError>(); IList <TestProtocolServer> protocolServers = Network.Servers; assertEquals("You must provide a configuration for all instances", protocolServers.Count, toCheckAgainst.Length); for (int j = 0; j < protocolServers.Count; j++) { members = toCheckAgainst[j].Members; roles = toCheckAgainst[j].Roles; failed = toCheckAgainst[j].Failed; StateMachines stateMachines = protocolServers[j].Server.StateMachines; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.cluster.statemachine.State<?, ?> clusterState = stateMachines.getStateMachine(ClusterMessage.class).getState(); State <object, ?> clusterState = stateMachines.GetStateMachine(typeof(ClusterMessage)).State; if (!clusterState.Equals(ClusterState.Entered)) { Logger.Logger.warning("Instance " + (j + 1) + " is not in the cluster (" + clusterState + ")"); continue; } ClusterContext context = ( ClusterContext )stateMachines.GetStateMachine(typeof(ClusterMessage)).Context; HeartbeatContext heartbeatContext = ( HeartbeatContext )stateMachines.GetStateMachine(typeof(HeartbeatMessage)).Context; ClusterConfiguration clusterConfiguration = context.Configuration; if (clusterConfiguration.MemberURIs.Count > 0) { Logger.Logger.fine(" Server " + (j + 1) + ": Cluster:" + clusterConfiguration.MemberURIs + ", Roles:" + clusterConfiguration.Roles + ", Failed:" + heartbeatContext.Failed); VerifyConfigurations(stateMachines, members, roles, failed, errors); } } // assertEquals( "In:" + in + ", Out:" + out, protocolServers.size(), Iterables.count( Iterables.<Cluster, // List<Cluster>>flatten( in, out ) ) ); if (errors.Count > 0) { foreach (AssertionError error in errors) { Logger.Logger.severe(error.ToString()); } throw errors[0]; } }
public virtual void DumpDiagnostics(StringBuilder appendTo) { StateMachines stateMachines = _protocolServer.StateMachines; foreach (StateMachine stateMachine in stateMachines.GetStateMachines()) { appendTo.Append(" ").Append(stateMachine.MessageType.SimpleName).Append(":").Append(stateMachine.State.ToString()).Append("\n"); } appendTo.Append("Current timeouts:\n"); foreach (KeyValuePair <object, Timeouts.Timeout> objectTimeoutEntry in stateMachines.Timeouts.Timeouts.SetOfKeyValuePairs()) { appendTo.Append(objectTimeoutEntry.Key.ToString()).Append(":").Append(objectTimeoutEntry.Value.TimeoutMessage.ToString()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogFirstHeartbeatAfterTimeout() public virtual void ShouldLogFirstHeartbeatAfterTimeout() { // given InstanceId instanceId = new InstanceId(1); InstanceId otherInstance = new InstanceId(2); ClusterConfiguration configuration = new ClusterConfiguration("whatever", NullLogProvider.Instance, "cluster://1", "cluster://2"); configuration.Members[otherInstance] = URI.create("cluster://2"); AssertableLogProvider internalLog = new AssertableLogProvider(true); TimeoutStrategy timeoutStrategy = mock(typeof(TimeoutStrategy)); Timeouts timeouts = new Timeouts(timeoutStrategy); Config config = mock(typeof(Config)); when(config.Get(ClusterSettings.max_acceptors)).thenReturn(10); MultiPaxosContext context = new MultiPaxosContext(instanceId, iterable(new ElectionRole("coordinator")), configuration, mock(typeof(Executor)), internalLog, mock(typeof(ObjectInputStreamFactory)), mock(typeof(ObjectOutputStreamFactory)), mock(typeof(AcceptorInstanceStore)), timeouts, mock(typeof(ElectionCredentialsProvider)), config); StateMachines stateMachines = new StateMachines(internalLog, mock(typeof(StateMachines.Monitor)), mock(typeof(MessageSource)), mock(typeof(MessageSender)), timeouts, mock(typeof(DelayedDirectExecutor)), ThreadStart.run, instanceId); stateMachines.AddStateMachine(new StateMachine(context.HeartbeatContext, typeof(HeartbeatMessage), HeartbeatState.Start, internalLog)); timeouts.Tick(0); when(timeoutStrategy.TimeoutFor(any(typeof(Message)))).thenReturn(5L); // when stateMachines.Process(Message.@internal(HeartbeatMessage.Join)); stateMachines.Process(Message.@internal(HeartbeatMessage.IAmAlive, new HeartbeatMessage.IAmAliveState(otherInstance)).setHeader(Message.HEADER_CREATED_BY, otherInstance.ToString())); for (int i = 1; i <= 15; i++) { timeouts.Tick(i); } // then verify(timeoutStrategy, times(3)).timeoutTriggered(argThat(new MessageArgumentMatcher <>() .onMessageType(HeartbeatMessage.TimedOut))); internalLog.AssertExactly(inLog(typeof(HeartbeatState)).debug("Received timed out for server 2"), inLog(typeof(HeartbeatContext)).info("1(me) is now suspecting 2"), inLog(typeof(HeartbeatState)).debug("Received timed out for server 2"), inLog(typeof(HeartbeatState)).debug("Received timed out for server 2")); internalLog.Clear(); // when stateMachines.Process(Message.@internal(HeartbeatMessage.IAmAlive, new HeartbeatMessage.IAmAliveState(otherInstance)).setHeader(Message.HEADER_CREATED_BY, otherInstance.ToString())); // then internalLog.AssertExactly(inLog(typeof(HeartbeatState)).debug("Received i_am_alive[2] after missing 3 (15ms)")); }
/// <summary> /// Updates this unified structure to become the merge of all the structures in MergedStructures /// </summary> private void ApplyUpdates() { Elements.Clear(); Procedures.Clear(); StateMachines.Clear(); Rules.Clear(); foreach (Structure merged in MergedStructures) { CombineWithUpdate(merged); } // Indicates to all the merged structure that this is their Unified Structure foreach (Structure structure in MergedStructures) { structure.ResetUnifiedStructure(this); } }
private void VerifyConfigurations(StateMachines stateMachines, IList <URI> members, IDictionary <string, InstanceId> roles, ISet <InstanceId> failed, IList <AssertionError> errors) { ClusterContext context = ( ClusterContext )stateMachines.GetStateMachine(typeof(ClusterMessage)).Context; int myId = context.MyId.toIntegerIndex(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.cluster.statemachine.State<?, ?> clusterState = stateMachines.getStateMachine(ClusterMessage.class).getState(); State <object, ?> clusterState = stateMachines.GetStateMachine(typeof(ClusterMessage)).State; if (!clusterState.Equals(ClusterState.Entered)) { Logger.Logger.warning("Instance " + myId + " is not in the cluster (" + clusterState + ")"); return; } HeartbeatContext heartbeatContext = ( HeartbeatContext )stateMachines.GetStateMachine(typeof(HeartbeatMessage)).Context; ClusterConfiguration clusterConfiguration = context.Configuration; try { assertEquals("Config for server" + myId + " is wrong", new HashSet <>(members), new HashSet <>(clusterConfiguration.MemberURIs) ); } catch (AssertionError e) { errors.Add(e); } try { assertEquals("Roles for server" + myId + " is wrong", roles, clusterConfiguration.Roles); } catch (AssertionError e) { errors.Add(e); } try { assertEquals("Failed for server" + myId + " is wrong", failed, heartbeatContext.Failed); } catch (AssertionError e) { errors.Add(e); } }
public ProjectViewModel(StateMachineProject project, IMarkDirty dirtyService, IMessageBoxService messageBoxService) { _project = project; _dirtyService = dirtyService; _messageBoxService = messageBoxService ?? throw new ArgumentNullException(nameof(messageBoxService)); if (_project.StateMachines != null) { StateMachines.AddRange(_project.StateMachines .Select(sm => ApplicationContainer.Container.Resolve <StateMachineReferenceViewModel>( new TypedParameter(typeof(StateMachine), sm), new TypedParameter(typeof(IDirtyService), _dirtyService) ))); } _generationOptions = new GenerationOptionsViewModel(project.GenerationOptions, dirtyService, _messageBoxService); NewStateMachineCommand = new RelayCommand(NewStateMachine); DeleteStateMachineCommand = new RelayCommand(DeleteStateMachine, CanDeleteStateMachine); GenerateCommand = new RelayCommand <string>((s) => GenerateWithNoDebug(s), (s) => CanGenerate(s)); GenerateAndDebugCommand = new RelayCommand <string>((s) => GenerateAndDebug(s), (s) => CanGenerate(s)); }
public static void RemoveState(PedHandle ped, Type stateType) => StateMachines.RemoveState(ped, stateType);
public static bool HasState(PedHandle ped, Type stateType) => StateMachines.HasState(ped, stateType);
public static void SetState(PedHandle ped, params State[] states) => StateMachines.Set(ped, new State.Machine(states));
private bool CanGenerate(string projectPath) { return(StateMachines.Any() && !string.IsNullOrWhiteSpace(projectPath)); }
public static void AddState(PedHandle ped, params State[] states) => StateMachines.Add(ped, new State.Machine(states));
public StateMachineProject GetModel() { _project.StateMachines = StateMachines.Select(vm => vm.GetModel()).ToArray(); _project.GenerationOptions = GenerationOptions.GetModel(); return(_project); }