Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 132 additions & 46 deletions Halovision/PluginHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,27 @@ public static void SetTossValue(int value)
{
visionForm.TossValue = value;
}

public static int GetEyeMoveMin()
{
return visionForm.EyeMoveMin;
}

public static int GetEyeMoveMax()
{
return visionForm.EyeMoveMax;
}
}

namespace Vision
namespace EyeMin
{
public class PluginHandler : lucidcode.LucidScribe.Interface.LucidPluginBase
{
public override string Name
{
get
{
return "Halovision";
return "Eye Move Min";
}
}

Expand All @@ -123,10 +133,106 @@ public override double Value
{
get
{
double tempValue = Device.GetVision();
if (tempValue > 999) { tempValue = 999; }
if (tempValue < 0) { tempValue = 0; }
return tempValue;
return Device.GetEyeMoveMin();
}
}

public override void Dispose()
{
Device.Dispose();
}
}
}

namespace EyeMax
{
public class PluginHandler : lucidcode.LucidScribe.Interface.LucidPluginBase
{
public override string Name
{
get
{
return "Eye Move Max";
}
}

public override bool Initialize()
{
try
{
return Device.Initialize();
}
catch (Exception ex)
{
throw (new Exception("The '" + Name + "' plugin failed to initialize: " + ex.Message));
}
}

public override double Value
{
get
{
return Device.GetEyeMoveMax();
}
}

public override void Dispose()
{
Device.Dispose();
}
}
}

namespace Toss
{
public class PluginHandler : lucidcode.LucidScribe.Interface.LucidPluginBase
{
List<int> history = new List<int>();

public override string Name
{
get
{
return "Toss";
}
}

public override bool Initialize()
{
try
{
return Device.Initialize();
}
catch (Exception ex)
{
throw (new Exception("The '" + Name + "' plugin failed to initialize: " + ex.Message));
}
}

public override double Value
{
get
{
history.Add(Convert.ToInt32(Device.GetVision()));
if (history.Count > 1000) { history.RemoveAt(0); }

int tossValue = 0;
for (int i = 0; i < history.Count; i++)
{
if (history[i] > Device.GetTossThreshold())
{
tossValue = 999;
}
tossValue = tossValue - Device.GetTossHalfLife();
}

if (tossValue < 0)
{
tossValue = 0;
}

Device.SetTossValue(tossValue);
return tossValue;
}
}

Expand Down Expand Up @@ -174,6 +280,9 @@ public override double Value
return 0;
}

int eyeMoveMin = Device.GetEyeMoveMin();
int eyeMoveMax = Device.GetEyeMoveMax();

history.Add(Convert.ToInt32(Device.GetVision()));
if (history.Count > 768) { history.RemoveAt(0); }

Expand All @@ -187,28 +296,29 @@ public override double Value
bool boolDreaming = false;
for (int i = 0; i < history.Count; i++)
{
Double dblValue = history[i];
double value = history[i];

// Check if the last 10 or next 10 were 1000
int lastOrNextOver1000 = 0;
bool overMax = false;
for (int l = i; l > 0 & l > i - 10; l--)
{
if (history[l] > 999)
if (history[l] > eyeMoveMax)
{
lastOrNextOver1000++;
overMax = true;
break;
}
}
for (int n = i; n < history.Count & n < i + 10; n++)
{
if (history[n] > 999)
if (history[n] > eyeMoveMax)
{
lastOrNextOver1000++;
overMax = true;
break;
}
}

if (lastOrNextOver1000 == 0)
if (!overMax)
{
if (dblValue > 8 & dblValue < 999)
if (value > eyeMoveMin & value < eyeMoveMax)
{
intAbove += 1;
intBelow = 0;
Expand All @@ -220,12 +330,6 @@ public override double Value
}
}

if (lastOrNextOver1000 > 10)
{
intBlinks = 0;
}


if (!boolBlinking)
{
if (intAbove >= 1)
Expand Down Expand Up @@ -266,7 +370,6 @@ public override double Value
if (intAbove > 12)
{ // reset
boolBlinking = false;
MessageBox.Show("2");
intBlinks = 0;
intBelow = 0;
intAbove = 0; ;
Expand Down Expand Up @@ -295,17 +398,15 @@ public override void Dispose()
}
}

namespace Toss
namespace Vision
{
public class PluginHandler : lucidcode.LucidScribe.Interface.LucidPluginBase
{
List<int> history = new List<int>();

public override string Name
{
get
{
return "Toss";
return "Halovision";
}
}

Expand All @@ -325,26 +426,10 @@ public override double Value
{
get
{
history.Add(Convert.ToInt32(Device.GetVision()));
if (history.Count > 1000) { history.RemoveAt(0); }

int tossValue = 0;
for (int i = 0; i < history.Count; i++)
{
if (history[i] > Device.GetTossThreshold())
{
tossValue = 999;
}
tossValue = tossValue - Device.GetTossHalfLife();
}

if (tossValue < 0)
{
tossValue = 0;
}

Device.SetTossValue(tossValue);
return tossValue;
double tempValue = Device.GetVision();
if (tempValue > 999) { tempValue = 999; }
if (tempValue < 0) { tempValue = 0; }
return tempValue;
}
}

Expand All @@ -354,4 +439,5 @@ public override void Dispose()
}
}
}

}
6 changes: 3 additions & 3 deletions Halovision/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("lucidcode")]
[assembly: AssemblyProduct("Plugin.Halovision")]
[assembly: AssemblyCopyright("Copyright © lucidcode 2013 - 2020")]
[assembly: AssemblyCopyright("Copyright © lucidcode 2013 - 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.5.0")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyVersion("1.0.9.0")]
[assembly: AssemblyFileVersion("1.0.9.0")]
39 changes: 38 additions & 1 deletion Halovision/VisionForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public partial class VisionForm : Form
public int TossHalfLife = 10;
public int TossValue = 0;

