示例#1
0
    // public Dictionary <string, DTNode> genealogy;

    public string Decide(GSR s)
    {
        string result       = "None";
        int    next_node    = 0;
        DTNode current_node = nodes[0];
        int    counter      = 0;

        while (next_node != -1)
        {
            // Debug.Log("Current node: " + current_node.Name + " Counter " + counter.ToString());

            current_node.Decide(s, out next_node, out result);
            // Debug.Log("Next node: " + next_node.ToString());
            if (next_node == -1)
            {
                return(result);
            }
            else
            {
                current_node = nodes[next_node];
            }

            counter += 1;
        }
        return(result);
    }
示例#2
0
 public void Decide(GSR s, out int next_node, out string result)
 {
     if (decision_type)
     {
         next_node = s.state[state_value_to_test] > test_value ? true_node : false_node;
         result    = "None";
     }
     else
     {
         next_node = -1;
         result    = Sample();
     }
 }
示例#3
0
    public DecisionTreeNode Decide(GSR state_reprez)
    {
        float state_value = state_reprez.state[state_value_to_test];

        if (test_value > state_value)
        {
            Debug.Log("Selecting true node");
            return(true_node);
        }
        else
        {
            Debug.Log("Selecting false node");
            return(false_node);
        }
    }
 public IEnumerator CalculateBaseline()
 {
     time = 0;
     while (time < 20)
     {
         time += Time.deltaTime;
         HR_Buff.Add(naos.GetHeartRate());
         GSR.Add(naos.GetGsr());
         loading = HR_Buff.Count;
         yield return(new WaitForSeconds(0.001f));
     }
     HR_Base           = HR_Buff.Average(); //move decimal point 2
     GSR_BAse          = GSR_Buff.Average();
     obtainingBaseline = false;
     baselineObtained  = true;
 }
    public void FixedUpdate()
    {
        if (naos.GetConnection() && obtainingBaseline && HR_Buff.Count < BaseLineTime && once)
        {
            print("start mouse thing");
            StartCoroutine(CalculateBaseline());
            once = false;
        }

        if (running && eyeData != null && naos.GetConnection())
        {
            if (
                eyeData.GetGDLX() != 0 &&
                eyeData.GetGDLY() != 0 &&
                eyeData.GetGDLZ() != 0 &&
                eyeData.GetGDRX() != 0 &&
                eyeData.GetGDRY() != 0 &&
                eyeData.GetGDRZ() != 0 &&
                eyeData.GetPDL() != 0 &&
                eyeData.GetPDR() != 0 &&
                naos.GetHeartRate() != 0 &&
                naos.GetGsr() != 0
                )
            {
                gdlX.Add(eyeData.GetGDLX());
                gdlY.Add(eyeData.GetGDLY());
                gdlZ.Add(eyeData.GetGDLZ());
                gdrX.Add(eyeData.GetGDRX());
                gdrY.Add(eyeData.GetGDRY());
                gdrZ.Add(eyeData.GetGDRZ());
                pdl.Add(eyeData.GetPDL());
                pdr.Add(eyeData.GetPDR());
                HR.Add(naos.GetHeartRate() - HR_Base);
                GSR.Add(naos.GetGsr());
                PredictedConation.Add(KerasBrain.prediction);
            }
        }
    }
