public void Execute(JSONNode args) { var api = ApiManager.Instance; var timeScale = args["time_scale"]; if (timeScale == null || timeScale.IsNull) { api.TimeScale = 1f; } else { api.TimeScale = timeScale.AsFloat; } SimulatorManager.SetTimeScale(api.TimeScale); var timeLimit = args["time_limit"].AsFloat; if (timeLimit != 0) { var frameLimit = (int)(timeLimit / Time.fixedDeltaTime); api.FrameLimit = api.CurrentFrame + frameLimit; } else { api.FrameLimit = 0; } SIM.LogAPI(SIM.API.SimulationRun, timeLimit.ToString()); }
public void SimulateCallsOrSms_SendSmsWithStatusFriends_ReturnTrue() { //arrange SimulateDTO simulateDTO = new SimulateDTO() { LineId = 1, SendTo = SimulateSendTo.Friends, IsSms = true }; Customer customer = _data.GetCustomerWithLinesAndPackage(); Line line = _data.GetLineWithPackageAndFriend(); List <Line> lines = _data.GetLines(1); _mock.Setup(s => s.Customer.GetActiveCustomerWithLines(It.IsAny <string>())) .Returns(customer); _mock.Setup(s => s.Line.GetLineWithPackageAndFriends(It.IsAny <int>())) .Returns(line); _mock.Setup(s => s.Line.GetAll()) .Returns(lines); _mock.Setup(s => s.Sms.Add(new Sms())); _manager = new SimulatorManager(_mock.Object); //act var res = _manager.SimulateCallsOrSms(simulateDTO); //assert Assert.AreEqual(true, res); }
public void OnRunCommand(Commands.Run run) { Debug.Assert(ClientState == State.Ready); ClientState = State.Running; SimulatorManager.SetTimeScale(1.0f); }
public void Execute(JSONNode args) { var api = ApiManager.Instance; var sim = SimulatorManager.Instance; var timeScale = args["time_scale"]; if (timeScale == null || timeScale.IsNull) { api.TimeScale = 1f; } else { api.TimeScale = timeScale.AsFloat; } SimulatorManager.SetTimeScale(api.TimeScale); var timeLimit = args["time_limit"].AsFloat; if (timeLimit != 0) { var frameLimit = (int)(timeLimit / Time.fixedDeltaTime); api.FrameLimit = api.CurrentFrame + frameLimit; } else { api.FrameLimit = 0; } sim.AnalysisManager.AnalysisInit(); }
public void Reset() { Events.Clear(); Agents.Clear(); AgentUID.Clear(); Sensors.Clear(); SensorUID.Clear(); Controllables.Clear(); ControllablesUID.Clear(); Collisions.Clear(); Waypoints.Clear(); StopLine.Clear(); LaneChange.Clear(); StopAllCoroutines(); var sim = SimulatorManager.Instance; sim.AgentManager.Reset(); sim.NPCManager.Reset(); sim.PedestrianManager.Reset(); sim.EnvironmentEffectsManager.Reset(); sim.MapManager.Reset(); sim.CurrentFrame = 0; sim.GTIDs = 0; sim.SignalIDs = 0; FrameLimit = 0; CurrentTime = 0.0; CurrentFrame = 0; SimulatorManager.SetTimeScale(0.0f); }
public AccountManagement(SimulatorManager manager) { InitializeComponent(); this.Manager = manager; this.OKBtn.Click += OKBtn_Click; }
public void OnLoadResultCommand(Commands.LoadResult res, NetPeer peer) { Debug.Assert(MasterState == State.Loading); var client = Clients.Find(c => c.Peer == peer); Debug.Assert(client != null); Debug.Assert(client.State == State.Loading); if (res.Success) { Debug.Log("Client loaded"); } else { // TODO: stop simulation / cancel loading for other clients Debug.LogError($"Client failed to load: ${res.ErrorMessage}"); // TODO: reset all other clients Debug.Log($"Failed to start '{Simulation.Name}' simulation"); // TODO: update simulation status in DB // simulation.Status = "Invalid"; // db.Update(simulation); // NotificationManager.SendNotification("simulation", SimulationResponse.Create(simulation), simulation.Owner); Loader.ResetLoaderScene(); Clients.Clear(); return; } client.State = State.Ready; if (!Loader.Instance.PendingSimulation.ApiOnly.GetValueOrDefault()) { if (Clients.All(c => c.State == State.Ready)) { Debug.Log("All clients are ready. Resuming time."); var run = new Commands.Run(); foreach (var c in Clients) { Packets.Send(c.Peer, run, DeliveryMethod.ReliableOrdered); c.State = State.Running; } MasterState = State.Running; Loader.Instance.CurrentSimulation = Loader.Instance.PendingSimulation; Loader.Instance.PendingSimulation = null; SimulatorManager.SetTimeScale(1.0f); } } }
void OnDestroy() { if (Server != null) { Server.Stop(); Server = null; } Instance = null; SimulatorManager.SetTimeScale(1.0f); SIM.LogAPI(SIM.API.SimulationDestroy); SIM.APIOnly = false; }
void OnDestroy() { if (Server != null) { Server.Stop(); Server = null; } Instance = null; SimulatorManager.SetTimeScale(1.0f); Loader.Instance.Network.MessagesManager?.UnregisterObject(this); ApiLock.Deinitialize(); }
// ctor public SimulatorViewModel(IFrameNavigationService navigationService) { _navigationService = navigationService; _simulatorManager = new SimulatorManager(); SearchCommand = new RelayCommand(Search); SimulateCommand = new RelayCommand(Simulate); LineSelectedCommand = new RelayCommand(ChackIfPackageHasFriends); ClearCommand = new RelayCommand(Clear); GoBackCommand = new RelayCommand(() => { _navigationService.NavigateTo("Login"); ViewModelLocator.UnRegisterSimulatorViewModel(); }); }
void OnDestroy() { if (Server != null) { Server.Stop(); Server = null; } Instance = null; SimulatorManager.SetTimeScale(1.0f); SIM.LogAPI(SIM.API.SimulationDestroy); SIM.APIOnly = false; Loader.Instance.Network.MessagesManager?.UnregisterObject(this); }
//public KeyCode exitKey = KeyCode.Escape; // d depth camera //public KeyCode exitKey = KeyCode.Escape; // h k traffic //public KeyCode exitKey = KeyCode.Escape; // f1 help //public KeyCode exitKey = KeyCode.Escape; // f12 tweaks //public KeyCode exitKey = KeyCode.Escape; // f2 camerafollow ??? //public KeyCode exitKey = KeyCode.Escape; // vehicle inputs //public KeyCode exitKey = KeyCode.Escape; // left shift //public KeyCode exitKey = KeyCode.Escape; // m ros to video??? #endregion #region mono private void Awake() { if (_instance == null) { _instance = this; } if (_instance != this) { DestroyImmediate(gameObject); } else { DontDestroyOnLoad(gameObject); } }
public async Task Reset() { await SimulatorManager.Instance.AnalysisManager.AnalysisSave(); Events.Clear(); Agents.Clear(); AgentUID.Clear(); if (SimulatorManager.InstanceAvailable) { SimulatorManager.Instance.Sensors.ClearSensorsRegistry(); } AgentFollowingWaypoints.Clear(); Collisions.Clear(); Waypoints.Clear(); StopLine.Clear(); LaneChange.Clear(); Destinations.Clear(); StopAllCoroutines(); var sim = SimulatorManager.Instance; sim.AgentManager.Reset(); sim.NPCManager.Reset(); sim.PedestrianManager.Reset(); sim.EnvironmentEffectsManager.Reset(); sim.ControllableManager.Reset(); sim.MapManager.Reset(); sim.CameraManager.Reset(); sim.UIManager.Reset(); sim.CurrentFrame = 0; sim.GTIDs = 0; sim.SignalIDs = 0; FrameLimit = 0; CurrentTime = 0.0; CurrentFrame = 0; SimulatorManager.SetTimeScale(0.0f); Resources.UnloadUnusedAssets(); #if UNITY_EDITOR UnityEditor.EditorUtility.UnloadUnusedAssetsImmediate(); #endif }
public void Execute(JSONNode args) { var api = ApiManager.Instance; var timeScale = args["time_scale"]; if (timeScale == null || timeScale.IsNull) { api.TimeScale = 1f; } else { api.TimeScale = timeScale.AsFloat; } SimulatorManager.SetTimeScale(api.TimeScale); var timeLimit = args["time_limit"].AsFloat; if (timeLimit != 0) { var frameLimit = (int)(timeLimit / Time.fixedDeltaTime); api.FrameLimit = api.CurrentFrame + frameLimit; } else { api.FrameLimit = 0; } //Start the scenario runner here var use_case_id = args["use_case_id"].AsInt; var scenario_id = args["scenario_id"].AsInt; var test_case_id = args["test_case_id"].AsInt; //ArrayList results; SimulatorManager.Instance.Scenario_Config(use_case_id, scenario_id, test_case_id); // var results_json = new JSONArray(); // foreach(String result in results) // { // results_json.Add(new JSONString(result)); // } // api.SendResult(results_json); SIM.LogAPI(SIM.API.SimulationRun, timeLimit.ToString()); }
private void Awake() { if (_instance == null) { _instance = this; } if (_instance != this) { DestroyImmediate(gameObject); } var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); CurrentTime = (DateTime.UtcNow - unixEpoch).TotalSeconds; SessionStartTime = CurrentTime; RenderLimiter.RenderLimitDisabled(); }
public void Reset() { Events.Clear(); Agents.Clear(); AgentUID.Clear(); Sensors.Clear(); SensorUID.Clear(); Controllables.Clear(); ControllablesUID.Clear(); Collisions.Clear(); Waypoints.Clear(); StopLine.Clear(); LaneChange.Clear(); StopAllCoroutines(); var sim = SimulatorManager.Instance; sim.AgentManager.Reset(); sim.NPCManager.Reset(); sim.PedestrianManager.Reset(); sim.EnvironmentEffectsManager.Reset(); sim.ControllableManager.Reset(); sim.MapManager.Reset(); sim.CameraManager.Reset(); sim.UIManager.Reset(); sim.CurrentFrame = 0; sim.GTIDs = 0; sim.SignalIDs = 0; FrameLimit = 0; CurrentTime = 0.0; CurrentFrame = 0; SimulatorManager.SetTimeScale(0.0f); Resources.UnloadUnusedAssets(); #if UNITY_EDITOR UnityEditor.EditorUtility.UnloadUnusedAssetsImmediate(); #endif }
void FixedUpdate() { if (Events.Count != 0) { var events = new JSONArray(); for (int i = 0; i < Events.Count; i++) { events[i] = Events[i]; } Events.Clear(); var msg = new JSONObject(); msg["events"] = events; SendResult(msg); SimulatorManager.SetTimeScale(0.0f); return; } if (Time.timeScale != 0.0f) { if (FrameLimit != 0 && CurrentFrame >= FrameLimit) { SimulatorManager.SetTimeScale(0.0f); SendResult(); } else { CurrentTime += Time.fixedDeltaTime; CurrentFrame += 1; if (!CurrentScene.IsNullOrEmpty()) { SimulatorManager.Instance.PhysicsUpdate(); } } } }
//public KeyCode exitKey = KeyCode.Escape; //public KeyCode toggleUIKey = KeyCode.Space; //public KeyCode saveAgentPos = KeyCode.F5; //public KeyCode loadAgentPos = KeyCode.F9; //public KeyCode spawnObstacle = KeyCode.F10; //public KeyCode demo = KeyCode.F11; //public KeyCode exitKey = KeyCode.Escape; // d depth camera //public KeyCode exitKey = KeyCode.Escape; // h k traffic //public KeyCode exitKey = KeyCode.Escape; // f1 help //public KeyCode exitKey = KeyCode.Escape; // f12 tweaks //public KeyCode exitKey = KeyCode.Escape; // f2 camerafollow ??? //public KeyCode exitKey = KeyCode.Escape; // vehicle inputs //public KeyCode exitKey = KeyCode.Escape; // left shift //public KeyCode exitKey = KeyCode.Escape; // m ros to video??? #endregion #region mono private void Awake() { if (_instance == null) { _instance = this; } if (_instance != this) { DestroyImmediate(gameObject); } if (FindObjectOfType <AnalyticsManager>() == null) { new GameObject("GA").AddComponent <AnalyticsManager>(); } if (FindObjectOfType <ROSAgentManager>() == null) { Instantiate(rosAgentManager).GetComponent <ROSAgentManager>().isDevMode = true; } }
//public KeyCode exitKey = KeyCode.Escape; //public KeyCode toggleUIKey = KeyCode.Space; //public KeyCode saveAgentPos = KeyCode.F5; //public KeyCode loadAgentPos = KeyCode.F9; //public KeyCode spawnObstacle = KeyCode.F10; //public KeyCode demo = KeyCode.F11; //public KeyCode exitKey = KeyCode.Escape; // d depth camera //public KeyCode exitKey = KeyCode.Escape; // h k traffic //public KeyCode exitKey = KeyCode.Escape; // f1 help //public KeyCode exitKey = KeyCode.Escape; // f12 tweaks //public KeyCode exitKey = KeyCode.Escape; // f2 camerafollow ??? //public KeyCode exitKey = KeyCode.Escape; // vehicle inputs //public KeyCode exitKey = KeyCode.Escape; // left shift //public KeyCode exitKey = KeyCode.Escape; // m ros to video??? #endregion #region mono private void Awake() { if (_instance == null) { _instance = this; } if (_instance != this) { DestroyImmediate(gameObject); } if (FindObjectOfType <AnalyticsManager>() == null) { new GameObject("GA").AddComponent <AnalyticsManager>(); } if (FindObjectOfType <ROSAgentManager>() == null) { GameObject clone = GameObject.Instantiate(Resources.Load("Managers/ROSAgentManager", typeof(GameObject))) as GameObject; clone.GetComponent <ROSAgentManager>().currentMode = StartModeTypes.Dev; clone.name = "ROSAgentManager"; } }
// Start is called before the first frame update void Awake() { timer.Elapsed += Timer_Elapsed; timer.Start(); if (instance == null) { instance = this; } else if (instance != this) { Destroy(this); } string[] var = Environment.GetCommandLineArgs(); int x = Convert.ToInt32(Mathf.Floor(cube.transform.localScale.x / particle.transform.localScale.x)); int y = Convert.ToInt32(Mathf.Floor(1f / particle.transform.localScale.y)) + 1; int z = Convert.ToInt32(Mathf.Floor(cube.transform.localScale.z / particle.transform.localScale.z)); layers = new GameObject[y][][]; for (int j = 0; j < y; j++) { GameObject[][] layer = new GameObject[x][]; for (int i = 0; i < x; i++) { GameObject[] row = new GameObject[z]; for (int k = 0; k < z; k++) { row[k] = Instantiate(particle, new Vector3(particle.transform.localScale.x * i, particle.transform.localScale.y * j, particle.transform.localScale.z * k), Quaternion.identity); } layer[i] = row; } layers[j] = layer; } InitialCond(); }
//private void Update() //{ // if (Input.GetKeyDown(exitKey)) // { // } // if (Input.GetKeyDown(toggleUIKey)) // { // } // if (Input.GetKeyDown(saveAgentPos)) // { // } // if (Input.GetKeyDown(loadAgentPos)) // { // } // if (Input.GetKeyDown(spawnObstacle)) // { // } // if (Input.GetKeyDown(demo)) // { // } // //CheckStateErrors(); //} private void OnApplicationQuit() { _instance = null; DestroyImmediate(gameObject); }
/// <summary> /// Initializes the entire server /// </summary> private void Initialize() { for (int i = 0; i < 20; i++) { msgAvgQue.Enqueue(0); } var rand = new Random(3); // Logging Enabled Logger.Initialize(); _synchronizers = new List <ISynchronizer>(); //Load configs ConnectionManagerConfig connectionManagerConfig = new ConnectionManagerConfig(new CoreNetworkConfig()); GalacticProperties galacticProperties = new GalacticProperties(); _consoleManager = new ConsoleManager(); _projectileManager = new ProjectileManager(); ConsoleManager.WriteLine("Starting database...", ConsoleMessageType.Startup); _databaseManager = new MongoDatabaseManager(); ShipStatManager.ReadShipsFromDBSList(_databaseManager.GetStatsFromDBAsync().Result); ConsoleManager.WriteLine("Ship types loaded.", ConsoleMessageType.Startup); RedisConfig rc = new RedisConfig(); _redisServer = new RedisServer(LogRedisError, LogRedisInfo, rc.Address); var slaveId = SlaveServerConfigService.GetFreeSlaveID(_redisServer).Result; _slaveServerConfigService = new SlaveServerConfigService(_redisServer, slaveId); _masterServerManager = new MasterServerManager(new MasterServerConfig(), new GalacticProperties(), _databaseManager, _databaseManager, _redisServer, _slaveServerConfigService); _cargoSynchronizer = new CargoSynchronizer(); _synchronizers.Add(_cargoSynchronizer); connectionManagerConfig.MyConfig.Port = ConnectionManager.GetFreePort(28002, 28010); _connectionManager = new ConnectionManager(); _connectionManager.Initialize(connectionManagerConfig); //Poll to listen to Lidgren until it is ready //LidgrenMessagePoller_Init initializationPoller = new LidgrenMessagePoller_Init(_connectionManager.Server, this); //initializationPoller.Poll(); _galaxyIDManager = new LocalIDManager(_masterServerManager, IDTypes.GalaxyID); _teamIDManager = new LocalIDManager(_masterServerManager, IDTypes.TeamID); _accountIDManager = new LocalIDManager(_masterServerManager, IDTypes.AccountID); _transactionIDManager = new LocalIDManager(_masterServerManager, IDTypes.TransactionID); _accountManager = new AccountManager(_accountIDManager, _databaseManager); _messageManager = new MessageManager(_connectionManager); _clientUpdateManager = new ClientUpdateManager(_playerManager); _playerManager = new PlayerManager(_databaseManager, _connectionManager, _redisServer, _galaxyIDManager, _clientUpdateManager); var chatCommands = new List <IChatCommand>() { new HelpCommand(), new ShoutCommand(_redisServer), new RadioCommand(), new TellCommand(_playerManager) }; var asyncChatCommands = new List <IAsyncChatCommand>() { new AdminWarpCommand(_databaseManager, _redisServer, new Random()) }; _teamManager = new GlobalTeamManager(_teamIDManager, _connectionManager, _redisServer, _playerManager, _databaseManager); _galaxyManager = new GalaxyManager(galacticProperties.SolID, _teamManager); _chatManager = new ChatManager(chatCommands, asyncChatCommands, _playerManager, _messageManager, _redisServer); _warpManager = new WarpManager(_galaxyManager, _messageManager, _chatManager, _redisServer, _accountManager, _databaseManager); _shipManager = new ShipManager(_messageManager, _galaxyManager, _warpManager, _connectionManager, _databaseManager); _structureManager = new StructureManager(_databaseManager, _galaxyManager, _galaxyIDManager, _cargoSynchronizer); loginManager = new LoginManager(_accountManager, _playerManager, _connectionManager, _redisServer); // Todo: Convert everything over to ServerNetworkMessage to propogate full request context. _simulatorManager = new SimulatorManager(new SimulatorConfig(), _redisServer, (sender, container) => ProcessMessage(sender, new ServerNetworkMessage(container, null))); StructureStatManager.Initialize(); ConsoleManager.WriteLine("Completed Initialization", ConsoleMessageType.Startup); _economyManager = new EconomyManager(_transactionIDManager, _playerManager, _galaxyManager, _cargoSynchronizer, _shipManager, _databaseManager, _masterServerManager); _killManager = new KillManager(_cargoSynchronizer, _playerManager, _galaxyManager, _messageManager, _connectionManager, _warpManager, _chatManager, _economyManager); _collisionManager = new CollisionManager(_galaxyManager, _messageManager, _killManager, _projectileManager); _registrationManager = new GalaxyRegistrationManager(_galaxyManager, _shipManager, _collisionManager, _galaxyIDManager, _playerManager, _accountManager, _cargoSynchronizer, _structureManager); _warpManager.SetRegistrationManager(_registrationManager);//Gross, I know. _locatorService = new LocatorService(_registrationManager, _playerManager, _galaxyManager, _shipManager, _accountManager, _teamManager, _teamManager, _messageManager, _structureManager, _masterServerManager); _msMessageHandler = new MasterServerMessageHandler((int)_masterServerManager.SlaveID, _redisServer, _connectionManager, _locatorService, _accountManager, _accountIDManager, _databaseManager, _galaxyManager, _galaxyIDManager, _playerManager, _shipManager, _registrationManager, _teamIDManager, _messageManager, _teamManager, _warpManager, _transactionIDManager, ProcessRoutedMessage); StructureFactory.Initialize(_galaxyIDManager, _registrationManager); ColonyFactory.Initialize(_galaxyIDManager, _registrationManager); dbSyncer = new DBSyncer(_databaseManager, _galaxyManager, _shipManager, _playerManager, _accountManager, _structureManager); #if DEBUG _typesToExcludeIgnore.Add(MessageTypes.PositionUpdateData); _typesToExcludeIgnore.Add(MessageTypes.ShipFireRequest); _typesToExcludeIgnore.Add(MessageTypes.ProjectileCollisionReport); _typesToExcludeIgnore.Add(MessageTypes.StructureFireRequest); _typesToExcludeIgnore.Add(MessageTypes.ObjectPickupRequest); #endif }
public Control(SimulatorManager manager) { InitializeComponent(); this.Manager = manager; }
private void Awake() { sim = GetComponent <SimulatorManager>(); }
public void Execute(JSONNode args) { SimulatorManager.SetTimeScale(ApiManager.Instance.TimeScale); }
private void SimulatorForm_Load(object sender, EventArgs e) { computerInfoControl.Monitour(); SimulatorManager = new SimulatorManager(); SimulatorManager.OnSimulatorLog += SimulatorManager_OnSimulatorLog; }