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