Beispiel #1
0
        private void GetHrvHistoryData()
        {
            if (HrvHistoryArrState)
            {
                return;
            }

            if (UserInfoStatic.ipAdd == null)
            {
                if (MainRightPerson.TmpHrvRecord.Count > 0)
                {
                    UserHrvRecord[] tmpArr = new UserHrvRecord[MainRightPerson.TmpHrvRecord.Count];
                    MainRightPerson.TmpHrvRecord.CopyTo(tmpArr);
                    for (int i = 0; i < MainRightPerson.TmpHrvRecord.Count; i++)
                    {
                        UserHrvRecord tmp = tmpArr[i];
                        if (tmp.RecordType < 10)
                        {
                            HrvHistoryArr.Add(MainRightPerson.TmpHrvRecord[i]);
                        }
                    }
                }
            }
            else
            {
                HrvHistoryArr = hrvdb.GetConstAndHistoryListData(1, 1, "1", "0");
            }

            HrvHistoryArrState = true;
        }
Beispiel #2
0
        public Hashtable GetGuestHistoryByID(int SID)
        {
            Hashtable hInfo = new Hashtable();

            UserHrvRecord[] tmp = new UserHrvRecord[1];

            if (_showType == 1)
            {
                HrvHistoryArr.CopyTo(SID - 1, tmp, 0, 1);
            }
            else if (_showType == 2)
            {
                TrainHistoryArr.CopyTo(SID - 1, tmp, 0, 1);
            }
            else
            {
                RelaxHistoryArr.CopyTo(SID - 1, tmp, 0, 1);
            }

            UserHrvRecord tmpRecord = tmp[0];

            if (tmpRecord != null)
            {
                hInfo["fMean"]     = tmpRecord.TimeData[0];
                hInfo["HRVScore"]  = tmpRecord.HrvScore;
                hInfo["score"]     = tmpRecord.Score;
                hInfo["Pressure"]  = tmpRecord.Pressure;
                hInfo["adjust"]    = tmpRecord.Adjust;
                hInfo["stable"]    = tmpRecord.Stable;     //稳定
                hInfo["report"]    = tmpRecord.Report;     //评价报告
                hInfo["NB"]        = tmpRecord.AnsBalance; //神经兴奋性
                hInfo["StartTime"] = tmpRecord.StartTime;  //开始时间
                hInfo["Time"]      = tmpRecord.HRVData.Count / 2.0;
                hInfo["hrvData"]   = tmpRecord.HRVData;
                hInfo["HRVMark"]   = tmpRecord.MarkData;
            }
            return(hInfo);
        }
