Esempio n. 1
0
        public void AfterAddAction_HasOneInList_Test()
        {
            Action action = new Think();

            action.AddAction(new IdleAction());
            Assert.Equal(1, action.ActionListCount());
        }
Esempio n. 2
0
        public PartialViewResult AddThink(int planId)
        {
            var model = new Think();

            model.planId = planId;
            return(PartialView("_AddThink", model));
        }
Esempio n. 3
0
        public void AfterActivate_HasStatusActive_Test()
        {
            Action action = new Think();

            action.Activate();
            Assert.Equal(ActionEnum.STATUS_ACTIVE, action.Status);
        }
Esempio n. 4
0
        public void AfterAddAction_HasAction_Test()
        {
            Action action     = new Think();
            Action idleAction = new IdleAction();

            action.AddAction(idleAction);
            Assert.True(action.CurrentAction().Equals(idleAction));
        }
Esempio n. 5
0
 public ThinkModel(Think t)
 {
     ThinkId = t.ThinkId;
     // UserId = t.UserId;
     Content          = t.Content;
     Title            = t.Title;
     Date_of_creation = t.Date_of_creation;
     //User = t.User;
 }
Esempio n. 6
0
        public void RemoveAction_OnListWithOneAction_Test()
        {
            Action action     = new Think();
            Action idleAction = new IdleAction();

            action.AddAction(idleAction);
            action.RemoveAction();
            Assert.Equal(0, action.ActionListCount());
        }
Esempio n. 7
0
        public void AfterAddTwoActions_NextActionIs_FirstAddedAction_Test()
        {
            Action action       = new Think();
            Action idleAction   = new IdleAction();
            Action wanderAction = new WanderAction();

            action.AddAction(idleAction);
            action.AddAction(wanderAction);
            Assert.True(action.NextAction().Equals(idleAction));
        }
Esempio n. 8
0
 void OnDestroy()
 {
     if (LastHitBy != null)
     {
         LastHitBy.Stats.Money += 500;
     }
     Think.Terminate();
     StopCoroutine(Tick());
     WorldManager.HumanCount--;
 }
        public void DeleteThink(int id)
        {
            Think t = db.Thinks.GetItem(id);

            if (t != null)
            {
                db.News.Delete(t.ThinkId);
                Save();
            }
        }
Esempio n. 10
0
        public void AfterAddTwoActions_HasTwoInList_Test()
        {
            Action action       = new Think();
            Action idleAction   = new IdleAction();
            Action wanderAction = new WanderAction();

            action.AddAction(idleAction);
            action.AddAction(wanderAction);
            Assert.Equal(2, action.ActionListCount());
        }
Esempio n. 11
0
        public async Task Create(ThinkViewModel model)
        {
            var newPost = new Think()
            {
                Description = model.Description,
                Title       = model.Title,
                CreatedOn   = model.CreatedOn
            };

            await _forumPostAnswer.InsertAsync(newPost);
        }
Esempio n. 12
0
        public async Task Delete(ThinkViewModel model)
        {
            var deletePost = new Think()
            {
                Description = model.Description,
                Title       = model.Title,
                CreatedOn   = model.CreatedOn
            };

            await _forumPostAnswer.DeleteAsync(deletePost);
        }
        public void UpdateThink(ThinkModel t)
        {
            Think th = db.Thinks.GetItem(t.ThinkId);

            th.Title            = t.Title;
            th.Content          = t.Content;
            th.Date_of_creation = t.Date_of_creation;
            // th.UserId = t.UserId;
            // th.User = t.User;
            Save();
        }
Esempio n. 14
0
        public void RemoveAction_OnListWithTwoActions_CurrentActionIsFirstAddedAction_Test()
        {
            Action action       = new Think();
            Action idleAction   = new IdleAction();
            Action wanderAction = new WanderAction();

            action.AddAction(idleAction);
            action.AddAction(wanderAction);
            action.RemoveAction();
            Assert.True(action.CurrentAction().Equals(idleAction));
        }
