Skip to content

Commit ba95d85

Browse files
committed
Add SPO2 channel
1 parent baa931d commit ba95d85

6 files changed

Lines changed: 246 additions & 72 deletions

File tree

ESP-SPO2/Channels/AvgBPM.cs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,40 @@
33

44
namespace lucidcode.LucidScribe.Plugin.ESPSPO2
55
{
6-
namespace lucidcode.LucidScribe.Plugin.ESPSPO2
6+
namespace AvgBPM
77
{
8-
namespace AvgBPM
8+
public class PluginHandler : Interface.LucidPluginBase
99
{
10-
public class PluginHandler : Interface.LucidPluginBase
11-
{
12-
public override string Name { get { return "ESP Avg BPM"; } }
10+
public override string Name { get { return "ESP Avg BPM"; } }
1311

14-
public override bool Initialize()
12+
public override bool Initialize()
13+
{
14+
try
1515
{
16-
try
17-
{
18-
return Device.Initialize();
19-
}
20-
catch (Exception ex)
21-
{
22-
throw (new Exception("The '" + Name + "' plugin failed to initialize: " + ex.Message));
23-
}
16+
return Device.Initialize();
2417
}
25-
26-
public override double Value
18+
catch (Exception ex)
2719
{
28-
get
29-
{
30-
return Device.GetAvgBpm();
31-
}
20+
throw (new Exception("The '" + Name + "' plugin failed to initialize: " + ex.Message));
3221
}
22+
}
3323

34-
public override void Dispose()
24+
public override double Value
25+
{
26+
get
3527
{
36-
Device.Dispose();
28+
return Device.GetAvgBpm();
3729
}
3830
}
31+
32+
public override void Dispose()
33+
{
34+
Device.Dispose();
35+
}
3936
}
37+
}
4038

41-
namespace AvgBpmRaw
39+
namespace AvgBpmRaw
4240
{
4341
public class PluginHandler : Interface.ILluminatedPlugin
4442
{
@@ -153,5 +151,4 @@ public int LastHour
153151
}
154152
}
155153
}
156-
}
157154
}

ESP-SPO2/Channels/BPM.cs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,40 @@
33

44
namespace lucidcode.LucidScribe.Plugin.ESPSPO2
55
{
6-
namespace lucidcode.LucidScribe.Plugin.ESPSPO2
6+
namespace Bpm
77
{
8-
namespace Bpm
8+
public class PluginHandler : Interface.LucidPluginBase
99
{
10-
public class PluginHandler : Interface.LucidPluginBase
11-
{
12-
public override string Name { get { return "ESP BPM"; } }
10+
public override string Name { get { return "ESP BPM"; } }
1311

14-
public override bool Initialize()
12+
public override bool Initialize()
13+
{
14+
try
1515
{
16-
try
17-
{
18-
return Device.Initialize();
19-
}
20-
catch (Exception ex)
21-
{
22-
throw (new Exception("The '" + Name + "' plugin failed to initialize: " + ex.Message));
23-
}
16+
return Device.Initialize();
2417
}
25-
26-
public override double Value
18+
catch (Exception ex)
2719
{
28-
get
29-
{
30-
return Device.GetBpm();
31-
}
20+
throw (new Exception("The '" + Name + "' plugin failed to initialize: " + ex.Message));
3221
}
22+
}
3323

34-
public override void Dispose()
24+
public override double Value
25+
{
26+
get
3527
{
36-
Device.Dispose();
28+
return Device.GetBpm();
3729
}
3830
}
31+
32+
public override void Dispose()
33+
{
34+
Device.Dispose();
35+
}
3936
}
37+
}
4038

41-
namespace BpmRaw
39+
namespace BpmRaw
4240
{
4341
public class PluginHandler : Interface.ILluminatedPlugin
4442
{
@@ -153,5 +151,4 @@ public int LastHour
153151
}
154152
}
155153
}
156-
}
157154
}

ESP-SPO2/Channels/IR.cs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,40 @@
33

