Exemple #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.");
            }
        }
Exemple #2
0
        private void okButton_Click(object sender, EventArgs e)
        {
            int newPort = Int32.Parse(portTextBox.Text);

            ServerOptions.PortNumber = newPort;
            ServerOptions.WriteFile();
            this.DialogResult = DialogResult.OK;
        }
Exemple #3
0
        public Form1()
        {
            string errorMsg = string.Empty;
            int    seats    = -1;

            if (Environment.GetCommandLineArgs().Length > 1)
            {
                ServerOptions.ReadFile();
                String portString = Environment.GetCommandLineArgs()[1];
                ServerOptions.PortNumber = Int32.Parse(portString);
                ServerOptions.WriteFile();
            }
            else
            {
                ServerConfigDialog d = new ServerConfigDialog();
                d.DialogMessage = "Configure the server port:";
                if (d.ShowDialog(this) == DialogResult.Cancel)
                {
                    MessageBox.Show(this, "Closing DDD", "User Requested Shutdown", MessageBoxButtons.OK);
                    this.Close();
                    return;
                }
                while (!SimCoreServer.SimCoreServer.CheckNetworkSettings())
                {
                    d.DialogMessage = "The specified port is not available.\nPlease shutdown any other application\nusing the port or choose a different one.";
                    d.ShowDialog(this);
                }
            }
            InitializeComponent();
            server = new SimCoreServer.SimCoreServer();
            LoadServerOptions();



            eventClient = new SimulationEventDistributorClient();
            SimCoreServer.SimCoreServer.simEngine.simCore.distributor.RegisterClient(ref eventClient);
            eventClient.Subscribe("ServerState");
            eventClient.Subscribe("PauseScenario");
            eventClient.Subscribe("ResumeScenario");
            serverState = "SCENARIO_STOPPED";

            comboBoxReplaySpeed.SelectedIndex     = 4;
            comboBoxReplaySpeed.Enabled           = false;
            toolStripStatusLabelServerStatus.Text = "Server: STOPPED";
            toolStripStatusLabelSimStatus.Text    = "Simulation: STOPPED";



            DMInfo = new DMInfoManager(this);


            UpdateScenarioNameLabel();
            updateTimer.Start();
            UpdateVoiceServerButton();
        }
Exemple #4
0
        private void eventLogPathButton_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                eventLogTextBox.Text            = fbd.SelectedPath;
                ServerOptions.EventLogDirectory = eventLogTextBox.Text;
                ServerOptions.WriteFile();
            }
        }
Exemple #5
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!forceFormClose)
            {     //force form close will override the user's choice
                if (DialogResult.Yes == (MessageBox.Show("Server is currently running, are you sure that you want to exit?", "Warning", MessageBoxButtons.YesNo)))
                { //force server shutdown
                    server.StopServer();
                }
                else
                {//do not quit
                    e.Cancel = true;
                }
            }
            else
            {
                server.StopServer();
            }

            ServerOptions.WriteFile();
        }
Exemple #6
0
        private void buttonScenario_Click(object sender, EventArgs e)
        {
            string         OFDXMLFilter = "XML File(*.xml)|*.xml";
            OpenFileDialog ofd          = new OpenFileDialog();

            ofd.Filter = OFDXMLFilter;

            if (File.Exists(textBoxScenario.Text))
            {
                ofd.FileName = textBoxScenario.Text;
            }
            else
            {
                ofd.InitialDirectory = Form1.ApplicationPath;
            }
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                textBoxScenario.Text = ofd.FileName;
                ServerOptions.DefaultScenarioPath = textBoxScenario.Text;
                ServerOptions.WriteFile();
            }
            UpdateScenarioNameLabel();
        }