Esempio n. 15
0
        public void AddTwoActionsByList_LastAddedIsCurrentAction_Test()
        {
            Action        action       = new Think();
            List <Action> list         = new List <Action>();
            Action        idleAction   = new IdleAction();
            Action        wanderAction = new WanderAction();

            list.Add(idleAction);
            list.Add(wanderAction);
            action.AddActions(list);
            Assert.True(action.CurrentAction().Equals(wanderAction));
        }
Esempio n. 16
0
        public void AddTwoActionsByList_Test()
        {
            Action        action       = new Think();
            List <Action> list         = new List <Action>();
            Action        idleAction   = new IdleAction();
            Action        wanderAction = new WanderAction();

            list.Add(idleAction);
            list.Add(wanderAction);
            action.AddActions(list);
            Assert.Equal(2, action.ActionListCount());
        }
Esempio n. 17
0
        public Ship(World world, Team team) : base(world)
        {
            this.Team = team;

            this.Velocity = new Vector2(0, 0);
            this.Scale    = 5;

            this.Color = team.Colour;

            this.Brain = new Think(this, world);
            this.Brain.Activate();
        }
Esempio n. 18
0
        public JsonResult AddTarget(Think model)
        {
            var service = new PlanService();
            var plan    = service.GetById(model.planId);

            if (plan.Thinks == null)
            {
                plan.Thinks = new List <Think> ();
            }
            plan.Thinks.Add(model);
            service.UpdatePlan(model.planId, plan.Thinks);
            return(Json(true));
        }
Esempio n. 19
0
        void Waiting()
        {
            TransactionCategory = nameof(Waiting);

            Receive <Message>(message =>
            {
                var think = new Think
                {
                    Id      = Guid.NewGuid(),
                    Message = message,
                };

                Context.System.Scheduler.ScheduleTellOnce(TimeSpan.FromSeconds(1), Self, think, Sender);

                Become(Thinking);
            });
        }
Esempio n. 20
0
        public override void Awake()
        {
            base.Awake();
            _renderer = GetComponent <Renderer>();
            var parameters = Parameters.Instance;

            SensoryMemory   = new SensoryMemory(this, parameters.AgentMemorySpan, parameters.FriendlyFire);
            TargetingSystem = new TargetingSystem(this);
            WeaponSystem    =
                new WeaponSystem(
                    this,
                    parameters.AgentReactionTime,
                    parameters.AgentAimAccuracy,
                    parameters.AgentAimPersistenceTime);
            PathPlanner = GetComponent <PathPlanner>();

            MaximumHealth     = parameters.AgentMaximumHealth;
            Health            = 10;
            HitIndicatorTimer = (int)parameters.HitFlashTime;
            Hit   = false;
            Score = 0;

            GoalArbitrationRegulator =
                new Regulator(parameters.AgentGoalAppraisalUpdateFrequency);
            VisionUpdateRegulator =
                new Regulator(parameters.AgentVisionUpdateFrequency);
            TargetSelectionRegulator =
                new Regulator(parameters.AgentTargetingUpdateFrequency);
            WeaponSelectionRegulator =
                new Regulator(parameters.AgentWeaponSelectionFrequency);

            Brain = new Think(this);

            FieldOfView = parameters.AgentFieldOfView;

            _normalMaterial = _renderer.materials;
            _flashMaterial  = CreateFlashMaterial();
        }
Esempio n. 21
0
        public SmartEntity(Vector2 pos, World w, string name) : base(pos, w)
        {
            /*
             * INIT FUZZY MODULES
             */
            _fuzzyThirst = new Thirst();
            _fuzzyHunger = new Hunger();
            _fuzzySleep  = new Sleep();

            NAME = name;
            // random stats
            hunger    = MyWorld.Random.Next(0, 25);
            thirst    = MyWorld.Random.Next(0, 25);
            tiredness = MyWorld.Random.Next(0, 25);

            Velocity = new Vector2(0, 0);
            Think    = new Think(this);
            Think.Activate();
            Behaviours = new List <SteeringBehaviour>
            {
                new WanderBehaviour(this, 90, 100),
                new WallAvoidance(this, 15)
            };
        }
Esempio n. 22
0
        public void RemoveAction_OnEmptyList_GivesException_Test()
        {
            Action action = new Think();

            Assert.Throws <InvalidOperationException>(() => action.RemoveAction());
        }
