Exemple #1
0
        static void Main(string[] args)
        {
            #region MyRegion

            AppParams.Add("port", SerialPort.GetPortNames().Last());
            AppParams.Add("interval", "300");

            foreach (string s in args)
            {
                var ss = s.Split('=');
                if (ss.Length == 2)
                {
                    if (AppParams.ContainsKey(ss[0]))
                    {
                        AppParams[ss[0]] = ss[1];
                    }
                }
            }

            #endregion

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
        public static void Test1()
        {
            AppParams appParams = AdConfigurer.GetAppParams();

            Console.WriteLine("UserID:" + appParams.userId);
            Console.WriteLine("StartTime:" + appParams.startTime);
        }
 public ActionResult Post([FromBody] string value)
 {
     _appParams = GetAppParams();
     try
     {
         var metaItMessage = JsonConvert.DeserializeObject <MetaItMessage>(value);
         if (_memoryCache.TryGetValue("MetaItMessages", out List <MetaItMessage> metaItMessages))
         {
             metaItMessages.Add(metaItMessage);
         }
         else
         {
             metaItMessages = new List <MetaItMessage>()
             {
                 metaItMessage
             };
         }
         _memoryCache.Set("MetaItMessages", metaItMessages);
         return(Ok("ok"));
     }
     catch
     {
         return(BadRequest("nok"));
     }
 }
Exemple #4
0
    public Task <Run> StartUSimRun(
        string runName,
        string sysParamId,
        string buildZipPath,
        AnimationCurve scaleFactorRange,
        int steps,
        int stepsPerJob,
        AppParams appParams)
    {
        UpdateProgress(0f, "");
        m_CancellationTokenSource = new CancellationTokenSource();
        var token = m_CancellationTokenSource.Token;

        var taskRun = API.UploadBuildAsync(runName, buildZipPath, cancellationTokenSource: m_CancellationTokenSource,
                                           progress: (progress) =>
        {
            UpdateProgress(progress * k_UploadProgressPercentage, "Uploading build");
        });

        var runTask = taskRun.ContinueWith((finishedTask) =>
        {
            if (finishedTask.IsCanceled)
            {
                return(null);
            }

            if (finishedTask.IsFaulted)
            {
                Debug.Log($"Upload failed. {finishedTask.Exception}");
                return(null);
            }

            Debug.Log($"Upload complete: build id {finishedTask.Result}");

            var appParamList = GenerateAppParamIds(runName, scaleFactorRange, steps, stepsPerJob, appParams, token);
            if (token.IsCancellationRequested)
            {
                return(null);
            }

            UpdateProgress(1f, "Starting run execution");
            var runDefinitionId = API.UploadRunDefinition(new RunDefinition
            {
                app_params   = appParamList.ToArray(),
                name         = runName,
                sys_param_id = sysParamId,
                build_id     = finishedTask.Result
            });
            var run = Run.CreateFromDefinitionId(runDefinitionId);
            run.Execute();
            m_CancellationTokenSource.Dispose();
            return(run);
        }, token);

        return(runTask);
    }
        public UWPMainPage()
        {
            InitializeComponent();
            PackageVersion version     = Package.Current.Id.Version;
            string         versionText = "" + version.Major + "." + version.Minor + "." + version.Revision + "." + version.Build;
            AppParams      appParams   = new AppParams(versionText, new ConstantValueProvider <StreamReader>(null));

            VisiPlacement.UWP.UWPTextMeasurer.Initialize();
            VisiPlacement.UWP.UWPButtonClicker.Initialize();
            LoadApplication(new ActRec.App(appParams));
        }
Exemple #6
0
        public void UpdateVisibilityMetric()
        {
            long newTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - startTime;

            if ((newTime - lastTime) > timeResolution)
            {
                lastTime = newTime;
                ao.Update();
                AppParams param = AdConfigurer.GetAppParams();
                InstanceParamsUpdateLog dtoObj = new InstanceParamsUpdateLog(param.userId, this.adUnitId, this.adServingId, this.instanceId, newTime, ao.CameraLA_X(), ao.CameraLA_Y(), ao.CameraLA_Z(), ao.CameraX(), ao.CameraY(), ao.CameraZ(), ao.AdObjectX(), ao.AdObjectY(), ao.AdObjectZ());
                AnalyticsManager.Push(dtoObj, AnalyticsManager.TYPE.VISIBILITY_METRIC, AnalyticsManager.PRIORITY.LOW);
            }
        }
        public void CommandLineBasicParsing()
        {
            string[] clParams = new string[] {
                "--LogLevel",
                "Debug",
                "--ConfigFile",
                "aSiteValue"
            };
            AppParams parms = new AppParams(clParams);

            Assert.That(parms.HasParam("LogLevel"));
            Assert.That(parms.HasParam("ConfigFile"));
            Assert.That(parms.P <string>("LogLevel").Equals("Debug"));
            Assert.That(parms.P <string>("ConfigFile").Equals("aSiteValue"));
        }
        /*************************************************************************
         *
         * Instnance handling methods
         *
         ************************************************************************/
        public ImageTextureAdInstance CreateInstance(String instanceId, IAdObject adObject)
        {
            if (ads.Count == 0)
            {
                return(null);
            }
            ImageTextureAdInstance instance = new ImageTextureAdInstance(instanceId, ads[adIndex], adObject);

            instances.Add(instance.GetInstanceId(), instance);
            adIndex = (adIndex + 1) % ads.Count;
            AppParams param = AdConfigurer.GetAppParams();

            AnalyticsManager.Push(new AdServedLog(param.userId, this.adUnitId, instance.GetAdServingId(), instanceId), AnalyticsManager.TYPE.AD_DISPLAYED, AnalyticsManager.PRIORITY.MEDIUM);
            return(instance);
        }
        internal new bool isParamTXT(AppParams myParams)
        {
            bool ret = false;

            if (myParams.Params != null)
            {
                foreach (var param in myParams.Params)
                {
                    if (isParamTXT(param.ParamKey))
                    {
                        ret = true;
                    }
                }
            }
            return(ret);
        }
Exemple #10
0
    void OnBeginRunButtonClicked()
    {
        var scaleFactorRange = m_ScaleFactorCurve.value;
        var steps            = m_StepsField.value;
        var stepsPerJob      = m_StepsPerJobField.value;
        var appParams        = new AppParams()
        {
            // NOTE: ScaleFactors intentionally not populated here because it varies by USim instance
            MaxFrames = m_MaxFramesField.value,
            MaxForegroundObjectsPerFrame = m_MaxForegroundObjectsPerFrame.value,
            BackgroundObjectDensity      = m_BackgroundObjectDensityField.value,
            NumBackgroundFillPasses      = m_NumBackgroundFillPassesField.value,
            ScalingMin               = m_ScalingMinField.value,
            ScalingSize              = m_ScalingSizeField.value,
            LightColorMin            = m_LightColorMinField.value,
            LightRotationMax         = m_LightRotationMaxField.value,
            BackgroundHueMaxOffset   = m_BackgroundHueMaxOffsetField.value,
            OccludingHueMaxOffset    = m_OccludingHueMaxOffsetField.value,
            NoiseStrengthMax         = m_NoiseStrengthMaxField.value,
            BlurKernelSizeMax        = m_BlurKernelSizeMaxField.value,
            BlurStandardDeviationMax = m_BlurStandardDeviationMaxField.value
        };

        // Build and zip
        bool buildSuccess;

        if (m_NameField.value == null)
        {
            m_NameField.value = "SynthDet";
        }

        buildSuccess = CreateLinuxBuildAndZip(m_NameField.value);

        if (buildSuccess && m_BuildZipPathField.value != null)
        {
            var runTask = StartUSimRun(
                m_NameField.value,
                m_SysParamPopup.value.id,
                m_BuildZipPathField.value,
                scaleFactorRange,
                steps,
                stepsPerJob,
                appParams);
            runTask?.ContinueWith(task => Debug.Log("USim run started. Execution ID " + task.Result.executionId));
            m_ExecuteTask = runTask;
        }
    }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            VisiPlacement.Android.AndroidTextMeasurer.Initialize();
            VisiPlacement.Android.AndroidButtonClicker.Initialize();

            PublicFileIo.setBasedir(Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "ActivityRecommender"));

            string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            AppParams parameters = new AppParams(version, new LogcatReader());

            LoadApplication(new App(parameters));

            Xamarin.Essentials.Platform.Init(this, bundle);
        }
        public void CommandLineBooleanWithoutValue()
        {
            string[] clParams = new string[] {
                "--LogLevel",
                "Debug",
                "--quiet",
                "true",
                "--verbose",
                "--ConfigFile",
                "aSiteValue"
            };
            AppParams parms = new AppParams(clParams);

            Assert.That(parms.HasParam("LogLevel"));
            Assert.That(parms.HasParam("ConfigFile"));
            Assert.That(parms.P <string>("LogLevel").Equals("Debug"));
            Assert.That(parms.P <string>("ConfigFile").Equals("aSiteValue"));
            Assert.That(parms.P <bool>("Verbose"));
        }
    public Task <Run> BuildAndStartUSimRun(
        string runName,
        string sysParamId,
        AnimationCurve scaleFactorRange,
        int steps,
        int stepsPerJob,
        AppParams appParams)
    {
        var token = m_CancellationTokenSource.Token;

        var buildSuccess = CreateLinuxBuildAndZip(m_NameField.value, out string buildZipPath);

        if (!buildSuccess)
        {
            return(null);
        }

        var taskRun = API.UploadBuildAsync(runName, buildZipPath, cancellationTokenSource: m_CancellationTokenSource,
                                           progress: (progress) =>
        {
            UpdateProgress(progress * k_UploadProgressPercentage, "Uploading build");
        });

        var runTask = taskRun.ContinueWith((finishedTask) =>
        {
            if (finishedTask.IsCanceled)
            {
                return(null);
            }

            if (finishedTask.IsFaulted)
            {
                Debug.Log($"Upload failed. {finishedTask.Exception}");
                return(null);
            }

            Debug.Log($"Upload complete: build id {finishedTask.Result}");

            return(ExecuteRun(runName, sysParamId, scaleFactorRange, steps, stepsPerJob, appParams, token, finishedTask.Result, k_UploadProgressPercentage));
        }, token);

        return(runTask);
    }
        public void CommandLineBooleanNegation()
        {
            string[] clParams = new string[] {
                "--LogLevel",
                "Debug",
                "--quiet",
                "true",
                "--noverbose",
                "--ConfigFile",
                "aSiteValue"
            };
            AppParams parms = new AppParams(clParams);

            Assert.That(parms.HasParam("LogLevel"));
            Assert.That(parms.HasParam("ConfigFile"));
            Assert.That(parms.P <string>(AppParams.P_LOGLEVEL).Equals("Debug"));
            Assert.That(parms.P <string>(AppParams.P_CONFIGFILE).Equals("aSiteValue"));
            Assert.That(parms.P <bool>(AppParams.P_QUIET));
            Assert.That(!parms.P <bool>(AppParams.P_VERBOSE));
        }
