Exemplo n.º 1
0
        //Server Comm
        public async void GetDataFromServer()
        {
            //Get All MetaData From server
            FlaskCommunication flaskcom = new FlaskCommunication();
            Tuple <HttpStatusCode, SoundDataModel> data = await flaskcom.GetAllMetaData();

            List <SoundDataModel.SoundData> SoundList = null;

            if (data.Item1 == HttpStatusCode.OK)
            {
                SoundList = data.Item2.SoundDatas; //Get List of SoundData
            }

            //Test Populate List View
            PopupListView view = new PopupListView(SoundList); //Generate Form with list data

            view.ShowDialog();
            //Get Selected MetaData Object
            Tuple <HttpStatusCode, byte []> seldata = await flaskcom.GetSoundFile(view.SelectedRecord);

            if (seldata.Item1 == HttpStatusCode.OK)
            {
                SoundData.Clear();
                this.PlotServerData(seldata.Item2);
                //Analyze if Needed
                if (view.Analyze)
                {
                    Tuple <HttpStatusCode, SoundDataModel.AnalysisResult> analyzeres = await flaskcom.GetAnalysisResult(view.SelectedRecord);

                    if (analyzeres.Item1 == HttpStatusCode.OK)
                    {
                        switch (analyzeres.Item2.Result)
                        {
                        case 0:
                            MessageBox.Show("Analysis Done - Abnormal Heart");
                            break;

                        case 1:
                            MessageBox.Show("Analysis Done - Healthy Heart");
                            break;

                        default:
                            MessageBox.Show("Numpy File Not found");
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        //Server Comm
        public async void SaveResultToServer()
        {
            long fileLength             = new FileInfo(outputfile).Length; //Get file length
            FlaskCommunication flaskcom = new FlaskCommunication();

            //Send File to server
            Console.WriteLine("Adding MetaData to Server");
            Tuple <HttpStatusCode, SoundDataModel.SoundData> data = await flaskcom.PostMetaData("HeartData", fileLength);

            if (data.Item1 == HttpStatusCode.OK)
            {
                HttpStatusCode fileupload = await flaskcom.PostFile(outputfile, fileLength,
                                                                    data.Item2.Id);

                if (fileupload != HttpStatusCode.OK)
                {
                    MessageBox.Show("Failed to save file to server");
                }
            }
        }