示例#6
0
    // Use this for initialization
    void Start()
    {
        // Debug.Log(DecisionModule);
        // Debug.Log(DecisionModule.nodes);
        // Debug.Log(DecisionModule.nodes.Count);
        // Debug.Log(DecisionModule.nodes[0]);
        // Debug.Log(DecisionModule.nodes[1]);
        // Debug.Log(DecisionModule.nodes[2]);

        Debug.Log(DecisionModule.nodes[0]);
        Debug.Log(DecisionModule.nodes[0].true_node);
        Debug.Log(DecisionModule.nodes[0].false_node);

        // Debug.Log(DecisionModule.genealogy.Keys);


        GSR s = new GSR();

        s.state = new float [] { 0.1f };
        string action = DecisionModule.Decide(s);

        Debug.Log(action);
    }
        public void BreathAPI(GSRAPI A)
        {
            G3_Measure_GSR B = new G3_Measure_GSR();

            B.Userid = A.Userid;
            int temp  = (int)A.SkinConductance;
            int temp2 = (int)((A.SkinConductance - temp) * 100);

            B.SkinConductance = temp + ((float)temp2 / 100);

            long temp3 = (int)A.SkinResistance;
            int  temp4 = (int)((A.SkinResistance - temp) * 100);

            B.SkinResistance = temp3 + ((float)temp4 / 100);

            int temp5 = (int)A.SkinConductanceVoltage;
            int temp6 = (int)((A.SkinConductanceVoltage - temp) * 10000);

            B.SkinConductanceVoltage = temp5 + ((float)temp6 / 10000);
            B.MeasurementDate        = DateTime.Now;
            if (B.SkinResistance < 1000)
            {
                B.Status = "出汗異常,有立即性危險,應盡速送醫";
                B.Score  = 10;
            }
            else
            {
                B.Status = "出汗正常";
                B.Score  = 0;
            }
            using (GSR db = new GSR())
            {
                db.G3_Measure_GSR.Add(B);
                db.SaveChanges();
            }
        }
        public ActionResult Create(string Name = null)
        {
            SystemNutrition        D       = new SystemNutrition();
            G3_Nutrition_Nutrition B       = new G3_Nutrition_Nutrition();
            HealthyScore           Healthy = new HealthyScore();
            UserHealthyInformation C       = new UserHealthyInformation();

            using (AIPEntities18 db = new AIPEntities18())
            {
                var reuslt = db.G1_User_Account.ToList();
                foreach (var item in reuslt)
                {
                    if (Name == item.email)
                    {
                        B.UserId = item.id;
                    }
                }
            }
            D.UserName  = Name;
            D.Nutrition = B;

            using (AIPEntities7 db = new AIPEntities7())
            {
                int number = 1;
                var reuslt = db.G3_Measure_BloodPressure.ToList();
                G3_Measure_BloodPressure History = new G3_Measure_BloodPressure();
                foreach (var item in reuslt)
                {
                    if (B.UserId == item.Userid && number == 1)
                    {
                        History.Userid          = item.Userid;
                        History.SBP             = item.SBP;
                        History.DBP             = item.DBP;
                        History.MeasurementDate = item.MeasurementDate;
                        History.Status          = item.Status;
                        History.Score           = item.Score;

                        number = number + 1;
                    }
                    else if (B.UserId == item.Userid && number != 1)
                    {
                        if (DateTime.Compare(item.MeasurementDate, History.MeasurementDate) > 0)
                        {
                            History.SBP             = item.SBP;
                            History.DBP             = item.DBP;
                            History.MeasurementDate = item.MeasurementDate;
                            History.Status          = item.Status;
                            History.Score           = item.Score;
                        }
                    }
                    C.BloodPressure = History;
                }
            }

            using (AIPEntities9 db = new AIPEntities9())
            {
                int            number  = 1;
                var            reuslt  = db.G3_Measure_ABG.ToList();
                G3_Measure_ABG History = new G3_Measure_ABG();

                foreach (var item in reuslt)
                {
                    if (B.UserId == item.Userid && number == 1)
                    {
                        History.Userid          = item.Userid;
                        History.SpO2            = item.SpO2;
                        History.MeasurementDate = item.MeasurementDate;
                        History.Status          = item.Status;
                        History.Score           = item.Score;

                        number = number + 1;
                    }
                    else if (B.UserId == item.Userid && number != 1)
                    {
                        if (DateTime.Compare(item.MeasurementDate, History.MeasurementDate) > 0)
                        {
                            History.SpO2            = item.SpO2;
                            History.MeasurementDate = item.MeasurementDate;
                            History.Status          = item.Status;
                            History.Score           = item.Score;
                        }
                    }
                    C.ABG = History;
                }
            }

            using (AIPEntities8 db = new AIPEntities8())
            {
                int number = 1;
                var reuslt = db.G3_Measure_BloodGlucose.ToList();
                G3_Measure_BloodGlucose History = new G3_Measure_BloodGlucose();

                foreach (var item in reuslt)
                {
                    if (B.UserId == item.Userid && number == 1)
                    {
                        History.Userid          = item.Userid;
                        History.GLU_AC          = item.GLU_AC;
                        History.MeasurementDate = item.MeasurementDate;
                        History.Status          = item.Status;
                        History.Score           = item.Score;

                        number = number + 1;
                    }
                    else if (B.UserId == item.Userid && number != 1)
                    {
                        if (DateTime.Compare(item.MeasurementDate, History.MeasurementDate) > 0)
                        {
                            History.GLU_AC          = item.GLU_AC;
                            History.MeasurementDate = item.MeasurementDate;
                            History.Status          = item.Status;
                            History.Score           = item.Score;
                        }
                    }
                    C.BloodGlucose = History;
                }
            }

            using (AIPEntities11 db = new AIPEntities11())
            {
                int            number  = 1;
                var            reuslt  = db.G3_Measure_BMI.ToList();
                G3_Measure_BMI History = new G3_Measure_BMI();

                foreach (var item in reuslt)
                {
                    if (B.UserId == item.Userid && number == 1)
                    {
                        History.Userid          = item.Userid;
                        History.BMI             = item.BMI;
                        History.MeasurementDate = item.MeasurementDate;
                        History.Status          = item.Status;
                        History.Score           = item.Score;

                        number = number + 1;
                    }
                    else if (B.UserId == item.Userid && number != 1)
                    {
                        if (DateTime.Compare(item.MeasurementDate, History.MeasurementDate) > 0)
                        {
                            History.BMI             = item.BMI;
                            History.MeasurementDate = item.MeasurementDate;
                            History.Status          = item.Status;
                            History.Score           = item.Score;
                        }
                    }
                    C.BMI = History;
                }
            }
            using (AIPEntities25 db = new AIPEntities25())
            {
                int            number  = 1;
                var            reuslt  = db.G3_Measure_Air.ToList();
                G3_Measure_Air History = new G3_Measure_Air();

                foreach (var item in reuslt)
                {
                    if (B.UserId == item.Userid && number == 1)
                    {
                        History.Userid          = item.Userid;
                        History.Air             = item.Air;
                        History.MeasurementDate = item.MeasurementDate;
                        History.Status          = item.Status;
                        History.Score           = item.Score;

                        number = number + 1;
                    }
                    else if (B.UserId == item.Userid && number != 1)
                    {
                        if (DateTime.Compare(item.MeasurementDate, History.MeasurementDate) > 0)
                        {
                            History.Air             = item.Air;
                            History.MeasurementDate = item.MeasurementDate;
                            History.Status          = item.Status;
                            History.Score           = item.Score;
                        }
                    }
                    C.Air = History;
                }
            }
            using (GSR db = new GSR())
            {
                int            number  = 1;
                var            reuslt  = db.G3_Measure_GSR.ToList();
                G3_Measure_GSR History = new G3_Measure_GSR();

                foreach (var item in reuslt)
                {
                    if (B.UserId == item.Userid && number == 1)
                    {
                        History.Userid                 = item.Userid;
                        History.SkinConductance        = item.SkinConductance;
                        History.SkinResistance         = item.SkinResistance;
                        History.SkinConductanceVoltage = item.SkinConductanceVoltage;
                        History.MeasurementDate        = item.MeasurementDate;
                        History.Status                 = item.Status;
                        History.Score = item.Score;

                        number = number + 1;
                    }
                    else if (B.UserId == item.Userid && number != 1)
                    {
                        if (DateTime.Compare(item.MeasurementDate, History.MeasurementDate) > 0)
                        {
                            History.SkinConductance        = item.SkinConductance;
                            History.SkinResistance         = item.SkinResistance;
                            History.SkinConductanceVoltage = item.SkinConductanceVoltage;
                            History.MeasurementDate        = item.MeasurementDate;
                            History.Status = item.Status;
                            History.Score  = item.Score;
                        }
                    }
                    C.GSR = History;
                }
            }
            using (GyroValues db = new GyroValues())
            {
                int number = 1;
                var reuslt = db.G3_Measure_GyroValues.ToList();
                G3_Measure_GyroValues History = new G3_Measure_GyroValues();

                foreach (var item in reuslt)
                {
                    if (B.UserId == item.Userid && number == 1)
                    {
                        History.Userid          = item.Userid;
                        History.RawX            = item.RawX;
                        History.RawY            = item.RawY;
                        History.RawZ            = item.RawZ;
                        History.MeasurementDate = item.MeasurementDate;
                        History.Status          = item.Status;
                        History.Score           = item.Score;

                        number = number + 1;
                    }
                    else if (B.UserId == item.Userid && number != 1)
                    {
                        if (DateTime.Compare(item.MeasurementDate, History.MeasurementDate) > 0)
                        {
                            History.RawX            = item.RawX;
                            History.RawY            = item.RawY;
                            History.RawZ            = item.RawZ;
                            History.MeasurementDate = item.MeasurementDate;
                            History.Status          = item.Status;
                            History.Score           = item.Score;
                        }
                    }
                    C.GyroValues = History;
                }
            }
            using (bodyTemperature db = new bodyTemperature())
            {
                int number = 1;
                var reuslt = db.G3_Measure_Temperature.ToList();
                G3_Measure_Temperature History = new G3_Measure_Temperature();

                foreach (var item in reuslt)
                {
                    if (B.UserId == item.Userid && number == 1)
                    {
                        History.Userid          = item.Userid;
                        History.Temperature     = item.Temperature;
                        History.MeasurementDate = item.MeasurementDate;
                        History.Status          = item.Status;
                        History.Score           = item.Score;

                        number = number + 1;
                    }
                    else if (B.UserId == item.Userid && number != 1)
                    {
                        if (DateTime.Compare(item.MeasurementDate, History.MeasurementDate) > 0)
                        {
                            History.Temperature     = item.Temperature;
                            History.MeasurementDate = item.MeasurementDate;
                            History.Status          = item.Status;
                            History.Score           = item.Score;
                        }
                    }
                    C.Temperature = History;
                }
            }
            using (Pulse db = new Pulse())
            {
                int number = 1;
                var reuslt = db.G3_Measure_Pulse.ToList();
                G3_Measure_Pulse History = new G3_Measure_Pulse();

                foreach (var item in reuslt)
                {
                    if (B.UserId == item.Userid && number == 1)
                    {
                        History.Userid          = item.Userid;
                        History.Pulse           = item.Pulse;
                        History.MeasurementDate = item.MeasurementDate;
                        History.Status          = item.Status;
                        History.Score           = item.Score;

                        number = number + 1;
                    }
                    else if (B.UserId == item.Userid && number != 1)
                    {
                        if (DateTime.Compare(item.MeasurementDate, History.MeasurementDate) > 0)
                        {
                            History.Pulse           = item.Pulse;
                            History.MeasurementDate = item.MeasurementDate;
                            History.Status          = item.Status;
                            History.Score           = item.Score;
                        }
                    }
                    C.Pulse = History;
                }
            }

            Healthy.HealthyInformation = C;
            Healthy.Total = C.ABG.Score + C.BloodGlucose.Score + C.BloodPressure.Score + C.BMI.Score +
                            C.Air.Score + C.GSR.Score + C.GyroValues.Score + C.Pulse.Score +
                            C.Temperature.Score;

            D.UserHealthy = Healthy;

            ViewBag.Message = "新增建議";
            return(View(D));
        }
示例#9
0
 public DecisionTreeNode Decide(GSR s)
 {
     return(this);
     // return null;
 }
示例#10
0
 public DecisionTreeNode Decide(GSR s)
 {
     return(null);
 }