Exemple #15
0
        internal bool isParamTXT_andExecuteIfNeeded(AppParams myParams, ConsoleMgr myConsole)
        {
            bool ret = false;

            if (myParams.Params != null)
            {
                foreach (var param in myParams.Params)
                {
                    if (isParamTXT(param.ParamKey))
                    {
                        ExecuteAppCmd(myParams, myConsole);
                        ret = true;
                    }
                }
            }
            else
            {
                ExecuteAppCmd(myParams, myConsole);
                ret = true;
            }
            return(ret);
        }
Exemple #16
0
    protected void Initialize()
    {
        m_Rand            = new Random(2);
        m_CurriculumQuery = EntityManager.CreateEntityQuery(typeof(CurriculumState));

        const string globalInitParamsName      = "Management";
        var          globalInitParamsContainer = GameObject.Find(globalInitParamsName);

        if (globalInitParamsContainer == null)
        {
            Debug.Log($"Cannot find a {globalInitParamsName} object to init parameters from.");
            return;
        }

        var init = globalInitParamsContainer.GetComponent <ProjectInitialization>();

        m_AppParams = init.AppParameters;
        var perceptionCamera = init.PerceptionCamera;

        camera             = perceptionCamera.GetComponentInParent <Camera>();
        m_ForegroundCenter =
            camera.transform.position + m_CameraForward * ForegroundObjectPlacer.k_ForegroundLayerDistance;
        // Compute the bottom left corner of the view frustum
        // IMPORTANT: We're assuming the camera is facing along the positive z-axis
        container = new GameObject("BackgroundContainer");
        container.transform.SetPositionAndRotation(
            m_CameraForward * k_PlacementDistance + camera.transform.position,
            Quaternion.identity);
        var statics = EntityManager.GetComponentObject <PlacementStatics>(m_CurriculumQuery.GetSingletonEntity());

        objectCache = new GameObjectOneWayCache(container.transform, statics.BackgroundPrefabs);

        backgroundHueMaxOffset = init.AppParameters.BackgroundHueMaxOffset;
        initialized            = true;

        m_ScaleRangeMetric = DatasetCapture.RegisterMetricDefinition("background scale range", "The range of scale factors used to place background objects each frame", k_BackgroundScaleMetricId);
    }
        public ActionResult SaveSettings(List <ParamNameValue> ParamNameValues)
        {
            List <ParamNameValue> WrongParams = new List <ParamNameValue>();
            string GeneralSecretAdminUrlOld   = AppParams.GeneralSecretAdminUrl.Value;
            string AppApiSecretURL            = AppParams.AppApiSecretURL.Value;

            foreach (ParamNameValue Param in ParamNameValues)
            {
                if (Param.Name == null || Param.Name.Length == 0)
                {
                    continue;
                }

                Parameter Parameter = Parameters.GetBy(Param.Name);
                Parameter.MemberID = Profile.Member.MemberID;

                string oldValue = Parameter.Value;
                Param.Value = Param.Value == null ? "" : Param.Value;

                if (Parameter.Type == ParameterType.Bool)
                {
                    if (Param.Value.ToLower() == "true")
                    {
                        Param.Value = Parameter.Value = "true";
                    }
                    else
                    {
                        Param.Value = Parameter.Value = "false";
                    }
                }
                else if (Parameter.Type == ParameterType.SmallInteger || Parameter.Type == ParameterType.RadioInteger)
                {
                    long value  = -1;
                    bool result = long.TryParse(Param.Value, out value);
                    Parameter.Value = result ? Param.Value : Parameter.Value;

                    if (!result)
                    {
                        WrongParams.Add(Param);
                    }
                }
                else
                {
                    Parameter.Value = Param.Value;
                }

                if (oldValue != Param.Value)
                {
                    Parameter.Save();
                }

                if (AppParams.GeneralAuditEnabled.Value == "true" && Param.Value != oldValue)
                {
                    AuditEvent.AppEventSuccess(Profile.Member.Email, String.Format("Changed: {0} -> from \"{1}\" to \"{2}\"", Parameter.Name, oldValue, Parameter.Value));
                }
            }

            AppParams.RefreshAppParameters();
            List <ParamNameValue> ParamValues = new List <ParamNameValue>();
            List <Parameter>      Params      = Parameters.Get();

            ////////////////////////////////////////////
            // Change admin route
            ////////////////////////////////////////////
            bool   AdminRouteChaned  = false;
            string RelativeAdminPath = "{controller}/{action}/{id}";

            if (AppParams.GeneralSecretAdminUrl != null && AppParams.GeneralSecretAdminUrl.Value.Length > 0 && GeneralSecretAdminUrlOld != AppParams.GeneralSecretAdminUrl.Value)
            {
                RouteCollection routes = RouteTable.Routes;
                using (routes.GetWriteLock())
                {
                    RelativeAdminPath = Path.Combine(AppSession.Parameters.GeneralSecretAdminUrl.Value.Replace("/", "\\"), RelativeAdminPath.Replace("/", "\\")).Replace("\\", "/");

                    if (RelativeAdminPath[0] == '/')
                    {
                        RelativeAdminPath = RelativeAdminPath.Remove(0, 1);
                    }

                    Route route = (Route)routes["Admin-Secret-Path"];
                    route.Url = RelativeAdminPath;
                }

                // If admin route changed redirect admin to correct url
                AdminRouteChaned = true;
            }
            else if ((AppParams.GeneralSecretAdminUrl == null || AppParams.GeneralSecretAdminUrl.Value.Length == 0) && GeneralSecretAdminUrlOld != AppParams.GeneralSecretAdminUrl.Value)
            {
                RouteCollection routes = RouteTable.Routes;
                using (routes.GetReadLock())
                {
                    Route route = (Route)routes["Admin-Secret-Path"];
                    route.Url = "Admin/" + RelativeAdminPath;
                }

                AdminRouteChaned = true;
            }

            ////////////////////////////////////////////
            // Change API route
            ////////////////////////////////////////////
            bool   APIRouteChaned  = false;
            string RelativeAPIPath = "{action}/{id}";

            if (AppParams.AppApiSecretURL != null && AppParams.GeneralSecretAdminUrl.Value.Length > 0 && AppApiSecretURL != AppParams.AppApiSecretURL.Value)
            {
                RouteCollection routes = RouteTable.Routes;
                using (routes.GetWriteLock())
                {
                    RelativeAPIPath = Path.Combine(AppSession.Parameters.AppApiSecretURL.Value.Replace("/", "\\"), RelativeAPIPath.Replace("/", "\\")).Replace("\\", "/");

                    if (RelativeAdminPath[0] == '/')
                    {
                        RelativeAdminPath = RelativeAPIPath.Remove(0, 1);
                    }

                    Route route = (Route)routes["API-Secret-Path"];
                    route.Url = RelativeAPIPath;
                }

                // If API route changed redirect admin to correct url
                APIRouteChaned = true;
            }
            else if ((AppParams.AppApiSecretURL == null || AppParams.AppApiSecretURL.Value.Length == 0) && AppApiSecretURL != AppParams.AppApiSecretURL.Value)
            {
                RouteCollection routes = RouteTable.Routes;
                using (routes.GetReadLock())
                {
                    Route route = (Route)routes["API-Secret-Path"];
                    route.Url = "Admin/API/" + RelativeAPIPath;
                }

                APIRouteChaned = true;
            }


            foreach (Parameter Param in Params)
            {
                ParamValues.Add(new ParamNameValue {
                    Name = Param.Name, Value = Param.Value, Type = Param.Type.ToString()
                });
            }


            string             Message         = "";
            string             AdminUrlChanged = "";
            string             APIUrlChanged   = "";
            RequestResultModel _model          = new RequestResultModel();

            if (AdminRouteChaned)
            {
                AdminUrlChanged = String.Format("<br/><strong>Admin URL has been changed. Click <a href=\"{0}\">here</a> to redirect to actual admin URL.</strong>", Url.Action("", "Settings"));
            }

            if (APIRouteChaned)
            {
                string Path = (AppParams.AppApiSecretURL.Value.Length > 0 ? AppParams.AppApiSecretURL.Value : "Admin/API");
                APIUrlChanged = String.Format("<br/>API URL has been changed. Please update all API clients. Here is base url now: <strong>{0}</strong>", Path);
            }


            if (WrongParams.Count == 0)
            {
                _model.Title    = GetLabel("Account.Controller.Congrat");
                _model.InfoType = RequestResultInfoType.Success;
                _model.Message  = "Application settngs have been saved." + AdminUrlChanged + APIUrlChanged;
                Message         = this.RenderPartialView(@"_RequestResultDialogInLine", _model);
            }
            else
            {
                _model.Title    = GetLabel("Account.Controller.Warning");
                _model.InfoType = RequestResultInfoType.ErrorOrDanger;
                _model.Message  = "Some parametrs have not been saved. Please check." + AdminUrlChanged + APIUrlChanged;
                Message         = this.RenderPartialView(@"_RequestResultDialogInLine", _model);
            }



            return(Json(new
            {
                Message = Message,
                Settings = ParamValues,
            }, JsonRequestBehavior.AllowGet));
        }