public int EyeMoveMin = 4;
public int EyeMoveMax = 200;

private int PixelSize = 4;
private bool TCMP = false;
private bool RecordVideo = false;
Expand Down Expand Up @@ -157,8 +160,10 @@ private void LoadSettings()
defaultSettings += "<PixelsInARow>4</PixelsInARow>";
defaultSettings += "<FrameThreshold>960</FrameThreshold>";
defaultSettings += "<Sensitivity>0</Sensitivity>";
defaultSettings += "<TossThreshold>999</TossThreshold>";
defaultSettings += "<TossThreshold>800</TossThreshold>";
defaultSettings += "<TossHalfLife>10</TossHalfLife>";
defaultSettings += "<EyeMoveMin>4</EyeMoveMin>";
defaultSettings += "<EyeMoveMax>200</EyeMoveMax>";
defaultSettings += "<IgnorePercentage>16</IgnorePercentage>";
defaultSettings += "<RecordVideo>0</RecordVideo>";
defaultSettings += "<TCMP>0</TCMP>";
Expand Down Expand Up @@ -225,6 +230,24 @@ private void LoadSettings()
tossHalfLifeInput.Value = TossHalfLife;
}

if (xmlSettings.DocumentElement.SelectSingleNode("//EyeMoveMin") != null)
{
eyeMoveMinInput.Value = Convert.ToDecimal(xmlSettings.DocumentElement.SelectSingleNode("//EyeMoveMin").InnerText);
}
else
{
eyeMoveMinInput.Value = EyeMoveMin;
}

if (xmlSettings.DocumentElement.SelectSingleNode("//EyeMoveMax") != null)
{
eyeMoveMaxInput.Value = Convert.ToDecimal(xmlSettings.DocumentElement.SelectSingleNode("//EyeMoveMax").InnerText);
}
else
{
eyeMoveMaxInput.Value = EyeMoveMax;
}

if (xmlSettings.DocumentElement.SelectSingleNode("//TCMP") != null && xmlSettings.DocumentElement.SelectSingleNode("//TCMP").InnerText == "1")
{
chkTCMP.Checked = true;
Expand Down Expand Up @@ -696,6 +719,8 @@ private void SaveSettings()
defaultSettings += "<Sensitivity>" + cmbSensitivity.Text + "</Sensitivity>";
defaultSettings += "<TossThreshold>" + tossThresholdInput.Value + "</TossThreshold>";
defaultSettings += "<TossHalfLife>" + tossHalfLifeInput.Value + "</TossHalfLife>";
defaultSettings += "<EyeMoveMin>" + eyeMoveMinInput.Value + "</EyeMoveMin>";
defaultSettings += "<EyeMoveMax>" + eyeMoveMaxInput.Value + "</EyeMoveMax>";
defaultSettings += "<IgnorePercentage>" + cmbIgnorePercentage.Text + "</IgnorePercentage>";

if (chkTCMP.Checked)
Expand Down Expand Up @@ -791,5 +816,17 @@ private void tossHalfLife_ValueChanged(object sender, EventArgs e)
TossHalfLife = (int)tossHalfLifeInput.Value;
SaveSettings();
}

private void eyeMoveMinInput_ValueChanged(object sender, EventArgs e)
{
EyeMoveMin = (int)eyeMoveMinInput.Value;
SaveSettings();
}

private void eyeMoveMaxInput_ValueChanged(object sender, EventArgs e)
{
EyeMoveMax = (int)eyeMoveMaxInput.Value;
SaveSettings();
}
}
}
Loading