44
namespace lucidcode.LucidScribe.Plugin.ESPSPO2
55
{
6-
namespace lucidcode.LucidScribe.Plugin.ESPSPO2
6+
namespace Ir
77
{
8-
namespace Ir
8+
public class PluginHandler : Interface.LucidPluginBase
99
{
10-
public class PluginHandler : Interface.LucidPluginBase
11-
{
12-
public override string Name { get { return "ESP IR"; } }
10+
public override string Name { get { return "ESP IR"; } }
1311

14-
public override bool Initialize()
12+
public override bool Initialize()
13+
{
14+
try
1515
{
16-
try
17-
{
18-
return Device.Initialize();
19-
}
20-
catch (Exception ex)
21-
{
22-
throw (new Exception("The '" + Name + "' plugin failed to initialize: " + ex.Message));
23-
}
16+
return Device.Initialize();
2417
}
25-
26-
public override double Value
18+
catch (Exception ex)
2719
{
28-
get
29-
{
30-
return Device.GetIr();
31-
}
20+
throw (new Exception("The '" + Name + "' plugin failed to initialize: " + ex.Message));
3221
}
22+
}
3323

34-
public override void Dispose()
24+
public override double Value
25+
{
26+
get
3527
{
36-
Device.Dispose();
28+
return Device.GetIr();
3729
}
3830
}
31+
32+
public override void Dispose()
33+
{
34+
Device.Dispose();
35+
}
3936
}
37+
}
4038

41-
namespace IrRaw
39+
namespace IrRaw
4240
{
4341
public class PluginHandler : Interface.ILluminatedPlugin
4442
{
@@ -153,5 +151,4 @@ public int LastHour
153151
}
154152
}
155153
}
156-
}
157154
}

ESP-SPO2/Channels/SPO2.cs

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
using System;
2+
using System.Drawing;
3+
4+
namespace lucidcode.LucidScribe.Plugin.ESPSPO2
5+
{
6+
namespace Spo2
7+
{
8+
public class PluginHandler : Interface.LucidPluginBase
9+
{
10+
public override string Name { get { return "ESP SPO2"; } }
11+
12+
public override bool Initialize()
13+
{
14+
try
15+
{
16+
return Device.Initialize();
17+
}
18+
catch (Exception ex)
19+
{
20+
throw (new Exception("The '" + Name + "' plugin failed to initialize: " + ex.Message));
21+
}
22+
}
23+
24+
public override double Value
25+
{
26+
get
27+
{
28+
return Device.GetSpo2();
29+
}
30+
}
31+
32+
public override void Dispose()
33+
{
34+
Device.Dispose();
35+
}
36+
}
37+
}
38+
39+
namespace Spo2Raw
40+
{
41+
public class PluginHandler : Interface.ILluminatedPlugin
42+
{
43+
public string Name { get { return "ESP SPO2 Raw"; } }
44+
45+
public bool Initialize()
46+
{
47+
try
48+
{
49+
bool initialized = Device.Initialize();
50+
Device.Spo2Changed += Spo2Changed;
51+
return initialized;
52+
}
53+
catch (Exception ex)
54+
{
55+
throw (new Exception("The '" + Name + "' plugin failed to initialize: " + ex.Message));
56+
}
57+
}
58+
59+
public event Interface.SenseHandler Sensed;
60+
public void Spo2Changed(object sender, EventArgs e)
61+
{
62+
if (ClearBuffer)
63+
{
64+
ClearBuffer = false;
65+
BufferData = "";
66+
}
67+
if (BufferData.Length > 8096) return;
68+
69+
BufferData += sender + ",";
70+
if (ClearTicks)
71+
{
72+
ClearTicks = false;
73+
TickCount = "";
74+
}
75+
TickCount += sender + ",";
76+
}
77+
78+
public void Dispose()
79+
{
80+
Device.Spo2Changed -= Spo2Changed;
81+
Device.Dispose();
82+
}
83+
84+
public Boolean isEnabled = false;
85+
public Boolean Enabled
86+
{
87+
get
88+
{
89+
return isEnabled;
90+
}
91+
set
92+
{
93+
isEnabled = value;
94+
}
95+
}
96+
97+
public Color PluginColor = Color.White;
98+
public Color Color
99+
{
100+
get
101+
{
102+
return Color;
103+
}
104+
set
105+
{
106+
Color = value;
107+
}
108+
}
109+
110+
private Boolean ClearTicks = false;
111+
public String TickCount = "";
112+
public String Ticks
113+
{
114+
get
115+
{
116+
ClearTicks = true;
117+
return TickCount;
118+
}
119+
set
120+
{
121+
TickCount = value;
122+
}
123+
}
124+
125+
private Boolean ClearBuffer = false;
126+
public String BufferData = "";
127+
public String Buffer
128+
{
129+
get
130+
{
131+
ClearBuffer = true;
132+
return BufferData;
133+
}
134+
set
135+
{
136+
BufferData = value;
137+
}
138+
}
139+
140+
int lastHour;
141+
public int LastHour
142+
{
143+
get
144+
{
145+
return lastHour;
146+
}
147+
set
148+
{
149+
lastHour = value;
150+
}
151+
}
152+
}
153+
}
154+
}

ESP-SPO2/ESP-SPO2.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
<ItemGroup>
6565
<Compile Include="Channels\BPM.cs" />
6666
<Compile Include="Channels\AvgBPM.cs" />
67+
<Compile Include="Channels\SPO2.cs" />
6768
<Compile Include="Channels\REM.cs" />
6869
<Compile Include="Channels\IR.cs" />
6970
<Compile Include="PluginHandler.cs" />

0 commit comments

Comments
 (0)