You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
4.0 KiB
112 lines
4.0 KiB
using Newtonsoft.Json;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
public class DongleProperties
|
|
{
|
|
public string serialnumber = "";
|
|
public Dictionary<string, string> properties = new Dictionary<string, string>();
|
|
}
|
|
public class Dongle
|
|
{
|
|
public class App
|
|
{
|
|
public static string PROJ_MAPPING = "proj-mapping";
|
|
public static string GRAYCODE = "graycode";
|
|
public static string CAM_CAL = "cam-cal";
|
|
public static string DEV_CAL = "dev-cal";
|
|
public static string PROJ_CAL = "proj-cal";
|
|
public static string DEV_PROJ_CAL = "dev-proj-cal";
|
|
public static string CCV = "ccv";
|
|
public static string AUTO_PRINT = "autoprint";
|
|
public static string SPACE_CAL = "spacecal";
|
|
public static string SEC_BODY = "sec-body";
|
|
public static string LEAP_CAL = "leap-cal";
|
|
public static string GIGE2SPOUT = "gige2spout";
|
|
public static string KINECT2_BG = "k2-bg";
|
|
public static string OSCFirmata = "oscfirmata";
|
|
public static string KINECT2_TOUCH = "k2-touch";
|
|
}
|
|
static string execute(string filePath, string arguments = "")
|
|
{
|
|
Process myProcess = new Process();
|
|
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
|
myProcess.StartInfo.WorkingDirectory = Directory.GetParent(filePath).ToString();
|
|
myProcess.StartInfo.CreateNoWindow = true;
|
|
myProcess.StartInfo.UseShellExecute = false;
|
|
myProcess.StartInfo.FileName = filePath;
|
|
myProcess.StartInfo.RedirectStandardOutput = true;
|
|
myProcess.StartInfo.Arguments = arguments;
|
|
//myProcess.StartInfo.StandardOutputEncoding = Encoding.GetEncoding(950);
|
|
|
|
myProcess.EnableRaisingEvents = true;
|
|
if (myProcess.Start() == false)
|
|
{
|
|
UnityEngine.Debug.LogWarning("Dongle process start fail");
|
|
}
|
|
string output = myProcess.StandardOutput.ReadToEnd();
|
|
myProcess.WaitForExit();
|
|
return output;
|
|
}
|
|
static JsonSerializerSettings jsonSettings
|
|
{
|
|
get
|
|
{
|
|
JsonSerializerSettings setting = new JsonSerializerSettings();
|
|
setting.MissingMemberHandling = MissingMemberHandling.Ignore;
|
|
setting.DefaultValueHandling = DefaultValueHandling.Include;
|
|
setting.NullValueHandling = NullValueHandling.Ignore;
|
|
return setting;
|
|
}
|
|
}
|
|
static Dongle()
|
|
{
|
|
try
|
|
{
|
|
//DongleProperties prop = new DongleProperties();
|
|
|
|
string dotKeyJson = execute(@"bin\ucDongleKeyLoader.exe", "json");
|
|
//print(dotKeyJson);
|
|
valid_dongles = JsonConvert.DeserializeObject<List<DongleProperties>>(dotKeyJson, jsonSettings);
|
|
//print("popList.Count = " + valid_dongles.Count);
|
|
|
|
string dongleIDJson = execute(@"bin\DongleID.exe");
|
|
//print(dongleIDJson);
|
|
current_dongles = JsonConvert.DeserializeObject<List<string>>(dongleIDJson, jsonSettings);
|
|
//print("serialNumbers.Count = " + current_dongles.Count);
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
}
|
|
static List<DongleProperties> valid_dongles = new List<DongleProperties>();
|
|
static List<string> current_dongles = new List<string>();
|
|
|
|
public static DongleProperties find_properties(string app_name)
|
|
{
|
|
try
|
|
{
|
|
foreach (DongleProperties valid_dongle in valid_dongles)
|
|
{
|
|
foreach (string current_dongle in current_dongles)
|
|
{
|
|
if (valid_dongle.serialnumber == current_dongle && valid_dongle.properties.ContainsKey(app_name) && valid_dongle.properties[app_name] != "FALSE")
|
|
{
|
|
return valid_dongle;
|
|
}
|
|
}
|
|
}
|
|
}catch
|
|
{
|
|
|
|
}
|
|
return null;
|
|
}
|
|
public static bool is_valid(string app_name)
|
|
{
|
|
return find_properties(app_name) != null;
|
|
}
|
|
}
|
|
|