Example #1
0
        /// <summary>
        /// Validates all properties
        /// </summary>
        public override void Validate()
        {
            base.Validate();
            CmvSettings.Validate();
            LiftBuildSettings?.Validate();

            if (Filter != null)
            {
                Filter.Validate();
            }

            if (OverrideStartUTC.HasValue || OverrideEndUTC.HasValue)
            {
                if (OverrideStartUTC.HasValue && OverrideEndUTC.HasValue)
                {
                    if (OverrideStartUTC.Value > OverrideEndUTC.Value)
                    {
                        throw new ServiceException(HttpStatusCode.BadRequest,
                                                   new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                               "Override startUTC must be earlier than override endUTC"));
                    }
                }
                else
                {
                    throw new ServiceException(HttpStatusCode.BadRequest,
                                               new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                           "If using an override date range both dates must be provided"));
                }
            }
        }
Example #2
0
    //public BrainParameters brain;
    //public AgentParameters agentParameters;


    void CreateAgents()
    {
        Debug.Log("CreateAgents called - CmvAgMan activating");
        var pp = new ParmProcessor();

#if UNITY_EDITOR
        pp.SetPreset("p1:par  p2:2.3  p3:3 p4:true p5:false p6");// for testing
#endif
        pp.Process();
        //pp.Dump();
        cmvSettings = GameObject.FindObjectOfType <CmvSettings>();
        area        = transform.parent.gameObject;
        ground      = area.transform.Find("Ground").gameObject;
        redGoal     = area.transform.Find("redGoal").gameObject;

        for (var i = 0; i < nagents; i++)
        {
            var agnum = i.ToString("D2");
            var aname = $"Agent-{agmanPrefix}-{agnum}";
            Debug.Log("Creating agent " + aname);
            var ago = new GameObject(aname);

            //dr.Awake();
            //ago.SetActive(false); // if we don't do this it gets enable events too soon (before we can init AgentParameters)
            ago.transform.parent = this.transform;
            var cmvag = ago.AddComponent <CmvAgent>();
            var dr    = ago.AddComponent <DecisionRequester>();
            dr.DecisionPeriod = 6;
            dr.TakeActionsBetweenDecisions = true;

            cmvag.rayPer = ago.AddComponent <RayPerceptionSensorComponent3D>();
            cmvag.rayPer.detectableTags = new List <string>()
            {
                "redGoal", "agent", "wall", "wall", "wall"
            };
            cmvag.rayPer.raysPerDirection = 2;// rays to the left or right
            cmvag.rayPer.CreateSensor();

            cmvag.LazyInitialize();
            cmvag.SetupAgent(this);
            //ago.SetActive(true);// causes agent's InitializeAgent() to be called
        }
        CrowdManInitAgents();

        Debug.Log("CreateAgents finished");
    }