Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Streaming.cs
00001 using System; 00002 using System.Collections.Generic; 00003 using System.Linq; 00004 using System.Text; 00005 using System.ComponentModel; 00006 using System.Collections; 00007 00008 namespace HealthSensorPlatform 00009 { 00010 class Streaming 00011 { 00012 BackgroundWorker _testWorker; 00013 00014 public ArrayList ArrayListRed = new ArrayList(); 00015 public ArrayList ArrayListIR = new ArrayList(); 00016 public ArrayList ArrayListGreen = new ArrayList(); 00017 public event EventHandler<PartialArrayIntAvailableEventArgs> PartialArrayIntAvailable; 00018 00019 public void Init() 00020 { 00021 _testWorker = new BackgroundWorker(); 00022 _testWorker.WorkerSupportsCancellation = true; 00023 _testWorker.ProgressChanged += new ProgressChangedEventHandler(_testWorker_ProgressChanged); 00024 _testWorker.DoWork += new DoWorkEventHandler(_testWorker_DoWork); 00025 _testWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_testWorker_RunWorkerCompleted); 00026 _testWorker.WorkerReportsProgress = true; 00027 } 00028 00029 protected virtual void OnPartialArrayIntAvailable(PartialArrayIntAvailableEventArgs e) 00030 { 00031 EventHandler<PartialArrayIntAvailableEventArgs> handler = PartialArrayIntAvailable; 00032 if (handler != null) 00033 { 00034 handler(this, e); 00035 } 00036 } 00037 00038 public void Start() 00039 { 00040 ArrayListRed.Clear(); 00041 ArrayListIR.Clear(); 00042 ArrayListGreen.Clear(); 00043 _testWorker.RunWorkerAsync(); 00044 } 00045 public void Stop() 00046 { 00047 _testWorker.CancelAsync(); 00048 } 00049 void _testWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) 00050 { 00051 var data = (System.Tuple<int, int, int[], int[], int[]>)(e.UserState); 00052 int reportID = data.Item1; 00053 int sampleNumberOffset = data.Item2; 00054 int[] list1_Red___or_X = data.Item3; 00055 int[] list2_IR____or_Y = data.Item4; 00056 int[] list3_Green_or_Z = data.Item5; 00057 00058 for (int index = 0; index < list1_Red___or_X.Length; index++) 00059 { 00060 ArrayListRed.Add(list1_Red___or_X[index]); 00061 } 00062 for (int index = 0; index < list2_IR____or_Y.Length; index++) 00063 { 00064 ArrayListIR.Add(list2_IR____or_Y[index]); 00065 } 00066 for (int index = 0; index < list3_Green_or_Z.Length; index++) 00067 { 00068 ArrayListGreen.Add(list3_Green_or_Z[index]); 00069 } 00070 00071 // https://jira.maxim-ic.com/browse/OS24EVK-59 matlab: PartialArrayIntAvailable based on PartialDataBufferAvailable of r14194 (broken) 00072 // https://jira.maxim-ic.com/browse/OS24EVK-59 matlab: What about using System.Array<int> instead of System.Collections.ArrayList? 00073 // https://jira.maxim-ic.com/browse/OS24EVK-59 matlab: Changed PartialDataBufferAvailableEventArgs and FinalDataBufferAvailableEventArgs to use int[] rawRedData, int[] rawIRData, int[] rawGreenData 00074 // int[] RawRedData replaces ArrayList ArrayListRed 00075 // example: https://jira.maxim-ic.com/browse/OS24EVK-59 standard event handler: Fire the PartialArrayIntAvailable event 00076 OnPartialArrayIntAvailable(new PartialArrayIntAvailableEventArgs() 00077 { 00078 sampleNumberOffset = sampleNumberOffset, 00079 rawRedData = (int[])ArrayListRed.ToArray(typeof(int)), 00080 rawIRData = (int[])ArrayListIR.ToArray(typeof(int)), 00081 rawGreenData = (int[])ArrayListGreen.ToArray(typeof(int)) 00082 }); 00083 } 00084 private void _testWorker_DoWork(object sender, DoWorkEventArgs e) 00085 { 00086 while (true) 00087 { 00088 if (_testWorker.CancellationPending) 00089 { 00090 return; 00091 } 00092 } 00093 } 00094 void _testWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) 00095 { 00096 } 00097 } 00098 }
Generated on Tue Jul 12 2022 21:52:40 by
1.7.2