private void ProcessCommandSendClusterEvent(Configuration Config, List <ClusterEvent> Events)
        {
            if (!File.Exists(SelectedConfig))
            {
                AppLogger.Log("No config file found: " + SelectedConfig);
                return;
            }

            EntityClusterNode MasterNode = Config.GetMasterNode();

            if (MasterNode == null)
            {
                AppLogger.Log("Master node not found");
                return;
            }

            if (Events == null || Events.Count == 0)
            {
                AppLogger.Log("Nothing to send");
                return;
            }

            foreach (ClusterEvent Event in Events)
            {
                SendClusterCommand(MasterNode.Addr, MasterNode.PortCE, Event.JsonData);
            }
        }
Beispiel #2
0
        // Config file parser
        public static Configuration Parse(string filePath)
        {
            Configuration ParsedConfig = new Configuration();

            try
            {
                foreach (string DirtyLine in File.ReadLines(filePath))
                {
                    string Line = PreprocessConfigLine(DirtyLine);

                    if (string.IsNullOrEmpty(Line) || Line.First() == '#')
                    {
                        //Do nothing
                    }
                    else
                    {
                        if (Line.ToLower().StartsWith("[cluster_node]"))
                        {
                            EntityClusterNode ClusterNode = new EntityClusterNode(Line);
                            if (!string.IsNullOrEmpty(ClusterNode.Id))
                            {
                                ParsedConfig.ClusterNodes.Add(ClusterNode.Id, ClusterNode);
                            }
                        }
                        if (Line.ToLower().StartsWith("[window]"))
                        {
                            EntityWindow Window = new EntityWindow(Line);
                            if (!string.IsNullOrEmpty(Window.Id))
                            {
                                ParsedConfig.Windows.Add(Window.Id, Window);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AppLogger.Log("ERROR! " + ex.Message);
                return(null);
            }

            return(ParsedConfig);
        }
        private string GenerateStartCommand(EntityClusterNode Node, Configuration Config)
        {
            string commandCmd     = string.Empty;
            string Application    = SelectedApplication;
            string ExtraAppParams = string.Empty;

            // Start command at first
            commandCmd = CommandStartApp;

            // Get file(s)
            List <string> Params = SplitAppLineParameters(SelectedApplication);

            foreach (string Param in Params)
            {
                commandCmd = string.Format("{0} {1}", commandCmd, Param);
            }

            // Custom common arguments
            if (!string.IsNullOrWhiteSpace(CustomCommonParams))
            {
                commandCmd = string.Format("{0} {1}", commandCmd, CustomCommonParams.Trim());
            }
            // Mandatory arguments
            commandCmd = string.Format("{0} {1}", commandCmd, ArgMandatory);
            // Config file
            commandCmd = string.Format("{0} {1}=\"{2}\"", commandCmd, ArgConfig, SelectedConfig);
            // Render API and mode
            commandCmd = string.Format("{0} {1} {2}", commandCmd, SelectedRenderApiParam.Value, SelectedRenderModeParam.Value);

            // No texture streaming
            if (IsNotextureStreaming)
            {
                commandCmd = string.Format("{0} {1}", commandCmd, ArgNoTextureStreaming);
            }
            // Use all available cores
            if (IsUseAllCores)
            {
                commandCmd = string.Format("{0} {1}", commandCmd, ArgUseAllAvailableCores);
            }

            // Set custom GPU selection policy
            if (Node.GPU != int.MinValue)
            {
                commandCmd = string.Format("{0} {1}={2}", commandCmd, ArgGpu, Node.GPU);
            }

            if (!Config.Windows.ContainsKey(Node.Window))
            {
                throw new Exception(string.Format("Node {0} has no windows property specified", Node.Id));
            }

            // Get window settings for the node
            EntityWindow Window = Config.Windows[Node.Window];

            // Fullscreen/windowed
            commandCmd = string.Format("{0} {1}", commandCmd, Window.IsFullscreen ? ArgFullscreen : ArgWindowed);

            // If windowed, we need to add -ForceRes parameter
            if (!Window.IsFullscreen)
            {
                commandCmd = string.Format("{0} {1}", commandCmd, ArgForceRes);
            }

            // Window location and size
            if (Window.ResX > 0 && Window.ResY > 0)
            {
                commandCmd = string.Format("{0} {1} {2} {3} {4}",
                                           commandCmd,
                                           string.Format("WinX={0}", Window.WinX),
                                           string.Format("WinY={0}", Window.WinY),
                                           string.Format("ResX={0}", Window.ResX),
                                           string.Format("ResY={0}", Window.ResY));
            }

            // Node ID
            commandCmd = string.Format("{0} {1}={2}", commandCmd, ArgNode, Node.Id);

            // additional launch arguments
            commandCmd = string.Format("{0} {1}", commandCmd, "-noxrstereo -messaging -concertisheadless");

            // Log file
            commandCmd = string.Format("{0} Log={1}.log", commandCmd, Node.Id);

            // Logging verbosity
            if (IsCustomLogsUsed)
            {
                string LogCmds = string.Format(
                    "LogDisplayClusterPlugin {0}, " +
                    "LogDisplayClusterEngine {1}, " +
                    "LogDisplayClusterConfig {2}, " +
                    "LogDisplayClusterCluster {3}, " +
                    "LogDisplayClusterGame {4}, " +
                    "LogDisplayClusterGameMode {5}, " +
                    "LogDisplayClusterInput {6}, " +
                    "LogDisplayClusterInputVRPN {7}, " +
                    "LogDisplayClusterNetwork {8}, " +
                    "LogDisplayClusterNetworkMsg {9}, " +
                    "LogDisplayClusterRender {10}, " +
                    "LogDisplayClusterRenderSync {11}, " +
                    "LogDisplayClusterBlueprint {12}"
                    , SelectedVerbocityPlugin
                    , SelectedVerbocityEngine
                    , SelectedVerbocityConfig
                    , SelectedVerbocityCluster
                    , SelectedVerbocityGame
                    , SelectedVerbocityGameMode
                    , SelectedVerbocityInput
                    , SelectedVerbocityVrpn
                    , SelectedVerbocityNetwork
                    , SelectedVerbocityNetworkMsg
                    , SelectedVerbocityRender
                    , SelectedVerbocityRenderSync
                    , SelectedVerbocityBlueprint);

                commandCmd = string.Format("{0} -LogCmds=\"{1}\"", commandCmd, LogCmds);
            }

            // Custom ExecCmds
            string CleanCustomCommonExecCmds = CustomCommonExecCmds.Trim();

            if (!string.IsNullOrEmpty(CleanCustomCommonExecCmds))
            {
                commandCmd = string.Format("{0} -ExecCmds=\"{1}\"", commandCmd, CleanCustomCommonExecCmds);
            }

            return(commandCmd);
        }
        private string GenerateStartCommand(EntityClusterNode Node, Configuration Config)
        {
            string commandCmd = string.Empty;

            // Executable
            commandCmd = string.Format("{0} \"{1}\"", CommandStartApp, SelectedApplication);
            // Custom common arguments
            if (!string.IsNullOrWhiteSpace(CustomCommonParams))
            {
                commandCmd = string.Format("{0} {1}", commandCmd, CustomCommonParams.Trim());
            }
            // Mandatory arguments
            commandCmd = string.Format("{0} {1}", commandCmd, ArgMandatory);
            // Config file
            commandCmd = string.Format("{0} {1}=\"{2}\"", commandCmd, ArgConfig, SelectedConfig);
            // Render API and mode
            commandCmd = string.Format("{0} {1} {2}", commandCmd, SelectedRenderApiParam.Value, SelectedRenderModeParam.Value);

            // No texture streaming
            if (IsNotextureStreaming)
            {
                commandCmd = string.Format("{0} {1}", commandCmd, ArgNoTextureStreaming);
            }
            // Use all available cores
            if (IsUseAllCores)
            {
                commandCmd = string.Format("{0} {1}", commandCmd, ArgUseAllAvailableCores);
            }

            if (!Config.Windows.ContainsKey(Node.Window))
            {
                throw new Exception("Node {0} has no windows property specified");
            }

            // Get window settings for the node
            EntityWindow Window = Config.Windows[Node.Window];

            // Fullscreen/windowed
            commandCmd = string.Format("{0} {1}", commandCmd, Window.IsFullscreen ? ArgFullscreen : ArgWindowed);

            // Window location and size
            if (Window.ResX > 0 && Window.ResY > 0)
            {
                commandCmd = string.Format("{0} {1} {2} {3} {4}",
                                           commandCmd,
                                           string.Format("WinX={0}", Window.WinX),
                                           string.Format("WinY={0}", Window.WinY),
                                           string.Format("ResX={0}", Window.ResX),
                                           string.Format("ResY={0}", Window.ResY));
            }

            // Node ID
            commandCmd = string.Format("{0} {1}={2}", commandCmd, ArgNode, Node.Id);

            // Log file
            commandCmd = string.Format("{0} Log={1}.log", commandCmd, Node.Id);

            // Logging verbosity
            if (IsCustomLogsUsed)
            {
                string LogCmds = string.Format(
                    "LogDisplayClusterPlugin {0}, " +
                    "LogDisplayClusterEngine {1}, " +
                    "LogDisplayClusterConfig {2}, " +
                    "LogDisplayClusterCluster {3}, " +
                    "LogDisplayClusterGame {4}, " +
                    "LogDisplayClusterGameMode {5}, " +
                    "LogDisplayClusterInput {6}, " +
                    "LogDisplayClusterInputVRPN {7}, " +
                    "LogDisplayClusterNetwork {8}, " +
                    "LogDisplayClusterNetworkMsg {9}, " +
                    "LogDisplayClusterRender {10}, " +
                    "LogDisplayClusterBlueprint {11}"
                    , SelectedVerbocityPlugin
                    , SelectedVerbocityEngine
                    , SelectedVerbocityConfig
                    , SelectedVerbocityCluster
                    , SelectedVerbocityGame
                    , SelectedVerbocityGameMode
                    , SelectedVerbocityInput
                    , SelectedVerbocityVrpn
                    , SelectedVerbocityNetwork
                    , SelectedVerbocityNetworkMsg
                    , SelectedVerbocityRender
                    , SelectedVerbocityBlueprint);

                commandCmd = string.Format("{0} -LogCmds=\"{1}\"", commandCmd, LogCmds);
            }

            // Custom ExecCmds
            string CleanCustomCommonExecCmds = CustomCommonExecCmds.Trim();

            if (!string.IsNullOrEmpty(CleanCustomCommonExecCmds))
            {
                commandCmd = string.Format("{0} -ExecCmds=\"{1}\"", commandCmd, CleanCustomCommonExecCmds);
            }

            return(commandCmd);
        }