Пример #1
0
        /// <summary>
        /// This function does the job. CyPhy2RF translation.
        /// </summary>
        private void WorkInMainTransaction()
        {
            this.result.Success = true;

            var config = (this.mainParameters.config as CyPhy2RF_Settings);
            RF.CodeGenerator.Mode mode = RF.CodeGenerator.Mode.DIRECTIVITY;
            if (config.doDirectivity != null)
            {
                Logger.WriteInfo("CyPhy2RF mode selected : directivity");
                mode = RF.CodeGenerator.Mode.DIRECTIVITY;
            }

            if (config.doSAR != null)
            {
                Logger.WriteInfo("CyPhy2RF mode selected : SAR");
                mode = RF.CodeGenerator.Mode.SAR;
            }

            // Elaborator
            var elaboratorSuccess = this.CallElaborator(
                this.mainParameters.Project,
                this.mainParameters.CurrentFCO,
                this.mainParameters.SelectedFCOs,
                this.mainParameters.StartModeParam);
            this.UpdateSuccess("Elaborator", elaboratorSuccess);

            bool successTranslation = true;
            try
            {
                Directory.CreateDirectory(OutputDirectory);

                // 1. Generate OpenEMS simulation model
                var rfCodeGenerator = new RF.CodeGenerator(this.mainParameters, mode, this.Logger);
                rfCodeGenerator.GenerateCode();
                successTranslation = true;

                // 2. Prepare batch file to be invoked by the job manager
                string cmdFileName = "run_dir_simulation.cmd";
                switch (mode)
                {
                    case RF.CodeGenerator.Mode.DIRECTIVITY:
                        cmdFileName = "run_dir_simulation.cmd";
                        File.WriteAllText(Path.Combine(OutputDirectory, cmdFileName), CyPhy2RF.Properties.Resources.run_dir_simulation);
                        break;
                    case RF.CodeGenerator.Mode.SAR:
                        cmdFileName = "run_sar_simulation.cmd";
                        File.WriteAllText(Path.Combine(OutputDirectory, cmdFileName), CyPhy2RF.Properties.Resources.run_sar_simulation);
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("Mode", "CyPhy2RF simulation mode not supported");
                }
                this.result.RunCommand = cmdFileName;
            }
            catch (ApplicationException ex)
            {
                Logger.WriteError(ex.Message);
                successTranslation = false;
            }
            catch (Exception ex)
            {
                Logger.WriteError(ex.Message);
                successTranslation = false;
            }
            this.UpdateSuccess("RF simulation translation", successTranslation);
        }
Пример #2
0
        /// <summary>
        /// This function does the job. CyPhy2RF translation.
        /// </summary>
        private void WorkInMainTransaction()
        {
            this.result.Success = true;

            var config = (this.mainParameters.config as CyPhy2RF_Settings);

            RF.CodeGenerator.Mode mode = RF.CodeGenerator.Mode.DIRECTIVITY;
            if (config.doDirectivity != null)
            {
                Logger.WriteInfo("CyPhy2RF mode selected : directivity");
                mode = RF.CodeGenerator.Mode.DIRECTIVITY;
            }

            if (config.doSAR != null)
            {
                Logger.WriteInfo("CyPhy2RF mode selected : SAR");
                mode = RF.CodeGenerator.Mode.SAR;
            }

            // Elaborator
            var elaboratorSuccess = this.CallElaborator(
                this.mainParameters.Project,
                this.mainParameters.CurrentFCO,
                this.mainParameters.SelectedFCOs,
                this.mainParameters.StartModeParam);

            this.UpdateSuccess("Elaborator", elaboratorSuccess);

            bool successTranslation = true;

            try
            {
                Directory.CreateDirectory(OutputDirectory);

                // 1. Generate OpenEMS simulation model
                var rfCodeGenerator = new RF.CodeGenerator(this.mainParameters, mode, this.Logger);
                rfCodeGenerator.GenerateCode();
                successTranslation = true;

                // 2. Prepare batch file to be invoked by the job manager
                string cmdFileName = "run_dir_simulation.cmd";
                switch (mode)
                {
                case RF.CodeGenerator.Mode.DIRECTIVITY:
                    cmdFileName = "run_dir_simulation.cmd";
                    File.WriteAllText(Path.Combine(OutputDirectory, cmdFileName), CyPhy2RF.Properties.Resources.run_dir_simulation);
                    break;

                case RF.CodeGenerator.Mode.SAR:
                    cmdFileName = "run_sar_simulation.cmd";
                    File.WriteAllText(Path.Combine(OutputDirectory, cmdFileName), CyPhy2RF.Properties.Resources.run_sar_simulation);
                    break;

                default:
                    throw new ArgumentOutOfRangeException("Mode", "CyPhy2RF simulation mode not supported");
                }
                this.result.RunCommand = cmdFileName;
            }
            catch (ApplicationException ex)
            {
                Logger.WriteError(ex.Message);
                successTranslation = false;
            }
            catch (Exception ex)
            {
                Logger.WriteError(ex.Message);
                successTranslation = false;
            }
            this.UpdateSuccess("RF simulation translation", successTranslation);
        }