Esempio n. 23
0
        public void CreateAction_Test()
        {
            Action action = new Think();

            Assert.NotEqual(null, action);
        }
Esempio n. 24
0
        public void OnCreate_HasEmptyList_Test()
        {
            Action action = new Think();

            Assert.Equal(0, action.ActionListCount());
        }
Esempio n. 25
0
        public void OnCreate_HasStatusInactive_Test()
        {
            Action action = new Think();

            Assert.Equal(ActionEnum.STATUS_INACTIVE, action.Status);
        }
Esempio n. 26
0
        //END OFF按鈕的功能部分********************************************************************************************************************************
        //廠商所提供的腦波執行序******************************************************************************************************************************************
        /// <summary>
        /// 腦波執行序方法
        /// </summary>
        private void Run()
        {
            while (_isInit)
            {
                _errCode = Think.TG_ReadPackets(_connectionId, 1);

                if (_errCode == 1)
                {
                    if (Think.TG_GetValueStatus(_connectionId,
                                                Think.DATA_POOR_SIGNAL) != 0)
                    {
                        _poorSignal = Think.TG_GetValue(_connectionId,
                                                        Think.DATA_POOR_SIGNAL);
                    }

                    if (Think
                        .TG_GetValueStatus(_connectionId, Think.DATA_DELTA) != 0)
                    {
                        _array[0] = Think.TG_GetValue(_connectionId,
                                                      Think.DATA_DELTA);
                    }


                    if (Think
                        .TG_GetValueStatus(_connectionId, Think.DATA_THETA) != 0)
                    {
                        _array[1] = Think.TG_GetValue(_connectionId,
                                                      Think.DATA_THETA);
                    }

                    if (Think.TG_GetValueStatus(_connectionId,
                                                Think.DATA_LowALPHA) != 0)
                    {
                        _array[2] = Think.TG_GetValue(_connectionId,
                                                      Think.DATA_LowALPHA);
                    }

                    if (Think.TG_GetValueStatus(_connectionId,
                                                Think.DATA_HighALPHA) != 0)
                    {
                        _array[3] = Think.TG_GetValue(_connectionId,
                                                      Think.DATA_HighALPHA);
                    }

                    if (Think
                        .TG_GetValueStatus(_connectionId, Think.DATA_LowBETA) != 0)
                    {
                        _array[4] = Think.TG_GetValue(_connectionId,
                                                      Think.DATA_LowBETA);
                    }

                    if (Think
                        .TG_GetValueStatus(_connectionId, Think.DATA_HighBETA) != 0)
                    {
                        _array[5] = Think.TG_GetValue(_connectionId,
                                                      Think.DATA_HighBETA);
                    }

                    if (Think.TG_GetValueStatus(_connectionId,
                                                Think.DATA_LowGAMMA) != 0)
                    {
                        _array[6] = Think.TG_GetValue(_connectionId,
                                                      Think.DATA_LowGAMMA);
                    }

                    if (Think.TG_GetValueStatus(_connectionId, Think.DATA_HighGAMMA) != 0)
                    {
                        _array[7] = Think.TG_GetValue(_connectionId,
                                                      Think.DATA_HighGAMMA);
                    }

                    if (Think.TG_GetValueStatus(_connectionId, Think.DATA_ATTENTION) != 0)
                    {
                        _array[8] = Think.TG_GetValue(_connectionId,
                                                      Think.DATA_ATTENTION);
                    }

                    if (Think.TG_GetValueStatus(_connectionId, Think.DATA_MEDITATION) != 0)
                    {
                        _array[9] = Think.TG_GetValue(_connectionId,
                                                      Think.DATA_MEDITATION);
                    }


                    if (_tempValue != _array[0])
                    {
                        float A = (float)(_array[2] + _array[3]);
                        float B = (float)(_array[4] + _array[5]);
                        float D = (float)_array[0];
                        float T = (float)_array[1];

                        // Pressure
                        _array[10] = 100 - _array[9];
                        //Sleep_Quality
                        _array[11] = (int)((((B / 2) + (T / 20)) / ((A / 2) + (D / 20))) * 100);
                        //Fatigue
                        _array[12] = (int)((((A / 2) + T) / (B / 2)));



                        if (_CheckBoxCount > 13)
                        {
                            for (int index = 13; index < _CheckBoxCount; index++)
                            {
                                _array[index] = Rules.RulesToDouble(Rules.GetReplaceString(
                                                                        OutputFile.Config.GetRules()[index - 13]), ref _array);
                            }
                        }

                        for (int index = 0; index < _array.Length; index++)
                        {
                            _avgArray[index] += _array[index];
                        }
                        //判斷訊號雜訊不為0就會被刪掉***********************************************************************************************************************************
                        if (_poorSignal == 0)
                        {
                            int tempCount = 0;

                            foreach (double p in _array)
                            {
                                if (p == 0)
                                {
                                    tempCount++;
                                }
                                if (tempCount == 3)
                                {
                                    break;
                                }
                            }

                            if (tempCount != 3)
                            {
                                OutputFile.CSV.AddData(_CheckBoxCount, ref _array, _poorSignal);
                            }
                        }
                        //END OFF判斷雜訊值為不為0***************************************************************************************************************************************

                        try
                        {
                            _chart.Invoke(new MethodInvoker(delegate()
                            {
                                DrawChart(_array, ref _index, ref _chart);
                            }));

                            _chartAvg.Invoke(new MethodInvoker(delegate()
                            {
                                DrawChartAvg(_avgArray, ref _index, ref _chartAvg);
                            }));
                        }
                        catch
                        {
                        }


                        _index++;
                        _tempValue = _array[0];
                    }
                }
            }
        }