Exemple #18
0
 public ReadUserControl(Icommand command, int imageLength, AppParams appParams)
 {
     InitializeComponent();
    void OnBeginRunButtonClicked()
    {
        var scaleFactorRange = m_ScaleFactorCurve.value;
        var steps            = m_StepsField.value;
        var stepsPerJob      = m_StepsPerJobField.value;
        var appParams        = new AppParams()
        {
            // NOTE: ScaleFactors intentionally not populated here because it varies by USim instance
            MaxFrames = m_MaxFramesField.value,
            MaxForegroundObjectsPerFrame = m_MaxForegroundObjectsPerFrame.value,
            BackgroundObjectDensity      = m_BackgroundObjectDensityField.value,
            NumBackgroundFillPasses      = m_NumBackgroundFillPassesField.value,
            ScalingMin                         = m_ScalingMinField.value,
            ScalingSize                        = m_ScalingSizeField.value,
            LightColorMin                      = m_LightColorMinField.value,
            LightRotationMax                   = m_LightRotationMaxField.value,
            BackgroundHueMaxOffset             = m_BackgroundHueMaxOffsetField.value,
            OccludingHueMaxOffset              = m_OccludingHueMaxOffsetField.value,
            BackgroundObjectInForegroundChance = m_BackgroundInForegroundChanceField.value,
            NoiseStrengthMax                   = m_NoiseStrengthMaxField.value,
            BlurKernelSizeMax                  = m_BlurKernelSizeMaxField.value,
            BlurStandardDeviationMax           = m_BlurStandardDeviationMaxField.value
        };

        // Build and zip
        if (m_NameField.value == null)
        {
            m_NameField.value = "SynthDet";
        }

        Task <Run> runTask;

        UpdateProgress(0f, "");
        m_CancellationTokenSource = new CancellationTokenSource();

        if (m_UseExistingBuildToggle.value)
        {
            if (string.IsNullOrWhiteSpace(m_ExistingBuildId.value))
            {
                Debug.LogError("Build ID is not valid");
                return;
            }
            runTask = new Task <Run>(() =>
                                     ExecuteRun(m_NameField.value,
                                                m_SysParamPopup.value.id,
                                                scaleFactorRange,
                                                steps,
                                                stepsPerJob,
                                                appParams,
                                                m_CancellationTokenSource.Token,
                                                m_ExistingBuildId.value,
                                                0f));
            runTask.Start();
        }
        else
        {
            runTask = BuildAndStartUSimRun(
                m_NameField.value,
                m_SysParamPopup.value.id,
                scaleFactorRange,
                steps,
                stepsPerJob,
                appParams);
        }

        runTask?.ContinueWith(task => Debug.Log("USim run started. Execution ID " + task.Result.executionId));
        m_ExecuteTask = runTask;
    }
Exemple #20
0
    List <AppParam> GenerateAppParamIds(string runName, AnimationCurve scaleFactorRange, int steps, int stepsPerJob, AppParams appParams, CancellationToken token)
    {
        float        stepSize     = 1f / (steps + 1);
        float        time         = 0f;
        int          stepsThisJob = 0;
        int          jobIndex     = 0;
        List <float> scaleFactors = new List <float>(stepsPerJob);
        var          appParamIds  = new List <AppParam>();

        for (int i = 0; i < steps; i++)
        {
            var scaleFactor = scaleFactorRange.Evaluate(time);
            scaleFactors.Add(scaleFactor);
            stepsThisJob++;
            if (stepsThisJob == stepsPerJob)
            {
                stepsThisJob = 0;
                var appParamName = $"{runName}_{jobIndex}";

                UpdateProgress(k_UploadProgressPercentage + (1 - k_UploadProgressPercentage) * jobIndex / steps, $"Uploading app param {appParamName}");
                if (token.IsCancellationRequested)
                {
                    return(null);
                }

                appParams.ScaleFactors = scaleFactors.ToArray();
                var appParamId = API.UploadAppParam(appParamName, appParams);
                appParamIds.Add(new AppParam()
                {
                    id            = appParamId,
                    name          = appParamName,
                    num_instances = 1
                });
                jobIndex++;
                scaleFactors.Clear();
            }

            time += stepSize;
        }

        return(appParamIds);
    }
    Run ExecuteRun(string runName, string sysParamId, AnimationCurve scaleFactorRange, int steps, int stepsPerJob, AppParams appParams, CancellationToken token, string buildId, float progressThusFar)
    {
        var appParamList = GenerateAppParamIds(runName, scaleFactorRange, steps, stepsPerJob, appParams, token, progressThusFar);

        if (appParamList == null || token.IsCancellationRequested)
        {
            Debug.Log($"Operation canceled");
            return(null);
        }

        UpdateProgress(1f, "Starting run execution");
        var runDefinitionId = API.UploadRunDefinition(new RunDefinition
        {
            app_params   = appParamList.ToArray(),
            name         = runName,
            sys_param_id = sysParamId,
            build_id     = buildId
        });
        var run = Run.CreateFromDefinitionId(runDefinitionId);

        run.Execute();
        m_CancellationTokenSource.Dispose();
        return(run);
    }
Exemple #22
0
    void Start()
    {
        m_ResourceDirectoriesEntity = World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntity(typeof(ResourceDirectories));
        World.DefaultGameObjectInjectionWorld.EntityManager.SetComponentData(m_ResourceDirectoriesEntity, new ResourceDirectories
        {
            ForegroundResourcePath = ForegroundObjectResourcesDirectory,
            BackgroundResourcePath = BackgroundObjectResourcesDirectory
        });
        var foregroundObjects = Resources.LoadAll <GameObject>(ForegroundObjectResourcesDirectory);
        var backgroundObjects = Resources.LoadAll <GameObject>(BackgroundObjectResourcesDirectory);
        var backgroundImages  = Resources.LoadAll <Texture2D>(BackgroundImageResourcesDirectory);

        if (foregroundObjects.Length == 0)
        {
            Debug.LogError($"No Prefabs of FBX files found in foreground object directory \"{ForegroundObjectResourcesDirectory}\".");
            return;
        }
        if (backgroundObjects.Length == 0)
        {
            Debug.LogError($"No Prefabs of FBX files found in background object directory \"{BackgroundObjectResourcesDirectory}\".");
            return;
        }
        //TODO: Fill in CurriculumState from app params
        if (TryGetAppParamPathFromCommandLine(out string appParamPath))
        {
            var AppParamsJson = File.ReadAllText(appParamPath);
            AppParameters = JsonUtility.FromJson <AppParams>(AppParamsJson);
        }
        else if (!String.IsNullOrEmpty(Configuration.Instance.SimulationConfig.app_param_uri))
        {
            AppParameters = Configuration.Instance.GetAppParams <AppParams>();
        }

        Debug.Log($"{nameof(ProjectInitialization)}: Starting up. MaxFrames: {AppParameters.MaxFrames}, " +
                  $"scale factors {{{string.Join(", ", AppParameters.ScaleFactors)}}}");

        m_PlacementStatics = new PlacementStatics(
            AppParameters.MaxFrames,
            AppParameters.MaxForegroundObjectsPerFrame,
            AppParameters.ScalingMin,
            AppParameters.ScalingSize,
            AppParameters.OccludingHueMaxOffset,
            foregroundObjects,
            backgroundObjects,
            backgroundImages,
            ObjectPlacementUtilities.GenerateInPlaneRotationCurriculum(Allocator.Persistent),
            ObjectPlacementUtilities.GenerateOutOfPlaneRotationCurriculum(Allocator.Persistent),
            new NativeArray <float>(AppParameters.ScaleFactors, Allocator.Persistent));
        var appParamsMetricDefinition = SimulationManager.RegisterMetricDefinition(
            "app-params", description: "The values from the app-params used in the simulation. Only triggered once per simulation.", id: k_AppParamsMetricGuid);

        SimulationManager.ReportMetric(appParamsMetricDefinition, new[] { AppParameters });
        m_CurriculumStateEntity = World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntity();
        World.DefaultGameObjectInjectionWorld.EntityManager.AddComponentData(
            m_CurriculumStateEntity, new CurriculumState());
        World.DefaultGameObjectInjectionWorld.EntityManager.AddComponentObject(
            m_CurriculumStateEntity, m_PlacementStatics);

        ValidateForegroundLabeling(foregroundObjects, PerceptionCamera);

#if !UNITY_EDITOR
        if (Debug.isDebugBuild && EnableProfileLog)
        {
            Debug.Log($"Enabling profile capture");
            m_ProfileLogPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "profileLog.raw");
            if (System.IO.File.Exists(m_ProfileLogPath))
            {
                System.IO.File.Delete(m_ProfileLogPath);
            }

            UnityEngine.Profiling.Profiler.logFile         = m_ProfileLogPath;
            UnityEngine.Profiling.Profiler.enabled         = true;
            UnityEngine.Profiling.Profiler.enableBinaryLog = true;
        }
#endif
        Manager.Instance.ShutdownNotification += CleanupState;

        //PerceptionCamera.renderedObjectInfosCalculated += OnRenderedObjectInfosCalculated;
    }