Beispiel #3
0
        private void OnStopAllTimerAndHD()
        {
            //if (startTimer.IsEnabled == true)
            //{
            //    startTimer.Stop();
            //    startTimer = new System.Windows.Threading.DispatcherTimer();
            //    this.playGrid.Children.Clear();
            //}
            if (isStart)
            {
                isStart = false;
                //isImage = false;
                hd.StopDriver();
                HRVReadTimer.Stop();
                HRVReadTimer = null;// new System.Windows.Threading.DispatcherTimer();
                //EPData = new ArrayList();
            }

            if (isGameStart)
            {
                //结束游戏
                //              MessageBox.Show("结束游戏");
                isGameStart = false;
                if (HRVData.Count > 128)
                {
                    HMMath    hdMath      = new HMMath(HRVData, EPData);    //计算14项数据,调节指数,稳定指数,综合得分和给出评价报告
                    Hashtable HRVDataCalc = hdMath.HRVCalc();               //用于存放HRV测量后计算的相关数据
                    HRVDataCalc["HRVScore"]  = EPScore;                     //HRV得分
                    HRVDataCalc["Time"]      = (Single)HRVData.Count / 2.0; //测试时间,单位是秒
                    HRVDataCalc["EndTime"]   = DateTime.Now;                //结束时间,datetime格式
                    HRVDataCalc["StartTime"] = startTime;                   //开始时间,datetime格式
                    //                HRVDataCalc["TimeType"] = this.SelectComboBox + 1;//HRV检测时间类型
                    //                    HRVDataCalc["TimeType"] = Convert.ToInt32(tInfo["tid"]);//HRV检测时间类型
                    HRVDataCalc["TimeType"] = 100;//HRV检测时间类型
                    //                HRVDataCalc["Mood"] = this.systemMeg["Mood"];//测量时心情状态
                    HRVDataCalc["Mood"]    = 101;
                    HRVDataCalc["HRVMark"] = hrvMarkArr;//事件标记

                    //开始数据库操作
                    //lich
                    if (UserInfoStatic.ipAdd != null)
                    {
                        hrvdb.OnInsertHRVDataAndEpData(HRVData, EPData, hrvMarkArr, HRVDataCalc, PPGData, "3");
                    }
                    else
                    {
                        UserHrvRecord hrvRecord = new UserHrvRecord();
                        hrvRecord.HRVData  = HRVData;
                        hrvRecord.EPData   = EPData;
                        hrvRecord.MarkData = hrvMarkArr;
                        hrvRecord.PWRData  = (ArrayList)HRVDataCalc["FS"];
                        hrvRecord.TimeData.Add(HRVDataCalc["fMean"]);
                        hrvRecord.TimeData.Add(HRVDataCalc["fStdDev"]);
                        hrvRecord.TimeData.Add(HRVDataCalc["fSDNN"]);
                        hrvRecord.TimeData.Add(HRVDataCalc["fRMSSD"]);
                        hrvRecord.TimeData.Add(HRVDataCalc["fSD"]);
                        hrvRecord.TimeData.Add(HRVDataCalc["fSDSD"]);
                        hrvRecord.TimeData.Add(HRVDataCalc["fPNN"]);
                        hrvRecord.FreData.Add(HRVDataCalc["tp"]);
                        hrvRecord.FreData.Add(HRVDataCalc["vlf"]);
                        hrvRecord.FreData.Add(HRVDataCalc["lf"]);
                        hrvRecord.FreData.Add(HRVDataCalc["hf"]);
                        hrvRecord.FreData.Add(HRVDataCalc["lhr"]);
                        hrvRecord.FreData.Add(HRVDataCalc["lfnorm"]);
                        hrvRecord.FreData.Add(HRVDataCalc["hfnorm"]);
                        hrvRecord.AnsBalance = Convert.ToDouble(HRVDataCalc["NB"]);
                        hrvRecord.Pressure   = Convert.ToDouble(HRVDataCalc["Pressure"]);
                        hrvRecord.Adjust     = Convert.ToDouble(HRVDataCalc["adjust"]);
                        hrvRecord.Stable     = Convert.ToDouble(HRVDataCalc["stable"]);
                        hrvRecord.Score      = Convert.ToDouble(HRVDataCalc["score"]);
                        hrvRecord.HrvScore   = Convert.ToDouble(HRVDataCalc["HRVScore"]);
                        hrvRecord.TimeLength = Convert.ToDouble(HRVData.Count / 2.0);
                        hrvRecord.StartTime  = Convert.ToDateTime(HRVDataCalc["StartTime"]);
                        hrvRecord.EndTime    = Convert.ToDateTime(HRVDataCalc["EndTime"]);
                        hrvRecord.RecordType = Convert.ToInt32(HRVDataCalc["TimeType"]);
                        hrvRecord.Mood       = Convert.ToInt32(HRVDataCalc["Mood"]);
                        hrvRecord.Report     = Convert.ToString(HRVDataCalc["report"]);

                        MainRightPerson.TmpHrvRecord.Add(hrvRecord);
                    }
                }
            }
            //if (timeTimer.IsEnabled == true)
            //{
            //    timeTimer.Stop();
            //    //timeTimer = new System.Windows.Threading.DispatcherTimer();
            //}
        }
        public void stopGame()
        {
            isGameStart = false;
            if (HRVData.Count > 128)
            {
                HMMath    hdMath      = new HMMath(HRVData, EPData); //计算14项数据,调节指数,稳定指数,综合得分和给出评价报告
                Hashtable HRVDataCalc = hdMath.HRVCalc();            //用于存放HRV测量后计算的相关数据
                //                HRVDataCalc["HRVScore"] = EPScore;//HRV得分
                HRVDataCalc["HRVScore"]  = 0;
                HRVDataCalc["Time"]      = (Single)HRVData.Count / 2.0; //测试时间,单位是秒
                HRVDataCalc["EndTime"]   = DateTime.Now;                //结束时间,datetime格式
                HRVDataCalc["StartTime"] = startTime;                   //开始时间,datetime格式
                //                HRVDataCalc["TimeType"] = this.SelectComboBox + 1;//HRV检测时间类型
                //                 HRVDataCalc["TimeType"] = Convert.ToInt32(tInfo["tid"]);//HRV检测时间类型
                //HRVDataCalc["TimeType"] = Convert.ToInt16(tInfo["tid"]) + 40;
                HRVDataCalc["TimeType"] = oldGameType;
                //                PmtsMessageBox.CustomControl1.Show(Convert.ToString(tInfo["tid"]), PmtsMessageBox.ServerMessageBoxButtonType.OK);
                //                HRVDataCalc["Mood"] = this.systemMeg["Mood"];//测量时心情状态
                HRVDataCalc["Mood"]    = 101;
                HRVDataCalc["HRVMark"] = hrvMarkArr;//事件标记

                //开始数据库操作
                //lich
                if (UserInfoStatic.ipAdd != null)
                {
                    hrvdb.OnInsertHRVDataAndEpData(HRVData, EPData, hrvMarkArr, HRVDataCalc, PPGData, "2");
                }
                else
                {
                    UserHrvRecord hrvRecord = new UserHrvRecord();
                    hrvRecord.HRVData  = HRVData;
                    hrvRecord.EPData   = EPData;
                    hrvRecord.MarkData = hrvMarkArr;
                    hrvRecord.PWRData  = (ArrayList)HRVDataCalc["FS"];
                    hrvRecord.TimeData.Add(HRVDataCalc["fMean"]);
                    hrvRecord.TimeData.Add(HRVDataCalc["fStdDev"]);
                    hrvRecord.TimeData.Add(HRVDataCalc["fSDNN"]);
                    hrvRecord.TimeData.Add(HRVDataCalc["fRMSSD"]);
                    hrvRecord.TimeData.Add(HRVDataCalc["fSD"]);
                    hrvRecord.TimeData.Add(HRVDataCalc["fSDSD"]);
                    hrvRecord.TimeData.Add(HRVDataCalc["fPNN"]);
                    hrvRecord.FreData.Add(HRVDataCalc["tp"]);
                    hrvRecord.FreData.Add(HRVDataCalc["vlf"]);
                    hrvRecord.FreData.Add(HRVDataCalc["lf"]);
                    hrvRecord.FreData.Add(HRVDataCalc["hf"]);
                    hrvRecord.FreData.Add(HRVDataCalc["lhr"]);
                    hrvRecord.FreData.Add(HRVDataCalc["lfnorm"]);
                    hrvRecord.FreData.Add(HRVDataCalc["hfnorm"]);
                    hrvRecord.AnsBalance = Convert.ToDouble(HRVDataCalc["NB"]);
                    hrvRecord.Pressure   = Convert.ToDouble(HRVDataCalc["Pressure"]);
                    hrvRecord.Adjust     = Convert.ToDouble(HRVDataCalc["adjust"]);
                    hrvRecord.Stable     = Convert.ToDouble(HRVDataCalc["stable"]);
                    hrvRecord.Score      = Convert.ToDouble(HRVDataCalc["score"]);
                    hrvRecord.HrvScore   = Convert.ToDouble(HRVDataCalc["HRVScore"]);
                    hrvRecord.TimeLength = Convert.ToDouble(HRVData.Count / 2.0);
                    hrvRecord.StartTime  = Convert.ToDateTime(HRVDataCalc["StartTime"]);
                    hrvRecord.EndTime    = Convert.ToDateTime(HRVDataCalc["EndTime"]);
                    hrvRecord.RecordType = Convert.ToInt32(HRVDataCalc["TimeType"]);
                    hrvRecord.Mood       = Convert.ToInt32(HRVDataCalc["Mood"]);
                    hrvRecord.Report     = Convert.ToString(HRVDataCalc["report"]);

                    MainRightPerson.TmpHrvRecord.Add(hrvRecord);
                }
            }
        }
        /// <summary>
        /// 接受flash传过来的值
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FromFlashCall(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEvent e)
        {
            System.Diagnostics.Debug.Write("解析nodeXml:" + e.request.ToString() + "\n");
            Hashtable requestInfo = NodeXmlToHashtable(e.request.ToString());

            //           MessageBox.Show(requestInfo["rType"].ToString());
            if (requestInfo != null)
            {
                if (requestInfo["rType"].ToString() == "test")
                {
                    //                    MessageBox.Show("test");
                    Hashtable historyInfo = new Hashtable();
                    historyInfo["trid"]  = tdb.GetTrainRecordID();
                    historyInfo["tid"]   = tInfo["tid"];
                    historyInfo["score"] = requestInfo["S"];
                    historyInfo["gate"]  = requestInfo["Gate"];
                    historyInfo["diff"]  = requestInfo["Diff"];
                    historyInfo["o"]     = requestInfo["O"];
                    historyInfo["r"]     = requestInfo["R"];
                    historyInfo["t"]     = requestInfo["T"];
                    historyInfo["e"]     = requestInfo["E"];
                    historyInfo["w"]     = requestInfo["W"];
                    historyInfo["bo"]    = UserInfoStatic.O;
                    historyInfo["br"]    = UserInfoStatic.R;
                    historyInfo["bt"]    = UserInfoStatic.T;
                    historyInfo["be"]    = UserInfoStatic.E;
                    historyInfo["bw"]    = UserInfoStatic.W;
                    tdb.OnInsertTrainToHistory(historyInfo);

                    UserInfoStatic.O += Convert.ToDouble(requestInfo["O"]);
                    UserInfoStatic.R += Convert.ToDouble(requestInfo["R"]);
                    UserInfoStatic.T += Convert.ToDouble(requestInfo["T"]);
                    UserInfoStatic.E += Convert.ToDouble(requestInfo["E"]);
                    UserInfoStatic.W += Convert.ToDouble(requestInfo["W"]);
                    tdb.OnUpdateTrainDataToUserPara();
                    if (UserInfoStatic.O >= 500 && UserInfoStatic.R >= 500 && UserInfoStatic.T >= 500 && UserInfoStatic.E >= 500 && UserInfoStatic.W >= 500)
                    {
                        tdb.OnUpdateTrainAll();
                    }
                    TrainBack tb = tListView as TrainBack;

                    //结束游戏
                    //    MessageBox.Show("结束游戏");

                    isGameStart = false;
                    if (HRVData.Count > 128)
                    {
                        HMMath    hdMath      = new HMMath(HRVData, EPData);          //计算14项数据,调节指数,稳定指数,综合得分和给出评价报告
                        Hashtable HRVDataCalc = hdMath.HRVCalc();                     //用于存放HRV测量后计算的相关数据
                        HRVDataCalc["HRVScore"]  = EPScore;                           //HRV得分
                        HRVDataCalc["Time"]      = (Single)HRVData.Count / 2.0;       //测试时间,单位是秒
                        HRVDataCalc["EndTime"]   = DateTime.Now;                      //结束时间,datetime格式
                        HRVDataCalc["StartTime"] = startTime;                         //开始时间,datetime格式
                        //                HRVDataCalc["TimeType"] = this.SelectComboBox + 1;//HRV检测时间类型
                        HRVDataCalc["TimeType"] = Convert.ToInt32(tInfo["tid"]) + 40; //HRV检测时间类型
                        //                HRVDataCalc["Mood"] = this.systemMeg["Mood"];//测量时心情状态
                        HRVDataCalc["Mood"]    = 101;
                        HRVDataCalc["HRVMark"] = hrvMarkArr;//事件标记

                        //开始数据库操作
                        //lich
                        if (UserInfoStatic.ipAdd != null)
                        {
                            hrvdb.OnInsertHRVDataAndEpData(HRVData, EPData, hrvMarkArr, HRVDataCalc, PPGData, "2");
                        }
                        else
                        {
                            UserHrvRecord hrvRecord = new UserHrvRecord();
                            hrvRecord.HRVData  = HRVData;
                            hrvRecord.EPData   = EPData;
                            hrvRecord.MarkData = hrvMarkArr;
                            hrvRecord.PWRData  = (ArrayList)HRVDataCalc["FS"];
                            hrvRecord.TimeData.Add(HRVDataCalc["fMean"]);
                            hrvRecord.TimeData.Add(HRVDataCalc["fStdDev"]);
                            hrvRecord.TimeData.Add(HRVDataCalc["fSDNN"]);
                            hrvRecord.TimeData.Add(HRVDataCalc["fRMSSD"]);
                            hrvRecord.TimeData.Add(HRVDataCalc["fSD"]);
                            hrvRecord.TimeData.Add(HRVDataCalc["fSDSD"]);
                            hrvRecord.TimeData.Add(HRVDataCalc["fPNN"]);
                            hrvRecord.FreData.Add(HRVDataCalc["tp"]);
                            hrvRecord.FreData.Add(HRVDataCalc["vlf"]);
                            hrvRecord.FreData.Add(HRVDataCalc["lf"]);
                            hrvRecord.FreData.Add(HRVDataCalc["hf"]);
                            hrvRecord.FreData.Add(HRVDataCalc["lhr"]);
                            hrvRecord.FreData.Add(HRVDataCalc["lfnorm"]);
                            hrvRecord.FreData.Add(HRVDataCalc["hfnorm"]);
                            hrvRecord.AnsBalance = Convert.ToDouble(HRVDataCalc["NB"]);
                            hrvRecord.Pressure   = Convert.ToDouble(HRVDataCalc["Pressure"]);
                            hrvRecord.Adjust     = Convert.ToDouble(HRVDataCalc["adjust"]);
                            hrvRecord.Stable     = Convert.ToDouble(HRVDataCalc["stable"]);
                            hrvRecord.Score      = Convert.ToDouble(HRVDataCalc["score"]);
                            hrvRecord.HrvScore   = Convert.ToDouble(HRVDataCalc["HRVScore"]);
                            hrvRecord.TimeLength = Convert.ToDouble(HRVData.Count / 2.0);
                            hrvRecord.StartTime  = Convert.ToDateTime(HRVDataCalc["StartTime"]);
                            hrvRecord.EndTime    = Convert.ToDateTime(HRVDataCalc["EndTime"]);
                            hrvRecord.RecordType = Convert.ToInt32(HRVDataCalc["TimeType"]);
                            hrvRecord.Mood       = Convert.ToInt32(HRVDataCalc["Mood"]);
                            hrvRecord.Report     = Convert.ToString(HRVDataCalc["report"]);

                            MainRightPerson.TmpHrvRecord.Add(hrvRecord);
                        }
                    }
                    //or (int i = 0; i < tb.TrainButtonGrid.Children.Count; i++)
                    //
                    //rainList tl = tb.TrainButtonGrid.Children[i] as TrainList;
                    //f (tl.HistoryButton.Tag.ToString() == tInfo["tid"].ToString())
                    //
                    //   tl.HistoryButton.IsEnabled = true;
                    //   break;
                    //
                    //
                }
                else if (requestInfo["rType"].ToString() == "start")
                {
                    isGameStart = true;
                    HRVData     = new ArrayList(); //初始化HRV曲线数组
                    EPData      = new ArrayList(); //初始化EP数组
                    IBIData     = new ArrayList(); //初始化IBI数组
                    PPGData     = new ArrayList(); //初始化PPG数组
                    hrvMarkArr  = new ArrayList(); //初始化时间标记数组
                    OnChartPaint(HRVData);         //初始化曲线图表
                    OnAnimationForEP(0);           //协调状态条
                    EPScore = 0;
                    //     MessageBox.Show("开始游戏");
                }
                else if (requestInfo["rType"].ToString() == "enter")
                {
                }
                else if (requestInfo["rType"].ToString() == "cmd")
                {
                    //                   MessageBox.Show("cmd");
                    if (requestInfo["cmd"].ToString() == "1")
                    {
                        OnStartHrvToFlash();
                    }
                    else
                    {
                        OnEndHrvToFlash();
                    }
                }
                else if (requestInfo["rType"].ToString() == "click")
                {
                    //                   MessageBox.Show("click");
                }
            }
        }
        //public void startGame(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEvent e)
        //{
        //    XmlDocument document = new XmlDocument();
        //    document.LoadXml(e.request);
        //    // get attributes to see which command flash is trying to call
        //    XmlAttributeCollection attributes = document.FirstChild.Attributes;

        //    // get function
        //    String command = attributes.Item(0).InnerText;

        //    // get parameters
        //    XmlNodeList list = document.GetElementsByTagName("arguments");

        //    isGameStart = true;
        //    HRVData = new ArrayList();//初始化HRV曲线数组
        //    EPData = new ArrayList();//初始化EP数组
        //    IBIData = new ArrayList();//初始化IBI数组
        //    PPGData = new ArrayList();//初始化PPG数组
        //    hrvMarkArr = new ArrayList();//初始化时间标记数组

        ////    MessageBox.Show("开始游戏");
        //    //switch (command)
        //    //{
        //    //    case "callCSharp":
        //    //        callCSharp();
        //    //        break;

        //    //}
        //}

        public void endGame(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEvent e)
        {
            XmlDocument document = new XmlDocument();

            document.LoadXml(e.request);
            // get attributes to see which command flash is trying to call
            XmlAttributeCollection attributes = document.FirstChild.Attributes;

            // get function
            String command = attributes.Item(0).InnerText;

            // get parameters
            XmlNodeList list = document.GetElementsByTagName("arguments");

            // arguments paramters
            XmlNodeList pList = list[0].ChildNodes;

//            MessageBox.Show("结束游戏");

            isGameStart = false;
            if (HRVData.Count > 128)
            {
                HMMath    hdMath      = new HMMath(HRVData, EPData); //计算14项数据,调节指数,稳定指数,综合得分和给出评价报告
                Hashtable HRVDataCalc = hdMath.HRVCalc();            //用于存放HRV测量后计算的相关数据
//                HRVDataCalc["HRVScore"] = EPScore;//HRV得分
                HRVDataCalc["HRVScore"]  = 0;
                HRVDataCalc["Time"]      = (Single)HRVData.Count / 2.0;  //测试时间,单位是秒
                HRVDataCalc["EndTime"]   = DateTime.Now;                 //结束时间,datetime格式
                HRVDataCalc["StartTime"] = startTime;                    //开始时间,datetime格式
//                HRVDataCalc["TimeType"] = this.SelectComboBox + 1;//HRV检测时间类型
                HRVDataCalc["TimeType"] = Convert.ToInt32(tInfo["tid"]); //HRV检测时间类型
//                HRVDataCalc["Mood"] = this.systemMeg["Mood"];//测量时心情状态
                HRVDataCalc["Mood"]    = 101;
                HRVDataCalc["HRVMark"] = hrvMarkArr;//事件标记

                //开始数据库操作
                //lich
                if (UserInfoStatic.ipAdd != null)
                {
                    hrvdb.OnInsertHRVDataAndEpData(HRVData, EPData, hrvMarkArr, HRVDataCalc, PPGData, "2");
                }
                else
                {
                    UserHrvRecord hrvRecord = new UserHrvRecord();
                    hrvRecord.HRVData  = HRVData;
                    hrvRecord.EPData   = EPData;
                    hrvRecord.MarkData = hrvMarkArr;
                    hrvRecord.PWRData  = (ArrayList)HRVDataCalc["FS"];
                    hrvRecord.TimeData.Add(HRVDataCalc["fMean"]);
                    hrvRecord.TimeData.Add(HRVDataCalc["fStdDev"]);
                    hrvRecord.TimeData.Add(HRVDataCalc["fSDNN"]);
                    hrvRecord.TimeData.Add(HRVDataCalc["fRMSSD"]);
                    hrvRecord.TimeData.Add(HRVDataCalc["fSD"]);
                    hrvRecord.TimeData.Add(HRVDataCalc["fSDSD"]);
                    hrvRecord.TimeData.Add(HRVDataCalc["fPNN"]);
                    hrvRecord.FreData.Add(HRVDataCalc["tp"]);
                    hrvRecord.FreData.Add(HRVDataCalc["vlf"]);
                    hrvRecord.FreData.Add(HRVDataCalc["lf"]);
                    hrvRecord.FreData.Add(HRVDataCalc["hf"]);
                    hrvRecord.FreData.Add(HRVDataCalc["lhr"]);
                    hrvRecord.FreData.Add(HRVDataCalc["lfnorm"]);
                    hrvRecord.FreData.Add(HRVDataCalc["hfnorm"]);
                    hrvRecord.AnsBalance = Convert.ToDouble(HRVDataCalc["NB"]);
                    hrvRecord.Pressure   = Convert.ToDouble(HRVDataCalc["Pressure"]);
                    hrvRecord.Adjust     = Convert.ToDouble(HRVDataCalc["adjust"]);
                    hrvRecord.Stable     = Convert.ToDouble(HRVDataCalc["stable"]);
                    hrvRecord.Score      = Convert.ToDouble(HRVDataCalc["score"]);
                    hrvRecord.HrvScore   = Convert.ToDouble(HRVDataCalc["HRVScore"]);
                    hrvRecord.TimeLength = Convert.ToDouble(HRVData.Count / 2.0);
                    hrvRecord.StartTime  = Convert.ToDateTime(HRVDataCalc["StartTime"]);
                    hrvRecord.EndTime    = Convert.ToDateTime(HRVDataCalc["EndTime"]);
                    hrvRecord.RecordType = Convert.ToInt32(HRVDataCalc["TimeType"]);
                    hrvRecord.Mood       = Convert.ToInt32(HRVDataCalc["Mood"]);
                    hrvRecord.Report     = Convert.ToString(HRVDataCalc["report"]);

                    MainRightPerson.TmpHrvRecord.Add(hrvRecord);
                }
            }
            //Console.WriteLine("游戏结果:" + pList[0].InnerText);
            // Console.WriteLine("游戏得分:" + pList[1].InnerText);
            // Console.WriteLine("剩余秒数(游戏总长300s):" + pList[2].InnerText);

            //标记当前节点
            //XmlNode currentNode;
            //遍历所有二级节点
            //for (int i = 0; i < list[0].ChildNodes.Count; i++)
            //{
            //二级
            // currentNode = list[0].ChildNodes[i];
            //currentNode.child
            // }
        }
        ///// <summary>
        ///// 退出游戏
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //public void quietGame(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEvent e)
        //{
        //    OnStopAllTimerAndHD();
        //    host = null;
        //    shockwave = null;
        //    this.Close();
        //}

        public void flash_FlashCall(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEvent e)
        {
            ArrayList paraList = GetParaList(e.request);

            if (paraList[0].Equals("startGame"))
            {
                //开始游戏
                XmlDocument document = new XmlDocument();
                document.LoadXml(e.request);
                // get attributes to see which command flash is trying to call
                XmlAttributeCollection attributes = document.FirstChild.Attributes;

                // get function
                String command = attributes.Item(0).InnerText;

                // get parameters
                XmlNodeList list = document.GetElementsByTagName("arguments");

                isGameStart = true;
                HRVData     = new ArrayList(); //初始化HRV曲线数组
                EPData      = new ArrayList(); //初始化EP数组
                IBIData     = new ArrayList(); //初始化IBI数组
                PPGData     = new ArrayList(); //初始化PPG数组
                hrvMarkArr  = new ArrayList(); //初始化时间标记数组

                //               MessageBox.Show("开始游戏");
            }
            else if (paraList[0].Equals("endGame"))
            {
                //结束游戏
//                MessageBox.Show("结束游戏");

                isGameStart = false;
                if (HRVData.Count > 128)
                {
                    HMMath    hdMath      = new HMMath(HRVData, EPData); //计算14项数据,调节指数,稳定指数,综合得分和给出评价报告
                    Hashtable HRVDataCalc = hdMath.HRVCalc();            //用于存放HRV测量后计算的相关数据
                    //                HRVDataCalc["HRVScore"] = EPScore;//HRV得分
                    HRVDataCalc["HRVScore"]  = 0;
                    HRVDataCalc["Time"]      = (Single)HRVData.Count / 2.0;  //测试时间,单位是秒
                    HRVDataCalc["EndTime"]   = DateTime.Now;                 //结束时间,datetime格式
                    HRVDataCalc["StartTime"] = startTime;                    //开始时间,datetime格式
                    //                HRVDataCalc["TimeType"] = this.SelectComboBox + 1;//HRV检测时间类型
                    HRVDataCalc["TimeType"] = Convert.ToInt32(tInfo["tid"]); //HRV检测时间类型
                    //                HRVDataCalc["Mood"] = this.systemMeg["Mood"];//测量时心情状态
                    HRVDataCalc["Mood"]    = 101;
                    HRVDataCalc["HRVMark"] = hrvMarkArr;//事件标记

                    //开始数据库操作
                    //lich
                    if (UserInfoStatic.ipAdd != null)
                    {
                        hrvdb.OnInsertHRVDataAndEpData(HRVData, EPData, hrvMarkArr, HRVDataCalc, PPGData, "2");
                    }
                    else
                    {
                        UserHrvRecord hrvRecord = new UserHrvRecord();
                        hrvRecord.HRVData  = HRVData;
                        hrvRecord.EPData   = EPData;
                        hrvRecord.MarkData = hrvMarkArr;
                        hrvRecord.PWRData  = (ArrayList)HRVDataCalc["FS"];
                        hrvRecord.TimeData.Add(HRVDataCalc["fMean"]);
                        hrvRecord.TimeData.Add(HRVDataCalc["fStdDev"]);
                        hrvRecord.TimeData.Add(HRVDataCalc["fSDNN"]);
                        hrvRecord.TimeData.Add(HRVDataCalc["fRMSSD"]);
                        hrvRecord.TimeData.Add(HRVDataCalc["fSD"]);
                        hrvRecord.TimeData.Add(HRVDataCalc["fSDSD"]);
                        hrvRecord.TimeData.Add(HRVDataCalc["fPNN"]);
                        hrvRecord.FreData.Add(HRVDataCalc["tp"]);
                        hrvRecord.FreData.Add(HRVDataCalc["vlf"]);
                        hrvRecord.FreData.Add(HRVDataCalc["lf"]);
                        hrvRecord.FreData.Add(HRVDataCalc["hf"]);
                        hrvRecord.FreData.Add(HRVDataCalc["lhr"]);
                        hrvRecord.FreData.Add(HRVDataCalc["lfnorm"]);
                        hrvRecord.FreData.Add(HRVDataCalc["hfnorm"]);
                        hrvRecord.AnsBalance = Convert.ToDouble(HRVDataCalc["NB"]);
                        hrvRecord.Pressure   = Convert.ToDouble(HRVDataCalc["Pressure"]);
                        hrvRecord.Adjust     = Convert.ToDouble(HRVDataCalc["adjust"]);
                        hrvRecord.Stable     = Convert.ToDouble(HRVDataCalc["stable"]);
                        hrvRecord.Score      = Convert.ToDouble(HRVDataCalc["score"]);
                        hrvRecord.HrvScore   = Convert.ToDouble(HRVDataCalc["HRVScore"]);
                        hrvRecord.TimeLength = Convert.ToDouble(HRVData.Count / 2.0);
                        hrvRecord.StartTime  = Convert.ToDateTime(HRVDataCalc["StartTime"]);
                        hrvRecord.EndTime    = Convert.ToDateTime(HRVDataCalc["EndTime"]);
                        hrvRecord.RecordType = Convert.ToInt32(HRVDataCalc["TimeType"]);
                        hrvRecord.Mood       = Convert.ToInt32(HRVDataCalc["Mood"]);
                        hrvRecord.Report     = Convert.ToString(HRVDataCalc["report"]);

                        MainRightPerson.TmpHrvRecord.Add(hrvRecord);
                    }
                }
            }
            else if (paraList[0].Equals("quietGame"))
            {
                //退出游戏
                OnStopAllTimerAndHD();
                host      = null;
                shockwave = null;
                this.Close();
            }
        }