Esempio n. 27
0
        //按鈕的功能部分**********************************************************************************************************************************************
        /// <summary>
        /// 開始或停止按鈕的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonStart_Click(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            if (button.Text == "啟動")
            {
                if (_series == null)
                {
                    MessageBox.Show("請選擇要顯示的資料");
                    return;
                }
                else
                {
                    if (!_isInit)
                    {
                        //取得通訊ID
                        _connectionId = Think.TG_GetNewConnectionId();
                        if (_connectionId < 0)
                        {
                            MessageBox.Show("無法連接"); return;
                        }

                        /* Set/open stream (raw bytes) log file for connection */
                        _errCode = Think.TG_SetStreamLog(_connectionId, "streamLog.txt");
                        if (_errCode < 0)
                        {
                            MessageBox.Show("無法連接"); return;
                        }

                        /* Set/open data (Think values) log file for connection */
                        _errCode = Think.TG_SetDataLog(_connectionId, "dataLog.txt");
                        if (_errCode < 0)
                        {
                            MessageBox.Show("無法連接"); return;
                        }

                        _errCode = Think.TG_Connect(_connectionId, _SelectComPort,
                                                    Think.BAUD_57600, Think.STREAM_PACKETS);
                        if (_errCode < 0)
                        {
                            MessageBox.Show("無法連接"); return;
                        }

                        button.Text = "停止";
                        _isInit     = true;
                        CleanArray();
                        CleanAvgArray();
                        CleanChart(ref _chart, true);
                        CleanChart(ref _chartAvg, true);
                        buttonImport.Enabled = false;


                        foreach (Series s in _series)
                        {
                            try { _chart.Series.Add(s); }
                            catch (ArgumentException ex) { }
                        }

                        foreach (Series s in _seriesAvg)
                        {
                            try { _chartAvg.Series.Add(s); }
                            catch (ArgumentException ex) { }
                        }


                        _thread = new Thread(new ThreadStart(Run));
                        _thread.Start();
                    }
                }
            }
            else if (button.Text == "停止")
            {
                button.Text = "啟動";
                Think.TG_Disconnect(_connectionId);
                _isInit = false;
                _thread.Abort();
                CleanChart(ref _chart, false);
                CleanChart(ref _chartAvg, false);
                buttonImport.Enabled = true;


                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork             += worker_DoWork;
                worker.RunWorkerCompleted += worker_RunWorkerCompleted;
                worker.RunWorkerAsync();

                int[]    select = _list.ToArray();
                String[] labels = checkedListBox1.Items.Cast <String>().ToArray();

                new TotalForm(select, _avgArray, labels, _index).ShowDialog();
                _index = 0;
            }
        }