Exemple #23
0
 internal AppCmd_AppParams_ConsoleMgr_Param(AppParams myParams, ConsoleMgr myConsole)
 {
     this.myParams  = myParams;
     this.myConsole = myConsole;
 }
Exemple #24
0
 internal abstract void ExecuteAppCmd(AppParams myParams, ConsoleMgr myConsole);
Exemple #25
0
        public static bool isAllowedToRun(Type type, bool isDefaultSubApp, ref string[] args)
        {
            var myAttr_Cmd = new List <string>();

            foreach (var attr in Attribute.GetCustomAttributes(type))
            {
                myAttr_Cmd.Add(((dynamic)attr).Cmd);
            }
            if (myAttr_Cmd.Count != 1)
            {
                throw new NotImplementedException("myAttr_Cmd.Count != 1");
            }
            var myAttr_Cmd_Singular = myAttr_Cmd[0];

            bool enableSubApp;

            if (isDefaultSubApp)
            {
                enableSubApp = true;
            }
            else
            {
                enableSubApp = false;
                using (var tmpAppParams = new AppParams(args))
                {
                    if (tmpAppParams.ParamLess != null)
                    {
                        foreach (var paramTxt in tmpAppParams.ParamLess.ParamData)
                        {
                            if (paramTxt.Equals(myAttr_Cmd_Singular, StringComparison.OrdinalIgnoreCase))
                            {
                                var  args_asList  = new List <string>();
                                bool adjustedArgs = false;
                                for (var i = 0; i < args.Length; i++)
                                {
                                    if (!adjustedArgs && args[i].Equals(myAttr_Cmd_Singular, StringComparison.OrdinalIgnoreCase))
                                    {
                                        adjustedArgs = true;
                                    }
                                    else
                                    {
                                        args_asList.Add(args[i]);
                                    }
                                }
                                if (!adjustedArgs)
                                {
                                    Console.Error.WriteLine("Error during parsing of parameters");
                                }
                                else
                                {
                                    enableSubApp = true;
                                    args         = args_asList.ToArray();
                                }
                                break;
                            }
                        }
                    }
                }
            }
            return(enableSubApp);
        }