Beispiel #8
0
        /// <summary>
        /// 分页处理
        /// </summary>
        /// <param name="page">当前的页号</param>
        /// <param name="num">每页的条数</param>
        private void OnDataOrPageChanged(int page, int num)
        {
            //            Hashtable[] tmpArr = new Hashtable[num];
            if (_showType == 1)
            {
                this.HrvDataGrid.Visibility   = Visibility.Visible;
                this.TrainDataGrid.Visibility = Visibility.Hidden;
                this.RelaxDataGrid.Visibility = Visibility.Hidden;

                _totalPage = Math.Ceiling(Convert.ToDouble(HrvHistoryArr.Count / Convert.ToDouble(_num)));

                this.PreviousButton.IsEnabled = true;
                this.NextButton.IsEnabled     = true;
                if (_nowPage == 1)
                {
                    this.PreviousButton.IsEnabled = false;
                }
                if (_nowPage == _totalPage)
                {
                    this.NextButton.IsEnabled = false;
                }
                if (HrvHistoryArr.Count / Convert.ToDouble(_num) > 1)
                {
                    // this.pageText.Content = "1 / " + _totalPage.ToString();
                    this.GotoPage.IsEnabled   = true;
                    this.JumpButton.IsEnabled = true;
                }
                else
                {
                    //this.pageText.Content = "1 / 1";
                    this.GotoPage.IsEnabled   = false;
                    this.JumpButton.IsEnabled = false;
                }

                UserHrvRecord[] tmpArr = new UserHrvRecord[num];
                if (HrvHistoryArr.Count <= num)
                {
                    HrvHistoryArr.CopyTo(tmpArr);
                }
                else
                {
                    if (Math.Ceiling(Convert.ToDouble(HrvHistoryArr.Count / Convert.ToDouble(num))) < page)
                    {
                        page       -= 1;
                        _totalPage -= 1;
                    }
                    if (page * num > HrvHistoryArr.Count && page == _totalPage)
                    {
                        int count = HrvHistoryArr.Count - ((page - 1) * num);
                        HrvHistoryArr.CopyTo((page - 1) * num, tmpArr, 0, count);
                    }
                    else
                    {
                        HrvHistoryArr.CopyTo((page - 1) * num, tmpArr, 0, num);
                    }
                }
                List <HRVRecordData> dataGridSource = new List <HRVRecordData>();

                //           for (int i = 0; i < tmpArr.Length; i++)
                for (int i = tmpArr.Length - 1; i >= 0; i--)
                {
                    //               Hashtable tmp = tmpArr[i];
                    UserHrvRecord tmp = tmpArr[i];
                    if (tmp != null)
                    {
                        string strType = "";
                        if (tmp.RecordType == 1)
                        {
                            strType = "基线测试";
                        }
                        else if (tmp.RecordType == 2)
                        {
                            strType = "5分钟测试";
                        }
                        else if (tmp.RecordType == 3)
                        {
                            strType = "10分钟测试";
                        }
                        dataGridSource.Add(new HRVRecordData()
                        {
                            Id      = tmp.Id,
                            Checked = false,
                            Index   = (page - 1) * num + i + 1,
                            // Type = tmp.RecordType.ToString(),
                            Type       = strType,
                            StartTime  = tmp.StartTime.ToString(),
                            TotalTime  = MathTime((int)tmp.TimeLength),
                            HrvScore   = Convert.ToInt32(tmp.HrvScore).ToString(),
                            Adjust     = Convert.ToInt32(tmp.Adjust).ToString(),
                            Stable     = Convert.ToInt32(tmp.Stable).ToString(),
                            Pressure   = Convert.ToInt32(tmp.Pressure).ToString(),
                            TotalScore = Convert.ToInt32(tmp.Score).ToString()
                        });
                        dataGridSource = getSortList(dataGridSource);
                    }
                }

                this.pageText.Content        = page.ToString() + " / " + _totalPage.ToString();
                this.HrvDataGrid.DataContext = dataGridSource;
            }
            else if (_showType == 2)
            {
                this.HrvDataGrid.Visibility   = Visibility.Hidden;
                this.TrainDataGrid.Visibility = Visibility.Visible;
                this.RelaxDataGrid.Visibility = Visibility.Hidden;

                _totalPage = Math.Ceiling(Convert.ToDouble(TrainHistoryArr.Count / Convert.ToDouble(_num)));

                this.PreviousButton.IsEnabled = true;
                this.NextButton.IsEnabled     = true;
                if (_nowPage == 1)
                {
                    this.PreviousButton.IsEnabled = false;
                }
                if (_nowPage == _totalPage)
                {
                    this.NextButton.IsEnabled = false;
                }
                if (TrainHistoryArr.Count / Convert.ToDouble(_num) > 1)
                {
                    // this.pageText.Content = "1 / " + _totalPage.ToString();
                    this.GotoPage.IsEnabled   = true;
                    this.JumpButton.IsEnabled = true;
                }
                else
                {
                    //this.pageText.Content = "1 / 1";
                    this.GotoPage.IsEnabled   = false;
                    this.JumpButton.IsEnabled = false;
                }

                UserHrvRecord[] tmpArr = new UserHrvRecord[num];
                if (TrainHistoryArr.Count <= num)
                {
                    TrainHistoryArr.CopyTo(tmpArr);
                }
                else
                {
                    if (Math.Ceiling(Convert.ToDouble(TrainHistoryArr.Count / Convert.ToDouble(num))) < page)
                    {
                        page       -= 1;
                        _totalPage -= 1;
                    }
                    if (page * num > TrainHistoryArr.Count && page == _totalPage)
                    {
                        int count = TrainHistoryArr.Count - ((page - 1) * num);
                        TrainHistoryArr.CopyTo((page - 1) * num, tmpArr, 0, count);
                    }
                    else
                    {
                        TrainHistoryArr.CopyTo((page - 1) * num, tmpArr, 0, num);
                    }
                }
                List <HRVRecordData> dataGridSource = new List <HRVRecordData>();

                //           for (int i = 0; i < tmpArr.Length; i++)
                for (int i = tmpArr.Length - 1; i >= 0; i--)
                {
                    //               Hashtable tmp = tmpArr[i];
                    UserHrvRecord tmp = tmpArr[i];
                    if (tmp != null)
                    {
                        string strType = "";

                        if (tmp.RecordType == 61)
                        {
                            strType = "荷韵";
                        }
                        else if (tmp.RecordType == 62)
                        {
                            strType = "梅花";
                        }
                        else if (tmp.RecordType == 63)
                        {
                            strType = "丝绸之路";
                        }
                        else if (tmp.RecordType == 64)
                        {
                            strType = "菩提树";
                        }
                        else if (tmp.RecordType == 65)
                        {
                            strType = "生命之泉";
                        }
                        else if (tmp.RecordType == 66)
                        {
                            strType = "星空";
                        }
                        else if (tmp.RecordType == 41)
                        {
                            strType = "挪来移去";
                        }
                        else if (tmp.RecordType == 42)
                        {
                            strType = "看图绘画";
                        }
                        else if (tmp.RecordType == 43)
                        {
                            strType = "边缘视力";
                        }
                        else if (tmp.RecordType == 44)
                        {
                            strType = "多彩球";
                        }
                        else if (tmp.RecordType == 45)
                        {
                            strType = "方向瞬记";
                        }
                        else if (tmp.RecordType == 46)
                        {
                            strType = "以此类推";
                        }
                        else if (tmp.RecordType == 70)
                        {
                            strType = "神笔马良";
                        }
                        else if (tmp.RecordType == 71)
                        {
                            strType = "冒险岛";
                        }
                        else if (tmp.RecordType == 72)
                        {
                            strType = "射箭";
                        }
                        else if (tmp.RecordType == 20)
                        {
                            strType = "情境仿真";
                        }
                        else
                        {
                            strType = tmp.RecordType.ToString();
                        }
                        dataGridSource.Add(new HRVRecordData()
                        {
                            Id      = tmp.Id,
                            Checked = false,
                            Index   = (page - 1) * num + i + 1,
                            //Type = tmp.RecordType.ToString(),
                            Type       = strType,
                            StartTime  = tmp.StartTime.ToString(),
                            TotalTime  = MathTime((int)tmp.TimeLength),
                            HrvScore   = Convert.ToInt32(tmp.HrvScore).ToString(),
                            Adjust     = Convert.ToInt32(tmp.Adjust).ToString(),
                            Stable     = Convert.ToInt32(tmp.Stable).ToString(),
                            Pressure   = Convert.ToInt32(tmp.Pressure).ToString(),
                            TotalScore = Convert.ToInt32(tmp.Score).ToString()
                        });
                        dataGridSource = getSortList(dataGridSource);
                    }
                }

                this.pageText.Content          = page.ToString() + " / " + _totalPage.ToString();
                this.TrainDataGrid.DataContext = dataGridSource;
            }
            else
            {
                this.HrvDataGrid.Visibility   = Visibility.Hidden;
                this.TrainDataGrid.Visibility = Visibility.Hidden;
                this.RelaxDataGrid.Visibility = Visibility.Visible;

                _totalPage = Math.Ceiling(Convert.ToDouble(RelaxHistoryArr.Count / Convert.ToDouble(_num)));

                this.PreviousButton.IsEnabled = true;
                this.NextButton.IsEnabled     = true;
                if (_nowPage == 1)
                {
                    this.PreviousButton.IsEnabled = false;
                }
                if (_nowPage == _totalPage)
                {
                    this.NextButton.IsEnabled = false;
                }
                if (RelaxHistoryArr.Count / Convert.ToDouble(_num) > 1)
                {
                    // this.pageText.Content = "1 / " + _totalPage.ToString();
                    this.GotoPage.IsEnabled   = true;
                    this.JumpButton.IsEnabled = true;
                }
                else
                {
                    //this.pageText.Content = "1 / 1";
                    this.GotoPage.IsEnabled   = false;
                    this.JumpButton.IsEnabled = false;
                }

                UserHrvRecord[] tmpArr = new UserHrvRecord[num];
                if (RelaxHistoryArr.Count <= num)
                {
                    RelaxHistoryArr.CopyTo(tmpArr);
                }
                else
                {
                    if (Math.Ceiling(Convert.ToDouble(RelaxHistoryArr.Count / Convert.ToDouble(num))) < page)
                    {
                        page       -= 1;
                        _totalPage -= 1;
                    }
                    if (page * num > RelaxHistoryArr.Count && page == _totalPage)
                    {
                        int count = RelaxHistoryArr.Count - ((page - 1) * num);
                        RelaxHistoryArr.CopyTo((page - 1) * num, tmpArr, 0, count);
                    }
                    else
                    {
                        RelaxHistoryArr.CopyTo((page - 1) * num, tmpArr, 0, num);
                    }
                }
                List <HRVRecordData> dataGridSource = new List <HRVRecordData>();

                //           for (int i = 0; i < tmpArr.Length; i++)
                for (int i = tmpArr.Length - 1; i >= 0; i--)
                {
                    //               Hashtable tmp = tmpArr[i];
                    UserHrvRecord tmp = tmpArr[i];
                    if (tmp != null)
                    {
                        dataGridSource.Add(new HRVRecordData()
                        {
                            Id      = tmp.Id,
                            Checked = false,
                            Index   = (page - 1) * num + i + 1,
                            // Type = tmp.RecordType.ToString(),
                            Type       = "放松训练",
                            StartTime  = tmp.StartTime.ToString(),
                            TotalTime  = MathTime((int)tmp.TimeLength),
                            HrvScore   = Convert.ToInt32(tmp.HrvScore).ToString(),
                            Adjust     = Convert.ToInt32(tmp.Adjust).ToString(),
                            Stable     = Convert.ToInt32(tmp.Stable).ToString(),
                            Pressure   = Convert.ToInt32(tmp.Pressure).ToString(),
                            TotalScore = Convert.ToInt32(tmp.Score).ToString()
                        });
                        dataGridSource = getSortList(dataGridSource);
                    }
                }

                this.pageText.Content          = page.ToString() + " / " + _totalPage.ToString();
                this.RelaxDataGrid.DataContext = dataGridSource;
            }
        }