Ejemplo n.º 1
0
        private void LoadScenario(string logType, DateTime time, string groupName, string replayFile)
        {
            ServerOptions.WriteFile();
            serverState = ServerState.RUNNING;

            string scenarioTitle = ServerOptions.DefaultScenarioPath.Remove(ServerOptions.DefaultScenarioPath.LastIndexOf('.'));

            scenarioTitle = scenarioTitle.Remove(0, scenarioTitle.LastIndexOf('\\') + 1);
            debugFile     = String.Format("{0}\\Debug\\DDDDebugLog-{1}.{2}.{3:yyyyMMddHHmmss}.txt", ServerOptions.EventLogDirectory, scenarioTitle, groupName, time);
            log           = String.Format("{0}\\DDDLog-{1}.{2}.{3:yyyyMMddHHmmss}.ddd", ServerOptions.EventLogDirectory, scenarioTitle, groupName, time);
            //TODO: Add back in later WriteClientAppConfig();
            SendServerStateEvent("LOADING_SCENARIO", scenarioTitle);
            if (System.IO.File.Exists(ServerOptions.SimulationModelPath))
            {
                switch (logType)
                {
                case "Limited":
                    //Begin Logging

                    simEngine.StartReplayLogger(Log, logType, productVersion, compileDate);
                    break;

                case "Detailed":
                    //Begin logging

                    simEngine.StartReplayLogger(Log, logType, productVersion, compileDate);
                    break;

                default:     //Don't log
                    break;
                }
                simEngine.StartTextChatServer();
                simEngine.StartWhiteboardServer();

                //  Start the voice server if it exists and is needed
                //    The conditions will be added later
                if (ServerOptions.EnableVoiceServer)
                {
                    HandshakeManager.SetVoiceEnabled(true);
                    HandshakeManager.SetVoiceServerName(ServerOptions.VoiceServerHostname);
                    HandshakeManager.SetVoiceServerPassword(ServerOptions.VoiceServerUserPassword);
                    HandshakeManager.SetVoiceServerPort(ServerOptions.VoiceServerPort);
                    simEngine.StartVoiceServer(ServerOptions.VoiceServerPort, ServerOptions.VoiceServerUserPassword,
                                               ServerOptions.VoiceServerAdminUsername, ServerOptions.VoiceServerAdminPassword, ServerOptions.EnableVoiceServerRecordings, time, false, 0.0);
                }
                else
                {
                    HandshakeManager.SetVoiceEnabled(false);
                    HandshakeManager.SetVoiceServerName(ServerOptions.VoiceServerHostname);
                    HandshakeManager.SetVoiceServerPassword(ServerOptions.VoiceServerUserPassword);
                    HandshakeManager.SetVoiceServerPort(ServerOptions.VoiceServerPort);
                }
                StartSimulationPaused(ServerOptions.ScenarioSchemaPath, ServerOptions.DefaultScenarioPath, replayFile);
            }
            else
            {
                throw new Exception("Error setting simulation model.");
            }
        }
Ejemplo n.º 2
0
        private void Start()
        {
            if (System.IO.File.Exists(simulationModelTextBox.Text))
            {
                simEngine.Initialize(simulationModelTextBox.Text, Int32.Parse(serverPortTextBox.Text));
                simEngine.StartSimCore();
                hostnameTextBox.Text = simEngine.GetServerHostName();
                UpdateForm();
                bbClient = simEngine.GetBlackboardClient();



                SubscribeToObject("PhysicalObject");
                SubscribeToObject("DecisionMaker");
                SubscribeToObject("Team");
                SubscribeToObject("SensorNetwork");
                SubscribeToObject("LandRegion");
                SubscribeToObject("ScoringRegion");
                SubscribeToObject("ActiveRegion");


                simulationModelButton.Enabled  = false;
                simulationModelTextBox.Enabled = false;
                serverPortTextBox.Enabled      = false;

                //start logging thread
                if (checkBoxReplayLog.Checked)
                {
                    string logPath = "log.txt";
                    string logMode = "Detailed";
                    if (textBoxReplayLog.Text != "")
                    {
                        logPath = textBoxReplayLog.Text;
                    }
                    if (radioButtonLimited.Checked)
                    {
                        logMode = "Limited";
                    }

                    simEngine.StartReplayLogger(logPath, logMode, SimCoreServer.SimCoreServer.GetProductVersion(), SimCoreServer.SimCoreServer.GetCompileDate());
                }
                checkBoxReplayLog.Enabled = false;
                startReplayButton.Enabled = true;
            }
            else
            {
                MessageBox.Show("Must set simulation model file first");
            }
        }