|
@@ -1,6 +1,7 @@
|
|
|
using System;
|
|
|
using Emgu.CV;
|
|
|
using Emgu.CV.Structure;
|
|
|
+using System.Timers;
|
|
|
using System.Threading;
|
|
|
|
|
|
namespace BBIWARG.Input.InputProviding
|
|
@@ -49,15 +50,26 @@ namespace BBIWARG.Input.InputProviding
|
|
|
|
|
|
public UInt16 lowConfidenceValue;
|
|
|
private AppDomain domain;
|
|
|
+ private System.Threading.Timer watchdogTimer;
|
|
|
|
|
|
public void initialize()
|
|
|
{
|
|
|
CurrentFrameID = 0;
|
|
|
+
|
|
|
+ watchdogTimer = new System.Threading.Timer(Timer_Elapsed, null, 1000, 1000);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Timer_Elapsed(object state)
|
|
|
+ {
|
|
|
+ checkExitErrorstate();
|
|
|
+
|
|
|
+ if (wrapper != null)
|
|
|
+ wrapper.errorstate = true;
|
|
|
}
|
|
|
|
|
|
public void start()
|
|
|
{
|
|
|
- domain = System.AppDomain.CreateDomain("IntelSucks");
|
|
|
+ domain = System.AppDomain.CreateDomain(System.Guid.NewGuid().ToString());
|
|
|
|
|
|
wrapper = (IntelCameraWrapper) domain.CreateInstanceAndUnwrap(typeof(IntelCameraWrapper).Assembly.GetName().ToString(), typeof(IntelCameraWrapper).FullName);
|
|
|
wrapper.init(this);
|
|
@@ -72,17 +84,30 @@ namespace BBIWARG.Input.InputProviding
|
|
|
|
|
|
wrapper.run();
|
|
|
|
|
|
- if (wrapper.errorstate) {
|
|
|
+ checkExitErrorstate();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkExitErrorstate()
|
|
|
+ {
|
|
|
+ if (wrapper.errorstate)
|
|
|
+ {
|
|
|
//we have crashed. Kill the app domain and try again.
|
|
|
Console.WriteLine("Killing AppDomain...");
|
|
|
- System.AppDomain.Unload(domain);
|
|
|
- Thread.Sleep(5000);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ System.AppDomain.Unload(domain);
|
|
|
+ Thread.Sleep(5000);
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ Console.WriteLine("Could not unload app domain... Still trying to start again...");
|
|
|
+ }
|
|
|
+
|
|
|
Console.WriteLine("Starting again...");
|
|
|
start();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public void stop()
|
|
|
{
|
|
|
IsActive = false;
|